comparison mm7_1.cpp @ 421:80a5aab68b67

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