annotate Chest.cpp @ 433:0eaed3e0d75f

Walk speed x12 (debugging purposes)
author Nomad
date Sun, 24 Feb 2013 01:08:02 +0200
parents 94546824edad
children 0dbf780e247f
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
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
64 //LayingItem a1; // [sp+14h] [bp-B0h]@28
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);
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
82 auto chest = pChests + uChestID;
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())
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
92 Chest::_420284(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;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
107 v6 = dword_5B5920 >> 3;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
108 v35 = v5;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
109 if ( (dword_5B5920 & 7) == OBJECT_Decoration)
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 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
119 if ( (dword_5B5920 & 7) != OBJECT_BModel)
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 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
123 v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F];
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
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
172 LayingItem a1; // [sp+14h] [bp-B0h]@28
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
173 //LayingItem::LayingItem(&a1);
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;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
182 a1.uItemType = v24;
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;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
223 return 0;
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;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
236 v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0);
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;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
239 pBtn_ExitCancel = v3->CreateButton(
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
240 0x1D7u,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
241 0x1BDu,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
242 0xA9u,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
243 0x23u,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
244 1,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
245 0,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
246 0x71u,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
247 0,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
248 0,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
249 pGlobalTXT_LocalizationStrings[79],// Exit
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
250 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
251 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
252 pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
253 pCurrentScreen = SCREEN_CHEST;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
254 pEventTimer->Pause();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
255 return 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
256 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
257
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
258 //----- (0042092D) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
259 void Chest::DrawChestUI(unsigned int uChestID)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
260 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
261 Render *v1; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
262 unsigned int v2; // ebx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
263 unsigned int v3; // ebx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
264 int v4; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
265 unsigned int v5; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
266 int v6; // ecx@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
267 unsigned int v7; // eax@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
268 Texture *v8; // esi@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
269 signed int v9; // ecx@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
270 signed int v10; // edx@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
271 signed int v11; // eax@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
272 int v12; // eax@6
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
273 int v13; // eax@6
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
274 unsigned int v14; // ST34_4@8
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
275 int v15; // edi@8
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
276 int *v16; // [sp+Ch] [bp-28h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
277 int v17; // [sp+10h] [bp-24h]@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
278 int v18; // [sp+14h] [bp-20h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
279 signed int v19; // [sp+18h] [bp-1Ch]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
280 int v20; // [sp+1Ch] [bp-18h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
281 signed int v21; // [sp+20h] [bp-14h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
282 char *v22; // [sp+2Ch] [bp-8h]@2
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
283 signed int v23; // [sp+30h] [bp-4h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
284
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
285 v1 = pRenderer;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
286 v2 = uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
287 v16 = pRenderer->pActiveZBuffer;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
288 pRenderer->ClearZBuffer(0, 479);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
289 v3 = v2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
290 v4 = pChests[v3].uChestBitmapID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
291 v20 = pChestSmthn1ByType[v4];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
292 v18 = pChestSmthn2ByType[v4];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
293 v21 = pChestWidthsByType[v4];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
294 v19 = pChestHeightsByType[v4];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
295 sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
296 v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
297 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
298 v23 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
299 if ( v21 * v19 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
300 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
301 v22 = (char *)pChests[v3].pInventoryIndices;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
302 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
303 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
304 v6 = *(short *)v22;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
305 if ( v6 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
306 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
307 v17 = v18 + 32 * v23 / v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
308 v7 = pIcons_LOD->LoadTexture(
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
309 pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
310 TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
311 v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
312 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
313 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
314 v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
315 if ( v9 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
316 v11 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
317 v12 = v11 - 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
318 LOBYTE(v12) = v12 & 0xE0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
319 v13 = v12 + 32;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
320 if ( (signed int)v8->uTextureHeight < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
321 v10 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
322 v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
323 v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
324 pRenderer->DrawTextureTransparent(
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
325 v14,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
326 v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1),
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
327 v8);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
328 sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
329 v1 = pRenderer;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
330 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
331 ++v23;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
332 v22 += 2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
333 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
334 while ( v23 < v21 * v19 );
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
335 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
336 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
337 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
338 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
339
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
340
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
341 //----- (0041FE71) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
342 int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
343 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
344 int v3; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
345 unsigned int v4; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
346 Texture *v5; // ecx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
347 signed int v6; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
348 signed int v7; // edi@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
349 signed int v8; // eax@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
350 int v9; // edi@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
351 int v10; // ebx@5
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
352 int v11; // esi@9
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
353 int v12; // edx@10
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
354 int v13; // ecx@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
355 char *v14; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
356 int v16; // [sp+Ch] [bp-Ch]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
357 signed int v17; // [sp+10h] [bp-8h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
358 signed int v18; // [sp+14h] [bp-4h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
359
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
360 v17 = a1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
361 v3 = pChests[uChestID].uChestBitmapID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
362 v16 = pChestHeightsByType[v3];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
363 v18 = pChestWidthsByType[v3];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
364 v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
365 v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
366 v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
367 if ( v6 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
368 v6 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
369 v7 = v6 - 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
370 v8 = v5->uTextureHeight;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
371 v9 = (v7 >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
372 if ( v8 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
373 v8 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
374 v10 = ((v8 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
375 if ( !areWeLoadingTexture )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
376 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
377 v5->Release();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
378 pIcons_LOD->_40F9C5();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
379 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
380 if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
381 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
382 v11 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
383 if ( v10 <= 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
384 return 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
385 v12 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
386 while ( 1 )
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 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
389 if ( v9 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
390 break;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
391 LABEL_15:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
392 v12 += v18;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
393 ++v11;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
394 if ( v11 >= v10 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
395 return 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
396 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
397 v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
398 while ( !*(short *)v14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
399 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
400 ++v13;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
401 v14 += 2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
402 if ( v13 >= v9 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
403 goto LABEL_15;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
404 }
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 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
407 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
408 // 506128: using guessed type int areWeLoadingTexture;
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 //----- (0041FF64) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
411 int Chest::_41FF64(unsigned int uChestID)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
412 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
413 unsigned int v1; // ecx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
414 signed int result; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
415 int v3; // edx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
416 ItemGen *pItem; // ecx@2
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
417
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
418 v1 = uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
419 result = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
420 v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
421 if ( v3 <= 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
422 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
423 LABEL_5:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
424 result = -1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
425 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
426 else
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 pItem = pChests[v1].mm7__vector_pItems;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
429 while ( pItem->uItemID )
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 ++result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
432 ++pItem;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
433 if ( result >= v3 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
434 goto LABEL_5;
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 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
437 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
438 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
439
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
440 //----- (0041FFA2) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
441 int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
442 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
443 int v3; // eax@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
444 ItemGen *v4; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
445 int v5; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
446 int result; // eax@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
447 unsigned int v7; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
448 int v8; // edx@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
449 int v9; // ecx@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
450 signed int v10; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
451 signed int v11; // edi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
452 unsigned int v12; // esi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
453 int v13; // edi@16
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
454 void *v14; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
455 int v15; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
456 int i; // ecx@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
457 ItemGen *Src; // [sp+Ch] [bp-18h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
458 signed int v18; // [sp+10h] [bp-14h]@2
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
459 int v19; // [sp+14h] [bp-10h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
460 int v20; // [sp+18h] [bp-Ch]@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
461 signed int v21; // [sp+1Ch] [bp-8h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
462 signed int v22; // [sp+20h] [bp-4h]@3
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
463 int v23; // [sp+20h] [bp-4h]@19
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 v21 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
466 v3 = pChests[uChestID].uChestBitmapID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
467 v4 = a2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
468 v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
469 Src = a2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
470 v19 = pChestWidthsByType[v3];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
471 if ( a1 == -1 )
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 v18 = _41FF64(uChestID);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
474 if ( v18 == -1 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
475 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
476 v22 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
477 if ( v5 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
478 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
479 while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) )
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 ++v22;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
482 if ( v22 >= v5 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
483 goto LABEL_8;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
484 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
485 v21 = v22;
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 LABEL_8:
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
488 if ( v22 == v5 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
489 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
490 if ( uActiveCharacter )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
491 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
492 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
493 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
494 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
495 HIWORD(v8) = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
496 v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
497 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
498 if ( v10 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
499 v10 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
500 v11 = *(short *)(v9 + 26);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
501 v12 = ((v10 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
502 if ( v11 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
503 v11 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
504 v13 = ((v11 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
505 if ( !areWeLoadingTexture )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
506 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
507 ((Texture *)v9)->Release();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
508 pIcons_LOD->_40F9C5();
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 if ( v13 > 0 )
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 v23 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
513 v20 = v13;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
514 do
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 if ( (signed int)v12 > 0 )
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 v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
519 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
520 v8 <<= 16;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
521 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
522 memset32(v14, v8, v12 >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
523 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
524 for ( i = v12 & 1; i; --i )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
525 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
526 *(short *)v15 = v8;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
527 v15 += 2;
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 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
530 v23 += v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
531 --v20;
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 while ( v20 );
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 pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
536 memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
537 result = v21 + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
538 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
539 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
540 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
541 result = 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
542 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
543 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
544 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
545 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
546
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
547 //----- (0042013E) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
548 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
549 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
550 int v3; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
551 unsigned int v4; // ebx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
552 int uItemID; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
553 int v6; // edx@4
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
554 unsigned int v7; // eax@5
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
555 Texture *v8; // ecx@5
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
556 signed int v9; // eax@5
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
557 signed int v10; // edi@7
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
558 unsigned int v11; // ebx@7
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
559 int v12; // edi@9
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
560 int v13; // edx@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
561 void *v14; // edi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
562 int v15; // edi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
563 int i; // ecx@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
564 unsigned int result; // eax@18
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
565 __int16 v18; // [sp+Ch] [bp-10h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
566 int v19; // [sp+10h] [bp-Ch]@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
567 int v20; // [sp+14h] [bp-8h]@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
568 unsigned int v21; // [sp+18h] [bp-4h]@1
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 v3 = 5324 * uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
571 v21 = a1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
572 v4 = 5324 * uChestID + 36 * uItemIdx;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
573 v18 = uItemIdx;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
574 uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
575 pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
576 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
577 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
578 v6 = rand() % 21 + 10;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
579 *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
580 *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6;
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 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
583 v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
584 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
585 if ( v9 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
586 v9 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
587 v10 = v8->uTextureHeight;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
588 v11 = ((v9 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
589 if ( v10 < 14 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
590 v10 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
591 v12 = ((v10 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
592 if ( !areWeLoadingTexture )
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 v8->Release();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
595 pIcons_LOD->_40F9C5();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
596 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
597 v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
598 if ( v12 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
599 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
600 v13 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
601 v20 = v12;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
602 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
603 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
604 if ( (signed int)v11 > 0 )
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 v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
607 LOWORD(v3) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
608 v3 <<= 16;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
609 LOWORD(v3) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
610 memset32(v14, v3, v11 >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
611 v15 = (int)((char *)v14 + 4 * (v11 >> 1));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
612 for ( i = v11 & 1; i; --i )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
613 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
614 *(short *)v15 = v3;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
615 v15 += 2;
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 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
618 v13 += v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
619 --v20;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
620 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
621 while ( v20 );
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 result = v21 + 2662 * uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
624 pChests[0].pInventoryIndices[result] = v18 + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
625 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
626 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
627 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
628
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
629 //----- (00420284) --------------------------------------------------------
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
630 char *Chest::_420284(unsigned int uChestID)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
631 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
632 int v1; // ebx@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
633 unsigned int v2; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
634 unsigned int v3; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
635 int uChestArea; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
636 int v5; // eax@2
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
637 int v6; // ebx@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
638 char *result; // eax@18
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
639 char Dst[144]; // [sp+Ch] [bp-A0h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
640 int v9; // [sp+9Ch] [bp-10h]@10
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
641 unsigned int v10; // [sp+A0h] [bp-Ch]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
642 unsigned int v11; // [sp+A4h] [bp-8h]@8
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
643 ItemGen *v12; // [sp+A8h] [bp-4h]@9
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
644
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
645 v1 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
646 v2 = uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
647 v10 = uChestID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
648 pRenderer->ClearZBuffer(0, 479);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
649 v3 = v2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
650 uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
651 memset(Dst, 0, 0x90u);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
652 if ( uChestArea > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
653 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
654 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
655 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
656 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
657 v5 = (unsigned __int8)rand();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
658 while ( v5 >= uChestArea );
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
659 while ( Dst[v5] )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
660 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
661 ++v5;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
662 if ( v5 == uChestArea )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
663 v5 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
664 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
665 Dst[v5] = v1++;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
666 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
667 while ( v1 < uChestArea );
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 v11 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
670 if ( uChestArea > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
671 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
672 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
673 do
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 v9 = v12->uItemID;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
676 if ( v9 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
677 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
678 v6 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
679 while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
680 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
681 ++v6;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
682 if ( v6 >= uChestArea )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
683 break;
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 if(v6<uChestArea)
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
686 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
687 Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
688 if ( pChests[v3].uFlags & 4 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
689 v12->SetIdentified();
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
690 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
691 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
692 ++v11;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
693 ++v12;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
694 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
695 while ( (signed int)v11 < uChestArea );
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
696 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
697 result = (char *)&pChests[v3].uFlags;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
698 pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
699 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
700 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
701 // 420284: using guessed type char Dst[144];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
702
0
Ritor1
parents:
diff changeset
703 //----- (00458B03) --------------------------------------------------------
Ritor1
parents:
diff changeset
704 void ChestList::ToFile()
Ritor1
parents:
diff changeset
705 {
Ritor1
parents:
diff changeset
706 ChestList *v1; // esi@1
Ritor1
parents:
diff changeset
707 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
708 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
709
Ritor1
parents:
diff changeset
710 v1 = this;
Ritor1
parents:
diff changeset
711 v2 = fopen("data\\dchest.bin", "wb");
Ritor1
parents:
diff changeset
712 v3 = v2;
Ritor1
parents:
diff changeset
713 if ( !v2 )
Ritor1
parents:
diff changeset
714 Abortf("Unable to save dchest.bin!");
Ritor1
parents:
diff changeset
715 fwrite(v1, 4u, 1u, v2);
Ritor1
parents:
diff changeset
716 fwrite(v1->pChests, 0x24u, v1->uNumChests, v3);
Ritor1
parents:
diff changeset
717 fclose(v3);
Ritor1
parents:
diff changeset
718 }
Ritor1
parents:
diff changeset
719
Ritor1
parents:
diff changeset
720
Ritor1
parents:
diff changeset
721 //----- (00458B4F) --------------------------------------------------------
Ritor1
parents:
diff changeset
722 void ChestList::FromFile(void *pSerialized)
Ritor1
parents:
diff changeset
723 {
Ritor1
parents:
diff changeset
724 uNumChests = *(int *)pSerialized;
Ritor1
parents:
diff changeset
725 pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, 36 * uNumChests, "Chest Descrip");
Ritor1
parents:
diff changeset
726 memcpy(pChests, (char *)pSerialized + 4, 36 * uNumChests);
Ritor1
parents:
diff changeset
727 }
Ritor1
parents:
diff changeset
728
Ritor1
parents:
diff changeset
729
Ritor1
parents:
diff changeset
730 //----- (00458B9C) --------------------------------------------------------
Ritor1
parents:
diff changeset
731 int ChestList::FromFileTxt(const char *Args)
Ritor1
parents:
diff changeset
732 {
Ritor1
parents:
diff changeset
733 ChestList *v2; // ebx@1
Ritor1
parents:
diff changeset
734 __int32 v3; // edi@1
Ritor1
parents:
diff changeset
735 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
736 unsigned int v5; // esi@3
Ritor1
parents:
diff changeset
737 const void *v6; // ST18_4@9
Ritor1
parents:
diff changeset
738 void *v7; // eax@9
Ritor1
parents:
diff changeset
739 FILE *v8; // ST0C_4@11
Ritor1
parents:
diff changeset
740 char *i; // eax@11
Ritor1
parents:
diff changeset
741 char v10; // al@14
Ritor1
parents:
diff changeset
742 const char *v11; // ST14_4@14
Ritor1
parents:
diff changeset
743 char v12; // al@14
Ritor1
parents:
diff changeset
744 const char *v13; // ST10_4@14
Ritor1
parents:
diff changeset
745 char Buf; // [sp+8h] [bp-2F0h]@3
Ritor1
parents:
diff changeset
746 FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4
Ritor1
parents:
diff changeset
747 FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4
Ritor1
parents:
diff changeset
748 FILE *File; // [sp+2F4h] [bp-4h]@1
Ritor1
parents:
diff changeset
749 unsigned int Argsa; // [sp+300h] [bp+8h]@3
Ritor1
parents:
diff changeset
750
Ritor1
parents:
diff changeset
751 v2 = this;
Ritor1
parents:
diff changeset
752 pAllocator->FreeChunk(this->pChests);
Ritor1
parents:
diff changeset
753 v3 = 0;
Ritor1
parents:
diff changeset
754 v2->pChests = 0;
Ritor1
parents:
diff changeset
755 v2->uNumChests = 0;
Ritor1
parents:
diff changeset
756 v4 = fopen(Args, "r");
Ritor1
parents:
diff changeset
757 File = v4;
Ritor1
parents:
diff changeset
758 if ( !v4 )
Ritor1
parents:
diff changeset
759 Abortf("ChestDescriptionList::load - Unable to open file: %s.");
Ritor1
parents:
diff changeset
760 v5 = 0;
Ritor1
parents:
diff changeset
761 Argsa = 0;
Ritor1
parents:
diff changeset
762 if ( fgets(&Buf, 490, v4) )
Ritor1
parents:
diff changeset
763 {
Ritor1
parents:
diff changeset
764 do
Ritor1
parents:
diff changeset
765 {
Ritor1
parents:
diff changeset
766 *strchr(&Buf, 10) = 0;
Ritor1
parents:
diff changeset
767 memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
Ritor1
parents:
diff changeset
768 if ( v17.field_0 && *v17.pProperties[0] != 47 )
Ritor1
parents:
diff changeset
769 ++Argsa;
Ritor1
parents:
diff changeset
770 }
Ritor1
parents:
diff changeset
771 while ( fgets(&Buf, 490, File) );
Ritor1
parents:
diff changeset
772 v5 = Argsa;
Ritor1
parents:
diff changeset
773 v3 = 0;
Ritor1
parents:
diff changeset
774 }
Ritor1
parents:
diff changeset
775 v6 = v2->pChests;
Ritor1
parents:
diff changeset
776 v2->uNumChests = v5;
Ritor1
parents:
diff changeset
777 v7 = pAllocator->AllocNamedChunk(v6, 36 * v5, "Chest Descrip");
Ritor1
parents:
diff changeset
778 v2->pChests = (ChestDesc *)v7;
Ritor1
parents:
diff changeset
779 if ( v7 == (void *)v3 )
Ritor1
parents:
diff changeset
780 Abortf("ChestDescriptionList::load - Out of Memory!");
Ritor1
parents:
diff changeset
781 memset(v7, v3, 36 * v2->uNumChests);
Ritor1
parents:
diff changeset
782 v8 = File;
Ritor1
parents:
diff changeset
783 v2->uNumChests = v3;
Ritor1
parents:
diff changeset
784 fseek(v8, v3, v3);
Ritor1
parents:
diff changeset
785 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
Ritor1
parents:
diff changeset
786 {
Ritor1
parents:
diff changeset
787 *strchr(&Buf, 10) = 0;
Ritor1
parents:
diff changeset
788 memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
Ritor1
parents:
diff changeset
789 if ( v17.field_0 && *v17.pProperties[0] != 47 )
Ritor1
parents:
diff changeset
790 {
Ritor1
parents:
diff changeset
791 strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]);
Ritor1
parents:
diff changeset
792 v10 = atoi(v17.pProperties[1]);
Ritor1
parents:
diff changeset
793 v11 = v17.pProperties[2];
Ritor1
parents:
diff changeset
794 v2->pChests[v2->uNumChests].uWidth = v10;
Ritor1
parents:
diff changeset
795 v12 = atoi(v11);
Ritor1
parents:
diff changeset
796 v13 = v17.pProperties[3];
Ritor1
parents:
diff changeset
797 v2->pChests[v2->uNumChests].uHeight = v12;
Ritor1
parents:
diff changeset
798 v2->pChests[v2->uNumChests++].uTextureID = atoi(v13);
Ritor1
parents:
diff changeset
799 }
Ritor1
parents:
diff changeset
800 }
Ritor1
parents:
diff changeset
801 fclose(File);
Ritor1
parents:
diff changeset
802 return 1;
Ritor1
parents:
diff changeset
803 }