annotate Chest.cpp @ 422:03ccac4fad25

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