annotate Chest.cpp @ 1440:a72236d60edc

m
author Ritor1
date Sat, 27 Jul 2013 09:36:29 +0600
parents c0b273d33338
children b67a3e0d6fc3
rev   line source
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1110
diff changeset
1 #ifdef _MSC_VER
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1110
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1110
diff changeset
3 #endif
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1110
diff changeset
4
0
Ritor1
parents:
diff changeset
5 #include <stdio.h>
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
6 #include <assert.h>
0
Ritor1
parents:
diff changeset
7
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
8 #include "BSPModel.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
9 #include "Items.h"
0
Ritor1
parents:
diff changeset
10 #include "Chest.h"
Ritor1
parents:
diff changeset
11 #include "FrameTableInc.h"
Ritor1
parents:
diff changeset
12 #include "Allocator.h"
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
13 #include "LOD.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
14 #include "MapInfo.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
15 #include "Actor.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
16 #include "Outdoor.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
17 #include "DecorationList.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
18 #include "Party.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
19 #include "AudioPlayer.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
20 #include "Math.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
21 #include "Texts.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
22 #include "ObjectList.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
23 #include "GUIWindow.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
24 #include "Time.h"
0
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26 #include "mm7_data.h"
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 832
diff changeset
27 #include "MM7.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
28 #include "SpriteObject.h"
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
29 #include "Mouse.h"
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
30 #include "Viewport.h"
0
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32 size_t uNumChests; // idb
Ritor1
parents:
diff changeset
33 struct ChestList *pChestList;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
34 std::array<Chest, 20> pChests;
0
Ritor1
parents:
diff changeset
35
Ritor1
parents:
diff changeset
36
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
37 const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42};
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
38 const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34};
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
39 const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
40 const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
0
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
43 //----- (0042041E) --------------------------------------------------------
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
44 bool Chest::Open( signed int uChestID )
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
45 {
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
46 unsigned int v2; // eax@8
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
47 GUIWindow *v3; // eax@15
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
48 int v5; // edx@16
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
49 int v6; // eax@16
1440
Ritor1
parents: 1405
diff changeset
50 ODMFace *pOdmFace; // eax@19
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
51 int v8; // edx@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
52 int v9; // edi@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
53 signed int v10; // ebx@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
54 int v11; // ecx@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
55 int v12; // eax@19
1440
Ritor1
parents: 1405
diff changeset
56 BLVFace *pBlvFace; // eax@20
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
57 int v14; // ebx@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
58 int v15; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
59 __int64 v17; // qax@22
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
60 double v18; // st7@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
61 double v19; // st6@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
62 double v20; // st7@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
63 int v21; // ecx@26
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
64 char v22[12]; // ST4C_12@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
65 unsigned int *v23; // edi@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
66 unsigned __int16 v24; // di@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
67 signed int v25; // ecx@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
68 char *v26; // edx@29
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
69 unsigned __int16 v27; // ax@32
1052
d48c762de563 -nomarg
Nomad
parents: 1018
diff changeset
70 int v29[4]; // [sp+84h] [bp-40h]@16
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
71 float v33; // [sp+94h] [bp-30h]@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
72 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
73 int a4; // [sp+ACh] [bp-18h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
74 int v38; // [sp+B0h] [bp-14h]@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
75 int sRotX; // [sp+B4h] [bp-10h]@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
76 float v40; // [sp+B8h] [bp-Ch]@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
77 float v41; // [sp+BCh] [bp-8h]@23
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
78 int sRotY; // [sp+C0h] [bp-4h]@8
1440
Ritor1
parents: 1405
diff changeset
79 SpriteObject a1; // [sp+14h] [bp-B0h]@28
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
80
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
81 assert(uChestID < 20);
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
82 if ((uChestID <0)&&(uChestID >=20) )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
83 return false;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
84 auto chest = &pChests[uChestID];
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
85
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
86 ++pIcons_LOD->uTexturePacksCount;
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
87 if (!pIcons_LOD->uNumPrevLoadedFiles)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
88 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
89
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
90 if (!chest->Initialized())
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
91 Chest::PlaceItems(uChestID);
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
92
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
93 if ( !uActiveCharacter )
1440
Ritor1
parents: 1405
diff changeset
94 return false;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
95 *(float *)&sRotY = 0.0;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
96 v2 = pMapStats->GetMapInfo(pCurrentMapName.data());
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
97 if ( !chest->Trapped() || !v2 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
98 goto LABEL_12;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
99 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
100 {
1052
d48c762de563 -nomarg
Nomad
parents: 1018
diff changeset
101 v29[0] = 811;
d48c762de563 -nomarg
Nomad
parents: 1018
diff changeset
102 v29[1] = 812;
d48c762de563 -nomarg
Nomad
parents: 1018
diff changeset
103 v29[2] = 813;
d48c762de563 -nomarg
Nomad
parents: 1018
diff changeset
104 v29[3] = 814;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
105 v5 = rand() % 4;
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 832
diff changeset
106 v6 = PID_ID(EvtTargetObj);
ceef50611567 * AI fixed (temporary)
zipi
parents: 832
diff changeset
107 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
108 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
109 v14 = pLevelDecorations[v6].vPosition.x;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
110 v38 = pLevelDecorations[v6].vPosition.y;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
111 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight;
1440
Ritor1
parents: 1405
diff changeset
112 v15 = pLevelDecorations[v6].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
113 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
114 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
115 {
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 832
diff changeset
116 if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
117 goto LABEL_12;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
118 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
119 {
1440
Ritor1
parents: 1405
diff changeset
120 pOdmFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F];
Ritor1
parents: 1405
diff changeset
121 v8 = pOdmFace->pBoundingBox.y1;
Ritor1
parents: 1405
diff changeset
122 v9 = pOdmFace->pBoundingBox.z2;
Ritor1
parents: 1405
diff changeset
123 v10 = pOdmFace->pBoundingBox.x1 + pOdmFace->pBoundingBox.x2;
Ritor1
parents: 1405
diff changeset
124 v11 = pOdmFace->pBoundingBox.y2;
Ritor1
parents: 1405
diff changeset
125 v12 = pOdmFace->pBoundingBox.z1;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
126 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
127 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
128 {
1440
Ritor1
parents: 1405
diff changeset
129 pBlvFace = &pIndoor->pFaces[v6];
Ritor1
parents: 1405
diff changeset
130 v8 = pBlvFace->pBounding.y1;
Ritor1
parents: 1405
diff changeset
131 v9 = pBlvFace->pBounding.z2;
Ritor1
parents: 1405
diff changeset
132 v10 = pBlvFace->pBounding.x1 + pBlvFace->pBounding.x2;
Ritor1
parents: 1405
diff changeset
133 v11 = pBlvFace->pBounding.y2;
Ritor1
parents: 1405
diff changeset
134 v12 = pBlvFace->pBounding.z1;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
135 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
136 v14 = v10 >> 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
137 v38 = (v8 + v11) >> 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
138 v15 = (v12 + v9) >> 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
139 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
140 v18 = (double)pParty->vPosition.x - (double)v14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
141 *(float *)&a4 = v18;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
142 v19 = (double)pParty->vPosition.y - (double)v38;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
143 v33 = v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
144 v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
145 *(float *)&sRotY = v19 * v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
146 *(float *)&sRotX = v18 * v18;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
147 v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
148 v40 = v20;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
149 if ( v20 <= 1.0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
150 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
151 *(float *)&sRotX = 0.0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
152 *(float *)&sRotY = 0.0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
153 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
154 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
155 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
156 sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
157 sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
158 sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
159 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
160 v21 = 256;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
161 if ( v40 < 256.0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
162 v21 = (signed __int64)v40 / 4;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
163 *(int *)&v22[8] = v15;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
164 *(_QWORD *)v22 = __PAIR__(v38, v14);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
165 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y);
1440
Ritor1
parents: 1405
diff changeset
166 v23 = (unsigned int *)(&v29 + v5);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
167 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
168
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
169 a1.stru_24.Reset();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
170 v24 = *(short *)v23;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
171 v25 = 0;
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
172 a1.spell_skill = 0;
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
173 a1.spell_level = 0;
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
174 a1.spell_id = 0;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
175 a1.field_54 = 0;
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 469
diff changeset
176 a1.uType = v24;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
177 if ( (signed int)pObjectList->uNumObjects <= 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
178 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
179 LABEL_32:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
180 v27 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
181 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
182 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
183 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
184 v26 = (char *)&pObjectList->pObjects->uObjectID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
185 while ( v24 != *(short *)v26 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
186 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
187 ++v25;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
188 v26 += 56;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
189 if ( v25 >= (signed int)pObjectList->uNumObjects )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
190 goto LABEL_32;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
191 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
192 v27 = v25;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
193 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
194 a1.uObjectDescID = v27;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
195 a1.vPosition.y = pOut.z;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
196 a1.vPosition.x = pOut.x;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
197 a1.vPosition.z = pOut.y;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
198 a1.uSoundID = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
199 a1.uAttributes = 48;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
200 a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
201 a1.uSpriteFrameID = 0;
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
202 a1.spell_caster_pid = 0;
823
c1da83d8223f More spell renames
Nomad
parents: 822
diff changeset
203 a1.spell_target_pid = 0;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
204 a1.uFacing = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
205 a1.Create(0, 0, 0, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
206 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
207 a1._438E35();
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
208 chest->SetInitialized(false);//*v34 &= 0xFEu;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
209 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
210 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
211 qword_A750D8 = 256i64;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
212 word_A750E0 = 5;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
213 word_A750E2 = uActiveCharacter;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
214 }
1405
c0b273d33338 RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents: 1404
diff changeset
215 pIcons_LOD->RemoveTexturesPackFromTextureList();
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
216 dword_507CD8 = 0;
1440
Ritor1
parents: 1405
diff changeset
217 return false;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
218 }
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
219 chest->SetInitialized(false);//*v1 &= 0xFEu;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
220 sRotY = 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
221 LABEL_12:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
222 pAudioPlayer->StopChannels(-1, -1);
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
223 pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
224 if ( *(float *)&sRotY != 0.0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
225 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
226 if ( !dword_507CD8 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
227 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
228 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
229 dword_507CD8 = 0;
948
5a2dbb00c399 Code cleaning.
Nomad
parents: 945
diff changeset
230 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0);
5a2dbb00c399 Code cleaning.
Nomad
parents: 945
diff changeset
231 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit
987
9e132060ada3 UIMSG_CHEST_ClickItem
Ritor1
parents: 948
diff changeset
232 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
233 pCurrentScreen = SCREEN_CHEST;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
234 pEventTimer->Pause();
1440
Ritor1
parents: 1405
diff changeset
235 return true;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
236 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
237
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
238 //----- (0042092D) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
239 void Chest::DrawChestUI(signed int uChestID)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
240 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
241
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
242 int chestBitmapId; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
243 unsigned int v5; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
244 int chest_item_index; // ecx@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
245 unsigned int item_texture_id; // eax@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
246 Texture *item_texture; // esi@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
247 signed int itemPixelWidth; // ecx@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
248 signed int itemPixelHeght; // edx@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
249 signed int v11; // eax@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
250 int v12; // eax@6
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
251 int v13; // eax@6
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
252 unsigned int itemPixelPosX; // ST34_4@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
253 int itemPixelPosY; // edi@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
254 int *v16; // [sp+Ch] [bp-28h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
255 int v17; // [sp+10h] [bp-24h]@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
256 int chest_offs_y; // [sp+14h] [bp-20h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
257 signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
258 int chest_offs_x; // [sp+1Ch] [bp-18h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
259 signed int chestWidthCells; // [sp+20h] [bp-14h]@1
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
260 signed int item_counter; // [sp+30h] [bp-4h]@1
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
261
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
262 v16 = pRenderer->pActiveZBuffer;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
263 pRenderer->ClearZBuffer(0, 479);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
264 chestBitmapId = pChests[uChestID].uChestBitmapID;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
265 chest_offs_x = pChestPixelOffsetX[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
266 chest_offs_y = pChestPixelOffsetY[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
267 chestWidthCells = pChestWidthsByType[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
268 chestHeghtCells = pChestHeightsByType[chestBitmapId];
1394
8ea496564034 Some LightmapBuilder renames.
Nomad
parents: 1297
diff changeset
269 sprintfex(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
270 v5 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
271 pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5));
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
272
1394
8ea496564034 Some LightmapBuilder renames.
Nomad
parents: 1297
diff changeset
273 for (item_counter = 0; item_counter < chestWidthCells * chestHeghtCells; ++item_counter)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
274 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
275 chest_item_index = pChests[uChestID].pInventoryIndices[item_counter];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
276 if ( chest_item_index > 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
277 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
278 item_texture_id = pIcons_LOD->LoadTexture(
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
279 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
1394
8ea496564034 Some LightmapBuilder renames.
Nomad
parents: 1297
diff changeset
280 pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index - 1].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
281 item_texture = pIcons_LOD->GetTexture(item_texture_id);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
282 itemPixelWidth = item_texture->uTextureWidth;
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
283 itemPixelHeght = item_texture->uTextureHeight;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
284 if ( itemPixelWidth < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
285 itemPixelWidth = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
286 v12 = itemPixelWidth - 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
287 v12 = v12 & 0xFFFFFFE0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
288 v13 = v12 + 32;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
289 if ( itemPixelHeght < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
290 itemPixelHeght = 14;
600
db4a23580e6c Chest item view fixed, gold can be taken
Gloval
parents: 592
diff changeset
291 itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2);
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
292 itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) +
600
db4a23580e6c Chest item view fixed, gold can be taken
Gloval
parents: 592
diff changeset
293 ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2);
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
294 pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture);
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
295 sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
296 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
297 }
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
298 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
299 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
300
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
301
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
302 //----- (0041FE71) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
303 bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, signed int uChestID )
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
304 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
305 int v3; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
306 unsigned int item_texture_id; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
307 Texture *item_texture; // ecx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
308 signed int v6; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
309 signed int v7; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
310 signed int v8; // eax@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
311 int texture_cell_width; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
312 int texture_cell_height; // ebx@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
313 int _row; // esi@9
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
314 int _cell_rows; // edx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
315 int _column; // ecx@11
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
316 char *v14; // eax@12
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
317 int chest_cell_heght; // [sp+Ch] [bp-Ch]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
318 signed int v17; // [sp+10h] [bp-8h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
319 signed int chest_cell_width; // [sp+14h] [bp-4h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
320
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
321 chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
322 chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
323 item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
324 item_texture = pIcons_LOD->GetTexture(item_texture_id);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
325 v6 = item_texture->uTextureWidth;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
326 if ( v6 < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
327 v6 = 14;
1110
cf6cd674c398 bitwise operator ambiguity reduced
Grumpy7
parents: 1052
diff changeset
328 texture_cell_width = ((v6 - 14) >> 5) + 1;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
329 v8 = item_texture->uTextureHeight;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
330 if ( v8 < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
331 v8 = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
332 texture_cell_height = ((v8 - 14) >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
333 if ( !areWeLoadingTexture )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
334 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
335 item_texture->Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 987
diff changeset
336 pIcons_LOD->SyncLoadedFilesCount();
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
337 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
338 if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) &&
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
339 (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
340 { //we not put over borders
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
341 _row = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
342 if ( texture_cell_height <= 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
343 return true;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
344 _cell_rows = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
345 while ( 1 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
346 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
347 _column = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
348 if ( texture_cell_width > 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
349 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
350 while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
351 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
352 ++_column;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
353 if ( _column >= texture_cell_width )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
354 break;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
355 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
356 if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0)
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
357 return false;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
358 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
359 _cell_rows += chest_cell_width;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
360 ++_row;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
361 if ( _row >= texture_cell_height )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
362 return true;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
363 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
364
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
365 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
366 return false;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
367 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
368 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
369
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
370 //----- (0041FF64) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
371 int Chest::CountChestItems(signed int uChestID)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
372 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
373 signed int item_count; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
374 int max_items; // edx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
375 item_count = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
376 max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
377 if ( max_items <= 0 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
378 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
379 item_count = -1;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
380 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
381 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
382 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
383 while ( pChests[uChestID].igChestItems[item_count].uItemID )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
384 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
385 ++item_count;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
386 if ( item_count >= max_items )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
387 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
388 item_count = -1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
389 break;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
390 }
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
391 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
392 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
393 return item_count;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
394 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
395
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
396 //----- (0041FFA2) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
397 int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
398 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
399 int v3; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
400 ItemGen *v4; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
401 int v5; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
402 int result; // eax@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
403 unsigned int v7; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
404 int v8; // edx@12
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
405 Texture *v9; // ecx@12
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
406 signed int v10; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
407 signed int v11; // edi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
408 unsigned int v12; // esi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
409 int v13; // edi@16
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
410 void *v14; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
411 int v15; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
412 int i; // ecx@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
413 ItemGen *Src; // [sp+Ch] [bp-18h]@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
414 signed int item_in_chest_count; // [sp+10h] [bp-14h]@2
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
415 int v19; // [sp+14h] [bp-10h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
416 int v20; // [sp+18h] [bp-Ch]@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
417 signed int v21; // [sp+1Ch] [bp-8h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
418 signed int v22; // [sp+20h] [bp-4h]@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
419 int v23; // [sp+20h] [bp-4h]@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
420
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
421 v21 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
422 v3 = pChests[uChestID].uChestBitmapID;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
423 v4 = put_item;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
424 v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
425 Src = put_item;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
426 v19 = pChestWidthsByType[v3];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
427 if ( position == -1 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
428 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
429 item_in_chest_count = CountChestItems(uChestID);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
430 if ( item_in_chest_count == -1 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
431 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
432 v22 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
433 if ( v5 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
434 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
435 while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
436 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
437 ++v22;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
438 if ( v22 >= v5 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
439 goto LABEL_8;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
440 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
441 v21 = v22;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
442 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
443 LABEL_8:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
444 if ( v22 == v5 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
445 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
446 if ( uActiveCharacter )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
447 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
448 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
449 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
450 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
451 HIWORD(v8) = 0;
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
452 v9 = pIcons_LOD->GetTexture(v7);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
453 v10 = v9->uTextureWidth;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
454 if ( v10 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
455 v10 = 14;
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
456 v11 = v9->uTextureHeight;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
457 v12 = ((v10 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
458 if ( v11 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
459 v11 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
460 v13 = ((v11 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
461 if ( !areWeLoadingTexture )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
462 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
463 ((Texture *)v9)->Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 987
diff changeset
464 pIcons_LOD->SyncLoadedFilesCount();
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
465 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
466 if ( v13 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
467 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
468 v23 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
469 v20 = v13;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
470 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
471 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
472 if ( (signed int)v12 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
473 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
474 v14 = &pChests[uChestID].pInventoryIndices[v21 + v23];
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
475 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
476 v8 <<= 16;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
477 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
478 memset32(v14, v8, v12 >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
479 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
480 for ( i = v12 & 1; i; --i )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
481 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
482 *(short *)v15 = v8;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
483 v15 += 2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
484 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
485 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
486 v23 += v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
487 --v20;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
488 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
489 while ( v20 );
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
490 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
491 pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
492 memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen));
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
493 result = v21 + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
494 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
495 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
496 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
497 result = 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
498 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
499 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
500 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
501 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
502
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
503 //----- (0042013E) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
504 void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed int uChestID )
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
505 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
506 int uItemID; // edi@1
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
507 int v6; // edx@4
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
508 unsigned int v7; // eax@5
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
509 Texture *v8; // ecx@5
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
510 signed int v9; // eax@5
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
511 signed int v10; // edi@7
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
512 unsigned int texture_cell_width; // ebx@7
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
513 int textute_cell_height; // edi@9
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
514 int chest_cell_row_pos; // edx@12
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
515 int chest_cell_width; // [sp+10h] [bp-Ch]@11
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
516
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
517 uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
518 pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]);
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
519 if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
520 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
521 v6 = rand() % 21 + 10;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
522 pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
523 pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
524 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
525 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
526 v8 = pIcons_LOD->GetTexture(v7);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
527 v9 = v8->uTextureWidth;
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
528 if ( v9 < 14 )
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
529 v9 = 14;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
530 v10 = v8->uTextureHeight;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
531 texture_cell_width = ((v9 - 14) >> 5) + 1;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
532 if ( v10 < 14 )
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
533 v10 = 14;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
534 textute_cell_height = ((v10 - 14) >> 5) + 1;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
535 if ( !areWeLoadingTexture )
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
536 {
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
537 v8->Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 987
diff changeset
538 pIcons_LOD->SyncLoadedFilesCount();
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
539 }
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
540 chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID];
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
541 chest_cell_row_pos = 0;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
542 for(int i=0; i<textute_cell_height; ++i)
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
543 {
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
544 for (int j=0; j<texture_cell_width; ++j)
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
545 {
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
546 pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1);
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
547 }
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
548 chest_cell_row_pos += chest_cell_width;
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
549 }
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
550 pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
551 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
552 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
553
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
554 //----- (00420284) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
555 void Chest::PlaceItems(signed int uChestID )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
556 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
557 int uChestArea; // edi@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
558 int random_chest_pos; // eax@2
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
559 int test_position; // ebx@11
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
560 char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
561 int chest_item_id; // [sp+9Ch] [bp-10h]@10
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
562 unsigned int items_counter; // [sp+A4h] [bp-8h]@8
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
563
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
564 pRenderer->ClearZBuffer(0, 479);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
565 uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
566 memset(chest_cells_map, 0, 144);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
567 //fill cell map at random positions
608
Ritor1
parents: 544
diff changeset
568 for ( items_counter = 0; items_counter < uChestArea; ++items_counter )
Ritor1
parents: 544
diff changeset
569 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
570 //get random position in chest
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
571 do
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
572 random_chest_pos = (unsigned __int8)rand();
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
573 while ( random_chest_pos >= uChestArea );
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
574 //if this pos occupied move to next
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
575 while ( chest_cells_map[random_chest_pos] )
608
Ritor1
parents: 544
diff changeset
576 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
577 ++random_chest_pos;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
578 if ( random_chest_pos == uChestArea )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
579 random_chest_pos = 0;
608
Ritor1
parents: 544
diff changeset
580 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
581 chest_cells_map[random_chest_pos] = items_counter;
608
Ritor1
parents: 544
diff changeset
582 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
583 items_counter = 0;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
584
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
585 for (items_counter = 0; items_counter<uChestArea; ++items_counter)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
586 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
587 chest_item_id = pChests[uChestID].igChestItems[items_counter].uItemID;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
588 if ( chest_item_id )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
589 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
590 test_position = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
591 while ( !Chest::CanPlaceItemAt((unsigned __int8)chest_cells_map[test_position], chest_item_id, uChestID) )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
592 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
593 ++test_position;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
594 if ( test_position >= uChestArea )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
595 break;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
596 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
597 if(test_position<uChestArea)
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
598 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
599 Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], items_counter, uChestID);
592
96f48cfdd657 some flags
Nomad
parents: 544
diff changeset
600 if ( pChests[uChestID].uFlags & CHEST_OPENED)
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
601 pChests[uChestID].igChestItems[items_counter].SetIdentified();
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
602 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
603 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
604 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
605 pChests[uChestID].SetInitialized(true);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
606 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
607 // 420284: using guessed type char Dst[144];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
608
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
609 //----- (00448A17) --------------------------------------------------------
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
610 void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle)
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
611 {
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
612 unsigned __int16 *pFlags; // eax@3
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
613
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
614 if ( uChestID >= 0 && uChestID <= 19 )
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
615 {
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
616 pFlags = &pChests[uChestID].uFlags;
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
617 if ( bToggle )
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
618 *pFlags |= uFlag;
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
619 else
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
620 *pFlags &= ~uFlag;
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
621 }
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
622 }
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
623
0
Ritor1
parents:
diff changeset
624 //----- (00458B03) --------------------------------------------------------
Ritor1
parents:
diff changeset
625 void ChestList::ToFile()
Ritor1
parents:
diff changeset
626 {
Ritor1
parents:
diff changeset
627 ChestList *v1; // esi@1
Ritor1
parents:
diff changeset
628 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
629 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
630
Ritor1
parents:
diff changeset
631 v1 = this;
Ritor1
parents:
diff changeset
632 v2 = fopen("data\\dchest.bin", "wb");
Ritor1
parents:
diff changeset
633 v3 = v2;
Ritor1
parents:
diff changeset
634 if ( !v2 )
Ritor1
parents:
diff changeset
635 Abortf("Unable to save dchest.bin!");
Ritor1
parents:
diff changeset
636 fwrite(v1, 4u, 1u, v2);
Ritor1
parents:
diff changeset
637 fwrite(v1->pChests, 0x24u, v1->uNumChests, v3);
Ritor1
parents:
diff changeset
638 fclose(v3);
Ritor1
parents:
diff changeset
639 }
Ritor1
parents:
diff changeset
640
Ritor1
parents:
diff changeset
641
Ritor1
parents:
diff changeset
642 //----- (00458B4F) --------------------------------------------------------
Ritor1
parents:
diff changeset
643 void ChestList::FromFile(void *pSerialized)
Ritor1
parents:
diff changeset
644 {
Ritor1
parents:
diff changeset
645 uNumChests = *(int *)pSerialized;
Ritor1
parents:
diff changeset
646 pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, 36 * uNumChests, "Chest Descrip");
Ritor1
parents:
diff changeset
647 memcpy(pChests, (char *)pSerialized + 4, 36 * uNumChests);
Ritor1
parents:
diff changeset
648 }
Ritor1
parents:
diff changeset
649
Ritor1
parents:
diff changeset
650
Ritor1
parents:
diff changeset
651 //----- (00458B9C) --------------------------------------------------------
Ritor1
parents:
diff changeset
652 int ChestList::FromFileTxt(const char *Args)
Ritor1
parents:
diff changeset
653 {
Ritor1
parents:
diff changeset
654 ChestList *v2; // ebx@1
Ritor1
parents:
diff changeset
655 __int32 v3; // edi@1
Ritor1
parents:
diff changeset
656 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
657 unsigned int v5; // esi@3
Ritor1
parents:
diff changeset
658 const void *v6; // ST18_4@9
Ritor1
parents:
diff changeset
659 void *v7; // eax@9
Ritor1
parents:
diff changeset
660 FILE *v8; // ST0C_4@11
Ritor1
parents:
diff changeset
661 char *i; // eax@11
Ritor1
parents:
diff changeset
662 char v10; // al@14
Ritor1
parents:
diff changeset
663 const char *v11; // ST14_4@14
Ritor1
parents:
diff changeset
664 char v12; // al@14
Ritor1
parents:
diff changeset
665 const char *v13; // ST10_4@14
Ritor1
parents:
diff changeset
666 char Buf; // [sp+8h] [bp-2F0h]@3
Ritor1
parents:
diff changeset
667 FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4
Ritor1
parents:
diff changeset
668 FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4
Ritor1
parents:
diff changeset
669 FILE *File; // [sp+2F4h] [bp-4h]@1
Ritor1
parents:
diff changeset
670 unsigned int Argsa; // [sp+300h] [bp+8h]@3
Ritor1
parents:
diff changeset
671
Ritor1
parents:
diff changeset
672 v2 = this;
Ritor1
parents:
diff changeset
673 pAllocator->FreeChunk(this->pChests);
Ritor1
parents:
diff changeset
674 v3 = 0;
Ritor1
parents:
diff changeset
675 v2->pChests = 0;
Ritor1
parents:
diff changeset
676 v2->uNumChests = 0;
Ritor1
parents:
diff changeset
677 v4 = fopen(Args, "r");
Ritor1
parents:
diff changeset
678 File = v4;
Ritor1
parents:
diff changeset
679 if ( !v4 )
Ritor1
parents:
diff changeset
680 Abortf("ChestDescriptionList::load - Unable to open file: %s.");
Ritor1
parents:
diff changeset
681 v5 = 0;
Ritor1
parents:
diff changeset
682 Argsa = 0;
Ritor1
parents:
diff changeset
683 if ( fgets(&Buf, 490, v4) )
Ritor1
parents:
diff changeset
684 {
Ritor1
parents:
diff changeset
685 do
Ritor1
parents:
diff changeset
686 {
Ritor1
parents:
diff changeset
687 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
688 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
689 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
690 ++Argsa;
Ritor1
parents:
diff changeset
691 }
Ritor1
parents:
diff changeset
692 while ( fgets(&Buf, 490, File) );
Ritor1
parents:
diff changeset
693 v5 = Argsa;
Ritor1
parents:
diff changeset
694 v3 = 0;
Ritor1
parents:
diff changeset
695 }
Ritor1
parents:
diff changeset
696 v6 = v2->pChests;
Ritor1
parents:
diff changeset
697 v2->uNumChests = v5;
Ritor1
parents:
diff changeset
698 v7 = pAllocator->AllocNamedChunk(v6, 36 * v5, "Chest Descrip");
Ritor1
parents:
diff changeset
699 v2->pChests = (ChestDesc *)v7;
Ritor1
parents:
diff changeset
700 if ( v7 == (void *)v3 )
Ritor1
parents:
diff changeset
701 Abortf("ChestDescriptionList::load - Out of Memory!");
Ritor1
parents:
diff changeset
702 memset(v7, v3, 36 * v2->uNumChests);
Ritor1
parents:
diff changeset
703 v8 = File;
Ritor1
parents:
diff changeset
704 v2->uNumChests = v3;
Ritor1
parents:
diff changeset
705 fseek(v8, v3, v3);
Ritor1
parents:
diff changeset
706 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
Ritor1
parents:
diff changeset
707 {
Ritor1
parents:
diff changeset
708 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
709 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
710 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
711 {
Ritor1
parents:
diff changeset
712 strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]);
Ritor1
parents:
diff changeset
713 v10 = atoi(v17.pProperties[1]);
Ritor1
parents:
diff changeset
714 v11 = v17.pProperties[2];
Ritor1
parents:
diff changeset
715 v2->pChests[v2->uNumChests].uWidth = v10;
Ritor1
parents:
diff changeset
716 v12 = atoi(v11);
Ritor1
parents:
diff changeset
717 v13 = v17.pProperties[3];
Ritor1
parents:
diff changeset
718 v2->pChests[v2->uNumChests].uHeight = v12;
Ritor1
parents:
diff changeset
719 v2->pChests[v2->uNumChests++].uTextureID = atoi(v13);
Ritor1
parents:
diff changeset
720 }
Ritor1
parents:
diff changeset
721 }
Ritor1
parents:
diff changeset
722 fclose(File);
Ritor1
parents:
diff changeset
723 return 1;
Ritor1
parents:
diff changeset
724 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
725
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
726 //----- (00420B13) --------------------------------------------------------
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
727 void __fastcall sub_420B13(int a1, int a2)
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
728 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
729 void *v2; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
730 ItemGen *v3; // ebx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
731 unsigned int v4; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
732 Texture *v5; // ecx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
733 signed int v6; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
734 signed int v7; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
735 signed int v8; // eax@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
736 int v9; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
737 int v10; // eax@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
738 int v11; // esi@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
739 unsigned int v12; // ecx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
740 void *v13; // edi@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
741 unsigned __int8 v14; // cf@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
742 int v15; // edi@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
743 int i; // ecx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
744 int v17; // [sp+Ch] [bp-14h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
745 int v18; // [sp+10h] [bp-10h]@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
746 int v19; // [sp+14h] [bp-Ch]@1
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
747 int v20; // [sp+18h] [bp-8h]@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
748 int v21; // [sp+1Ch] [bp-4h]@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
749 int v22; // [sp+1Ch] [bp-4h]@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
750
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
751 v19 = a2;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
752 v2 = pChestWindow->ptr_1C;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
753 v20 = (int)v2;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
754 v2 = (void *)(5324 * (int)v2);
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
755 //v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
756 v3 = &pChests[v20].igChestItems[a1];
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
757 //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
758 v17 = pChestWidthsByType[pChests[v20].uChestBitmapID];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
759 v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
760 v5 = pIcons_LOD->GetTexture(v4);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
761 v6 = v5->uTextureWidth;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
762 if ( v6 < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
763 v6 = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
764 v7 = v6 - 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
765 v8 = v5->uTextureHeight;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
766 v9 = (v7 >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
767 v18 = v9;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
768 if ( v8 < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
769 v8 = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
770 v10 = ((v8 - 14) >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
771 v21 = v10;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
772 if ( !areWeLoadingTexture )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
773 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
774 v5->Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 987
diff changeset
775 pIcons_LOD->SyncLoadedFilesCount();
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
776 v10 = v21;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
777 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
778 if ( v10 > 0 )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
779 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
780 v11 = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
781 v22 = v10;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
782 do
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
783 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
784 if ( v9 > 0 )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
785 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
786 v12 = v9;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
787 //v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
788 v13 = &pChests[v20].pInventoryIndices[v19 + v11];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
789 v14 = v12 & 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
790 v12 >>= 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
791 memset(v13, 0, 4 * v12);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
792 v15 = (int)((char *)v13 + 4 * v12);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
793 for ( i = v14; i; --i )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
794 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
795 *(short *)v15 = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
796 v15 += 2;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
797 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
798 v9 = v18;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
799 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
800 v11 += v17;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
801 --v22;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
802 }
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
803 while ( v22 );
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
804 }
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
805 v3->Reset();
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
806 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
807 // 506128: using guessed type int areWeLoadingTexture;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
808 //----- (00420E01) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
809 void __cdecl OnChestLeftClick()
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
810 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
811 int chest_id; // edi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
812 POINT *v1; // esi@2
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
813 int v2; // eax@2
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
814 int v3; // ebx@4
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
815 int v4; // esi@6
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
816 int v5; // ecx@6
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
817 //SpriteObject v6; // [sp+Ch] [bp-80h]@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
818 POINT v7; // [sp+7Ch] [bp-10h]@2
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
819 POINT a2; // [sp+84h] [bp-8h]@2
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
820
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
821 SpriteObject v6; // [sp+Ch] [bp-80h]@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
822 //SpriteObject::SpriteObject(&v6);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
823
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
824 chest_id = pGUIWindow_CurrentMenu->par1C;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
825 if ( pParty->pPickedItem.uItemID )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
826 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
827 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
828 pMouse->RemoveHoldingItem();
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
829 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
830 else
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
831 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
832 v1 = pMouse->GetCursorPos(&a2);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
833 v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
834 if ( v2 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
835 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
836 if ( v2 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
837 v3 = v2 - 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
838 else
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
839 v3 = -1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
840 v4 = pChests[chest_id].pInventoryIndices[v3] - 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
841 if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
842 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
843 party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
844 viewparams->bRedrawGameUI = 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
845 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
846 else
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
847 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
848 pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
849 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
850 sub_420B13(v4, v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
851 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
852 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
853 }