Mercurial > mm7
changeset 526:214d9d47cf1f
Chest working, but items are not laid correctly
author | Gloval |
---|---|
date | Sun, 03 Mar 2013 01:55:57 +0400 |
parents | e7b3fa10d58d |
children | 661f1932d971 b1598f110b07 8e34868c8069 |
files | Actor.cpp Actor.h Chest.cpp Chest.h GUIWindow.cpp Items.cpp Items.h mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h |
diffstat | 14 files changed, 411 insertions(+), 469 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/Actor.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -94,14 +94,14 @@ } //----- (004485A7) -------------------------------------------------------- -void Actor::GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive) +void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) { unsigned int v3; // eax@3 char *v4; // ecx@3 - unsigned int *v5; // eax@8 + int *v5; // eax@8 ItemGen *v6; // ecx@12 - if ( (uActorID & 0x80000000u) == 0 && (signed int)uActorID <= (signed int)(uNumActors - 1) ) + if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) { v3 = uActorID; v4 = (char *)&pActors[uActorID].uCarriedItemID;
--- a/Actor.h Sat Mar 02 15:38:49 2013 +0400 +++ b/Actor.h Sun Mar 03 01:55:57 2013 +0400 @@ -229,7 +229,7 @@ static void AggroSurroundingPeasants(unsigned int uActorID, int a2); static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID); - static void GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive); + static void GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive); static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle); static void ApplyFineForKillingPeasant(unsigned int uActorID); static void DrawHealthBar(Actor *a1, struct GUIWindow *a2);
--- a/Chest.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/Chest.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -29,12 +29,15 @@ Chest pChests[20]; - +const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42}; +const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34}; +const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; +const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; //----- (0042041E) -------------------------------------------------------- -bool Chest::Open(unsigned int uChestID) -{ +bool Chest::Open( signed int uChestID ) + { //char *v1; // edi@5 unsigned int v2; // eax@8 GUIWindow *v3; // eax@15 @@ -79,7 +82,9 @@ //a4 = uChestID; assert(uChestID < 20); - auto chest = pChests + uChestID; + if ((uChestID <0)&&(uChestID >=20) ) + return false; + auto chest = &pChests[uChestID]; ++pIcons_LOD->uTexturePacksCount; if (!pIcons_LOD->uNumPrevLoadedFiles) @@ -89,7 +94,7 @@ //v1 = (char *)&pChests[uChestID].uFlags; //v34 = v1; if (!chest->Initialized()) - Chest::_420284(uChestID); + Chest::PlaceItems(uChestID); if ( !uActiveCharacter ) return 0; @@ -233,22 +238,11 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); } dword_507CD8 = 0; - v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0); - pGUIWindow_CurrentMenu = v3; - pChestWindow = v3; - pBtn_ExitCancel = v3->CreateButton( - 0x1D7u, - 0x1BDu, - 0xA9u, - 0x23u, - 1, - 0, - 0x71u, - 0, - 0, - pGlobalTXT_LocalizationStrings[79],// Exit - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), - 0); + + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0); + pChestWindow = pGUIWindow_CurrentMenu; + pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79],// Exit + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); @@ -257,188 +251,165 @@ //----- (0042092D) -------------------------------------------------------- void Chest::DrawChestUI(unsigned int uChestID) -{ - Render *v1; // edi@1 - unsigned int v2; // ebx@1 - unsigned int v3; // ebx@1 - int v4; // eax@1 - unsigned int v5; // eax@1 - int v6; // ecx@3 - unsigned int v7; // eax@4 - Texture *v8; // esi@4 - signed int v9; // ecx@4 - signed int v10; // edx@4 - signed int v11; // eax@4 - int v12; // eax@6 - int v13; // eax@6 - unsigned int v14; // ST34_4@8 - int v15; // edi@8 - int *v16; // [sp+Ch] [bp-28h]@1 - int v17; // [sp+10h] [bp-24h]@4 - int v18; // [sp+14h] [bp-20h]@1 - signed int v19; // [sp+18h] [bp-1Ch]@1 - int v20; // [sp+1Ch] [bp-18h]@1 - signed int v21; // [sp+20h] [bp-14h]@1 - char *v22; // [sp+2Ch] [bp-8h]@2 - signed int v23; // [sp+30h] [bp-4h]@1 + { + + int chestBitmapId; // eax@1 + unsigned int v5; // eax@1 + int chest_item_index; // ecx@3 + unsigned int item_texture_id; // eax@4 + Texture *item_texture; // esi@4 + signed int itemPixelWidth; // ecx@4 + signed int itemPixelHeght; // edx@4 + signed int v11; // eax@4 + int v12; // eax@6 + int v13; // eax@6 + unsigned int itemPixelPosX; // ST34_4@8 + int itemPixelPosY; // edi@8 + int *v16; // [sp+Ch] [bp-28h]@1 + int v17; // [sp+10h] [bp-24h]@4 + int chest_offs_y; // [sp+14h] [bp-20h]@1 + signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1 + int chest_offs_x; // [sp+1Ch] [bp-18h]@1 + signed int chestWidthCells; // [sp+20h] [bp-14h]@1 + signed int cells_counter; // [sp+30h] [bp-4h]@1 - v1 = pRenderer; - v2 = uChestID; - v16 = pRenderer->pActiveZBuffer; - pRenderer->ClearZBuffer(0, 479); - v3 = v2; - v4 = pChests[v3].uChestBitmapID; - v20 = pChestSmthn1ByType[v4]; - v18 = pChestSmthn2ByType[v4]; - v21 = pChestWidthsByType[v4]; - v19 = pChestHeightsByType[v4]; - sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID); - v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); - v23 = 0; - if ( v21 * v19 > 0 ) - { - v22 = (char *)pChests[v3].pInventoryIndices; - do - { - v6 = *(short *)v22; - if ( v6 > 0 ) - { - v17 = v18 + 32 * v23 / v19; - v7 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, - TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26); - v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v11 = 14; - v12 = v11 - 14; - LOBYTE(v12) = v12 & 0xE0; - v13 = v12 + 32; - if ( (signed int)v8->uTextureHeight < 14 ) - v10 = 14; - v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1); - v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1); - pRenderer->DrawTextureTransparent( - v14, - v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1), - v8); - sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1); - v1 = pRenderer; - } - ++v23; - v22 += 2; + v16 = pRenderer->pActiveZBuffer; + pRenderer->ClearZBuffer(0, 479); + chestBitmapId = pChests[uChestID].uChestBitmapID; + chest_offs_x = pChestPixelOffsetX[chestBitmapId]; + chest_offs_y = pChestPixelOffsetY[chestBitmapId]; + chestWidthCells = pChestWidthsByType[chestBitmapId]; + chestHeghtCells = pChestHeightsByType[chestBitmapId]; + sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); + v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); + + for (cells_counter = 0; cells_counter< chestWidthCells * chestHeghtCells; ++cells_counter) + { + chest_item_index = pChests[uChestID].pInventoryIndices[cells_counter]; + if ( chest_item_index > 0 ) + { + item_texture_id = pIcons_LOD->LoadTexture( + //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, + pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE); + item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0); + itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24); + itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26); + if ( itemPixelWidth < 14 ) + itemPixelWidth = 14; + v12 = itemPixelWidth - 14; + v12 = v12 & 0xFFFFFFE0; + v13 = v12 + 32; + if ( itemPixelHeght < 14 ) + itemPixelHeght = 14; + itemPixelPosX = chest_offs_x + (32 * cells_counter) % chestWidthCells + ((v13 - itemPixelWidth) >> 1); + itemPixelPosY = chest_offs_y + (32 * cells_counter) / chestHeghtCells + + ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1); + pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture); + sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, cells_counter + 1); + } + } + pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } - while ( v23 < v21 * v19 ); - } - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); -} //----- (0041FE71) -------------------------------------------------------- -int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID) -{ - int v3; // eax@1 - unsigned int v4; // eax@1 - Texture *v5; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // ebx@5 - int v11; // esi@9 - int v12; // edx@10 - int v13; // ecx@11 - char *v14; // eax@12 - int v16; // [sp+Ch] [bp-Ch]@1 - signed int v17; // [sp+10h] [bp-8h]@1 - signed int v18; // [sp+14h] [bp-4h]@1 +bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, unsigned int uChestID ) + { + int v3; // eax@1 + unsigned int item_texture_id; // eax@1 + Texture *item_texture; // ecx@1 + signed int v6; // eax@1 + signed int v7; // edi@3 + signed int v8; // eax@3 + int texture_cell_width; // edi@3 + int texture_cell_height; // ebx@5 + int _row; // esi@9 + int _cell_rows; // edx@10 + int _column; // ecx@11 + char *v14; // eax@12 + int chest_cell_heght; // [sp+Ch] [bp-Ch]@1 + signed int v17; // [sp+10h] [bp-8h]@1 + signed int chest_cell_width; // [sp+14h] [bp-4h]@1 + + v17 = test_cell_position; - v17 = a1; - v3 = pChests[uChestID].uChestBitmapID; - v16 = pChestHeightsByType[v3]; - v18 = pChestWidthsByType[v3]; - v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE); - v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); - v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); - if ( v6 < 14 ) - v6 = 14; - v7 = v6 - 14; - v8 = v5->uTextureHeight; - v9 = (v7 >> 5) + 1; - if ( v8 < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v5->Release(); - pIcons_LOD->_40F9C5(); - } - if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 ) - { - v11 = 0; - if ( v10 <= 0 ) - return 1; - v12 = 0; - while ( 1 ) - { - v13 = 0; - if ( v9 > 0 ) - break; -LABEL_15: - v12 += v18; - ++v11; - if ( v11 >= v10 ) - return 1; + chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; + item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE); + item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0); + v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24); + if ( v6 < 14 ) + v6 = 14; + texture_cell_width = (v6 - 14 >> 5) + 1; + v8 = item_texture->uTextureHeight; + if ( v8 < 14 ) + v8 = 14; + texture_cell_height = ((v8 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + item_texture->Release(); + pIcons_LOD->_40F9C5(); + } + if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && + (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) ) + { //we not put over borders + _row = 0; + if ( texture_cell_height <= 0 ) + return true; + _cell_rows = 0; + while ( 1 ) + { + _column = 0; + if ( texture_cell_width > 0 ) + { + while ( !pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]) + { + ++_column; + if ( _column >= texture_cell_width ) + break; + } + } + _cell_rows += chest_cell_width; + ++_row; + if ( _row >= texture_cell_height ) + return true; + } + + } + return false; } - v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID]; - while ( !*(short *)v14 ) - { - ++v13; - v14 += 2; - if ( v13 >= v9 ) - goto LABEL_15; - } - } - return 0; -} // 506128: using guessed type int areWeLoadingTexture; //----- (0041FF64) -------------------------------------------------------- -int Chest::_41FF64(unsigned int uChestID) +int Chest::CountChestItems(unsigned int uChestID) { - unsigned int v1; // ecx@1 - signed int result; // eax@1 - int v3; // edx@1 - ItemGen *pItem; // ecx@2 - - v1 = uChestID; - result = 0; - v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID]; - if ( v3 <= 0 ) + signed int item_count; // eax@1 + int max_items; // edx@1 + item_count = 0; + max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + if ( max_items <= 0 ) { -LABEL_5: - result = -1; + item_count = -1; } else { - pItem = pChests[v1].mm7__vector_pItems; - while ( pItem->uItemID ) + while ( pChests[uChestID].igChestItems[item_count].uItemID ) { - ++result; - ++pItem; - if ( result >= v3 ) - goto LABEL_5; + ++item_count; + if ( item_count >= max_items ) + { + item_count = -1; + break; + } } } - return result; + return item_count; } //----- (0041FFA2) -------------------------------------------------------- -int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) +int Chest::PutItemInChest(int position, ItemGen *put_item, unsigned int uChestID) { int v3; // eax@1 ItemGen *v4; // edi@1 @@ -455,7 +426,7 @@ int v15; // edi@21 int i; // ecx@21 ItemGen *Src; // [sp+Ch] [bp-18h]@1 - signed int v18; // [sp+10h] [bp-14h]@2 + signed int item_in_chest_count; // [sp+10h] [bp-14h]@2 int v19; // [sp+14h] [bp-10h]@1 int v20; // [sp+18h] [bp-Ch]@19 signed int v21; // [sp+1Ch] [bp-8h]@1 @@ -464,19 +435,19 @@ v21 = 0; v3 = pChests[uChestID].uChestBitmapID; - v4 = a2; + v4 = put_item; v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; - Src = a2; + Src = put_item; v19 = pChestWidthsByType[v3]; - if ( a1 == -1 ) + if ( position == -1 ) { - v18 = _41FF64(uChestID); - if ( v18 == -1 ) + item_in_chest_count = CountChestItems(uChestID); + if ( item_in_chest_count == -1 ) return 0; v22 = 0; if ( v5 > 0 ) { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) + while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) ) { ++v22; if ( v22 >= v5 ) @@ -515,7 +486,7 @@ { if ( (signed int)v12 > 0 ) { - v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; + v14 = &pChests[uChestID].pInventoryIndices[v21 + v23]; LOWORD(v8) = -1 - v21; v8 <<= 16; LOWORD(v8) = -1 - v21; @@ -532,8 +503,8 @@ } while ( v20 ); } - pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; - memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); + pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1; + memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen)); result = v21 + 1; } else @@ -545,8 +516,8 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (0042013E) -------------------------------------------------------- -unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) -{ +void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int uItemIdx, unsigned int uChestID ) + { int v3; // esi@1 unsigned int v4; // ebx@1 int uItemID; // edi@1 @@ -568,16 +539,16 @@ unsigned int v21; // [sp+18h] [bp-4h]@1 v3 = 5324 * uChestID; - v21 = a1; + v21 = put_cell_pos; v4 = 5324 * uChestID + 36 * uItemIdx; v18 = uItemIdx; - uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4); - pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4)); - if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) ) + uItemID = pChests[ uChestID].igChestItems[uItemIdx].uItemID; + pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[uItemIdx]); + if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[uItemIdx].uNumCharges) { v6 = rand() % 21 + 10; - *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; - *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; + pChests[ uChestID].igChestItems[uItemIdx].uNumCharges = v6; + pChests[ uChestID].igChestItems[uItemIdx].uMaxCharges = v6; } v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); @@ -594,7 +565,7 @@ v8->Release(); pIcons_LOD->_40F9C5(); } - v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; + v19 = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; if ( v12 > 0 ) { v13 = 0; @@ -603,7 +574,7 @@ { if ( (signed int)v11 > 0 ) { - v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; + v14 = &pChests[uChestID].pInventoryIndices[v21 + v13]; LOWORD(v3) = -1 - v21; v3 <<= 16; LOWORD(v3) = -1 - v21; @@ -619,85 +590,64 @@ --v20; } while ( v20 ); - } - result = v21 + 2662 * uChestID; - pChests[0].pInventoryIndices[result] = v18 + 1; - return result; + } + pChests[uChestID].pInventoryIndices[v21] = v18 + 1; } // 506128: using guessed type int areWeLoadingTexture; //----- (00420284) -------------------------------------------------------- -char *Chest::_420284(unsigned int uChestID) -{ - int v1; // ebx@1 - unsigned int v2; // esi@1 - unsigned int v3; // esi@1 - int uChestArea; // edi@1 - int v5; // eax@2 - int v6; // ebx@11 - char *result; // eax@18 - char Dst[144]; // [sp+Ch] [bp-A0h]@1 - int v9; // [sp+9Ch] [bp-10h]@10 - unsigned int v10; // [sp+A0h] [bp-Ch]@1 - unsigned int v11; // [sp+A4h] [bp-8h]@8 - ItemGen *v12; // [sp+A8h] [bp-4h]@9 - - v1 = 0; - v2 = uChestID; - v10 = uChestID; - pRenderer->ClearZBuffer(0, 479); - v3 = v2; - uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID]; - memset(Dst, 0, 0x90u); - if ( uChestArea > 0 ) - { - do +void Chest::PlaceItems( unsigned int uChestID ) { - do - v5 = (unsigned __int8)rand(); - while ( v5 >= uChestArea ); - while ( Dst[v5] ) - { - ++v5; - if ( v5 == uChestArea ) - v5 = 0; - } - Dst[v5] = v1++; + int uChestArea; // edi@1 + int random_chest_pos; // eax@2 + int test_position; // ebx@11 + char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1 + int chest_item_id; // [sp+9Ch] [bp-10h]@10 + unsigned int cell_counter; // [sp+A4h] [bp-8h]@8 + + pRenderer->ClearZBuffer(0, 479); + uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; + memset(chest_cells_map, 0, 144); + //fill cell map at random positions + for (cell_counter = 0; cell_counter<uChestArea; ++cell_counter) + { + //get random position in chest + do + random_chest_pos = (unsigned __int8)rand(); + while ( random_chest_pos >= uChestArea ); + //if this pos occupied move to next + while ( chest_cells_map[random_chest_pos] ) + { + ++random_chest_pos; + if ( random_chest_pos == uChestArea ) + random_chest_pos = 0; + } + chest_cells_map[random_chest_pos] = cell_counter; + } + cell_counter = 0; + + for (cell_counter = 0; cell_counter<uChestArea; ++cell_counter) + { + chest_item_id = pChests[uChestID].igChestItems[cell_counter].uItemID; + if ( chest_item_id ) + { + test_position = 0; + while ( !Chest::CanPlaceItemAt((unsigned __int8)chest_cells_map[test_position], chest_item_id, uChestID) ) + { + ++test_position; + if ( test_position >= uChestArea ) + break; + } + if(test_position<uChestArea) + { + Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], cell_counter, uChestID); + if ( pChests[uChestID].uFlags & 4 ) + pChests[uChestID].igChestItems[cell_counter].SetIdentified(); + } + } + } + pChests[uChestID].uFlags = pChests[uChestID].uFlags & 0xFFFB | 2; } - while ( v1 < uChestArea ); - } - v11 = 0; - if ( uChestArea > 0 ) - { - v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes; - do - { - v9 = v12->uItemID; - if ( v9 ) - { - v6 = 0; - while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) ) - { - ++v6; - if ( v6 >= uChestArea ) - break; - } - if(v6<uChestArea) - { - Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10); - if ( pChests[v3].uFlags & 4 ) - v12->SetIdentified(); - } - } - ++v11; - ++v12; - } - while ( (signed int)v11 < uChestArea ); - } - result = (char *)&pChests[v3].uFlags; - pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2; - return result; -} // 420284: using guessed type char Dst[144]; //----- (00458B03) -------------------------------------------------------- @@ -801,3 +751,83 @@ fclose(File); return 1; } + +//----- (00420B13) -------------------------------------------------------- +void __fastcall sub_420B13(int a1, int a2) + { + void *v2; // eax@1 + ItemGen *v3; // ebx@1 + unsigned int v4; // eax@1 + Texture *v5; // ecx@1 + signed int v6; // eax@1 + signed int v7; // edi@3 + signed int v8; // eax@3 + int v9; // edi@3 + int v10; // eax@5 + int v11; // esi@8 + unsigned int v12; // ecx@10 + void *v13; // edi@10 + unsigned __int8 v14; // cf@10 + int v15; // edi@10 + int i; // ecx@10 + int v17; // [sp+Ch] [bp-14h]@1 + int v18; // [sp+10h] [bp-10h]@3 + int v19; // [sp+14h] [bp-Ch]@1 + void *v20; // [sp+18h] [bp-8h]@1 + int v21; // [sp+1Ch] [bp-4h]@5 + int v22; // [sp+1Ch] [bp-4h]@8 + + v19 = a2; + v2 = pChestWindow->ptr_1C; + v20 = v2; + v2 = (void *)(5324 * (int)v2); + v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); + v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; + v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); + v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); + if ( v6 < 14 ) + v6 = 14; + v7 = v6 - 14; + v8 = v5->uTextureHeight; + v9 = (v7 >> 5) + 1; + v18 = v9; + if ( v8 < 14 ) + v8 = 14; + v10 = ((v8 - 14) >> 5) + 1; + v21 = v10; + if ( !areWeLoadingTexture ) + { + v5->Release(); + pIcons_LOD->_40F9C5(); + v10 = v21; + } + if ( v10 > 0 ) + { + v11 = 0; + v22 = v10; + do + { + if ( v9 > 0 ) + { + v12 = v9; + v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; + v14 = v12 & 1; + v12 >>= 1; + memset(v13, 0, 4 * v12); + v15 = (int)((char *)v13 + 4 * v12); + for ( i = v14; i; --i ) + { + *(short *)v15 = 0; + v15 += 2; + } + v9 = v18; + } + v11 += v17; + --v22; + } + while ( v22 ); + } + v3->Reset(); + } +// 506128: using guessed type int areWeLoadingTexture;
--- a/Chest.h Sat Mar 02 15:38:49 2013 +0400 +++ b/Chest.h Sun Mar 03 01:55:57 2013 +0400 @@ -47,29 +47,29 @@ /* 65 */ #pragma pack(push, 1) -struct Chest +struct Chest //0x14cc { inline bool Initialized() const {return uFlags & CHEST_ITEMS_PLACED;} inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;} inline bool Trapped() const {return uFlags & CHEST_TRAPPED;} - static int CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID); - static int _41FF64(unsigned int uChestID); - static int _41FFA2(int a1, ItemGen *a2, unsigned int uChestID); - static unsigned int PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID); - static char *_420284(unsigned int uChestID); - static bool Open(unsigned int uChestID); + static bool CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID); + static int CountChestItems(unsigned int uChestID); + static int PutItemInChest(int a1, ItemGen *a2, unsigned int uChestID); + static void PlaceItemAt(unsigned int put_cell_pos, unsigned int uItemIdx, unsigned int uChestID); + static void PlaceItems(unsigned int uChestID); + static bool Open(signed int uChestID); static void DrawChestUI(unsigned int uChestID); static void ToggleFlag(unsigned int uChestID, unsigned __int16 uFlag, unsigned int bToggle); - unsigned __int16 uChestBitmapID; - unsigned __int16 uFlags; - struct ItemGen mm7__vector_pItems[140]; - __int16 pInventoryIndices[140]; + unsigned __int16 uChestBitmapID; //0 + unsigned __int16 uFlags; //2 + struct ItemGen igChestItems[140]; //4 + __int16 pInventoryIndices[140]; //0x13b4 }; #pragma pack(pop) - +void __fastcall sub_420B13(int a1, int a2); extern size_t uNumChests; // idb
--- a/GUIWindow.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/GUIWindow.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -1211,7 +1211,7 @@ } else { - pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uTextureID_506438]); + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); } } @@ -1794,7 +1794,7 @@ pMainScreenNum = pCurrentScreen; pCurrentScreen = SCREEN_NPC_DIALOGUE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); if ( pWindow->par1C != 1 ) { num_menu_buttons = 0; @@ -1916,7 +1916,7 @@ { pCurrentScreen = SCREEN_HOUSE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[80],//Выйти из здания - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); v25 = uNumDialogueNPCPortraits; v26 = 0; if ( uNumDialogueNPCPortraits > 0 )
--- a/Items.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/Items.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -25,9 +25,9 @@ }; -char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; +const char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; -ITEM_VARIATION shopWeap_variation_ord[15] ={ +const ITEM_VARIATION shopWeap_variation_ord[15] ={ { 0, { 0, 0, 0, 0 }}, { 1, { 23, 27, 20, 20 }}, { 1, { 23, 24, 28, 20 }}, @@ -44,7 +44,7 @@ { 2, { 30, 26, 26, 26 }}, { 2, { 28, 25, 28, 29 }}}; -ITEM_VARIATION shopArmr_variation_ord[28] ={ +const ITEM_VARIATION shopArmr_variation_ord[28] ={ { 1, { 35, 35, 38, 38 }}, { 1, { 31, 31, 31, 34 }}, { 1, { 35, 35, 38, 38 }}, @@ -76,10 +76,10 @@ -unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; -unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; +const unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; +const unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; -ITEM_VARIATION shopWeap_variation_spc[15]={ +const ITEM_VARIATION shopWeap_variation_spc[15]={ { 0, { 0, 0, 0, 0 }}, { 2, { 25, 30, 20, 20}}, { 2, { 23, 24, 28, 20}}, @@ -96,7 +96,7 @@ { 4, { 30, 26, 26, 26}}, { 4, { 28, 25, 28, 29}}}; -ITEM_VARIATION shopArmr_variation_spc[28]={ +const ITEM_VARIATION shopArmr_variation_spc[28]={ { 2, { 35, 35, 38, 38 }}, { 2, { 31, 31, 31, 34 }}, { 2, { 35, 35, 38, 38 }}, @@ -127,8 +127,18 @@ { 5, { 33, 33, 33, 33 }} }; -unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; -unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; +const unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; +const unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; + + +char byte_4E8168[7][14]={ //byte_4E8178 + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, + { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, + { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, + { 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); @@ -2043,8 +2053,8 @@ //----- (00450218) -------------------------------------------------------- -void __cdecl sub_450218_prolly_generate_chests_loot() - { +void sub_450218_prolly_generate_chests_loot() + { unsigned int v0; // eax@1 Chest *v1; // ebx@1 MapInfo *v2; // esi@1 @@ -2076,14 +2086,13 @@ v2 = &pMapStats->pInfos[v0]; v21 = pChests; v20 = &pMapStats->pInfos[v0]; - do + for(int i=0; i<20;++i) { - v3 = v1->mm7__vector_pItems; - v23 = 140; - do + for(int j=0; j<140;++j) { - if ( (v3->uItemID & 0x80000000u) == 0 ) - goto LABEL_56; + v3 = &pChests[i].igChestItems[j]; + if ( v3->uItemID < 0 ) + { v4 = rand() % 5 + 1; v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; @@ -2091,6 +2100,13 @@ v8 = v6 - v5 + 1; v9 = v5 + v7 % v8; v19 = v5 + v7 % v8; + /* switch (v9) + { + default: + + }*/ + + if ( v9 < 7 ) { if ( v18 < 20 ) @@ -2146,7 +2162,7 @@ v13 = v12; if ( v12 >= 140 ) goto LABEL_52; - v14 = &v21->mm7__vector_pItems[v12]; + v14 = &v21->igChestItems[v12]; while ( v14->uItemID ) { ++v13; @@ -2226,17 +2242,14 @@ goto LABEL_25; } v3->GenerateArtifact(); + LABEL_55: v2 = v20; -LABEL_56: - ++v3; - --v23; - } - while ( v23 ); - v1 = v21 + 1; - ++v21; +LABEL_56: ; + } + } } - while ( (signed int)v21 < (signed int)&uNumChests ); + }
--- a/Items.h Sat Mar 02 15:38:49 2013 +0400 +++ b/Items.h Sun Mar 03 01:55:57 2013 +0400 @@ -116,7 +116,7 @@ /* 64 */ #pragma pack(push, 1) -struct ItemGen +struct ItemGen //0x24 { //----- (0042EB25) -------------------------------------------------------- inline ItemGen() @@ -139,7 +139,7 @@ - unsigned int uItemID; + int uItemID; int uEncantmentType; int _bonus_strength; int uSpecEnchantmentType; // 25: +5 levels @@ -290,7 +290,7 @@ void GenerateStandartShopItems(); void GenerateSpecialShopItems(); - +extern const char uItemsAmountPerShopType[]; // weak extern ItemGen *ptr_50C9A4; extern struct ItemsTable *pItemsTable;
--- a/mm7_1.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_1.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -3817,7 +3817,7 @@ if ( v1 ) { auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C - + 18 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime + + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); v2 = _w->GetDisplayName(); sub_41C0B8_set_status_string(v2); @@ -3825,85 +3825,6 @@ } } -//----- (00420B13) -------------------------------------------------------- -void __fastcall sub_420B13(int a1, int a2) -{ - void *v2; // eax@1 - ItemGen *v3; // ebx@1 - unsigned int v4; // eax@1 - Texture *v5; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // eax@5 - int v11; // esi@8 - unsigned int v12; // ecx@10 - void *v13; // edi@10 - unsigned __int8 v14; // cf@10 - int v15; // edi@10 - int i; // ecx@10 - int v17; // [sp+Ch] [bp-14h]@1 - int v18; // [sp+10h] [bp-10h]@3 - int v19; // [sp+14h] [bp-Ch]@1 - void *v20; // [sp+18h] [bp-8h]@1 - int v21; // [sp+1Ch] [bp-4h]@5 - int v22; // [sp+1Ch] [bp-4h]@8 - - v19 = a2; - v2 = pChestWindow->ptr_1C; - v20 = v2; - v2 = (void *)(5324 * (int)v2); - v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4)); - v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)]; - v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); - v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); - if ( v6 < 14 ) - v6 = 14; - v7 = v6 - 14; - v8 = v5->uTextureHeight; - v9 = (v7 >> 5) + 1; - v18 = v9; - if ( v8 < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - v21 = v10; - if ( !areWeLoadingTexture ) - { - v5->Release(); - pIcons_LOD->_40F9C5(); - v10 = v21; - } - if ( v10 > 0 ) - { - v11 = 0; - v22 = v10; - do - { - if ( v9 > 0 ) - { - v12 = v9; - v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20]; - v14 = v12 & 1; - v12 >>= 1; - memset(v13, 0, 4 * v12); - v15 = (int)((char *)v13 + 4 * v12); - for ( i = v14; i; --i ) - { - *(short *)v15 = 0; - v15 += 2; - } - v9 = v18; - } - v11 += v17; - --v22; - } - while ( v22 ); - } - v3->Reset(); -} -// 506128: using guessed type int areWeLoadingTexture; //----- (00420C05) -------------------------------------------------------- void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) @@ -4017,23 +3938,23 @@ //----- (00420E01) -------------------------------------------------------- void __cdecl sub_420E01() { - void *v0; // edi@1 + int chest_id; // edi@1 POINT *v1; // esi@2 int v2; // eax@2 int v3; // ebx@4 int v4; // esi@6 int v5; // ecx@6 //SpriteObject v6; // [sp+Ch] [bp-80h]@1 - char v7; // [sp+7Ch] [bp-10h]@2 + POINT v7; // [sp+7Ch] [bp-10h]@2 POINT a2; // [sp+84h] [bp-8h]@2 SpriteObject v6; // [sp+Ch] [bp-80h]@1 //SpriteObject::SpriteObject(&v6); - v0 = pGUIWindow_CurrentMenu->ptr_1C; + chest_id = pGUIWindow_CurrentMenu->par1C; if ( pParty->pPickedItem.uItemID ) { - if ( Chest::_41FFA2(-1, &pParty->pPickedItem, (unsigned int)pGUIWindow_CurrentMenu->ptr_1C) ) + if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) pMouse->RemoveHoldingItem(); } else @@ -4046,16 +3967,15 @@ v3 = v2 - 1; else v3 = -1; - v4 = pChests[0].pInventoryIndices[v3 + 2662 * (int)v0] - 1; - v5 = 5324 * (int)v0 + 36 * v4; - if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 ) + v4 = pChests[chest_id].pInventoryIndices[v3] - 1; + if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 ) { - party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uSpecEnchantmentType + v5), 0); + party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck viewparams->bRedrawGameUI = 1; } else { - pParty->SetHoldingItem((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v5)); + pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); } sub_420B13(v4, v3); } @@ -5468,7 +5388,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-c", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2); @@ -5504,7 +5424,7 @@ uTextureID_Btn_Rest = pIcons_LOD->LoadTexture("ib-m2d-c", TEXTURE_16BIT_PALETTE); uTextureID_Btn_QuickReference = pIcons_LOD->LoadTexture("ib-m3d-c", TEXTURE_16BIT_PALETTE); uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-c", TEXTURE_16BIT_PALETTE); - uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE); + uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE); dword_50796C = pIcons_LOD->LoadTexture("isg-01-c", TEXTURE_16BIT_PALETTE); dword_507968 = pIcons_LOD->LoadTexture("isg-02-c", TEXTURE_16BIT_PALETTE); dword_507964 = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE); @@ -5553,7 +5473,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-a", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2); @@ -5589,7 +5509,7 @@ uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-a", TEXTURE_16BIT_PALETTE); uTextureID_Btn_ZoomIn = pIcons_LOD->LoadTexture("ib-autout-a", TEXTURE_16BIT_PALETTE); uTextureID_Btn_ZoomOut = pIcons_LOD->LoadTexture("ib-autin-a", TEXTURE_16BIT_PALETTE); - uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE); + uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE); dword_50796C = pIcons_LOD->LoadTexture("isg-01-a", TEXTURE_16BIT_PALETTE); dword_507968 = pIcons_LOD->LoadTexture("isg-02-a", TEXTURE_16BIT_PALETTE); dword_507964 = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE); @@ -5649,7 +5569,7 @@ pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID); pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchB"); pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-b", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
--- a/mm7_2.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_2.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -3159,7 +3159,7 @@ pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0); pDialogueWindow->_41D08F(1, 1, 0, 2); @@ -3301,7 +3301,7 @@ pDialogueWindow->pControlsTail = 0; pDialogueWindow->uNumControls = 0; pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0); @@ -3685,7 +3685,7 @@ pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[74], //"End Conversation" - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : NULL), + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : NULL), 0); return pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, 0x51u, 0, 0, "", 0); } @@ -9330,26 +9330,18 @@ const char **v4; // ebx@2 unsigned int result; // eax@6 - v2 = this; v3 = 1; - if ( (signed int)this->uNumMaps <= 1 ) - { -LABEL_6: - result = 0; - } - else - { - v4 = (const char **)&this->pInfos[1].pFilename; - while ( !*v4 || _strcmpi(*v4, Str2) ) + if ( (signed int)uNumMaps <= 1 ) + return 0; + + while ( !*this->pInfos[v3].pFilename || _strcmpi(this->pInfos[v3].pFilename, Str2) ) { ++v3; - v4 += 17; - if ( (signed int)v3 >= (signed int)v2->uNumMaps ) - goto LABEL_6; - } - result = v3; - } - return result; + if ( (signed int)v3 >= (signed int)uNumMaps ) + return 0; + } + return v3; + } //----- (004547E4) --------------------------------------------------------
--- a/mm7_3.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_3.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -14458,7 +14458,7 @@ while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } } - pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } //----- (004459F9) --------------------------------------------------------
--- a/mm7_4.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_4.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -10627,7 +10627,7 @@ pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0); pDialogueWindow->_41D08F(1, 1, 0, 2); @@ -10650,7 +10650,7 @@ v2 = ""; pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); if ( contract_approved ) @@ -10683,7 +10683,7 @@ 0, 0, pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) ) @@ -10764,7 +10764,7 @@ pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0); pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) {
--- a/mm7_5.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_5.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -6276,7 +6276,7 @@ uTextureID_507B04 = uTextureID_right_panel; v30 = 0; uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE); - uTextureID_5118C8 = uTextureID_506438; + uTextureID_5118C8 = uExitCancelTextureId; do { v42 = v30 + 1; @@ -13124,7 +13124,7 @@ pRenderer->DrawTextureTransparent( 0x1D7u, 0x1BDu, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); v6.uFrameX = 8; v6.uFrameY = 8; v6.uFrameWidth = 460; @@ -14231,7 +14231,7 @@ enum WindowType pWindowType; // esi@1 pWindowType = (enum WindowType)uBook; - pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); switch ( pWindowType ) { case WINDOW_Lloyd: // 177 @@ -15497,7 +15497,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0)); } } } @@ -16255,7 +16255,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - __debugbreak(); + // __debugbreak(); if ( !pPlayers[uActiveCharacter]->CanAct() ) { sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s не в состоянии %s @@ -16275,7 +16275,7 @@ v9 = pX + pSRZBufferLineOffsets[pY]; if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) ) goto LABEL_132; - v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime + v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); } else
--- a/mm7_data.cpp Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_data.cpp Sun Mar 03 01:55:57 2013 +0400 @@ -686,10 +686,7 @@ char _4E2B21_buff_spell_tooltip_colors[80]; char byte_4E2B70[777]; // weak char byte_4E2BC8; // weak -int pChestSmthn1ByType[8] = {42, 18, 18, 42, 42, 42, 18, 42}; -int pChestSmthn2ByType[8] = {34, 30, 30, 34, 34, 34, 30, 34}; -int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; -int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; + char aSS[777]; // idb char ascii_4E2C54[6]; char ascii_4E2C5C[7]; @@ -1105,14 +1102,7 @@ char aEWorkMsdevMm_7[777]; // idb char aGammaControlNo[777]; // idb __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; -char byte_4E8168[7][14]={ //byte_4E8178 - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, - { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, - { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, - { 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}}; + char aD3dTextureName[777]; // idb char aLogd3d_txt[777]; // idb char byte_4E8394[204] = @@ -1830,7 +1820,7 @@ int dword_506364; // weak Texture *dword_506404[12]; // weak Texture *dword_50640C[12]; // weak -unsigned int uTextureID_506438; +unsigned int uExitCancelTextureId; int dword_50651C; // weak int awards_count; // weak int awards_count2; // weak
--- a/mm7_data.h Sat Mar 02 15:38:49 2013 +0400 +++ b/mm7_data.h Sun Mar 03 01:55:57 2013 +0400 @@ -474,10 +474,7 @@ extern char _4E2B21_buff_spell_tooltip_colors[80]; extern char byte_4E2B70[]; // weak extern char byte_4E2BC8; // weak -extern int pChestSmthn1ByType[8]; -extern int pChestSmthn2ByType[8]; -extern int pChestWidthsByType[8]; -extern int pChestHeightsByType[8]; + extern char aSS[]; // idb extern char ascii_4E2C54[6]; extern char ascii_4E2C5C[7]; @@ -1005,7 +1002,7 @@ extern __int16 word_4F0576[]; // weak //extern __int16 word_4F05AE[]; // weak -extern char uItemsAmountPerShopType[]; // weak + //extern __int16 word_4F063E[290]; //extern __int16 word_4F06D8[22]; extern int guild_mambership_flags[32]; @@ -1153,7 +1150,7 @@ extern char byte_506360; // weak extern int dword_506364; // weak extern Texture *dword_50640C[]; // weak -extern unsigned int uTextureID_506438; +extern unsigned int uExitCancelTextureId; extern int dword_50651C; // weak extern int awards_count; // weak extern int awards_count2; // weak @@ -1904,7 +1901,7 @@ void __cdecl RestUI_Initialize(); void __cdecl RestUI_Draw(); // idb void __cdecl sub_42038D(); -void __fastcall sub_420B13(int a1, int a2); + void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void __cdecl sub_420E01(); void __cdecl GameUI_WritePointedObjectStatusString(); @@ -2055,7 +2052,7 @@ // int __cdecl crt_deconstruct_44C42C(); void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -void __cdecl sub_450218_prolly_generate_chests_loot(); +void sub_450218_prolly_generate_chests_loot(); signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); int __fastcall sub_45063B(struct MapInfo *a1, int a2); void RespawnGlobalDecorations();