Mercurial > mm7
comparison Chest.cpp @ 2268:fd788d2e9585
EventProcessor cleaned and ODM_NearClip fix
author | Ritor1 |
---|---|
date | Sun, 09 Mar 2014 22:39:59 +0600 |
parents | 47b87aea14ba |
children | 9551756f46c4 |
comparison
equal
deleted
inserted
replaced
2267:6532bbac1a9e | 2268:fd788d2e9585 |
---|---|
300 chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; | 300 chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; |
301 item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE); | 301 item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE); |
302 item_texture = pIcons_LOD->GetTexture(item_texture_id); | 302 item_texture = pIcons_LOD->GetTexture(item_texture_id); |
303 v6 = item_texture->uTextureWidth; | 303 v6 = item_texture->uTextureWidth; |
304 if ( v6 < 14 ) | 304 if ( v6 < 14 ) |
305 v6 = 14; | 305 v6 = 14; |
306 texture_cell_width = ((v6 - 14) >> 5) + 1; | 306 texture_cell_width = ((v6 - 14) >> 5) + 1; |
307 v8 = item_texture->uTextureHeight; | 307 v8 = item_texture->uTextureHeight; |
308 if ( v8 < 14 ) | 308 if ( v8 < 14 ) |
309 v8 = 14; | 309 v8 = 14; |
310 texture_cell_height = ((v8 - 14) >> 5) + 1; | 310 texture_cell_height = ((v8 - 14) >> 5) + 1; |
311 if ( !areWeLoadingTexture ) | 311 if ( !areWeLoadingTexture ) |
312 { | 312 { |
313 item_texture->Release(); | 313 item_texture->Release(); |
314 pIcons_LOD->SyncLoadedFilesCount(); | 314 pIcons_LOD->SyncLoadedFilesCount(); |
315 } | 315 } |
316 if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && | 316 if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && |
317 (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) ) | 317 (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) ) |
318 { //we not put over borders | 318 { //we not put over borders |
319 _row = 0; | 319 _row = 0; |
320 if ( texture_cell_height <= 0 ) | 320 if ( texture_cell_height <= 0 ) |
321 return true; | 321 return true; |
322 _cell_rows = 0; | 322 _cell_rows = 0; |
323 while ( 1 ) | 323 while ( 1 ) |
324 { | 324 { |
325 _column = 0; | 325 _column = 0; |
326 if ( texture_cell_width > 0 ) | 326 if ( texture_cell_width > 0 ) |
327 { | 327 { |
328 while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0) | 328 while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0) |
329 { | 329 { |
369 return item_count; | 369 return item_count; |
370 } | 370 } |
371 | 371 |
372 //----- (0041FFA2) -------------------------------------------------------- | 372 //----- (0041FFA2) -------------------------------------------------------- |
373 int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID) | 373 int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID) |
374 { | 374 {//(rus: положить предмет в ящик) |
375 ItemGen *v4; // edi@1 | 375 ItemGen *v4; // edi@1 |
376 int v5; // esi@1 | 376 int v5; // esi@1 |
377 int result; // eax@11 | 377 int result; // eax@11 |
378 unsigned int v7; // eax@12 | 378 unsigned int v7; // eax@12 |
379 int v8; // edx@12 | 379 int v8; // edx@12 |
569 } | 569 } |
570 // 420284: using guessed type char Dst[144]; | 570 // 420284: using guessed type char Dst[144]; |
571 | 571 |
572 //----- (00448A17) -------------------------------------------------------- | 572 //----- (00448A17) -------------------------------------------------------- |
573 void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle) | 573 void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle) |
574 { | 574 { |
575 unsigned __int16 *pFlags; // eax@3 | 575 if ( uChestID >= 0 && uChestID <= 19 ) |
576 | 576 { |
577 if ( uChestID >= 0 && uChestID <= 19 ) | 577 if ( bToggle ) |
578 { | 578 pChests[uChestID].uFlags |= uFlag; |
579 pFlags = &pChests[uChestID].uFlags; | 579 else |
580 if ( bToggle ) | 580 pChests[uChestID].uFlags &= ~uFlag; |
581 *pFlags |= uFlag; | 581 } |
582 else | 582 } |
583 *pFlags &= ~uFlag; | |
584 } | |
585 } | |
586 | 583 |
587 //----- (00458B03) -------------------------------------------------------- | 584 //----- (00458B03) -------------------------------------------------------- |
588 void ChestList::ToFile() | 585 void ChestList::ToFile() |
589 { | 586 { |
590 FILE *v2; // eax@1 | 587 FILE *v2; // eax@1 |
696 return 1; | 693 return 1; |
697 } | 694 } |
698 | 695 |
699 //----- (00420B13) -------------------------------------------------------- | 696 //----- (00420B13) -------------------------------------------------------- |
700 void __fastcall sub_420B13(int a1, int a2) | 697 void __fastcall sub_420B13(int a1, int a2) |
701 { | 698 { //Give item from chest(rus: Взять предмет из ящика) |
702 void *v2; // eax@1 | 699 void *v2; // eax@1 |
703 ItemGen *v3; // ebx@1 | |
704 unsigned int v4; // eax@1 | 700 unsigned int v4; // eax@1 |
705 Texture *texture; // ecx@1 | 701 Texture *texture; // ecx@1 |
706 signed int v6; // eax@1 | 702 signed int v6; // eax@1 |
707 signed int v7; // edi@3 | 703 signed int v7; // edi@3 |
708 signed int v8; // eax@3 | 704 signed int v8; // eax@3 |
714 unsigned __int8 v14; // cf@10 | 710 unsigned __int8 v14; // cf@10 |
715 int v15; // edi@10 | 711 int v15; // edi@10 |
716 int i; // ecx@10 | 712 int i; // ecx@10 |
717 int v17; // [sp+Ch] [bp-14h]@1 | 713 int v17; // [sp+Ch] [bp-14h]@1 |
718 int v18; // [sp+10h] [bp-10h]@3 | 714 int v18; // [sp+10h] [bp-10h]@3 |
719 int v19; // [sp+14h] [bp-Ch]@1 | |
720 int v20; // [sp+18h] [bp-8h]@1 | |
721 int v21; // [sp+1Ch] [bp-4h]@5 | 715 int v21; // [sp+1Ch] [bp-4h]@5 |
722 int v22; // [sp+1Ch] [bp-4h]@8 | 716 int v22; // [sp+1Ch] [bp-4h]@8 |
723 | 717 |
724 v19 = a2; | 718 v2 = (void *)(5324 * (int)pChestWindow->ptr_1C); |
725 v2 = pChestWindow->ptr_1C; | 719 v17 = pChestWidthsByType[pChests[(int)pChestWindow->ptr_1C].uChestBitmapID]; |
726 v20 = (int)v2; | 720 v4 = pIcons_LOD->LoadTexture(pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].GetIconName(), TEXTURE_16BIT_PALETTE); |
727 v2 = (void *)(5324 * (int)v2); | |
728 //v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); | |
729 v3 = &pChests[v20].igChestItems[a1]; | |
730 //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; | |
731 v17 = pChestWidthsByType[pChests[v20].uChestBitmapID]; | |
732 v4 = pIcons_LOD->LoadTexture(v3->GetIconName(), TEXTURE_16BIT_PALETTE); | |
733 texture = pIcons_LOD->GetTexture(v4); | 721 texture = pIcons_LOD->GetTexture(v4); |
734 | 722 |
735 v6 = texture->uTextureWidth; | 723 v6 = texture->uTextureWidth; |
736 if ( texture->uTextureWidth < 14 ) | 724 if ( texture->uTextureWidth < 14 ) |
737 v6 = 14; | 725 v6 = 14; |
742 v8 = texture->uTextureHeight; | 730 v8 = texture->uTextureHeight; |
743 if ( texture->uTextureHeight < 14 ) | 731 if ( texture->uTextureHeight < 14 ) |
744 v8 = 14; | 732 v8 = 14; |
745 v10 = ((v8 - 14) >> 5) + 1; | 733 v10 = ((v8 - 14) >> 5) + 1; |
746 v21 = v10; | 734 v21 = v10; |
735 | |
747 if ( !areWeLoadingTexture ) | 736 if ( !areWeLoadingTexture ) |
748 { | 737 { |
749 texture->Release(); | 738 texture->Release(); |
750 pIcons_LOD->SyncLoadedFilesCount(); | 739 pIcons_LOD->SyncLoadedFilesCount(); |
751 v10 = v21; | 740 v10 = v21; |
752 } | 741 } |
753 if ( v10 > 0 ) | 742 if ( v10 > 0 ) |
754 { | 743 { |
755 v11 = 0; | 744 v11 = 0; |
756 v22 = v10; | 745 for ( v22 = v10; v22; --v22 ) |
757 do | 746 { |
747 if ( v9 > 0 ) | |
758 { | 748 { |
759 if ( v9 > 0 ) | 749 v12 = v9; |
760 { | 750 v13 = &pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11]; |
761 v12 = v9; | 751 v14 = v12 & 1; |
762 //v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; | 752 v12 >>= 1; |
763 v13 = &pChests[v20].pInventoryIndices[v19 + v11]; | 753 memset(&pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11], 0, 4 * v12); |
764 v14 = v12 & 1; | 754 v15 = (int)((char *)v13 + 4 * v12); |
765 v12 >>= 1; | 755 for ( i = v14; i; --i ) |
766 memset(v13, 0, 4 * v12); | 756 { |
767 v15 = (int)((char *)v13 + 4 * v12); | 757 *(short *)v15 = 0; |
768 for ( i = v14; i; --i ) | 758 v15 += 2; |
769 { | 759 } |
770 *(short *)v15 = 0; | 760 v9 = v18; |
771 v15 += 2; | |
772 } | |
773 v9 = v18; | |
774 } | |
775 v11 += v17; | |
776 --v22; | |
777 } | 761 } |
778 while ( v22 ); | 762 v11 += v17; |
779 } | 763 } |
780 v3->Reset(); | 764 } |
765 pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].Reset(); | |
781 } | 766 } |
782 // 506128: using guessed type int areWeLoadingTexture; | 767 // 506128: using guessed type int areWeLoadingTexture; |
783 //----- (00420E01) -------------------------------------------------------- | 768 //----- (00420E01) -------------------------------------------------------- |
784 void OnChestLeftClick() | 769 void OnChestLeftClick() |
785 { | 770 { |
786 int chest_id; // edi@1 | |
787 POINT *v1; // esi@2 | |
788 int v2; // eax@2 | 771 int v2; // eax@2 |
789 int v3; // ebx@4 | 772 int v3; // ebx@4 |
790 int v4; // esi@6 | 773 int v4; // esi@6 |
791 int v5; // ecx@6 | 774 POINT cursor; // [sp+84h] [bp-8h]@2 |
792 //SpriteObject v6; // [sp+Ch] [bp-80h]@1 | |
793 POINT v7; // [sp+7Ch] [bp-10h]@2 | |
794 POINT a2; // [sp+84h] [bp-8h]@2 | |
795 | 775 |
796 SpriteObject v6; // [sp+Ch] [bp-80h]@1 | 776 SpriteObject v6; // [sp+Ch] [bp-80h]@1 |
797 //SpriteObject::SpriteObject(&v6); | |
798 | |
799 chest_id = pGUIWindow_CurrentMenu->par1C; | |
800 if ( pParty->pPickedItem.uItemID ) | 777 if ( pParty->pPickedItem.uItemID ) |
801 { | 778 { |
802 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) | 779 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) |
803 pMouse->RemoveHoldingItem(); | 780 pMouse->RemoveHoldingItem(); |
804 } | 781 } |
805 else | 782 else |
806 { | 783 { |
807 v1 = pMouse->GetCursorPos(&a2); | 784 pMouse->GetCursorPos(&cursor); |
808 v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF; | 785 v2 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; |
809 if ( v2 ) | 786 if ( v2 ) |
810 { | 787 { |
811 if ( v2 ) | 788 if ( v2 ) |
812 v3 = v2 - 1; | 789 v3 = v2 - 1; |
813 else | 790 else |
814 v3 = -1; | 791 v3 = -1; |
815 v4 = pChests[chest_id].pInventoryIndices[v3] - 1; | 792 v4 = pChests[(int)pGUIWindow_CurrentMenu->par1C].pInventoryIndices[v3] - 1; |
816 if ( pChests[chest_id].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) | 793 if ( pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) |
817 { | 794 { |
818 pParty->PartyFindsGold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); | 795 pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].uSpecEnchantmentType, 0); |
819 viewparams->bRedrawGameUI = 1; | 796 viewparams->bRedrawGameUI = 1; |
820 } | 797 } |
821 else | 798 else |
822 pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); | 799 pParty->SetHoldingItem(&pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4]); |
823 sub_420B13(v4, v3); | 800 sub_420B13(v4, v3); |
824 } | 801 } |
825 } | 802 } |
826 } | 803 } |