Mercurial > mm7
diff mm7_2.cpp @ 916:897b10712a1a
UIShop_Buy_Identify_Repair little clean and rename
author | Ritor1 |
---|---|
date | Thu, 25 Apr 2013 17:37:00 +0600 |
parents | a8a3efd631de |
children | 34ed2d5e7cfb |
line wrap: on
line diff
--- a/mm7_2.cpp Tue Apr 23 09:18:22 2013 +0600 +++ b/mm7_2.cpp Thu Apr 25 17:37:00 2013 +0600 @@ -890,91 +890,28 @@ //----- (004BDB56) -------------------------------------------------------- void __cdecl UIShop_Buy_Identify_Repair() { - Player *v0; // edi@1 - signed int v1; // esi@9 - unsigned int v2; // eax@11 - int v3; // esi@12 - float v4; // ST1C_4@12 - signed int v5; // eax@12 - signed int v6; // eax@12 - char v7; // zf@12 int v8; // eax@15 - const char *v9; // ecx@15 - signed int v10; // esi@18 - unsigned int v11; // esi@20 - int v12; // esi@21 - void *v13; // ecx@26 - signed int v14; // esi@31 + unsigned int pItemID; // esi@20 + ItemGen *item; // esi@21 unsigned int v15; // eax@33 - GUIWindow *v16; // esi@34 - POINT *v17; // esi@37 + POINT *pCursorPos; // esi@37 int v18; // ecx@37 - void *v19; // eax@38 - ItemGen *v20; // esi@38 - float v21; // ST1C_4@38 - signed int v22; // eax@38 - int v23; // ebx@38 - int v24; // edx@39 - int v25; // eax@40 - int v26; // ebx@41 - Player *v27; // ecx@43 - POINT *v28; // esi@49 - int v29; // ecx@49 - void *v30; // eax@50 - int v31; // ecx@50 - ItemGen *v32; // esi@51 - //float v33; // ST1C_4@53 - //signed int v34; // eax@53 - //int v35; // eax@53 - //bool v36; // eax@53 - unsigned int v37; // eax@53 - int v38; // eax@55 + float pPriceMultiplier; // ST1C_4@38 + int taken_item; // eax@40 + ItemGen *bought_item; // esi@51 + int party_reputation; // eax@55 int v39; // eax@63 - //int v40; // eax@64 - int v41; // edx@66 int v42; // esi@74 signed int v43; // ebx@74 - int v44; // ecx@74 unsigned __int16 *pSkill; // esi@77 - signed int v46; // [sp-18h] [bp-CCh]@36 - unsigned int v47; // [sp-14h] [bp-C8h]@36 - signed int v48; // [sp-10h] [bp-C4h]@36 - signed int v49; // [sp-Ch] [bp-C0h]@36 - int v50; // [sp-8h] [bp-BCh]@36 - int v51; // [sp-4h] [bp-B8h]@28 - unsigned int v52; // [sp-4h] [bp-B8h]@36 - int v53; // [sp+0h] [bp-B4h]@16 - unsigned int v54; // [sp+0h] [bp-B4h]@25 int v55; // [sp+0h] [bp-B4h]@26 - int v56; // [sp+0h] [bp-B4h]@36 - //POINT v57; // [sp+10h] [bp-A4h]@49 - //POINT v58; // [sp+18h] [bp-9Ch]@18 - POINT v59; // [sp+20h] [bp-94h]@49 - POINT v60; // [sp+28h] [bp-8Ch]@9 - POINT v61; // [sp+30h] [bp-84h]@37 - POINT v62; // [sp+38h] [bp-7Ch]@18 - POINT v63; // [sp+40h] [bp-74h]@37 - //POINT v64; // [sp+48h] [bp-6Ch]@19 - POINT v65; // [sp+50h] [bp-64h]@32 - //POINT v66; // [sp+58h] [bp-5Ch]@18 - POINT v67; // [sp+60h] [bp-54h]@31 - POINT a2; // [sp+68h] [bp-4Ch]@9 - POINT v69; // [sp+70h] [bp-44h]@31 - POINT v70; // [sp+78h] [bp-3Ch]@9 - POINT v71; // [sp+80h] [bp-34h]@31 - POINT v72; // [sp+88h] [bp-2Ch]@10 - //bool v73; // [sp+90h] [bp-24h]@53 - int v74; // [sp+94h] [bp-20h]@53 + POINT cursor; // [sp+40h] [bp-74h]@37 int a6; // [sp+98h] [bp-1Ch]@57 int a3; // [sp+9Ch] [bp-18h]@53 - //Player *v77; // [sp+A0h] [bp-14h]@1 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 unsigned int v79; // [sp+A8h] [bp-Ch]@9 - int v80; // [sp+ACh] [bp-8h]@12 - ItemGen *_this; // [sp+B0h] [bp-4h]@13 - - v0 = pPlayers[uActiveCharacter]; - //v77 = pPlayers[uActiveCharacter]; + int uPriceItemService; // [sp+ACh] [bp-8h]@12 + if ( pCurrentScreen == SCREEN_E ) { sub_421EA6_OnInventoryLeftClick(); @@ -996,34 +933,29 @@ } case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: { - v17 = pMouse->GetCursorPos(&v63); - v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF; + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; if ( !v18 ) return; - v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); - v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - _this = v20; - v22 = v20->GetValue(); - v23 = pPlayers[uActiveCharacter]->GetBuyingPrice(v22, v21); - v80 = v23; + bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); + pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); GetAsyncKeyState(VK_CONTROL); - if ( pParty->uNumGold < v23 ) - { - v24 = 2; - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24); + if ( pParty->uNumGold < uPriceItemService ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); return; } - v25 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v20->uItemID); - if ( v25 ) - { - v26 = 1; - v20->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v25-1], v20, 0x24u); - dword_F8B1E4 = v26; - Party::TakeGold(v80); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + taken_item = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); + if ( taken_item ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; @@ -1034,17 +966,15 @@ } case HOUSE_DIALOGUE_SHOP_SELL: { - v14 = pMouse->GetCursorPos(&v71)->x - 14; - v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&v67)->x <= 13 - || pMouse->GetCursorPos(&v65)->x >= 462 + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x <= 13 + || pMouse->GetCursorPos(&cursor)->x >= 462 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) return; - v16 = window_SpeakInHouse; - if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) ) + if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) { dword_F8B1E4 = 1; - pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)v16->ptr_1C); + pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); viewparams->bRedrawGameUI = 1; pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); @@ -1056,33 +986,29 @@ } case HOUSE_DIALOGUE_SHOP_IDENTIFY: { - pMouse->GetCursorPos(&v62); - v10 = v62.x - 14; - v79 = (v10 >> 5) + 14 * ((v62.y - 17) >> 5); - if (v62.x > 13 && v62.x < 462) - { - v11 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); - if ( v11 ) - { - //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]); - v80 = pPlayers[uActiveCharacter]->_4B8179(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); - v12 = (int)&pPlayers[uActiveCharacter]->pInventoryItems[v11-1]; - if ( !(*(char *)(v12 + 20) & 1) ) - { - _this = (ItemGen *)window_SpeakInHouse->ptr_1C; - if ( MerchandiseTest((ItemGen *)v12, (int)_this) ) + pMouse->GetCursorPos(&cursor); + v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); + if (cursor.x > 13 && cursor.x < 462) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + if ( !(item->uAttributes & 1) ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { - if ( pParty->uNumGold >= v80 ) + if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; - Party::TakeGold(v80); - *(int *)(v12 + 20) |= 1u; + Party::TakeGold(uPriceItemService); + item->uAttributes |= 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); - v9 = pGlobalTXT_LocalizationStrings[569]; - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); return; } - PlayHouseSound((unsigned int)_this, (HouseSoundID)2); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); @@ -1097,41 +1023,34 @@ } case HOUSE_DIALOGUE_SHOP_REPAIR: { - v1 = pMouse->GetCursorPos(&a2)->x - 14; - v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&v60)->x > 13 ) - { - if ( pMouse->GetCursorPos(&v72)->x < 462 ) - { - v2 = v0->GetItemIDAtInventoryIndex((int *)&v79); - if ( v2 ) - { - v3 = (int)&v0->pInventoryItems[v2-1]; - //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]; - v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1]; - v5 = _v->GetValue(); - v6 = pPlayers[uActiveCharacter]->_4B81C3(v5, v4); - v7 = (*(char *)(v3 + 20) & 2) == 0; - v80 = v6; - if ( !v7 ) + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x > 13 ) + { + if ( pMouse->GetCursorPos(&cursor)->x < 462 ) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); + if ( item->uAttributes & 2 ) { - _this = (ItemGen *)window_SpeakInHouse->ptr_1C; - if ( MerchandiseTest((ItemGen *)v3, (int)_this) ) + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { - if ( pParty->uNumGold >= v80 ) + if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; - Party::TakeGold(v80); - v8 = *(int *)(v3 + 20); + Party::TakeGold(uPriceItemService); + v8 = item->uAttributes; LOBYTE(v8) = v8 & 0xFD; - *(int *)(v3 + 20) = v8 | 1; + item->uAttributes = v8 | 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); - v9 = pGlobalTXT_LocalizationStrings[570]; - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); return; } - PlayHouseSound((unsigned int)_this, (HouseSoundID)2); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); @@ -1148,42 +1067,25 @@ case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { - v28 = pMouse->GetCursorPos(&v59); - v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[v28->y]] & 0xFFFF; - if ( !v29 ) + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; + if ( !v18 ) return; - v30 = window_SpeakInHouse->ptr_1C; - // v31 = 9 * (v29 - 1 + 12 * (int)v30); if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - { - v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1]; - _this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1]; - } + bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; else - { - _this =&pParty->SpecialItemsInShops[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724]; - v32 = &pParty->SpecialItemsInShops[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; - } - //v33 = p2DEvents_minus1__20[13 * (signed int)v30]; - //v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier; - //v34 = v32->GetValue(); - v80 = pPlayers[uActiveCharacter]->GetBuyingPrice(v32->GetValue(), p2DEvents[(unsigned int)v30 - 1].fPriceMultiplier); - //LOWORD(v35) = GetAsyncKeyState(VK_CONTROL); - v74 = GetAsyncKeyState(VK_CONTROL); - //v36 = v0->CanSteal(); + bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); uNumSeconds = 0; a3 = 0; - //v73 = v0->CanSteal(); - v37 = pMapStats->GetMapInfo(pCurrentMapName); - if ( v37 ) - a3 = pMapStats->pInfos[v37]._steal_perm; - v38 = GetPartyReputation(); - v26 = 1; + if ( pMapStats->GetMapInfo(pCurrentMapName) ) + a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm; + party_reputation = GetPartyReputation(); if (pPlayers[uActiveCharacter]->CanSteal()) { - if ( v74 ) - { - uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(v32, a3, v38, 0, &a6); + if ( GetAsyncKeyState(VK_CONTROL) ) + { + uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); if ( !uNumSeconds ) { sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); @@ -1191,56 +1093,49 @@ } } } - if ( pParty->uNumGold < v80 ) - { - v24 = 2; + if ( pParty->uNumGold < uPriceItemService ) + { if ( uNumSeconds != 2 ) { if ( uNumSeconds != 1 ) { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" return; } } } - v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v32->uItemID); + v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); if ( v39 ) { - v32->SetIdentified(); - v7 = pPlayers[uActiveCharacter]->CanSteal(); - //v40 = (int)((char *)v0 + 36 * v39); - //memcpy((void *)(v40 + 496), v32, 0x24u); - memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen)); - if ( v7 ) - { - if ( v74 ) - { - v41 = uNumSeconds; + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); + if ( pPlayers[uActiveCharacter]->CanSteal() ) + { + if ( GetAsyncKeyState(VK_CONTROL) ) + { if ( uNumSeconds == 1 || uNumSeconds == 2 ) { - //*(char *)(v40 + 517) |= 1u; pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen(); - sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } } } - dword_F8B1E4 = v26; - Party::TakeGold(v80); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" break; } default:// if click video screen in shop @@ -1251,15 +1146,15 @@ v42 = dialog_menu_id - 36; //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); - v44 = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; - if ( v44 < v43 / 3 ) - v44 = v43 / 3; + uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( uPriceItemService < v43 / 3 ) + uPriceItemService = v43 / 3; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) { pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; if ( !*pSkill ) { - if ( pParty->uNumGold < v44 ) + if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" if ( in_current_building_type == BildingType_Training ) @@ -1269,7 +1164,7 @@ PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); return; } - Party::TakeGold(v44); + Party::TakeGold(uPriceItemService); dword_F8B1E4 = 1; *pSkill = 1; pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); @@ -9466,7 +9361,7 @@ int v1; // ecx@1 unsigned int v2; // edi@1 unsigned int v3; // edx@4 - unsigned int v4; // esi@5 + unsigned int pSkillType; // esi@5 unsigned __int16 v5; // ax@7 unsigned int v6; // edi@19 int v7; // esi@27 @@ -9508,24 +9403,24 @@ unsigned int v50; // [sp+38h] [bp-14h]@50 int v51; // [sp+3Ch] [bp-10h]@1 unsigned int v52; // [sp+40h] [bp-Ch]@5 - int v53; // [sp+44h] [bp-8h]@1 - unsigned int v54; // [sp+48h] [bp-4h]@1 + //int v53; // [sp+44h] [bp-8h]@1 + //unsigned int v54; // [sp+48h] [bp-4h]@1 v51 = 0; _this.Reset(); //v0 = pPlayers[uActiveCharacter]; v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; - v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; - v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uEquipType == 1 ) + //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v53 = v1; + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) v51 = v1; v3 = pParty->pPickedItem.uItemID; if ( pParty->pPickedItem.uItemID ) { v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; - v4 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; - if ( v4 == 4 ) + pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; + if ( pSkillType == 4 ) { if ( v2 ) { @@ -9540,7 +9435,7 @@ } else { - if ( (v4 == 8 || v4 == 1 || v4 == 2) + if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) && v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) { @@ -9575,7 +9470,7 @@ case 8u: case 9u: case 0xBu: - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; @@ -9637,21 +9532,21 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v54 ) - { - --v54; + if ( v2 ) + { + --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54); + v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); *(char *)(v12 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v12 + 532)); _this.uBodyAnchor = 1; - v13 = v54 + 1; + v13 = v2 + 1; v14 = v51 == 0; memcpy((void *)(v12 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v13; @@ -9673,7 +9568,7 @@ return; } memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v53 - 1)); + v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); *(char *)(v15 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v15 + 532)); @@ -9693,14 +9588,14 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } v50 = 0; - if ( v4 == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) - || v4 == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) + if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) + || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) { if (pAsyncMouse) { @@ -9717,16 +9612,16 @@ { if ( !v51 ) { - if ( v54 ) + if ( v2 ) { - --v54; + --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54); + v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); *(char *)(v20 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v20 + 532)); _this.uBodyAnchor = 1; - v21 = v54 + 1; + v21 = v2 + 1; v14 = v52 == 12; memcpy((void *)(v20 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v21; @@ -9737,9 +9632,7 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } @@ -9758,14 +9651,13 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } } } - if ( !v53 ) + if ( !v1 ) { v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); if ( (v26 & 0x80000000u) != 0 ) @@ -9782,20 +9674,18 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } - --v53; + --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53); + v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); *(char *)(v24 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v24 + 532)); _this.uBodyAnchor = 2; - v25 = v53 + 1; + v25 = v1 + 1; v14 = v52 == 12; memcpy((void *)(v24 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; @@ -9806,9 +9696,7 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; case 1u: @@ -9817,26 +9705,26 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v53 ) - { - if ( v54 ) + if ( v1 ) + { + if ( v2 ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - --v53; + --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53); + v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); *(char *)(v27 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v27 + 532)); _this.uBodyAnchor = 2; - v28 = v53 + 1; + v28 = v1 + 1; memcpy((void *)(v27 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; } @@ -9845,10 +9733,10 @@ v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); if ( (v52 & 0x80000000u) == 0 ) { - if ( v54 ) + if ( v2 ) { memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v54 - 1)); + v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); *(char *)(v29 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v29 + 532)); @@ -9936,7 +9824,7 @@ v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; if ( v35 ) { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35-1]; + auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; pParty->SetHoldingItem(_a); _a->Reset(); pPlayers[uActiveCharacter]->pEquipment.uBow = 0;