comparison mm7_3.cpp @ 2085:52abdea20b9e

Door_switch_animation
author Ritor1
date Wed, 11 Dec 2013 23:12:54 +0600
parents 87be06553c76
children 3920278a2905
comparison
equal deleted inserted replaced
2068:a290d9fbdc95 2085:52abdea20b9e
56 __int16 pNextSector; // si@10 56 __int16 pNextSector; // si@10
57 int pArrayNum; // ecx@12 57 int pArrayNum; // ecx@12
58 unsigned __int8 v6; // sf@12 58 unsigned __int8 v6; // sf@12
59 unsigned __int8 v7; // of@12 59 unsigned __int8 v7; // of@12
60 int result; // eax@14 60 int result; // eax@14
61 //BLVSector *v9; // ebx@15 61 //int v10; // ecx@15
62 int v10; // ecx@15
63 int pFloor; // eax@16 62 int pFloor; // eax@16
64 //BLVFace *v12; // ebp@16
65 int v13; // eax@24
66 int v14; // esi@24
67 int v15; // eax@24 63 int v15; // eax@24
68 int v16; // edx@25 64 int v16; // edx@25
69 int v17; // eax@29 65 int v17; // eax@29
70 unsigned int v18; // eax@33 66 unsigned int v18; // eax@33
71 int v19; // eax@35
72 int v20; // edx@35
73 int v21; // eax@35 67 int v21; // eax@35
74 int v22; // ecx@36 68 int v22; // ecx@36
75 int v23; // eax@40 69 int v23; // eax@40
76 unsigned int v24; // eax@44 70 unsigned int v24; // eax@44
77 int a3; // [sp+10h] [bp-48h]@28 71 int a3; // [sp+10h] [bp-48h]@28
78 int v26; // [sp+14h] [bp-44h]@15 72 int v26; // [sp+14h] [bp-44h]@15
79 int i; // [sp+18h] [bp-40h]@1 73 int i; // [sp+18h] [bp-40h]@1
80 int a10; // [sp+1Ch] [bp-3Ch]@1 74 int a10; // [sp+1Ch] [bp-3Ch]@1
81 int v29; // [sp+20h] [bp-38h]@14 75 int v29; // [sp+20h] [bp-38h]@14
82 int v30; // [sp+24h] [bp-34h]@35
83 int v31; // [sp+28h] [bp-30h]@24
84 int v32; // [sp+2Ch] [bp-2Ch]@15 76 int v32; // [sp+2Ch] [bp-2Ch]@15
85 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1 77 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1
86 78
87 pSector = &pIndoor->pSectors[stru_721530.uSectorID]; 79 pSector = &pIndoor->pSectors[stru_721530.uSectorID];
88 v2 = 0; 80 i = 1;
89 a10 = b1; 81 a10 = b1;
90 pSectorsArray[0] = stru_721530.uSectorID; 82 pSectorsArray[0] = stru_721530.uSectorID;
91 for ( i = 1; v2 < pSector->uNumPortals; ++v2 ) 83 for ( v2 = 0; v2 < pSector->uNumPortals; ++v2 )
92 { 84 {
93 pFace = &pIndoor->pFaces[pSector->pPortals[v2]]; 85 pFace = &pIndoor->pFaces[pSector->pPortals[v2]];
94 if ( stru_721530.sMaxX <= pFace->pBounding.x2 86 if ( stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
95 && stru_721530.sMinX >= pFace->pBounding.x1 87 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
96 && stru_721530.sMaxY <= pFace->pBounding.y2 88 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
97 && stru_721530.sMinY >= pFace->pBounding.y1
98 && stru_721530.sMaxZ <= pFace->pBounding.z2
99 && stru_721530.sMinZ >= pFace->pBounding.z1
100 && abs((pFace->pFacePlane_old.dist 89 && abs((pFace->pFacePlane_old.dist
101 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x 90 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
102 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y 91 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
103 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 ) 92 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 )
104 { 93 {
110 if ( !(v6 ^ v7) ) 99 if ( !(v6 ^ v7) )
111 break; 100 break;
112 } 101 }
113 } 102 }
114 result = 0; 103 result = 0;
115 v29 = 0; 104 for ( v29 = 0; v29 < i; v29++ )
116 if ( i > 0 ) 105 {
117 { 106 pSector = &pIndoor->pSectors[pSectorsArray[v29]];
118 while ( 1 ) 107 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
119 { 108 for ( v26 = 0; v26 < v32; v26++ )
120 pSector = &pIndoor->pSectors[pSectorsArray[result]]; 109 {
121 v10 = 0; 110 pFloor = pSector->pFloors[v26];
122 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; 111 pFace = &pIndoor->pFaces[pSector->pFloors[v26]];
123 v26 = 0; 112 if ( !pFace->Portal()
124 if ( v32 > 0 ) 113 && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
125 break; 114 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
126 LABEL_46: 115 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
127 result = v29++ + 1; 116 && pFloor != stru_721530.field_84 )
128 if ( v29 >= i ) 117 {
129 return result; 118 v15 = ( pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
130 } 119 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
131 while ( 1 ) 120 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
132 {
133 pFloor = pSector->pFloors[v10];
134 pFace = &pIndoor->pFaces[pFloor];
135 if ( pFace->Portal()
136 || stru_721530.sMaxX > pFace->pBounding.x2
137 || stru_721530.sMinX < pFace->pBounding.x1
138 || stru_721530.sMaxY > pFace->pBounding.y2
139 || stru_721530.sMinY < pFace->pBounding.y1
140 || stru_721530.sMaxZ > pFace->pBounding.z2
141 || stru_721530.sMinZ < pFace->pBounding.z1
142 || pFloor == stru_721530.field_84 )
143 goto LABEL_45;
144 v13 = pFace->pFacePlane_old.vNormal.y;
145 v14 = pFace->pFacePlane_old.dist;
146 v31 = v13;
147 v15 = (stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + v14 + stru_721530.normal.y * v13
148 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16;
149 if ( v15 > 0 ) 121 if ( v15 > 0 )
150 { 122 {
151 v16 = (stru_721530.normal2.y * v31 + pFace->pFacePlane_old.dist + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z 123 v16 = ( pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x
152 + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x) >> 16; 124 + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y
125 + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
153 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) 126 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
154 { 127 {
155 if ( v16 <= v15 ) 128 if ( v16 <= v15 )
156 { 129 {
157 a3 = stru_721530.field_6C; 130 a3 = stru_721530.field_6C;
158 if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, 131 if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
159 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) 132 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
160 { 133 {
161 v17 = a3; 134 v17 = a3;
162 } 135 }
163 else 136 else
164 { 137 {
178 } 151 }
179 } 152 }
180 } 153 }
181 LABEL_34: 154 LABEL_34:
182 if ( !(stru_721530.field_0 & 1) 155 if ( !(stru_721530.field_0 & 1)
183 || (v19 = pFace->pFacePlane_old.vNormal.x, 156 || (v21 = ( pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x
184 v20 = pFace->pFacePlane_old.vNormal.y, 157 + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y
185 v30 = v19, 158 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0)
186 v21 = (stru_721530.position.x * v19 + pFace->pFacePlane_old.dist + stru_721530.position.y * v20 159 || (v22 = ( pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x
187 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, 160 + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y
188 v21 <= 0) 161 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d)
189 || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20 162 && v22 > stru_721530.prolly_normal_d || v22 > v21 )
190 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, 163 continue;
191 v21 > stru_721530.prolly_normal_d)
192 && v22 > stru_721530.prolly_normal_d
193 || v22 > v21 )
194 goto LABEL_45;
195 a3 = stru_721530.field_6C; 164 a3 = stru_721530.field_6C;
196 if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, 165 if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
197 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) 166 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
198 { 167 {
199 v23 = a3; 168 v23 = a3;
211 v24 = 8 * pSector->pFloors[v26]; 180 v24 = 8 * pSector->pFloors[v26];
212 LOBYTE(v24) = v24 | 6; 181 LOBYTE(v24) = v24 | 6;
213 stru_721530.uFaceID = v24; 182 stru_721530.uFaceID = v24;
214 } 183 }
215 } 184 }
216 LABEL_45: 185 }
217 v10 = v26++ + 1; 186 }
218 if ( v26 >= v32 ) 187 result = v29 + 1;
219 goto LABEL_46;
220 }
221 } 188 }
222 return result; 189 return result;
223 } 190 }
224 // 46E44E: using guessed type int var_28[10]; 191 // 46E44E: using guessed type int var_28[10];
225 192
226 //----- (0046E889) -------------------------------------------------------- 193 //----- (0046E889) --------------------------------------------------------
227 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0) 194 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
228 { 195 {
229 int result; // eax@1 196 int result; // eax@1
230 BSPModel *v2; // ecx@3
231 int v3; // ebx@9 197 int v3; // ebx@9
232 ODMFace *v4; // eax@11
233 int v5; // edi@17
234 int v6; // esi@17
235 unsigned int v7; // ecx@17
236 int v8; // eax@19 198 int v8; // eax@19
237 int v9; // ecx@20 199 int v9; // ecx@20
238 int v10; // eax@24 200 int v10; // eax@24
239 int v11; // ST18_4@25
240 int v12; // ST1C_4@25
241 int v13; // ST0C_4@25
242 unsigned int v14; // eax@28 201 unsigned int v14; // eax@28
243 int v15; // eax@30 202 int v15; // eax@30
244 int v16; // ecx@31 203 int v16; // ecx@31
245 unsigned int v17; // eax@36 204 unsigned int v17; // eax@36
246 int v18; // ST18_4@41
247 int v19; // ST1C_4@41
248 int v20; // ST0C_4@41
249 int v21; // eax@42 205 int v21; // eax@42
250 unsigned int v22; // eax@43 206 unsigned int v22; // eax@43
251 //BLVFace f; // [sp+Ch] [bp-7Ch]@1
252 int v24; // [sp+6Ch] [bp-1Ch]@9
253 int a11; // [sp+70h] [bp-18h]@1 207 int a11; // [sp+70h] [bp-18h]@1
254 unsigned int v26; // [sp+74h] [bp-14h]@2
255 unsigned int v27; // [sp+78h] [bp-10h]@10
256 BSPModel *v28; // [sp+7Ch] [bp-Ch]@3
257 int a10; // [sp+80h] [bp-8h]@1 208 int a10; // [sp+80h] [bp-8h]@1
258 int a2; // [sp+84h] [bp-4h]@23 209 int a2; // [sp+84h] [bp-4h]@23
259 210
260 a11 = ecx0; 211 a11 = ecx0;
261 212
262 BLVFace f; // [sp+Ch] [bp-7Ch]@1 213 BLVFace f; // [sp+Ch] [bp-7Ch]@1
263 //BLVFace::BLVFace(&f);
264 214
265 result = 0; 215 result = 0;
266 a10 = 0; 216 for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
267 if ( (signed int)pOutdoor->uNumBModels > 0 ) 217 {
268 { 218 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX
269 v26 = 0; 219 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[a10].sMinY
270 while ( 1 ) 220 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[a10].sMinZ )
271 { 221 {
272 v2 = &pOutdoor->pBModels[v26 / 0xBC]; 222 for ( v3 = 0; v3 < pOutdoor->pBModels[a10].uNumFaces; ++v3 )
273 v28 = &pOutdoor->pBModels[v26 / 0xBC]; 223 {
274 if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX ) 224 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1
275 { 225 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1
276 if ( stru_721530.sMinX >= v2->sMinX ) 226 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 )
277 { 227 {
278 if ( stru_721530.sMaxY <= v2->sMaxY ) 228 f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
229 f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
230 f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
231 f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
232 f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
233 f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
234 f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
235 f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
236 f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
237 f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
238 f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
239 f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
240 f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
241 f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
242 f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
243 f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
244 f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
245 f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
246 f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
247 f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
248 f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
249 if ( !f.Ethereal() && !f.Portal() )
279 { 250 {
280 if ( stru_721530.sMinY >= v2->sMinY ) 251 v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x
252 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
253 + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
254 if ( v8 > 0 )
281 { 255 {
282 if ( stru_721530.sMaxZ <= v2->sMaxZ ) 256 v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x
257 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
258 + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
259 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
283 { 260 {
284 if ( stru_721530.sMinZ >= v2->sMinZ ) 261 if ( v9 <= v8 )
285 { 262 {
286 v3 = 0; 263 a2 = stru_721530.field_6C;
287 v24 = v2->uNumFaces; 264 if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
288 if ( v24 > 0 ) 265 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
289 break; 266 {
267 v10 = a2;
268 }
269 else
270 {
271 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
272 if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
273 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
274 goto LABEL_29;
275 v10 = a2 - stru_721530.prolly_normal_d;
276 a2 -= stru_721530.prolly_normal_d;
277 }
278 if ( v10 < stru_721530.field_7C )
279 {
280 stru_721530.field_7C = v10;
281 v14 = 8 * (v3 | (a10 << 6));
282 LOBYTE(v14) = v14 | 6;
283 stru_721530.uFaceID = v14;
284 }
290 } 285 }
291 } 286 }
292 } 287 }
293 }
294 }
295 }
296 LABEL_39:
297 ++a10;
298 v26 += 188;
299 result = a10;
300 if ( a10 >= (signed int)pOutdoor->uNumBModels )
301 return result;
302 }
303 v27 = 0;
304 while ( 1 )
305 {
306 v4 = &v2->pFaces[v27 / 0x134];
307 if ( stru_721530.sMaxX > v4->pBoundingBox.x2
308 || stru_721530.sMinX < v4->pBoundingBox.x1
309 || stru_721530.sMaxY > v4->pBoundingBox.y2
310 || stru_721530.sMinY < v4->pBoundingBox.y1
311 || stru_721530.sMaxZ > v4->pBoundingBox.z2
312 || stru_721530.sMinZ < v4->pBoundingBox.z1 )
313 goto LABEL_38;
314 f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x;
315 f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y;
316 v5 = v4->pFacePlane.vNormal.z;
317 f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
318 v6 = v4->pFacePlane.dist;
319 f.pFacePlane_old.dist = v4->pFacePlane.dist;
320 v7 = v4->uAttributes;
321 f.uAttributes = v7;
322 f.pBounding.x1 = v4->pBoundingBox.x1;
323 f.pBounding.y1 = v4->pBoundingBox.y1;
324 f.pBounding.z1 = v4->pBoundingBox.z1;
325 f.pBounding.x2 = v4->pBoundingBox.x2;
326 f.pBounding.y2 = v4->pBoundingBox.y2;
327 f.pBounding.z2 = v4->pBoundingBox.z2;
328 f.zCalc1 = v4->zCalc1;
329 f.zCalc2 = v4->zCalc2;
330 f.zCalc3 = v4->zCalc3;
331 f.pXInterceptDisplacements = v4->pXInterceptDisplacements;
332 f.pYInterceptDisplacements = v4->pYInterceptDisplacements;
333 f.pZInterceptDisplacements = v4->pZInterceptDisplacements;
334 f.uPolygonType = (PolygonType)v4->uPolygonType;
335 f.uNumVertices = v4->uNumVertices;
336 f.uBitmapID = v4->uTextureID;
337 f.pVertexIDs = v4->pVertexIDs;
338 if ( !(v7 & 0x20000000) )
339 {
340 if ( !(v7 & 1) )
341 break;
342 }
343 LABEL_37:
344 v2 = v28;
345 LABEL_38:
346 v27 += 308;
347 ++v3;
348 if ( v3 >= v24 )
349 goto LABEL_39;
350 }
351 v8 = (v5 * stru_721530.normal.z
352 + v6
353 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
354 + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16;
355 if ( v8 > 0 )
356 {
357 v9 = (v5 * stru_721530.normal2.z
358 + v6
359 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
360 + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16;
361 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
362 {
363 if ( v9 <= v8 )
364 {
365 a2 = stru_721530.field_6C;
366 if ( sub_4754BF(
367 stru_721530.prolly_normal_d,
368 &a2,
369 stru_721530.normal.x,
370 stru_721530.normal.y,
371 stru_721530.normal.z,
372 stru_721530.direction.x,
373 stru_721530.direction.y,
374 stru_721530.direction.z,
375 &f,
376 a10,
377 a11) )
378 {
379 v10 = a2;
380 }
381 else
382 {
383 v11 = stru_721530.direction.y;
384 v12 = stru_721530.direction.z;
385 v13 = stru_721530.normal.y;
386 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
387 if ( !sub_475F30(
388 &a2,
389 &f,
390 stru_721530.normal.x,
391 v13,
392 stru_721530.normal.z,
393 stru_721530.direction.x,
394 v11,
395 v12,
396 a10) )
397 goto LABEL_29;
398 v10 = a2 - stru_721530.prolly_normal_d;
399 a2 -= stru_721530.prolly_normal_d;
400 }
401 if ( v10 < stru_721530.field_7C )
402 {
403 stru_721530.field_7C = v10;
404 v14 = 8 * (v3 | (a10 << 6));
405 LOBYTE(v14) = v14 | 6;
406 stru_721530.uFaceID = v14;
407 }
408 }
409 }
410 }
411 LABEL_29: 288 LABEL_29:
412 if ( stru_721530.field_0 & 1 ) 289 if ( stru_721530.field_0 & 1 )
413 {
414 v15 = (f.pFacePlane_old.vNormal.z * stru_721530.position.z
415 + f.pFacePlane_old.dist
416 + f.pFacePlane_old.vNormal.y * stru_721530.position.y
417 + f.pFacePlane_old.vNormal.x * stru_721530.position.x) >> 16;
418 if ( v15 > 0 )
419 {
420 v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
421 + f.pFacePlane_old.dist
422 + f.pFacePlane_old.vNormal.y * stru_721530.field_50
423 + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16;
424 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
425 {
426 if ( v16 <= v15 )
427 {
428 a2 = stru_721530.field_6C;
429 if ( sub_4754BF(stru_721530.field_8_radius,
430 &a2,
431 stru_721530.position.x,
432 stru_721530.position.y,
433 stru_721530.position.z,
434 stru_721530.direction.x,
435 stru_721530.direction.y,
436 stru_721530.direction.z,
437 &f,
438 a10,
439 a11) )
440 { 290 {
441 if ( a2 < stru_721530.field_7C ) 291 v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x
292 + f.pFacePlane_old.vNormal.y * stru_721530.position.y
293 + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
294 if ( v15 > 0 )
442 { 295 {
443 stru_721530.field_7C = a2; 296 v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C
444 v17 = 8 * (v3 | (a10 << 6)); 297 + f.pFacePlane_old.vNormal.y * stru_721530.field_50
445 LOBYTE(v17) = v17 | 6; 298 + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
446 stru_721530.uFaceID = v17; 299 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
447 }
448 }
449 else
450 {
451 v18 = stru_721530.direction.y;
452 v19 = stru_721530.direction.z;
453 v20 = stru_721530.position.y;
454 a2 = stru_721530.field_6C + stru_721530.field_8_radius;
455 if ( sub_475F30(&a2,
456 &f,
457 stru_721530.position.x,
458 v20,
459 stru_721530.position.z,
460 stru_721530.direction.x,
461 v18,
462 v19,
463 a10) )
464 {
465 v2 = v28;
466 v21 = a2 - stru_721530.prolly_normal_d;
467 a2 -= stru_721530.prolly_normal_d;
468 if ( a2 < stru_721530.field_7C )
469 { 300 {
470 stru_721530.field_7C = v21; 301 if ( v16 <= v15 )
471 v22 = 8 * (v3 | (a10 << 6));
472 LOBYTE(v22) = v22 | 6;
473 stru_721530.uFaceID = v22;
474 }
475 goto LABEL_38;
476 }
477 }
478 }
479 }
480 }
481 }
482 goto LABEL_37;
483 }
484 return result;
485 }
486
487 //----- (0046ED1B) --------------------------------------------------------
488 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
489 {
490 uint uFaceID = -1;
491 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID);
492
493 if (floor_level != -30000 && floor_level <= z + 50)
494 {
495 *pFaceID = uFaceID;
496 return floor_level;
497 }
498
499 uint uSectorID = pIndoor->GetSector(x, y, z);
500 *pSectorID = uSectorID;
501
502 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID);
503 if (uSectorID && floor_level != -30000)
504 *pFaceID = uFaceID;
505 else return -30000;
506 return floor_level;
507 }
508
509 //----- (0046ED8A) --------------------------------------------------------
510 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
511 {
512 int v1; // ebx@2
513 ObjectDesc *v2; // edx@4
514 int v3; // esi@5
515 int v4; // ecx@5
516 int v5; // eax@7
517 int v6; // edi@9
518 int v7; // edx@9
519 int v8; // edi@11
520 int v9; // ebx@11
521 int v10; // ecx@12
522 int v11; // esi@13
523 signed int v12; // [sp+0h] [bp-14h]@1
524 int v13; // [sp+4h] [bp-10h]@9
525 char *v14; // [sp+8h] [bp-Ch]@2
526 unsigned int v15; // [sp+10h] [bp-4h]@1
527
528 v15 = 0;
529 v12 = _this;
530 if ( (signed int)uNumSpriteObjects > 0 )
531 {
532 v1 = (int)&pSpriteObjects[0].uObjectDescID;
533 v14 = (char *)&pSpriteObjects[0].uObjectDescID;
534 do
535 {
536 if ( *(short *)v1 )
537 {
538 v2 = &pObjectList->pObjects[*(short *)v1];
539 if ( !(v2->uFlags & 2) )
540 {
541 v3 = v2->uRadius;
542 v4 = *(int *)(v1 + 2);
543 if ( stru_721530.sMaxX <= v4 + v3 )
544 {
545 if ( stru_721530.sMinX >= v4 - v3 )
546 {
547 v5 = *(int *)(v1 + 6);
548 if ( stru_721530.sMaxY <= v5 + v3 )
549 {
550 if ( stru_721530.sMinY >= v5 - v3 )
551 {
552 v6 = v2->uHeight;
553 v7 = *(int *)(v1 + 10);
554 v13 = v6;
555 if ( stru_721530.sMaxZ <= v7 + v6 )
556 { 302 {
557 if ( stru_721530.sMinZ >= v7 ) 303 a2 = stru_721530.field_6C;
304 if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
305 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
558 { 306 {
559 v8 = v4 - stru_721530.normal.x; 307 if ( a2 < stru_721530.field_7C )
560 v9 = v5 - stru_721530.normal.y;
561 if ( abs(((v4 - stru_721530.normal.x) * stru_721530.direction.y
562 - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= v3
563 + stru_721530.prolly_normal_d )
564 { 308 {
565 v10 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16; 309 stru_721530.field_7C = a2;
566 if ( v10 > 0 ) 310 v17 = 8 * (v3 | (a10 << 6));
311 LOBYTE(v17) = v17 | 6;
312 stru_721530.uFaceID = v17;
313 }
314 }
315 else
316 {
317 a2 = stru_721530.field_6C + stru_721530.field_8_radius;
318 if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
319 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
320 {
321 v21 = a2 - stru_721530.prolly_normal_d;
322 a2 -= stru_721530.prolly_normal_d;
323 if ( a2 < stru_721530.field_7C )
567 { 324 {
568 v11 = stru_721530.normal.z 325 stru_721530.field_7C = v21;
569 + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); 326 v22 = 8 * (v3 | (a10 << 6));
570 if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d ) 327 LOBYTE(v22) = v22 | 6;
571 { 328 stru_721530.uFaceID = v22;
572 if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
573 {
574 if ( v10 < stru_721530.field_7C )
575 sub_46DEF2(v12, v15);
576 }
577 }
578 } 329 }
579 } 330 }
580 } 331 }
581 } 332 }
582 } 333 }
583 } 334 }
584 } 335 }
585 } 336 }
586 } 337 }
587 } 338 }
588 ++v15; 339 }
589 v1 = (int)(v14 + 112); 340 result = a10;
590 v14 += 112; 341 }
591 } 342 return result;
592 while ( (signed int)v15 < (signed int)uNumSpriteObjects ); 343 }
344
345 //----- (0046ED1B) --------------------------------------------------------
346 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
347 {
348 uint uFaceID = -1;
349 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID);
350
351 if (floor_level != -30000 && floor_level <= z + 50)
352 {
353 *pFaceID = uFaceID;
354 return floor_level;
355 }
356
357 uint uSectorID = pIndoor->GetSector(x, y, z);
358 *pSectorID = uSectorID;
359
360 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID);
361 if (uSectorID && floor_level != -30000)
362 *pFaceID = uFaceID;
363 else return -30000;
364 return floor_level;
365 }
366
367 //----- (0046ED8A) --------------------------------------------------------
368 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
369 {
370 ObjectDesc *object; // edx@4
371 int v10; // ecx@12
372 int v11; // esi@13
373
374 if ( (signed int)uNumSpriteObjects > 0 )
375 {
376 for ( uint i = 0; i < uNumSpriteObjects; ++i )
377 {
378 if ( pSpriteObjects[i].uObjectDescID )
379 {
380 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
381 if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
382 {
383 if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius
384 && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
385 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius
386 && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
387 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight
388 && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z )
389 {
390 if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
391 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight
392 + stru_721530.prolly_normal_d )
393 {
394 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
395 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
396 if ( v10 > 0 )
397 {
398 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
399 if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d )
400 {
401 if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
402 {
403 if ( v10 < stru_721530.field_7C )
404 sub_46DEF2(_this, i);
405 }
406 }
407 }
408 }
409 }
410 }
411 }
412 }
593 } 413 }
594 } 414 }
595 415
596 //----- (0046EF01) -------------------------------------------------------- 416 //----- (0046EF01) --------------------------------------------------------
597 int _46EF01_collision_chech_player(int a1) 417 int _46EF01_collision_chech_player(int a1)
610 430
611 v8 = a1; 431 v8 = a1;
612 v1 = 2 * pParty->field_14_radius; 432 v1 = 2 * pParty->field_14_radius;
613 result = pParty->vPosition.x; 433 result = pParty->vPosition.x;
614 v9 = pParty->uPartyHeight; 434 v9 = pParty->uPartyHeight;
615 if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14_radius ) 435 if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1
616 { 436 && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1
617 if ( stru_721530.sMinX >= pParty->vPosition.x - v1 ) 437 && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight)
618 { 438 && stru_721530.sMinZ >= pParty->vPosition.z )
619 if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 ) 439 {
620 { 440 v3 = stru_721530.prolly_normal_d + v1;
621 if ( stru_721530.sMinY >= pParty->vPosition.y - v1 ) 441 v11 = pParty->vPosition.x - stru_721530.normal.x;
442 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
443 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
444 v10 = pParty->vPosition.y - stru_721530.normal.y;
445 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
446 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
447 if ( result <= stru_721530.prolly_normal_d + v1 )
448 {
449 result = v10 * stru_721530.direction.y;
450 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
451 if ( v5 > 0 )
452 {
453 v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
454 result = pParty->vPosition.z;
455 if ( v6 >= pParty->vPosition.z )
622 { 456 {
623 if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) ) 457 result = v9 + pParty->vPosition.z;
458 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
624 { 459 {
625 if ( stru_721530.sMinZ >= pParty->vPosition.z ) 460 result = integer_sqrt(v3 * v3 - v4 * v4);
461 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
462 if ( v7 < 0 )
463 v7 = 0;
464 if ( v7 < stru_721530.field_7C )
626 { 465 {
627 v3 = stru_721530.prolly_normal_d + v1; 466 stru_721530.field_7C = v7;
628 v11 = pParty->vPosition.x - stru_721530.normal.x; 467 stru_721530.uFaceID = 4;
629 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
630 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
631 v10 = pParty->vPosition.y - stru_721530.normal.y;
632 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
633 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
634 if ( result <= v3 )
635 {
636 result = v10 * stru_721530.direction.y;
637 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
638 if ( v5 > 0 )
639 {
640 v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
641 result = pParty->vPosition.z;
642 if ( v6 >= pParty->vPosition.z )
643 {
644 result = v9 + pParty->vPosition.z;
645 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
646 {
647 result = integer_sqrt(v3 * v3 - v4 * v4);
648 v7 = v5 - result;
649 if ( v7 < 0 )
650 v7 = 0;
651 if ( v7 < stru_721530.field_7C )
652 {
653 stru_721530.field_7C = v7;
654 stru_721530.uFaceID = 4;
655 }
656 }
657 }
658 }
659 }
660 } 468 }
661 } 469 }
662 } 470 }
663 } 471 }
664 } 472 }
667 } 475 }
668 476
669 //----- (0046F04E) -------------------------------------------------------- 477 //----- (0046F04E) --------------------------------------------------------
670 int _46F04E_collide_against_portals() 478 int _46F04E_collide_against_portals()
671 { 479 {
672 BLVSector *v0; // ecx@1
673 unsigned int v1; // eax@1 480 unsigned int v1; // eax@1
674 int v2; // eax@2 481 BLVFace *face; // eax@3
675 BLVFace *v3; // eax@3
676 int v4; // ecx@9 482 int v4; // ecx@9
677 int v5; // edx@9 483 int v5; // edx@9
678 signed int result; // eax@21 484 signed int result; // eax@21
679 BLVFace *v7; // eax@22
680 signed int v8; // [sp+0h] [bp-14h]@1
681 BLVSector *v9; // [sp+4h] [bp-10h]@1
682 unsigned int v10; // [sp+8h] [bp-Ch]@1 485 unsigned int v10; // [sp+8h] [bp-Ch]@1
683 int a3; // [sp+Ch] [bp-8h]@13 486 int a3; // [sp+Ch] [bp-8h]@13
684 int v12; // [sp+10h] [bp-4h]@15 487 int v12; // [sp+10h] [bp-4h]@15
685 488
686 v8 = 0;
687 v0 = &pIndoor->pSectors[stru_721530.uSectorID];
688 v1 = 0xFFFFFFu; 489 v1 = 0xFFFFFFu;
689 v10 = 0xFFFFFFu; 490 v10 = 0xFFFFFFu;
690 v9 = v0; 491 for ( uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i )
691 if ( v0->uNumPortals > 0 ) 492 {
692 { 493 if ( pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80 )
693 do 494 {
694 { 495 face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]];
695 v2 = v0->pPortals[v8]; 496 if ( stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1
696 if ( v2 != stru_721530.field_80 ) 497 && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1
697 { 498 && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1 )
698 v3 = &pIndoor->pFaces[v2]; 499 {
699 if ( stru_721530.sMaxX <= v3->pBounding.x2 ) 500 v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist
501 + stru_721530.normal.y * face->pFacePlane_old.vNormal.y
502 + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16;
503 v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist
504 + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x
505 + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16;
506 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
507 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
508 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face))
509 && a3 < (signed int)v10 )
700 { 510 {
701 if ( stru_721530.sMinX >= v3->pBounding.x1 511 v10 = a3;
702 && stru_721530.sMaxY <= v3->pBounding.y2 512 v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i];
703 && stru_721530.sMinY >= v3->pBounding.y1
704 && stru_721530.sMaxZ <= v3->pBounding.z2
705 && stru_721530.sMinZ >= v3->pBounding.z1 )
706 {
707 v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x + v3->pFacePlane_old.dist
708 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
709 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
710 v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z + v3->pFacePlane_old.dist
711 + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
712 + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
713 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
714 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
715 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, v3))
716 && a3 < (signed int)v10 )
717 {
718 v0 = v9;
719 v10 = a3;
720 v12 = v9->pPortals[v8];
721 }
722 else
723 {
724 v0 = v9;
725 }
726 }
727 } 513 }
728 } 514 }
729 ++v8; 515 }
730 } 516 }
731 while ( v8 < v0->uNumPortals ); 517 v1 = v10;
732 v1 = v10;
733 }
734 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C ) 518 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C )
735 { 519 {
736 stru_721530.field_80 = v12; 520 stru_721530.field_80 = v12;
737 v7 = &pIndoor->pFaces[v12]; 521 if ( pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID )
738 if ( v7->uSectorID == stru_721530.uSectorID ) 522 stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID;
739 stru_721530.uSectorID = v7->uBackSectorID;
740 else 523 else
741 stru_721530.uSectorID = v7->uSectorID; 524 stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID;
742 stru_721530.field_7C = 268435455; 525 stru_721530.field_7C = 268435455;
743 result = 0; 526 result = 0;
744 } 527 }
745 else 528 else
746 { 529 {
858 } 641 }
859 642
860 //----- (004706C6) -------------------------------------------------------- 643 //----- (004706C6) --------------------------------------------------------
861 void UpdateActors_ODM() 644 void UpdateActors_ODM()
862 { 645 {
863 Actor *v0; // esi@2
864 AIState uAIState; // ax@2
865 //unsigned int v2; // ecx@6
866 int v3; // ebx@6 646 int v3; // ebx@6
867 //int v4; // eax@8
868 int v5; // eax@10 647 int v5; // eax@10
869 int v6; // ecx@10 648 int v6; // ecx@10
870 //signed int v7; // ebx@10
871 signed int v8; // ebx@17 649 signed int v8; // ebx@17
872 //unsigned __int8 v9; // zf@17
873 unsigned __int8 v10; // sf@17 650 unsigned __int8 v10; // sf@17
874 unsigned __int16 v11; // ax@21 651 unsigned __int16 v11; // ax@21
875 //int v12; // eax@29
876 //unsigned __int64 v13; // qax@29
877 //int v14; // eax@30
878 //unsigned __int64 v15; // qax@30
879 int v16; // eax@33
880 //int v17; // edi@34
881 //int v18; // edx@42
882 //int v19; // ecx@42
883 __int16 v20; // ax@42 652 __int16 v20; // ax@42
884 //int v21; // ebx@42
885 //int v22; // edi@42
886 //int v23; // ecx@42
887 //__int16 v24; // ax@42
888 int v25; // eax@45 653 int v25; // eax@45
889 signed int v26; // ecx@50 654 signed int v26; // ecx@50
890 //int v27; // eax@52
891 int v28; // eax@54 655 int v28; // eax@54
892 signed int v29; // ebx@57 656 signed int v29; // ebx@57
893 signed int v30; // eax@57 657 signed int v30; // eax@57
894 int v31; // edi@57 658 int v31; // edi@57
895 signed int i; // ebx@57 659 signed int i; // ebx@57
896 unsigned int v33; // ecx@58 660 unsigned int v33; // ecx@58
897 //int v34; // ebx@64
898 int v35; // edi@64 661 int v35; // edi@64
899 int v36; // eax@64 662 int v36; // eax@64
900 //unsigned __int16 v37; // cx@66
901 signed int v38; // edx@71
902 unsigned int v39; // edi@71 663 unsigned int v39; // edi@71
903 BSPModel *v40; // eax@75 664 ODMFace *face; // edi@75
904 ODMFace *v41; // edi@75
905 int v42; // ebx@76
906 int v43; // ecx@77
907 int v44; // edx@77
908 __int16 v45; // dx@82
909 int v46; // ecx@82 665 int v46; // ecx@82
910 signed int v47; // ebx@85 666 signed int v47; // ebx@85
911 int v48; // edi@85 667 int v48; // edi@85
912 int v49; // edi@85
913 //int v50; // eax@85
914 //unsigned __int64 v51; // qax@85
915 //unsigned __int8 v52; // zf@87
916 //unsigned __int8 v53; // sf@87
917 // unsigned __int8 v54; // of@104
918 int v55; // eax@107 668 int v55; // eax@107
919 unsigned int v56; // edi@107 669 unsigned int v56; // edi@107
920 int v57; // ST10_4@107 670 int v57; // ST10_4@107
921 unsigned int v58; // edi@107 671 unsigned int v58; // edi@107
922 unsigned int v59; // ebx@107 672 unsigned int v59; // ebx@107
923 signed int v60; // eax@107 673 signed int v60; // eax@107
924 int v61; // eax@124 674 int v61; // eax@124
925 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 675 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
926 int v63; // [sp+18h] [bp-38h]@64 676 int v63; // [sp+18h] [bp-38h]@64
927 int v64; // [sp+1Ch] [bp-34h]@64 677 int v64; // [sp+1Ch] [bp-34h]@64
928 int v65; // [sp+20h] [bp-30h]@2
929 int v66; // [sp+24h] [bp-2Ch]@2
930 bool v67; // [sp+28h] [bp-28h]@10 678 bool v67; // [sp+28h] [bp-28h]@10
931 //unsigned int v68; // [sp+2Ch] [bp-24h]@10
932 unsigned int v69; // [sp+30h] [bp-20h]@6 679 unsigned int v69; // [sp+30h] [bp-20h]@6
933 unsigned int v70; // [sp+34h] [bp-1Ch]@10 680 unsigned int v70; // [sp+34h] [bp-1Ch]@10
934 int v71; // [sp+38h] [bp-18h]@62 681 int v71; // [sp+38h] [bp-18h]@62
935 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 682 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
936 int v72b; 683 int v72b;
939 unsigned int v75; // [sp+48h] [bp-8h]@1 686 unsigned int v75; // [sp+48h] [bp-8h]@1
940 int uIsOnWater; // [sp+4Ch] [bp-4h]@10 687 int uIsOnWater; // [sp+4Ch] [bp-4h]@10
941 688
942 for (v75 = 0; v75 < uNumActors; ++v75) 689 for (v75 = 0; v75 < uNumActors; ++v75)
943 { 690 {
944 v0 = &pActors[v75]; 691 if ( pActors[v75].uAIState == Removed || pActors[v75].uAIState == Disabled || pActors[v75].uAIState == Summoned
945 v66 = v0->vPosition.x; 692 || !pActors[v75].uMovementSpeed )
946 v65 = v0->vPosition.y; 693 continue;
947 uAIState = v0->uAIState;
948 if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed )
949 {
950 continue;
951 }
952 v3 = 0; 694 v3 = 0;
953 v69 = 0; 695 v69 = 0;
954 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) 696 if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
955 v3 = 1; 697 v3 = 1;
956 v0->uSectorID = 0; 698 pActors[v75].uSectorID = 0;
957 uIsFlying = v0->pMonsterInfo.uFlying; 699 uIsFlying = pActors[v75].pMonsterInfo.uFlying;
958 if ( !v0->CanAct() ) 700 if ( !pActors[v75].CanAct() )
959 uIsFlying = 0; 701 uIsFlying = 0;
960 v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); 702 v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y);
961 v5 = ODM_GetFloorLevel( 703 v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z,
962 v0->vPosition.x, 704 pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3);
963 v0->vPosition.y, 705 v6 = pActors[v75].vPosition.z;
964 v0->vPosition.z,
965 v0->uActorHeight,
966 &uIsOnWater,
967 (int *)&v69,
968 v3);
969 v6 = v0->vPosition.z;
970 uIsAboveFloor = 0; 706 uIsAboveFloor = 0;
971 v67 = v69 == 0; 707 v67 = v69 == 0;
972 if ( v6 > v5 + 1 ) 708 if ( v6 > v5 + 1 )
973 uIsAboveFloor = 1; 709 uIsAboveFloor = 1;
974 if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) 710 if ( pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor )
975 { 711 {
976 v0->uAIState = Removed; 712 pActors[v75].uAIState = Removed;
977 continue; 713 continue;
978 } 714 }
979 if ( v0->uCurrentActionAnimation == ANIM_Walking ) 715 if ( pActors[v75].uCurrentActionAnimation == ANIM_Walking )
980 { 716 {
981 v8 = v0->uMovementSpeed; 717 v8 = pActors[v75].uMovementSpeed;
982 if ( (signed __int64)v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) 718 if ( (signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
983 { 719 {
984 v8 = (signed __int64)((double)v8 * 0.5); 720 v8 = (signed __int64)((double)v8 * 0.5);
985 } 721 }
986 if ( uAIState == Fleeing || uAIState == Pursuing ) 722 if ( pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing )
987 { 723 {
988 v8 *= 2; 724 v8 *= 2;
989 } 725 }
990 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 ) 726 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 )
991 v8 *= flt_6BE3AC_debug_recmod1_x_1_6; 727 v8 *= flt_6BE3AC_debug_recmod1_x_1_6;
992 if ( v8 > 1000 ) 728 if ( v8 > 1000 )
993 v8 = 1000; 729 v8 = 1000;
994 730
995 v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v0->uYawAngle), v8); 731 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8);
996 v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v0->uYawAngle), v8); 732 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8);
997 if ( uIsFlying ) 733 if ( uIsFlying )
998 { 734 {
999 v0->vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(v0->uPitchAngle), v8); 735 pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8);
1000 } 736 }
1001 //v7 = v68; 737 //v7 = v68;
1002 } 738 }
1003 else 739 else
1004 { 740 {
1005 v0->vVelocity.x = fixpoint_mul(55000, v0->vVelocity.x); 741 pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x);
1006 v0->vVelocity.y = fixpoint_mul(55000, v0->vVelocity.y); 742 pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y);
1007 if ( uIsFlying ) 743 if ( uIsFlying )
1008 { 744 pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z);
1009 v0->vVelocity.z = fixpoint_mul(55000, v0->vVelocity.z); 745 }
1010 } 746 if ( pActors[v75].vPosition.z < v5 )
1011 } 747 {
1012 if ( v0->vPosition.z < v5 ) 748 pActors[v75].vPosition.z = v5;
1013 { 749 pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0;
1014 v16 = uIsFlying;
1015 v0->vPosition.z = v5;
1016 v0->vVelocity.z = v16 != 0 ? 0x14 : 0;
1017 } 750 }
1018 //v17 = 0; 751 //v17 = 0;
1019 if ( !uIsAboveFloor || uIsFlying ) 752 if ( !uIsAboveFloor || uIsFlying )
1020 { 753 {
1021 if ( v70 && !uIsAboveFloor && v67 ) 754 if ( v70 && !uIsAboveFloor && v67 )
1022 { 755 {
1023 v0->vPosition.z = v5; 756 pActors[v75].vPosition.z = v5;
1024 ODM_GetTerrainNormalAt(v0->vPosition.x, v0->vPosition.y, &v62); 757 ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62);
1025 v20 = GetGravityStrength(); 758 v20 = GetGravityStrength();
1026 //v21 = v62.y; 759 //v21 = v62.y;
1027 //v22 = v62.z; 760 //v22 = v62.z;
1028 //v23 = v62.y * v0->vVelocity.y; 761 //v23 = v62.y * v0->vVelocity.y;
1029 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; 762 pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
1030 int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16; 763 int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16;
1031 //v72b = v21; 764 //v72b = v21;
1032 v0->vVelocity.x += fixpoint_mul(v73, v62.x); 765 pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x);
1033 v0->vVelocity.y += fixpoint_mul(v73, v62.y); 766 pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y);
1034 v0->vVelocity.z += fixpoint_mul(v73, v62.z); 767 pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z);
1035 //v17 = 0; 768 //v17 = 0;
1036 } 769 }
1037 } 770 }
1038 else 771 else
1039 { 772 {
1040 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); 773 pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1041 } 774 }
1042 if ( pParty->armageddon_timer != 0 && v0->CanAct() ) 775 if ( pParty->armageddon_timer != 0 && pActors[v75].CanAct() )
1043 { 776 {
1044 v0->vVelocity.x += rand() % 100 - 50; 777 pActors[v75].vVelocity.x += rand() % 100 - 50;
1045 v0->vVelocity.y += rand() % 100 - 50; 778 pActors[v75].vVelocity.y += rand() % 100 - 50;
1046 v0->vVelocity.z += rand() % 100 - 20; 779 pActors[v75].vVelocity.z += rand() % 100 - 20;
1047 v25 = rand(); 780 v25 = rand();
1048 v0->uAIState = Stunned; 781 pActors[v75].uAIState = Stunned;
1049 v0->uYawAngle += v25 % 32 - 16; 782 pActors[v75].uYawAngle += v25 % 32 - 16;
1050 v0->UpdateAnimation(); 783 pActors[v75].UpdateAnimation();
1051 } 784 }
1052 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 ) 785 if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0 )
1053 { 786 {
1054 v0->vVelocity.y = 0; 787 pActors[v75].vVelocity.y = 0;
1055 v0->vVelocity.x = 0; 788 pActors[v75].vVelocity.x = 0;
1056 } 789 }
1057 stru_721530.field_0 = 1; 790 stru_721530.field_0 = 1;
1058 if ( !uIsFlying ) 791 if ( !uIsFlying )
1059 v26 = 40; 792 v26 = 40;
1060 else 793 else
1061 v26 = v0->uActorRadius; 794 v26 = pActors[v75].uActorRadius;
1062 795
1063 stru_721530.field_84 = -1; 796 stru_721530.field_84 = -1;
1064 stru_721530.field_8_radius = v26; 797 stru_721530.field_8_radius = v26;
1065 stru_721530.prolly_normal_d = v26; 798 stru_721530.prolly_normal_d = v26;
1066 stru_721530.height = v0->uActorHeight; 799 stru_721530.height = pActors[v75].uActorHeight;
1067 stru_721530.field_70 = 0; 800 stru_721530.field_70 = 0;
1068 v69 = 0; 801
1069 while ( 1 ) 802 for ( v69 = 0; v69 < 100; ++v69 )
1070 { 803 {
1071 stru_721530.position.x = v0->vPosition.x; 804 stru_721530.position.x = pActors[v75].vPosition.x;
1072 stru_721530.normal.x = stru_721530.position.x; 805 stru_721530.normal.x = stru_721530.position.x;
1073 stru_721530.position.y = v0->vPosition.y; 806 stru_721530.position.y = pActors[v75].vPosition.y;
1074 stru_721530.normal.y = stru_721530.position.y; 807 stru_721530.normal.y = stru_721530.position.y;
1075 v28 = v0->vPosition.z; 808 v28 = pActors[v75].vPosition.z;
1076 stru_721530.normal.z = v28 + v26 + 1; 809 stru_721530.normal.z = v28 + v26 + 1;
1077 stru_721530.position.z = v28 - v26 + stru_721530.height - 1; 810 stru_721530.position.z = v28 - v26 + stru_721530.height - 1;
1078 if ( stru_721530.position.z < stru_721530.normal.z ) 811 if ( stru_721530.position.z < stru_721530.normal.z )
1079 stru_721530.position.z = v28 + v26 + 1; 812 stru_721530.position.z = v28 + v26 + 1;
1080 stru_721530.velocity.x = v0->vVelocity.x; 813 stru_721530.velocity.x = pActors[v75].vVelocity.x;
1081 stru_721530.uSectorID = 0; 814 stru_721530.uSectorID = 0;
1082 stru_721530.velocity.y = v0->vVelocity.y; 815 stru_721530.velocity.y = pActors[v75].vVelocity.y;
1083 stru_721530.velocity.z = v0->vVelocity.z; 816 stru_721530.velocity.z = pActors[v75].vVelocity.z;
1084 if ( stru_721530._47050A(0) ) 817 if ( stru_721530._47050A(0) )
1085 break; 818 break;
1086 _46E889_collide_against_bmodels(1u); 819 _46E889_collide_against_bmodels(1);
1087 v29 = WorldPosToGridCellZ(v0->vPosition.y); 820 v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y);
1088 v30 = WorldPosToGridCellX(v0->vPosition.x); 821 v30 = WorldPosToGridCellX(pActors[v75].vPosition.x);
1089 _46E26D_collide_against_sprites(v30, v29); 822 _46E26D_collide_against_sprites(v30, v29);
1090 _46EF01_collision_chech_player(0); 823 _46EF01_collision_chech_player(0);
1091 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); 824 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75));
1092 v31 = 0; 825 v31 = 0;
1093 for ( i = 0; v31 < ai_arrays_size; ++v31 ) 826 for ( i = 0; v31 < ai_arrays_size; ++v31 )
1099 v71 = i > 1; 832 v71 = i > 1;
1100 if ( stru_721530.field_7C < stru_721530.field_6C ) 833 if ( stru_721530.field_7C < stru_721530.field_6C )
1101 v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); 834 v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
1102 //v34 = 0; 835 //v34 = 0;
1103 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; 836 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1104 v36 = ODM_GetFloorLevel(stru_721530.normal2.x, 837 v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y,
1105 stru_721530.normal2.y,
1106 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, 838 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
1107 v0->uActorHeight, 839 pActors[v75].uActorHeight, (int *)&v63, &v64, 0);
1108 (int *)&v63,
1109 &v64,
1110 0);
1111 if ( uIsOnWater ) 840 if ( uIsOnWater )
1112 { 841 {
1113 if ( v35 < v36 + 60 ) 842 if ( v35 < v36 + 60 )
1114 { 843 {
1115 if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) 844 if ( pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed
845 || pActors[v75].uAIState == Disabled )
1116 { 846 {
1117 if ( v64 ) 847 if ( v64 )
1118 v61 = v36 + 30; 848 v61 = v36 + 30;
1119 else 849 else
1120 v61 = v5 + 60; 850 v61 = v5 + 60;
1121 sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61); 851 sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61);
1122 v0->uAIState = Removed; 852 pActors[v75].uAIState = Removed;
1123 return; 853 return;
1124 } 854 }
1125 } 855 }
1126 } 856 }
1127 if ( stru_721530.field_7C >= stru_721530.field_6C ) 857 if ( stru_721530.field_7C >= stru_721530.field_6C )
1128 { 858 {
1129 v0->vPosition.x = LOWORD(stru_721530.normal2.x); 859 pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x);
1130 v0->vPosition.y = LOWORD(stru_721530.normal2.y); 860 pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y);
1131 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; 861 pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
1132 break; 862 break;
1133 } 863 }
1134 //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x); 864 //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x);
1135 v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); 865 pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
1136 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; 866 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1137 v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); 867 pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
1138 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; 868 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1139 v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); 869 pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
1140 v38 = stru_721530.uFaceID;
1141 stru_721530.field_70 += stru_721530.field_7C; 870 stru_721530.field_70 += stru_721530.field_7C;
1142 v39 = PID_ID(v38); 871 v39 = PID_ID(stru_721530.uFaceID);
1143 switch ( PID_TYPE(v38) ) 872 switch ( PID_TYPE(stru_721530.uFaceID) )
1144 { 873 {
1145 case OBJECT_Actor: 874 case OBJECT_Actor:
1146 if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 ) 875 if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 )
1147 { 876 {
1148 //if(pParty->bTurnBasedModeOn == 1) 877 //if(pParty->bTurnBasedModeOn == 1)
1149 //v34 = 0; 878 //v34 = 0;
1150 if ( v0->pMonsterInfo.uHostilityType ) 879 if ( pActors[v75].pMonsterInfo.uHostilityType )
1151 { 880 {
1152 if ( v71 == 0 ) 881 if ( v71 == 0 )
1153 { 882 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
1154 Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); 883 else
1155 } 884 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
1156 else
1157 {
1158 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
1159 }
1160 } 885 }
1161 else if ( v71 ) 886 else if ( v71 )
1162 {
1163 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); 887 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
1164 } 888 else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
1165 else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) 889 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
1166 { 890 else
1167 Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); 891 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
1168 }
1169 else
1170 {
1171 Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
1172 }
1173 } 892 }
1174 break; 893 break;
1175 case OBJECT_Player: 894 case OBJECT_Player:
1176 if ( !v0->GetActorsRelation(0) ) 895 if ( !pActors[v75].GetActorsRelation(0) )
1177 { 896 {
1178 v38 = stru_721530.uFaceID; 897 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
1179 Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
1180 break; 898 break;
1181 } 899 }
1182 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; 900 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0;
1183 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; 901 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0;
1184 v0->vVelocity.y = 0; 902 pActors[v75].vVelocity.y = 0;
1185 v0->vVelocity.x = 0; 903 pActors[v75].vVelocity.x = 0;
1186 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) 904 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) )
1187 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) 905 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
1188 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); 906 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
1189 viewparams->bRedrawGameUI = 1; 907 viewparams->bRedrawGameUI = 1;
1190 break; 908 break;
1191 case OBJECT_Decoration: 909 case OBJECT_Decoration:
1192 v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); 910 v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y);
1193 v48 = stru_5C6E00->Atan2( 911 v48 = stru_5C6E00->Atan2( pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x,
1194 v0->vPosition.x - pLevelDecorations[v39].vPosition.x, 912 pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y);
1195 v0->vPosition.y - pLevelDecorations[v39].vPosition.y); 913 //v49 = v48;
1196 v49 = v48; 914 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
1197 v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); 915 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
1198 v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
1199 break; 916 break;
1200 case OBJECT_BModel: 917 case OBJECT_BModel:
1201 v40 = &pOutdoor->pBModels[v38 >> 9]; 918 face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F];
1202 v41 = &v40->pFaces[v39 & 0x3F]; 919 if ( !face->Ethereal() )
1203 if ( !(v41->uAttributes & 0x20000000) )
1204 { 920 {
1205 v42 = v41->uPolygonType; 921 if ( face->uPolygonType == 3 )
1206 if ( v42 == 3 )
1207 { 922 {
1208 v43 = v0->vVelocity.y; 923 pActors[v75].vVelocity.z = 0;
1209 v44 = v0->vVelocity.x; 924 pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1;
1210 v0->vVelocity.z = 0; 925 if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x
1211 v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1; 926 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 )
1212 if ( v44 * v44 + v43 * v43 < 400 )
1213 { 927 {
1214 v0->vVelocity.y = 0; 928 pActors[v75].vVelocity.y = 0;
1215 v0->vVelocity.x = 0; 929 pActors[v75].vVelocity.x = 0;
1216 } 930 }
1217 } 931 }
1218 else 932 else
1219 { 933 {
1220 v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z 934 v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z
1221 + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; 935 + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16;
1222 if ( (stru_721530.speed >> 3) > v72b ) 936 if ( (stru_721530.speed >> 3) > v72b )
1223 v72b = stru_721530.speed >> 3; 937 v72b = stru_721530.speed >> 3;
1224 938
1225 v0->vVelocity.x += fixpoint_mul(v72b, v41->pFacePlane.vNormal.x); 939 pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x);
1226 v0->vVelocity.y += fixpoint_mul(v72b, v41->pFacePlane.vNormal.y); 940 pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y);
1227 v0->vVelocity.z += fixpoint_mul(v72b, v41->pFacePlane.vNormal.z); 941 pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z);
1228 if ( v42 != 4 ) 942 if ( face->uPolygonType != 4 )
1229 { 943 {
1230 v45 = v0->vPosition.z;
1231 v46 = stru_721530.prolly_normal_d 944 v46 = stru_721530.prolly_normal_d
1232 - ((v41->pFacePlane.dist 945 - ((face->pFacePlane.dist
1233 + v41->pFacePlane.vNormal.x * v0->vPosition.x 946 + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x
1234 + v41->pFacePlane.vNormal.y * v0->vPosition.y 947 + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y
1235 + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16); 948 + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16);
1236 if ( v46 > 0 ) 949 if ( v46 > 0 )
1237 { 950 {
1238 v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16; 951 pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16;
1239 v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16; 952 pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16;
1240 v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16); 953 pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16;
1241 } 954 }
1242 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); 955 pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y);
1243 } 956 }
1244 } 957 }
1245 } 958 }
1246 break; 959 break;
1247 } 960 }
1248 961
1249 v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x); 962 pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x);
1250 v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y); 963 pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y);
1251 v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z); 964 pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z);
1252 965
1253 ++v69;
1254 if ( v69 >= 100 )
1255 break;
1256 v26 = stru_721530.prolly_normal_d; 966 v26 = stru_721530.prolly_normal_d;
1257 } 967 }
1258 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1; 968
1259 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1; 969 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
1260 if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) 970 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
1261 && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) 971 if ( WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x)
1262 && v58 972 && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y)
1263 || v67 != 0 ) 973 && v58 || v67 != 0 )
1264 { 974 {
1265 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) 975 if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
1266 { 976 {
1267 v58 = v58 == 0; 977 v58 = v58 == 0;
1268 v59 = v59 == 0; 978 v59 = v59 == 0;
1269 } 979 }
1270 if ( !uIsFlying && v58 && !v59 ) 980 if ( !uIsFlying && v58 && !v59 )
1271 { 981 {
1272 v0->vPosition.x = v66; 982 pActors[v75].vPosition.x = pActors[v75].vPosition.x;
1273 v0->vPosition.y = v65; 983 pActors[v75].vPosition.y = pActors[v75].vPosition.y;
1274 if ( v0->CanAct() ) 984 if ( pActors[v75].CanAct() )
1275 { 985 {
1276 v0->uYawAngle -= 32; 986 pActors[v75].uYawAngle -= 32;
1277 v0->uCurrentActionTime = 0; 987 pActors[v75].uCurrentActionTime = 0;
1278 v0->uCurrentActionLength = 128; 988 pActors[v75].uCurrentActionLength = 128;
1279 v0->uAIState = Fleeing; 989 pActors[v75].uAIState = Fleeing;
1280 } 990 }
1281 } 991 }
1282 } 992 }
1283 } 993 }
1284 } 994 }
1288 { 998 {
1289 unsigned int v0; // ebx@0 999 unsigned int v0; // ebx@0
1290 //unsigned int v1; // edi@1 1000 //unsigned int v1; // edi@1
1291 //char *v2; // esi@2 1001 //char *v2; // esi@2
1292 //__int16 v3; // dx@5 1002 //__int16 v3; // dx@5
1293 ObjectDesc *v4; // eax@5 1003 ObjectDesc *object; // eax@5
1294 int v5; // ecx@6 1004 int v5; // ecx@6
1295 __int16 v6; // cx@7 1005 __int16 v6; // cx@7
1296 signed int v7; // eax@9 1006 signed int v7; // eax@9
1297 __int16 v8; // cx@14 1007 //unsigned int v10; // ecx@16
1298 __int16 v9; // dx@14
1299 unsigned int v10; // ecx@16
1300 signed int v11; // eax@17 1008 signed int v11; // eax@17
1301 int v12; // edi@27 1009 int v12; // edi@27
1302 int v13; // eax@27 1010 int v13; // eax@27
1303 int v14; // ebx@27 1011 int v14; // ebx@27
1304 unsigned int v15; // ecx@27 1012 unsigned int v15; // ecx@27
1319 //LOWORD(v0) = item->uAttributes; 1027 //LOWORD(v0) = item->uAttributes;
1320 if (item->uAttributes & OBJECT_40) 1028 if (item->uAttributes & OBJECT_40)
1321 item->uAttributes &= ~OBJECT_40; 1029 item->uAttributes &= ~OBJECT_40;
1322 else 1030 else
1323 { 1031 {
1324 //v3 = item->uObjectDescID; 1032 object = &pObjectList->pObjects[item->uObjectDescID];
1325 v4 = &pObjectList->pObjects[item->uObjectDescID];
1326 if (item->AttachedToActor()) 1033 if (item->AttachedToActor())
1327 { 1034 {
1328 v5 = PID_ID(item->spell_target_pid); 1035 v5 = PID_ID(item->spell_target_pid);
1329 item->vPosition.x = pActors[v5].vPosition.x; 1036 item->vPosition.x = pActors[v5].vPosition.x;
1330 item->vPosition.y = pActors[v5].vPosition.y; 1037 item->vPosition.y = pActors[v5].vPosition.y;
1331 item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; 1038 item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
1332 if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) ) 1039 if ( !item->uObjectDescID )
1333 continue; 1040 continue;
1334 if ( v6 >= 0 ) 1041 item->uSpriteFrameID += pEventTimer->uTimeElapsed;
1042 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
1043 continue;
1044 if ( item->uSpriteFrameID >= 0 )
1335 { 1045 {
1336 v7 = v4->uLifetime; 1046 v7 = object->uLifetime;
1337 if (item->uAttributes & 2) 1047 if (item->uAttributes & ITEM_BROKEN)
1338 v7 = item->field_20; 1048 v7 = item->field_20;
1339 if ( v6 < v7 ) 1049 if ( item->uSpriteFrameID < v7 )
1340 continue; 1050 continue;
1341 } 1051 }
1342 v10 = i; 1052 SpriteObject::OnInteraction(i);
1343 SpriteObject::OnInteraction(v10); 1053 continue;
1344 continue;
1345 } 1054 }
1346 1055
1347 if ( item->uObjectDescID ) 1056 if ( item->uObjectDescID )
1348 { 1057 {
1349 v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID; 1058 item->uSpriteFrameID += pEventTimer->uTimeElapsed;
1350 item->uSpriteFrameID = v8; 1059 if ( object->uFlags & OBJECT_DESC_TEMPORARY )
1351 v9 = v4->uFlags; 1060 {
1352 if ( v9 & 4 ) 1061 if ( item->uSpriteFrameID < 0 )
1353 { 1062 {
1354 if ( v8 < 0 ) 1063 SpriteObject::OnInteraction(i);
1355 { 1064 continue;
1356 v10 = i; 1065 }
1357 SpriteObject::OnInteraction(v10); 1066 v11 = object->uLifetime;
1358 continue; 1067 if (item->uAttributes & ITEM_BROKEN)
1359 } 1068 v11 = item->field_20;
1360 v11 = v4->uLifetime; 1069 }
1361 if (item->uAttributes & 2) 1070 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 )
1362 v11 = item->field_20;
1363 }
1364 if ( !(v9 & 4) || v8 < v11 )
1365 { 1071 {
1366 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1072 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
1367 SpriteObject::UpdateObject_fn0_BLV(i); 1073 SpriteObject::UpdateObject_fn0_BLV(i);
1368 else 1074 else
1369 SpriteObject::UpdateObject_fn0_ODM(i); 1075 SpriteObject::UpdateObject_fn0_ODM(i);
1393 v14 = v17; 1099 v14 = v17;
1394 } 1100 }
1395 v0 = (unsigned int)(11 * v14) >> 5; 1101 v0 = (unsigned int)(11 * v14) >> 5;
1396 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 ) 1102 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
1397 continue; 1103 continue;
1398 v10 = i; 1104 SpriteObject::OnInteraction(i);
1399 SpriteObject::OnInteraction(v10);
1400 continue; 1105 continue;
1401 } 1106 }
1402 v10 = i; 1107 if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
1403 if ( !(v9 & 0x40) ) 1108 {
1404 { 1109 SpriteObject::OnInteraction(i);
1405 SpriteObject::OnInteraction(v10);
1406 continue; 1110 continue;
1407 } 1111 }
1408 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); 1112 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
1409 } 1113 }
1410 } 1114 }
1411 //v2 += 112;
1412 //v1 = v20++ + 1;
1413 //}
1414 //while ( v20 < (signed int)uNumSpriteObjects );
1415 } 1115 }
1416 } 1116 }
1417 1117
1418 //----- (0047272C) -------------------------------------------------------- 1118 //----- (0047272C) --------------------------------------------------------
1419 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) 1119 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
1449 } 1149 }
1450 } 1150 }
1451 return result; 1151 return result;
1452 } 1152 }
1453 1153
1454 //----- (00472866) --------------------------------------------------------
1455 void BLV_ProcessPartyActions()
1456 {
1457 int v1; // ebx@1
1458 int v2; // edi@1
1459 //int v6; // eax@18
1460 //signed __int64 v8; // qax@27
1461 //int v9; // eax@27
1462 double v10; // st7@27
1463 unsigned int v12; // eax@49
1464 double v13; // st7@50
1465 //int v14; // eax@51
1466 //signed __int64 v15; // qax@53
1467 //double v16; // st7@54
1468 int v17; // eax@62
1469 double v18; // st7@62
1470 int v19; // ST40_4@62
1471 int v20; // eax@65
1472 double v21; // st7@65
1473 int v22; // ST40_4@65
1474 int v23; // eax@66
1475 double v24; // st7@66
1476 int v25; // ST40_4@66
1477 int v26; // eax@67
1478 double v27; // st7@67
1479 int v28; // ST40_4@67
1480 unsigned int v35; // eax@74
1481 int v36; // ecx@88
1482 int new_party_z; // esi@96
1483 int v38; // eax@96
1484 int v39; // ecx@106
1485 int v40; // eax@106
1486 Player **v41; // esi@113
1487 int v42; // eax@120
1488 signed int v43; // ecx@123
1489 BLVFace *v44; // esi@126
1490 PolygonType v45; // al@126
1491 int v46; // ecx@133
1492 char v47; // zf@133
1493 int v48; // eax@133
1494 int v49; // ST40_4@136
1495 int v50; // ST40_4@140
1496 int v51; // eax@140
1497 int v52; // eax@140
1498 signed int v53; // edi@146
1499 int v54; // ebx@146
1500 int v55; // ST30_4@146
1501 AudioPlayer *v56; // ecx@162
1502 SoundID v57; // [sp-20h] [bp-80h]@163
1503 signed int v58; // [sp-1Ch] [bp-7Ch]@161
1504 unsigned int v59; // [sp-18h] [bp-78h]@161
1505 signed int v60; // [sp-14h] [bp-74h]@161
1506 signed int v61; // [sp-10h] [bp-70h]@161
1507 int v62; // [sp-Ch] [bp-6Ch]@161
1508 int v63; // [sp-8h] [bp-68h]@75
1509 unsigned int v64; // [sp-8h] [bp-68h]@161
1510 int v65; // [sp-4h] [bp-64h]@75
1511 int v66; // [sp-4h] [bp-64h]@161
1512 //int v68; // [sp+10h] [bp-50h]@45
1513 int v69; // [sp+10h] [bp-50h]@140
1514 unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
1515 //signed int v71; // [sp+18h] [bp-48h]@1
1516 signed int v72; // [sp+1Ch] [bp-44h]@1
1517 signed int v73; // [sp+20h] [bp-40h]@100
1518 int v74; // [sp+20h] [bp-40h]@140
1519 bool bFeatherFall; // [sp+24h] [bp-3Ch]@15
1520 unsigned int uSectorID; // [sp+28h] [bp-38h]@1
1521 int v78; // [sp+2Ch] [bp-34h]@1
1522 unsigned int uFaceID; // [sp+30h] [bp-30h]@1
1523 int v80; // [sp+34h] [bp-2Ch]@1
1524 int v81; // [sp+38h] [bp-28h]@47
1525 int v82; // [sp+3Ch] [bp-24h]@47
1526 int _view_angle; // [sp+40h] [bp-20h]@47
1527 int bJumping; // [sp+44h] [bp-1Ch]@1
1528 int new_party_y; // [sp+48h] [bp-18h]@1
1529 int new_party_x; // [sp+4Ch] [bp-14h]@1
1530 int party_z; // [sp+50h] [bp-10h]@1
1531 //int v89; // [sp+58h] [bp-8h]@1
1532 int angle; // [sp+5Ch] [bp-4h]@47
1533
1534 uFaceEvent = 0;
1535 //v89 = pParty->uFallSpeed;
1536 v1 = 0;
1537 v2 = 0;
1538 new_party_x = pParty->vPosition.x;
1539 new_party_y = pParty->vPosition.y;
1540 party_z = pParty->vPosition.z;
1541 uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
1542 v72 = 0;
1543 v78 = 0;
1544 bJumping = 0;
1545
1546 uFaceID = -1;
1547 int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
1548
1549 if ( pParty->bFlying )
1550 {
1551 pParty->bFlying = false;
1552 if (pParty->FlyActive())
1553 pOtherOverlayList->pOverlays[pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID - 1].field_E |= 1;
1554 }
1555
1556 if ( floor_level == -30000 || uFaceID == -1)
1557 {
1558 floor_level = collide_against_floor_approximate(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
1559 if ( floor_level == -30000 || uFaceID == -1)
1560 {
1561 __debugbreak(); // level built with errors
1562 pParty->vPosition.x = blv_prev_party_x;
1563 pParty->vPosition.y = blv_prev_party_z;
1564 pParty->vPosition.z = blv_prev_party_y;
1565 pParty->uFallStartY = blv_prev_party_y;
1566 return;
1567 }
1568 }
1569
1570 blv_prev_party_x = pParty->vPosition.x;
1571 blv_prev_party_z = pParty->vPosition.y;
1572 blv_prev_party_y = pParty->vPosition.z;
1573 if (!pParty->bTurnBasedModeOn)
1574 {
1575 int v67 = GetTickCount() / 500;
1576 if (dword_720CDC != v67 )
1577 {
1578 dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x;
1579 dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y;
1580 dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z;
1581 if ( dword_4F8580[0] > 60 )
1582 dword_4F8580[0] = 1;
1583 }
1584 dword_720CDC = v67;
1585 }
1586
1587 uint fall_start;
1588 if (!pParty->FeatherFallActive())
1589 {
1590 bFeatherFall = false;
1591 if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && // grants feather fall
1592 !pParty->pPlayers[1].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
1593 !pParty->pPlayers[2].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
1594 !pParty->pPlayers[3].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT))
1595 {
1596 fall_start = pParty->uFallStartY;
1597 }
1598 }
1599 else
1600 {
1601 fall_start = floor_level;
1602 bFeatherFall = true;
1603 pParty->uFallStartY = floor_level;
1604 }
1605
1606
1607 if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1)
1608 {
1609 assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor?
1610 if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
1611 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
1612 else for (uint i = 0; i < 4; ++i)
1613 { // receive falling damage
1614 Player* player = &pParty->pPlayers[i];
1615 if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS))
1616 {
1617 player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL);
1618 v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
1619 player->SetRecoveryTime((signed __int64)v10);
1620 }
1621 }
1622 }
1623
1624 if ( party_z > floor_level + 1 )
1625 bJumping = 1;
1626
1627 bool jumping_up = false;
1628
1629 if ( party_z - floor_level <= 32 )
1630 {
1631 pParty->uFallStartY = party_z;
1632 jumping_up = true;
1633 }
1634
1635 if (bWalkSound && pParty->walk_sound_timer)
1636 {
1637 if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed)
1638 pParty->walk_sound_timer -= pEventTimer->uTimeElapsed;
1639 else pParty->walk_sound_timer = 0;
1640 }
1641
1642
1643 if (party_z <= floor_level + 1)
1644 {
1645 party_z = floor_level + 1;
1646 pParty->uFallStartY = floor_level + 1;
1647
1648 if (!bJumping && pParty->floor_face_pid != uFaceID)
1649 {
1650 BLVFace* pFace = &pIndoor->pFaces[uFaceID];
1651 if (pFace->uAttributes & FACE_PRESSURE_PLATE)
1652 uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
1653 }
1654 }
1655 if (!bJumping)
1656 pParty->floor_face_pid = uFaceID;
1657
1658 bool on_water = false;
1659 if ( pIndoor->pFaces[uFaceID].Fluid())
1660 on_water = true;
1661
1662 v81 = pParty->uWalkSpeed;
1663 angle = pParty->sRotationY;
1664 _view_angle = pParty->sRotationX;
1665 v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi)
1666 / 180)) >> 16;
1667 //LABEL_87:
1668 while ( pPartyActionQueue->uNumActions )
1669 {
1670 switch ( pPartyActionQueue->Next() )
1671 {
1672 case PARTY_TurnLeft:
1673 if (uTurnSpeed)
1674 angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed);
1675 else
1676 angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier));
1677 break;
1678 case PARTY_TurnRight:
1679 if (uTurnSpeed)
1680 angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed);
1681 else
1682 angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier));
1683 break;
1684
1685 case PARTY_FastTurnLeft:
1686 if (uTurnSpeed)
1687 angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed);
1688 else
1689 angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82));
1690 break;
1691
1692 case PARTY_FastTurnRight:
1693 if (uTurnSpeed)
1694 angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed);
1695 else
1696 angle = stru_5C6E00->uDoublePiMask & (angle - (int)(2.0f * fTurnSpeedMultiplier * (double)v82));
1697 break;
1698
1699 case PARTY_StrafeLeft:
1700 v2 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
1701 v1 += fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
1702 v78 = 1;
1703 break;
1704 case PARTY_StrafeRight:
1705 v2 += fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
1706 v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
1707 v78 = 1;
1708 break;
1709 case PARTY_WalkForward:
1710 v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier);
1711 v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier);
1712 v78 = 1;
1713 break;
1714 case PARTY_WalkBackward:
1715 v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
1716 v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
1717 v78 = 1;
1718 break;
1719 case PARTY_RunForward:
1720 v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier);
1721 v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier);
1722 v72 = 1;
1723 break;
1724 case PARTY_RunBackward:
1725 //v32 = stru_5C6E00->SinCos(angle);
1726 //v33 = (double)v81;
1727 //v88 = (double)v81;
1728 v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
1729 //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
1730 v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
1731 v72 = 1;
1732 break;
1733 case PARTY_LookUp:
1734 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
1735 if ( _view_angle > 128 )
1736 _view_angle = 128;
1737 v35 = uActiveCharacter;
1738 if ( uActiveCharacter )
1739 pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0);
1740 break;
1741 case PARTY_LookDown:
1742 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
1743 if ( _view_angle < -128 )
1744 _view_angle = -128;
1745 v35 = uActiveCharacter;
1746 if ( uActiveCharacter )
1747 pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_64, 0);
1748 break;
1749 case PARTY_CenterView:
1750 _view_angle = 0;
1751 break;
1752 case PARTY_Jump:
1753 if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 )
1754 {
1755 bJumping = 1;
1756 pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
1757 }
1758 break;
1759 default:
1760 break;
1761 }
1762 }
1763 v36 = 0;
1764 pParty->sRotationY = angle;
1765 pParty->sRotationX = _view_angle;
1766 if ( bJumping )
1767 {
1768 pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
1769 if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
1770 {
1771 if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
1772 {
1773 v41 = &pPlayers[1];
1774 do
1775 {
1776 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8
1777 (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
1778 ++v41;
1779 }
1780 while ( (signed int)v41 <= (signed int)&pPlayers[4] );
1781 }
1782 }
1783 else
1784 pParty->uFallStartY = party_z;
1785 }
1786 else
1787 {
1788 if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 )
1789 {
1790 pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
1791 pParty->uFallStartY = party_z;
1792 }
1793 else
1794 {
1795 if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
1796 pParty->uFallSpeed = 0;
1797 pParty->uFallStartY = party_z;
1798 }
1799 }
1800 if ( v2 * v2 + v1 * v1 < 400 )
1801 {
1802 v1 = 0;
1803 v2 = 0;
1804 }
1805 stru_721530.field_84 = -1;
1806 stru_721530.field_70 = 0;
1807 stru_721530.prolly_normal_d = pParty->field_14_radius;
1808 stru_721530.field_8_radius = pParty->field_14_radius / 2;
1809 int v83 = 0;
1810 stru_721530.field_0 = 1;
1811 stru_721530.height = pParty->uPartyHeight - 32;
1812 while ( 1 )
1813 {
1814 new_party_z = party_z;
1815 stru_721530.position.x = new_party_x;
1816 stru_721530.normal.x = new_party_x;
1817 stru_721530.velocity.x = v2;
1818 stru_721530.position.y = new_party_y;
1819 stru_721530.normal.y = new_party_y;
1820 stru_721530.velocity.y = v1;
1821 stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
1822 stru_721530.position.z = stru_721530.height + party_z + 1;
1823 stru_721530.velocity.z = pParty->uFallSpeed;
1824 stru_721530.uSectorID = uSectorID;
1825 v38 = 0;
1826 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
1827 v38 = 13312;
1828 if ( stru_721530._47050A(v38) )
1829 break;
1830 v73 = 0;
1831 do
1832 {
1833 _46E44E_collide_against_faces_and_portals(1u);
1834 _46E0B2_collide_against_decorations();
1835 for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
1836 Actor::_46DF1A_collide_against_actor(v80, 0);
1837 if ( _46F04E_collide_against_portals() )
1838 break;
1839 ++v73;
1840 }
1841 while ( v73 < 100 );
1842 if ( stru_721530.field_7C >= stru_721530.field_6C )
1843 {
1844 v39 = stru_721530.normal2.x;
1845 uSectorID = stru_721530.normal2.y;
1846 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1847 }
1848 else
1849 {
1850 v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x;
1851 uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16);
1852 v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16);
1853 }
1854 v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
1855 if ( v42 == -30000 || v42 - new_party_z > 128 )
1856 return;
1857 if ( stru_721530.field_7C >= stru_721530.field_6C )
1858 {
1859 new_party_x = stru_721530.normal2.x;
1860 new_party_y = stru_721530.normal2.y;
1861 new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1862 break;
1863 }
1864 new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
1865 new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
1866 v43 = stru_721530.uFaceID;
1867 uSectorID = stru_721530.uSectorID;
1868 stru_721530.field_70 += stru_721530.field_7C;
1869 unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z;
1870 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
1871 {
1872 if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0
1873 && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
1874 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
1875 viewparams->bRedrawGameUI = 1;
1876 }
1877 else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
1878 {
1879 v53 = integer_sqrt(v2 * v2 + v1 * v1);
1880 v80 = v53;
1881 v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
1882 new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
1883 v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)v53) >> 16;
1884 v55 = stru_5C6E00->Sin(v54);
1885 v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16;
1886 }
1887 else
1888 {
1889 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
1890 {
1891 v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
1892 v45 = v44->uPolygonType;
1893 if ( v45 == 3 )
1894 {
1895 if ( pParty->uFallSpeed < 0 )
1896 pParty->uFallSpeed = 0;
1897 v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1;
1898 if ( pParty->uFallStartY - v87 < 512 )
1899 pParty->uFallStartY = v87;
1900 if ( v2 * v2 + v1 * v1 < 400 )
1901 {
1902 v1 = 0;
1903 v2 = 0;
1904 }
1905 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
1906 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
1907 }
1908 else
1909 {
1910 v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
1911 v47 = v45 == 4;
1912 v48 = v44->pFacePlane_old.vNormal.x;
1913 if ( !v47 )
1914 {
1915 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
1916 if ((stru_721530.speed >> 3) > v80 )
1917 v80 = stru_721530.speed >> 3;
1918 v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
1919 v81 = v44->pFacePlane_old.vNormal.y;
1920 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
1921 v82 = v44->pFacePlane_old.vNormal.z;
1922 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
1923 v2 += v50;
1924 pParty->uFallSpeed += v82;
1925 v74 = v44->pFacePlane_old.vNormal.z;
1926 v51 = v44->pFacePlane_old.vNormal.y;
1927 v69 = v44->pFacePlane_old.vNormal.x;
1928 v80 = v51;
1929 v1 += v81;
1930 v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
1931 if ( v52 > 0 )
1932 {
1933 new_party_x += v52 * v69 >> 16;
1934 new_party_y += v52 * v80 >> 16;
1935 v87 += v52 * v74 >> 16;
1936 }
1937 v43 = stru_721530.uFaceID;
1938 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
1939 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
1940 }
1941 else
1942 {
1943 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
1944 if ((stru_721530.speed >> 3) > v80 )
1945 v80 = stru_721530.speed >> 3;
1946 v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
1947 v81 = v44->pFacePlane_old.vNormal.y;
1948 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
1949 v82 = v44->pFacePlane_old.vNormal.z;
1950 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
1951 v2 += v49;
1952 v1 += v81;
1953 pParty->uFallSpeed += v82;
1954 if ( v2 * v2 + v1 * v1 >= 400 )
1955 {
1956 v43 = stru_721530.uFaceID;
1957 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
1958 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
1959 }
1960 else
1961 {
1962 v2 = 0;
1963 v1 = 0;
1964 pParty->uFallSpeed = 0;
1965 }
1966 }
1967 }
1968 }
1969 }
1970 v2 = (unsigned __int64)(58500i64 * v2) >> 16;
1971 v1 = (unsigned __int64)(58500i64 * v1) >> 16;
1972 ++v83;
1973 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
1974 if ( v83 >= 100 )
1975 {
1976 new_party_z = v87;
1977 break;
1978 }
1979 }
1980 if ( bWalkSound && !pParty->walk_sound_timer)
1981 {
1982 if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
1983 * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z)
1984 * (pParty->vPosition.z - new_party_z)) <= 16 )
1985 {
1986 pAudioPlayer->_4AA258(804);
1987 pParty->walk_sound_timer = 64;
1988 }
1989 else if ( v72 && (!bJumping || jumping_up) )
1990 {
1991 v66 = 0;
1992 v64 = 0;
1993 v62 = 0;
1994 v61 = 0;
1995 v60 = -1;
1996 v59 = 1;
1997 v58 = 804;
1998 if ( !on_water )
1999 {
2000 v56 = pAudioPlayer;
2001 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
2002 v57 = (SoundID)50;
2003 else
2004 v57 = (SoundID)64;
2005 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
2006 }
2007 else
2008 {
2009 v57 = (SoundID)63;
2010 v56 = pAudioPlayer;
2011 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
2012 }
2013 }
2014 else if ( v78 && (!bJumping || jumping_up) )
2015 {
2016 v66 = 0;
2017 v64 = 0;
2018 v62 = 0;
2019 v61 = 0;
2020 v60 = -1;
2021 v59 = 1;
2022 v58 = 804;
2023 if ( on_water )
2024 {
2025 v57 = (SoundID)102;
2026 v56 = pAudioPlayer;
2027 }
2028 else
2029 {
2030 v56 = pAudioPlayer;
2031 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
2032 v57 = (SoundID)89;
2033 else
2034 v57 = (SoundID)103;
2035 }
2036 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
2037 }
2038 else
2039 {
2040 pAudioPlayer->_4AA258(804);
2041 pParty->walk_sound_timer = 64;
2042 }
2043 }
2044 if ( !bJumping || jumping_up )
2045 pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
2046 else
2047 pParty->uFlags |= PARTY_FLAGS_1_FALLING;
2048 pParty->uFlags &= ~0x200;
2049 pParty->vPosition.x = new_party_x;
2050 pParty->vPosition.z = new_party_z;
2051 pParty->vPosition.y = new_party_y;
2052 //pParty->uFallSpeed = v89;
2053 if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 )
2054 pParty->uFlags |= 0x200;
2055 if (uFaceEvent)
2056 EventProcessor(uFaceEvent, 0, 1);
2057 }
2058
2059 //----- (0047531C) -------------------------------------------------------- 1154 //----- (0047531C) --------------------------------------------------------
2060 bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10) 1155 bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10)
2061 { 1156 {
2062 BLVFace *v10; // ebx@1
2063 int v11; // ST1C_4@3 1157 int v11; // ST1C_4@3
2064 int v12; // edi@3 1158 int v12; // edi@3
2065 int v13; // esi@3 1159 int v13; // esi@3
2066 int v14; // edi@4 1160 int v14; // edi@4
2067 signed __int64 v15; // qtt@6 1161 signed __int64 v15; // qtt@6
2068 __int16 v16; // si@7 1162 __int16 v16; // si@7
2069 int *v18; // [sp+Ch] [bp-Ch]@1
2070 int v19; // [sp+10h] [bp-8h]@1
2071 int a7a; // [sp+30h] [bp+18h]@7 1163 int a7a; // [sp+30h] [bp+18h]@7
2072 int a9b; // [sp+38h] [bp+20h]@3 1164 int a9b; // [sp+38h] [bp+20h]@3
2073 int a9a; // [sp+38h] [bp+20h]@3 1165 int a9a; // [sp+38h] [bp+20h]@3
2074 int a10b; // [sp+3Ch] [bp+24h]@3 1166 int a10b; // [sp+3Ch] [bp+24h]@3
2075 signed int a10a; // [sp+3Ch] [bp+24h]@4 1167 signed int a10a; // [sp+3Ch] [bp+24h]@4
2076 int a10c; // [sp+3Ch] [bp+24h]@5 1168 int a10c; // [sp+3Ch] [bp+24h]@5
2077 1169
2078 v10 = a9; 1170 if ( a10 && face->Ethereal() )
2079 v18 = a2;
2080 v19 = a1;
2081 if ( a10 && BYTE3(a9->uAttributes) & 0x20 )
2082 return 0; 1171 return 0;
2083 v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16; 1172 v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
2084 a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16; 1173 a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
2085 a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16; 1174 a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
2086 v12 = v11 + a9b + a10b; 1175 v12 = v11 + a9b + a10b;
2087 a9a = v11 + a9b + a10b; 1176 a9a = v11 + a9b + a10b;
2088 v13 = (a1 << 16) 1177 v13 = (a1 << 16)
2089 - a3 * v10->pFacePlane_old.vNormal.x 1178 - pos_x * face->pFacePlane_old.vNormal.x
2090 - a4 * v10->pFacePlane_old.vNormal.y 1179 - pos_y * face->pFacePlane_old.vNormal.y
2091 - a5 * v10->pFacePlane_old.vNormal.z 1180 - pos_z * face->pFacePlane_old.vNormal.z
2092 - v10->pFacePlane_old.dist; 1181 - face->pFacePlane_old.dist;
2093 if ( abs((a1 << 16) 1182 if ( abs((a1 << 16)
2094 - a3 * v10->pFacePlane_old.vNormal.x 1183 - pos_x * face->pFacePlane_old.vNormal.x
2095 - a4 * v10->pFacePlane_old.vNormal.y 1184 - pos_y * face->pFacePlane_old.vNormal.y
2096 - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 ) 1185 - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
2097 { 1186 {
2098 a10c = abs(v13) >> 14; 1187 a10c = abs(v13) >> 14;
2099 if ( a10c > abs(v12) ) 1188 if ( a10c > abs(v12) )
2100 return 0; 1189 return 0;
2101 LODWORD(v15) = v13 << 16; 1190 LODWORD(v15) = v13 << 16;
2102 HIDWORD(v15) = v13 >> 16; 1191 HIDWORD(v15) = v13 >> 16;
2103 v14 = v19; 1192 v14 = a1;
2104 a10a = v15 / a9a; 1193 a10a = v15 / a9a;
2105 } 1194 }
2106 else 1195 else
2107 { 1196 {
2108 a10a = 0; 1197 a10a = 0;
2109 v14 = abs(v13) >> 16; 1198 v14 = abs(v13) >> 16;
2110 } 1199 }
2111 v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16); 1200 v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16);
2112 LOWORD(a7a) = (short)a3 1201 LOWORD(a7a) = (short)pos_x
2113 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16) 1202 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16)
2114 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16); 1203 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16);
2115 HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16); 1204 HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16);
2116 if ( !sub_475665( 1205 if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16)
2117 v10, 1206 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) )
2118 a7a,
2119 (short)a5
2120 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16)
2121 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) )
2122 return 0; 1207 return 0;
2123 *v18 = a10a >> 16; 1208 *a2 = a10a >> 16;
2124 if ( a10a >> 16 < 0 ) 1209 if ( a10a >> 16 < 0 )
2125 *v18 = 0; 1210 *a2 = 0;
2126 return 1; 1211 return 1;
2127 } 1212 }
2128 1213
2129 //----- (004754BF) -------------------------------------------------------- 1214 //----- (004754BF) --------------------------------------------------------
2130 bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10, int a11) 1215 bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11)
2131 { 1216 {
2132 BLVFace *v11; // ebx@1
2133 int v12; // ST1C_4@3 1217 int v12; // ST1C_4@3
2134 int v13; // edi@3 1218 int v13; // edi@3
2135 int v14; // esi@3 1219 int v14; // esi@3
2136 int v15; // edi@4 1220 int v15; // edi@4
2137 signed __int64 v16; // qtt@6 1221 signed __int64 v16; // qtt@6
2138 __int16 v17; // si@7 1222 __int16 v17; // si@7
2139 int *v19; // [sp+Ch] [bp-Ch]@1
2140 int v20; // [sp+10h] [bp-8h]@1
2141 int a7a; // [sp+30h] [bp+18h]@7 1223 int a7a; // [sp+30h] [bp+18h]@7
2142 int a1b; // [sp+38h] [bp+20h]@3 1224 int a1b; // [sp+38h] [bp+20h]@3
2143 int a1a; // [sp+38h] [bp+20h]@3 1225 int a1a; // [sp+38h] [bp+20h]@3
2144 int a11b; // [sp+40h] [bp+28h]@3 1226 int a11b; // [sp+40h] [bp+28h]@3
2145 signed int a11a; // [sp+40h] [bp+28h]@4 1227 signed int a11a; // [sp+40h] [bp+28h]@4
2146 int a11c; // [sp+40h] [bp+28h]@5 1228 int a11c; // [sp+40h] [bp+28h]@5
2147 1229
2148 v11 = a9; 1230 if ( a11 && face->Ethereal() )
2149 v19 = a2; 1231 return false;
2150 v20 = a1; 1232 v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
2151 if ( a11 && BYTE3(a9->uAttributes) & 0x20 ) 1233 a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
2152 return 0; 1234 a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
2153 v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
2154 a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
2155 a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
2156 v13 = v12 + a1b + a11b; 1235 v13 = v12 + a1b + a11b;
2157 a1a = v12 + a1b + a11b; 1236 a1a = v12 + a1b + a11b;
2158 v14 = (a1 << 16) 1237 v14 = (a1 << 16)
2159 - a3 * v11->pFacePlane_old.vNormal.x 1238 - X * face->pFacePlane_old.vNormal.x
2160 - a4 * v11->pFacePlane_old.vNormal.y 1239 - Y * face->pFacePlane_old.vNormal.y
2161 - a5 * v11->pFacePlane_old.vNormal.z 1240 - Z * face->pFacePlane_old.vNormal.z
2162 - v11->pFacePlane_old.dist; 1241 - face->pFacePlane_old.dist;
2163 if ( abs((a1 << 16) 1242 if ( abs((a1 << 16)
2164 - a3 * v11->pFacePlane_old.vNormal.x 1243 - X * face->pFacePlane_old.vNormal.x
2165 - a4 * v11->pFacePlane_old.vNormal.y 1244 - Y * face->pFacePlane_old.vNormal.y
2166 - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 ) 1245 - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
2167 { 1246 {
2168 a11c = abs(v14) >> 14; 1247 a11c = abs(v14) >> 14;
2169 if ( a11c > abs(v13) ) 1248 if ( a11c > abs(v13) )
2170 return 0; 1249 return false;
2171 LODWORD(v16) = v14 << 16; 1250 LODWORD(v16) = v14 << 16;
2172 HIDWORD(v16) = v14 >> 16; 1251 HIDWORD(v16) = v14 >> 16;
2173 v15 = v20; 1252 v15 = a1;
2174 a11a = v16 / a1a; 1253 a11a = v16 / a1a;
2175 } 1254 }
2176 else 1255 else
2177 { 1256 {
2178 a11a = 0; 1257 a11a = 0;
2179 v15 = abs(v14) >> 16; 1258 v15 = abs(v14) >> 16;
2180 } 1259 }
2181 v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16); 1260 v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16);
2182 LOWORD(a7a) = (short)a3 1261 LOWORD(a7a) = (short)X
2183 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16) 1262 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16)
2184 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16); 1263 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16);
2185 HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16); 1264 HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16);
2186 if ( !sub_4759C9( 1265 if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16)
2187 v11, 1266 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) )
2188 a10, 1267 return false;
2189 a7a, 1268 *a2 = a11a >> 16;
2190 (short)a5
2191 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16)
2192 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) )
2193 return 0;
2194 *v19 = a11a >> 16;
2195 if ( a11a >> 16 < 0 ) 1269 if ( a11a >> 16 < 0 )
2196 *v19 = 0; 1270 *a2 = 0;
2197 return 1; 1271 return true;
2198 } 1272 }
2199 1273
2200 //----- (00475665) -------------------------------------------------------- 1274 //----- (00475665) --------------------------------------------------------
2201 int sub_475665(BLVFace *_this, int a2, __int16 a3) 1275 int sub_475665(BLVFace *_this, int a2, __int16 a3)
2202 { 1276 {
2344 } 1418 }
2345 1419
2346 //----- (004759C9) -------------------------------------------------------- 1420 //----- (004759C9) --------------------------------------------------------
2347 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4) 1421 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
2348 { 1422 {
2349 unsigned int v4; // eax@1 1423 //unsigned int v4; // eax@1
2350 int v5; // edx@4 1424 //int v5; // edx@4
2351 __int16 v6; // si@4 1425 __int16 v6; // si@4
2352 int v7; // edx@9 1426 //int v7; // edx@9
2353 __int16 v8; // si@9 1427 __int16 v8; // si@9
2354 int v9; // edx@13 1428 //int v9; // edx@13
2355 __int16 v10; // si@13 1429 __int16 v10; // si@13
2356 int v11; // esi@14 1430 int v11; // esi@14
2357 bool v12; // edi@14 1431 bool v12; // edi@14
2358 int v13; // ecx@16 1432 int v13; // ecx@16
2359 signed int v14; // edx@16 1433 signed int v14; // edx@16
2370 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3 1444 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
2371 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8 1445 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
2372 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12 1446 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
2373 signed int a4d; // [sp+30h] [bp+Ch]@14 1447 signed int a4d; // [sp+30h] [bp+Ch]@14
2374 1448
2375 v4 = a1->uAttributes; 1449 //v4 = a1->uAttributes;
2376 v22 = 0; 1450 v22 = 0;
2377 if ( BYTE1(v4) & 1 ) 1451 if ( BYTE1(a1->uAttributes) & 1 )
2378 { 1452 {
2379 v23 = (signed __int16)a3; 1453 v23 = (signed __int16)a3;
2380 v24 = SHIWORD(a3); 1454 v24 = SHIWORD(a3);
2381 if ( a1->uNumVertices ) 1455 if ( a1->uNumVertices )
2382 { 1456 {
2383 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices; 1457 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
2384 do 1458 do
2385 { 1459 {
2386 v5 = 2 * v22; 1460 //v5 = 2 * v22;
2387 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x); 1461 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x);
2388 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y); 1462 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y);
2389 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x); 1463 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x);
2390 word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y); 1464 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
2391 ++v22; 1465 ++v22;
2392 } 1466 }
2393 while ( v22 < a1->uNumVertices ); 1467 while ( v22 < a1->uNumVertices );
2394 } 1468 }
2395 } 1469 }
2396 else 1470 else
2397 { 1471 {
2398 if ( BYTE1(v4) & 2 ) 1472 if ( BYTE1(a1->uAttributes) & 2 )
2399 { 1473 {
2400 v23 = (signed __int16)a3; 1474 v23 = (signed __int16)a3;
2401 v24 = a4; 1475 v24 = a4;
2402 if ( a1->uNumVertices ) 1476 if ( a1->uNumVertices )
2403 { 1477 {
2404 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices; 1478 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
2405 do 1479 do
2406 { 1480 {
2407 v7 = 2 * v22; 1481 //v7 = 2 * v22;
2408 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x); 1482 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x);
2409 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z); 1483 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z);
2410 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x); 1484 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x);
2411 word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z); 1485 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
2412 ++v22; 1486 ++v22;
2413 } 1487 }
2414 while ( v22 < a1->uNumVertices ); 1488 while ( v22 < a1->uNumVertices );
2415 } 1489 }
2416 } 1490 }
2421 if ( a1->uNumVertices ) 1495 if ( a1->uNumVertices )
2422 { 1496 {
2423 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices; 1497 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
2424 do 1498 do
2425 { 1499 {
2426 v9 = 2 * v22; 1500 //v9 = 2 * v22;
2427 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y); 1501 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y);
2428 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z); 1502 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z);
2429 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y); 1503 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y);
2430 word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z); 1504 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
2431 ++v22; 1505 ++v22;
2432 } 1506 }
2433 while ( v22 < a1->uNumVertices ); 1507 while ( v22 < a1->uNumVertices );
2434 } 1508 }
2435 } 1509 }
2541 } 1615 }
2542 1616
2543 //----- (00475F30) -------------------------------------------------------- 1617 //----- (00475F30) --------------------------------------------------------
2544 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) 1618 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
2545 { 1619 {
2546 BLVFace *v9; // ebx@1 1620 //BLVFace *v9; // ebx@1
2547 int v10; // ST20_4@2 1621 int v10; // ST20_4@2
2548 int v11; // ST28_4@2 1622 int v11; // ST28_4@2
2549 int v12; // ST24_4@2 1623 int v12; // ST24_4@2
2550 char v13; // zf@2 1624 char v13; // zf@2
2551 int v14; // edi@2 1625 int v14; // edi@2
2552 int v15; // eax@5 1626 int v15; // eax@5
2553 signed int v16; // esi@5 1627 signed int v16; // esi@5
2554 int v17; // ST20_4@9 1628 int v17; // ST20_4@9
2555 signed __int64 v18; // qtt@10 1629 signed __int64 v18; // qtt@10
2556 int v19; // ST14_4@11 1630 int v19; // ST14_4@11
2557 int *v21; // [sp+14h] [bp-10h]@1 1631 //int *v21; // [sp+14h] [bp-10h]@1
2558 int v22; // [sp+1Ch] [bp-8h]@2 1632 int v22; // [sp+1Ch] [bp-8h]@2
2559 int v23; // [sp+1Ch] [bp-8h]@10 1633 int v23; // [sp+1Ch] [bp-8h]@10
2560 signed int v24; // [sp+20h] [bp-4h]@10 1634 signed int v24; // [sp+20h] [bp-4h]@10
2561 1635
2562 v9 = a2; 1636 //v9 = a2;
2563 v21 = a1; 1637 //v21 = a1;
2564 if ( BYTE3(a2->uAttributes) & 0x20 1638 if ( a2->Ethereal()
2565 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, 1639 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
2566 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, 1640 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
2567 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, 1641 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
2568 v13 = v10 + v12 + v11 == 0, 1642 v13 = v10 + v12 + v11 == 0,
2569 v14 = v10 + v12 + v11, 1643 v14 = v10 + v12 + v11,
2583 if ( v16 < 0 ) 1657 if ( v16 < 0 )
2584 return 0; 1658 return 0;
2585 } 1659 }
2586 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; 1660 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
2587 if ( v17 > abs(v14) 1661 if ( v17 > abs(v14)
2588 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16) 1662 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16)
2589 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), 1663 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
2590 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), 1664 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
2591 !sub_4759C9( 1665 !sub_4759C9(a2, a9, v19,
2592 v9,
2593 a9,
2594 v19,
2595 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) ) 1666 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) )
2596 return 0; 1667 return 0;
2597 *v21 = v24 >> 16; 1668 *a1 = v24 >> 16;
2598 return 1; 1669 return 1;
2599 } 1670 }
2600 1671
2601 //----- (004760D5) -------------------------------------------------------- 1672 //----- (004760D5) --------------------------------------------------------
2602 PartyAction ActionQueue::Next() 1673 PartyAction ActionQueue::Next()
5723 _5B65AC_npcdata_fame_or_other = 0; 4794 _5B65AC_npcdata_fame_or_other = 0;
5724 _5B65A8_npcdata_uflags_or_other = 0; 4795 _5B65A8_npcdata_uflags_or_other = 0;
5725 } 4796 }
5726 } 4797 }
5727 4798
5728
5729
5730 //----- (00449A49) -------------------------------------------------------- 4799 //----- (00449A49) --------------------------------------------------------
5731 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2) 4800 void Door_switch_animation(unsigned int uDoorID, int a2)
5732 { 4801 {
5733 int v2; // eax@1 4802 int old_state; // eax@1
5734 int v3; // ebx@1 4803 signed int door_id; // esi@2
5735 signed int v4; // esi@2 4804
5736 int v5; // edx@2
5737 BLVDoor *v6; // ecx@8
5738 unsigned int v7; // edx@18
5739 signed int v8; // esi@19
5740 int v9; // eax@19
5741 //char Args; // [sp+Ch] [bp-78h]@6
5742
5743 LOWORD(v2) = LOWORD(pIndoor->pDoors);
5744 v3 = a2;
5745 if ( !pIndoor->pDoors ) 4805 if ( !pIndoor->pDoors )
5746 return v2; 4806 return;
5747 v4 = 0; 4807 for ( door_id = 0; door_id < 200; ++door_id )
5748 v5 = (int)&pIndoor->pDoors->uDoorID; 4808 {
5749 do 4809 if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
5750 {
5751 if ( *(int *)v5 == uDoorID )
5752 break; 4810 break;
5753 ++v4; 4811 }
5754 v5 += 80; 4812 if ( door_id >= 200 )
5755 }
5756 while ( v4 < 200 );
5757 if ( v4 >= 200 )
5758 { 4813 {
5759 Error("Unable to find Door ID: %i!", uDoorID); 4814 Error("Unable to find Door ID: %i!", uDoorID);
5760 } 4815 }
5761 v6 = &pIndoor->pDoors[v4]; 4816 old_state = pIndoor->pDoors[door_id].uState;
5762 if ( v3 == 2 ) 4817 //old_state: 0 - в нижнем положении/закрыто
5763 { 4818 // 2 - в верхнем положении/открыто,
5764 LOWORD(v2) = v6->uState; 4819 //a2: 1 - открыть
5765 if ( (short)v2 == 3 || (short)v2 == 1 ) 4820 // 2 - опустить/поднять
5766 return v2; 4821 if ( a2 == 2 )
5767 if ( (short)v2 ) 4822 {
5768 goto LABEL_14; 4823 if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening )
4824 return;
4825 if ( pIndoor->pDoors[door_id].uState )
4826 {
4827 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
4828 {
4829 pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
4830 if ( old_state == BLVDoor::Open )
4831 {
4832 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
4833 return;
4834 }
4835 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
4836 {
4837 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
4838 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
4839 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
4840 return;
4841 }
4842 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
4843 }
4844 return;
4845 }
5769 } 4846 }
5770 else 4847 else
5771 { 4848 {
5772 if ( !v3 ) 4849 if ( a2 == 0 )
5773 { 4850 {
5774 LABEL_14: 4851 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
5775 LOWORD(v2) = v6->uState; 4852 {
5776 if ( (short)v2 && (short)v2 != 3 ) 4853 pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
5777 { 4854 if ( old_state == BLVDoor::Open )
5778 v6->uState = BLVDoor::Closing;
5779 if ( (short)v2 == 2 )
5780 { 4855 {
5781 LABEL_17: 4856 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
5782 v6->uTimeSinceTriggered = 0; 4857 return;
5783 return v2;
5784 } 4858 }
5785 v7 = v6->uTimeSinceTriggered; 4859 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
5786 v2 = 15360;
5787 if ( v7 != 15360 )
5788 { 4860 {
5789 v8 = v6->uOpenSpeed; 4861 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
5790 v9 = v6->uCloseSpeed; 4862 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
5791 LABEL_26: 4863 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
5792 v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8; 4864 return;
5793 goto LABEL_27;
5794 } 4865 }
5795 goto LABEL_27; 4866 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
5796 } 4867 }
5797 return v2; 4868 return;
5798 } 4869 }
5799 if ( v3 != 1 ) 4870 if ( a2 != 1 )
5800 return v2; 4871 return;
5801 } 4872 }
5802 LOWORD(v2) = v6->uState; 4873 if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
5803 if ( (short)v2 != 2 && (short)v2 != 1 ) 4874 {
5804 { 4875 pIndoor->pDoors[door_id].uState = BLVDoor::Opening;
5805 v6->uState = BLVDoor::Opening; 4876 if ( old_state == BLVDoor::Closed )
5806 if ( !(short)v2 ) 4877 {
5807 goto LABEL_17; 4878 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
5808 v7 = v6->uTimeSinceTriggered; 4879 return;
5809 v2 = 15360; 4880 }
5810 if ( v7 != 15360 ) 4881 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
5811 { 4882 {
5812 v8 = v6->uCloseSpeed; 4883 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed
5813 v9 = v6->uOpenSpeed; 4884 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed)
5814 goto LABEL_26; 4885 / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed;
5815 } 4886 return;
5816 LABEL_27: 4887 }
5817 v6->uTimeSinceTriggered = v2; 4888 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
5818 } 4889 }
5819 return v2; 4890 return;
5820 } 4891 }
5821 4892
5822 //----- (00449B57) -------------------------------------------------------- 4893 //----- (00449B57) --------------------------------------------------------
5823 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 ) 4894 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
5824 { 4895 {
5843 void ShowStatusBarString( const char *pString, unsigned int uNumSeconds ) 4914 void ShowStatusBarString( const char *pString, unsigned int uNumSeconds )
5844 { 4915 {
5845 strcpy(GameUI_Footer_TimedString.data(), pString); 4916 strcpy(GameUI_Footer_TimedString.data(), pString);
5846 GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount(); 4917 GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount();
5847 4918
5848 for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); 4919 for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450;
5849 i > 450; 4920 i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
5850 i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
5851 GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; 4921 GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0;
5852 } 4922 }
5853 4923
5854 //----- (0044C1D0) -------------------------------------------------------- 4924 //----- (0044C1D0) --------------------------------------------------------
5855 void ShowNothingHereStatus() 4925 void ShowNothingHereStatus()
5886 4956
5887 //----- (00401000) -------------------------------------------------------- 4957 //----- (00401000) --------------------------------------------------------
5888 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int)) 4958 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int))
5889 { 4959 {
5890 void *v4; // esi@2 4960 void *v4; // esi@2
5891 int v5; // edi@2 4961
5892 4962 if ( numObjs > 0 )
5893 if ( numObjs - 1 >= 0 )
5894 { 4963 {
5895 v4 = a1; 4964 v4 = a1;
5896 v5 = numObjs; 4965 for ( int i = numObjs; i; --i )
5897 do
5898 { 4966 {
5899 constructor((int)v4); 4967 constructor((int)v4);
5900 v4 = (char *)v4 + objSize; 4968 v4 = (char *)v4 + objSize;
5901 --v5; 4969 }
5902 }
5903 while ( v5 );
5904 } 4970 }
5905 } 4971 }
5906 4972
5907 //----- (0040261D) -------------------------------------------------------- 4973 //----- (0040261D) --------------------------------------------------------
5908 void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8) 4974 void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8)