# HG changeset patch # User Gloval # Date 1361646931 -14400 # Node ID afad358dc6849f4aed44584f139c1b461c2d740b # Parent 88c30918eef7d36d4a627c4ca3dfd2c7b1c7a7aa# Parent 03ccac4fad25260c7cba2c6af528624cbff642ed Merge diff -r 88c30918eef7 -r afad358dc684 Actor.cpp --- a/Actor.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/Actor.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -3055,42 +3055,19 @@ //----- (00402F87) -------------------------------------------------------- void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) { - //int v3; // edi@1 - //AIDirection *v4; // esi@1 - //Actor *v5; // ebx@1 - //SpriteFrame *v6; // ecx@3 unsigned int v7; // eax@3 - //int v8; // edx@3 unsigned int v9; // eax@3 - //int result; // eax@4 - AIDirection a3; // [sp+Ch] [bp-5Ch]@2 - //AIDirection v12; // [sp+28h] [bp-40h]@2 - //AIDirection v13; // [sp+44h] [bp-24h]@2 - //unsigned int v14; // [sp+60h] [bp-8h]@1 - //unsigned int v15; // [sp+64h] [bp-4h]@1 assert(uActorID < uNumActors); auto actor = pActors + uActorID; - - //v3 = uActorID; - //v4 = a4; - //v5 = &pActors[uActorID]; - //v14 = uObjID; - //v15 = uActorID; + + AIDirection a3; // [sp+Ch] [bp-5Ch]@2 if (!a4) a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); - /*{ - memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13)); - memcpy(&v12, &v13, sizeof(v12)); - v3 = v15; - v4 = &v12; - }*/ - //v6 = pSpriteFrameTable->pSpriteSFrames; actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); - //LOWORD(v8) = actor->uYawAngle; v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; if ( BYTE1(v9) & 7 ) // turned away - just stand @@ -3572,146 +3549,137 @@ v6->UpdateAnimation(); } -//----- (00401221) -------------------------------------------------------- -void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) +//----- (00SelectTarget) -------------------------------------------------------- +void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) { - Actor *v3; // esi@1 - unsigned int v4; // ebx@1 + //Actor *v3; // esi@1 + //unsigned int v4; // ebx@1 int v5; // ecx@1 - unsigned int v6; // eax@1 - Actor *v7; // edi@2 - __int16 v8; // ax@3 + //unsigned int v6; // eax@1 + //Actor *v7; // edi@2 + //__int16 v8; // ax@3 int v9; // eax@10 signed int v10; // eax@13 int v11; // ebx@16 int v12; // eax@16 - int v13; // eax@25 + //int v13; // eax@25 signed int v14; // eax@31 int v15; // edi@43 int v16; // ebx@45 int v17; // eax@45 - int v18; // eax@51 + //int v18; // eax@51 int v19; // [sp+Ch] [bp-24h]@16 - int *v20; // [sp+10h] [bp-20h]@1 + //int *v20; // [sp+10h] [bp-20h]@1 signed int v21; // [sp+14h] [bp-1Ch]@1 - unsigned int v22; // [sp+18h] [bp-18h]@1 + //unsigned int v22; // [sp+18h] [bp-18h]@1 int v23; // [sp+1Ch] [bp-14h]@16 - unsigned int v24; // [sp+20h] [bp-10h]@1 + //unsigned int v24; // [sp+20h] [bp-10h]@1 int v25; // [sp+24h] [bp-Ch]@1 - signed int v26; // [sp+28h] [bp-8h]@1 + //signed int v26; // [sp+28h] [bp-8h]@1 int v27; // [sp+2Ch] [bp-4h]@16 int v28; // [sp+2Ch] [bp-4h]@45 v25 = -1; - v22 = uActorID; - v3 = &pActors[uActorID]; - v4 = 0; + //v22 = uActorID; + //v3 = &pActors[uActorID]; + //v4 = 0; v5 = 0; - v6 = v3->uLastCharacterIDToHit; + //v6 = v3->uLastCharacterIDToHit; *a2 = 0; - v20 = a2; + //v20 = a2; v21 = 0; - v24 = v6; - v26 = 0; - if ( (signed int)uNumActors > 0 ) + //v24 = v3->uLastCharacterIDToHit; + //v26 = 0; + assert(uActorID < uNumActors); + auto _this = pActors + uActorID; + + for (uint i = 0; i < uNumActors; ++i) { - v7 = pActors; - do - { - v8 = v7->uAIState; - if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) + auto actor = pActors + i; + //v7 = pActors; + //do + //{ + //v8 = v7->uAIState; + if (actor->uAIState == Dead || actor->uAIState == Dying || + actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) + continue; + + if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, _this->uLastCharacterIDToHit != v9) ) { - ++v7; - v5 = v26++ + 1; + v10 = _this->GetActorsRelation(actor); + if ( v10 == 0 ) continue; } - if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) + else if (_this->IsNotAlive()) { - v10 = v3->GetActorsRelation(v7); - if ( v10 == v4 ) - { - ++v7; - v5 = v26++ + 1; + _this->uLastCharacterIDToHit = 0; + v10 = _this->GetActorsRelation(actor); + if ( v10 == 0 ) continue; - } - } - else if (v7->IsNotAlive()) - { - v24 = v4; - v3->uLastCharacterIDToHit = v4; - v10 = v3->GetActorsRelation(v7); - if ( v10 == v4 ) - { - ++v7; - v5 = v26++ + 1; - continue; - } } else { - v18 = v7->uGroup; - if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) - { - ++v7; - v5 = v26++ + 1; + //v18 = actor->uGroup; + if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup ) continue; - } v10 = 4; } - if ( v3->pMonsterInfo.uHostilityType ) - v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; + if ( _this->pMonsterInfo.uHostilityType ) + v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType; v11 = dword_4DF380[v10]; - v23 = abs(v3->vPosition.x - v7->vPosition.x); - v27 = abs(v3->vPosition.y - v7->vPosition.y); - v12 = abs(v3->vPosition.z - v7->vPosition.z); + v23 = abs(_this->vPosition.x - actor->vPosition.x); + v27 = abs(_this->vPosition.y - actor->vPosition.y); + v12 = abs(_this->vPosition.z - actor->vPosition.z); v19 = v12; if ( v23 <= v11 && v27 <= v11 && v12 <= v11 - && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) + && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) { v25 = v23 * v23 + v27 * v27 + v19 * v19; - v21 = v26; + v21 = i; } - v4 = 0; - ++v7; - v5 = v26++ + 1; - } - while ( v26 < (signed int)uNumActors ); - if ( v25 != -1 ) - { - v13 = 8 * v21; - LOBYTE(v13) = 8 * v21 | 3; - *v20 = v13; - } + //v4 = 0; + //++v7; + //v5 = v26++ + 1; + //} + //while ( v26 < (signed int)uNumActors ); + } - if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4 - && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) ) - a3 = v4; - if ( a3 != v4 ) + if ( v25 != -1 ) + { + //v13 = 8 * v21; + //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; + *a2 = 8 * v21 | OBJECT_Actor; + } + + if (pParty->Invisible()) + can_target_party = false; + + if (can_target_party) { - v14 = v3->GetActorsRelation(0); - if ( BYTE2(v3->uAttributes) & 8 - && SHIDWORD(v3->pActorBuffs[12].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[12].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[12].uExpireTime) <= v4) - && SHIDWORD(v3->pActorBuffs[1].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[1].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[1].uExpireTime) <= v4) - && SHIDWORD(v3->pActorBuffs[2].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[2].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[2].uExpireTime) <= v4) ) + v14 = _this->GetActorsRelation(0); + if ( BYTE2(_this->uAttributes) & 8 + && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0) + && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0) + && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) ) v14 = 4; - if ( v14 != v4 ) + if ( v14 != 0 ) { v15 = dword_4DF390; - if ( !v3->pMonsterInfo.uHostilityType ) + if ( !_this->pMonsterInfo.uHostilityType ) v15 = dword_4DF380[v14]; - v16 = abs(v3->vPosition.x - pParty->vPosition.x); - v28 = abs(v3->vPosition.y - pParty->vPosition.y); - v17 = abs(v3->vPosition.z - pParty->vPosition.z); + v16 = abs(_this->vPosition.x - pParty->vPosition.x); + v28 = abs(_this->vPosition.y - pParty->vPosition.y); + v17 = abs(_this->vPosition.z - pParty->vPosition.z); if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) { if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 ) - *v20 = 4; + *a2 = OBJECT_Player; } } } diff -r 88c30918eef7 -r afad358dc684 Actor.h --- a/Actor.h Sat Feb 23 23:09:48 2013 +0400 +++ b/Actor.h Sat Feb 23 23:15:31 2013 +0400 @@ -201,7 +201,7 @@ bool IsPeasant(); - static void _401221(unsigned int uActorID, int *a2, unsigned int a3); + static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party); static void _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); static void _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); static void _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); @@ -265,7 +265,7 @@ char field_B7; unsigned int uCurrentActionTime; unsigned __int16 pSpriteIDs[8]; - unsigned __int16 pSoundSampleIDs[4]; + unsigned __int16 pSoundSampleIDs[4]; // 1 die 3 bored struct SpellBuff pActorBuffs[22]; struct ItemGen array_000234[4]; unsigned int uGroup; diff -r 88c30918eef7 -r afad358dc684 Chest.cpp --- a/Chest.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/Chest.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -3,6 +3,20 @@ #include "Chest.h" #include "FrameTableInc.h" #include "Allocator.h" +#include "LOD.h" +#include "MapInfo.h" +#include "Actor.h" +#include "Indoor.h" +#include "Outdoor.h" +#include "DecorationList.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Math.h" +#include "Texts.h" +#include "ObjectList.h" +#include "GUIWindow.h" +#include "Time.h" +#include "Overlays.h" #include "mm7_data.h" @@ -17,6 +31,670 @@ +//----- (0042041E) -------------------------------------------------------- +bool Chest::Open(unsigned int uChestID) +{ + char *v1; // edi@5 + unsigned int v2; // eax@8 + GUIWindow *v3; // eax@15 + int v5; // edx@16 + int v6; // eax@16 + ODMFace *v7; // eax@19 + int v8; // edx@19 + int v9; // edi@19 + signed int v10; // ebx@19 + int v11; // ecx@19 + int v12; // eax@19 + BLVFace *v13; // eax@20 + int v14; // ebx@21 + int v15; // edi@21 + int v16; // ecx@22 + __int64 v17; // qax@22 + double v18; // st7@23 + double v19; // st6@23 + double v20; // st7@23 + int v21; // ecx@26 + char v22[12]; // ST4C_12@28 + unsigned int *v23; // edi@28 + unsigned __int16 v24; // di@28 + signed int v25; // ecx@28 + char *v26; // edx@29 + unsigned __int16 v27; // ax@32 + //LayingItem a1; // [sp+14h] [bp-B0h]@28 + int v29; // [sp+84h] [bp-40h]@16 + int v30; // [sp+88h] [bp-3Ch]@16 + int v31; // [sp+8Ch] [bp-38h]@16 + int v32; // [sp+90h] [bp-34h]@16 + float v33; // [sp+94h] [bp-30h]@23 + char *v34; // [sp+98h] [bp-2Ch]@5 + int v35; // [sp+9Ch] [bp-28h]@16 + Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 + int a4; // [sp+ACh] [bp-18h]@1 + int v38; // [sp+B0h] [bp-14h]@21 + int sRotX; // [sp+B4h] [bp-10h]@23 + float v40; // [sp+B8h] [bp-Ch]@23 + float v41; // [sp+BCh] [bp-8h]@23 + int sRotY; // [sp+C0h] [bp-4h]@8 + + a4 = uChestID; + if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 ) + return 0; + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + v1 = (char *)&pChests[uChestID].uFlags; + v34 = v1; + if ( !(*v1 & CHEST_ITEMS_PLACED) ) + Chest::_420284(uChestID); + if ( !uActiveCharacter ) + return 0; + *(float *)&sRotY = 0.0; + v2 = pMapStats->GetMapInfo(pCurrentMapName); + if ( !(*v1 & 1) || !v2 ) + goto LABEL_12; + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) + { + v29 = 811; + v30 = 812; + v31 = 813; + v32 = 814; + v5 = rand() % 4; + v6 = dword_5B5920 >> 3; + v35 = v5; + if ( (dword_5B5920 & 7) == OBJECT_Decoration) + { + v16 = v6; + v14 = pLevelDecorations[v6].vPosition.x; + v38 = pLevelDecorations[v6].vPosition.y; + v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; + v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); + } + else + { + if ( (dword_5B5920 & 7) != OBJECT_BModel) + goto LABEL_12; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F]; + v8 = v7->pBoundingBox.y1; + v9 = v7->pBoundingBox.z2; + v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; + v11 = v7->pBoundingBox.y2; + v12 = v7->pBoundingBox.z1; + } + else + { + v13 = &pIndoor->pFaces[v6]; + v8 = v13->pBounding.y1; + v9 = v13->pBounding.z2; + v10 = v13->pBounding.x1 + v13->pBounding.x2; + v11 = v13->pBounding.y2; + v12 = v13->pBounding.z1; + } + v14 = v10 >> 1; + v38 = (v8 + v11) >> 1; + v15 = (v12 + v9) >> 1; + } + v18 = (double)pParty->vPosition.x - (double)v14; + *(float *)&a4 = v18; + v19 = (double)pParty->vPosition.y - (double)v38; + v33 = v19; + v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; + *(float *)&sRotY = v19 * v19; + *(float *)&sRotX = v18 * v18; + v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); + v40 = v20; + if ( v20 <= 1.0 ) + { + *(float *)&sRotX = 0.0; + *(float *)&sRotY = 0.0; + } + else + { + sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); + sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); + sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); + } + v21 = 256; + if ( v40 < 256.0 ) + v21 = (signed __int64)v40 / 4; + *(int *)&v22[8] = v15; + *(_QWORD *)v22 = __PAIR__(v38, v14); + Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); + v23 = (unsigned int *)(&v29 + v35); + sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); + + LayingItem a1; // [sp+14h] [bp-B0h]@28 + //LayingItem::LayingItem(&a1); + + a1.stru_24.Reset(); + v24 = *(short *)v23; + v25 = 0; + a1.field_50 = 0; + a1.field_4C = 0; + a1.field_48 = 0; + a1.field_54 = 0; + a1.uItemType = v24; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { +LABEL_32: + v27 = 0; + } + else + { + v26 = (char *)&pObjectList->pObjects->uObjectID; + while ( v24 != *(short *)v26 ) + { + ++v25; + v26 += 56; + if ( v25 >= (signed int)pObjectList->uNumObjects ) + goto LABEL_32; + } + v27 = v25; + } + a1.uObjectDescID = v27; + a1.vPosition.y = pOut.z; + a1.vPosition.x = pOut.x; + a1.vPosition.z = pOut.y; + a1.uSoundID = 0; + a1.uAttributes = 48; + a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); + a1.uSpriteFrameID = 0; + a1.field_58_pid = 0; + a1.field_5C = 0; + a1.uFacing = 0; + a1.Create(0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); + a1._438E35(); + *v34 &= 0xFEu; + if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) + { + qword_A750D8 = 256i64; + word_A750E0 = 5; + word_A750E2 = uActiveCharacter; + } + pIcons_LOD->_4114F2(); + dword_507CD8 = 0; + return 0; + } + *v1 &= 0xFEu; + sRotY = 1; +LABEL_12: + pAudioPlayer->StopChannels(-1, -1); + pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0); + if ( *(float *)&sRotY != 0.0 ) + { + if ( !dword_507CD8 ) + 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); + pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); + pCurrentScreen = SCREEN_CHEST; + pEventTimer->Pause(); + return 1; +} + +//----- (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 + + 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; + } + 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 + + 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; + } + 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) +{ + 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 ) + { +LABEL_5: + result = -1; + } + else + { + pItem = pChests[v1].mm7__vector_pItems; + while ( pItem->uItemID ) + { + ++result; + ++pItem; + if ( result >= v3 ) + goto LABEL_5; + } + } + return result; +} + +//----- (0041FFA2) -------------------------------------------------------- +int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) +{ + int v3; // eax@1 + ItemGen *v4; // edi@1 + int v5; // esi@1 + int result; // eax@11 + unsigned int v7; // eax@12 + int v8; // edx@12 + int v9; // ecx@12 + signed int v10; // eax@12 + signed int v11; // edi@14 + unsigned int v12; // esi@14 + int v13; // edi@16 + void *v14; // edi@21 + int v15; // edi@21 + int i; // ecx@21 + ItemGen *Src; // [sp+Ch] [bp-18h]@1 + signed int v18; // [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 + signed int v22; // [sp+20h] [bp-4h]@3 + int v23; // [sp+20h] [bp-4h]@19 + + v21 = 0; + v3 = pChests[uChestID].uChestBitmapID; + v4 = a2; + v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; + Src = a2; + v19 = pChestWidthsByType[v3]; + if ( a1 == -1 ) + { + v18 = _41FF64(uChestID); + if ( v18 == -1 ) + return 0; + v22 = 0; + if ( v5 > 0 ) + { + while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) + { + ++v22; + if ( v22 >= v5 ) + goto LABEL_8; + } + v21 = v22; + } +LABEL_8: + if ( v22 == v5 ) + { + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + return 0; + } + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + HIWORD(v8) = 0; + v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0; + v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v10 < 14 ) + v10 = 14; + v11 = *(short *)(v9 + 26); + v12 = ((v10 - 14) >> 5) + 1; + if ( v11 < 14 ) + v11 = 14; + v13 = ((v11 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + ((Texture *)v9)->Release(); + pIcons_LOD->_40F9C5(); + } + if ( v13 > 0 ) + { + v23 = 0; + v20 = v13; + do + { + if ( (signed int)v12 > 0 ) + { + v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; + LOWORD(v8) = -1 - v21; + v8 <<= 16; + LOWORD(v8) = -1 - v21; + memset32(v14, v8, v12 >> 1); + v15 = (int)((char *)v14 + 4 * (v12 >> 1)); + for ( i = v12 & 1; i; --i ) + { + *(short *)v15 = v8; + v15 += 2; + } + } + v23 += v19; + --v20; + } + while ( v20 ); + } + pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; + memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); + result = v21 + 1; + } + else + { + result = 1; + } + return result; +} +// 506128: using guessed type int areWeLoadingTexture; + +//----- (0042013E) -------------------------------------------------------- +unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) +{ + int v3; // esi@1 + unsigned int v4; // ebx@1 + int uItemID; // edi@1 + int v6; // edx@4 + unsigned int v7; // eax@5 + Texture *v8; // ecx@5 + signed int v9; // eax@5 + signed int v10; // edi@7 + unsigned int v11; // ebx@7 + int v12; // edi@9 + int v13; // edx@12 + void *v14; // edi@14 + int v15; // edi@14 + int i; // ecx@14 + unsigned int result; // eax@18 + __int16 v18; // [sp+Ch] [bp-10h]@1 + int v19; // [sp+10h] [bp-Ch]@11 + int v20; // [sp+14h] [bp-8h]@12 + unsigned int v21; // [sp+18h] [bp-4h]@1 + + v3 = 5324 * uChestID; + v21 = a1; + 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) ) + { + v6 = rand() % 21 + 10; + *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; + *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; + } + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); + v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v9 < 14 ) + v9 = 14; + v10 = v8->uTextureHeight; + v11 = ((v9 - 14) >> 5) + 1; + if ( v10 < 14 ) + v10 = 14; + v12 = ((v10 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + v8->Release(); + pIcons_LOD->_40F9C5(); + } + v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; + if ( v12 > 0 ) + { + v13 = 0; + v20 = v12; + do + { + if ( (signed int)v11 > 0 ) + { + v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; + LOWORD(v3) = -1 - v21; + v3 <<= 16; + LOWORD(v3) = -1 - v21; + memset32(v14, v3, v11 >> 1); + v15 = (int)((char *)v14 + 4 * (v11 >> 1)); + for ( i = v11 & 1; i; --i ) + { + *(short *)v15 = v3; + v15 += 2; + } + } + v13 += v19; + --v20; + } + while ( v20 ); + } + result = v21 + 2662 * uChestID; + pChests[0].pInventoryIndices[result] = v18 + 1; + return result; +} +// 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 + { + do + v5 = (unsigned __int8)rand(); + while ( v5 >= uChestArea ); + while ( Dst[v5] ) + { + ++v5; + if ( v5 == uChestArea ) + v5 = 0; + } + Dst[v5] = v1++; + } + 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(v6SetIdentified(); + } + } + ++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) -------------------------------------------------------- void ChestList::ToFile() { diff -r 88c30918eef7 -r afad358dc684 GUIWindow.cpp --- a/GUIWindow.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/GUIWindow.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -1093,11 +1093,14 @@ goto LABEL_58; while ( 1 ) { - pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, - *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, - &pIcons_LOD->pTextures[uTextureID_50795C]); - pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6), - *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]); + //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, + // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, + pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8] - 4, + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); // frame around portrait + //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6), + // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8], pDialogueNPCPortraits[v8]); if ( uNumDialogueNPCPortraits < 4 ) break; LABEL_57: @@ -1126,15 +1129,15 @@ } v15 = 3; v13 = array_5913D8[v8 - (dword_591080 != 0)]->pName; - v9 = dword_4E5EC8[v8 + 6 * uNumDialogueNPCPortraits] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; + v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; } v11 = v19; v10 = v9; goto LABEL_56; } v4 = (char *)array_5913D8[6] - 1; - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[(signed int)v4]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[(signed int)v4]); if ( pCurrentScreen == SCREEN_E ) { CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); @@ -1905,7 +1908,7 @@ (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Au, 0, 0x59u, pWindow->Hint, (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); - pWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 0x3Fu, 0x49u, 1, 0, 0x5Au, 1u, 0x20u, pWindow->Hint, 0, 0, 0); + pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, 0x5Au, 1u, 0x20u, pWindow->Hint, 0, 0, 0); pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->Hint, 0); break; case WINDOW_SpellBook: // окно книги заклов @@ -1956,8 +1959,8 @@ v29 = (char*)pGlobalTXT_LocalizationStrings[435];// "Converse with %s" Побеседовать с ^Pt[%s] } sprintf(&byte_591180[100 * v26], v29, v30); - array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(*(&pNPCPortraits_x + v26 + 6 * uNumDialogueNPCPortraits - 6), - *(&pNPCPortraits_y + v26 + 6 * uNumDialogueNPCPortraits - 6), + array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], 0x3Fu, 0x49u, 1, 0, 0x19Au, v26, 0, &byte_591180[100 * v26], 0, 0, 0); ++v26; v25 = uNumDialogueNPCPortraits; @@ -1980,7 +1983,7 @@ (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Bu, 0, 0x59u, pWindow->Hint, (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); - pWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 0x3Fu, 0x49u, 1, 0, 0x19Bu, 1, 0x20u, pWindow->Hint, 0); + pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, 0x19Bu, 1, 0x20u, pWindow->Hint, 0); pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->Hint, 0); return pWindow; } diff -r 88c30918eef7 -r afad358dc684 mm7_1.cpp --- a/mm7_1.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_1.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -3831,373 +3831,7 @@ (int)pGlobalTXT_LocalizationStrings[81]); } } -// 4E2BC8: using guessed type char byte_4E2BC8; -// 506F14: using guessed type int dword_506F14; -// 506F1C: using guessed type int dword_506F1C; -// 50765C: using guessed type int uTextureID_RestUI_restmain; -// 507CD4: using guessed type int 507CD4_RestUI_hourglass_anim_controller; - -//----- (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 - - 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; - } - 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) -{ - 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 ) - { -LABEL_5: - result = -1; - } - else - { - pItem = pChests[v1].mm7__vector_pItems; - while ( pItem->uItemID ) - { - ++result; - ++pItem; - if ( result >= v3 ) - goto LABEL_5; - } - } - return result; -} - -//----- (0041FFA2) -------------------------------------------------------- -int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) -{ - int v3; // eax@1 - ItemGen *v4; // edi@1 - int v5; // esi@1 - int result; // eax@11 - unsigned int v7; // eax@12 - int v8; // edx@12 - int v9; // ecx@12 - signed int v10; // eax@12 - signed int v11; // edi@14 - unsigned int v12; // esi@14 - int v13; // edi@16 - void *v14; // edi@21 - int v15; // edi@21 - int i; // ecx@21 - ItemGen *Src; // [sp+Ch] [bp-18h]@1 - signed int v18; // [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 - signed int v22; // [sp+20h] [bp-4h]@3 - int v23; // [sp+20h] [bp-4h]@19 - - v21 = 0; - v3 = pChests[uChestID].uChestBitmapID; - v4 = a2; - v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; - Src = a2; - v19 = pChestWidthsByType[v3]; - if ( a1 == -1 ) - { - v18 = _41FF64(uChestID); - if ( v18 == -1 ) - return 0; - v22 = 0; - if ( v5 > 0 ) - { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) - { - ++v22; - if ( v22 >= v5 ) - goto LABEL_8; - } - v21 = v22; - } -LABEL_8: - if ( v22 == v5 ) - { - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - return 0; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - HIWORD(v8) = 0; - v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0; - v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v10 < 14 ) - v10 = 14; - v11 = *(short *)(v9 + 26); - v12 = ((v10 - 14) >> 5) + 1; - if ( v11 < 14 ) - v11 = 14; - v13 = ((v11 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - ((Texture *)v9)->Release(); - pIcons_LOD->_40F9C5(); - } - if ( v13 > 0 ) - { - v23 = 0; - v20 = v13; - do - { - if ( (signed int)v12 > 0 ) - { - v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; - LOWORD(v8) = -1 - v21; - v8 <<= 16; - LOWORD(v8) = -1 - v21; - memset32(v14, v8, v12 >> 1); - v15 = (int)((char *)v14 + 4 * (v12 >> 1)); - for ( i = v12 & 1; i; --i ) - { - *(short *)v15 = v8; - v15 += 2; - } - } - v23 += v19; - --v20; - } - while ( v20 ); - } - pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; - memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); - result = v21 + 1; - } - else - { - result = 1; - } - return result; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (0042013E) -------------------------------------------------------- -unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) -{ - int v3; // esi@1 - unsigned int v4; // ebx@1 - int uItemID; // edi@1 - int v6; // edx@4 - unsigned int v7; // eax@5 - Texture *v8; // ecx@5 - signed int v9; // eax@5 - signed int v10; // edi@7 - unsigned int v11; // ebx@7 - int v12; // edi@9 - int v13; // edx@12 - void *v14; // edi@14 - int v15; // edi@14 - int i; // ecx@14 - unsigned int result; // eax@18 - __int16 v18; // [sp+Ch] [bp-10h]@1 - int v19; // [sp+10h] [bp-Ch]@11 - int v20; // [sp+14h] [bp-8h]@12 - unsigned int v21; // [sp+18h] [bp-4h]@1 - - v3 = 5324 * uChestID; - v21 = a1; - 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) ) - { - v6 = rand() % 21 + 10; - *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; - *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v9 = 14; - v10 = v8->uTextureHeight; - v11 = ((v9 - 14) >> 5) + 1; - if ( v10 < 14 ) - v10 = 14; - v12 = ((v10 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v8->Release(); - pIcons_LOD->_40F9C5(); - } - v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; - if ( v12 > 0 ) - { - v13 = 0; - v20 = v12; - do - { - if ( (signed int)v11 > 0 ) - { - v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; - LOWORD(v3) = -1 - v21; - v3 <<= 16; - LOWORD(v3) = -1 - v21; - memset32(v14, v3, v11 >> 1); - v15 = (int)((char *)v14 + 4 * (v11 >> 1)); - for ( i = v11 & 1; i; --i ) - { - *(short *)v15 = v3; - v15 += 2; - } - } - v13 += v19; - --v20; - } - while ( v20 ); - } - result = v21 + 2662 * uChestID; - pChests[0].pInventoryIndices[result] = v18 + 1; - return result; -} -// 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 - { - do - v5 = (unsigned __int8)rand(); - while ( v5 >= uChestArea ); - while ( Dst[v5] ) - { - ++v5; - if ( v5 == uChestArea ) - v5 = 0; - } - Dst[v5] = v1++; - } - 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(v6SetIdentified(); - } - } - ++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]; + //----- (0042038D) -------------------------------------------------------- void __cdecl sub_42038D() @@ -4223,307 +3857,6 @@ } } -//----- (0042041E) -------------------------------------------------------- -bool Chest::Open(unsigned int uChestID) -{ - char *v1; // edi@5 - unsigned int v2; // eax@8 - GUIWindow *v3; // eax@15 - int v5; // edx@16 - int v6; // eax@16 - ODMFace *v7; // eax@19 - int v8; // edx@19 - int v9; // edi@19 - signed int v10; // ebx@19 - int v11; // ecx@19 - int v12; // eax@19 - BLVFace *v13; // eax@20 - int v14; // ebx@21 - int v15; // edi@21 - int v16; // ecx@22 - __int64 v17; // qax@22 - double v18; // st7@23 - double v19; // st6@23 - double v20; // st7@23 - int v21; // ecx@26 - char v22[12]; // ST4C_12@28 - unsigned int *v23; // edi@28 - unsigned __int16 v24; // di@28 - signed int v25; // ecx@28 - char *v26; // edx@29 - unsigned __int16 v27; // ax@32 - //LayingItem a1; // [sp+14h] [bp-B0h]@28 - int v29; // [sp+84h] [bp-40h]@16 - int v30; // [sp+88h] [bp-3Ch]@16 - int v31; // [sp+8Ch] [bp-38h]@16 - int v32; // [sp+90h] [bp-34h]@16 - float v33; // [sp+94h] [bp-30h]@23 - char *v34; // [sp+98h] [bp-2Ch]@5 - int v35; // [sp+9Ch] [bp-28h]@16 - Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int a4; // [sp+ACh] [bp-18h]@1 - int v38; // [sp+B0h] [bp-14h]@21 - int sRotX; // [sp+B4h] [bp-10h]@23 - float v40; // [sp+B8h] [bp-Ch]@23 - float v41; // [sp+BCh] [bp-8h]@23 - int sRotY; // [sp+C0h] [bp-4h]@8 - - a4 = uChestID; - if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 ) - return 0; - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - v1 = (char *)&pChests[uChestID].uFlags; - v34 = v1; - if ( !(*v1 & CHEST_ITEMS_PLACED) ) - Chest::_420284(uChestID); - if ( !uActiveCharacter ) - return 0; - *(float *)&sRotY = 0.0; - v2 = pMapStats->GetMapInfo(pCurrentMapName); - if ( !(*v1 & 1) || !v2 ) - goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) - { - v29 = 811; - v30 = 812; - v31 = 813; - v32 = 814; - v5 = rand() % 4; - v6 = dword_5B5920 >> 3; - v35 = v5; - if ( (dword_5B5920 & 7) == OBJECT_Decoration) - { - v16 = v6; - v14 = pLevelDecorations[v6].vPosition.x; - v38 = pLevelDecorations[v6].vPosition.y; - v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; - v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); - } - else - { - if ( (dword_5B5920 & 7) != OBJECT_BModel) - goto LABEL_12; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F]; - v8 = v7->pBoundingBox.y1; - v9 = v7->pBoundingBox.z2; - v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; - v11 = v7->pBoundingBox.y2; - v12 = v7->pBoundingBox.z1; - } - else - { - v13 = &pIndoor->pFaces[v6]; - v8 = v13->pBounding.y1; - v9 = v13->pBounding.z2; - v10 = v13->pBounding.x1 + v13->pBounding.x2; - v11 = v13->pBounding.y2; - v12 = v13->pBounding.z1; - } - v14 = v10 >> 1; - v38 = (v8 + v11) >> 1; - v15 = (v12 + v9) >> 1; - } - v18 = (double)pParty->vPosition.x - (double)v14; - *(float *)&a4 = v18; - v19 = (double)pParty->vPosition.y - (double)v38; - v33 = v19; - v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; - *(float *)&sRotY = v19 * v19; - *(float *)&sRotX = v18 * v18; - v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); - v40 = v20; - if ( v20 <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); - sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); - sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); - } - v21 = 256; - if ( v40 < 256.0 ) - v21 = (signed __int64)v40 / 4; - *(int *)&v22[8] = v15; - *(_QWORD *)v22 = __PAIR__(v38, v14); - Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); - v23 = (unsigned int *)(&v29 + v35); - sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); - - LayingItem a1; // [sp+14h] [bp-B0h]@28 - //LayingItem::LayingItem(&a1); - - a1.stru_24.Reset(); - v24 = *(short *)v23; - v25 = 0; - a1.field_50 = 0; - a1.field_4C = 0; - a1.field_48 = 0; - a1.field_54 = 0; - a1.uItemType = v24; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_32: - v27 = 0; - } - else - { - v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v26 ) - { - ++v25; - v26 += 56; - if ( v25 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_32; - } - v27 = v25; - } - a1.uObjectDescID = v27; - a1.vPosition.y = pOut.z; - a1.vPosition.x = pOut.x; - a1.vPosition.z = pOut.y; - a1.uSoundID = 0; - a1.uAttributes = 48; - a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - a1.uSpriteFrameID = 0; - a1.field_58_pid = 0; - a1.field_5C = 0; - a1.uFacing = 0; - a1.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - a1._438E35(); - *v34 &= 0xFEu; - if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 5; - word_A750E2 = uActiveCharacter; - } - pIcons_LOD->_4114F2(); - dword_507CD8 = 0; - return 0; - } - *v1 &= 0xFEu; - sRotY = 1; -LABEL_12: - pAudioPlayer->StopChannels(-1, -1); - pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0); - if ( *(float *)&sRotY != 0.0 ) - { - if ( !dword_507CD8 ) - 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); - pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); - pCurrentScreen = SCREEN_CHEST; - pEventTimer->Pause(); - return 1; -} - -//----- (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 - - 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; - } - while ( v23 < v21 * v19 ); - } - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); -} - //----- (00420B13) -------------------------------------------------------- void __fastcall sub_420B13(int a1, int a2) { diff -r 88c30918eef7 -r afad358dc684 mm7_2.cpp --- a/mm7_2.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_2.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -4375,7 +4375,7 @@ v3 = byte_591180; do { - array_5913D8[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(*(&pNPCPortraits_x + v2 + 6 * v1 - 6), *(&pNPCPortraits_y + v2 + 6 * v1 - 6), + array_5913D8[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], 0x3Fu, 0x49u, 1, 0, 0x19Au, v2, 0, v3, 0, 0, 0); v1 = uNumDialogueNPCPortraits; ++v2; diff -r 88c30918eef7 -r afad358dc684 mm7_3.cpp --- a/mm7_3.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_3.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -14623,8 +14623,8 @@ v10 = pMapStats->GetMapInfo(pCurrentMapName); v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pTexture_outside); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); uTextureID_507B04 = uTextureID_right_panel; pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0)); pRenderer->DrawTextureIndexed(556, 451, (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0)); @@ -14750,11 +14750,9 @@ pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); v0 = pMapStats->GetMapInfo(pDestinationMapName); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureTransparent(0x1D4u, 0, - (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pTexture_outside); - pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, - (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0)); + pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); + pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, &pIcons_LOD->pTextures[uTextureID_x_x_u]); pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u, (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0)); if ( v0 ) @@ -14978,8 +14976,8 @@ v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[0]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[0]); if (pNPC->uProfession) { @@ -17682,7 +17680,7 @@ //unsigned int v17; // edx@67 //unsigned int v18; // ecx@67 //unsigned __int16 v19; // ax@72 - int *v20; // esi@80 + //int *v20; // esi@80 Actor *v21; // ebx@80 unsigned __int16 v22; // ax@86 signed int v23; // eax@94 @@ -17839,7 +17837,7 @@ //pActor = (Actor *)(LODWORD(v80) - 176); //v11 = *(unsigned int *)LODWORD(v80); //v49 = *(unsigned int *)LODWORD(v80) == 5; - dword_4F6E08[i] = 4; + ai_near_actors_targets_pid[i] = OBJECT_Player; if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) continue; @@ -17928,12 +17926,12 @@ actor_id = ai_near_actors_ids[v78]; assert(actor_id < uNumActors); - v20 = &dword_4F6E08[actor_id]; + //v20 = &ai_near_actors_targets_pid[actor_id]; v21 = &pActors[actor_id]; - Actor::_401221(actor_id, &dword_4F6E08[actor_id], 1u); - if ( v21->pMonsterInfo.uHostilityType && !*v20 ) + Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); + if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - a2 = *v20; + a2 = ai_near_actors_targets_pid[actor_id]; v76 = a2 & 7; if ( (a2 & 7) == OBJECT_Actor) v80 = 0.5; @@ -18687,7 +18685,7 @@ v7 = v6->uAttributes; if ( v7 & 0x8000 < 0 ) { - v8 = dword_4F6E08[v5]; + v8 = ai_near_actors_targets_pid[v5]; LOBYTE(v7) = v7 | 0x80; v6->uAttributes = v7; v33 = 8 * v5 | OBJECT_Actor; diff -r 88c30918eef7 -r afad358dc684 mm7_4.cpp --- a/mm7_4.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_4.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -11209,11 +11209,11 @@ sprintf(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, 0x71u, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],// "Cancel" - (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), pBtn_YES = pDialogueWindow->CreateButton( 486u, 445u, 75u, 33u, 1, 0, 0xBFu, 1u, 0x59u, sHouseName, (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); - pDialogueWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 63u, 73u, 1, 0, 0xBFu, 1u, 0x20u, sHouseName, 0); + pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0, 0xBFu, 1u, 0x20u, sHouseName, 0); pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, sHouseName, 0); } else @@ -13133,9 +13133,7 @@ int v51; // eax@73 unsigned int v52; // ecx@73 unsigned __int16 v53; // ax@73 - char a1[100]; // [sp+10h] [bp-1B4h]@64 - char Dest; // [sp+74h] [bp-150h]@66 - char v56; // [sp+D8h] [bp-ECh]@66 + char a1[300]; // [sp+10h] [bp-1B4h]@64 GUIWindow v57; // [sp+13Ch] [bp-88h]@1 __int64 v58; // [sp+190h] [bp-34h]@1 __int64 v59; // [sp+198h] [bp-2Ch]@1 @@ -13410,8 +13408,8 @@ sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]); v63 = 0; } - strcpy(&Dest, pGlobalTXT_LocalizationStrings[68]); - strcpy(&v56, pGlobalTXT_LocalizationStrings[160]); + strcpy(&a1[100], pGlobalTXT_LocalizationStrings[68]); + strcpy(&a1[200], pGlobalTXT_LocalizationStrings[160]); v42 = v63; v43 = pDialogueWindow; v44 = v63; @@ -14252,8 +14250,8 @@ v4->uCurrentActionTime += pMiscTimer->uTimeElapsed; if ( (signed int)v4->uCurrentActionTime >= v5 ) { - v17 = dword_4F6E08[v20]; - v6 = Actor::GetDirectionInfo(8 * v20 | 3, v17, &a3, v2); + v17 = ai_near_actors_targets_pid[v20]; + v6 = Actor::GetDirectionInfo(8 * v20 | OBJECT_Actor, v17, &a3, v2); v7 = v4->uAIState; memcpy(&v15, v6, sizeof(v15)); v8 = v7 - 4; diff -r 88c30918eef7 -r afad358dc684 mm7_5.cpp --- a/mm7_5.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_5.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -4749,7 +4749,7 @@ v37 = v3; if ( stru_50FE08.field_3EC[v0] & 1 ) { - v6 = dword_4F6E08[v3]; + v6 = ai_near_actors_targets_pid[v3]; v7 = v6 >> 3; v8 = (v6 & 7) - 3; uActorID = v7; @@ -9721,7 +9721,7 @@ if ( v6 != 8 ) goto LABEL_19; v3 = 0; - Actor::AI_StandOrBored(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0); + Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0); } } } @@ -9753,7 +9753,7 @@ { if ( v11 != 17 ) { - v12 = dword_4F6E08[v10]; + v12 = ai_near_actors_targets_pid[v10]; v9->uActionLength = v3; Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); } @@ -10044,8 +10044,8 @@ if ( (v1->uPackedID & 7) != OBJECT_Player) { v4 = v3 >> 3; // turn based only stuff - a2a = dword_4F6E08[v3 >> 3]; - memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3)); + a2a = ai_near_actors_targets_pid[v3 >> 3]; + memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[v3 >> 3], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); v5 = &pActors[v3 >> 3]; LOWORD(v3) = v5->uAIState; @@ -10189,8 +10189,8 @@ { if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 ) { - v6 = (unsigned int *)&dword_4F6E08[(int)v4]; - Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u); + v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4]; + Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true); if ( v5->pMonsterInfo.uHostilityType && !*v6 ) v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v22 = *v6; @@ -10340,7 +10340,7 @@ v5 = v10->uPackedID; if ( (v10->uPackedID & 7) == OBJECT_Actor) { - v8 = dword_4F6E08[v5 >> 3]; + v8 = ai_near_actors_targets_pid[v5 >> 3]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); @@ -10384,7 +10384,7 @@ if ( pActors[v3].CanAct() ) { v4 = v2->uPackedID; - v9 = dword_4F6E08[v3]; + v9 = ai_near_actors_targets_pid[v3]; memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6)); Actor::AI_Stand(v8, v9, 0x20u, &v6); v2->field_C = 0; @@ -10447,7 +10447,7 @@ result = 1; if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) ) { - v13 = dword_4F6E08[v5]; + v13 = ai_near_actors_targets_pid[v5]; memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); v7 = v6->uAIState; if ( v7 == 6 || v7 == 1 ) @@ -10524,12 +10524,12 @@ v5 = v4->uAIState; if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 ) return 1; - v6 = &dword_4F6E08[v3]; + v6 = &ai_near_actors_targets_pid[v3]; v7 = &pTurnEngine->pQueue[a2]; v8 = *v6; v29 = &pTurnEngine->pQueue[a2]; a2a = v8; - Actor::_401221(v3, &dword_4F6E08[v3], 1u); + Actor::_SelectTarget(v3, &ai_near_actors_targets_pid[v3], true); if ( v4->pMonsterInfo.uHostilityType && !*v6 ) v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0); @@ -10724,10 +10724,10 @@ { if ( v6 != 17 ) { - v7 = (unsigned int *)&dword_4F6E08[v4]; + v7 = (unsigned int *)&ai_near_actors_targets_pid[v4]; a2 = *v7; v8 = a2; - Actor::_401221(v4, (int *)v7, 1u); + Actor::_SelectTarget(v4, (int *)v7, true); memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11)); memcpy(&a4, &v11, sizeof(a4)); v5->uCurrentActionTime += pMiscTimer->uTimeElapsed; @@ -12099,7 +12099,7 @@ if (_449B57_test_bit(pParty->_award_bits, 100)) v5 = 1; - Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // dword_4F6E08[i] for AI_Stand seems always 0; original code behaviour is identical + Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical for (uint i = 0; i < uNumActors; ++i) { auto actor = pActors + i; @@ -12112,7 +12112,7 @@ actor->sCurrentHP = actor->pMonsterInfo.uHP; if (actor->uAIState != Disabled) { - Actor::AI_Stand(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0); + Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); } } diff -r 88c30918eef7 -r afad358dc684 mm7_data.cpp --- a/mm7_data.cpp Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_data.cpp Sat Feb 23 23:15:31 2013 +0400 @@ -958,9 +958,24 @@ char aBardataC[10]; // weak char aLoadprog[777]; // idb char aLoadingD_pcx[777]; // idb -int pNPCPortraits_x = 521; // idb -int dword_4E5EC8[777]; // weak -int pNPCPortraits_y = 38; // idb +int pNPCPortraits_x[6][6] = // 004E5E50 +{ + {521, 0, 0, 0, 0, 0}, + {521, 521, 0, 0, 0, 0}, + {521, 521, 521, 0, 0, 0}, + {521, 486, 564, 521, 0, 0}, + {521, 486, 564, 486, 564, 0}, + {486, 564, 486, 564, 486, 564} +}; +int pNPCPortraits_y[6][6] = // 004E5EE0 +{ + {38, 0, 0, 0, 0, 0}, + {38, 165, 0, 0, 0, 0}, + {38, 133, 228, 0, 0, 0}, + {38, 133, 133, 228, 0, 0}, + {38, 133, 133, 228, 228, 0}, + {38, 38, 133, 133, 228, 228} +}; const char *pHouse_ExitPictures[11]= { "", @@ -1711,7 +1726,7 @@ int dword_4F5D98_xs[777]; // idb int ai_array_4F5E68[500]; int ai_array_4F6638_actor_ids[500]; -int dword_4F6E08[500]; +int ai_near_actors_targets_pid[500]; int ai_arrays_size; // weak int ai_near_actors_distances[500]; unsigned int ai_near_actors_ids[500]; diff -r 88c30918eef7 -r afad358dc684 mm7_data.h --- a/mm7_data.h Sat Feb 23 23:09:48 2013 +0400 +++ b/mm7_data.h Sat Feb 23 23:15:31 2013 +0400 @@ -681,9 +681,8 @@ extern char aBardataC[10]; // weak extern char aLoadprog[]; // idb extern char aLoadingD_pcx[]; // idb -extern int pNPCPortraits_x; // idb -extern int dword_4E5EC8[]; // weak -extern int pNPCPortraits_y; // idb +extern int pNPCPortraits_x[6][6]; // 004E5E50 +extern int pNPCPortraits_y[6][6]; // 004E5EE0 extern const char *pHouse_ExitPictures[11]; extern const char *_4E6BDC_loc_names[11]; extern char aOutside[]; // idb @@ -1071,7 +1070,7 @@ extern int dword_4F5D98_xs[]; // idb extern int ai_array_4F5E68[500]; extern int ai_array_4F6638_actor_ids[500]; -extern int dword_4F6E08[500]; +extern int ai_near_actors_targets_pid[500]; extern int ai_arrays_size; // weak extern int ai_near_actors_distances[500]; extern unsigned int ai_near_actors_ids[500];