annotate Chest.cpp @ 540:d6711da258f1

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