annotate Chest.cpp @ 755:e0914a9bc424

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