comparison mm7_1.cpp @ 452:f56c98a2ab52

Слияние
author Ritor1
date Sun, 24 Feb 2013 01:14:42 +0600
parents 9bb6aaff2413 80a5aab68b67
children 5e5dfedcc0ad
comparison
equal deleted inserted replaced
451:9bb6aaff2413 452:f56c98a2ab52
3827 (enum WindowType)96, 3827 (enum WindowType)96,
3828 (int)pButton_RestUI_Exit, 3828 (int)pButton_RestUI_Exit,
3829 (int)pGlobalTXT_LocalizationStrings[81]); 3829 (int)pGlobalTXT_LocalizationStrings[81]);
3830 } 3830 }
3831 } 3831 }
3832 // 4E2BC8: using guessed type char byte_4E2BC8; 3832
3833 // 506F14: using guessed type int dword_506F14;
3834 // 506F1C: using guessed type int dword_506F1C;
3835 // 50765C: using guessed type int uTextureID_RestUI_restmain;
3836 // 507CD4: using guessed type int 507CD4_RestUI_hourglass_anim_controller;
3837
3838 //----- (0041FE71) --------------------------------------------------------
3839 int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID)
3840 {
3841 int v3; // eax@1
3842 unsigned int v4; // eax@1
3843 Texture *v5; // ecx@1
3844 signed int v6; // eax@1
3845 signed int v7; // edi@3
3846 signed int v8; // eax@3
3847 int v9; // edi@3
3848 int v10; // ebx@5
3849 int v11; // esi@9
3850 int v12; // edx@10
3851 int v13; // ecx@11
3852 char *v14; // eax@12
3853 int v16; // [sp+Ch] [bp-Ch]@1
3854 signed int v17; // [sp+10h] [bp-8h]@1
3855 signed int v18; // [sp+14h] [bp-4h]@1
3856
3857 v17 = a1;
3858 v3 = pChests[uChestID].uChestBitmapID;
3859 v16 = pChestHeightsByType[v3];
3860 v18 = pChestWidthsByType[v3];
3861 v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE);
3862 v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
3863 v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
3864 if ( v6 < 14 )
3865 v6 = 14;
3866 v7 = v6 - 14;
3867 v8 = v5->uTextureHeight;
3868 v9 = (v7 >> 5) + 1;
3869 if ( v8 < 14 )
3870 v8 = 14;
3871 v10 = ((v8 - 14) >> 5) + 1;
3872 if ( !areWeLoadingTexture )
3873 {
3874 v5->Release();
3875 pIcons_LOD->_40F9C5();
3876 }
3877 if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 )
3878 {
3879 v11 = 0;
3880 if ( v10 <= 0 )
3881 return 1;
3882 v12 = 0;
3883 while ( 1 )
3884 {
3885 v13 = 0;
3886 if ( v9 > 0 )
3887 break;
3888 LABEL_15:
3889 v12 += v18;
3890 ++v11;
3891 if ( v11 >= v10 )
3892 return 1;
3893 }
3894 v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID];
3895 while ( !*(short *)v14 )
3896 {
3897 ++v13;
3898 v14 += 2;
3899 if ( v13 >= v9 )
3900 goto LABEL_15;
3901 }
3902 }
3903 return 0;
3904 }
3905 // 506128: using guessed type int areWeLoadingTexture;
3906
3907 //----- (0041FF64) --------------------------------------------------------
3908 int Chest::_41FF64(unsigned int uChestID)
3909 {
3910 unsigned int v1; // ecx@1
3911 signed int result; // eax@1
3912 int v3; // edx@1
3913 ItemGen *pItem; // ecx@2
3914
3915 v1 = uChestID;
3916 result = 0;
3917 v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID];
3918 if ( v3 <= 0 )
3919 {
3920 LABEL_5:
3921 result = -1;
3922 }
3923 else
3924 {
3925 pItem = pChests[v1].mm7__vector_pItems;
3926 while ( pItem->uItemID )
3927 {
3928 ++result;
3929 ++pItem;
3930 if ( result >= v3 )
3931 goto LABEL_5;
3932 }
3933 }
3934 return result;
3935 }
3936
3937 //----- (0041FFA2) --------------------------------------------------------
3938 int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID)
3939 {
3940 int v3; // eax@1
3941 ItemGen *v4; // edi@1
3942 int v5; // esi@1
3943 int result; // eax@11
3944 unsigned int v7; // eax@12
3945 int v8; // edx@12
3946 int v9; // ecx@12
3947 signed int v10; // eax@12
3948 signed int v11; // edi@14
3949 unsigned int v12; // esi@14
3950 int v13; // edi@16
3951 void *v14; // edi@21
3952 int v15; // edi@21
3953 int i; // ecx@21
3954 ItemGen *Src; // [sp+Ch] [bp-18h]@1
3955 signed int v18; // [sp+10h] [bp-14h]@2
3956 int v19; // [sp+14h] [bp-10h]@1
3957 int v20; // [sp+18h] [bp-Ch]@19
3958 signed int v21; // [sp+1Ch] [bp-8h]@1
3959 signed int v22; // [sp+20h] [bp-4h]@3
3960 int v23; // [sp+20h] [bp-4h]@19
3961
3962 v21 = 0;
3963 v3 = pChests[uChestID].uChestBitmapID;
3964 v4 = a2;
3965 v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3];
3966 Src = a2;
3967 v19 = pChestWidthsByType[v3];
3968 if ( a1 == -1 )
3969 {
3970 v18 = _41FF64(uChestID);
3971 if ( v18 == -1 )
3972 return 0;
3973 v22 = 0;
3974 if ( v5 > 0 )
3975 {
3976 while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) )
3977 {
3978 ++v22;
3979 if ( v22 >= v5 )
3980 goto LABEL_8;
3981 }
3982 v21 = v22;
3983 }
3984 LABEL_8:
3985 if ( v22 == v5 )
3986 {
3987 if ( uActiveCharacter )
3988 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
3989 return 0;
3990 }
3991 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
3992 HIWORD(v8) = 0;
3993 v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
3994 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
3995 if ( v10 < 14 )
3996 v10 = 14;
3997 v11 = *(short *)(v9 + 26);
3998 v12 = ((v10 - 14) >> 5) + 1;
3999 if ( v11 < 14 )
4000 v11 = 14;
4001 v13 = ((v11 - 14) >> 5) + 1;
4002 if ( !areWeLoadingTexture )
4003 {
4004 ((Texture *)v9)->Release();
4005 pIcons_LOD->_40F9C5();
4006 }
4007 if ( v13 > 0 )
4008 {
4009 v23 = 0;
4010 v20 = v13;
4011 do
4012 {
4013 if ( (signed int)v12 > 0 )
4014 {
4015 v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID];
4016 LOWORD(v8) = -1 - v21;
4017 v8 <<= 16;
4018 LOWORD(v8) = -1 - v21;
4019 memset32(v14, v8, v12 >> 1);
4020 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
4021 for ( i = v12 & 1; i; --i )
4022 {
4023 *(short *)v15 = v8;
4024 v15 += 2;
4025 }
4026 }
4027 v23 += v19;
4028 --v20;
4029 }
4030 while ( v20 );
4031 }
4032 pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1;
4033 memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u);
4034 result = v21 + 1;
4035 }
4036 else
4037 {
4038 result = 1;
4039 }
4040 return result;
4041 }
4042 // 506128: using guessed type int areWeLoadingTexture;
4043
4044 //----- (0042013E) --------------------------------------------------------
4045 unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID)
4046 {
4047 int v3; // esi@1
4048 unsigned int v4; // ebx@1
4049 int uItemID; // edi@1
4050 int v6; // edx@4
4051 unsigned int v7; // eax@5
4052 Texture *v8; // ecx@5
4053 signed int v9; // eax@5
4054 signed int v10; // edi@7
4055 unsigned int v11; // ebx@7
4056 int v12; // edi@9
4057 int v13; // edx@12
4058 void *v14; // edi@14
4059 int v15; // edi@14
4060 int i; // ecx@14
4061 unsigned int result; // eax@18
4062 __int16 v18; // [sp+Ch] [bp-10h]@1
4063 int v19; // [sp+10h] [bp-Ch]@11
4064 int v20; // [sp+14h] [bp-8h]@12
4065 unsigned int v21; // [sp+18h] [bp-4h]@1
4066
4067 v3 = 5324 * uChestID;
4068 v21 = a1;
4069 v4 = 5324 * uChestID + 36 * uItemIdx;
4070 v18 = uItemIdx;
4071 uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4);
4072 pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4));
4073 if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) )
4074 {
4075 v6 = rand() % 21 + 10;
4076 *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6;
4077 *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6;
4078 }
4079 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
4080 v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
4081 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4082 if ( v9 < 14 )
4083 v9 = 14;
4084 v10 = v8->uTextureHeight;
4085 v11 = ((v9 - 14) >> 5) + 1;
4086 if ( v10 < 14 )
4087 v10 = 14;
4088 v12 = ((v10 - 14) >> 5) + 1;
4089 if ( !areWeLoadingTexture )
4090 {
4091 v8->Release();
4092 pIcons_LOD->_40F9C5();
4093 }
4094 v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)];
4095 if ( v12 > 0 )
4096 {
4097 v13 = 0;
4098 v20 = v12;
4099 do
4100 {
4101 if ( (signed int)v11 > 0 )
4102 {
4103 v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID];
4104 LOWORD(v3) = -1 - v21;
4105 v3 <<= 16;
4106 LOWORD(v3) = -1 - v21;
4107 memset32(v14, v3, v11 >> 1);
4108 v15 = (int)((char *)v14 + 4 * (v11 >> 1));
4109 for ( i = v11 & 1; i; --i )
4110 {
4111 *(short *)v15 = v3;
4112 v15 += 2;
4113 }
4114 }
4115 v13 += v19;
4116 --v20;
4117 }
4118 while ( v20 );
4119 }
4120 result = v21 + 2662 * uChestID;
4121 pChests[0].pInventoryIndices[result] = v18 + 1;
4122 return result;
4123 }
4124 // 506128: using guessed type int areWeLoadingTexture;
4125
4126 //----- (00420284) --------------------------------------------------------
4127 char *Chest::_420284(unsigned int uChestID)
4128 {
4129 int v1; // ebx@1
4130 unsigned int v2; // esi@1
4131 unsigned int v3; // esi@1
4132 int uChestArea; // edi@1
4133 int v5; // eax@2
4134 int v6; // ebx@11
4135 char *result; // eax@18
4136 char Dst[144]; // [sp+Ch] [bp-A0h]@1
4137 int v9; // [sp+9Ch] [bp-10h]@10
4138 unsigned int v10; // [sp+A0h] [bp-Ch]@1
4139 unsigned int v11; // [sp+A4h] [bp-8h]@8
4140 ItemGen *v12; // [sp+A8h] [bp-4h]@9
4141
4142 v1 = 0;
4143 v2 = uChestID;
4144 v10 = uChestID;
4145 pRenderer->ClearZBuffer(0, 479);
4146 v3 = v2;
4147 uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID];
4148 memset(Dst, 0, 0x90u);
4149 if ( uChestArea > 0 )
4150 {
4151 do
4152 {
4153 do
4154 v5 = (unsigned __int8)rand();
4155 while ( v5 >= uChestArea );
4156 while ( Dst[v5] )
4157 {
4158 ++v5;
4159 if ( v5 == uChestArea )
4160 v5 = 0;
4161 }
4162 Dst[v5] = v1++;
4163 }
4164 while ( v1 < uChestArea );
4165 }
4166 v11 = 0;
4167 if ( uChestArea > 0 )
4168 {
4169 v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes;
4170 do
4171 {
4172 v9 = v12->uItemID;
4173 if ( v9 )
4174 {
4175 v6 = 0;
4176 while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) )
4177 {
4178 ++v6;
4179 if ( v6 >= uChestArea )
4180 break;
4181 }
4182 if(v6<uChestArea)
4183 {
4184 Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10);
4185 if ( pChests[v3].uFlags & 4 )
4186 v12->SetIdentified();
4187 }
4188 }
4189 ++v11;
4190 ++v12;
4191 }
4192 while ( (signed int)v11 < uChestArea );
4193 }
4194 result = (char *)&pChests[v3].uFlags;
4195 pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2;
4196 return result;
4197 }
4198 // 420284: using guessed type char Dst[144];
4199 3833
4200 //----- (0042038D) -------------------------------------------------------- 3834 //----- (0042038D) --------------------------------------------------------
4201 void __cdecl sub_42038D() 3835 void __cdecl sub_42038D()
4202 { 3836 {
4203 POINT *v0; // esi@2 3837 POINT *v0; // esi@2
4217 + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); 3851 + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
4218 v2 = _w->GetDisplayName(); 3852 v2 = _w->GetDisplayName();
4219 sub_41C0B8_set_status_string(v2); 3853 sub_41C0B8_set_status_string(v2);
4220 } 3854 }
4221 } 3855 }
4222 }
4223
4224 //----- (0042041E) --------------------------------------------------------
4225 bool Chest::Open(unsigned int uChestID)
4226 {
4227 char *v1; // edi@5
4228 unsigned int v2; // eax@8
4229 GUIWindow *v3; // eax@15
4230 int v5; // edx@16
4231 int v6; // eax@16
4232 ODMFace *v7; // eax@19
4233 int v8; // edx@19
4234 int v9; // edi@19
4235 signed int v10; // ebx@19
4236 int v11; // ecx@19
4237 int v12; // eax@19
4238 BLVFace *v13; // eax@20
4239 int v14; // ebx@21
4240 int v15; // edi@21
4241 int v16; // ecx@22
4242 __int64 v17; // qax@22
4243 double v18; // st7@23
4244 double v19; // st6@23
4245 double v20; // st7@23
4246 int v21; // ecx@26
4247 char v22[12]; // ST4C_12@28
4248 unsigned int *v23; // edi@28
4249 unsigned __int16 v24; // di@28
4250 signed int v25; // ecx@28
4251 char *v26; // edx@29
4252 unsigned __int16 v27; // ax@32
4253 //LayingItem a1; // [sp+14h] [bp-B0h]@28
4254 int v29; // [sp+84h] [bp-40h]@16
4255 int v30; // [sp+88h] [bp-3Ch]@16
4256 int v31; // [sp+8Ch] [bp-38h]@16
4257 int v32; // [sp+90h] [bp-34h]@16
4258 float v33; // [sp+94h] [bp-30h]@23
4259 char *v34; // [sp+98h] [bp-2Ch]@5
4260 int v35; // [sp+9Ch] [bp-28h]@16
4261 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
4262 int a4; // [sp+ACh] [bp-18h]@1
4263 int v38; // [sp+B0h] [bp-14h]@21
4264 int sRotX; // [sp+B4h] [bp-10h]@23
4265 float v40; // [sp+B8h] [bp-Ch]@23
4266 float v41; // [sp+BCh] [bp-8h]@23
4267 int sRotY; // [sp+C0h] [bp-4h]@8
4268
4269 a4 = uChestID;
4270 if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 )
4271 return 0;
4272 ++pIcons_LOD->uTexturePacksCount;
4273 if ( !pIcons_LOD->uNumPrevLoadedFiles )
4274 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
4275 v1 = (char *)&pChests[uChestID].uFlags;
4276 v34 = v1;
4277 if ( !(*v1 & CHEST_ITEMS_PLACED) )
4278 Chest::_420284(uChestID);
4279 if ( !uActiveCharacter )
4280 return 0;
4281 *(float *)&sRotY = 0.0;
4282 v2 = pMapStats->GetMapInfo(pCurrentMapName);
4283 if ( !(*v1 & 1) || !v2 )
4284 goto LABEL_12;
4285 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 )
4286 {
4287 v29 = 811;
4288 v30 = 812;
4289 v31 = 813;
4290 v32 = 814;
4291 v5 = rand() % 4;
4292 v6 = dword_5B5920 >> 3;
4293 v35 = v5;
4294 if ( (dword_5B5920 & 7) == OBJECT_Decoration)
4295 {
4296 v16 = v6;
4297 v14 = pLevelDecorations[v6].vPosition.x;
4298 v38 = pLevelDecorations[v6].vPosition.y;
4299 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight;
4300 v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1);
4301 }
4302 else
4303 {
4304 if ( (dword_5B5920 & 7) != OBJECT_BModel)
4305 goto LABEL_12;
4306 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
4307 {
4308 v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F];
4309 v8 = v7->pBoundingBox.y1;
4310 v9 = v7->pBoundingBox.z2;
4311 v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2;
4312 v11 = v7->pBoundingBox.y2;
4313 v12 = v7->pBoundingBox.z1;
4314 }
4315 else
4316 {
4317 v13 = &pIndoor->pFaces[v6];
4318 v8 = v13->pBounding.y1;
4319 v9 = v13->pBounding.z2;
4320 v10 = v13->pBounding.x1 + v13->pBounding.x2;
4321 v11 = v13->pBounding.y2;
4322 v12 = v13->pBounding.z1;
4323 }
4324 v14 = v10 >> 1;
4325 v38 = (v8 + v11) >> 1;
4326 v15 = (v12 + v9) >> 1;
4327 }
4328 v18 = (double)pParty->vPosition.x - (double)v14;
4329 *(float *)&a4 = v18;
4330 v19 = (double)pParty->vPosition.y - (double)v38;
4331 v33 = v19;
4332 v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15;
4333 *(float *)&sRotY = v19 * v19;
4334 *(float *)&sRotX = v18 * v18;
4335 v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY);
4336 v40 = v20;
4337 if ( v20 <= 1.0 )
4338 {
4339 *(float *)&sRotX = 0.0;
4340 *(float *)&sRotY = 0.0;
4341 }
4342 else
4343 {
4344 sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY);
4345 sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33);
4346 sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41);
4347 }
4348 v21 = 256;
4349 if ( v40 < 256.0 )
4350 v21 = (signed __int64)v40 / 4;
4351 *(int *)&v22[8] = v15;
4352 *(_QWORD *)v22 = __PAIR__(v38, v14);
4353 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y);
4354 v23 = (unsigned int *)(&v29 + v35);
4355 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0);
4356
4357 LayingItem a1; // [sp+14h] [bp-B0h]@28
4358 //LayingItem::LayingItem(&a1);
4359
4360 a1.stru_24.Reset();
4361 v24 = *(short *)v23;
4362 v25 = 0;
4363 a1.field_50 = 0;
4364 a1.field_4C = 0;
4365 a1.field_48 = 0;
4366 a1.field_54 = 0;
4367 a1.uItemType = v24;
4368 if ( (signed int)pObjectList->uNumObjects <= 0 )
4369 {
4370 LABEL_32:
4371 v27 = 0;
4372 }
4373 else
4374 {
4375 v26 = (char *)&pObjectList->pObjects->uObjectID;
4376 while ( v24 != *(short *)v26 )
4377 {
4378 ++v25;
4379 v26 += 56;
4380 if ( v25 >= (signed int)pObjectList->uNumObjects )
4381 goto LABEL_32;
4382 }
4383 v27 = v25;
4384 }
4385 a1.uObjectDescID = v27;
4386 a1.vPosition.y = pOut.z;
4387 a1.vPosition.x = pOut.x;
4388 a1.vPosition.z = pOut.y;
4389 a1.uSoundID = 0;
4390 a1.uAttributes = 48;
4391 a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y);
4392 a1.uSpriteFrameID = 0;
4393 a1.field_58_pid = 0;
4394 a1.field_5C = 0;
4395 a1.uFacing = 0;
4396 a1.Create(0, 0, 0, 0);
4397 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
4398 a1._438E35();
4399 *v34 &= 0xFEu;
4400 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 )
4401 {
4402 qword_A750D8 = 256i64;
4403 word_A750E0 = 5;
4404 word_A750E2 = uActiveCharacter;
4405 }
4406 pIcons_LOD->_4114F2();
4407 dword_507CD8 = 0;
4408 return 0;
4409 }
4410 *v1 &= 0xFEu;
4411 sRotY = 1;
4412 LABEL_12:
4413 pAudioPlayer->StopChannels(-1, -1);
4414 pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0);
4415 if ( *(float *)&sRotY != 0.0 )
4416 {
4417 if ( !dword_507CD8 )
4418 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
4419 }
4420 dword_507CD8 = 0;
4421 v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0);
4422 pGUIWindow_CurrentMenu = v3;
4423 pChestWindow = v3;
4424 pBtn_ExitCancel = v3->CreateButton(
4425 0x1D7u,
4426 0x1BDu,
4427 0xA9u,
4428 0x23u,
4429 1,
4430 0,
4431 0x71u,
4432 0,
4433 0,
4434 pGlobalTXT_LocalizationStrings[79],// Exit
4435 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
4436 0);
4437 pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
4438 pCurrentScreen = SCREEN_CHEST;
4439 pEventTimer->Pause();
4440 return 1;
4441 }
4442
4443 //----- (0042092D) --------------------------------------------------------
4444 void Chest::DrawChestUI(unsigned int uChestID)
4445 {
4446 Render *v1; // edi@1
4447 unsigned int v2; // ebx@1
4448 unsigned int v3; // ebx@1
4449 int v4; // eax@1
4450 unsigned int v5; // eax@1
4451 int v6; // ecx@3
4452 unsigned int v7; // eax@4
4453 Texture *v8; // esi@4
4454 signed int v9; // ecx@4
4455 signed int v10; // edx@4
4456 signed int v11; // eax@4
4457 int v12; // eax@6
4458 int v13; // eax@6
4459 unsigned int v14; // ST34_4@8
4460 int v15; // edi@8
4461 int *v16; // [sp+Ch] [bp-28h]@1
4462 int v17; // [sp+10h] [bp-24h]@4
4463 int v18; // [sp+14h] [bp-20h]@1
4464 signed int v19; // [sp+18h] [bp-1Ch]@1
4465 int v20; // [sp+1Ch] [bp-18h]@1
4466 signed int v21; // [sp+20h] [bp-14h]@1
4467 char *v22; // [sp+2Ch] [bp-8h]@2
4468 signed int v23; // [sp+30h] [bp-4h]@1
4469
4470 v1 = pRenderer;
4471 v2 = uChestID;
4472 v16 = pRenderer->pActiveZBuffer;
4473 pRenderer->ClearZBuffer(0, 479);
4474 v3 = v2;
4475 v4 = pChests[v3].uChestBitmapID;
4476 v20 = pChestSmthn1ByType[v4];
4477 v18 = pChestSmthn2ByType[v4];
4478 v21 = pChestWidthsByType[v4];
4479 v19 = pChestHeightsByType[v4];
4480 sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
4481 v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
4482 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
4483 v23 = 0;
4484 if ( v21 * v19 > 0 )
4485 {
4486 v22 = (char *)pChests[v3].pInventoryIndices;
4487 do
4488 {
4489 v6 = *(short *)v22;
4490 if ( v6 > 0 )
4491 {
4492 v17 = v18 + 32 * v23 / v19;
4493 v7 = pIcons_LOD->LoadTexture(
4494 pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
4495 TEXTURE_16BIT_PALETTE);
4496 v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0);
4497 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4498 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26);
4499 v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4500 if ( v9 < 14 )
4501 v11 = 14;
4502 v12 = v11 - 14;
4503 LOBYTE(v12) = v12 & 0xE0;
4504 v13 = v12 + 32;
4505 if ( (signed int)v8->uTextureHeight < 14 )
4506 v10 = 14;
4507 v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1);
4508 v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1);
4509 pRenderer->DrawTextureTransparent(
4510 v14,
4511 v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1),
4512 v8);
4513 sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1);
4514 v1 = pRenderer;
4515 }
4516 ++v23;
4517 v22 += 2;
4518 }
4519 while ( v23 < v21 * v19 );
4520 }
4521 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
4522 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
4523 } 3856 }
4524 3857
4525 //----- (00420B13) -------------------------------------------------------- 3858 //----- (00420B13) --------------------------------------------------------
4526 void __fastcall sub_420B13(int a1, int a2) 3859 void __fastcall sub_420B13(int a1, int a2)
4527 { 3860 {