Mercurial > mm7
annotate mm7_3.cpp @ 1424:5930342f092b
fall to the water
author | Ritor1 |
---|---|
date | Tue, 30 Jul 2013 15:14:46 +0600 |
parents | 483b1b453986 |
children | 1987f2cca08f |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4 |
119 | 5 #include <assert.h> |
6 | |
1323 | 7 #include "Weather.h" |
1262 | 8 #include "Texture.h" |
9 #include "mm7_data.h" | |
1016 | 10 #include "Sprites.h" |
11 #include "BSPModel.h" | |
12 #include "OutdoorCamera.h" | |
13 #include "LightmapBuilder.h" | |
14 #include "DecalBuilder.h" | |
15 #include "ParticleEngine.h" | |
16 #include "Mouse.h" | |
17 #include "Keyboard.h" | |
18 #include "stru6.h" | |
1263 | 19 #include "FactionTable.h" |
0 | 20 #include "MapInfo.h" |
21 #include "Game.h" | |
22 #include "GUIWindow.h" | |
23 #include "GUIFont.h" | |
24 #include "GUIProgressBar.h" | |
25 #include "Party.h" | |
26 #include "AudioPlayer.h" | |
27 #include "Outdoor.h" | |
1277 | 28 #include "Outdoor_stuff.h" |
0 | 29 #include "IndoorCamera.h" |
30 #include "Overlays.h" | |
31 #include "LOD.h" | |
32 #include "Actor.h" | |
33 #include "Allocator.h" | |
34 #include "Events.h" | |
35 #include "Viewport.h" | |
36 #include "Math.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
37 #include "SpriteObject.h" |
0 | 38 #include "ObjectList.h" |
39 #include "PaletteManager.h" | |
40 #include "DecorationList.h" | |
41 #include "stru123.h" | |
42 #include "Time.h" | |
43 #include "IconFrameTable.h" | |
44 #include "TurnEngine.h" | |
45 #include "Events2D.h" | |
46 #include "stru176.h" | |
47 #include "stru298.h" | |
189 | 48 #include "texts.h" |
0 | 49 #include "Log.h" |
1262 | 50 #include "Lights.h" |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
51 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
52 #include "MM7.h" |
0 | 53 |
54 //----- (0046E44E) -------------------------------------------------------- | |
55 int __thiscall _46E44E_collide_against_faces_and_portals(unsigned int b1) | |
56 { | |
717 | 57 BLVSector *pSector; // edi@1 |
0 | 58 signed int v2; // ebx@1 |
717 | 59 BLVFace *pFace; // esi@2 |
60 __int16 pNextSector; // si@10 | |
61 int pArrayNum; // ecx@12 | |
0 | 62 unsigned __int8 v6; // sf@12 |
63 unsigned __int8 v7; // of@12 | |
64 int result; // eax@14 | |
717 | 65 //BLVSector *v9; // ebx@15 |
0 | 66 int v10; // ecx@15 |
717 | 67 int pFloor; // eax@16 |
68 //BLVFace *v12; // ebp@16 | |
0 | 69 int v13; // eax@24 |
70 int v14; // esi@24 | |
71 int v15; // eax@24 | |
72 int v16; // edx@25 | |
73 int v17; // eax@29 | |
74 unsigned int v18; // eax@33 | |
75 int v19; // eax@35 | |
76 int v20; // edx@35 | |
77 int v21; // eax@35 | |
78 int v22; // ecx@36 | |
79 int v23; // eax@40 | |
80 unsigned int v24; // eax@44 | |
81 int a3; // [sp+10h] [bp-48h]@28 | |
82 int v26; // [sp+14h] [bp-44h]@15 | |
83 int i; // [sp+18h] [bp-40h]@1 | |
84 int a10; // [sp+1Ch] [bp-3Ch]@1 | |
85 int v29; // [sp+20h] [bp-38h]@14 | |
86 int v30; // [sp+24h] [bp-34h]@35 | |
87 int v31; // [sp+28h] [bp-30h]@24 | |
88 int v32; // [sp+2Ch] [bp-2Ch]@15 | |
717 | 89 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1 |
90 | |
91 pSector = &pIndoor->pSectors[stru_721530.uSectorID]; | |
0 | 92 v2 = 0; |
93 a10 = b1; | |
717 | 94 pSectorsArray[0] = stru_721530.uSectorID; |
95 for ( i = 1; v2 < pSector->uNumPortals; ++v2 ) | |
96 { | |
97 pFace = &pIndoor->pFaces[pSector->pPortals[v2]]; | |
98 if ( stru_721530.sMaxX <= pFace->pBounding.x2 | |
99 && stru_721530.sMinX >= pFace->pBounding.x1 | |
100 && stru_721530.sMaxY <= pFace->pBounding.y2 | |
101 && stru_721530.sMinY >= pFace->pBounding.y1 | |
102 && stru_721530.sMaxZ <= pFace->pBounding.z2 | |
103 && stru_721530.sMinZ >= pFace->pBounding.z1 | |
104 && abs((pFace->pFacePlane_old.dist | |
105 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x | |
106 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y | |
107 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 ) | |
108 { | |
109 pNextSector = pFace->uSectorID == stru_721530.uSectorID ? pFace->uBackSectorID : pFace->uSectorID;//FrontSectorID | |
110 pArrayNum = i++; | |
111 v7 = i < 10; | |
0 | 112 v6 = i - 10 < 0; |
717 | 113 pSectorsArray[pArrayNum] = pNextSector; |
0 | 114 if ( !(v6 ^ v7) ) |
115 break; | |
116 } | |
117 } | |
118 result = 0; | |
119 v29 = 0; | |
120 if ( i > 0 ) | |
121 { | |
122 while ( 1 ) | |
123 { | |
717 | 124 pSector = &pIndoor->pSectors[pSectorsArray[result]]; |
0 | 125 v10 = 0; |
717 | 126 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; |
0 | 127 v26 = 0; |
128 if ( v32 > 0 ) | |
129 break; | |
130 LABEL_46: | |
131 result = v29++ + 1; | |
132 if ( v29 >= i ) | |
133 return result; | |
134 } | |
135 while ( 1 ) | |
136 { | |
717 | 137 pFloor = pSector->pFloors[v10]; |
138 pFace = &pIndoor->pFaces[pFloor]; | |
139 if ( pFace->Portal() | |
140 || stru_721530.sMaxX > pFace->pBounding.x2 | |
141 || stru_721530.sMinX < pFace->pBounding.x1 | |
142 || stru_721530.sMaxY > pFace->pBounding.y2 | |
143 || stru_721530.sMinY < pFace->pBounding.y1 | |
144 || stru_721530.sMaxZ > pFace->pBounding.z2 | |
145 || stru_721530.sMinZ < pFace->pBounding.z1 | |
146 || pFloor == stru_721530.field_84 ) | |
0 | 147 goto LABEL_45; |
717 | 148 v13 = pFace->pFacePlane_old.vNormal.y; |
149 v14 = pFace->pFacePlane_old.dist; | |
0 | 150 v31 = v13; |
717 | 151 v15 = (stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + v14 + stru_721530.normal.y * v13 |
152 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16; | |
0 | 153 if ( v15 > 0 ) |
154 { | |
717 | 155 v16 = (stru_721530.normal2.y * v31 + pFace->pFacePlane_old.dist + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z |
156 + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x) >> 16; | |
0 | 157 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) |
158 { | |
159 if ( v16 <= v15 ) | |
160 { | |
161 a3 = stru_721530.field_6C; | |
717 | 162 if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, |
163 stru_721530.field_58.x, stru_721530.field_58.y, stru_721530.field_58.z, pFace, a10) ) | |
0 | 164 { |
165 v17 = a3; | |
166 } | |
167 else | |
168 { | |
169 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d; | |
717 | 170 if ( !sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, pFace) ) |
0 | 171 goto LABEL_34; |
172 v17 = a3 - stru_721530.prolly_normal_d; | |
173 a3 -= stru_721530.prolly_normal_d; | |
174 } | |
175 if ( v17 < stru_721530.field_7C ) | |
176 { | |
177 stru_721530.field_7C = v17; | |
717 | 178 v18 = 8 * pSector->pFloors[v26]; |
0 | 179 LOBYTE(v18) = v18 | 6; |
180 stru_721530.uFaceID = v18; | |
181 } | |
182 } | |
183 } | |
184 } | |
185 LABEL_34: | |
186 if ( !(stru_721530.field_0 & 1) | |
717 | 187 || (v19 = pFace->pFacePlane_old.vNormal.x, |
188 v20 = pFace->pFacePlane_old.vNormal.y, | |
0 | 189 v30 = v19, |
717 | 190 v21 = (stru_721530.field_34.x * v19 + pFace->pFacePlane_old.dist + stru_721530.field_34.y * v20 |
191 + stru_721530.field_34.z * pFace->pFacePlane_old.vNormal.z) >> 16, | |
0 | 192 v21 <= 0) |
717 | 193 || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20 |
194 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, | |
0 | 195 v21 > stru_721530.prolly_normal_d) |
196 && v22 > stru_721530.prolly_normal_d | |
197 || v22 > v21 ) | |
198 goto LABEL_45; | |
199 a3 = stru_721530.field_6C; | |
717 | 200 if ( sub_47531C(stru_721530.field_8, &a3, stru_721530.field_34.x, stru_721530.field_34.y, stru_721530.field_34.z, |
201 stru_721530.field_58.x, stru_721530.field_58.y, stru_721530.field_58.z, pFace, a10) ) | |
0 | 202 { |
203 v23 = a3; | |
204 goto LABEL_43; | |
205 } | |
206 a3 = stru_721530.field_6C + stru_721530.field_8; | |
717 | 207 if ( sub_475D85(&stru_721530.field_34, &stru_721530.field_58, &a3, pFace) ) |
0 | 208 { |
209 v23 = a3 - stru_721530.prolly_normal_d; | |
210 a3 -= stru_721530.prolly_normal_d; | |
211 LABEL_43: | |
212 if ( v23 < stru_721530.field_7C ) | |
213 { | |
214 stru_721530.field_7C = v23; | |
717 | 215 v24 = 8 * pSector->pFloors[v26]; |
0 | 216 LOBYTE(v24) = v24 | 6; |
217 stru_721530.uFaceID = v24; | |
218 } | |
219 } | |
220 LABEL_45: | |
221 v10 = v26++ + 1; | |
222 if ( v26 >= v32 ) | |
223 goto LABEL_46; | |
224 } | |
225 } | |
226 return result; | |
227 } | |
228 // 46E44E: using guessed type int var_28[10]; | |
229 | |
230 //----- (0046E889) -------------------------------------------------------- | |
231 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0) | |
232 { | |
233 int result; // eax@1 | |
234 BSPModel *v2; // ecx@3 | |
235 int v3; // ebx@9 | |
236 ODMFace *v4; // eax@11 | |
237 int v5; // edi@17 | |
238 int v6; // esi@17 | |
239 unsigned int v7; // ecx@17 | |
240 int v8; // eax@19 | |
241 int v9; // ecx@20 | |
242 int v10; // eax@24 | |
243 int v11; // ST18_4@25 | |
244 int v12; // ST1C_4@25 | |
245 int v13; // ST0C_4@25 | |
246 unsigned int v14; // eax@28 | |
247 int v15; // eax@30 | |
248 int v16; // ecx@31 | |
249 unsigned int v17; // eax@36 | |
250 int v18; // ST18_4@41 | |
251 int v19; // ST1C_4@41 | |
252 int v20; // ST0C_4@41 | |
253 int v21; // eax@42 | |
254 unsigned int v22; // eax@43 | |
255 //BLVFace f; // [sp+Ch] [bp-7Ch]@1 | |
256 int v24; // [sp+6Ch] [bp-1Ch]@9 | |
257 int a11; // [sp+70h] [bp-18h]@1 | |
258 unsigned int v26; // [sp+74h] [bp-14h]@2 | |
259 unsigned int v27; // [sp+78h] [bp-10h]@10 | |
260 BSPModel *v28; // [sp+7Ch] [bp-Ch]@3 | |
261 int a10; // [sp+80h] [bp-8h]@1 | |
262 int a2; // [sp+84h] [bp-4h]@23 | |
263 | |
264 a11 = ecx0; | |
265 | |
266 BLVFace f; // [sp+Ch] [bp-7Ch]@1 | |
267 //BLVFace::BLVFace(&f); | |
268 | |
269 result = 0; | |
270 a10 = 0; | |
271 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
272 { | |
273 v26 = 0; | |
274 while ( 1 ) | |
275 { | |
276 v2 = &pOutdoor->pBModels[v26 / 0xBC]; | |
277 v28 = &pOutdoor->pBModels[v26 / 0xBC]; | |
278 if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX ) | |
279 { | |
280 if ( stru_721530.sMinX >= v2->sMinX ) | |
281 { | |
282 if ( stru_721530.sMaxY <= v2->sMaxY ) | |
283 { | |
284 if ( stru_721530.sMinY >= v2->sMinY ) | |
285 { | |
286 if ( stru_721530.sMaxZ <= v2->sMaxZ ) | |
287 { | |
288 if ( stru_721530.sMinZ >= v2->sMinZ ) | |
289 { | |
290 v3 = 0; | |
291 v24 = v2->uNumFaces; | |
292 if ( v24 > 0 ) | |
293 break; | |
294 } | |
295 } | |
296 } | |
297 } | |
298 } | |
299 } | |
300 LABEL_39: | |
301 ++a10; | |
302 v26 += 188; | |
303 result = a10; | |
304 if ( a10 >= (signed int)pOutdoor->uNumBModels ) | |
305 return result; | |
306 } | |
307 v27 = 0; | |
308 while ( 1 ) | |
309 { | |
310 v4 = &v2->pFaces[v27 / 0x134]; | |
311 if ( stru_721530.sMaxX > v4->pBoundingBox.x2 | |
312 || stru_721530.sMinX < v4->pBoundingBox.x1 | |
313 || stru_721530.sMaxY > v4->pBoundingBox.y2 | |
314 || stru_721530.sMinY < v4->pBoundingBox.y1 | |
315 || stru_721530.sMaxZ > v4->pBoundingBox.z2 | |
316 || stru_721530.sMinZ < v4->pBoundingBox.z1 ) | |
317 goto LABEL_38; | |
318 f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x; | |
319 f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y; | |
320 v5 = v4->pFacePlane.vNormal.z; | |
321 f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z; | |
322 v6 = v4->pFacePlane.dist; | |
323 f.pFacePlane_old.dist = v4->pFacePlane.dist; | |
324 v7 = v4->uAttributes; | |
325 f.uAttributes = v7; | |
326 f.pBounding.x1 = v4->pBoundingBox.x1; | |
327 f.pBounding.y1 = v4->pBoundingBox.y1; | |
328 f.pBounding.z1 = v4->pBoundingBox.z1; | |
329 f.pBounding.x2 = v4->pBoundingBox.x2; | |
330 f.pBounding.y2 = v4->pBoundingBox.y2; | |
331 f.pBounding.z2 = v4->pBoundingBox.z2; | |
332 f.zCalc1 = v4->zCalc1; | |
333 f.zCalc2 = v4->zCalc2; | |
334 f.zCalc3 = v4->zCalc3; | |
335 f.pXInterceptDisplacements = v4->pXInterceptDisplacements; | |
336 f.pYInterceptDisplacements = v4->pYInterceptDisplacements; | |
337 f.pZInterceptDisplacements = v4->pZInterceptDisplacements; | |
338 f.uPolygonType = (PolygonType)v4->uPolygonType; | |
339 f.uNumVertices = v4->uNumVertices; | |
340 f.uBitmapID = v4->uTextureID; | |
341 f.pVertexIDs = v4->pVertexIDs; | |
342 if ( !(v7 & 0x20000000) ) | |
343 { | |
344 if ( !(v7 & 1) ) | |
345 break; | |
346 } | |
347 LABEL_37: | |
348 v2 = v28; | |
349 LABEL_38: | |
350 v27 += 308; | |
351 ++v3; | |
352 if ( v3 >= v24 ) | |
353 goto LABEL_39; | |
354 } | |
355 v8 = (v5 * stru_721530.normal.z | |
356 + v6 | |
357 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y | |
358 + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16; | |
359 if ( v8 > 0 ) | |
360 { | |
361 v9 = (v5 * stru_721530.normal2.z | |
362 + v6 | |
363 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y | |
364 + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16; | |
365 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d ) | |
366 { | |
367 if ( v9 <= v8 ) | |
368 { | |
369 a2 = stru_721530.field_6C; | |
370 if ( sub_4754BF( | |
371 stru_721530.prolly_normal_d, | |
372 &a2, | |
373 stru_721530.normal.x, | |
374 stru_721530.normal.y, | |
375 stru_721530.normal.z, | |
376 stru_721530.field_58.x, | |
377 stru_721530.field_58.y, | |
378 stru_721530.field_58.z, | |
379 &f, | |
380 a10, | |
381 a11) ) | |
382 { | |
383 v10 = a2; | |
384 } | |
385 else | |
386 { | |
387 v11 = stru_721530.field_58.y; | |
388 v12 = stru_721530.field_58.z; | |
389 v13 = stru_721530.normal.y; | |
390 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; | |
391 if ( !sub_475F30( | |
392 &a2, | |
393 &f, | |
394 stru_721530.normal.x, | |
395 v13, | |
396 stru_721530.normal.z, | |
397 stru_721530.field_58.x, | |
398 v11, | |
399 v12, | |
400 a10) ) | |
401 goto LABEL_29; | |
402 v10 = a2 - stru_721530.prolly_normal_d; | |
403 a2 -= stru_721530.prolly_normal_d; | |
404 } | |
405 if ( v10 < stru_721530.field_7C ) | |
406 { | |
407 stru_721530.field_7C = v10; | |
408 v14 = 8 * (v3 | (a10 << 6)); | |
409 LOBYTE(v14) = v14 | 6; | |
410 stru_721530.uFaceID = v14; | |
411 } | |
412 } | |
413 } | |
414 } | |
415 LABEL_29: | |
416 if ( stru_721530.field_0 & 1 ) | |
417 { | |
418 v15 = (f.pFacePlane_old.vNormal.z * stru_721530.field_34.z | |
419 + f.pFacePlane_old.dist | |
420 + f.pFacePlane_old.vNormal.y * stru_721530.field_34.y | |
421 + f.pFacePlane_old.vNormal.x * stru_721530.field_34.x) >> 16; | |
422 if ( v15 > 0 ) | |
423 { | |
424 v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54 | |
425 + f.pFacePlane_old.dist | |
426 + f.pFacePlane_old.vNormal.y * stru_721530.field_50 | |
427 + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16; | |
428 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) | |
429 { | |
430 if ( v16 <= v15 ) | |
431 { | |
432 a2 = stru_721530.field_6C; | |
433 if ( sub_4754BF( | |
434 stru_721530.field_8, | |
435 &a2, | |
436 stru_721530.field_34.x, | |
437 stru_721530.field_34.y, | |
438 stru_721530.field_34.z, | |
439 stru_721530.field_58.x, | |
440 stru_721530.field_58.y, | |
441 stru_721530.field_58.z, | |
442 &f, | |
443 a10, | |
444 a11) ) | |
445 { | |
446 if ( a2 < stru_721530.field_7C ) | |
447 { | |
448 stru_721530.field_7C = a2; | |
449 v17 = 8 * (v3 | (a10 << 6)); | |
450 LOBYTE(v17) = v17 | 6; | |
451 stru_721530.uFaceID = v17; | |
452 } | |
453 } | |
454 else | |
455 { | |
456 v18 = stru_721530.field_58.y; | |
457 v19 = stru_721530.field_58.z; | |
458 v20 = stru_721530.field_34.y; | |
459 a2 = stru_721530.field_6C + stru_721530.field_8; | |
460 if ( sub_475F30( | |
461 &a2, | |
462 &f, | |
463 stru_721530.field_34.x, | |
464 v20, | |
465 stru_721530.field_34.z, | |
466 stru_721530.field_58.x, | |
467 v18, | |
468 v19, | |
469 a10) ) | |
470 { | |
471 v2 = v28; | |
472 v21 = a2 - stru_721530.prolly_normal_d; | |
473 a2 -= stru_721530.prolly_normal_d; | |
474 if ( a2 < stru_721530.field_7C ) | |
475 { | |
476 stru_721530.field_7C = v21; | |
477 v22 = 8 * (v3 | (a10 << 6)); | |
478 LOBYTE(v22) = v22 | 6; | |
479 stru_721530.uFaceID = v22; | |
480 } | |
481 goto LABEL_38; | |
482 } | |
483 } | |
484 } | |
485 } | |
486 } | |
487 } | |
488 goto LABEL_37; | |
489 } | |
490 return result; | |
491 } | |
492 | |
493 //----- (0046ED1B) -------------------------------------------------------- | |
783 | 494 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) |
0 | 495 { |
496 uint uFaceID = -1; | |
723 | 497 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID); |
0 | 498 |
499 if (floor_level != -30000 && floor_level <= z + 50) | |
500 { | |
501 *pFaceID = uFaceID; | |
502 return floor_level; | |
503 } | |
504 | |
505 uint uSectorID = pIndoor->GetSector(x, y, z); | |
506 *pSectorID = uSectorID; | |
507 | |
723 | 508 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID); |
0 | 509 if (uSectorID && floor_level != -30000) |
510 *pFaceID = uFaceID; | |
511 else return -30000; | |
512 return floor_level; | |
513 } | |
514 | |
515 //----- (0046ED8A) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
516 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this) |
0 | 517 { |
518 int v1; // ebx@2 | |
519 ObjectDesc *v2; // edx@4 | |
520 int v3; // esi@5 | |
521 int v4; // ecx@5 | |
522 int v5; // eax@7 | |
523 int v6; // edi@9 | |
524 int v7; // edx@9 | |
525 int v8; // edi@11 | |
526 int v9; // ebx@11 | |
527 int v10; // ecx@12 | |
528 int v11; // esi@13 | |
529 signed int v12; // [sp+0h] [bp-14h]@1 | |
530 int v13; // [sp+4h] [bp-10h]@9 | |
531 char *v14; // [sp+8h] [bp-Ch]@2 | |
532 unsigned int v15; // [sp+10h] [bp-4h]@1 | |
533 | |
534 v15 = 0; | |
535 v12 = _this; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
536 if ( (signed int)uNumSpriteObjects > 0 ) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
537 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
538 v1 = (int)&pSpriteObjects[0].uObjectDescID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
539 v14 = (char *)&pSpriteObjects[0].uObjectDescID; |
0 | 540 do |
541 { | |
542 if ( *(short *)v1 ) | |
543 { | |
544 v2 = &pObjectList->pObjects[*(short *)v1]; | |
545 if ( !(v2->uFlags & 2) ) | |
546 { | |
547 v3 = v2->uRadius; | |
548 v4 = *(int *)(v1 + 2); | |
549 if ( stru_721530.sMaxX <= v4 + v3 ) | |
550 { | |
551 if ( stru_721530.sMinX >= v4 - v3 ) | |
552 { | |
553 v5 = *(int *)(v1 + 6); | |
554 if ( stru_721530.sMaxY <= v5 + v3 ) | |
555 { | |
556 if ( stru_721530.sMinY >= v5 - v3 ) | |
557 { | |
558 v6 = v2->uHeight; | |
559 v7 = *(int *)(v1 + 10); | |
560 v13 = v6; | |
561 if ( stru_721530.sMaxZ <= v7 + v6 ) | |
562 { | |
563 if ( stru_721530.sMinZ >= v7 ) | |
564 { | |
565 v8 = v4 - stru_721530.normal.x; | |
566 v9 = v5 - stru_721530.normal.y; | |
567 if ( abs(((v4 - stru_721530.normal.x) * stru_721530.field_58.y | |
568 - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16) <= v3 | |
569 + stru_721530.prolly_normal_d ) | |
570 { | |
571 v10 = (v8 * stru_721530.field_58.x + v9 * stru_721530.field_58.y) >> 16; | |
572 if ( v10 > 0 ) | |
573 { | |
574 v11 = stru_721530.normal.z | |
575 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v10) >> 16); | |
576 if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d ) | |
577 { | |
578 if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) ) | |
579 { | |
580 if ( v10 < stru_721530.field_7C ) | |
581 sub_46DEF2(v12, v15); | |
582 } | |
583 } | |
584 } | |
585 } | |
586 } | |
587 } | |
588 } | |
589 } | |
590 } | |
591 } | |
592 } | |
593 } | |
594 ++v15; | |
595 v1 = (int)(v14 + 112); | |
596 v14 += 112; | |
597 } | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
598 while ( (signed int)v15 < (signed int)uNumSpriteObjects ); |
0 | 599 } |
600 } | |
601 | |
602 //----- (0046EF01) -------------------------------------------------------- | |
603 int __thiscall _46EF01_collision_chech_player(int a1) | |
604 { | |
605 int v1; // edx@1 | |
606 int result; // eax@1 | |
607 int v3; // ebx@7 | |
608 int v4; // esi@7 | |
609 int v5; // edi@8 | |
610 int v6; // ecx@9 | |
611 int v7; // edi@12 | |
612 int v8; // [sp+Ch] [bp-10h]@1 | |
613 unsigned int v9; // [sp+10h] [bp-Ch]@1 | |
614 int v10; // [sp+14h] [bp-8h]@7 | |
615 int v11; // [sp+18h] [bp-4h]@7 | |
616 | |
617 v8 = a1; | |
618 v1 = 2 * pParty->field_14; | |
619 result = pParty->vPosition.x; | |
620 v9 = pParty->uPartyHeight; | |
621 if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14 ) | |
622 { | |
623 if ( stru_721530.sMinX >= pParty->vPosition.x - v1 ) | |
624 { | |
625 if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 ) | |
626 { | |
627 if ( stru_721530.sMinY >= pParty->vPosition.y - v1 ) | |
628 { | |
629 if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) ) | |
630 { | |
631 if ( stru_721530.sMinZ >= pParty->vPosition.z ) | |
632 { | |
633 v3 = stru_721530.prolly_normal_d + v1; | |
634 v11 = pParty->vPosition.x - stru_721530.normal.x; | |
635 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y | |
636 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16; | |
637 v10 = pParty->vPosition.y - stru_721530.normal.y; | |
638 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y | |
639 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16); | |
640 if ( result <= v3 ) | |
641 { | |
642 result = v10 * stru_721530.field_58.y; | |
643 v5 = (v10 * stru_721530.field_58.y + v11 * stru_721530.field_58.x) >> 16; | |
644 if ( v5 > 0 ) | |
645 { | |
646 v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; | |
647 result = pParty->vPosition.z; | |
648 if ( v6 >= pParty->vPosition.z ) | |
649 { | |
650 result = v9 + pParty->vPosition.z; | |
651 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 ) | |
652 { | |
295 | 653 result = integer_sqrt(v3 * v3 - v4 * v4); |
0 | 654 v7 = v5 - result; |
655 if ( v7 < 0 ) | |
656 v7 = 0; | |
657 if ( v7 < stru_721530.field_7C ) | |
658 { | |
659 stru_721530.field_7C = v7; | |
660 stru_721530.uFaceID = 4; | |
661 } | |
662 } | |
663 } | |
664 } | |
665 } | |
666 } | |
667 } | |
668 } | |
669 } | |
670 } | |
671 } | |
672 return result; | |
673 } | |
674 | |
675 //----- (0046F04E) -------------------------------------------------------- | |
676 signed int __cdecl _46F04E_collide_against_portals() | |
677 { | |
678 BLVSector *v0; // ecx@1 | |
679 unsigned int v1; // eax@1 | |
680 int v2; // eax@2 | |
681 BLVFace *v3; // eax@3 | |
682 int v4; // ecx@9 | |
683 int v5; // edx@9 | |
684 signed int result; // eax@21 | |
685 BLVFace *v7; // eax@22 | |
686 signed int v8; // [sp+0h] [bp-14h]@1 | |
687 BLVSector *v9; // [sp+4h] [bp-10h]@1 | |
688 unsigned int v10; // [sp+8h] [bp-Ch]@1 | |
689 int a3; // [sp+Ch] [bp-8h]@13 | |
690 int v12; // [sp+10h] [bp-4h]@15 | |
691 | |
692 v8 = 0; | |
693 v0 = &pIndoor->pSectors[stru_721530.uSectorID]; | |
694 v1 = 0xFFFFFFu; | |
695 v10 = 0xFFFFFFu; | |
696 v9 = v0; | |
697 if ( v0->uNumPortals > 0 ) | |
698 { | |
699 do | |
700 { | |
701 v2 = v0->pPortals[v8]; | |
702 if ( v2 != stru_721530.field_80 ) | |
703 { | |
704 v3 = &pIndoor->pFaces[v2]; | |
705 if ( stru_721530.sMaxX <= v3->pBounding.x2 ) | |
706 { | |
707 if ( stru_721530.sMinX >= v3->pBounding.x1 | |
708 && stru_721530.sMaxY <= v3->pBounding.y2 | |
709 && stru_721530.sMinY >= v3->pBounding.y1 | |
710 && stru_721530.sMaxZ <= v3->pBounding.z2 | |
711 && stru_721530.sMinZ >= v3->pBounding.z1 ) | |
712 { | |
713 v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x | |
714 + v3->pFacePlane_old.dist | |
715 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y | |
716 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16; | |
717 v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z | |
718 + v3->pFacePlane_old.dist | |
719 + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x | |
720 + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16; | |
721 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d) | |
722 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d) | |
723 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v3)) | |
724 && a3 < (signed int)v10 ) | |
725 { | |
726 v0 = v9; | |
727 v10 = a3; | |
728 v12 = v9->pPortals[v8]; | |
729 } | |
730 else | |
731 { | |
732 v0 = v9; | |
733 } | |
734 } | |
735 } | |
736 } | |
737 ++v8; | |
738 } | |
739 while ( v8 < v0->uNumPortals ); | |
740 v1 = v10; | |
741 } | |
742 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C ) | |
743 { | |
744 stru_721530.field_80 = v12; | |
745 v7 = &pIndoor->pFaces[v12]; | |
746 if ( v7->uSectorID == stru_721530.uSectorID ) | |
747 stru_721530.uSectorID = v7->uBackSectorID; | |
748 else | |
749 stru_721530.uSectorID = v7->uSectorID; | |
750 stru_721530.field_7C = 268435455; | |
751 result = 0; | |
752 } | |
753 else | |
754 { | |
755 result = 1; | |
756 } | |
757 return result; | |
758 } | |
759 | |
760 //----- (0047050A) -------------------------------------------------------- | |
761 int stru141::_47050A(int a2) | |
762 { | |
763 stru141 *v2; // esi@1 | |
764 signed int v3; // eax@1 | |
765 int v4; // ecx@1 | |
766 int v5; // edx@1 | |
767 int v6; // edx@1 | |
768 int v7; // eax@1 | |
769 int v8; // eax@3 | |
770 signed int result; // eax@4 | |
771 int v10; // eax@5 | |
772 int v11; // eax@5 | |
773 int v12; // ebx@5 | |
774 int v13; // edx@5 | |
775 int v14; // edi@5 | |
776 int v15; // ecx@5 | |
777 int v16; // eax@5 | |
778 int v17; // eax@5 | |
779 int v18; // eax@7 | |
780 int v19; // edx@9 | |
781 int v20; // edi@9 | |
782 int v21; // eax@9 | |
783 int v22; // eax@11 | |
784 int v23; // edx@13 | |
785 int v24; // eax@13 | |
786 int v25; // eax@14 | |
787 int v26; // eax@16 | |
788 int v27; // eax@17 | |
789 int v28; // [sp+14h] [bp+8h]@5 | |
790 | |
791 v2 = this; | |
295 | 792 v3 = integer_sqrt(this->field_24 * this->field_24 + this->field_20 * this->field_20 + this->field_1C * this->field_1C); |
0 | 793 v4 = v3 | 1; |
794 v5 = v2->field_1C; | |
795 v2->field_64 = v3 | 1; | |
796 v2->field_58.x = 65536 / (v3 | 1) * v5; | |
797 v2->field_58.y = 65536 / (v3 | 1) * v2->field_20; | |
798 v6 = 65536 / (v3 | 1) * v2->field_24; | |
799 v2->field_68 = 65536 / (v3 | 1); | |
800 v7 = a2; | |
801 v2->field_58.z = v6; | |
802 if ( !a2 ) | |
803 v7 = pEventTimer->dt_in_some_format; | |
804 v8 = ((unsigned __int64)(v7 * (signed __int64)v4) >> 16) - v2->field_70; | |
805 v2->field_6C = v8; | |
806 if ( v8 > 0 ) | |
807 { | |
808 v10 = ((unsigned __int64)(v8 * (signed __int64)v2->field_58.x) >> 16) + v2->normal.x; | |
809 v2->field_4C = v10; | |
810 v2->normal2.x = v10; | |
811 v11 = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.y) >> 16) + v2->normal.y; | |
812 v2->field_50 = v11; | |
813 v2->normal2.y = v11; | |
814 v2->normal2.z = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16) + v2->normal.z; | |
815 v12 = v2->field_34.z; | |
816 v13 = v2->normal.x; | |
817 v14 = v2->normal2.x; | |
818 v15 = v2->prolly_normal_d; | |
819 v16 = v12 + ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16); | |
820 v28 = v16; | |
821 v2->field_54 = v16; | |
822 v17 = v13; | |
823 if ( v13 >= v14 ) | |
824 v17 = v14; | |
825 v2->sMaxX = v17 - v15; | |
826 v18 = v15 + v13; | |
827 if ( v13 <= v14 ) | |
828 v18 = v15 + v14; | |
829 v19 = v2->normal.y; | |
830 v20 = v2->normal2.y; | |
831 v2->sMinX = v18; | |
832 v21 = v19; | |
833 if ( v19 >= v20 ) | |
834 v21 = v20; | |
835 v2->sMaxY = v21 - v15; | |
836 v22 = v15 + v19; | |
837 if ( v19 <= v20 ) | |
838 v22 = v20 + v15; | |
839 v23 = v2->normal2.z; | |
840 v2->sMinY = v22; | |
841 v24 = v2->normal.z; | |
842 if ( v24 >= v23 ) | |
843 v25 = v23 - v15; | |
844 else | |
845 v25 = v24 - v15; | |
846 v2->sMaxZ = v25; | |
847 v26 = v2->field_8; | |
848 if ( v12 <= v28 ) | |
849 v27 = v28 + v26; | |
850 else | |
851 v27 = v12 + v26; | |
852 v2->uFaceID = 0; | |
853 v2->field_80 = -1; | |
854 v2->field_88 = -1; | |
855 v2->sMinZ = v27; | |
856 v2->field_7C = 0xFFFFFFu; | |
857 result = 0; | |
858 } | |
859 else | |
860 { | |
861 result = 1; | |
862 } | |
863 return result; | |
864 } | |
865 | |
866 //----- (004706C6) -------------------------------------------------------- | |
867 void __cdecl UpdateActors_ODM() | |
868 { | |
869 Actor *v0; // esi@2 | |
845 | 870 AIState uAIState; // ax@2 |
846 | 871 //unsigned int v2; // ecx@6 |
0 | 872 int v3; // ebx@6 |
845 | 873 //int v4; // eax@8 |
0 | 874 int v5; // eax@10 |
875 int v6; // ecx@10 | |
846 | 876 //signed int v7; // ebx@10 |
0 | 877 signed int v8; // ebx@17 |
845 | 878 //unsigned __int8 v9; // zf@17 |
0 | 879 unsigned __int8 v10; // sf@17 |
880 unsigned __int16 v11; // ax@21 | |
881 int v12; // eax@29 | |
882 unsigned __int64 v13; // qax@29 | |
883 int v14; // eax@30 | |
884 unsigned __int64 v15; // qax@30 | |
885 int v16; // eax@33 | |
846 | 886 //int v17; // edi@34 |
0 | 887 int v18; // edx@42 |
888 int v19; // ecx@42 | |
889 __int16 v20; // ax@42 | |
890 int v21; // ebx@42 | |
891 int v22; // edi@42 | |
892 int v23; // ecx@42 | |
893 __int16 v24; // ax@42 | |
894 int v25; // eax@45 | |
895 signed int v26; // ecx@50 | |
896 int v27; // eax@52 | |
897 int v28; // eax@54 | |
898 signed int v29; // ebx@57 | |
899 signed int v30; // eax@57 | |
900 int v31; // edi@57 | |
901 signed int i; // ebx@57 | |
902 unsigned int v33; // ecx@58 | |
845 | 903 //int v34; // ebx@64 |
0 | 904 int v35; // edi@64 |
905 int v36; // eax@64 | |
848 | 906 //unsigned __int16 v37; // cx@66 |
0 | 907 signed int v38; // edx@71 |
848 | 908 unsigned int v39; // edi@71 |
0 | 909 BSPModel *v40; // eax@75 |
910 ODMFace *v41; // edi@75 | |
911 int v42; // ebx@76 | |
912 int v43; // ecx@77 | |
913 int v44; // edx@77 | |
914 __int16 v45; // dx@82 | |
915 int v46; // ecx@82 | |
916 signed int v47; // ebx@85 | |
917 int v48; // edi@85 | |
918 int v49; // edi@85 | |
919 int v50; // eax@85 | |
920 unsigned __int64 v51; // qax@85 | |
848 | 921 //unsigned __int8 v52; // zf@87 |
922 //unsigned __int8 v53; // sf@87 | |
845 | 923 // unsigned __int8 v54; // of@104 |
0 | 924 int v55; // eax@107 |
925 unsigned int v56; // edi@107 | |
926 int v57; // ST10_4@107 | |
927 unsigned int v58; // edi@107 | |
928 unsigned int v59; // ebx@107 | |
929 signed int v60; // eax@107 | |
930 int v61; // eax@124 | |
931 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 | |
153 | 932 int v63; // [sp+18h] [bp-38h]@64 |
0 | 933 int v64; // [sp+1Ch] [bp-34h]@64 |
934 int v65; // [sp+20h] [bp-30h]@2 | |
935 int v66; // [sp+24h] [bp-2Ch]@2 | |
936 bool v67; // [sp+28h] [bp-28h]@10 | |
846 | 937 //unsigned int v68; // [sp+2Ch] [bp-24h]@10 |
0 | 938 unsigned int v69; // [sp+30h] [bp-20h]@6 |
939 unsigned int v70; // [sp+34h] [bp-1Ch]@10 | |
940 int v71; // [sp+38h] [bp-18h]@62 | |
845 | 941 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 |
942 int v72b; | |
0 | 943 int v73; // [sp+40h] [bp-10h]@17 |
845 | 944 int uIsFlying; // [sp+44h] [bp-Ch]@8 |
0 | 945 unsigned int v75; // [sp+48h] [bp-8h]@1 |
845 | 946 int uIsOnWater; // [sp+4Ch] [bp-4h]@10 |
947 | |
948 for(v75=0;(signed int)v75 < (signed int)uNumActors;++v75) | |
0 | 949 { |
950 v0 = &pActors[v75]; | |
951 v66 = v0->vPosition.x; | |
952 v65 = v0->vPosition.y; | |
845 | 953 uAIState = v0->uAIState; |
954 if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed ) | |
955 { | |
956 continue; | |
957 } | |
0 | 958 v3 = 0; |
959 v69 = 0; | |
846 | 960 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) |
0 | 961 v3 = 1; |
962 v0->uSectorID = 0; | |
845 | 963 uIsFlying = v0->pMonsterInfo.uFlying; |
0 | 964 if ( !v0->CanAct() ) |
845 | 965 uIsFlying = 0; |
138 | 966 v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); |
723 | 967 v5 = ODM_GetFloorLevel( |
0 | 968 v0->vPosition.x, |
969 v0->vPosition.y, | |
970 v0->vPosition.z, | |
971 v0->uActorHeight, | |
845 | 972 &uIsOnWater, |
0 | 973 (int *)&v69, |
974 v3); | |
975 v6 = v0->vPosition.z; | |
845 | 976 uIsAboveFloor = 0; |
0 | 977 v67 = v69 == 0; |
978 if ( v6 > v5 + 1 ) | |
845 | 979 uIsAboveFloor = 1; |
980 if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) | |
0 | 981 { |
982 v0->uAIState = Removed; | |
845 | 983 continue; |
0 | 984 } |
305 | 985 if ( v0->uCurrentActionAnimation == ANIM_Walking ) |
0 | 986 { |
987 v8 = v0->uMovementSpeed; | |
988 v73 = v0->uMovementSpeed; | |
845 | 989 if ( (signed __int64)v0->pActorBuffs[7].uExpireTime > 0 ) |
0 | 990 { |
991 v8 = (signed __int64)((double)v73 * 0.5); | |
992 v73 = (signed __int64)((double)v73 * 0.5); | |
993 } | |
845 | 994 if ( uAIState == Fleeing || uAIState == Pursuing ) |
0 | 995 { |
996 v8 *= 2; | |
997 v73 = v8; | |
998 } | |
1340 | 999 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 ) |
0 | 1000 v8 = (signed __int64)((double)v73 * flt_6BE3AC_debug_recmod1_x_1_6); |
1001 if ( v8 > 1000 ) | |
1002 v8 = 1000; | |
323 | 1003 v12 = stru_5C6E00->Cos(v0->uYawAngle); |
0 | 1004 v13 = v12 * (signed __int64)v8; |
1005 v73 = v13 >> 16; | |
1006 v0->vVelocity.x = WORD1(v13); | |
323 | 1007 v69 = stru_5C6E00->Sin(v0->uYawAngle); |
0 | 1008 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16; |
1009 v0->vVelocity.y = v69 * v8 >> 16; | |
845 | 1010 if ( uIsFlying ) |
0 | 1011 { |
323 | 1012 v14 = stru_5C6E00->Sin(v0->uPitchAngle); |
0 | 1013 v69 = v14; |
1014 v15 = v14 * (signed __int64)v8; | |
1015 v73 = v15 >> 16; | |
1016 v0->vVelocity.z = WORD1(v15); | |
1017 } | |
846 | 1018 //v7 = v68; |
0 | 1019 } |
1020 else | |
1021 { | |
1022 v73 = v0->vVelocity.x; | |
1023 v69 = 55000; | |
1024 v73 = (unsigned __int64)(55000i64 * v73) >> 16; | |
1025 v0->vVelocity.x = v73; | |
1026 v73 = v0->vVelocity.y; | |
1027 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16; | |
1028 v0->vVelocity.y = v73; | |
845 | 1029 if ( uIsFlying ) |
0 | 1030 { |
1031 v69 = 55000; | |
1032 v73 = v0->vVelocity.z; | |
1033 v73 = (unsigned __int64)(55000i64 * v73) >> 16; | |
1034 v0->vVelocity.z = v73; | |
1035 } | |
1036 } | |
846 | 1037 if ( v0->vPosition.z < v5 ) |
0 | 1038 { |
845 | 1039 v16 = uIsFlying; |
846 | 1040 v0->vPosition.z = v5; |
0 | 1041 v0->vVelocity.z = v16 != 0 ? 0x14 : 0; |
1042 } | |
846 | 1043 //v17 = 0; |
845 | 1044 if ( !uIsAboveFloor || uIsFlying ) |
1045 { | |
1046 if ( v70 && !uIsAboveFloor && v67 ) | |
0 | 1047 { |
1048 v18 = v0->vPosition.y; | |
1049 v19 = v0->vPosition.x; | |
846 | 1050 v0->vPosition.z = v5; |
138 | 1051 ODM_GetTerrainNormalAt(v19, v18, &v62); |
0 | 1052 v20 = GetGravityStrength(); |
1053 v21 = v62.y; | |
1054 v22 = v62.z; | |
1055 v23 = v62.y * v0->vVelocity.y; | |
1056 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; | |
1057 v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16; | |
845 | 1058 v72b = v21; |
0 | 1059 v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16; |
845 | 1060 v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; |
1061 v24 = v72b; | |
1062 v72b = v22; | |
0 | 1063 v0->vVelocity.y += v24; |
845 | 1064 v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; |
1065 v0->vVelocity.z += v72b; | |
846 | 1066 //v17 = 0; |
0 | 1067 } |
1068 } | |
1069 else | |
1070 { | |
1071 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
1072 } | |
846 | 1073 if ( pParty->armageddon_timer != 0 && v0->CanAct() ) |
0 | 1074 { |
1075 v0->vVelocity.x += rand() % 100 - 50; | |
1076 v0->vVelocity.y += rand() % 100 - 50; | |
1077 v0->vVelocity.z += rand() % 100 - 20; | |
1078 v25 = rand(); | |
1079 v0->uAIState = Stunned; | |
1080 v0->uYawAngle += v25 % 32 - 16; | |
1081 v0->UpdateAnimation(); | |
1082 } | |
846 | 1083 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 ) |
1084 { | |
1085 v0->vVelocity.y = 0; | |
1086 v0->vVelocity.x = 0; | |
0 | 1087 } |
1088 stru_721530.field_0 = 1; | |
845 | 1089 if ( !uIsFlying ) |
0 | 1090 v26 = 40; |
1091 else | |
1092 v26 = v0->uActorRadius; | |
1093 v27 = v0->uActorHeight; | |
1094 stru_721530.field_84 = -1; | |
1095 stru_721530.field_8 = v26; | |
1096 stru_721530.prolly_normal_d = v26; | |
1097 stru_721530.field_C = v27; | |
846 | 1098 stru_721530.field_70 = 0; |
1099 v69 = 0; | |
0 | 1100 while ( 1 ) |
1101 { | |
1102 stru_721530.field_34.x = v0->vPosition.x; | |
1103 stru_721530.normal.x = stru_721530.field_34.x; | |
1104 stru_721530.field_34.y = v0->vPosition.y; | |
1105 stru_721530.normal.y = stru_721530.field_34.y; | |
1106 v28 = v0->vPosition.z; | |
1107 stru_721530.normal.z = v28 + v26 + 1; | |
1108 stru_721530.field_34.z = v28 - v26 + stru_721530.field_C - 1; | |
1109 if ( stru_721530.field_34.z < stru_721530.normal.z ) | |
1110 stru_721530.field_34.z = v28 + v26 + 1; | |
1111 stru_721530.field_1C = v0->vVelocity.x; | |
1112 stru_721530.uSectorID = 0; | |
1113 stru_721530.field_20 = v0->vVelocity.y; | |
1114 stru_721530.field_24 = v0->vVelocity.z; | |
1115 if ( stru_721530._47050A(0) ) | |
1116 break; | |
1117 _46E889_collide_against_bmodels(1u); | |
1118 v29 = WorldPosToGridCellZ(v0->vPosition.y); | |
1119 v30 = WorldPosToGridCellX(v0->vPosition.x); | |
1120 _46E26D_collide_against_sprites(v30, v29); | |
1121 _46EF01_collision_chech_player(0); | |
862 | 1122 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); |
0 | 1123 v31 = 0; |
1124 for ( i = 0; v31 < ai_arrays_size; ++v31 ) | |
1125 { | |
390 | 1126 v33 = ai_near_actors_ids[v31]; |
0 | 1127 if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) ) |
1128 ++i; | |
1129 } | |
1130 v71 = i > 1; | |
1131 if ( stru_721530.field_7C < stru_721530.field_6C ) | |
1132 v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
845 | 1133 //v34 = 0; |
0 | 1134 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; |
723 | 1135 v36 = ODM_GetFloorLevel( |
0 | 1136 stru_721530.normal2.x, |
1137 stru_721530.normal2.y, | |
1138 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, | |
1139 v0->uActorHeight, | |
1140 (int *)&v63, | |
1141 &v64, | |
1142 0); | |
845 | 1143 if ( uIsOnWater ) |
0 | 1144 { |
1145 if ( v35 < v36 + 60 ) | |
1146 { | |
848 | 1147 if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) |
0 | 1148 { |
1149 if ( v64 ) | |
1150 v61 = v36 + 30; | |
1151 else | |
846 | 1152 v61 = v5 + 60; |
0 | 1153 sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61); |
1154 v0->uAIState = Removed; | |
1155 return; | |
1156 } | |
1157 } | |
1158 } | |
1159 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
1160 { | |
1161 v0->vPosition.x = LOWORD(stru_721530.normal2.x); | |
1162 v0->vPosition.y = LOWORD(stru_721530.normal2.y); | |
1163 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
1164 break; | |
1165 } | |
845 | 1166 v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; |
0 | 1167 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; |
845 | 1168 v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; |
0 | 1169 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; |
845 | 1170 v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; |
0 | 1171 v38 = stru_721530.uFaceID; |
1172 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; | |
1173 stru_721530.field_70 += stru_721530.field_7C; | |
848 | 1174 v39 = PID_ID(v38); |
845 | 1175 switch ( PID_TYPE(v38) ) |
1176 { | |
1177 case OBJECT_Actor: | |
1340 | 1178 if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 ) |
845 | 1179 { |
1180 //if(pParty->bTurnBasedModeOn == 1) | |
1181 //v34 = 0; | |
0 | 1182 if ( v0->pMonsterInfo.uHostilityType ) |
1183 { | |
845 | 1184 if ( v71 == 0 ) |
1185 { | |
1060 | 1186 Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); |
845 | 1187 } |
1188 else | |
1189 { | |
1190 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); | |
1191 } | |
0 | 1192 } |
845 | 1193 else if ( v71 != 0 ) |
1194 { | |
1195 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); | |
1196 } | |
1197 else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) | |
0 | 1198 { |
1060 | 1199 Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); |
0 | 1200 } |
845 | 1201 else |
1202 { | |
1060 | 1203 Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0); |
845 | 1204 } |
0 | 1205 } |
1206 break; | |
845 | 1207 case OBJECT_Player: |
0 | 1208 if ( !v0->GetActorsRelation(0) ) |
1209 { | |
1210 v38 = stru_721530.uFaceID; | |
1060 | 1211 Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0); |
845 | 1212 break; |
0 | 1213 } |
1167 | 1214 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; |
1215 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; | |
0 | 1216 v0->vVelocity.y = 0; |
1217 v0->vVelocity.x = 0; | |
1167 | 1218 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) |
1219 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) | |
1220 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 1221 viewparams->bRedrawGameUI = 1; |
1222 break; | |
845 | 1223 case OBJECT_Decoration: |
295 | 1224 v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); |
0 | 1225 v48 = stru_5C6E00->Atan2( |
1226 v0->vPosition.x - pLevelDecorations[v39].vPosition.x, | |
1227 v0->vPosition.y - pLevelDecorations[v39].vPosition.y); | |
323 | 1228 v71 = stru_5C6E00->Cos(v48); |
0 | 1229 v70 = (unsigned __int64)(v71 * (signed __int64)v47) >> 16; |
323 | 1230 v49 = v48; |
0 | 1231 v0->vVelocity.x = (unsigned int)(v71 * v47) >> 16; |
323 | 1232 v50 = stru_5C6E00->Sin(v48); |
0 | 1233 v71 = v50; |
1234 v51 = v50 * (signed __int64)v47; | |
1235 v70 = v51 >> 16; | |
1236 v0->vVelocity.y = WORD1(v51); | |
1237 break; | |
845 | 1238 case OBJECT_BModel: |
0 | 1239 v40 = &pOutdoor->pBModels[v38 >> 9]; |
1240 v41 = &v40->pFaces[v39 & 0x3F]; | |
1241 if ( !(BYTE3(v41->uAttributes) & 0x20) ) | |
1242 { | |
1243 v42 = v41->uPolygonType; | |
1244 if ( v42 == 3 ) | |
1245 { | |
1246 v43 = v0->vVelocity.y; | |
1247 v44 = v0->vVelocity.x; | |
1248 v0->vVelocity.z = 0; | |
1249 v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1; | |
1250 if ( v44 * v44 + v43 * v43 < 400 ) | |
1251 { | |
1252 v0->vVelocity.y = 0; | |
1253 v0->vVelocity.x = 0; | |
1254 } | |
1255 } | |
1256 else | |
1257 { | |
845 | 1258 v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z |
0 | 1259 + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; |
845 | 1260 if ( stru_721530.field_64 >> 3 > v72b ) |
1261 v72b = stru_721530.field_64 >> 3; | |
0 | 1262 v73 = v41->pFacePlane.vNormal.x; |
845 | 1263 v73 = (unsigned __int64)(v72b * (signed __int64)v73) >> 16; |
0 | 1264 v71 = v41->pFacePlane.vNormal.y; |
845 | 1265 v71 = (unsigned __int64)(v72b * (signed __int64)v71) >> 16; |
0 | 1266 v70 = v41->pFacePlane.vNormal.z; |
845 | 1267 v70 = (unsigned __int64)(v72b * (signed __int64)(signed int)v70) >> 16; |
0 | 1268 v0->vVelocity.x += v73; |
1269 v0->vVelocity.y += v71; | |
1270 v0->vVelocity.z += v70; | |
1271 if ( v42 != 4 ) | |
1272 { | |
1273 v45 = v0->vPosition.z; | |
1274 v46 = stru_721530.prolly_normal_d | |
1275 - ((v41->pFacePlane.dist | |
1276 + v41->pFacePlane.vNormal.x * v0->vPosition.x | |
1277 + v41->pFacePlane.vNormal.y * v0->vPosition.y | |
1278 + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16); | |
1279 if ( v46 > 0 ) | |
1280 { | |
1281 v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16; | |
1282 v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16; | |
1283 v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16); | |
1284 } | |
1285 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); | |
1286 } | |
1287 } | |
1288 } | |
1289 break; | |
1290 } | |
1291 v70 = v0->vVelocity.x; | |
1292 v71 = 58500; | |
1293 v70 = (unsigned __int64)(58500i64 * (signed int)v70) >> 16; | |
1294 v0->vVelocity.x = v70; | |
1295 v70 = v0->vVelocity.y; | |
1296 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; | |
1297 v71 = 58500; | |
1298 v0->vVelocity.y = v70; | |
1299 v70 = v0->vVelocity.z; | |
1300 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; | |
1301 ++v69; | |
845 | 1302 //v54 = v69 < 100; |
1303 //v10 = (v69 - 100) < 0; | |
0 | 1304 v0->vVelocity.z = v70; |
845 | 1305 if ( v69 >= 100 ) |
0 | 1306 break; |
1307 v26 = stru_721530.prolly_normal_d; | |
1308 } | |
846 | 1309 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1; |
1310 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1; | |
1311 if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) | |
845 | 1312 && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) |
1313 && v58 | |
1314 || v67 != 0 ) | |
0 | 1315 { |
1316 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) | |
1317 { | |
1318 v58 = v58 == 0; | |
1319 v59 = v59 == 0; | |
1320 } | |
845 | 1321 if ( !uIsFlying && v58 && !v59 ) |
0 | 1322 { |
1323 v0->vPosition.x = v66; | |
1324 v0->vPosition.y = v65; | |
1325 if ( v0->CanAct() ) | |
1326 { | |
1327 v0->uYawAngle -= 32; | |
1328 v0->uCurrentActionTime = 0; | |
1329 v0->uCurrentActionLength = 128; | |
1330 v0->uAIState = Fleeing; | |
1331 } | |
1332 } | |
1333 } | |
845 | 1334 } |
0 | 1335 } |
1336 | |
1337 //----- (0047253E) -------------------------------------------------------- | |
1338 void UpdateObjects() | |
1339 { | |
1340 unsigned int v0; // ebx@0 | |
1341 //unsigned int v1; // edi@1 | |
1083 | 1342 //char *v2; // esi@2 |
0 | 1343 //__int16 v3; // dx@5 |
1344 ObjectDesc *v4; // eax@5 | |
1345 int v5; // ecx@6 | |
1346 __int16 v6; // cx@7 | |
1347 signed int v7; // eax@9 | |
1348 __int16 v8; // cx@14 | |
1349 __int16 v9; // dx@14 | |
1350 unsigned int v10; // ecx@16 | |
1351 signed int v11; // eax@17 | |
1352 int v12; // edi@27 | |
1353 int v13; // eax@27 | |
1354 int v14; // ebx@27 | |
1355 unsigned int v15; // ecx@27 | |
1356 unsigned int v16; // edx@30 | |
1357 unsigned int v17; // edx@32 | |
1358 int v18; // [sp+4h] [bp-10h]@27 | |
1359 int v19; // [sp+8h] [bp-Ch]@27 | |
1360 //signed int v20; // [sp+10h] [bp-4h]@1 | |
1361 | |
1362 //v1 = 0; | |
1363 //v20 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1364 for (uint i = 0; i < uNumSpriteObjects; ++i) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1365 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
1366 auto item = &pSpriteObjects[i]; |
1083 | 1367 //v2 = (char *)&item->uSpriteFrameID; |
0 | 1368 //do |
1369 //{ | |
1370 //LOWORD(v0) = item->uAttributes; | |
1371 if (item->uAttributes & 0x40) | |
1372 item->uAttributes &= 0xFFBF; | |
1373 else | |
1374 { | |
1375 //v3 = item->uObjectDescID; | |
1376 v4 = &pObjectList->pObjects[item->uObjectDescID]; | |
430 | 1377 if (item->AttachedToActor()) |
1378 { | |
848 | 1379 v5 = PID_ID(item->spell_target_pid); |
1083 | 1380 item->vPosition.x = pActors[v5].vPosition.x; |
1381 item->vPosition.y = pActors[v5].vPosition.y; | |
1382 item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; | |
1383 if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) ) | |
1384 continue; | |
0 | 1385 if ( v6 >= 0 ) |
1386 { | |
1387 v7 = v4->uLifetime; | |
1388 if (item->uAttributes & 2) | |
1083 | 1389 v7 = item->field_20; |
0 | 1390 if ( v6 < v7 ) |
1083 | 1391 continue; |
1392 } | |
1393 v10 = i; | |
1394 SpriteObject::OnInteraction(v10); | |
1395 continue; | |
0 | 1396 } |
1397 | |
1398 if ( item->uObjectDescID ) | |
1399 { | |
1400 v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID; | |
1401 item->uSpriteFrameID = v8; | |
1402 v9 = v4->uFlags; | |
1083 | 1403 if ( v9 & 4 ) |
1404 { | |
1405 if ( v8 < 0 ) | |
1406 { | |
1407 v10 = i; | |
1408 SpriteObject::OnInteraction(v10); | |
1409 continue; | |
1410 } | |
1411 v11 = v4->uLifetime; | |
1412 if (item->uAttributes & 2) | |
1413 v11 = item->field_20; | |
1414 } | |
1415 if ( !(v9 & 4) || v8 < v11 ) | |
1416 { | |
0 | 1417 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1418 SpriteObject::UpdateObject_fn0_BLV(i); |
0 | 1419 else |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1420 SpriteObject::UpdateObject_fn0_ODM(i); |
1083 | 1421 if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) ) |
1422 continue; | |
1423 v12 = abs(pParty->vPosition.x - item->vPosition.x); | |
1424 v18 = abs(pParty->vPosition.y - item->vPosition.y); | |
1425 v19 = abs(pParty->vPosition.z - item->vPosition.z); | |
0 | 1426 v13 = v12; |
1427 v14 = v18; | |
1428 v15 = v19; | |
1429 if ( v12 < v18 ) | |
1430 { | |
1431 v13 = v18; | |
1432 v14 = v12; | |
1433 } | |
1434 if ( v13 < v19 ) | |
1435 { | |
1436 v16 = v13; | |
1437 v13 = v19; | |
1438 v15 = v16; | |
1439 } | |
1440 if ( v14 < (signed int)v15 ) | |
1441 { | |
1442 v17 = v15; | |
1443 v15 = v14; | |
1444 v14 = v17; | |
1445 } | |
1446 v0 = (unsigned int)(11 * v14) >> 5; | |
1447 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 ) | |
1083 | 1448 continue; |
0 | 1449 v10 = i; |
1083 | 1450 SpriteObject::OnInteraction(v10); |
1451 continue; | |
0 | 1452 } |
1453 v10 = i; | |
1454 if ( !(v9 & 0x40) ) | |
1083 | 1455 { |
1456 SpriteObject::OnInteraction(v10); | |
1457 continue; | |
1458 } | |
862 | 1459 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); |
0 | 1460 } |
1461 } | |
1462 //v2 += 112; | |
1463 //v1 = v20++ + 1; | |
1464 //} | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1465 //while ( v20 < (signed int)uNumSpriteObjects ); |
0 | 1466 } |
1467 } | |
1468 | |
1469 //----- (0047272C) -------------------------------------------------------- | |
831 | 1470 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) |
0 | 1471 { |
1472 signed int v5; // ebx@1 | |
1473 int result; // eax@1 | |
1474 int v7; // [sp+10h] [bp-8h]@1 | |
1475 signed int v8; // [sp+14h] [bp-4h]@1 | |
1476 | |
1477 v5 = x - 2; | |
1478 v7 = x; | |
1479 v8 = y; | |
1480 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40); | |
783 | 1481 result = collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID); |
0 | 1482 if ( result == -30000 || !*pSectorID ) |
1483 { | |
1484 *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40); | |
783 | 1485 result = collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID); |
0 | 1486 if ( result == -30000 || !*pSectorID ) |
1487 { | |
1488 *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40); | |
783 | 1489 result = collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID); |
0 | 1490 if ( result == -30000 || !*pSectorID ) |
1491 { | |
1492 *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40); | |
783 | 1493 result = collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID); |
0 | 1494 if ( result == -30000 || !*pSectorID ) |
1495 { | |
1496 *pSectorID = pIndoor->GetSector(v7, v8, z + 140); | |
783 | 1497 result = collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID); |
0 | 1498 } |
1499 } | |
1500 } | |
1501 } | |
1502 return result; | |
1503 } | |
1504 | |
1505 //----- (00472866) -------------------------------------------------------- | |
1506 void BLV_ProcessPartyActions() | |
1507 { | |
1508 int v1; // ebx@1 | |
1509 int v2; // edi@1 | |
831 | 1510 //int v6; // eax@18 |
1511 //signed __int64 v8; // qax@27 | |
1512 //int v9; // eax@27 | |
0 | 1513 double v10; // st7@27 |
1514 unsigned int v12; // eax@49 | |
1515 double v13; // st7@50 | |
831 | 1516 //int v14; // eax@51 |
1517 //signed __int64 v15; // qax@53 | |
1518 //double v16; // st7@54 | |
0 | 1519 int v17; // eax@62 |
1520 double v18; // st7@62 | |
1521 int v19; // ST40_4@62 | |
1522 int v20; // eax@65 | |
1523 double v21; // st7@65 | |
1524 int v22; // ST40_4@65 | |
1525 int v23; // eax@66 | |
1526 double v24; // st7@66 | |
1527 int v25; // ST40_4@66 | |
1528 int v26; // eax@67 | |
1529 double v27; // st7@67 | |
1530 int v28; // ST40_4@67 | |
1531 unsigned int v35; // eax@74 | |
1532 int v36; // ecx@88 | |
1533 int new_party_z; // esi@96 | |
1534 int v38; // eax@96 | |
1535 int v39; // ecx@106 | |
1536 int v40; // eax@106 | |
1537 Player **v41; // esi@113 | |
1538 int v42; // eax@120 | |
1539 signed int v43; // ecx@123 | |
1540 BLVFace *v44; // esi@126 | |
1541 PolygonType v45; // al@126 | |
1542 int v46; // ecx@133 | |
1543 char v47; // zf@133 | |
1544 int v48; // eax@133 | |
1545 int v49; // ST40_4@136 | |
1546 int v50; // ST40_4@140 | |
1547 int v51; // eax@140 | |
1548 int v52; // eax@140 | |
1549 signed int v53; // edi@146 | |
1550 int v54; // ebx@146 | |
1551 int v55; // ST30_4@146 | |
1552 AudioPlayer *v56; // ecx@162 | |
1553 SoundID v57; // [sp-20h] [bp-80h]@163 | |
1554 signed int v58; // [sp-1Ch] [bp-7Ch]@161 | |
1555 unsigned int v59; // [sp-18h] [bp-78h]@161 | |
1556 signed int v60; // [sp-14h] [bp-74h]@161 | |
1557 signed int v61; // [sp-10h] [bp-70h]@161 | |
1558 int v62; // [sp-Ch] [bp-6Ch]@161 | |
1559 int v63; // [sp-8h] [bp-68h]@75 | |
1560 unsigned int v64; // [sp-8h] [bp-68h]@161 | |
1561 int v65; // [sp-4h] [bp-64h]@75 | |
1562 int v66; // [sp-4h] [bp-64h]@161 | |
831 | 1563 //int v68; // [sp+10h] [bp-50h]@45 |
0 | 1564 int v69; // [sp+10h] [bp-50h]@140 |
1565 unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1 | |
831 | 1566 //signed int v71; // [sp+18h] [bp-48h]@1 |
0 | 1567 signed int v72; // [sp+1Ch] [bp-44h]@1 |
1568 signed int v73; // [sp+20h] [bp-40h]@100 | |
1569 int v74; // [sp+20h] [bp-40h]@140 | |
1570 bool bFeatherFall; // [sp+24h] [bp-3Ch]@15 | |
1571 unsigned int uSectorID; // [sp+28h] [bp-38h]@1 | |
1572 int v78; // [sp+2Ch] [bp-34h]@1 | |
1573 unsigned int uFaceID; // [sp+30h] [bp-30h]@1 | |
1574 int v80; // [sp+34h] [bp-2Ch]@1 | |
1575 int v81; // [sp+38h] [bp-28h]@47 | |
1576 int v82; // [sp+3Ch] [bp-24h]@47 | |
1577 int _view_angle; // [sp+40h] [bp-20h]@47 | |
1578 int bJumping; // [sp+44h] [bp-1Ch]@1 | |
1579 int new_party_y; // [sp+48h] [bp-18h]@1 | |
1580 int new_party_x; // [sp+4Ch] [bp-14h]@1 | |
1581 int party_z; // [sp+50h] [bp-10h]@1 | |
717 | 1582 //int v89; // [sp+58h] [bp-8h]@1 |
0 | 1583 int angle; // [sp+5Ch] [bp-4h]@47 |
1584 | |
1585 uFaceEvent = 0; | |
717 | 1586 //v89 = pParty->uFallSpeed; |
0 | 1587 v1 = 0; |
1588 v2 = 0; | |
1589 new_party_x = pParty->vPosition.x; | |
717 | 1590 new_party_y = pParty->vPosition.y; |
0 | 1591 party_z = pParty->vPosition.z; |
1592 uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1593 v72 = 0; | |
1594 v78 = 0; | |
1595 bJumping = 0; | |
792 | 1596 |
1597 uFaceID = -1; | |
831 | 1598 auto floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); |
792 | 1599 |
0 | 1600 if ( pParty->bFlying ) |
1601 { | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
526
diff
changeset
|
1602 pParty->bFlying = false; |
0 | 1603 if (pParty->FlyActive()) |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
526
diff
changeset
|
1604 pOtherOverlayList->pOverlays[pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID - 1].field_E |= 1; |
831 | 1605 } |
1606 | |
1607 if ( floor_level == -30000 || uFaceID == -1) | |
1608 { | |
1609 floor_level = collide_against_floor_approximate(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); | |
1610 if ( floor_level == -30000 || uFaceID == -1) | |
1611 { | |
1612 __debugbreak(); // level built with errors | |
0 | 1613 pParty->vPosition.x = blv_prev_party_x; |
1614 pParty->vPosition.y = blv_prev_party_z; | |
1615 pParty->vPosition.z = blv_prev_party_y; | |
1616 pParty->uFallStartY = blv_prev_party_y; | |
1617 return; | |
1618 } | |
1619 } | |
831 | 1620 |
0 | 1621 blv_prev_party_x = pParty->vPosition.x; |
1622 blv_prev_party_z = pParty->vPosition.y; | |
1623 blv_prev_party_y = pParty->vPosition.z; | |
1624 if (!pParty->bTurnBasedModeOn) | |
1625 { | |
1626 auto v67 = GetTickCount() / 500; | |
1627 if (dword_720CDC != v67 ) | |
1628 { | |
1285 | 1629 dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x; |
1630 dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y; | |
1631 dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z; | |
0 | 1632 if ( dword_4F8580[0] > 60 ) |
1633 dword_4F8580[0] = 1; | |
1634 } | |
1635 dword_720CDC = v67; | |
1636 } | |
831 | 1637 |
1638 uint fall_start; | |
0 | 1639 if (!pParty->FeatherFallActive()) |
1640 { | |
1641 bFeatherFall = false; | |
1080 | 1642 if (!pParty->pPlayers[0].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) && // grants feather fall |
1643 !pParty->pPlayers[1].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) && | |
1644 !pParty->pPlayers[2].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) && | |
1645 !pParty->pPlayers[3].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) | |
831 | 1646 { |
1647 fall_start = pParty->uFallStartY; | |
1648 } | |
1649 } | |
1650 else | |
1651 { | |
1652 fall_start = floor_level; | |
0 | 1653 bFeatherFall = true; |
831 | 1654 pParty->uFallStartY = floor_level; |
1655 } | |
1656 | |
1657 | |
1658 if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1) | |
1659 { | |
1660 assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor? | |
569 | 1661 if (pParty->uFlags & PARTY_FLAGS_1_LANDING) |
1662 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
0 | 1663 else for (uint i = 0; i < 4; ++i) |
1664 { // receive falling damage | |
831 | 1665 auto player = pParty->pPlayers + i; |
1080 | 1666 if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS)) |
831 | 1667 { |
1036 | 1668 player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL); |
1669 v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; | |
831 | 1670 player->SetRecoveryTime((signed __int64)v10); |
1671 } | |
1672 } | |
1673 } | |
1674 | |
1675 if ( party_z > floor_level + 1 ) | |
0 | 1676 bJumping = 1; |
831 | 1677 |
1678 bool jumping_up = false; | |
1679 | |
1680 if ( party_z - floor_level <= 32 ) | |
1681 { | |
0 | 1682 pParty->uFallStartY = party_z; |
831 | 1683 jumping_up = true; |
1684 } | |
1685 | |
1686 if (bWalkSound && pParty->walk_sound_timer) | |
1687 { | |
1688 if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed) | |
1689 pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; | |
1690 else pParty->walk_sound_timer = 0; | |
1691 } | |
1692 | |
1693 | |
1694 if (party_z <= floor_level + 1) | |
1695 { | |
1696 party_z = floor_level + 1; | |
1697 pParty->uFallStartY = floor_level + 1; | |
1698 | |
1699 if (!bJumping && pParty->floor_face_pid != uFaceID) | |
1700 { | |
1701 auto pFace = &pIndoor->pFaces[uFaceID]; | |
1702 if (pFace->uAttributes & FACE_PRESSURE_PLATE) | |
1703 uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; | |
1704 } | |
1705 } | |
1706 if (!bJumping) | |
1707 pParty->floor_face_pid = uFaceID; | |
1708 | |
1709 bool on_water = false; | |
1710 if ( pIndoor->pFaces[uFaceID].Fluid()) | |
1711 on_water = true; | |
1712 | |
0 | 1713 v81 = pParty->uWalkSpeed; |
1714 angle = pParty->sRotationY; | |
1715 _view_angle = pParty->sRotationX; | |
831 | 1716 v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) |
0 | 1717 / 180)) >> 16; |
809 | 1718 //LABEL_87: |
0 | 1719 while ( pPartyActionQueue->uNumActions ) |
1720 { | |
1721 switch ( pPartyActionQueue->Next() ) | |
1722 { | |
1723 case PARTY_TurnLeft: | |
831 | 1724 if (uTurnSpeed) |
1725 angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); | |
1726 else | |
1727 angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier)); | |
809 | 1728 break; |
0 | 1729 case PARTY_TurnRight: |
831 | 1730 if (uTurnSpeed) |
809 | 1731 angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); |
831 | 1732 else |
1733 angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier)); | |
809 | 1734 break; |
831 | 1735 |
0 | 1736 case PARTY_FastTurnLeft: |
831 | 1737 if (uTurnSpeed) |
1738 angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); | |
0 | 1739 else |
831 | 1740 angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); |
809 | 1741 break; |
831 | 1742 |
0 | 1743 case PARTY_FastTurnRight: |
831 | 1744 if (uTurnSpeed) |
1745 angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); | |
1746 else | |
1747 angle = stru_5C6E00->uDoublePiMask & (angle - (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); | |
809 | 1748 break; |
831 | 1749 |
809 | 1750 case PARTY_StrafeLeft: |
1751 v2 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; | |
1752 v1 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; | |
717 | 1753 v78 = 1; |
809 | 1754 break; |
0 | 1755 case PARTY_StrafeRight: |
809 | 1756 v2 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; |
1757 v1 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; | |
717 | 1758 v78 = 1; |
809 | 1759 break; |
0 | 1760 case PARTY_WalkForward: |
831 | 1761 v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16; |
1762 v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16; | |
717 | 1763 v78 = 1; |
809 | 1764 break; |
0 | 1765 case PARTY_WalkBackward: |
809 | 1766 v2 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; |
1767 v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; | |
0 | 1768 v78 = 1; |
809 | 1769 break; |
0 | 1770 case PARTY_RunForward: |
323 | 1771 v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; |
1772 v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; | |
0 | 1773 v72 = 1; |
809 | 1774 break; |
0 | 1775 case PARTY_RunBackward: |
1776 //v32 = stru_5C6E00->SinCos(angle); | |
1777 //v33 = (double)v81; | |
1778 //v88 = (double)v81; | |
323 | 1779 v2 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; |
0 | 1780 //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); |
323 | 1781 v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; |
0 | 1782 v72 = 1; |
807 | 1783 break; |
0 | 1784 case PARTY_LookUp: |
1785 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); | |
1786 if ( _view_angle > 128 ) | |
1787 _view_angle = 128; | |
1788 v35 = uActiveCharacter; | |
809 | 1789 if ( uActiveCharacter ) |
1790 pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0); | |
717 | 1791 break; |
0 | 1792 case PARTY_LookDown: |
1793 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); | |
1794 if ( _view_angle < -128 ) | |
1795 _view_angle = -128; | |
1796 v35 = uActiveCharacter; | |
1797 if ( uActiveCharacter ) | |
717 | 1798 pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_64, 0); |
0 | 1799 break; |
1800 case PARTY_CenterView: | |
1801 _view_angle = 0; | |
1802 break; | |
1803 case PARTY_Jump: | |
831 | 1804 if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 ) |
0 | 1805 { |
1806 bJumping = 1; | |
717 | 1807 pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); |
0 | 1808 } |
1809 break; | |
1810 default: | |
809 | 1811 break; |
0 | 1812 } |
1813 } | |
1814 v36 = 0; | |
1815 pParty->sRotationY = angle; | |
1816 pParty->sRotationX = _view_angle; | |
1817 if ( bJumping ) | |
1818 { | |
1418 | 1819 pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); |
1820 if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) | |
1821 { | |
1822 if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) | |
1823 { | |
1824 v41 = &pPlayers[1]; | |
1825 do | |
1826 { | |
1827 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 | |
1828 (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); | |
1829 ++v41; | |
1830 } | |
1831 while ( (signed int)v41 <= (signed int)&pPlayers[4] ); | |
1832 } | |
1833 } | |
1834 else | |
1835 pParty->uFallStartY = party_z; | |
0 | 1836 } |
1837 else | |
1838 { | |
831 | 1839 if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) |
0 | 1840 { |
717 | 1841 pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); |
1418 | 1842 pParty->uFallStartY = party_z; |
0 | 1843 } |
1418 | 1844 else |
1845 { | |
1846 if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) | |
1847 pParty->uFallSpeed = 0; | |
1848 pParty->uFallStartY = party_z; | |
1849 } | |
1850 } | |
0 | 1851 if ( v2 * v2 + v1 * v1 < 400 ) |
1852 { | |
1853 v1 = 0; | |
1854 v2 = 0; | |
1855 } | |
1856 stru_721530.field_84 = -1; | |
1857 stru_721530.field_70 = 0; | |
1858 stru_721530.prolly_normal_d = pParty->field_14; | |
1859 stru_721530.field_8 = pParty->field_14 >> 1; | |
1860 auto v83 = 0; | |
1861 stru_721530.field_0 = 1; | |
1862 stru_721530.field_C = pParty->uPartyHeight - 32; | |
1863 while ( 1 ) | |
1864 { | |
1865 new_party_z = party_z; | |
1866 stru_721530.field_34.x = new_party_x; | |
1867 stru_721530.normal.x = new_party_x; | |
1868 stru_721530.field_1C = v2; | |
1869 stru_721530.field_34.y = new_party_y; | |
1870 stru_721530.normal.y = new_party_y; | |
1871 stru_721530.field_20 = v1; | |
1872 stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1; | |
1873 stru_721530.field_34.z = stru_721530.field_C + party_z + 1; | |
717 | 1874 stru_721530.field_24 = pParty->uFallSpeed; |
0 | 1875 stru_721530.uSectorID = uSectorID; |
1876 v38 = 0; | |
1340 | 1877 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 ) |
0 | 1878 v38 = 13312; |
1879 if ( stru_721530._47050A(v38) ) | |
1880 break; | |
1881 v73 = 0; | |
1882 do | |
1883 { | |
1884 _46E44E_collide_against_faces_and_portals(1u); | |
1885 _46E0B2_collide_against_decorations(); | |
1886 for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 ) | |
1887 _46DF1A_collide_against_actor(v80, 0); | |
1888 if ( _46F04E_collide_against_portals() ) | |
1889 break; | |
1890 ++v73; | |
1891 } | |
1892 while ( v73 < 100 ); | |
1893 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
1894 { | |
1895 v39 = stru_721530.normal2.x; | |
1896 uSectorID = stru_721530.normal2.y; | |
1897 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
1898 } | |
1899 else | |
1900 { | |
1901 v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + new_party_x; | |
1902 uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); | |
1903 v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); | |
1904 } | |
783 | 1905 v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID); |
0 | 1906 if ( v42 == -30000 || v42 - new_party_z > 128 ) |
1907 return; | |
1908 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
1909 { | |
1910 new_party_x = stru_721530.normal2.x; | |
1911 new_party_y = stru_721530.normal2.y; | |
1912 new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
1913 break; | |
1914 } | |
1915 new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
1916 new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
1917 v43 = stru_721530.uFaceID; | |
1918 uSectorID = stru_721530.uSectorID; | |
1919 stru_721530.field_70 += stru_721530.field_7C; | |
1920 auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; | |
848 | 1921 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) |
0 | 1922 { |
1167 | 1923 if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 |
1924 && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) | |
1925 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 1926 viewparams->bRedrawGameUI = 1; |
1927 } | |
1418 | 1928 else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) |
0 | 1929 { |
295 | 1930 v53 = integer_sqrt(v2 * v2 + v1 * v1); |
0 | 1931 v80 = v53; |
717 | 1932 v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, |
0 | 1933 new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); |
323 | 1934 v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)v53) >> 16; |
1935 v55 = stru_5C6E00->Sin(v54); | |
0 | 1936 v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16; |
1937 } | |
1938 else | |
1939 { | |
848 | 1940 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) |
0 | 1941 { |
1942 v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; | |
1943 v45 = v44->uPolygonType; | |
1944 if ( v45 == 3 ) | |
1945 { | |
717 | 1946 if ( pParty->uFallSpeed < 0 ) |
1947 pParty->uFallSpeed = 0; | |
0 | 1948 v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1; |
1949 if ( pParty->uFallStartY - v87 < 512 ) | |
1950 pParty->uFallStartY = v87; | |
1951 if ( v2 * v2 + v1 * v1 < 400 ) | |
1952 { | |
1953 v1 = 0; | |
1954 v2 = 0; | |
1955 } | |
831 | 1956 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) |
717 | 1957 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; |
1958 } | |
1418 | 1959 else |
1960 { | |
1961 v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; | |
1962 v47 = v45 == 4; | |
1963 v48 = v44->pFacePlane_old.vNormal.x; | |
1964 if ( !v47 ) | |
1965 { | |
1966 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; | |
1967 if ( stru_721530.field_64 >> 3 > v80 ) | |
1968 v80 = stru_721530.field_64 >> 3; | |
1969 v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; | |
1970 v81 = v44->pFacePlane_old.vNormal.y; | |
1971 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; | |
1972 v82 = v44->pFacePlane_old.vNormal.z; | |
1973 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; | |
1974 v2 += v50; | |
1975 pParty->uFallSpeed += v82; | |
1976 v74 = v44->pFacePlane_old.vNormal.z; | |
1977 v51 = v44->pFacePlane_old.vNormal.y; | |
1978 v69 = v44->pFacePlane_old.vNormal.x; | |
1979 v80 = v51; | |
1980 v1 += v81; | |
1981 v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); | |
1982 if ( v52 > 0 ) | |
1983 { | |
1984 new_party_x += v52 * v69 >> 16; | |
1985 new_party_y += v52 * v80 >> 16; | |
1986 v87 += v52 * v74 >> 16; | |
1987 } | |
1988 v43 = stru_721530.uFaceID; | |
1989 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) | |
1990 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; | |
1991 } | |
1992 else | |
1993 { | |
1994 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; | |
1995 if ( stru_721530.field_64 >> 3 > v80 ) | |
1996 v80 = stru_721530.field_64 >> 3; | |
1997 v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; | |
1998 v81 = v44->pFacePlane_old.vNormal.y; | |
1999 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; | |
2000 v82 = v44->pFacePlane_old.vNormal.z; | |
2001 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; | |
2002 v2 += v49; | |
2003 v1 += v81; | |
2004 pParty->uFallSpeed += v82; | |
2005 if ( v2 * v2 + v1 * v1 >= 400 ) | |
2006 { | |
2007 v43 = stru_721530.uFaceID; | |
2008 if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) | |
2009 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; | |
2010 } | |
2011 else | |
2012 { | |
2013 v2 = 0; | |
2014 v1 = 0; | |
2015 pParty->uFallSpeed = 0; | |
2016 } | |
2017 } | |
2018 } | |
0 | 2019 } |
2020 } | |
2021 v2 = (unsigned __int64)(58500i64 * v2) >> 16; | |
2022 v1 = (unsigned __int64)(58500i64 * v1) >> 16; | |
2023 ++v83; | |
717 | 2024 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
0 | 2025 if ( v83 >= 100 ) |
2026 { | |
2027 new_party_z = v87; | |
2028 break; | |
2029 } | |
2030 } | |
831 | 2031 if ( bWalkSound && !pParty->walk_sound_timer) |
0 | 2032 { |
295 | 2033 if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) |
717 | 2034 * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z) |
2035 * (pParty->vPosition.z - new_party_z)) <= 16 ) | |
1418 | 2036 { |
2037 pAudioPlayer->_4AA258(804); | |
2038 pParty->walk_sound_timer = 64; | |
2039 } | |
2040 else if ( v72 && (!bJumping || jumping_up) ) | |
0 | 2041 { |
2042 v66 = 0; | |
2043 v64 = 0; | |
2044 v62 = 0; | |
2045 v61 = 0; | |
2046 v60 = -1; | |
2047 v59 = 1; | |
2048 v58 = 804; | |
831 | 2049 if ( !on_water ) |
0 | 2050 { |
2051 v56 = pAudioPlayer; | |
2052 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) | |
2053 v57 = (SoundID)50; | |
2054 else | |
2055 v57 = (SoundID)64; | |
1418 | 2056 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); |
0 | 2057 } |
1418 | 2058 else |
2059 { | |
2060 v57 = (SoundID)63; | |
2061 v56 = pAudioPlayer; | |
2062 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); | |
2063 } | |
0 | 2064 } |
1418 | 2065 else if ( v78 && (!bJumping || jumping_up) ) |
0 | 2066 { |
2067 v66 = 0; | |
2068 v64 = 0; | |
2069 v62 = 0; | |
2070 v61 = 0; | |
2071 v60 = -1; | |
2072 v59 = 1; | |
2073 v58 = 804; | |
831 | 2074 if ( on_water ) |
0 | 2075 { |
2076 v57 = (SoundID)102; | |
717 | 2077 v56 = pAudioPlayer; |
0 | 2078 } |
1418 | 2079 else |
2080 { | |
2081 v56 = pAudioPlayer; | |
2082 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) | |
2083 v57 = (SoundID)89; | |
2084 else | |
2085 v57 = (SoundID)103; | |
2086 } | |
0 | 2087 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); |
2088 } | |
2089 else | |
2090 { | |
2091 pAudioPlayer->_4AA258(804); | |
831 | 2092 pParty->walk_sound_timer = 64; |
2093 } | |
2094 } | |
2095 if ( !bJumping || jumping_up ) | |
569 | 2096 pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; |
2097 else | |
2098 pParty->uFlags |= PARTY_FLAGS_1_FALLING; | |
2099 pParty->uFlags &= ~0x200; | |
0 | 2100 pParty->vPosition.x = new_party_x; |
2101 pParty->vPosition.z = new_party_z; | |
2102 pParty->vPosition.y = new_party_y; | |
717 | 2103 //pParty->uFallSpeed = v89; |
0 | 2104 if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 ) |
569 | 2105 pParty->uFlags |= 0x200; |
0 | 2106 if (uFaceEvent) |
2107 EventProcessor(uFaceEvent, 0, 1); | |
2108 } | |
2109 | |
2110 //----- (00473893) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2111 void ODM_ProcessPartyActions() |
0 | 2112 { |
2113 int v1; // edi@1 | |
2114 int v2; // ebx@1 | |
2115 int v3; // eax@14 | |
2116 int v6; // esi@45 | |
2117 ODMFace *v7; // ecx@45 | |
2118 signed int v33; // eax@143 | |
2119 int v34; // esi@143 | |
141 | 2120 int v35; // esi@147 |
0 | 2121 int v36; // eax@155 |
2122 signed int v37; // esi@159 | |
2123 signed int v38; // eax@159 | |
2124 signed int i; // esi@159 | |
2125 int v40; // esi@162 | |
2126 bool v42; // eax@180 | |
2127 signed int v43; // ecx@184 | |
2128 signed int v44; // edx@184 | |
2129 int v45; // ecx@200 | |
1424 | 2130 BSPModel *pModel; // eax@203 |
2131 ODMFace *pODMFace; // esi@203 | |
0 | 2132 int v48; // eax@203 |
2133 char v49; // zf@203 | |
2134 char v50; // sf@203 | |
2135 unsigned __int8 v51; // of@203 | |
2136 int v52; // eax@203 | |
2137 BSPModel *v54; // eax@215 | |
2138 int v55; // eax@217 | |
2139 signed int v56; // ebx@228 | |
2140 int v57; // eax@228 | |
2141 BSPModel *v58; // eax@228 | |
2142 unsigned __int64 v59; // qax@228 | |
2143 BSPModel *v60; // eax@228 | |
2144 unsigned __int64 v61; // qax@228 | |
2145 int v62; // eax@241 | |
2146 unsigned int v65; // ebx@263 | |
2147 unsigned int v66; // esi@263 | |
2148 int v67; // eax@263 | |
2149 signed int v68; // ecx@263 | |
2150 int v69; // eax@263 | |
2151 int v70; // ebx@271 | |
2152 int v71; // esi@271 | |
2153 int v72; // edi@271 | |
2154 int v73; // eax@271 | |
2155 unsigned int v76; // edi@293 | |
2156 bool v77; // edx@297 | |
2157 bool v78; // ecx@303 | |
2158 int v79; // ecx@314 | |
2159 __int16 v80; // dx@317 | |
2160 int v81; // ebx@318 | |
2161 int v82; // ecx@318 | |
1424 | 2162 int pTerrainHeight; // eax@321 |
0 | 2163 int v86; // [sp-20h] [bp-B4h]@246 |
2164 int v87; // [sp-20h] [bp-B4h]@248 | |
2165 signed int v88; // [sp-1Ch] [bp-B0h]@246 | |
2166 unsigned int v89; // [sp-18h] [bp-ACh]@246 | |
2167 signed int v90; // [sp-14h] [bp-A8h]@246 | |
2168 signed int v91; // [sp-10h] [bp-A4h]@246 | |
2169 int v92; // [sp-Ch] [bp-A0h]@246 | |
2170 unsigned int v94; // [sp-8h] [bp-9Ch]@246 | |
2171 int v96; // [sp-4h] [bp-98h]@246 | |
2172 int v97; // [sp+Ch] [bp-88h]@180 | |
138 | 2173 Vec3_int_ v98; |
0 | 2174 bool v101; // [sp+1Ch] [bp-78h]@33 |
2175 int v102; // [sp+20h] [bp-74h]@1 | |
2176 int v103; // [sp+24h] [bp-70h]@1 | |
2177 int bFeatherFall; // [sp+28h] [bp-6Ch]@4 | |
2178 int v105; // [sp+2Ch] [bp-68h]@24 | |
2179 int bWaterWalk; // [sp+30h] [bp-64h]@1 | |
2180 int v109; // [sp+3Ch] [bp-58h]@28 | |
2181 int v110; // [sp+40h] [bp-54h]@180 | |
2182 int v111; // [sp+44h] [bp-50h]@14 | |
2183 int bJumping; // [sp+48h] [bp-4Ch]@1 | |
2184 int v113; // [sp+4Ch] [bp-48h]@1 | |
2185 unsigned int v114; // [sp+50h] [bp-44h]@1 | |
2186 int _walk_speed; // [sp+54h] [bp-40h]@48 | |
723 | 2187 int pX; // [sp+58h] [bp-3Ch]@1 |
2188 int pY; // [sp+5Ch] [bp-38h]@1 | |
0 | 2189 int v118; // [sp+60h] [bp-34h]@1 |
2190 int _angle_x; // [sp+68h] [bp-2Ch]@48 | |
2191 unsigned int v122; // [sp+70h] [bp-24h]@180 | |
723 | 2192 int pZ; // [sp+74h] [bp-20h]@1 |
0 | 2193 int v124; // [sp+78h] [bp-1Ch]@1 |
2194 int _angle_y; // [sp+7Ch] [bp-18h]@48 | |
2195 int v126; // [sp+80h] [bp-14h]@48 | |
2196 int v128; // [sp+88h] [bp-Ch]@1 | |
2197 int v129; // [sp+8Ch] [bp-8h]@92 | |
1424 | 2198 |
723 | 2199 pZ = pParty->vPosition.z; |
0 | 2200 v1 = 0; |
2201 v103 = 0; | |
2202 v2 = 0; | |
1061 | 2203 //*(float *)&v128 = 0.0; |
2204 v128 = 0; | |
2205 v129 = 0; | |
723 | 2206 pX = pParty->vPosition.x; |
2207 pY = pParty->vPosition.y; | |
0 | 2208 v113 = pParty->field_6F0; |
2209 bJumping = 0; | |
138 | 2210 auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); |
0 | 2211 v114 = 0; |
2212 v124 = 0; | |
2213 v102 = 0; | |
1424 | 2214 pModel = 0; |
0 | 2215 bWaterWalk = 0; |
122 | 2216 if (!pParty->FeatherFallActive()) |
0 | 2217 { |
2218 bFeatherFall = 0; | |
122 | 2219 for (int i = 0; i < 4; ++i) |
1080 | 2220 if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) // seems like flying boots |
122 | 2221 { |
2222 bFeatherFall = 1; | |
2223 break; | |
2224 } | |
2225 } | |
889 | 2226 else |
2227 { | |
2228 bFeatherFall = 1; | |
2229 } | |
122 | 2230 //LABEL_9: |
569 | 2231 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; |
122 | 2232 if (pParty->WaterWalkActive()) |
2233 { | |
2234 //LOBYTE(pParty->uFlags) &= 0x7Fu; | |
0 | 2235 bWaterWalk = 1; |
1167 | 2236 *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; |
122 | 2237 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) && |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2238 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) |
0 | 2239 bWaterWalk = 0; |
2240 } | |
1413 | 2241 int bmodel_standing_on_pid; |
2242 int is_on_water = false; | |
2243 v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); | |
2244 int is_not_on_bmodel = bmodel_standing_on_pid == 0; | |
2245 | |
0 | 2246 v111 = v3; |
2247 if ( bFeatherFall ) | |
2248 pParty->uFallStartY = v3; | |
2249 else | |
2250 v3 = pParty->uFallStartY; | |
723 | 2251 if ( v3 - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 ) |
0 | 2252 { |
141 | 2253 if (pParty->uFlags & PARTY_FLAGS_1_LANDING) |
2254 { | |
2255 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
2256 } | |
2257 else for (int _i = 0; _i < 4; ++_i) // receive falling damage | |
2258 { | |
2259 auto player = pParty->pPlayers + _i; | |
2260 | |
1080 | 2261 if ( !player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) |
141 | 2262 { |
2263 player->ReceiveDamage( | |
723 | 2264 (signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(player->GetMaxHealth() / 10)) / 256, |
1036 | 2265 DMGT_PHISYCAL); |
2266 v105 = 20 - player->GetParameterBonus(player->GetActualEndurance()); | |
141 | 2267 player->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); |
2268 } | |
2269 //} | |
2270 //while ( (signed int)v4 <= (signed int)&pPlayers[4] ); | |
0 | 2271 } |
2272 } | |
2273 v109 = -1; | |
138 | 2274 if ( pParty->bFlying ) |
723 | 2275 v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); |
1413 | 2276 //v107 = bmodel_standing_on_pid == 0; |
0 | 2277 v105 = v111 + 1; |
723 | 2278 if ( pZ <= v111 + 1 ) |
0 | 2279 { |
2280 v109 = -1; | |
138 | 2281 pParty->bFlying = false; |
0 | 2282 } |
2283 else | |
2284 { | |
2285 bJumping = 1; | |
2286 } | |
723 | 2287 v101 = pZ - v111 <= 32; |
831 | 2288 if ( bWalkSound && pParty->walk_sound_timer) |
2289 { | |
2290 if (pParty->walk_sound_timer >= pEventTimer->uTimeElapsed) | |
2291 pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; | |
2292 else pParty->walk_sound_timer = 0; | |
2293 } | |
1413 | 2294 if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) |
138 | 2295 pParty->bFlying = false; |
2296 if (!bJumping) | |
0 | 2297 { |
1413 | 2298 if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) |
0 | 2299 { |
1413 | 2300 if (bmodel_standing_on_pid) |
0 | 2301 { |
1413 | 2302 if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels ) |
0 | 2303 { |
1413 | 2304 v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces; |
2305 v6 = bmodel_standing_on_pid & 0x3F; | |
79 | 2306 /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) |
0 | 2307 { |
862 | 2308 pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); |
0 | 2309 v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292); |
79 | 2310 }*/ |
2311 if ( BYTE3(v7[v6].uAttributes) & 4 ) | |
2312 { | |
1413 | 2313 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); |
79 | 2314 v103 = v7[v6].sCogTriggeredID; |
0 | 2315 } |
2316 } | |
2317 } | |
2318 } | |
1413 | 2319 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); |
0 | 2320 } |
2321 _walk_speed = pParty->uWalkSpeed; | |
2322 _angle_y = pParty->sRotationY; | |
2323 _angle_x = pParty->sRotationX; | |
2324 v126 = pEventTimer->dt_in_some_format; | |
122 | 2325 /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format |
0 | 2326 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed |
2327 * stru_5C6E00->uIntegerPi) | |
122 | 2328 / 180)) >> 16);*/ |
2329 __int64 dturn = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; | |
140 | 2330 while (pPartyActionQueue->uNumActions) |
2331 { | |
2332 switch (pPartyActionQueue->Next()) | |
0 | 2333 { |
2334 case PARTY_FlyUp: | |
138 | 2335 { |
2336 if (!pParty->FlyActive() && !bUnderwater) | |
2337 break; | |
2338 | |
2339 pParty->bFlying = false; | |
2340 if (bUnderwater || | |
2341 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || | |
569 | 2342 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 ) |
0 | 2343 { |
2344 if ( pParty->vPosition.z < 4000 || bJumping ) | |
2345 { | |
723 | 2346 pZ += 30; |
0 | 2347 v113 += 30; |
2348 pParty->bFlying = 1; | |
723 | 2349 if ( pZ > 4000 ) |
0 | 2350 { |
723 | 2351 pZ = 4000; |
0 | 2352 v113 = 4000; |
2353 } | |
2354 v1 = 0; | |
2355 v2 = 0; | |
1424 | 2356 pParty->uFallSpeed = 0; |
0 | 2357 *(float *)&v128 = 0.0; |
723 | 2358 if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 ) |
0 | 2359 { |
2360 pParty->field_6E0 = 0; | |
2361 pParty->field_6E4 = 0; | |
2362 pPartyActionQueue->uNumActions = 0; | |
569 | 2363 pParty->uFlags |= PARTY_FLAGS_1_LANDING; |
0 | 2364 pParty->vPosition.z = v109 - pParty->uPartyHeight - 31; |
723 | 2365 pParty->field_6F0 = pZ; |
0 | 2366 pParty->bFlying = 0; |
723 | 2367 pZ = v109 - pParty->uPartyHeight - 31; |
0 | 2368 v113 = pParty->field_6F0; |
2369 } | |
2370 pParty->uFallSpeed = 0; | |
1424 | 2371 pModel = (BSPModel *)1; |
0 | 2372 } |
2373 } | |
138 | 2374 } |
2375 break; | |
2376 | |
0 | 2377 case PARTY_FlyDown: |
139 | 2378 if (pParty->FlyActive() || bUnderwater) |
0 | 2379 { |
2380 pParty->bFlying = 0; | |
2381 if ( bUnderwater | |
1167 | 2382 || pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 |
2383 || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 10] > 0 ) | |
0 | 2384 { |
723 | 2385 pZ -= 30; |
0 | 2386 v113 -= 30; |
2387 pParty->uFallSpeed = 0; | |
1424 | 2388 //pParty->uFallSpeed = 0; |
0 | 2389 pParty->bFlying = 1; |
1424 | 2390 pModel = (BSPModel *)1; |
723 | 2391 if ( pZ <= v111 ) |
0 | 2392 { |
2393 pParty->bFlying = 0; | |
2394 pPartyActionQueue->uNumActions = 0; | |
2395 } | |
2396 } | |
2397 } | |
139 | 2398 break; |
2399 | |
0 | 2400 case PARTY_TurnLeft: |
139 | 2401 if (uTurnSpeed) |
2402 _angle_y += uTurnSpeed; //descrete turn | |
2403 else | |
2404 _angle_y += dturn * fTurnSpeedMultiplier; // time-based smooth turn | |
2405 | |
2406 _angle_y &= stru_5C6E00->uDoublePiMask; | |
2407 break; | |
122 | 2408 |
2409 case PARTY_TurnRight: | |
139 | 2410 if (uTurnSpeed) |
2411 _angle_y -= uTurnSpeed; | |
2412 else | |
2413 _angle_y -= dturn * fTurnSpeedMultiplier; | |
2414 | |
2415 _angle_y &= stru_5C6E00->uDoublePiMask; | |
2416 break; | |
122 | 2417 |
2418 case PARTY_FastTurnLeft: | |
139 | 2419 if (uTurnSpeed) |
2420 _angle_y += uTurnSpeed; | |
2421 else | |
2422 _angle_y += 2.0f * fTurnSpeedMultiplier * (double)dturn; | |
2423 | |
2424 _angle_y &= stru_5C6E00->uDoublePiMask; | |
2425 break; | |
122 | 2426 |
0 | 2427 case PARTY_FastTurnRight: |
139 | 2428 if (!uTurnSpeed) |
2429 _angle_y -= 2.0f * fTurnSpeedMultiplier * (double)dturn; | |
2430 else | |
2431 _angle_y -= uTurnSpeed; | |
2432 | |
2433 _angle_y &= stru_5C6E00->uDoublePiMask; | |
2434 break; | |
122 | 2435 |
0 | 2436 case PARTY_StrafeLeft: |
139 | 2437 { |
2438 *(float *)&v128 = pParty->uWalkSpeed; | |
2439 | |
2440 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2441 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
2442 v2 -= 3 * dx / 4; | |
2443 | |
2444 float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2445 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
2446 v1 += 3 * dy / 4; | |
2447 | |
2448 v128 = v1; | |
2449 v124 = 1; | |
2450 } | |
2451 break; | |
2452 | |
0 | 2453 case PARTY_StrafeRight: |
139 | 2454 { |
2455 *(float *)&v128 = pParty->uWalkSpeed; | |
140 | 2456 |
139 | 2457 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); |
2458 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
2459 v2 += 3 * dx / 4; | |
2460 | |
2461 float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2462 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
2463 v1 -= 3 * dy / 4; | |
2464 | |
2465 v128 = v1; | |
2466 v124 = 1; | |
2467 } | |
2468 break; | |
2469 | |
0 | 2470 case PARTY_WalkForward: |
140 | 2471 { |
2472 *(float *)&v128 = _walk_speed; | |
2473 | |
2474 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
2475 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2476 | |
2477 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
433 | 2478 v2 += dx * 12; |
140 | 2479 |
2480 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
433 | 2481 v1 += dy * 12; |
140 | 2482 |
139 | 2483 v128 = v1; |
2484 v124 = 1; | |
140 | 2485 } |
139 | 2486 break; |
2487 | |
0 | 2488 case PARTY_RunForward: |
140 | 2489 { |
2490 *(float *)&v128 = _walk_speed; | |
2491 | |
2492 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
2493 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2494 | |
1424 | 2495 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
140 | 2496 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
2497 | |
2498 if (pParty->bFlying) | |
2499 { | |
2500 v2 += 4 * dx; | |
2501 v1 += 4 * dy; | |
2502 | |
2503 v128 = v1; | |
2504 } | |
1413 | 2505 else if (partyAtHighSlope && !bmodel_standing_on_pid) |
140 | 2506 { |
2507 v2 += dx; | |
2508 v1 += dy; | |
2509 | |
139 | 2510 v128 = v1; |
2511 v124 = 1; | |
140 | 2512 } |
2513 else | |
2514 { | |
2515 v2 += 2 * dx; | |
2516 v1 += 2 * dy; | |
2517 | |
2518 v128 = v1; | |
2519 v114 = 1; | |
2520 } | |
2521 } | |
2522 break; | |
2523 | |
2524 | |
2525 case PARTY_WalkBackward: | |
2526 { | |
2527 *(float *)&v128 = _walk_speed; | |
2528 | |
2529 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
2530 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2531 | |
2532 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
2533 v2 -= dx; | |
2534 | |
2535 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
2536 v1 -= dy; | |
2537 | |
0 | 2538 v128 = v1; |
140 | 2539 v124 = 1; |
2540 } | |
2541 break; | |
2542 | |
139 | 2543 |
0 | 2544 case PARTY_RunBackward: |
140 | 2545 { |
2546 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
2547 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
2548 | |
2549 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
2550 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
2551 | |
2552 if (pParty->bFlying) | |
2553 { | |
2554 v2 -= 4 * dx; | |
2555 v1 -= 4 * dy; | |
0 | 2556 v128 = v1; |
2557 } | |
2558 else | |
2559 { | |
140 | 2560 v2 -= dx; |
2561 v1 -= dy; | |
2562 | |
0 | 2563 v128 = v1; |
2564 v124 = 1; | |
2565 } | |
140 | 2566 } |
2567 break; | |
2568 | |
2569 case PARTY_CenterView: | |
2570 _angle_x = 0; | |
2571 break; | |
2572 | |
0 | 2573 case PARTY_LookUp: |
2574 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); | |
2575 if ( _angle_x > 128 ) | |
2576 _angle_x = 128; | |
140 | 2577 if (uActiveCharacter) |
187 | 2578 pPlayers[uActiveCharacter]->PlaySound(SPEECH_63, 0); |
140 | 2579 break; |
2580 | |
0 | 2581 case PARTY_LookDown: |
2582 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); | |
2583 if ( _angle_x < -128 ) | |
2584 _angle_x = -128; | |
140 | 2585 if (uActiveCharacter) |
187 | 2586 pPlayers[uActiveCharacter]->PlaySound(SPEECH_64, 0); |
140 | 2587 break; |
2588 | |
0 | 2589 case PARTY_Jump: |
1413 | 2590 if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) |
0 | 2591 { |
2592 v126 = pParty->field_24 << 6; | |
2593 bJumping = 1; | |
1424 | 2594 pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); |
0 | 2595 } |
140 | 2596 break; |
2597 | |
0 | 2598 default: |
140 | 2599 assert(false); |
2600 | |
0 | 2601 case PARTY_Land: |
140 | 2602 if (pParty->bFlying) |
0 | 2603 { |
141 | 2604 pParty->uFlags |= PARTY_FLAGS_1_LANDING; |
0 | 2605 pParty->uFallSpeed = 0; |
2606 } | |
140 | 2607 pParty->bFlying = false; |
0 | 2608 pPartyActionQueue->uNumActions = 0; |
140 | 2609 break; |
2610 } | |
2611 } | |
2612 | |
1061 | 2613 //LABEL_123: |
0 | 2614 pParty->sRotationY = _angle_y; |
2615 pParty->sRotationX = _angle_x; | |
1061 | 2616 if ( pZ < v111 || pParty->bFlying) |
0 | 2617 { |
2618 if ( pParty->bFlying ) | |
2619 { | |
1424 | 2620 v126 = stru_5C6E00->Cos(GetTickCount()); |
0 | 2621 v129 = (unsigned __int64)(4i64 * v126) >> 16; |
723 | 2622 pZ = v113 + v129; |
1424 | 2623 if ( pModel ) |
723 | 2624 pZ = v113; |
141 | 2625 if (pParty->FlyActive()) |
1167 | 2626 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFEu; |
723 | 2627 pParty->uFallStartY = pZ; |
1061 | 2628 } |
1424 | 2629 else |
2630 { | |
2631 if ( is_on_water && pParty->uFallSpeed ) | |
2632 sub_42F960_create_object(pX, pY, v111); | |
2633 pParty->uFallSpeed = 0; | |
2634 pZ = v111; | |
2635 pParty->uFallStartY = v111; | |
2636 v113 = pZ; | |
2637 if (pParty->FlyActive()) | |
2638 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; | |
2639 } | |
1061 | 2640 } |
2641 else | |
2642 { | |
2643 v113 = pZ; | |
2644 if (pParty->FlyActive()) | |
1167 | 2645 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; |
1061 | 2646 } |
2647 //LABEL_141: | |
141 | 2648 if (bJumping && !pParty->bFlying) |
0 | 2649 { |
2650 v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); | |
1424 | 2651 v34 = pParty->uFallSpeed + 2 * v33; |
2652 pParty->uFallSpeed += 2 * v33; | |
1061 | 2653 } |
2654 else if (!partyAtHighSlope) | |
0 | 2655 { |
1424 | 2656 v34 = pParty->uFallSpeed; |
1061 | 2657 } |
2658 else if (!bJumping) | |
2659 { | |
1413 | 2660 if ( !bmodel_standing_on_pid ) |
1061 | 2661 { |
2662 // rolling down the hill | |
2663 // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air | |
2664 // and falling to the gravity, gradually sliding downwards. nice trick | |
2665 pZ = v111; | |
2666 ODM_GetTerrainNormalAt(pX, pY, &v98); | |
1424 | 2667 v35 = pParty->uFallSpeed + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); |
1061 | 2668 v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16; |
2669 v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16; | |
2670 v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16; | |
2671 v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16); | |
2672 v128 = v1; | |
1424 | 2673 pParty->uFallSpeed = v34; |
1061 | 2674 } |
2675 } | |
2676 else | |
1424 | 2677 v34 = pParty->uFallSpeed; |
1061 | 2678 |
2679 //LABEL_164: | |
1070 | 2680 if(bJumping) |
2681 { | |
2682 if ( !bUnderwater && v34 <= 0) | |
2683 { | |
2684 if ( v34 < -500 | |
2685 && !pParty->bFlying | |
2686 && pParty->vPosition.z - v111 > 1000 | |
2687 && !pParty->FeatherFallActive()) | |
2688 { // falling scream | |
2689 for (int i = 0; i < 4; ++i) | |
2690 { | |
2691 auto player = pParty->pPlayers + i; | |
1080 | 2692 if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) && player->CanAct()) |
1070 | 2693 player->PlaySound(SPEECH_66, 0); |
2694 } | |
2695 } | |
2696 } | |
141 | 2697 } |
2698 else | |
2699 { | |
1061 | 2700 //LABEL_150: |
723 | 2701 pParty->uFallStartY = pZ; |
141 | 2702 } |
2703 | |
138 | 2704 if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope ) |
0 | 2705 { |
2706 *(float *)&v128 = 0.0; | |
2707 v2 = 0; | |
2708 } | |
2709 stru_721530.field_84 = -1; | |
2710 stru_721530.field_70 = 0; | |
2711 stru_721530.prolly_normal_d = pParty->field_14; | |
2712 stru_721530.field_8 = pParty->field_14 >> 1; | |
2713 v126 = 0; | |
2714 stru_721530.field_0 = 1; | |
2715 stru_721530.field_C = pParty->uPartyHeight - 32; | |
2716 do | |
2717 { | |
723 | 2718 stru_721530.field_34.x = pX; |
2719 stru_721530.normal.x = pX; | |
0 | 2720 stru_721530.field_1C = v2; |
723 | 2721 stru_721530.field_34.y = pY; |
2722 stru_721530.normal.y = pY; | |
2723 stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1; | |
2724 stru_721530.field_34.z = stru_721530.field_C + pZ + 1; | |
0 | 2725 stru_721530.field_20 = v128; |
1424 | 2726 stru_721530.field_24 = pParty->uFallSpeed; |
0 | 2727 v36 = 0; |
2728 stru_721530.uSectorID = 0; | |
1340 | 2729 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 ) |
0 | 2730 v36 = 13312; |
2731 if ( stru_721530._47050A(v36) ) | |
2732 break; | |
2733 _46E889_collide_against_bmodels(1u); | |
2734 v37 = WorldPosToGridCellZ(pParty->vPosition.y); | |
2735 v38 = WorldPosToGridCellX(pParty->vPosition.x); | |
2736 _46E26D_collide_against_sprites(v38, v37); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
2737 _46ED8A_collide_against_sprite_objects(4u); |
0 | 2738 for ( i = 0; i < (signed int)uNumActors; ++i ) |
2739 _46DF1A_collide_against_actor(i, 0); | |
2740 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
2741 { | |
2742 _angle_x = stru_721530.normal2.x; | |
2743 _angle_y = stru_721530.normal2.y; | |
2744 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
2745 } | |
2746 else | |
2747 { | |
723 | 2748 _angle_x = pX + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16); |
2749 _angle_y = pY + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); | |
1424 | 2750 pModel = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); |
723 | 2751 v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ; |
0 | 2752 } |
2753 v122 = v40; | |
1413 | 2754 ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); |
2755 v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); | |
2756 auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); | |
1424 | 2757 pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); |
723 | 2758 v42 = IsTerrainSlopeTooHigh(pX, _angle_y); |
1413 | 2759 is_not_on_bmodel = false; |
0 | 2760 v118 = v42; |
1413 | 2761 if ( !v97 && !v110 && !bmodel_standing_on_pid ) |
2762 is_not_on_bmodel = true; | |
0 | 2763 v43 = 1; |
2764 v44 = 1; | |
1413 | 2765 if ( bUnderwater || !is_not_on_bmodel ) |
1061 | 2766 { |
2767 pX = _angle_x; | |
2768 if ( v43 ) | |
2769 pY = _angle_y; | |
2770 } | |
2771 else | |
2772 { | |
1424 | 2773 if ( pModel && v129 > pZ ) |
1061 | 2774 v44 = 0; |
2775 if ( v118 && v119 > pZ ) | |
2776 v43 = 0; | |
2777 if ( v44 ) | |
2778 { | |
2779 pX = _angle_x; | |
2780 if ( v43 ) | |
2781 pY = _angle_y; | |
2782 } | |
2783 else if ( v43 ) | |
2784 pY = _angle_y; | |
2785 else | |
2786 { | |
1424 | 2787 pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); |
2788 if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ ) | |
1061 | 2789 { |
2790 v43 = 1; | |
2791 pX = _angle_x; | |
2792 if ( v43 ) | |
2793 pY = _angle_y; | |
2794 } | |
2795 } | |
2796 } | |
0 | 2797 if ( stru_721530.field_7C >= stru_721530.field_6C ) |
2798 { | |
1413 | 2799 if ( !is_not_on_bmodel ) |
0 | 2800 { |
723 | 2801 pX = stru_721530.normal2.x; |
2802 pY = stru_721530.normal2.y; | |
2803 } | |
2804 pZ = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
0 | 2805 break; |
2806 } | |
2807 stru_721530.field_70 += stru_721530.field_7C; | |
723 | 2808 pX = _angle_x; |
2809 pY = _angle_y; | |
0 | 2810 v45 = stru_721530.uFaceID; |
723 | 2811 pZ = v40; |
848 | 2812 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) |
141 | 2813 { |
2814 if (pParty->Invisible()) | |
2815 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
2816 | |
0 | 2817 viewparams->bRedrawGameUI = 1; |
1061 | 2818 v2 = (unsigned __int64)(58500i64 * v2) >> 16; |
1424 | 2819 pModel = (BSPModel *)58500; |
1061 | 2820 v128 = (unsigned __int64)(58500i64 * v128) >> 16; |
1424 | 2821 v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2822 ++v126; |
1424 | 2823 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2824 continue; |
2825 } | |
848 | 2826 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) |
0 | 2827 { |
295 | 2828 v56 = integer_sqrt(v2 * v2 + v128 * v128); |
0 | 2829 v118 = v56; |
1413 | 2830 v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, |
2831 _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); | |
0 | 2832 v129 = v57; |
323 | 2833 v58 = (BSPModel *)stru_5C6E00->Cos(v57); |
1424 | 2834 pModel = v58; |
0 | 2835 v59 = (signed int)v58 * (signed __int64)v56; |
2836 v122 = v59 >> 16; | |
2837 v2 = v59 >> 16; | |
323 | 2838 v60 = (BSPModel *)stru_5C6E00->Sin(v129); |
1424 | 2839 pModel = v60; |
0 | 2840 v61 = (signed int)v60 * (signed __int64)v118; |
2841 v122 = v61 >> 16; | |
2842 v128 = v61 >> 16; | |
2843 } | |
2844 else | |
2845 { | |
848 | 2846 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) |
0 | 2847 { |
2848 pParty->bFlying = 0; | |
1424 | 2849 pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; |
2850 //v127 = v46; | |
2851 pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; | |
2852 v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; | |
0 | 2853 v51 = __OFSUB__(v48, 32); |
2854 v49 = v48 == 32; | |
2855 v50 = v48 - 32 < 0; | |
1424 | 2856 v52 = pODMFace->pFacePlane.vNormal.z; |
0 | 2857 v129 = (unsigned __int8)(v50 ^ v51 | v49); |
122 | 2858 v119 = v52 < 46378; |
0 | 2859 if ( bUnderwater == 1 ) |
2860 v119 = 0; | |
1424 | 2861 if ( pODMFace->uPolygonType == POLYGON_Floor ) |
0 | 2862 { |
1424 | 2863 if ( pParty->uFallSpeed < 0 ) |
2864 pParty->uFallSpeed = 0; | |
2865 pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1; | |
2866 if ( v2 * v2 + v128 * v128 < 400 ) | |
2867 { | |
2868 v2 = 0; | |
2869 *(float *)&v128 = 0.0; | |
2870 } | |
2871 if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE)) | |
2872 { | |
2873 pParty->floor_face_pid = v45; | |
2874 v103 = pODMFace->sCogTriggeredID; | |
2875 } | |
2876 v2 = (unsigned __int64)(58500i64 * v2) >> 16; | |
2877 pModel = (BSPModel *)58500; | |
2878 v128 = (unsigned __int64)(58500i64 * v128) >> 16; | |
2879 v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; | |
2880 ++v126; | |
2881 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; | |
2882 continue; | |
0 | 2883 } |
1424 | 2884 if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// óï¸ðñÿ â ñòîëá |
0 | 2885 { |
1424 | 2886 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; |
0 | 2887 if ( stru_721530.field_64 >> 3 > v118 ) |
2888 v118 = stru_721530.field_64 >> 3; | |
1424 | 2889 v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16; |
2890 _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16; | |
0 | 2891 v54 = 0; |
2892 if ( !v119 ) | |
2893 { | |
1424 | 2894 pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z; |
2895 pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); | |
2896 v54 = pModel; | |
0 | 2897 } |
1424 | 2898 pParty->uFallSpeed += (int)v54; |
0 | 2899 v128 += _walk_speed; |
2900 v2 += v129; | |
2901 v55 = stru_721530.prolly_normal_d | |
1424 | 2902 - ((signed int)(pODMFace->pFacePlane.dist |
2903 + v122 * pODMFace->pFacePlane.vNormal.z | |
2904 + _angle_y * pODMFace->pFacePlane.vNormal.y | |
2905 + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16); | |
0 | 2906 if ( v55 > 0 ) |
2907 { | |
1424 | 2908 pX = _angle_x + (pODMFace->pFacePlane.vNormal.x * v55 >> 16); |
2909 pY = _angle_y + (pODMFace->pFacePlane.vNormal.y * v55 >> 16); | |
0 | 2910 if ( !v119 ) |
1424 | 2911 pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16); |
0 | 2912 } |
1061 | 2913 //LABEL_220: |
2914 v45 = stru_721530.uFaceID; | |
1424 | 2915 if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) |
1061 | 2916 { |
2917 pParty->floor_face_pid = v45; | |
1424 | 2918 v103 = pODMFace->sCogTriggeredID; |
1061 | 2919 } |
2920 v2 = (unsigned __int64)(58500i64 * v2) >> 16; | |
1424 | 2921 pModel = (BSPModel *)58500; |
1061 | 2922 v128 = (unsigned __int64)(58500i64 * v128) >> 16; |
1424 | 2923 v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2924 ++v126; |
1424 | 2925 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2926 continue; |
0 | 2927 } |
1424 | 2928 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; |
0 | 2929 if ( stru_721530.field_64 >> 3 > v118 ) |
2930 v118 = stru_721530.field_64 >> 3; | |
1424 | 2931 v122 = pODMFace->pFacePlane.vNormal.x; |
0 | 2932 v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16; |
1424 | 2933 pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y; |
2934 pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); | |
2935 v129 = pODMFace->pFacePlane.vNormal.z; | |
0 | 2936 v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16; |
1424 | 2937 pParty->uFallSpeed += v129; |
0 | 2938 v2 += v122; |
1424 | 2939 v128 += (int)pModel; |
0 | 2940 if ( v2 * v2 + v128 * v128 >= 400 ) |
1061 | 2941 { |
2942 v45 = stru_721530.uFaceID; | |
1424 | 2943 if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) |
1061 | 2944 { |
2945 pParty->floor_face_pid = v45; | |
1424 | 2946 v103 = pODMFace->sCogTriggeredID; |
1061 | 2947 } |
2948 v2 = (unsigned __int64)(58500i64 * v2) >> 16; | |
1424 | 2949 pModel = (BSPModel *)58500; |
1061 | 2950 v128 = (unsigned __int64)(58500i64 * v128) >> 16; |
1424 | 2951 v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2952 ++v126; |
1424 | 2953 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
1061 | 2954 continue; |
2955 } | |
0 | 2956 v2 = 0; |
1424 | 2957 pParty->uFallSpeed = 0; |
0 | 2958 *(float *)&v128 = 0.0; |
2959 } | |
2960 } | |
1061 | 2961 //LABEL_234: |
0 | 2962 v2 = (unsigned __int64)(58500i64 * v2) >> 16; |
1424 | 2963 pModel = (BSPModel *)58500; |
0 | 2964 v128 = (unsigned __int64)(58500i64 * v128) >> 16; |
1424 | 2965 v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
0 | 2966 ++v126; |
1424 | 2967 pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; |
0 | 2968 } |
2969 while ( v126 < 100 ); | |
831 | 2970 if ( bWalkSound && pParty->walk_sound_timer <= 0 ) |
0 | 2971 { |
723 | 2972 v122 = abs(pParty->vPosition.x - pX); |
2973 v126 = abs(pParty->vPosition.y - pY); | |
2974 v62 = abs(pParty->vPosition.z - pZ); | |
295 | 2975 if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) < 8 ) |
1061 | 2976 { |
2977 pAudioPlayer->_4AA258(804); | |
2978 pParty->walk_sound_timer = 64; | |
2979 } | |
2980 else | |
2981 { | |
2982 if ( v114 && (!bJumping || v101) ) | |
2983 { | |
1413 | 2984 if ( !is_not_on_bmodel |
1061 | 2985 && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) |
2986 { | |
1424 | 2987 pAudioPlayer->PlaySound(SOUND_64, 804, 1, -1, 0, 0, 0, 0); |
1061 | 2988 } |
2989 else | |
2990 { | |
1424 | 2991 //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; |
2992 //v64 = WorldPosToGridCellX(pParty->vPosition.x); | |
2993 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); | |
1398 | 2994 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0); |
1061 | 2995 } |
2996 } | |
2997 else | |
2998 { | |
2999 if ( v124 && (!bJumping || v101) ) | |
3000 { | |
1413 | 3001 if ( is_not_on_bmodel |
1061 | 3002 || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) |
3003 { | |
1424 | 3004 //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; |
3005 //v64 = WorldPosToGridCellX(pParty->vPosition.x); | |
3006 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0); | |
1398 | 3007 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0); |
1061 | 3008 } |
3009 else | |
1424 | 3010 pAudioPlayer->PlaySound(SOUND_103, 804, 1, -1, 0, 0, 0, 0); |
1061 | 3011 } |
3012 else | |
3013 { | |
3014 pAudioPlayer->_4AA258(804); | |
3015 pParty->walk_sound_timer = 64; | |
3016 } | |
3017 } | |
0 | 3018 } |
3019 } | |
3020 if ( !bJumping || v101 ) | |
569 | 3021 pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; |
3022 else | |
3023 pParty->uFlags |= PARTY_FLAGS_1_FALLING; | |
0 | 3024 v126 = WorldPosToGridCellX(pParty->vPosition.x); |
3025 v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; | |
723 | 3026 v114 = WorldPosToGridCellX(pX); |
3027 v66 = WorldPosToGridCellZ(pY) - 1; | |
1424 | 3028 pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); |
1413 | 3029 v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; |
0 | 3030 v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); |
3031 v68 = 0; | |
1413 | 3032 v69 = (~(unsigned int)v67 >> 1) & 1; |
0 | 3033 if ( v114 == v126 && v66 == v65 && v122 && v69 ) |
3034 v68 = 1; | |
1413 | 3035 if ( !is_not_on_bmodel ) |
0 | 3036 v68 = 1; |
3037 if ( v68 ) | |
3038 { | |
723 | 3039 v70 = pZ; |
3040 v71 = pX; | |
3041 v72 = pY; | |
1424 | 3042 //pParty->uFallSpeed = v121; |
723 | 3043 v73 = pZ; |
3044 pParty->vPosition.x = pX; | |
3045 pParty->vPosition.y = pY; | |
3046 pParty->vPosition.z = pZ; | |
0 | 3047 pParty->field_6F0 = v113; |
723 | 3048 if ( pZ > 8160 ) |
0 | 3049 { |
3050 v73 = 8160; | |
3051 pParty->uFallStartY = 8160; | |
3052 pParty->vPosition.z = 8160; | |
3053 } | |
3054 if ( !v103 | |
3055 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71) | |
3056 && pParty->vPosition.y == v72 | |
3057 && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) ) | |
3058 { | |
3059 if ( v73 < v111 ) | |
3060 { | |
3061 pParty->uFallSpeed = 0; | |
3062 v73 = v105; | |
3063 pParty->vPosition.z = v105; | |
1424 | 3064 if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(ïàäåíèå íà çåìëþ ñ âûñîòû) |
0 | 3065 { |
569 | 3066 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) |
3067 { | |
3068 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
0 | 3069 } |
3070 else | |
3071 { | |
1424 | 3072 for ( uint i = 1; i <= 4; ++i ) |
0 | 3073 { |
1424 | 3074 v110 = pPlayers[i]->GetMaxHealth(); |
3075 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, | |
1036 | 3076 DMGT_PHISYCAL); |
1424 | 3077 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); |
3078 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | |
0 | 3079 } |
3080 v73 = pParty->vPosition.z; | |
3081 } | |
3082 } | |
3083 pParty->uFallStartY = v70; | |
3084 } | |
3085 if ( v102 && v73 < v109 ) | |
3086 { | |
3087 if ( (signed int)(pParty->uPartyHeight + v73) >= v109 ) | |
3088 { | |
3089 pParty->vPosition.z = v109 - pParty->uPartyHeight - 1; | |
3090 pParty->field_6F0 = v109 - pParty->uPartyHeight - 1; | |
3091 } | |
3092 } | |
569 | 3093 pParty->uFlags &= ~0x204; |
0 | 3094 } |
3095 return; | |
3096 } | |
3097 v76 = pParty->bFlying; | |
1424 | 3098 if ( pParty->bFlying || v101 == 0 || bWaterWalk || !pModel ) |
0 | 3099 v77 = 1; |
3100 else | |
3101 v77 = v122 != 0; | |
3102 v114 = 0; | |
3103 if ( !pParty->bFlying && v101 != 0 && !bWaterWalk ) | |
3104 { | |
1424 | 3105 if ( pModel ) |
0 | 3106 { |
3107 v78 = v69 != 0; | |
1061 | 3108 } |
3109 else | |
3110 { | |
3111 v114 = 1; | |
3112 v78 = 1; | |
3113 } | |
3114 } | |
3115 else | |
3116 v78 = 1; | |
3117 //LABEL_306: | |
0 | 3118 if ( v77 ) |
3119 { | |
723 | 3120 pParty->vPosition.x = pX; |
0 | 3121 } |
3122 if ( v78 ) | |
3123 { | |
723 | 3124 pParty->vPosition.y = pY; |
1061 | 3125 } |
3126 if ( v78 || v77) | |
3127 { | |
0 | 3128 if ( bWaterWalk ) |
3129 { | |
569 | 3130 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; |
1167 | 3131 //v79 = 20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 6180178; |
3132 //*(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; | |
3133 v79 = (int)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119]; | |
569 | 3134 *(short *)v79 |= 1u; |
0 | 3135 if ( !v122 || !v69 ) |
3136 { | |
3137 if ( !v76 ) | |
3138 { | |
3139 v80 = *(short *)v79; | |
569 | 3140 pParty->uFlags |= PARTY_FLAGS_1_STANDING_ON_WATER; |
0 | 3141 *(short *)v79 = v80 & 0xFFFE; |
3142 } | |
3143 } | |
3144 } | |
1061 | 3145 } |
3146 else if ( bWalkSound && pParty->walk_sound_timer <= 0 ) | |
0 | 3147 { |
3148 pAudioPlayer->_4AA258(804); | |
831 | 3149 pParty->walk_sound_timer = 64; |
0 | 3150 } |
1061 | 3151 //LABEL_318: |
723 | 3152 v81 = pZ; |
3153 v82 = pZ; | |
3154 pParty->vPosition.z = pZ; | |
3155 if ( pZ > 8160 ) | |
0 | 3156 { |
3157 v82 = 8160; | |
3158 pParty->uFallStartY = 8160; | |
3159 pParty->vPosition.z = 8160; | |
3160 } | |
3161 LOWORD(pParty->uFlags) &= 0xFDFBu; | |
1424 | 3162 //pParty->uFallSpeed = v121; |
0 | 3163 pParty->field_6F0 = v113; |
1424 | 3164 if ( v114 )//party stand to the water(ãðóïïà ñòîèò íà âîäå) |
3165 { | |
3166 pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1); | |
3167 if ( pParty->vPosition.z <= pTerrainHeight + 1 )//ïîëîæåíèå ãðóïïû âñåãäà +1 | |
3168 pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE; | |
0 | 3169 } |
3170 if ( !v103 | |
723 | 3171 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX) |
3172 && pParty->vPosition.y == pY | |
0 | 3173 && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) ) |
3174 { | |
3175 if ( v82 < v111 ) | |
3176 { | |
3177 v82 = v105; | |
3178 pParty->uFallSpeed = 0; | |
3179 pParty->vPosition.z = v105; | |
1424 | 3180 if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )//Fall to the water(ïàäåíèå íà âîäó ñ âûñîòû) |
0 | 3181 { |
569 | 3182 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) |
3183 { | |
3184 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
0 | 3185 } |
3186 else | |
3187 { | |
1424 | 3188 for ( uint i = 1; i <= 4; ++i ) |
0 | 3189 { |
1424 | 3190 v110 = pPlayers[i]->GetMaxHealth(); |
3191 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, | |
1036 | 3192 DMGT_PHISYCAL); |
1424 | 3193 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); |
3194 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | |
0 | 3195 } |
3196 v82 = pParty->vPosition.z; | |
3197 } | |
3198 } | |
3199 pParty->uFallStartY = v81; | |
3200 } | |
3201 if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 ) | |
3202 { | |
3203 pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1; | |
3204 pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1; | |
3205 } | |
3206 } | |
3207 } | |
3208 | |
3209 //----- (0047531C) -------------------------------------------------------- | |
3210 bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10) | |
3211 { | |
3212 BLVFace *v10; // ebx@1 | |
3213 int v11; // ST1C_4@3 | |
3214 int v12; // edi@3 | |
3215 int v13; // esi@3 | |
3216 int v14; // edi@4 | |
3217 signed __int64 v15; // qtt@6 | |
3218 __int16 v16; // si@7 | |
3219 int *v18; // [sp+Ch] [bp-Ch]@1 | |
3220 int v19; // [sp+10h] [bp-8h]@1 | |
3221 int a7a; // [sp+30h] [bp+18h]@7 | |
3222 int a9b; // [sp+38h] [bp+20h]@3 | |
3223 int a9a; // [sp+38h] [bp+20h]@3 | |
3224 int a10b; // [sp+3Ch] [bp+24h]@3 | |
3225 signed int a10a; // [sp+3Ch] [bp+24h]@4 | |
3226 int a10c; // [sp+3Ch] [bp+24h]@5 | |
3227 | |
3228 v10 = a9; | |
3229 v18 = a2; | |
3230 v19 = a1; | |
3231 if ( a10 && BYTE3(a9->uAttributes) & 0x20 ) | |
3232 return 0; | |
3233 v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16; | |
3234 a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16; | |
3235 a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16; | |
3236 v12 = v11 + a9b + a10b; | |
3237 a9a = v11 + a9b + a10b; | |
3238 v13 = (a1 << 16) | |
3239 - a3 * v10->pFacePlane_old.vNormal.x | |
3240 - a4 * v10->pFacePlane_old.vNormal.y | |
3241 - a5 * v10->pFacePlane_old.vNormal.z | |
3242 - v10->pFacePlane_old.dist; | |
3243 if ( abs((a1 << 16) | |
3244 - a3 * v10->pFacePlane_old.vNormal.x | |
3245 - a4 * v10->pFacePlane_old.vNormal.y | |
3246 - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 ) | |
3247 { | |
3248 a10c = abs(v13) >> 14; | |
3249 if ( a10c > abs(v12) ) | |
3250 return 0; | |
3251 LODWORD(v15) = v13 << 16; | |
3252 HIDWORD(v15) = v13 >> 16; | |
3253 v14 = v19; | |
3254 a10a = v15 / a9a; | |
3255 } | |
3256 else | |
3257 { | |
3258 a10a = 0; | |
3259 v14 = abs(v13) >> 16; | |
3260 } | |
3261 v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16); | |
3262 LOWORD(a7a) = (short)a3 | |
3263 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16) | |
3264 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16); | |
3265 HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16); | |
3266 if ( !sub_475665( | |
3267 v10, | |
3268 a7a, | |
3269 (short)a5 | |
3270 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16) | |
3271 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) ) | |
3272 return 0; | |
3273 *v18 = a10a >> 16; | |
3274 if ( a10a >> 16 < 0 ) | |
3275 *v18 = 0; | |
3276 return 1; | |
3277 } | |
3278 | |
3279 //----- (004754BF) -------------------------------------------------------- | |
3280 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) | |
3281 { | |
3282 BLVFace *v11; // ebx@1 | |
3283 int v12; // ST1C_4@3 | |
3284 int v13; // edi@3 | |
3285 int v14; // esi@3 | |
3286 int v15; // edi@4 | |
3287 signed __int64 v16; // qtt@6 | |
3288 __int16 v17; // si@7 | |
3289 int *v19; // [sp+Ch] [bp-Ch]@1 | |
3290 int v20; // [sp+10h] [bp-8h]@1 | |
3291 int a7a; // [sp+30h] [bp+18h]@7 | |
3292 int a1b; // [sp+38h] [bp+20h]@3 | |
3293 int a1a; // [sp+38h] [bp+20h]@3 | |
3294 int a11b; // [sp+40h] [bp+28h]@3 | |
3295 signed int a11a; // [sp+40h] [bp+28h]@4 | |
3296 int a11c; // [sp+40h] [bp+28h]@5 | |
3297 | |
3298 v11 = a9; | |
3299 v19 = a2; | |
3300 v20 = a1; | |
3301 if ( a11 && BYTE3(a9->uAttributes) & 0x20 ) | |
3302 return 0; | |
3303 v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16; | |
3304 a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16; | |
3305 a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16; | |
3306 v13 = v12 + a1b + a11b; | |
3307 a1a = v12 + a1b + a11b; | |
3308 v14 = (a1 << 16) | |
3309 - a3 * v11->pFacePlane_old.vNormal.x | |
3310 - a4 * v11->pFacePlane_old.vNormal.y | |
3311 - a5 * v11->pFacePlane_old.vNormal.z | |
3312 - v11->pFacePlane_old.dist; | |
3313 if ( abs((a1 << 16) | |
3314 - a3 * v11->pFacePlane_old.vNormal.x | |
3315 - a4 * v11->pFacePlane_old.vNormal.y | |
3316 - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 ) | |
3317 { | |
3318 a11c = abs(v14) >> 14; | |
3319 if ( a11c > abs(v13) ) | |
3320 return 0; | |
3321 LODWORD(v16) = v14 << 16; | |
3322 HIDWORD(v16) = v14 >> 16; | |
3323 v15 = v20; | |
3324 a11a = v16 / a1a; | |
3325 } | |
3326 else | |
3327 { | |
3328 a11a = 0; | |
3329 v15 = abs(v14) >> 16; | |
3330 } | |
3331 v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16); | |
3332 LOWORD(a7a) = (short)a3 | |
3333 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16) | |
3334 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16); | |
3335 HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16); | |
3336 if ( !sub_4759C9( | |
3337 v11, | |
3338 a10, | |
3339 a7a, | |
3340 (short)a5 | |
3341 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16) | |
3342 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) ) | |
3343 return 0; | |
3344 *v19 = a11a >> 16; | |
3345 if ( a11a >> 16 < 0 ) | |
3346 *v19 = 0; | |
3347 return 1; | |
3348 } | |
3349 | |
3350 //----- (00475665) -------------------------------------------------------- | |
3351 signed int __thiscall sub_475665(BLVFace *_this, int a2, __int16 a3) | |
3352 { | |
3353 unsigned int v3; // eax@1 | |
3354 Vec3_short_ *v4; // edx@3 | |
3355 signed int v5; // eax@4 | |
3356 int v6; // esi@4 | |
3357 signed int v7; // eax@7 | |
3358 Vec3_short_ *v8; // edx@8 | |
3359 signed int v9; // eax@9 | |
3360 int v10; // esi@9 | |
3361 signed int v11; // eax@11 | |
3362 Vec3_short_ *v12; // edx@12 | |
3363 signed int v13; // eax@13 | |
3364 int v14; // esi@13 | |
3365 int v15; // esi@14 | |
3366 bool v16; // edi@14 | |
3367 int v17; // ecx@16 | |
3368 signed int v18; // edx@16 | |
3369 int v19; // eax@17 | |
3370 signed int v20; // ebx@18 | |
3371 int v21; // edi@20 | |
3372 signed int v22; // ST14_4@22 | |
3373 signed __int64 v23; // qtt@22 | |
3374 signed int result; // eax@25 | |
3375 int v25; // [sp+14h] [bp-10h]@14 | |
3376 int v26; // [sp+1Ch] [bp-8h]@2 | |
3377 signed int v27; // [sp+20h] [bp-4h]@2 | |
3378 signed int v28; // [sp+30h] [bp+Ch]@2 | |
3379 signed int v29; // [sp+30h] [bp+Ch]@7 | |
3380 signed int v30; // [sp+30h] [bp+Ch]@11 | |
3381 signed int v31; // [sp+30h] [bp+Ch]@14 | |
3382 | |
3383 v3 = _this->uAttributes; | |
3384 if ( BYTE1(v3) & 1 ) | |
3385 { | |
3386 v28 = 0; | |
3387 v26 = (signed __int16)a2; | |
3388 v27 = SHIWORD(a2); | |
3389 if ( _this->uNumVertices ) | |
3390 { | |
3391 v4 = pIndoor->pVertices; | |
3392 do | |
3393 { | |
3394 v5 = v28; | |
3395 v6 = 2 * v28; | |
3396 word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x; | |
3397 word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y; | |
3398 word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1] | |
3399 + v4[_this->pVertexIDs[v5 + 1]].x; | |
3400 word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y; | |
3401 } | |
3402 while ( v28 < _this->uNumVertices ); | |
3403 } | |
3404 } | |
3405 else | |
3406 { | |
3407 if ( BYTE1(v3) & 2 ) | |
3408 { | |
3409 v26 = (signed __int16)a2; | |
3410 v7 = a3; | |
3411 v29 = 0; | |
3412 v27 = v7; | |
3413 if ( _this->uNumVertices ) | |
3414 { | |
3415 v8 = pIndoor->pVertices; | |
3416 do | |
3417 { | |
3418 v9 = v29; | |
3419 v10 = 2 * v29; | |
3420 word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x; | |
3421 word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z; | |
3422 word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x; | |
3423 word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z; | |
3424 } | |
3425 while ( v29 < _this->uNumVertices ); | |
3426 } | |
3427 } | |
3428 else | |
3429 { | |
3430 v26 = SHIWORD(a2); | |
3431 v11 = a3; | |
3432 v30 = 0; | |
3433 v27 = v11; | |
3434 if ( _this->uNumVertices ) | |
3435 { | |
3436 v12 = pIndoor->pVertices; | |
3437 do | |
3438 { | |
3439 v13 = v30; | |
3440 v14 = 2 * v30; | |
3441 word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y; | |
3442 word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z; | |
3443 word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y; | |
3444 word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z; | |
3445 } | |
3446 while ( v30 < _this->uNumVertices ); | |
3447 } | |
3448 } | |
3449 } | |
3450 v15 = 2 * _this->uNumVertices; | |
3451 v31 = 0; | |
3452 word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0]; | |
3453 word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0]; | |
3454 v25 = 0; | |
3455 v16 = word_720B40_intercepts_zs[0] >= v27; | |
3456 if ( v15 <= 0 ) | |
1418 | 3457 return 0; |
0 | 3458 do |
3459 { | |
3460 if ( v31 >= 2 ) | |
3461 break; | |
3462 v17 = v25; | |
3463 v18 = word_720B40_intercepts_zs[v25 + 1]; | |
1110 | 3464 if ( v16 ^ (v18 >= v27) ) |
0 | 3465 { |
3466 v19 = word_720C10_intercepts_xs[v17 + 1]; | |
3467 if ( v19 >= v26 ) | |
3468 v20 = 0; | |
3469 else | |
3470 v20 = 2; | |
1110 | 3471 v21 = v20 | (word_720C10_intercepts_xs[v17] < v26); |
0 | 3472 if ( v21 != 3 ) |
3473 { | |
3474 if ( !v21 | |
3475 || (v22 = v19 - word_720C10_intercepts_xs[v17], | |
3476 LODWORD(v23) = v22 << 16, | |
3477 HIDWORD(v23) = v22 >> 16, | |
3478 word_720C10_intercepts_xs[v17] | |
3479 + ((signed int)(((unsigned __int64)(v23 | |
3480 / (v18 - word_720B40_intercepts_zs[v17]) | |
3481 * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16) | |
3482 + 32768) >> 16) >= v26) ) | |
3483 ++v31; | |
3484 } | |
3485 } | |
3486 ++v25; | |
3487 v16 = v18 >= v27; | |
3488 } | |
3489 while ( v25 < v15 ); | |
3490 result = 1; | |
3491 if ( v31 != 1 ) | |
3492 result = 0; | |
3493 return result; | |
3494 } | |
3495 | |
3496 //----- (004759C9) -------------------------------------------------------- | |
3497 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4) | |
3498 { | |
3499 unsigned int v4; // eax@1 | |
3500 int v5; // edx@4 | |
3501 __int16 v6; // si@4 | |
3502 int v7; // edx@9 | |
3503 __int16 v8; // si@9 | |
3504 int v9; // edx@13 | |
3505 __int16 v10; // si@13 | |
3506 int v11; // esi@14 | |
3507 bool v12; // edi@14 | |
3508 int v13; // ecx@16 | |
3509 signed int v14; // edx@16 | |
3510 int v15; // eax@17 | |
3511 signed int v16; // ebx@18 | |
3512 int v17; // edi@20 | |
3513 signed int v18; // ST14_4@22 | |
3514 signed __int64 v19; // qtt@22 | |
3515 bool result; // eax@25 | |
3516 int v21; // [sp+14h] [bp-10h]@14 | |
3517 signed int v22; // [sp+18h] [bp-Ch]@1 | |
3518 int v23; // [sp+1Ch] [bp-8h]@2 | |
3519 signed int v24; // [sp+20h] [bp-4h]@2 | |
3520 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3 | |
3521 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8 | |
3522 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12 | |
3523 signed int a4d; // [sp+30h] [bp+Ch]@14 | |
3524 | |
3525 v4 = a1->uAttributes; | |
3526 v22 = 0; | |
3527 if ( BYTE1(v4) & 1 ) | |
3528 { | |
3529 v23 = (signed __int16)a3; | |
3530 v24 = SHIWORD(a3); | |
3531 if ( a1->uNumVertices ) | |
3532 { | |
3533 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
3534 do | |
3535 { | |
3536 v5 = 2 * v22; | |
3537 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x); | |
3538 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y); | |
3539 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x); | |
3540 word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y); | |
3541 ++v22; | |
3542 } | |
3543 while ( v22 < a1->uNumVertices ); | |
3544 } | |
3545 } | |
3546 else | |
3547 { | |
3548 if ( BYTE1(v4) & 2 ) | |
3549 { | |
3550 v23 = (signed __int16)a3; | |
3551 v24 = a4; | |
3552 if ( a1->uNumVertices ) | |
3553 { | |
3554 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
3555 do | |
3556 { | |
3557 v7 = 2 * v22; | |
3558 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x); | |
3559 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z); | |
3560 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x); | |
3561 word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z); | |
3562 ++v22; | |
3563 } | |
3564 while ( v22 < a1->uNumVertices ); | |
3565 } | |
3566 } | |
3567 else | |
3568 { | |
3569 v23 = SHIWORD(a3); | |
3570 v24 = a4; | |
3571 if ( a1->uNumVertices ) | |
3572 { | |
3573 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
3574 do | |
3575 { | |
3576 v9 = 2 * v22; | |
3577 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y); | |
3578 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z); | |
3579 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y); | |
3580 word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z); | |
3581 ++v22; | |
3582 } | |
3583 while ( v22 < a1->uNumVertices ); | |
3584 } | |
3585 } | |
3586 } | |
3587 v11 = 2 * a1->uNumVertices; | |
3588 a4d = 0; | |
3589 word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0]; | |
3590 word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0]; | |
3591 v21 = 0; | |
3592 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; | |
3593 if ( v11 <= 0 ) | |
1418 | 3594 return 0; |
0 | 3595 do |
3596 { | |
3597 if ( a4d >= 2 ) | |
3598 break; | |
3599 v13 = v21; | |
3600 v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1]; | |
1110 | 3601 if ( v12 ^ (v14 >= v24) ) |
0 | 3602 { |
3603 v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1]; | |
3604 if ( v15 >= v23 ) | |
3605 v16 = 0; | |
3606 else | |
3607 v16 = 2; | |
1110 | 3608 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23); |
0 | 3609 if ( v17 != 3 ) |
3610 { | |
3611 if ( !v17 | |
3612 || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13], | |
3613 LODWORD(v19) = v18 << 16, | |
3614 HIDWORD(v19) = v18 >> 16, | |
3615 word_720A70_intercepts_xs_plus_xs[v13] | |
3616 + ((signed int)(((unsigned __int64)(v19 | |
3617 / (v14 - word_7209A0_intercepts_ys_plus_ys[v13]) | |
3618 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16) | |
3619 + 32768) >> 16) >= v23) ) | |
3620 ++a4d; | |
3621 } | |
3622 } | |
3623 ++v21; | |
3624 v12 = v14 >= v24; | |
3625 } | |
3626 while ( v21 < v11 ); | |
3627 result = 1; | |
3628 if ( a4d != 1 ) | |
3629 result = 0; | |
3630 return result; | |
3631 } | |
3632 | |
3633 //----- (00475D85) -------------------------------------------------------- | |
3634 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4) | |
3635 { | |
3636 BLVFace *v4; // ebx@1 | |
3637 int v5; // ST24_4@2 | |
3638 int v6; // ST28_4@2 | |
3639 int v7; // edi@2 | |
3640 int v8; // eax@5 | |
3641 signed int v9; // esi@5 | |
3642 signed __int64 v10; // qtt@10 | |
3643 Vec3_int_ *v11; // esi@11 | |
3644 int v12; // ST14_4@11 | |
3645 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1 | |
3646 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1 | |
3647 int v16; // [sp+18h] [bp-Ch]@2 | |
3648 int v17; // [sp+20h] [bp-4h]@10 | |
3649 int a4b; // [sp+30h] [bp+Ch]@2 | |
3650 int a4c; // [sp+30h] [bp+Ch]@9 | |
3651 signed int a4a; // [sp+30h] [bp+Ch]@10 | |
3652 | |
3653 v4 = a4; | |
3654 v15 = a2; | |
3655 v14 = a1; | |
3656 if ( BYTE3(a4->uAttributes) & 0x20 | |
3657 || (v5 = (unsigned __int64)(a2->x * (signed __int64)a4->pFacePlane_old.vNormal.x) >> 16, | |
3658 a4b = (unsigned __int64)(a2->y * (signed __int64)a4->pFacePlane_old.vNormal.y) >> 16, | |
3659 v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16, | |
3660 v7 = v5 + v6 + a4b, | |
3661 (v16 = v5 + v6 + a4b) == 0) | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
675
diff
changeset
|
3662 || v7 > 0 && !v4->Portal()) |
0 | 3663 return 0; |
3664 v8 = v4->pFacePlane_old.vNormal.z * a1->z; | |
3665 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x); | |
3666 if ( v7 <= 0 ) | |
3667 { | |
3668 if ( v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0 ) | |
3669 return 0; | |
3670 } | |
3671 else | |
3672 { | |
3673 if ( v9 < 0 ) | |
3674 return 0; | |
3675 } | |
3676 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14; | |
3677 if ( a4c > abs(v7) | |
3678 || (LODWORD(v10) = v9 << 16, HIDWORD(v10) = v9 >> 16, a4a = v10 / v16, v17 = v10 / v16, v17 > *a3 << 16) | |
3679 || (v11 = v14, | |
3680 LOWORD(v12) = LOWORD(v14->x) | |
3681 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->x) >> 16) + 32768) >> 16), | |
3682 HIWORD(v12) = LOWORD(v11->y) | |
3683 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->y) >> 16) + 32768) >> 16), | |
3684 !sub_475665( | |
3685 v4, | |
3686 v12, | |
3687 LOWORD(v11->z) + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->z) >> 16) + 32768) >> 16))) ) | |
3688 return 0; | |
3689 *a3 = a4a >> 16; | |
3690 return 1; | |
3691 } | |
3692 | |
3693 //----- (00475F30) -------------------------------------------------------- | |
3694 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) | |
3695 { | |
3696 BLVFace *v9; // ebx@1 | |
3697 int v10; // ST20_4@2 | |
3698 int v11; // ST28_4@2 | |
3699 int v12; // ST24_4@2 | |
3700 char v13; // zf@2 | |
3701 int v14; // edi@2 | |
3702 int v15; // eax@5 | |
3703 signed int v16; // esi@5 | |
3704 int v17; // ST20_4@9 | |
3705 signed __int64 v18; // qtt@10 | |
3706 int v19; // ST14_4@11 | |
3707 int *v21; // [sp+14h] [bp-10h]@1 | |
3708 int v22; // [sp+1Ch] [bp-8h]@2 | |
3709 int v23; // [sp+1Ch] [bp-8h]@10 | |
3710 signed int v24; // [sp+20h] [bp-4h]@10 | |
3711 | |
3712 v9 = a2; | |
3713 v21 = a1; | |
3714 if ( BYTE3(a2->uAttributes) & 0x20 | |
3715 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, | |
3716 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, | |
3717 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, | |
3718 v13 = v10 + v12 + v11 == 0, | |
3719 v14 = v10 + v12 + v11, | |
3720 v22 = v10 + v12 + v11, | |
3721 v13) | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
675
diff
changeset
|
3722 || v14 > 0 && !a2->Portal()) |
0 | 3723 return 0; |
3724 v15 = a4 * a2->pFacePlane_old.vNormal.y; | |
3725 v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z); | |
3726 if ( v14 <= 0 ) | |
3727 { | |
3728 if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 ) | |
3729 return 0; | |
3730 } | |
3731 else | |
3732 { | |
3733 if ( v16 < 0 ) | |
3734 return 0; | |
3735 } | |
3736 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; | |
3737 if ( v17 > abs(v14) | |
3738 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16) | |
3739 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), | |
3740 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), | |
3741 !sub_4759C9( | |
3742 v9, | |
3743 a9, | |
3744 v19, | |
3745 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) ) | |
3746 return 0; | |
3747 *v21 = v24 >> 16; | |
3748 return 1; | |
3749 } | |
3750 | |
3751 //----- (004760D5) -------------------------------------------------------- | |
3752 PartyAction ActionQueue::Next() | |
3753 { | |
3754 if (!uNumActions) | |
3755 return PARTY_INVALID; | |
3756 | |
3757 auto result = pActions[0]; | |
3758 for (unsigned int i = 0; i < uNumActions - 1; ++i) | |
3759 pActions[i] = pActions[i + 1]; | |
3760 --uNumActions; | |
3761 | |
3762 return result; | |
3763 } | |
3764 | |
3765 //----- (004775ED) -------------------------------------------------------- | |
3766 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2) | |
3767 { | |
3768 char *v2; // edi@1 | |
3769 int v3; // eax@1 | |
3770 char *v4; // edx@2 | |
3771 char *v5; // esi@3 | |
3772 double v6; // st7@6 | |
3773 signed __int64 v7; // ST84_8@6 | |
3774 double v8; // ST0C_8@6 | |
3775 int v9; // esi@6 | |
3776 double v10; // ST44_8@6 | |
3777 int v11; // ecx@6 | |
3778 double v12; // ST34_8@6 | |
3779 int v13; // ecx@6 | |
3780 double v14; // ST14_8@6 | |
3781 double v15; // st7@8 | |
3782 unsigned int v16; // ecx@8 | |
3783 signed __int64 v17; // ST64_8@8 | |
3784 double v18; // ST24_8@8 | |
3785 int v19; // edi@8 | |
3786 double v20; // ST3C_8@8 | |
3787 int v21; // ecx@8 | |
3788 double v22; // ST2C_8@8 | |
3789 int v23; // ST9C_4@8 | |
3790 double v24; // ST1C_8@8 | |
3791 int *v25; // edi@8 | |
3792 int v26; // esi@8 | |
3793 int *v27; // edi@10 | |
3794 int v28; // esi@10 | |
3795 int result; // eax@12 | |
3796 __int64 v30; // [sp+A8h] [bp-30h]@8 | |
3797 float v31; // [sp+B0h] [bp-28h]@6 | |
3798 float v32; // [sp+B4h] [bp-24h]@6 | |
3799 int v33; // [sp+B8h] [bp-20h]@6 | |
3800 int v34; // [sp+BCh] [bp-1Ch]@2 | |
3801 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1 | |
3802 float v36; // [sp+C4h] [bp-14h]@6 | |
3803 int v37; // [sp+C8h] [bp-10h]@6 | |
3804 int v38; // [sp+CCh] [bp-Ch]@1 | |
3805 float v39; // [sp+D0h] [bp-8h]@6 | |
3806 int *v40; // [sp+D4h] [bp-4h]@2 | |
3807 | |
1390 | 3808 v2 = (char *)&this->field_64[4 * this->uNumVertices]; |
0 | 3809 v38 = 0; |
1390 | 3810 *(int *)v2 = this->field_64[0]; |
0 | 3811 v2 += 4; |
1390 | 3812 *(int *)v2 = this->field_64[1]; |
0 | 3813 v2 += 4; |
1390 | 3814 *(int *)v2 = this->field_64[2]; |
3815 *((int *)v2 + 1) = this->field_64[3]; | |
3816 v3 = this->uNumVertices; | |
0 | 3817 v35 = this; |
3818 if ( v3 > 0 ) | |
3819 { | |
1390 | 3820 v40 = &this->field_64[20]; |
3821 v4 = (char *)&this->field_64[3] + 3; | |
0 | 3822 v34 = v3; |
3823 while ( 1 ) | |
3824 { | |
3825 v5 = v4 - 15; | |
3826 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) | |
1418 | 3827 { |
3828 v4 += 16; | |
3829 --v34; | |
3830 if ( !v34 ) | |
3831 return this->uNumVertices = v38; | |
3832 continue; | |
3833 } | |
0 | 3834 if ( *(float *)v5 <= (double)a2 ) |
1418 | 3835 { |
3836 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
3837 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; | |
3838 v36 = v6; | |
3839 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); | |
3840 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); | |
3841 *(float *)&v37 = (double)v7 * v6; | |
3842 v8 = *(float *)&v37 + 6.7553994e15; | |
3843 v9 = (unsigned __int8)*v4; | |
3844 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
3845 v10 = *(float *)&v37 + 6.7553994e15; | |
3846 v11 = (unsigned __int8)*(v4 - 2); | |
3847 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); | |
3848 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; | |
3849 v12 = v39 + 6.7553994e15; | |
3850 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); | |
3851 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
3852 v14 = v39 + 6.7553994e15; | |
3853 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); | |
3854 //this = v35; | |
3855 v5 = (char *)&v30 + 4; | |
3856 } | |
3857 else if ( *(float *)(v4 + 1) <= (double)a2 ) | |
0 | 3858 { |
3859 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
3860 v16 = (unsigned __int8)*v4; | |
3861 HIDWORD(v30) = LODWORD(a2); | |
3862 v17 = (unsigned __int8)v4[16] - v16; | |
3863 v36 = v15; | |
3864 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11); | |
3865 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7); | |
3866 v39 = (double)v17 * v15; | |
3867 v18 = v39 + 6.7553994e15; | |
3868 v19 = (unsigned __int8)*v4; | |
3869 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
3870 v20 = v39 + 6.7553994e15; | |
3871 v21 = (unsigned __int8)*(v4 - 2); | |
3872 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1); | |
3873 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36; | |
3874 v22 = v39 + 6.7553994e15; | |
3875 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2); | |
3876 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
3877 v24 = v39 + 6.7553994e15; | |
3878 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8); | |
3879 v25 = v40; | |
3880 *v40 = *(int *)v5; | |
3881 v26 = (int)(v5 + 4); | |
3882 ++v25; | |
3883 *v25 = *(int *)v26; | |
3884 v26 += 4; | |
3885 ++v25; | |
3886 ++v38; | |
3887 v40 += 4; | |
3888 *v25 = *(int *)v26; | |
3889 v25[1] = *(int *)(v26 + 4); | |
1418 | 3890 v5 = (char *)&v30 + 4; |
0 | 3891 } |
3892 v27 = v40; | |
3893 ++v38; | |
3894 *v40 = *(int *)v5; | |
3895 v28 = (int)(v5 + 4); | |
3896 ++v27; | |
3897 *v27 = *(int *)v28; | |
3898 v28 += 4; | |
3899 ++v27; | |
3900 v40 += 4; | |
3901 *v27 = *(int *)v28; | |
3902 v27[1] = *(int *)(v28 + 4); | |
3903 v4 += 16; | |
3904 --v34; | |
3905 if ( !v34 ) | |
1418 | 3906 return this->uNumVertices = v38; |
0 | 3907 } |
1418 | 3908 } |
1390 | 3909 return this->uNumVertices = v38; |
0 | 3910 } |
3911 | |
3912 //----- (00477927) -------------------------------------------------------- | |
3913 int stru6_stru1_indoor_sw_billboard::_477927(float a2) | |
3914 { | |
3915 char *v2; // edi@1 | |
3916 int v3; // eax@1 | |
3917 char *v4; // edx@2 | |
3918 char *v5; // esi@3 | |
3919 double v6; // st7@6 | |
3920 signed __int64 v7; // ST84_8@6 | |
3921 double v8; // ST0C_8@6 | |
3922 int v9; // esi@6 | |
3923 double v10; // ST44_8@6 | |
3924 int v11; // ecx@6 | |
3925 double v12; // ST34_8@6 | |
3926 int v13; // ecx@6 | |
3927 double v14; // ST14_8@6 | |
3928 double v15; // st7@8 | |
3929 unsigned int v16; // ecx@8 | |
3930 signed __int64 v17; // ST64_8@8 | |
3931 double v18; // ST24_8@8 | |
3932 int v19; // edi@8 | |
3933 double v20; // ST3C_8@8 | |
3934 int v21; // ecx@8 | |
3935 double v22; // ST2C_8@8 | |
3936 int v23; // ST9C_4@8 | |
3937 double v24; // ST1C_8@8 | |
3938 int *v25; // edi@8 | |
3939 int v26; // esi@8 | |
3940 int *v27; // edi@10 | |
3941 int v28; // esi@10 | |
3942 int result; // eax@12 | |
3943 __int64 v30; // [sp+A8h] [bp-30h]@8 | |
3944 float v31; // [sp+B0h] [bp-28h]@6 | |
3945 float v32; // [sp+B4h] [bp-24h]@6 | |
3946 int v33; // [sp+B8h] [bp-20h]@6 | |
3947 int v34; // [sp+BCh] [bp-1Ch]@2 | |
3948 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1 | |
3949 float v36; // [sp+C4h] [bp-14h]@6 | |
3950 int v37; // [sp+C8h] [bp-10h]@6 | |
3951 int v38; // [sp+CCh] [bp-Ch]@1 | |
3952 float v39; // [sp+D0h] [bp-8h]@6 | |
3953 int *v40; // [sp+D4h] [bp-4h]@2 | |
3954 | |
1390 | 3955 v2 = (char *)&this->field_64[4 * this->uNumVertices]; |
0 | 3956 v38 = 0; |
1390 | 3957 *(int *)v2 = this->field_64[0]; |
0 | 3958 v2 += 4; |
1390 | 3959 *(int *)v2 = this->field_64[1]; |
0 | 3960 v2 += 4; |
1390 | 3961 *(int *)v2 = this->field_64[2]; |
3962 *((int *)v2 + 1) = this->field_64[3]; | |
3963 v3 = this->uNumVertices; | |
0 | 3964 v35 = this; |
3965 if ( v3 > 0 ) | |
3966 { | |
1390 | 3967 v40 = &this->field_64[20]; |
3968 v4 = (char *)&this->field_64[3] + 3; | |
0 | 3969 v34 = v3; |
3970 while ( 1 ) | |
3971 { | |
3972 v5 = v4 - 15; | |
3973 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) | |
1418 | 3974 { |
3975 v4 += 16; | |
3976 --v34; | |
3977 if ( !v34 ) | |
3978 return this->uNumVertices = v38; | |
3979 continue; | |
3980 } | |
0 | 3981 if ( *(float *)v5 >= (double)a2 ) |
1418 | 3982 { |
3983 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
3984 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; | |
3985 v36 = v6; | |
3986 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); | |
3987 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); | |
3988 *(float *)&v37 = (double)v7 * v6; | |
3989 v8 = *(float *)&v37 + 6.7553994e15; | |
3990 v9 = (unsigned __int8)*v4; | |
3991 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
3992 v10 = *(float *)&v37 + 6.7553994e15; | |
3993 v11 = (unsigned __int8)*(v4 - 2); | |
3994 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); | |
3995 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; | |
3996 v12 = v39 + 6.7553994e15; | |
3997 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); | |
3998 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
3999 v14 = v39 + 6.7553994e15; | |
4000 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); | |
4001 //this = v35; | |
4002 v5 = (char *)&v30 + 4; | |
4003 } | |
4004 else if ( *(float *)(v4 + 1) >= (double)a2 ) | |
0 | 4005 { |
4006 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
4007 v16 = (unsigned __int8)*v4; | |
4008 HIDWORD(v30) = LODWORD(a2); | |
4009 v17 = (unsigned __int8)v4[16] - v16; | |
4010 v36 = v15; | |
4011 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11); | |
4012 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7); | |
4013 v39 = (double)v17 * v15; | |
4014 v18 = v39 + 6.7553994e15; | |
4015 v19 = (unsigned __int8)*v4; | |
4016 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
4017 v20 = v39 + 6.7553994e15; | |
4018 v21 = (unsigned __int8)*(v4 - 2); | |
4019 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1); | |
4020 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36; | |
4021 v22 = v39 + 6.7553994e15; | |
4022 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2); | |
4023 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
4024 v24 = v39 + 6.7553994e15; | |
4025 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8); | |
4026 v25 = v40; | |
4027 *v40 = *(int *)v5; | |
4028 v26 = (int)(v5 + 4); | |
4029 ++v25; | |
4030 *v25 = *(int *)v26; | |
4031 v26 += 4; | |
4032 ++v25; | |
4033 ++v38; | |
4034 v40 += 4; | |
4035 *v25 = *(int *)v26; | |
4036 v25[1] = *(int *)(v26 + 4); | |
1418 | 4037 v5 = (char *)&v30 + 4; |
0 | 4038 } |
4039 v27 = v40; | |
4040 ++v38; | |
4041 *v40 = *(int *)v5; | |
4042 v28 = (int)(v5 + 4); | |
4043 ++v27; | |
4044 *v27 = *(int *)v28; | |
4045 v28 += 4; | |
4046 ++v27; | |
4047 v40 += 4; | |
4048 *v27 = *(int *)v28; | |
4049 v27[1] = *(int *)(v28 + 4); | |
4050 v4 += 16; | |
4051 --v34; | |
4052 if ( !v34 ) | |
1418 | 4053 return this->uNumVertices = v38; |
0 | 4054 } |
1418 | 4055 } |
1390 | 4056 return this->uNumVertices = v38; |
0 | 4057 } |
4058 | |
4059 //----- (00477C61) -------------------------------------------------------- | |
4060 int stru6_stru1_indoor_sw_billboard::sub_477C61() | |
4061 { | |
998 | 4062 //stru6_stru1_indoor_sw_billboard *v1; // ebx@1 |
0 | 4063 int v2; // ecx@2 |
4064 int v3; // eax@3 | |
4065 double v4; // st7@4 | |
4066 double v5; // st7@5 | |
4067 double v6; // st6@5 | |
4068 double v7; // st5@6 | |
4069 float v8; // ST30_4@8 | |
4070 float v9; // ST24_4@8 | |
4071 double v10; // st7@8 | |
4072 double v11; // st6@8 | |
4073 double v12; // st5@8 | |
4074 float v13; // ST24_4@13 | |
4075 int v14; // esi@13 | |
4076 char *v15; // esi@15 | |
4077 signed int v16; // eax@16 | |
4078 __int16 v17; // fps@16 | |
4079 unsigned __int8 v18; // c2@16 | |
4080 unsigned __int8 v19; // c3@16 | |
4081 double v20; // st6@16 | |
4082 float v21; // ST18_4@17 | |
4083 float v22; // ST2C_4@17 | |
4084 float v23; // ST34_4@17 | |
4085 float v24; // ST24_4@17 | |
4086 double v25; // st7@17 | |
4087 double v26; // st6@17 | |
4088 float v27; // ST34_4@18 | |
4089 float v28; // ST30_4@18 | |
4090 int v29; // eax@19 | |
4091 signed int v31; // [sp+8h] [bp-28h]@15 | |
4092 float v32; // [sp+Ch] [bp-24h]@16 | |
4093 float v33; // [sp+14h] [bp-1Ch]@16 | |
4094 float v34; // [sp+18h] [bp-18h]@16 | |
4095 float v35; // [sp+1Ch] [bp-14h]@17 | |
4096 float v36; // [sp+20h] [bp-10h]@4 | |
4097 float v37; // [sp+24h] [bp-Ch]@4 | |
4098 float v38; // [sp+24h] [bp-Ch]@16 | |
4099 float v39; // [sp+28h] [bp-8h]@9 | |
4100 float v40; // [sp+28h] [bp-8h]@16 | |
4101 float v41; // [sp+2Ch] [bp-4h]@6 | |
4102 float v42; // [sp+2Ch] [bp-4h]@9 | |
4103 | |
998 | 4104 //v1 = this; |
0 | 4105 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
4106 { | |
4107 v2 = 0; | |
1390 | 4108 if ( this->uNumVertices > 0 ) |
998 | 4109 { |
4110 v3 = (int)&this->field_14[1]; | |
0 | 4111 do |
4112 { | |
4113 v4 = *(float *)(v3 - 4); | |
4114 LODWORD(v37) = *(int *)v3; | |
4115 LODWORD(v36) = *(int *)(v3 + 4); | |
4116 if ( pBLVRenderParams->sPartyRotX ) | |
4117 { | |
4118 v5 = v4 - (double)pBLVRenderParams->vPartyPos.x; | |
4119 v6 = v37 - (double)pBLVRenderParams->vPartyPos.y; | |
4120 if ( pRenderer->pRenderD3D ) | |
4121 { | |
4122 v41 = pBLVRenderParams->fSineY * v6 + pBLVRenderParams->fCosineY * v5; | |
4123 v7 = pBLVRenderParams->fSineY * v5 - pBLVRenderParams->fCosineY * v6; | |
4124 } | |
4125 else | |
4126 { | |
4127 v41 = pBLVRenderParams->fCosineY * v5 - pBLVRenderParams->fSineY * v6; | |
4128 v7 = pBLVRenderParams->fSineY * v5 + pBLVRenderParams->fCosineY * v6; | |
4129 } | |
4130 v8 = v7; | |
4131 v9 = v36 - (double)pBLVRenderParams->vPartyPos.z; | |
4132 v10 = pBLVRenderParams->fCosineNegX * v41 - pBLVRenderParams->fSineNegX * v9; | |
4133 v11 = v8; | |
4134 v12 = pBLVRenderParams->fCosineNegX * v9 + pBLVRenderParams->fSineNegX * v41; | |
4135 } | |
4136 else | |
4137 { | |
4138 v42 = v4 - (double)pBLVRenderParams->vPartyPos.x; | |
4139 v39 = v37 - (double)pBLVRenderParams->vPartyPos.y; | |
4140 if ( pRenderer->pRenderD3D ) | |
4141 { | |
4142 v10 = pBLVRenderParams->fSineY * v39 + pBLVRenderParams->fCosineY * v42; | |
4143 v11 = pBLVRenderParams->fSineY * v42 - pBLVRenderParams->fCosineY * v39; | |
4144 } | |
4145 else | |
4146 { | |
4147 v10 = pBLVRenderParams->fCosineY * v42 - pBLVRenderParams->fSineY * v39; | |
4148 v11 = pBLVRenderParams->fSineY * v42 + pBLVRenderParams->fCosineY * v39; | |
4149 } | |
4150 v12 = v36 - (double)pBLVRenderParams->vPartyPos.z; | |
4151 } | |
4152 v13 = v12; | |
4153 ++v2; | |
4154 *(int *)(v3 + 84) = LODWORD(v13); | |
4155 v14 = *(int *)(v3 + 8); | |
4156 *(float *)(v3 + 76) = v10; | |
4157 *(int *)(v3 + 88) = v14; | |
4158 *(float *)(v3 + 80) = v11; | |
4159 v3 += 16; | |
4160 } | |
1390 | 4161 while ( v2 < this->uNumVertices ); |
0 | 4162 } |
4163 } | |
4164 else | |
4165 { | |
4166 v15 = (char *)&this->field_14[1]; | |
4167 v31 = 3; | |
4168 do | |
4169 { | |
323 | 4170 v40 = (double)stru_5C6E00->Cos(pIndoorCamera->sRotationX) * 0.0000152587890625; |
4171 v32 = (double)stru_5C6E00->Sin(pIndoorCamera->sRotationX) * 0.0000152587890625; | |
4172 v34 = (double)stru_5C6E00->Cos(pIndoorCamera->sRotationY) * 0.0000152587890625; | |
4173 v16 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); | |
0 | 4174 LODWORD(v38) = *(int *)v15; |
4175 v33 = (double)v16 * 0.0000152587890625; | |
4176 //UNDEF(v17); | |
4177 v20 = *((float *)v15 - 1) - (double)pIndoorCamera->pos.x; | |
1090 | 4178 //if ( v19 | v18 ) |
4179 if(pIndoorCamera->pos.x == 0) | |
0 | 4180 { |
4181 v27 = v20; | |
4182 LODWORD(v35) = *((int *)v15 + 1); | |
4183 v28 = v38 - (double)pIndoorCamera->pos.y; | |
4184 v25 = v33 * v28 + v34 * v27; | |
4185 v26 = v34 * v28 - v33 * v27; | |
4186 } | |
4187 else | |
4188 { | |
4189 v21 = v20; | |
4190 v22 = v38 - (double)pIndoorCamera->pos.y; | |
4191 v23 = v33 * v22 + v34 * v21; | |
4192 v24 = *((float *)v15 + 1) - (double)pIndoorCamera->pos.z; | |
4193 v25 = v32 * v24 + v40 * v23; | |
4194 v26 = v34 * v22 - v33 * v21; | |
4195 v35 = v40 * v24 - v32 * v23; | |
4196 } | |
4197 *((int *)v15 + 21) = LODWORD(v35); | |
4198 v29 = *((int *)v15 + 2); | |
4199 *((float *)v15 + 19) = v25; | |
4200 *((int *)v15 + 22) = v29; | |
4201 *((float *)v15 + 20) = v26; | |
4202 v15 += 16; | |
4203 --v31; | |
4204 } | |
4205 while ( v31 ); | |
4206 } | |
1390 | 4207 this->uNumVertices = 3; |
0 | 4208 return 1; |
4209 } | |
4210 | |
4211 //----- (00477F63) -------------------------------------------------------- | |
4212 bool stru6_stru1_indoor_sw_billboard::sub_477F63() | |
4213 { | |
4214 signed int v1; // ebx@1 | |
4215 stru6_stru1_indoor_sw_billboard *v2; // esi@1 | |
4216 double v3; // st7@2 | |
4217 int v4; // edx@4 | |
4218 char *v5; // ecx@5 | |
4219 int v6; // edi@5 | |
4220 float v7; // ST08_4@13 | |
4221 signed int v9; // [sp+Ch] [bp-8h]@1 | |
4222 float v10; // [sp+10h] [bp-4h]@2 | |
4223 | |
4224 auto a1 = this; | |
4225 | |
4226 v1 = 0; | |
4227 v2 = a1; | |
4228 v9 = 0; | |
4229 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
4230 { | |
4231 v10 = 16192.0; | |
4232 v3 = (double)pBLVRenderParams->field_40 * 0.000015258789; | |
4233 } | |
4234 else | |
4235 { | |
4236 v10 = (double)pOutdoorCamera->shading_dist_mist; | |
4237 v3 = 8.0; | |
4238 } | |
1390 | 4239 v4 = a1->uNumVertices; |
0 | 4240 if ( v4 <= 0 ) |
1418 | 4241 { |
4242 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); | |
4243 return v2->uNumVertices != 0; | |
4244 } | |
0 | 4245 v5 = (char *)&a1->field_14[20]; |
4246 v6 = v4; | |
4247 do | |
4248 { | |
4249 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 ) | |
4250 { | |
4251 if ( v3 < *(float *)v5 ) | |
4252 v9 = 1; | |
4253 else | |
4254 v1 = 1; | |
4255 } | |
4256 v5 += 16; | |
4257 --v6; | |
4258 } | |
4259 while ( v6 ); | |
4260 if ( !v1 ) | |
4261 { | |
4262 if ( v9 ) | |
4263 { | |
4264 v2->_477927(v10); | |
1390 | 4265 return v2->uNumVertices != 0; |
0 | 4266 } |
4267 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); | |
1390 | 4268 return v2->uNumVertices != 0; |
0 | 4269 } |
4270 v7 = v3; | |
4271 _4775ED(v7); | |
1390 | 4272 return v2->uNumVertices != 0; |
0 | 4273 } |
4274 | |
4275 //----- (0047802A) -------------------------------------------------------- | |
4276 int stru6_stru1_indoor_sw_billboard::sub_47802A() | |
4277 { | |
4278 double v6; // st7@4 | |
4279 double v12; // st7@16 | |
4280 signed int v16; // [sp+38h] [bp-Ch]@1 | |
4281 int a6; // [sp+3Ch] [bp-8h]@5 | |
4282 int a5; // [sp+40h] [bp-4h]@5 | |
4283 | |
4284 auto a1 = this; | |
4285 | |
4286 v16 = 0; | |
4287 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
4288 { | |
1390 | 4289 for(int i = 0; i < a1->uNumVertices; i++) |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4290 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4291 v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4292 if ( pRenderer->pRenderD3D ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4293 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4294 pGame->pIndoorCameraD3D->Project( |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4295 round(a1->field_B4[i*4]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4296 round(a1->field_B4[i*4+1]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4297 round(a1->field_B4[i*4+2]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4298 &a5, |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4299 &a6); |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4300 a1->field_B4[i*4+16] = (double)a5; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4301 a1->field_B4[i*4+17] = (double)a6; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4302 a1->field_B4[i*4+18] = round(a1->field_B4[i*4]); |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4303 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4304 else |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4305 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4306 a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4307 a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4308 a1->field_B4[i*4+18] = a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4309 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4310 a1->field_B4[i*4+19] = a1->field_B4[i*4+3]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4311 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4312 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4313 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4314 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4315 v16 = 1; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4316 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4317 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4318 else |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4319 { |
1390 | 4320 for(int i = 0; i < a1->uNumVertices; i++) |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4321 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4322 v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4323 a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4324 a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4325 *((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4326 *((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4327 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4328 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4329 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4330 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
4331 v16 = 1; |
0 | 4332 } |
4333 } | |
4334 return v16; | |
4335 } | |
4336 | |
4337 //----- (004783FA) -------------------------------------------------------- | |
4338 void __cdecl sub_4783FA_construct_global_73D150() | |
4339 { | |
4340 char *v0; // eax@1 | |
4341 signed int v1; // ecx@1 | |
4342 | |
4343 v0 = (char *)&array_73D150[0].flt_2C; | |
4344 v1 = 20; | |
4345 do | |
4346 { | |
4347 *(float *)v0 = 0.0; | |
4348 v0 += 48; | |
4349 --v1; | |
4350 } | |
4351 while ( v1 ); | |
4352 } | |
4353 | |
4354 //----- (0047840D) -------------------------------------------------------- | |
4355 char Render::DrawBuildingsD3D() | |
4356 { | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4357 //IndoorCameraD3D *v0; // eax@3 |
0 | 4358 char result; // al@3 |
79 | 4359 BSPModel *v2; // ebx@4 |
4360 int v3; // eax@6 | |
0 | 4361 ODMFace *pFace; // esi@6 |
79 | 4362 Vec3_int_ *v5; // ecx@8 |
0 | 4363 int v6; // eax@8 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4364 struct Polygon *v7; // ebx@8 |
0 | 4365 LightmapBuilder *v8; // eax@8 |
4366 int v9; // ecx@8 | |
4367 char v10; // zf@8 | |
4368 Texture *pFaceTexture; // eax@10 | |
4369 signed int v12; // ecx@10 | |
4370 unsigned int v13; // eax@14 | |
4371 unsigned int v14; // eax@18 | |
4372 unsigned int v15; // eax@22 | |
4373 unsigned int v16; // edi@22 | |
4374 int v17; // eax@24 | |
4375 int v18; // edi@34 | |
79 | 4376 RenderVertexSoft *v19; // eax@35 |
4377 unsigned short *v20; // ecx@35 | |
4378 unsigned short *v20b; // ecx@35 | |
4379 unsigned short *v20c; // ecx@35 | |
0 | 4380 Vec3_int_ *v21; // edx@36 |
4381 int v22; // edx@36 | |
79 | 4382 RenderVertexSoft *v23; // edi@37 |
0 | 4383 int v24; // eax@50 |
4384 int v25; // ecx@55 | |
4385 int v26; // eax@57 | |
4386 int v27; // eax@57 | |
4387 int v28; // eax@58 | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4388 //int v29; // edx@58 |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4389 //double v30; // st7@59 |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4390 //LightmapBuilder *v31; // edi@63 |
0 | 4391 signed int v32; // eax@73 |
4392 int v33; // eax@78 | |
4393 unsigned int v34; // eax@80 | |
4394 std::string v35; // [sp-18h] [bp-70h]@2 | |
4395 int v36; // [sp-14h] [bp-6Ch]@69 | |
4396 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69 | |
4397 int v38; // [sp-Ch] [bp-64h]@69 | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4398 //LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 |
0 | 4399 int v40; // [sp-4h] [bp-5Ch]@2 |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4400 //std::string *v41; // [sp+Ch] [bp-4Ch]@2 |
79 | 4401 int v41b; |
4402 int v42; // [sp+10h] [bp-48h]@6 | |
0 | 4403 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8 |
4404 float v44; // [sp+18h] [bp-40h]@10 | |
4405 float v45; // [sp+1Ch] [bp-3Ch]@10 | |
4406 ODMFace *v46; // [sp+20h] [bp-38h]@6 | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4407 //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 |
0 | 4408 unsigned int v48; // [sp+28h] [bp-30h]@8 |
4409 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
4410 int v50; // [sp+30h] [bp-28h]@34 | |
4411 int v51; // [sp+34h] [bp-24h]@35 | |
4412 int v52; // [sp+38h] [bp-20h]@36 | |
4413 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
4414 Vec3_int_ *v54; // [sp+40h] [bp-18h]@6 | |
4415 int a1; // [sp+44h] [bp-14h]@3 | |
79 | 4416 BSPModel *v56; // [sp+48h] [bp-10h]@4 |
0 | 4417 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 |
4418 int unused; // [sp+50h] [bp-8h]@3 | |
4419 int a3; // [sp+57h] [bp-1h]@2 | |
4420 | |
4421 if ( !pRenderer->pRenderD3D ) | |
4422 { | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4423 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4424 } |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4425 |
0 | 4426 unused = 0; |
4427 a1 = 0; | |
4428 result = LOBYTE(pOutdoor->pBModels); | |
79 | 4429 v41b = pOutdoor->uNumBModels; |
0 | 4430 if ( (signed int)pOutdoor->uNumBModels > 0 ) |
4431 { | |
79 | 4432 v2 = pOutdoor->pBModels; |
4433 v56 = pOutdoor->pBModels; | |
0 | 4434 while ( 1 ) |
4435 { | |
4436 if ( IsBModelVisible(a1, &unused) ) | |
4437 { | |
79 | 4438 v2->field_40 |= 1u; |
4439 v3 = v2->uNumFaces; | |
4440 pFace = v2->pFaces; | |
0 | 4441 v54 = 0; |
4442 v46 = pFace; | |
4443 v42 = v3; | |
79 | 4444 if ( v3 > 0 ) |
0 | 4445 break; |
4446 } | |
4447 LABEL_86: | |
4448 ++a1; | |
79 | 4449 ++v2;// += 47; |
0 | 4450 result = a1; |
4451 v56 = v2; | |
79 | 4452 if ( a1 >= v41b ) |
0 | 4453 return result; |
4454 } | |
4455 while ( 1 ) | |
4456 { | |
4457 if (pFace->Invisible()) | |
4458 goto LABEL_85; | |
79 | 4459 //v5 = (int)*(v2 - 1); |
4460 v5 = v2->pVertices.pVertices; | |
0 | 4461 v6 = pFace->pVertexIDs[0]; |
4462 v53 = 0; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4463 v7 = &array_77EC08[pOutdoorCamera->uNumPolygons]; |
79 | 4464 //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); |
4465 v8 = (LightmapBuilder *)v5[v6].z; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4466 v7->flags = 0; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4467 v7->field_32 = 0; |
0 | 4468 pLightmapBuilder = v8; |
4469 v9 = pFace->uTextureID; | |
4470 v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0; | |
4471 v48 = pFace->uTextureID; | |
4472 if ( !v10 ) | |
4473 { | |
4474 v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
4475 v9 = v48; | |
4476 } | |
945 | 4477 pFaceTexture = pBitmaps_LOD->GetTexture(v9); |
0 | 4478 v7->pTexture = pFaceTexture; |
945 | 4479 v12 = pFaceTexture->uTextureWidth; |
0 | 4480 v49 = v12; |
4481 v49 = pFaceTexture->uTextureHeight; | |
4482 v10 = (pFace->uAttributes & 0x10) == 0; | |
4483 v45 = 1.0 / (double)v12; | |
4484 v44 = 1.0 / (double)v49; | |
4485 if ( !v10 ) | |
4486 *(int *)&v7->flags |= 2u; | |
4487 if ( BYTE2(pFace->uAttributes) & 0x40 ) | |
4488 HIBYTE(v7->flags) |= 4u; | |
4489 v13 = pFace->uAttributes; | |
4490 if ( v13 & 4 ) | |
4491 { | |
4492 HIBYTE(v7->flags) |= 4u; | |
4493 } | |
4494 else | |
4495 { | |
4496 if ( v13 & 0x20 ) | |
4497 HIBYTE(v7->flags) |= 8u; | |
4498 } | |
4499 v14 = pFace->uAttributes; | |
4500 if ( BYTE1(v14) & 8 ) | |
4501 { | |
4502 *(int *)&v7->flags |= 0x2000u; | |
4503 } | |
4504 else | |
4505 { | |
4506 if ( v14 & 0x40 ) | |
4507 HIBYTE(v7->flags) |= 0x10u; | |
4508 } | |
4509 v15 = GetTickCount(); | |
4510 v7->sTextureDeltaU = pFace->sTextureDeltaU; | |
4511 v7->sTextureDeltaV = pFace->sTextureDeltaV; | |
4512 v16 = v15 >> 4; | |
4513 if ( pFace->pFacePlane.vNormal.z && (v40 = pFace->pFacePlane.vNormal.z, abs(v40) >= 59082) ) | |
4514 { | |
4515 v17 = *(int *)&v7->flags; | |
4516 if ( BYTE1(v17) & 4 ) | |
4517 goto LABEL_29; | |
4518 if ( BYTE1(v17) & 8 ) | |
4519 { | |
4520 LABEL_26: | |
4521 v7->sTextureDeltaV -= v16 & v7->pTexture->uHeightMinus1; | |
4522 goto LABEL_30; | |
4523 } | |
4524 } | |
4525 else | |
4526 { | |
4527 v17 = *(int *)&v7->flags; | |
4528 if ( BYTE1(v17) & 4 ) | |
4529 goto LABEL_26; | |
4530 if ( BYTE1(v17) & 8 ) | |
4531 { | |
4532 LABEL_29: | |
4533 v7->sTextureDeltaV += v16 & v7->pTexture->uHeightMinus1; | |
4534 goto LABEL_30; | |
4535 } | |
4536 } | |
4537 LABEL_30: | |
4538 if ( BYTE1(v17) & 0x10 ) | |
4539 { | |
4540 v7->sTextureDeltaU -= v16 & v7->pTexture->uWidthMinus1; | |
4541 } | |
4542 else | |
4543 { | |
4544 if ( BYTE1(v17) & 0x20 ) | |
4545 v7->sTextureDeltaU += v16 & v7->pTexture->uWidthMinus1; | |
4546 } | |
4547 v18 = pFace->uNumVertices; | |
4548 v50 = 0; | |
4549 v49 = 0; | |
4550 uNumVertices = v18; | |
4551 if ( v18 > 0 ) | |
4552 { | |
79 | 4553 //v19 = (char *)&array_73D150[0].vWorldPosition.z; |
4554 //v20 = (char *)pFace->pTextureUIDs; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4555 v19 = array_73D150; |
79 | 4556 v20 = pFace->pTextureUIDs; |
4557 v20b = pFace->pVertexIDs; | |
4558 v20c = pFace->pTextureVIDs; | |
0 | 4559 v51 = v18; |
4560 do | |
4561 { | |
79 | 4562 /* v21 = &(*(v56 - 1))[*((short *)v20 - 20)]; |
0 | 4563 *((float *)v19 - 2) = (double)v21->x; |
4564 *((float *)v19 - 1) = (double)v21->y; | |
4565 *(float *)v19 = (double)v21->z; | |
4566 v19 += 48; | |
4567 v52 = v7->sTextureDeltaU + *(short *)v20; | |
4568 *((float *)v19 - 5) = (double)v52 * v45; | |
4569 v22 = v7->sTextureDeltaV + *((short *)v20 + 20); | |
4570 v20 += 2; | |
4571 v10 = v51-- == 1; | |
4572 v52 = v22; | |
79 | 4573 *((float *)v19 - 4) = (double)v22 * v44;*/ |
4574 | |
4575 //v21 = (BSPVertexBuffer *)(*((_DWORD *)v56 - 1) + 12 * *(v20 - 20)); | |
4576 v21 = &v56->pVertices.pVertices[*v20b]; | |
4577 //*((float *)v19 - 2) = (double)v21->x; | |
4578 //*((float *)v19 - 1) = (double)v21->y; | |
4579 v19->vWorldPosition.x = (double)v21->x; | |
4580 v19->vWorldPosition.y = (double)v21->y; | |
4581 v19->vWorldPosition.z = (double)v21->z; | |
4582 ++v19; | |
4583 v52 = v7->sTextureDeltaU + (signed __int16)*v20; | |
4584 //*((float *)v19 - 5) = (double)v52 * v45; | |
4585 (v19-1)->u = (double)v52 * v45; | |
4586 v22 = v7->sTextureDeltaV + (signed __int16)*v20c; | |
4587 ++v20; | |
4588 ++v20b; | |
4589 ++v20c; | |
4590 v10 = v51-- == 1; | |
4591 v52 = v22; | |
4592 //*((float *)v19 - 4) = (double)v22 * v44; | |
4593 (v19-1)->v = (double)v22 * v44; | |
0 | 4594 } |
4595 while ( !v10 ); | |
79 | 4596 //v23 = (char *)&array_73D150[0].vWorldViewPosition; |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4597 v23 = array_73D150; |
0 | 4598 v51 = uNumVertices; |
4599 *(float *)&pLightmapBuilder = (double)(signed int)pLightmapBuilder; | |
4600 do | |
4601 { | |
79 | 4602 //if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) ) |
4603 if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z ) | |
0 | 4604 ++v53; |
79 | 4605 //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4606 pGame->pIndoorCameraD3D->ViewTransform(v23, 1u); |
79 | 4607 if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x ) |
4608 { | |
4609 if ( v23->vWorldViewPosition.x >= 8.0 ) | |
0 | 4610 v49 = 1; |
4611 else | |
4612 v50 = 1; | |
4613 } | |
4614 else | |
4615 { | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4616 pGame->pIndoorCameraD3D->Project(v23, 1u, 0); |
79 | 4617 } |
4618 ++v23;// += 48; | |
0 | 4619 --v51; |
4620 } | |
4621 while ( v51 ); | |
4622 v18 = uNumVertices; | |
4623 } | |
4624 if ( v53 == v18 ) | |
4625 LOBYTE(v7->field_32) |= 1u; | |
4626 v24 = pOutdoor->vSunlight.x; | |
4627 v7->pODMFace = pFace; | |
4628 v7->uNumVertices = v18; | |
4629 v7->field_59 = 5; | |
4630 pLightmapBuilder = (LightmapBuilder *)-v24; | |
4631 v51 = pFace->pFacePlane.vNormal.x; | |
4632 v51 = (unsigned __int64)(-v24 * (signed __int64)v51) >> 16; | |
4633 v53 = pFace->pFacePlane.vNormal.y; | |
4634 pLightmapBuilder = (LightmapBuilder *)-pOutdoor->vSunlight.y; | |
4635 v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)v53) >> 16; | |
4636 v52 = pFace->pFacePlane.vNormal.z; | |
4637 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16; | |
4638 pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52); | |
4639 v51 = 20 * (int)pLightmapBuilder; | |
4640 result = 20 - (20 * (signed int)pLightmapBuilder >> 16); | |
638 | 4641 v7->dimming_level = result; |
0 | 4642 if ( result < 0 ) |
638 | 4643 v7->dimming_level = 0; |
4644 if ( v7->dimming_level > 31 ) | |
4645 v7->dimming_level = 31; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4646 if ( pOutdoorCamera->uNumPolygons >= 1999 + 5000) |
0 | 4647 return result; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4648 ++pOutdoorCamera->uNumPolygons; |
0 | 4649 ++pOutdoorCamera->field_44; |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4650 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) ) |
0 | 4651 { |
4652 LOBYTE(v25) = (char)v54; | |
4653 v26 = a1; | |
4654 pFace->bVisible = 1; | |
4655 v7->uBModelFaceID = v25; | |
4656 LOWORD(v25) = (unsigned __int8)v25; | |
4657 v7->uBModelID = v26; | |
4658 v27 = 8 * (v25 | (v26 << 6)); | |
4659 LOBYTE(v27) = v27 | 6; | |
4660 v7->field_50 = v27; | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4661 |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4662 for (v28 = 0; v28 < v18; ++v28) |
0 | 4663 { |
4664 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4665 array_50AC10[v28]._rhw = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001); |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4666 |
0 | 4667 pFace = v46; |
4668 } | |
4669 | |
4670 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
4671 /*static bool __init_flag = false; | |
4672 if (!__init_flag) | |
4673 { | |
4674 __init_flag = true; | |
4675 | |
4676 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
4677 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
4678 atexit(loc_4789D4); | |
4679 }*/ | |
4680 | |
4681 v40 = (int)pFace; | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4682 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(pFace); |
0 | 4683 pDecalBuilder->ApplyDecals_OutdoorFace(pFace); |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4684 pGame->pLightmapBuilder->std__vector_000004_size = 0; |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4685 |
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4686 int v31 = 0; |
0 | 4687 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) |
4688 { | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4689 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; |
866 | 4690 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); |
0 | 4691 if ( pDecalBuilder->uNumDecals > 0 ) |
4692 { | |
4693 v40 = -1; | |
4694 v38 = 0; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4695 v37 = array_50AC10; |
0 | 4696 v36 = uNumVertices; |
638 | 4697 pDecalBuilder->ApplyDecals(31 - v7->dimming_level, |
0 | 4698 2, |
4699 &static_RenderBuildingsD3D_stru_73C834, | |
4700 uNumVertices, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4701 array_50AC10, |
0 | 4702 0, |
4703 (char)v31, | |
4704 -1); | |
4705 } | |
4706 } | |
4707 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
1395
8d4ec56416ef
Fix to ticket #69 array_50A2B0 being accessed outside of bounds
Nomad
parents:
1391
diff
changeset
|
4708 pGame->pLightmapBuilder->ApplyLights( |
0 | 4709 &stru_F8AD28, |
4710 &static_RenderBuildingsD3D_stru_73C834, | |
4711 uNumVertices, | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
4712 array_50AC10, |
0 | 4713 0, |
4714 (char)v31); | |
4715 if ( v50 ) | |
4716 { | |
4717 v32 = sr_424CD7(uNumVertices); | |
4718 goto LABEL_76; | |
4719 } | |
4720 if ( v49 ) | |
4721 { | |
4722 v32 = sr_424EE0_MakeFanFromTriangle(uNumVertices); | |
4723 LABEL_76: | |
4724 v7->uNumVertices = v32; | |
4725 uNumVertices = v32; | |
4726 OutdoorCamera::Project(v32); | |
4727 } | |
4728 if ( uNumVertices ) | |
4729 { | |
4730 v33 = *(int *)&v7->flags; | |
4731 if ( v33 & 2 ) | |
4732 { | |
4733 if ( BYTE1(v33) & 0x3C ) | |
4734 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
4735 else | |
265 | 4736 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
0 | 4737 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; |
4738 } | |
4739 else | |
4740 { | |
4741 v40 = (int)pBitmaps_LOD->pHardwareTextures[v48]; | |
4742 } | |
4743 pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40); | |
4744 } | |
4745 goto LABEL_85; | |
4746 } | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4747 --pOutdoorCamera->uNumPolygons; |
0 | 4748 --pOutdoorCamera->field_44; |
4749 LABEL_85: | |
4750 v54 = (Vec3_int_ *)((char *)v54 + 1); | |
4751 v2 = v56; | |
4752 ++pFace; | |
4753 v46 = pFace; | |
4754 if ( (signed int)v54 >= (signed int)v42 ) | |
4755 goto LABEL_86; | |
4756 } | |
4757 } | |
4758 return result; | |
4759 } | |
4760 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; | |
4761 | |
4762 | |
4763 //----- (00479089) -------------------------------------------------------- | |
323 | 4764 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) |
0 | 4765 { |
4766 BSPModel *v2; // eax@1 | |
4767 int v3; // edi@1 | |
4768 int v4; // ebx@1 | |
4769 int v5; // ST28_4@1 | |
4770 int v6; // ecx@1 | |
4771 int v7; // ebx@3 | |
4772 int v8; // eax@3 | |
4773 int v9; // eax@3 | |
323 | 4774 //int v10; // ebx@3 |
0 | 4775 signed int v11; // esi@6 |
4776 int v12; // esi@8 | |
4777 bool result; // eax@9 | |
323 | 4778 //unsigned int v14; // [sp+Ch] [bp-20h]@1 |
0 | 4779 int v15; // [sp+Ch] [bp-20h]@5 |
323 | 4780 //int *v16; // [sp+10h] [bp-1Ch]@1 |
0 | 4781 int v17; // [sp+1Ch] [bp-10h]@1 |
4782 int v18; // [sp+20h] [bp-Ch]@1 | |
4783 int v19; // [sp+20h] [bp-Ch]@3 | |
4784 int angle; // [sp+24h] [bp-8h]@1 | |
4785 int v21; // [sp+28h] [bp-4h]@1 | |
323 | 4786 //int v22; // [sp+28h] [bp-4h]@3 |
4787 | |
4788 //v16 = unused; | |
0 | 4789 angle = (signed int)(pOutdoorCamera->uCameraFovInDegrees << 11) / 360 >> 1; |
323 | 4790 //v14 = uModelID; |
0 | 4791 v2 = &pOutdoor->pBModels[uModelID]; |
4792 v3 = v2->vBoundingCenter.x - pIndoorCamera->pos.x; | |
4793 v4 = v2->vBoundingCenter.y - pIndoorCamera->pos.y; | |
323 | 4794 v5 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); |
4795 v21 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); | |
4796 v18 = stru_5C6E00->Cos(pIndoorCamera->sRotationX); | |
4797 stru_5C6E00->Sin(pIndoorCamera->sRotationX); | |
0 | 4798 v6 = v5; |
4799 v17 = v3 * v5 + v4 * v21; | |
4800 if ( pIndoorCamera->sRotationX ) | |
4801 v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16; | |
4802 v19 = v4 * v6 - v3 * v21; | |
4803 v7 = abs(v4); | |
4804 v8 = abs(v3); | |
322 | 4805 v9 = int_get_vector_length(v8, v7, 0); |
323 | 4806 //v10 = v14 * 188; |
4807 //v22 = v9; | |
4808 *reachable = false; | |
4809 if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 ) | |
4810 *reachable = true; | |
4811 v15 = stru_5C6E00->Sin(angle); | |
0 | 4812 if ( v19 >= 0 ) |
323 | 4813 v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16); |
4814 else | |
4815 v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16); | |
0 | 4816 v12 = v11 >> 16; |
323 | 4817 if ( v9 <= pOutdoorCamera->shading_dist_mist + 2048 ) |
0 | 4818 { |
79 | 4819 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) |
323 | 4820 if ( abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512 ) |
0 | 4821 { |
4822 result = v12 < 0; | |
4823 LOBYTE(result) = v12 >= 0; | |
323 | 4824 return result; |
4825 } | |
4826 else | |
4827 return true; | |
4828 } | |
4829 return false; | |
0 | 4830 } |
4831 | |
4832 //----- (00479295) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4833 int Polygon::_479295() |
0 | 4834 { |
4835 ODMFace *v2; // esi@1 | |
4836 int v3; // ecx@4 | |
4837 int v4; // eax@4 | |
4838 int v5; // edx@4 | |
4839 int v6; // ST14_4@5 | |
4840 int v7; // ST04_4@5 | |
4841 stru149 *v8; // ecx@5 | |
4842 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 | |
4843 int v11; // [sp+18h] [bp-4h]@4 | |
4844 | |
4845 v2 = this->pODMFace; | |
4846 if ( !v2->pFacePlane.vNormal.z ) | |
4847 { | |
4848 v3 = v2->pFacePlane.vNormal.x; | |
4849 v4 = -v2->pFacePlane.vNormal.y; | |
4850 v5 = 0; | |
4851 v11 = 65536; | |
1418 | 4852 } |
4853 else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) | |
0 | 4854 { |
4855 thisa.x = -v2->pFacePlane.vNormal.y; | |
4856 thisa.y = v2->pFacePlane.vNormal.x; | |
4857 thisa.z = 0; | |
4858 thisa.Normalize_float(); | |
4859 v4 = thisa.x; | |
4860 v3 = thisa.y; | |
1418 | 4861 v5 = 0; |
4862 v11 = 65536; | |
4863 } | |
4864 else | |
4865 { | |
4866 v3 = 0; | |
4867 v4 = 65536; | |
4868 v11 = 0; | |
4869 v5 = -65536; | |
4870 } | |
0 | 4871 v6 = v11; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4872 sTextureDeltaU = v2->sTextureDeltaU; |
0 | 4873 v7 = v3; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4874 v8 = ptr_38; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
4875 sTextureDeltaV = v2->sTextureDeltaV; |
0 | 4876 v8->_48616B(v4, v7, 0, 0, v5, v6); |
4877 return 1; | |
4878 } | |
4879 | |
4880 | |
168 | 4881 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) |
4882 { | |
4883 #pragma pack(push, 1) | |
4884 struct TGAHeader | |
4885 { | |
4886 unsigned char tgaSkip; | |
4887 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette | |
4888 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed | |
4889 | |
4890 short colourmapstart; // first colour map entry in palette | |
4891 short colourmaplength; // number of colours in palette | |
4892 char colourmapbits; // number of bits per palette entry 15,16,24,32 | |
4893 | |
4894 //unsigned char tgaDontCare2[9]; | |
4895 short xstart; // image x origin | |
4896 short ystart; // image y origin | |
4897 | |
4898 unsigned short tgaWidth; | |
4899 unsigned short tgaHeight; | |
4900 unsigned char tgaBPP; | |
4901 | |
4902 char descriptor; // image descriptor bits: 00vhaaaa | |
4903 // h horizontal flip | |
4904 // v vertical flip | |
4905 // a alpha bits | |
4906 }; | |
4907 #pragma pack(pop) | |
4908 | |
4909 if (out_width) | |
4910 *out_width = 0; | |
4911 if (out_height) | |
4912 *out_height = 0; | |
4913 | |
4914 DWORD w; | |
4915 auto file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); | |
4916 if (file == INVALID_HANDLE_VALUE) | |
4917 return nullptr; | |
4918 | |
4919 TGAHeader header; | |
4920 ReadFile(file, &header, sizeof(header), &w, nullptr); | |
4921 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT); | |
4922 | |
4923 if (header.tgaBPP != 24 || header.tgaType != 2) | |
4924 { | |
4925 CloseHandle(file); | |
4926 return nullptr; | |
4927 } | |
4928 | |
4929 int imgSize = header.tgaWidth * header.tgaHeight * 3; | |
4930 auto pixels = new unsigned char[imgSize]; | |
4931 ReadFile(file, pixels, imgSize, &w, nullptr); | |
4932 CloseHandle(file); | |
4933 | |
4934 if (w != imgSize) | |
4935 { | |
4936 delete [] pixels; | |
4937 return nullptr; | |
4938 } | |
4939 | |
4940 if (out_width) | |
4941 *out_width = header.tgaWidth; | |
4942 if (out_height) | |
4943 *out_height = header.tgaHeight; | |
4944 | |
4945 auto pixels_16bit = new unsigned short[imgSize / 3]; | |
4946 for (int i = 0; i < imgSize / 3; ++i) | |
4947 { | |
4948 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) | | |
4949 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) | | |
4950 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11); | |
4951 } | |
4952 delete [] pixels; | |
4953 return pixels_16bit; | |
4954 } | |
4955 | |
4956 unsigned short *skybox_xn, *skybox_xp, | |
4957 *skybox_yn, *skybox_yp, | |
4958 *skybox_zn, *skybox_zp; | |
4959 int skybox_width, skybox_height; | |
781 | 4960 |
168 | 4961 IDirect3DTexture2 *skybox_texture; |
4962 IDirectDrawSurface4 *skybox_surface; | |
781 | 4963 |
168 | 4964 bool Skybox_Initialize(const wchar_t *skybox_name) |
4965 { | |
4966 wchar_t xn_filename[1024], xp_filename[1024], | |
4967 yn_filename[1024], yp_filename[1024], | |
4968 zn_filename[1024], zp_filename[1024]; | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4969 swprintf(xn_filename, wcslen(L"%s_xn.tga"), L"%s_xn.tga", skybox_name); swprintf(xp_filename, wcslen(L"%s_xp.tga"), L"%s_xp.tga", skybox_name); |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4970 swprintf(yn_filename, wcslen(L"%s_yn.tga"), L"%s_yn.tga", skybox_name); swprintf(yp_filename, wcslen(L"%s_yp.tga"), L"%s_yp.tga", skybox_name); |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4971 swprintf(zn_filename, wcslen(L"%s_zn.tga"), L"%s_zn.tga", skybox_name); swprintf(zp_filename, wcslen(L"%s_zp.tga"), L"%s_zp.tga", skybox_name); |
168 | 4972 |
4973 int xn_width, xn_height; | |
4974 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height); | |
4975 if (!skybox_xn) | |
4976 return false; | |
4977 | |
4978 int xp_width, xp_height; | |
4979 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height); | |
4980 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height) | |
4981 { | |
4982 delete [] skybox_xn; | |
4983 if (skybox_xp) delete [] skybox_xp; | |
4984 return false; | |
4985 } | |
4986 | |
4987 int yn_width, yn_height; | |
4988 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height); | |
4989 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height) | |
4990 { | |
4991 delete [] skybox_xn; | |
4992 if (skybox_xp) delete [] skybox_xp; | |
4993 if (skybox_yn) delete [] skybox_yn; | |
4994 return false; | |
4995 } | |
4996 | |
4997 int yp_width, yp_height; | |
4998 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height); | |
4999 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height) | |
5000 { | |
5001 delete [] skybox_xn; | |
5002 if (skybox_xp) delete [] skybox_xp; | |
5003 if (skybox_yn) delete [] skybox_yn; | |
5004 if (skybox_yp) delete [] skybox_yp; | |
5005 return false; | |
5006 } | |
5007 | |
5008 int zn_width, zn_height; | |
5009 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height); | |
5010 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height) | |
5011 { | |
5012 delete [] skybox_xn; | |
5013 if (skybox_xp) delete [] skybox_xp; | |
5014 if (skybox_yn) delete [] skybox_yn; | |
5015 if (skybox_yp) delete [] skybox_yp; | |
5016 if (skybox_zn) delete [] skybox_zn; | |
5017 return false; | |
5018 } | |
5019 | |
5020 int zp_width, zp_height; | |
5021 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height); | |
5022 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height) | |
5023 { | |
5024 delete [] skybox_xn; | |
5025 if (skybox_xp) delete [] skybox_xp; | |
5026 if (skybox_yn) delete [] skybox_yn; | |
5027 if (skybox_yp) delete [] skybox_yp; | |
5028 if (skybox_zn) delete [] skybox_zn; | |
5029 if (skybox_zp) delete [] skybox_zp; | |
5030 return false; | |
5031 } | |
5032 | |
5033 skybox_width = xn_width; | |
5034 skybox_height = xn_height; | |
5035 | |
5036 | |
5037 if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture, | |
5038 false, false, pRenderer->uMinDeviceTextureDim)) | |
5039 return false; | |
5040 | |
5041 return true; | |
5042 } | |
5043 | |
5044 struct vector | |
5045 { | |
5046 float x, y, z; | |
5047 }; | |
781 | 5048 |
168 | 5049 struct matrix |
5050 { | |
5051 float m[4][4]; | |
5052 }; | |
781 | 5053 |
168 | 5054 void VectorNormalize(vector *v) |
5055 { | |
5056 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); | |
5057 v->x *= invmag; | |
5058 v->y *= invmag; | |
5059 v->z *= invmag; | |
5060 } | |
781 | 5061 |
168 | 5062 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle) |
5063 { | |
5064 memset(pout, 0, sizeof(matrix)); | |
5065 pout->m[3][0] = 0; | |
5066 pout->m[3][1] = 0; | |
5067 pout->m[3][2] = 0; | |
5068 pout->m[3][3] = 1; | |
5069 | |
5070 vector v; | |
5071 v.x = pv->x; v.y = pv->y; v.z = pv->z; | |
5072 VectorNormalize(&v); | |
5073 | |
5074 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle); | |
5075 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z; | |
5076 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y; | |
5077 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z; | |
5078 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle); | |
5079 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x; | |
5080 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y; | |
5081 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x; | |
5082 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle); | |
5083 } | |
781 | 5084 |
168 | 5085 void VectorTransform(const matrix *m, const vector *v, vector *out) |
5086 { | |
5087 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0]; | |
5088 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1]; | |
5089 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2]; | |
5090 } | |
5091 | |
5092 bool DrawSkyD3D_Skybox() | |
5093 { | |
5094 static bool initialized = false, | |
5095 initialization_failed = false; | |
5096 if (initialization_failed) | |
5097 return false; | |
5098 | |
5099 static int last_camera_rot_y, | |
5100 last_camera_rot_x; | |
5101 if (!initialized) | |
5102 { | |
5103 if (!Skybox_Initialize(L"data/skybox/stars")) | |
5104 { | |
5105 initialization_failed = true; | |
5106 return false; | |
5107 } | |
5108 initialized = true; | |
5109 | |
5110 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run | |
5111 last_camera_rot_x = pParty->sRotationX + 1; | |
5112 } | |
5113 | |
5114 /* | |
5115 r(y) = | |
5116 cos y 0 sin y 0 | |
5117 0 1 0 0 | |
5118 -sin y 0 cos y 0 | |
5119 0 0 0 1 | |
5120 | |
5121 x cos y - z sin y | |
5122 y | |
5123 x sin y + z cos y | |
5124 1 | |
5125 | |
5126 | |
5127 | |
5128 r(x) = // should be r(right) actually | |
5129 1 0 0 0 | |
5130 0 cos x -sin x 0 | |
5131 0 sin x cos x 0 | |
5132 0 0 0 1 | |
5133 | |
5134 | |
5135 x | |
5136 y cos x + z sin x | |
5137 -y sin x + z cos x | |
5138 1 | |
5139 | |
5140 */ | |
5141 | |
5142 if (last_camera_rot_y == pParty->sRotationY && | |
5143 last_camera_rot_x == pParty->sRotationX) | |
5144 { | |
5145 draw: | |
5146 struct RenderVertexD3D3 v[6]; | |
5147 | |
692 | 5148 v[0].pos.x = pViewport->uScreen_TL_X; |
5149 v[0].pos.y = pViewport->uScreen_TL_Y; | |
168 | 5150 v[0].pos.z = 0.99989998; |
5151 v[0].rhw = 1; | |
5152 v[0].diffuse = 0xFFFFFFFF; | |
5153 v[0].specular = 0; | |
5154 v[0].texcoord.x = 0; | |
5155 v[0].texcoord.y = 0; | |
5156 | |
692 | 5157 v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; |
5158 v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
168 | 5159 v[1].pos.z = 0.99989998; |
5160 v[1].rhw = 1; | |
5161 v[1].diffuse = 0xFFFFFFFF; | |
5162 v[1].specular = 0; | |
5163 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
5164 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
5165 | |
692 | 5166 v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; |
5167 v[2].pos.y = pViewport->uScreen_TL_Y; | |
168 | 5168 v[2].pos.z = 0.99989998; |
5169 v[2].rhw = 1; | |
5170 v[2].diffuse = 0xFFFFFFFF; | |
5171 v[2].specular = 0; | |
5172 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
5173 v[2].texcoord.y = 0; | |
5174 | |
5175 memcpy(&v[3], &v[0], sizeof(*v)); | |
5176 | |
692 | 5177 v[4].pos.x = pViewport->uScreen_TL_X; |
5178 v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
168 | 5179 v[4].pos.z = 0.99989998; |
5180 v[4].rhw = 1; | |
5181 v[4].diffuse = 0xFFFFFFFF; | |
5182 v[4].specular = 0; | |
5183 v[4].texcoord.x = 0; | |
5184 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
5185 | |
5186 memcpy(&v[5], &v[1], sizeof(*v)); | |
5187 | |
5188 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); | |
5189 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture); | |
5190 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
5191 //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
5192 | |
5193 return true; | |
5194 } | |
5195 | |
5196 | |
5197 DDSURFACEDESC2 desc; | |
5198 desc.dwSize = sizeof(desc); | |
5199 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY)) | |
5200 return false; | |
5201 | |
5202 last_camera_rot_y = pParty->sRotationY; | |
5203 last_camera_rot_x = pParty->sRotationX; | |
5204 | |
5205 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight; | |
5206 float fov_x = 3.141592f * (pOutdoorCamera->uCameraFovInDegrees + 0) / 360.0f; | |
5207 float fov_y = fov_x / aspect; | |
5208 | |
5209 float ray_dx = fov_x / (float)pViewport->uScreenWidth, | |
5210 ray_dy = fov_y / (float)pViewport->uScreenHeight; | |
5211 float party_angle_x = 2 * 3.141592653589 * pParty->sRotationX / 2048.0, | |
5212 party_angle_y = 2 * 3.141592653589 * pParty->sRotationY / 2048.0; | |
5213 for (int y = 0; y < pViewport->uScreenHeight; ++y) | |
5214 for (int x = 0; x < pViewport->uScreenWidth; ++x) | |
5215 { | |
5216 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy; | |
5217 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx; | |
5218 | |
5219 float _dir_x_ = 1, | |
5220 _dir_y_ = 0, | |
5221 _dir_z_ = 0; | |
5222 | |
5223 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y | |
5224 //float dir_y_ = _dir_y_; | |
5225 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y); | |
5226 | |
5227 //float dir_x = dir_x_; // rotation around x | |
5228 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x); | |
5229 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x); | |
5230 | |
5231 vector right; // rotate around right actually to avoid space distortion | |
5232 right.x = /*dir_y * 0*/ - dir_z_ * 1; | |
5233 right.y = /*dir_z_ * 0 - dir_x_ * */0; | |
5234 right.z = dir_x_ * 1/* - dir_y_ * 0*/; | |
5235 //VectorNormalize(&right); | |
5236 | |
5237 matrix rightMatrix; | |
5238 MatrixRotationAxis(&rightMatrix, &right, angle_x); | |
5239 | |
5240 vector v1, v2; | |
5241 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_; | |
5242 VectorTransform(&rightMatrix, &v1, &v2); | |
5243 | |
5244 float dir_x = v2.x, | |
5245 dir_y = v2.y, | |
5246 dir_z = v2.z; | |
5247 | |
5248 float abs_dir_x = fabsf(dir_x), | |
5249 abs_dir_y = fabsf(dir_y), | |
5250 abs_dir_z = fabsf(dir_z); | |
5251 | |
5252 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange | |
5253 if (abs_dir_x >= abs_dir_y) | |
5254 { | |
5255 if (abs_dir_x >= abs_dir_z) | |
5256 { | |
5257 if (dir_x >= 0) | |
5258 { | |
5259 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0 | |
5260 float instersect_z = dir_z / (2.0f * dir_x); | |
5261 | |
5262 float u = 1.0f - (instersect_z + 0.5f), | |
5263 v = 1.0f - (instersect_y + 0.5f); | |
5264 | |
5265 int tx = u * (skybox_width - 1), | |
5266 ty = v * (skybox_height - 1); | |
5267 | |
5268 color = skybox_xp[ty * skybox_width + tx]; | |
5269 //color = ty * 0x1F / skybox_height; | |
5270 } | |
5271 else | |
5272 { | |
5273 float instersect_y = dir_y / (2.0f * dir_x); | |
5274 float instersect_z = dir_z / (2.0f * dir_x); | |
5275 | |
5276 float u = 1.0f - (instersect_z + 0.5f), | |
5277 v = instersect_y + 0.5f; | |
5278 | |
5279 int tx = u * (skybox_width - 1), | |
5280 ty = v * (skybox_height - 1); | |
5281 | |
5282 color = skybox_xn[ty * skybox_width + tx]; | |
5283 //color = tx * 0x1F / skybox_height; | |
5284 } | |
5285 } | |
5286 else if (dir_z >= 0) | |
5287 goto DIR_ZP; | |
5288 else | |
5289 goto DIR_ZN; | |
5290 } | |
5291 else if (abs_dir_y >= abs_dir_z) | |
5292 { | |
5293 if (dir_y >= 0) | |
5294 { | |
5295 float instersect_x = dir_x / (2.0f * dir_y); | |
5296 float instersect_z = dir_z / (2.0f * dir_y); | |
5297 | |
5298 float u = instersect_x + 0.5f, | |
5299 v = instersect_z + 0.5f; | |
5300 | |
5301 int tx = u * (skybox_width - 1), | |
5302 ty = v * (skybox_height - 1); | |
5303 | |
5304 color = skybox_yp[ty * skybox_width + tx]; | |
5305 //color = tx * 0x1F / skybox_height; | |
5306 } | |
5307 /*else should never be seen i guess | |
5308 { | |
5309 __debugbreak(); | |
5310 // -y | |
5311 //Log::Warning(L"(%03u, %03u): -y", x, y); | |
5312 }*/ | |
5313 } | |
5314 else if (dir_z >= 0) | |
5315 { | |
5316 DIR_ZP: | |
5317 // +z | |
5318 float instersect_x = dir_x / (2.0f * dir_z); | |
5319 float instersect_y = dir_y / (2.0f * dir_z); | |
5320 //float intersect_z = 0.5f; | |
5321 | |
5322 float u = instersect_x + 0.5f, | |
5323 v = -instersect_y + 0.5f; | |
5324 | |
5325 int tx = u * (skybox_width - 1), | |
5326 ty = v * (skybox_height - 1); | |
5327 | |
5328 color = skybox_zp[ty * skybox_width + tx]; | |
5329 } | |
5330 else | |
5331 { | |
5332 DIR_ZN: | |
5333 // -z | |
5334 float instersect_x = -dir_x / (2.0f * dir_z); | |
5335 float instersect_y = -dir_y / (2.0f * dir_z); | |
5336 //float intersect_z = -0.5f; | |
5337 | |
5338 float u = 1.0f - instersect_x - 0.5f, | |
5339 v = -instersect_y + 0.5f; | |
5340 | |
5341 int tx = u * (skybox_width - 1), | |
5342 ty = v * (skybox_height - 1); | |
5343 | |
5344 color = skybox_zn[ty * skybox_width + tx]; | |
5345 } | |
5346 | |
5347 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color; | |
5348 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color; | |
5349 } | |
5350 | |
5351 ErrD3D((skybox_surface)->Unlock(0)); | |
5352 goto draw; | |
5353 } | |
5354 | |
0 | 5355 //----- (00479543) -------------------------------------------------------- |
5356 void Render::DrawSkyD3D() | |
5357 { | |
5358 int v0; // esi@2 | |
5359 int v1; // eax@2 | |
5360 int v8; // eax@4 | |
5361 int v9; // eax@4 | |
5362 int v10; // ebx@4 | |
5363 signed __int64 v11; // qax@6 | |
1344 | 5364 //double v12; // st7@6 |
0 | 5365 int v13; // edi@6 |
5366 int v14; // ecx@6 | |
1344 | 5367 //int v15; // eax@8 |
0 | 5368 int v16; // eax@12 |
5369 signed __int64 v17; // qtt@13 | |
1344 | 5370 signed int pShading; // ecx@13 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5371 struct Polygon pSky; // [sp+14h] [bp-150h]@1 |
0 | 5372 float v28; // [sp+12Ch] [bp-38h]@2 |
5373 int v29; // [sp+130h] [bp-34h]@4 | |
5374 int v30; // [sp+134h] [bp-30h]@1 | |
5375 int v32; // [sp+13Ch] [bp-28h]@6 | |
5376 int v33; // [sp+140h] [bp-24h]@2 | |
67 | 5377 int v34; // [sp+144h] [bp-20h]@1 |
0 | 5378 int v35; // [sp+148h] [bp-1Ch]@4 |
67 | 5379 int v36; // [sp+14Ch] [bp-18h]@2 |
0 | 5380 int v37; // [sp+154h] [bp-10h]@8 |
5381 int v38; // [sp+158h] [bp-Ch]@1 | |
5382 int v39; // [sp+15Ch] [bp-8h]@4 | |
5383 int v40; // [sp+160h] [bp-4h]@7 | |
168 | 5384 |
5385 extern bool new_sky; | |
5386 if (new_sky) | |
5387 { | |
5388 if (DrawSkyD3D_Skybox()) | |
5389 return; | |
5390 } | |
0 | 5391 |
67 | 5392 v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z) |
5393 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY); | |
1344 | 5394 v38 = pViewport->uScreenCenterY - pOutdoorCamera->int_fov_rad / |
5395 (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) * | |
5396 (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z); | |
5397 | |
5398 pSky._48607B(&stru_8019C8); | |
5399 pSky.ptr_38->sky_48694B(); | |
5400 pSky.uTileBitmapID = pOutdoor->uSky_TextureID;//íîìåð òåêñòóðû | |
5401 pSky.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//òåêñòóðà íåáà | |
67 | 5402 if (pOutdoor->uSky_TextureID == -1) |
5403 return; | |
168 | 5404 |
1344 | 5405 pSky.dimming_level = 0;//çàòåìíåíèå |
5406 pSky.uNumVertices = 4;//êîëè÷åñòâî âåðøèí | |
5407 | |
5408 //centering(öåíòðóåì)--------------------------------------------------------------- | |
5409 pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216 | |
5410 pSky.v_18.y = 0; | |
5411 pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457 | |
5412 //--------------------------------------------------------------------------- | |
5413 | |
5414 pSky.field_24 = 0x2000000; | |
5415 | |
5416 pSky.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
5417 pSky.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
5418 | |
5419 //sky position(ïîëîæåíèå íåáà)---------------------------------------------- | |
693 | 5420 array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X; |
5421 array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y; | |
5422 | |
5423 array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X; | |
67 | 5424 array_50AC10[1].vWorldViewProjY = v38; |
5425 | |
693 | 5426 array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X; |
840 | 5427 array_50AC10[2].vWorldViewProjY = v38; |
693 | 5428 |
5429 array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X; | |
840 | 5430 array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y; |
1344 | 5431 //-------------------------------------------------------------------------- |
840 | 5432 |
895 | 5433 //pParty->sRotationY / 2048.0f |
1344 | 5434 // move sky(äâèäåíèå íåáà)--------------include----------------------------- |
895 | 5435 float t = (GetTickCount() % 96000) / 96000.0f; |
5436 array_50AC10[0].u = t - pParty->sRotationY / 1024.0f; | |
5437 array_50AC10[0].v = t - pParty->sRotationX / 512.0f; | |
5438 | |
5439 array_50AC10[1].u = t - pParty->sRotationY / 1024.0f; | |
5440 array_50AC10[1].v = 1 + t - pParty->sRotationX / 512.0f; | |
5441 | |
5442 array_50AC10[2].u = 1 + t - pParty->sRotationY / 1024.0f; | |
5443 array_50AC10[2].v = 1 + t - pParty->sRotationX / 512.0f; | |
5444 | |
5445 array_50AC10[3].u = 1 + t - pParty->sRotationY / 1024.0f; | |
5446 array_50AC10[3].v = t - pParty->sRotationX / 512.0f; | |
1344 | 5447 //-------------------------------------------------------------------------- |
5448 | |
5449 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
5450 v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//öåíòð ýêðàíà 230 | |
5451 v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);//214 | |
5452 | |
5453 for (uint i = 0; i < pSky.uNumVertices; ++i) | |
5454 { | |
5455 v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8 | |
5456 v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0 | |
5457 v8 = v39 + pSky.ptr_38->field_C;//0 | |
5458 | |
5459 v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0 | |
5460 v36 = v39 + pSky.ptr_38->field_18;//65536 | |
5461 | |
5462 v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;//27917 | |
5463 v10 = pSky.v_18.x + v9;//24701 | |
5464 v39 = pSky.v_18.x + v9;//24701 | |
5465 if ( pSky.v_18.x + v9 > 0 ) | |
577 | 5466 { |
5467 v10 = 0; | |
5468 v39 = 0; | |
5469 } | |
840 | 5470 //v11 = (signed __int64)array_50AC10[i].vWorldViewProjX; |
577 | 5471 v38 = v10; |
1344 | 5472 //v12 = array_50AC10[i].vWorldViewProjY - 1.0; |
840 | 5473 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); |
1344 | 5474 v34 = -pSky.field_24; |
5475 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; | |
577 | 5476 v14 = v33 * (v30 - v32); |
1344 | 5477 |
577 | 5478 while ( 1 ) |
5479 { | |
1344 | 5480 v40 = v14; |
577 | 5481 if ( !v10 ) |
5482 { | |
1344 | 5483 v37 = pSky.v_18.z; |
5484 v16 = (unsigned __int64)(pSky.v_18.z * (signed __int64)v14) >> 16; | |
0 | 5485 --v32; |
5486 v14 += v33; | |
1344 | 5487 v10 = pSky.v_18.x + v16; |
5488 v39 = pSky.v_18.x + v16; | |
5489 v38 = pSky.v_18.x + v16; | |
67 | 5490 break; |
5491 } | |
577 | 5492 v37 = abs(v34 >> 14); |
1344 | 5493 if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y ) |
577 | 5494 { |
5495 if ( v39 <= 0 ) | |
5496 break; | |
5497 } | |
1344 | 5498 v14 = v40; |
5499 v37 = pSky.v_18.z; | |
5500 v16 = (unsigned __int64)(pSky.v_18.z * v14) >> 16; | |
577 | 5501 --v32; |
5502 v14 += v33; | |
1344 | 5503 v10 = pSky.v_18.x + v16; |
5504 v39 = pSky.v_18.x + v16; | |
5505 v38 = pSky.v_18.x + v16; | |
577 | 5506 break; |
5507 } | |
1344 | 5508 |
577 | 5509 LODWORD(v17) = v34 << 16; |
5510 HIDWORD(v17) = v34 >> 16; | |
1344 | 5511 pShading = v17 / v38; |
5512 if ( pShading < 0 ) | |
5513 pShading = pOutdoorCamera->shading_dist_mist; | |
5514 | |
5515 v37 += ((unsigned __int64)(pSky.ptr_38->field_10 * v13) >> 16); | |
5516 v36 += ((unsigned __int64)(pSky.ptr_38->field_1C * v13) >> 16); | |
5517 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8; | |
5518 v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, pShading) / 8; | |
840 | 5519 |
579 | 5520 //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; |
1344 | 5521 //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0); |
840 | 5522 //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16); |
1344 | 5523 //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0); |
895 | 5524 //array_50AC10[i]._rhw = 1.0f / (v18 >> 16); |
1344 | 5525 //array_50AC10[i].u = (double)v35 / (65536.0 * pSky.pTexture->uTextureWidth); |
5526 //array_50AC10[i].v = (double)v36 / (65536.0 * pSky.pTexture->uTextureHeight); | |
5527 //----------------------------------------------------------------------------------------- | |
5528 | |
895 | 5529 array_50AC10[i]._rhw = 1.0f; |
1344 | 5530 } |
5531 //if ( i == _this.uNumVertices - 1 ) | |
5532 //{ | |
5533 pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]); | |
5534 | |
5535 array_50AC10[0].vWorldViewProjY = v38; | |
5536 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; | |
5537 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; | |
5538 array_50AC10[3].vWorldViewProjY = v38; | |
5539 | |
5540 pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]); | |
5541 //} | |
0 | 5542 } |
5543 | |
5544 //----- (0047A384) -------------------------------------------------------- | |
5545 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa) | |
5546 { | |
5547 int v2; // ebx@3 | |
5548 unsigned int v3; // eax@3 | |
5549 MapInfo *v4; // edi@4 | |
5550 //int v5; // eax@8 | |
5551 //SpawnPointMM7 *v6; // edx@14 | |
5552 size_t v7; // eax@19 | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5553 //char *v8; // eax@19 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5554 //char *v9; // eax@21 |
0 | 5555 char Source[120]; // [sp+Ch] [bp-84h]@19 |
5556 const char *pFilename; // [sp+84h] [bp-Ch]@1 | |
5557 //unsigned int v12; // [sp+88h] [bp-8h]@12 | |
5558 //int v13; // [sp+8Ch] [bp-4h]@11 | |
5559 | |
5560 pFilename = pLevelFilename; | |
5561 thisa->AllocSoftwareDrawBuffers(); | |
5562 pOutdoorCamera->_485F64(); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5563 pWeather->bRenderSnow = false; |
0 | 5564 pRenderer->ClearZBuffer(0, 479); |
5565 thisa = (OutdoorCamera *)1; | |
5566 GetAlertStatus(); | |
5567 if ( qword_A750D8 ) | |
5568 qword_A750D8 = 0i64; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
5569 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 5570 v3 = 0; |
5571 if ( v2 ) | |
5572 { | |
5573 v4 = &pMapStats->pInfos[v2]; | |
5574 v3 = v4->uRespawnIntervalDays; | |
5575 } | |
5576 else | |
5577 { | |
5578 v4 = (MapInfo *)thisa; | |
5579 } | |
767 | 5580 day_attrib &= ~DAY_ATTRIB_FOG; |
0 | 5581 dword_6BE13C_uCurrentlyLoadedLocationID = v2; |
5582 pOutdoor->Initialize( | |
5583 pFilename, | |
5584 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1, | |
5585 v3, | |
5586 (int)&thisa); | |
5587 if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x20) ) | |
5588 { | |
5589 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
5590 InitializeSpriteObjects(); |
0 | 5591 } |
5592 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; | |
5593 //v5 = 0; | |
5594 if ( !v2 ) | |
5595 thisa = 0; | |
5596 if ( thisa == (OutdoorCamera *)1 ) | |
5597 { | |
5598 //v13 = 0; | |
5599 for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i) | |
5600 { | |
5601 //v12 = 0; | |
5602 //while ( 1 ) | |
5603 //{ | |
5604 auto spawn = pOutdoor->pSpawnPoints + i; | |
5605 //v6 = &pOutdoor->pSpawnPoints[v12 / 0x18]; | |
5606 if (spawn->uKind == 3 ) | |
5607 SpawnEncounter(v4, spawn, 0, 0, 0); | |
5608 else | |
5609 v4->SpawnRandomTreasure(spawn); | |
5610 //++v13; | |
5611 //v12 += 24; | |
5612 //if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints ) | |
5613 // break; | |
5614 //v5 = 0; | |
5615 //} | |
5616 } | |
5617 RespawnGlobalDecorations(); | |
5618 } | |
5619 pOutdoor->PrepareDecorations(); | |
5620 pOutdoor->_47F223_LooksLikeGenerateMonsterLoot(); | |
5621 pOutdoor->InitalizeActors(v2); | |
5622 pOutdoor->MessWithLUN(); | |
5623 v7 = strlen("levels\\"); | |
5624 strcpy(Source, &pFilename[v7]); | |
5625 strcpy(pOutdoor->pLevelFilename, Source); | |
5626 pWeather->Initialize(); | |
5627 pIndoorCamera->sRotationY = pParty->sRotationY; | |
5628 pIndoorCamera->sRotationX = pParty->sRotationX; | |
5629 pOutdoorCamera->RotationToInts(); | |
5630 pOutdoor->UpdateSunlightVectors(); | |
5631 pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; | |
5632 pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5633 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5634 for (int i = 0; i < 20000; ++i) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5635 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5636 array_77EC08[i].ptr_38 = &stru_8019C8; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5637 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5638 array_77EC08[i].prolly_head = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5639 array_77EC08[i].prolly_tail = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5640 array_77EC08[i].ptr_48 = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5641 } |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5642 |
0 | 5643 MM7Initialization(); |
5644 } | |
5645 | |
5646 //----- (0047A825) -------------------------------------------------------- | |
5647 bool LevelDecoration::_47A825() | |
5648 { | |
5649 bool v1; // ebx@1 | |
5650 LevelDecoration *v2; // edi@1 | |
5651 | |
5652 v1 = 0; | |
5653 v2 = this; | |
484 | 5654 if ( pParty->uCurrentHour >= 1 || (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 178) ) |
0 | 5655 { |
5656 v1 = 0; | |
5657 } | |
5658 else | |
5659 { | |
484 | 5660 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 164) |
5661 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 165) | |
5662 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 166) | |
5663 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 167) | |
5664 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 168) | |
5665 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 169) | |
5666 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 170) | |
5667 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 171) | |
5668 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 172) | |
5669 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 173) | |
5670 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 174) | |
5671 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 175) | |
5672 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 176) | |
5673 && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 177) ) | |
0 | 5674 { |
5675 v1 = 1; | |
5676 LOBYTE(v2->field_2) &= 0xDFu; | |
5677 return v1; | |
5678 } | |
5679 } | |
5680 LOBYTE(v2->field_2) |= 0x20u; | |
5681 return v1; | |
5682 } | |
5683 | |
5684 | |
5685 //----- (0047C370) -------------------------------------------------------- | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5686 unsigned int GetLevelFogColor() |
0 | 5687 { |
5688 signed __int64 v1; // qax@5 | |
5689 int v2; // eax@6 | |
5690 | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5691 if (bUnderwater) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5692 return 0xFF258F5C; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5693 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5694 if (day_attrib & DAY_ATTRIB_FOG) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5695 { |
767 | 5696 if ( pWeather->bNight ) // night-time fog |
750 | 5697 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5698 __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad |
750 | 5699 v2 = -(pWeather->bNight != 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5700 return (v2 & 0xE0E0E1) - 0xE0E0E1; |
0 | 5701 } |
5702 else | |
5703 { | |
5704 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5705 return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); |
0 | 5706 } |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5707 } |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5708 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5709 return 0; |
0 | 5710 } |
5711 | |
5712 //----- (0047C3D7) -------------------------------------------------------- | |
5713 int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) | |
5714 { | |
5715 int v3; // ecx@1 | |
5716 double v5; // st7@10 | |
5717 signed int v7; // ecx@11 | |
5718 double v8; // st6@12 | |
5719 double v9; // st7@15 | |
5720 double v10; // st6@16 | |
5721 float v11; // ST14_4@17 | |
5722 double v12; // ST08_8@17 | |
5723 | |
750 | 5724 v3 = pWeather->bNight; |
0 | 5725 if ( bUnderwater == 1 ) |
5726 v3 = 0; | |
767 | 5727 if ( pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater ) |
349 | 5728 return 0xFF000000; |
0 | 5729 if ( v3 ) |
5730 { | |
5731 v5 = (double)day_fogrange_1; | |
5732 if ( a3 < v5 ) | |
1418 | 5733 { |
5734 v7 = 0; | |
5735 if ( a3 == 0.0 ) | |
5736 { | |
5737 v7 = 216; | |
5738 } | |
5739 goto LABEL_21; | |
5740 } | |
5741 else | |
5742 { | |
5743 v8 = (double)day_fogrange_2; | |
5744 if ( a3 > v8 ) | |
5745 { | |
5746 v7 = 216; | |
5747 if ( a3 == 0.0 ) | |
5748 { | |
5749 v7 = 216; | |
5750 } | |
5751 goto LABEL_21; | |
5752 } | |
5753 v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); | |
5754 } | |
0 | 5755 } |
5756 else | |
5757 { | |
5758 v9 = (double)day_fogrange_1; | |
5759 if ( a3 < v9 ) | |
5760 { | |
5761 v7 = 0; | |
1418 | 5762 if ( a3 == 0.0 ) |
5763 { | |
5764 v7 = 216; | |
5765 } | |
5766 goto LABEL_21; | |
0 | 5767 } |
1418 | 5768 else |
5769 { | |
5770 v10 = (double)day_fogrange_2; | |
5771 if ( a3 > v10 ) | |
5772 { | |
5773 v7 = 216; | |
5774 if ( a3 == 0.0 ) | |
5775 { | |
5776 v7 = 216; | |
5777 } | |
5778 goto LABEL_21; | |
5779 } | |
5780 else | |
5781 { | |
5782 v11 = (a3 - v9) * 216.0 / (v10 - v9); | |
5783 v12 = v11 + 6.7553994e15; | |
5784 v7 = LODWORD(v12); | |
5785 } | |
5786 } | |
5787 } | |
5788 if ( v7 > 216 ) | |
5789 { | |
5790 v7 = 216; | |
5791 } | |
5792 else | |
5793 { | |
5794 if ( a3 == 0.0 ) | |
5795 { | |
5796 v7 = 216; | |
5797 } | |
5798 } | |
0 | 5799 LABEL_21: |
5800 if ( a2 ) | |
5801 v7 = 248; | |
5802 return (-1 - v7) << 24; | |
5803 } | |
349 | 5804 |
0 | 5805 //----- (0047C4FC) -------------------------------------------------------- |
638 | 5806 signed int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5) |
349 | 5807 { |
5808 //int v5; // esi@1 | |
0 | 5809 signed int v6; // edx@1 |
349 | 5810 //signed int result; // eax@2 |
0 | 5811 int v8; // eax@3 |
5812 double v9; // st7@12 | |
750 | 5813 //double v10; // ST0C_8@18 |
0 | 5814 int v11; // ecx@28 |
349 | 5815 //signed int v12; // edi@28 |
5816 //double v13; // ST0C_8@33 | |
5817 //double v14; // ST0C_8@34 | |
0 | 5818 double v15; // st7@44 |
349 | 5819 //double v16; // ST0C_8@44 |
5820 //double v17; // ST0C_8@44 | |
0 | 5821 int v18; // ST14_4@44 |
349 | 5822 //double v19; // ST0C_8@44 |
0 | 5823 signed int v20; // [sp+10h] [bp-4h]@10 |
5824 float a3a; // [sp+1Ch] [bp+8h]@33 | |
638 | 5825 //float a3b; // [sp+1Ch] [bp+8h]@34 |
0 | 5826 float a3c; // [sp+1Ch] [bp+8h]@44 |
349 | 5827 //float a3d; // [sp+1Ch] [bp+8h]@44 |
750 | 5828 //float a4b; // [sp+20h] [bp+Ch]@18 |
638 | 5829 //int a4a; // [sp+20h] [bp+Ch]@33 |
349 | 5830 //float a4c; // [sp+20h] [bp+Ch]@44 |
5831 //float a4d; // [sp+20h] [bp+Ch]@44 | |
0 | 5832 int a5a; // [sp+24h] [bp+10h]@44 |
5833 | |
349 | 5834 //v5 = a2; |
0 | 5835 v6 = 0; |
349 | 5836 |
5837 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
638 | 5838 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8); |
5839 | |
349 | 5840 if (pParty->armageddon_timer) |
5841 return 0xFFFF0000; | |
5842 | |
750 | 5843 v8 = pWeather->bNight; |
638 | 5844 if (bUnderwater) |
0 | 5845 v8 = 0; |
5846 if ( v8 ) | |
5847 { | |
5848 v20 = 1; | |
349 | 5849 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) |
5850 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; | |
0 | 5851 v9 = (double)v20 * 1024.0; |
5852 if ( a4 ) | |
5853 goto LABEL_19; | |
638 | 5854 if ( distance <= v9 ) |
5855 { | |
5856 if ( distance > 0.0 ) | |
5857 { | |
750 | 5858 //a4b = distance * 216.0 / v9; |
5859 //v10 = a4b + 6.7553994e15; | |
5860 //v6 = LODWORD(v10); | |
5861 v6 = floorf(0.5f + distance * 216.0 / v9); | |
5862 if (v6 > 216 ) | |
0 | 5863 goto LABEL_19; |
5864 } | |
5865 } | |
5866 else | |
5867 { | |
5868 v6 = 216; | |
5869 } | |
638 | 5870 if ( distance != 0.0 ) |
0 | 5871 { |
5872 LABEL_20: | |
5873 if ( a5 ) | |
5874 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
5875 if ( v6 > 216 ) | |
5876 v6 = 216; | |
5877 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
5878 } | |
5879 LABEL_19: | |
5880 v6 = 216; | |
5881 goto LABEL_20; | |
5882 } | |
349 | 5883 |
5884 | |
5885 | |
638 | 5886 if (fabsf(distance) < 1.0e-6f) |
349 | 5887 return 0xFFF8F8F8; |
5888 | |
638 | 5889 // dim in measured in 8-steps |
5890 v11 = 8 * (max_dimm - min_dimm); | |
349 | 5891 //v12 = v11; |
0 | 5892 if ( v11 >= 0 ) |
5893 { | |
5894 if ( v11 > 216 ) | |
349 | 5895 v11 = 216; |
5896 } | |
5897 else | |
5898 v11 = 0; | |
5899 | |
638 | 5900 float fog_density_mult = 216.0f; |
5901 if (a4) | |
5902 fog_density_mult += distance / (double)pOutdoorCamera->shading_dist_shade * 32.0; | |
5903 | |
5904 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f); | |
5905 /*if ( a4 ) | |
5906 { | |
5907 //a3b = pOutdoor->fFogDensity * 216.0; | |
349 | 5908 //v14 = a3b + 6.7553994e15; |
638 | 5909 //a4a = floorf(a3b + 0.5f);//LODWORD(v14); |
5910 } | |
5911 else | |
5912 { | |
5913 //a3a = (distance / (double)pOutdoorCamera->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity; | |
349 | 5914 //v13 = a3a + 6.7553994e15; |
638 | 5915 //a4a = floorf(a3a + 0.5f);//LODWORD(v13); |
5916 } | |
5917 v6 = a4a + v11;*/ | |
0 | 5918 if ( a5 ) |
5919 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
5920 if ( v6 > 216 ) | |
5921 v6 = 216; | |
349 | 5922 if ( v6 < v11 ) |
5923 v6 = v11; | |
638 | 5924 if ( v6 > 8 * pOutdoor->max_terrain_dimming_level ) |
5925 v6 = 8 * pOutdoor->max_terrain_dimming_level; | |
0 | 5926 if ( !bUnderwater ) |
5927 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
349 | 5928 else |
5929 { | |
0 | 5930 v15 = (double)(255 - v6) * 0.0039215689; |
5931 a3c = v15; | |
349 | 5932 //a4c = v15 * 16.0; |
5933 //v16 = a4c + 6.7553994e15; | |
5934 a5a = floorf(v15 * 16.0 + 0.5f);//LODWORD(v16); | |
5935 //a4d = a3c * 194.0; | |
5936 //v17 = a4d + 6.7553994e15; | |
5937 v18 = floorf(a3c * 194.0 + 0.5f);//LODWORD(v17); | |
5938 //a3d = a3c * 153.0; | |
5939 //v19 = a3d + 6.7553994e15; | |
5940 return (int)floorf(a3c * 153.0 + 0.5f)/*LODWORD(v19)*/ | ((v18 | (a5a << 8)) << 8); | |
5941 } | |
0 | 5942 } |
5943 // 6BE3C4: using guessed type char bUnderwater; | |
5944 | |
5945 //----- (0047F44B) -------------------------------------------------------- | |
1412 | 5946 unsigned int WorldPosToGridCellX(int sWorldPosX) |
67 | 5947 { |
1412 | 5948 return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 |
5949 // and -880 sar 9 = -2 | |
0 | 5950 } |
5951 | |
5952 //----- (0047F458) -------------------------------------------------------- | |
1412 | 5953 unsigned int WorldPosToGridCellZ(int sWorldPosZ) |
67 | 5954 { |
1412 | 5955 return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 |
5956 // and -880 sar 9 = -2 | |
0 | 5957 } |
5958 | |
5959 //----- (0047F469) -------------------------------------------------------- | |
5960 int __stdcall GridCellToWorldPosX(int a1) | |
5961 { | |
5962 return (a1 - 64) << 9; | |
5963 } | |
5964 | |
5965 //----- (0047F476) -------------------------------------------------------- | |
5966 int __stdcall GridCellToWorldPosZ(int a1) | |
5967 { | |
5968 return (64 - a1) << 9; | |
5969 } | |
5970 | |
5971 | |
5972 //----- (004811A3) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
5973 void Polygon::DrawBorderTiles() |
1338 | 5974 { |
5975 //__debugbreak(); | |
5976 | |
5977 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
0 | 5978 pRenderer->DrawTerrainPolygon(uNumVertices, this, |
1338 | 5979 pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
5980 | |
5981 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
5982 //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true); | |
0 | 5983 } |
5984 | |
5985 | |
5986 //----- (00481EB7) -------------------------------------------------------- | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5987 void ResetPolygons() |
0 | 5988 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5989 for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5990 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5991 array_77EC08[i].prolly_head = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5992 array_77EC08[i].prolly_tail = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5993 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5994 array_77EC08[i].flags = 0; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
5995 array_77EC08[i].field_32 = 0; |
0 | 5996 } |
5997 } | |
5998 | |
5999 //----- (00481ED9) -------------------------------------------------------- | |
6000 void __cdecl sub_481ED9_MessWithOutdoorCamera() | |
6001 { | |
6002 stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0); | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6003 pOutdoorCamera->uNumPolygons = 0; |
0 | 6004 pOutdoorCamera->uNumEdges = 0; |
6005 pOutdoorCamera->uNumSpans = 0; | |
6006 pOutdoorCamera->uNumSurfs = 0; | |
6007 pOutdoorCamera->uNumBillboards = 0; | |
6008 pOutdoorCamera->field_44 = 0; | |
6009 } | |
6010 | |
6011 //----- (004823F4) -------------------------------------------------------- | |
138 | 6012 bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) |
6013 { | |
6014 //unsigned int v2; // ebx@1 | |
6015 //unsigned int v3; // edi@1 | |
6016 //int v4; // eax@1 | |
6017 //int v6; // esi@5 | |
6018 //int v7; // ecx@6 | |
6019 //int v8; // edx@6 | |
6020 //int v9; // eax@6 | |
6021 //int v10; // esi@10 | |
6022 //int v11; // [sp+14h] [bp-8h]@1 | |
6023 //int v12; // [sp+18h] [bp-4h]@1 | |
6024 | |
6025 //v12 = a1; | |
6026 //v11 = a2; | |
6027 auto grid_x = WorldPosToGridCellX(pos_x); | |
6028 auto grid_z = WorldPosToGridCellZ(pos_z) - 1; | |
6029 | |
6030 auto party_grid_x1 = GridCellToWorldPosX(grid_x); | |
6031 //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); | |
6032 //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); | |
6033 //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x); | |
6034 auto party_grid_z1 = GridCellToWorldPosZ(grid_z); | |
6035 //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z); | |
6036 //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
6037 //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
6038 auto party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); | |
6039 auto party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); | |
6040 auto party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); | |
6041 auto party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
6042 //dword_76D554_terrain_cell_world_pos_around_party_y = v4; | |
6043 if (party_x1z1_y == party_x2z1_y && | |
6044 party_x2z1_y == party_x2z2_y && | |
6045 party_x2z2_y == party_x1z2_y ) | |
6046 return false; | |
6047 | |
6048 auto dx = abs(pos_x - party_grid_x1), | |
6049 dz = abs(party_grid_z1 - pos_z); | |
6050 | |
6051 int y1, y2, y3; | |
6052 if (dz >= dx) | |
6053 { | |
6054 y1 = party_x1z2_y; // lower-left triangle | |
6055 y2 = party_x2z2_y; // y3 | \ | |
6056 y3 = party_x1z1_y; // | \ | |
6057 /* | \ | |
6058 |______ \ | |
6059 y1 y2 */ | |
6060 } | |
6061 else | |
6062 { | |
6063 y1 = party_x2z1_y; // upper-right | |
6064 y2 = party_x1z1_y; // y2_______ y1 | |
6065 y3 = party_x2z2_y; // \ | | |
6066 /* \ | | |
6067 \ | | |
6068 y3 */ | |
6069 } | |
6070 | |
6071 int y_min = min(y1, min(y2, y3)), | |
6072 y_max = max(y1, max(y2, y3)); | |
6073 return y_max - y_min > 512; | |
6074 | |
6075 /*if ( y1 >= y2 ) | |
6076 { | |
6077 y_min = y2; | |
6078 if ( y2 < y3 ) | |
0 | 6079 goto LABEL_13; |
6080 LABEL_12: | |
138 | 6081 y_min = y3; |
0 | 6082 goto LABEL_13; |
6083 } | |
138 | 6084 else if ( y1 >= y3 ) |
0 | 6085 goto LABEL_12; |
138 | 6086 else |
6087 y_min = y1; | |
6088 | |
0 | 6089 LABEL_13: |
138 | 6090 if ( y1 <= y2 ) |
6091 { | |
6092 if ( y2 > y3 ) | |
6093 y3 = y2; | |
6094 } | |
6095 else | |
6096 { | |
6097 if ( y1 > y3 ) | |
6098 y3 = y1; | |
6099 } | |
6100 return y3 - v10 > 512;*/ | |
0 | 6101 } |
6102 | |
6103 //----- (0048257A) -------------------------------------------------------- | |
812 | 6104 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater) |
6105 { | |
6106 //unsigned int v4; // ebx@1 | |
6107 //unsigned int v5; // edi@1 | |
0 | 6108 int result; // eax@9 |
812 | 6109 //int v7; // ebx@10 |
0 | 6110 int v8; // ebx@11 |
6111 int v9; // eax@11 | |
6112 int v10; // ecx@11 | |
812 | 6113 //int v11; // [sp+Ch] [bp-Ch]@1 |
6114 //int v12; // [sp+10h] [bp-8h]@1 | |
0 | 6115 int v13; // [sp+10h] [bp-8h]@11 |
6116 signed int v14; // [sp+14h] [bp-4h]@3 | |
6117 int v15; // [sp+24h] [bp+Ch]@11 | |
6118 | |
812 | 6119 //v11 = a1; |
6120 //v12 = a2; | |
6121 auto grid_x = WorldPosToGridCellX(a1); | |
6122 auto grid_z = WorldPosToGridCellZ(a2) - 1; | |
6123 | |
6124 auto grid_x1 = GridCellToWorldPosX(grid_x), | |
6125 grid_x2 = GridCellToWorldPosX(grid_x + 1); | |
6126 auto grid_z1 = GridCellToWorldPosZ(grid_z), | |
6127 grid_z2 = GridCellToWorldPosZ(grid_z + 1); | |
6128 | |
6129 auto y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z), | |
6130 y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z), | |
6131 y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1), | |
6132 y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
6133 //v4 = WorldPosToGridCellX(a1); | |
6134 //v5 = WorldPosToGridCellZ(v12) - 1; | |
6135 //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
6136 //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
6137 //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
6138 //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
6139 //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
6140 //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
6141 //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
6142 //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
6143 //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5); | |
6144 //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5); | |
6145 //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1); | |
6146 //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1); | |
791 | 6147 *pIsOnWater = false; |
812 | 6148 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2 ) |
791 | 6149 *pIsOnWater = true; |
0 | 6150 v14 = 0; |
812 | 6151 if ( !bFloatAboveWater && *pIsOnWater ) |
0 | 6152 v14 = -60; |
812 | 6153 if ( y_x1z1 != y_x2z1 || |
6154 y_x2z1 != y_x2z2 || | |
6155 y_x2z2 != y_x1z2 ) | |
6156 { | |
6157 if ( abs(grid_z1 - a2) >= abs(a1 - grid_x1) ) | |
6158 { | |
6159 v8 = y_x1z2; | |
6160 v9 = y_x2z2; | |
6161 v10 = y_x1z1; | |
6162 v15 = a1 - grid_x1; | |
6163 v13 = a2 - grid_z2; | |
0 | 6164 } |
6165 else | |
6166 { | |
812 | 6167 v8 = y_x2z1; |
6168 v9 = y_x1z1; | |
6169 v10 = y_x2z2; | |
6170 v15 = grid_x2 - a1; | |
6171 v13 = grid_z1 - a2; | |
6172 } | |
871 | 6173 return v14 + v8 + fixpoint_sub0(v13, (v10 - v8) * 128) + fixpoint_sub0(v15, (v9 - v8) * 128); |
812 | 6174 } |
6175 else | |
6176 return y_x1z1; | |
0 | 6177 } |
6178 | |
6179 //----- (00482A90) -------------------------------------------------------- | |
6180 signed int __cdecl const_1_0() | |
6181 { | |
6182 return 1; | |
6183 } | |
6184 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6185 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6186 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6187 |
0 | 6188 |
6189 //----- (00485F53) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6190 void __thiscall sr_485F53(Vec2_int_ *v) |
0 | 6191 { |
6192 ++v->y; | |
6193 if ( v->y > 1000 ) | |
6194 v->y = 0; | |
6195 } | |
6196 | |
6197 //----- (0048607B) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
6198 void Polygon::_48607B(stru149 *a2) |
0 | 6199 { |
6200 this->pTexture = 0; | |
6201 this->ptr_38 = a2; | |
6202 } | |
6203 | |
6204 //----- (00486089) -------------------------------------------------------- | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6205 void Polygon::_normalize_v_18() |
0 | 6206 { |
6207 double v2; // st7@1 | |
6208 double v3; // st6@1 | |
6209 double v5; // st5@1 | |
6210 | |
1025 | 6211 //v1 = this; |
0 | 6212 v2 = (double)this->v_18.x; |
6213 v3 = (double)this->v_18.y; | |
6214 v5 = (double)this->v_18.z; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6215 float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6216 if (fabsf(len) < 1e-6f) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6217 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6218 v_18.x = 0; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6219 v_18.y = 0; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6220 v_18.z = 65536; |
0 | 6221 } |
6222 else | |
6223 { | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6224 v_18.x = round(v2 / len * 65536.0); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6225 v_18.y = round(v3 / len * 65536.0); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
6226 v_18.y = round(v5 / len * 65536.0); |
0 | 6227 } |
6228 } | |
6229 | |
6230 //----- (0048616B) -------------------------------------------------------- | |
6231 int stru149::_48616B(int a2, int a3, int a4, int a5, int a6, int a7) | |
6232 { | |
6233 int v7; // ebx@1 | |
6234 int v8; // esi@1 | |
6235 int v9; // edi@1 | |
6236 int v10; // eax@1 | |
6237 int v11; // edx@1 | |
6238 int v12; // esi@2 | |
6239 int v13; // eax@2 | |
6240 int v14; // ST10_4@3 | |
6241 int v15; // esi@3 | |
6242 int v16; // eax@5 | |
6243 int v17; // ST0C_4@6 | |
6244 int v18; // eax@8 | |
6245 int v19; // ST0C_4@9 | |
6246 int v20; // eax@10 | |
6247 int v21; // edx@10 | |
6248 int v22; // eax@10 | |
6249 int result; // eax@10 | |
6250 int v24; // [sp+14h] [bp-14h]@1 | |
6251 int v25; // [sp+18h] [bp-10h]@1 | |
6252 int v26; // [sp+1Ch] [bp-Ch]@1 | |
6253 int v27; // [sp+24h] [bp-4h]@1 | |
6254 int v28; // [sp+30h] [bp+8h]@10 | |
6255 int v29; // [sp+3Ch] [bp+14h]@10 | |
6256 | |
6257 v25 = pOutdoorCamera->camera_rotation_x_int_cosine; | |
6258 v7 = pOutdoorCamera->camera_rotation_y_int_sine; | |
6259 v27 = pOutdoorCamera->camera_rotation_x_int_sine; | |
6260 v8 = -pIndoorCamera->pos.y; | |
6261 v9 = pOutdoorCamera->camera_rotation_y_int_cosine; | |
6262 v26 = -pIndoorCamera->pos.z; | |
6263 v24 = -pIndoorCamera->pos.x; | |
6264 v10 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.x; | |
6265 v11 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y; | |
6266 if ( pIndoorCamera->sRotationX ) | |
6267 { | |
6268 v14 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y; | |
6269 v15 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24; | |
755 | 6270 this->field_0_party_dir_x = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) |
0 | 6271 + ((unsigned __int64)(-65536 |
6272 * pIndoorCamera->pos.z | |
6273 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
755 | 6274 this->field_4_party_dir_y = v15; |
0 | 6275 v12 = v25; |
6276 v13 = ((unsigned __int64)((v26 << 16) * (signed __int64)v25) >> 16) | |
6277 - ((unsigned __int64)(v14 * (signed __int64)v27) >> 16); | |
6278 } | |
6279 else | |
6280 { | |
755 | 6281 this->field_4_party_dir_y = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24; |
0 | 6282 v12 = v25; |
755 | 6283 this->field_0_party_dir_x = v11; |
0 | 6284 v13 = v26 << 16; |
6285 } | |
6286 this->field_8 = v13; | |
6287 if ( pIndoorCamera->sRotationX ) | |
6288 { | |
6289 v17 = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16); | |
6290 this->field_C = ((unsigned __int64)(v17 * (signed __int64)v12) >> 16) | |
6291 + ((unsigned __int64)(a4 * (signed __int64)v27) >> 16); | |
6292 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16) | |
6293 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16); | |
6294 v16 = ((unsigned __int64)(a4 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v17 * (signed __int64)v27) >> 16); | |
6295 } | |
6296 else | |
6297 { | |
6298 this->field_C = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16) | |
6299 + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16); | |
6300 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16) | |
6301 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16); | |
6302 v16 = a4; | |
6303 } | |
6304 this->field_14 = v16; | |
6305 if ( pIndoorCamera->sRotationX ) | |
6306 { | |
6307 v19 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16); | |
6308 this->field_18 = ((unsigned __int64)(v19 * (signed __int64)v12) >> 16) | |
6309 + ((unsigned __int64)(a7 * (signed __int64)v27) >> 16); | |
6310 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16) | |
6311 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16); | |
6312 v18 = ((unsigned __int64)(a7 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v27) >> 16); | |
6313 } | |
6314 else | |
6315 { | |
6316 this->field_18 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16) | |
6317 + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16); | |
6318 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16) | |
6319 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16); | |
6320 v18 = a7; | |
6321 } | |
6322 this->field_18 = -this->field_18; | |
6323 this->field_1C = -this->field_1C; | |
6324 this->field_20 = v18; | |
6325 v20 = this->field_C; | |
6326 this->field_20 = -this->field_20; | |
755 | 6327 v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0_party_dir_x) >> 16) |
6328 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16) | |
0 | 6329 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16); |
6330 v28 = this->field_18; | |
755 | 6331 v22 = this->field_0_party_dir_x; |
0 | 6332 this->field_24 = v21; |
6333 v29 = (unsigned __int64)(v28 * (signed __int64)v22) >> 16; | |
755 | 6334 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16; |
0 | 6335 this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); |
6336 return result; | |
6337 } | |
6338 | |
6339 //----- (0048694B) -------------------------------------------------------- | |
1344 | 6340 int stru149::sky_48694B() |
0 | 6341 { |
6342 int v1; // eax@1 | |
6343 int v2; // ST04_4@1 | |
6344 int v3; // ST00_4@1 | |
6345 int v4; // eax@1 | |
6346 int v5; // ST0C_4@1 | |
6347 int result; // eax@1 | |
6348 | |
6349 v1 = this->field_C; | |
6350 this->field_18 = -this->field_18; | |
6351 this->field_1C = -this->field_1C; | |
6352 this->field_20 = -this->field_20; | |
755 | 6353 v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16; |
0 | 6354 v3 = this->field_18; |
755 | 6355 v4 = this->field_0_party_dir_x; |
0 | 6356 this->field_24 = v2 |
755 | 6357 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16) |
0 | 6358 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16); |
6359 v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16; | |
755 | 6360 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16; |
0 | 6361 this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); |
6362 return result; | |
6363 } | |
6364 | |
6365 //----- (0044100D) -------------------------------------------------------- | |
994 | 6366 bool sub_44100D() |
0 | 6367 { |
569 | 6368 return pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHARACTERS || |
6369 pCurrentScreen > SCREEN_LOADGAME && pCurrentScreen <= SCREEN_E || | |
6370 pCurrentScreen > SCREEN_VIDEO && pCurrentScreen <= SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_CASTING; | |
0 | 6371 } |
6372 // 4E28F8: using guessed type int pCurrentScreen; | |
6373 | |
6374 //----- (00441A4E) -------------------------------------------------------- | |
910 | 6375 __int16 __fastcall sub_441A4E(int a1)//for blessing |
0 | 6376 { |
6377 __int16 result; // ax@1 | |
6378 int v2; // ebx@1 | |
6379 char *v3; // esi@1 | |
6380 int v4; // edi@4 | |
1110 | 6381 bool v5; // ecx@4 |
0 | 6382 SpriteFrame *v6; // eax@6 |
6383 SpriteFrame *v7; // edi@6 | |
6384 int v8; // eax@6 | |
6385 unsigned __int16 v9; // ax@6 | |
6386 RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1 | |
6387 int v11; // [sp+5Ch] [bp-Ch]@6 | |
6388 int v12; // [sp+60h] [bp-8h]@1 | |
6389 int v13; // [sp+64h] [bp-4h]@6 | |
6390 | |
6391 v10.uParentBillboardID = -1; | |
6392 v10.pTarget = pRenderer->pTargetSurface; | |
6393 v10.pTargetZ = pRenderer->pActiveZBuffer; | |
6394 v10.uTargetPitch = pRenderer->field_10; | |
6395 result = 0; | |
6396 v2 = a1; | |
6397 v10.uViewportX = 0; | |
6398 v10.uViewportY = 0; | |
6399 v10.uViewportZ = 639; | |
6400 v10.uViewportW = 479; | |
6401 v12 = 0; | |
921 | 6402 //v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C; |
6403 //do | |
6404 for ( uint i = 0; i < 50; ++i ) | |
6405 { | |
6406 if ( pOtherOverlayList->pOverlays[i].field_6 > 0 ) | |
6407 { | |
6408 result = pOtherOverlayList->pOverlays[i].field_0; | |
6409 if ( pOtherOverlayList->pOverlays[i].field_0 >= 300 ) | |
6410 { | |
6411 //v4 = result; | |
6412 v5 = pOtherOverlayList->pOverlays[i].field_0 == v2 + 320 | |
1110 | 6413 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 330 |
6414 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 340 | |
6415 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 350; | |
921 | 6416 pOtherOverlayList->pOverlays[i].field_0 = v2 + 310; |
1110 | 6417 if ( pOtherOverlayList->pOverlays[i].field_0 == v2 + 310 || v5 ) |
921 | 6418 { |
6419 if ( !pOtherOverlayList->pOverlays[i].field_0 ) | |
6420 { | |
6421 v6 = pSpriteFrameTable->GetFrame(pOverlayList->pOverlays[pOtherOverlayList->pOverlays[i].field_2].uSpriteFramesetID, | |
6422 pOtherOverlayList->pOverlays[i].field_4); | |
0 | 6423 v7 = v6; |
921 | 6424 v11 = pOtherOverlayList->pOverlays[i].field_E; |
0 | 6425 v13 = v6->scale; |
6426 v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16; | |
921 | 6427 v10.uScreenSpaceX = pOtherOverlayList->pOverlays[i].field_8; |
6428 v10.uScreenSpaceY = pOtherOverlayList->pOverlays[i].field_A; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
6429 v10._screenspace_x_scaler_packedfloat = v13; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
6430 v10._screenspace_y_scaler_packedfloat = v13; |
0 | 6431 v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1); |
921 | 6432 v8 = pOtherOverlayList->pOverlays[i].field_2; |
0 | 6433 v10.sZValue = 0; |
6434 v10.uFlags = 0; | |
6435 v9 = pOverlayList->pOverlays[v8].uOverlayType; | |
6436 if ( !v9 || v9 == 2 ) | |
6437 v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1; | |
6438 result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0); | |
6439 ++v12; | |
6440 if ( v12 == 5 ) | |
6441 break; | |
6442 } | |
6443 } | |
6444 } | |
6445 } | |
921 | 6446 //v3 += 20; |
6447 } | |
6448 //while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays ); | |
0 | 6449 return result; |
6450 } | |
6451 | |
6452 //----- (00443801) -------------------------------------------------------- | |
237 | 6453 void Initialize2DA() |
6454 { | |
6455 | |
6456 int i; | |
6457 char* test_string; | |
6458 unsigned char c; | |
6459 bool break_loop; | |
6460 unsigned int temp_str_len; | |
6461 char* tmp_pos; | |
6462 int decode_step; | |
6463 | |
6464 if ( p2DEventsTXT_Raw ) | |
6465 pAllocator->FreeChunk(p2DEventsTXT_Raw); | |
6466 p2DEventsTXT_Raw = NULL; | |
6467 p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); | |
6468 strtok(p2DEventsTXT_Raw, "\r"); | |
6469 strtok(NULL, "\r"); | |
6470 | |
6471 for (i=0;i<525;++i) | |
6472 { | |
6473 test_string = strtok(NULL, "\r") + 1; | |
6474 break_loop = false; | |
6475 decode_step=0; | |
6476 do | |
6477 { | |
6478 c = *(unsigned char*)test_string; | |
6479 temp_str_len = 0; | |
6480 while((c!='\t')&&(c>0)) | |
6481 { | |
6482 ++temp_str_len; | |
6483 c=test_string[temp_str_len]; | |
6484 } | |
6485 tmp_pos=test_string+temp_str_len; | |
6486 if (*tmp_pos == 0) | |
6487 break_loop = true; | |
6488 *tmp_pos = 0; | |
6489 if (temp_str_len) | |
6490 { | |
6491 switch (decode_step) | |
6492 { | |
6493 case 2: | |
6494 { | |
6495 if ( !_strnicmp(test_string, "wea", 3) ) | |
6496 { | |
1411 | 6497 p2DEvents[i].uType = BuildingType_WeaponShop; |
237 | 6498 break; |
6499 } | |
6500 if ( !_strnicmp(test_string, "arm", 3) ) | |
6501 { | |
1411 | 6502 p2DEvents[i].uType = BuildingType_ArmorShop; |
237 | 6503 break; |
6504 } | |
6505 if ( !_strnicmp(test_string, "mag", 3) ) | |
6506 { | |
1411 | 6507 p2DEvents[i].uType = BuildingType_MagicShop; |
237 | 6508 break; |
6509 } | |
6510 if ( !_strnicmp(test_string, "alc", 3) ) | |
6511 { | |
1411 | 6512 p2DEvents[i].uType = BuildingType_AlchemistShop; |
237 | 6513 break; |
6514 } | |
6515 if ( !_strnicmp(test_string, "sta", 3) ) | |
6516 { | |
1411 | 6517 p2DEvents[i].uType = BuildingType_Stables; |
237 | 6518 break; |
6519 } | |
6520 if ( !_strnicmp(test_string, "boa", 3) ) | |
6521 { | |
1411 | 6522 p2DEvents[i].uType = BuildingType_Boats; |
237 | 6523 break; |
6524 } | |
6525 if ( !_strnicmp(test_string, "tem", 3) ) | |
6526 { | |
1411 | 6527 p2DEvents[i].uType = BuildingType_Temple; |
237 | 6528 break; |
6529 } | |
6530 if ( !_strnicmp(test_string, "tra", 3) ) | |
6531 { | |
1411 | 6532 p2DEvents[i].uType = BuildingType_Training; |
237 | 6533 break; |
6534 } | |
6535 if ( !_strnicmp(test_string, "tow", 3) ) | |
6536 { | |
1411 | 6537 p2DEvents[i].uType = BuildingType_TownHall; |
237 | 6538 break; |
6539 } | |
6540 | |
6541 if ( !_strnicmp(test_string, "tav", 3) ) | |
6542 { | |
1411 | 6543 p2DEvents[i].uType = BuildingType_Tavern; |
237 | 6544 break; |
6545 } | |
6546 if ( !_strnicmp(test_string, "ban", 3) ) | |
6547 { | |
1411 | 6548 p2DEvents[i].uType = BuildingType_Bank; |
237 | 6549 break; |
6550 } | |
6551 if ( !_strnicmp(test_string, "fir", 3) ) | |
6552 { | |
1411 | 6553 p2DEvents[i].uType = BuildingType_FireGuild; |
237 | 6554 break; |
6555 } | |
6556 if ( !_strnicmp(test_string, "air", 3) ) | |
6557 { | |
1411 | 6558 p2DEvents[i].uType = BuildingType_AirGuild; |
237 | 6559 break; |
6560 } | |
6561 if ( !_strnicmp(test_string, "wat", 3) ) | |
6562 { | |
1411 | 6563 p2DEvents[i].uType = BuildingType_WaterGuild; |
237 | 6564 break; |
6565 } | |
6566 if ( !_strnicmp(test_string, "ear", 3) ) | |
6567 { | |
1411 | 6568 p2DEvents[i].uType = BuildingType_EarthGuild; |
237 | 6569 break; |
6570 } | |
6571 if ( !_strnicmp(test_string, "spi", 3) ) | |
6572 { | |
1411 | 6573 p2DEvents[i].uType = BuildingType_SpiritGuild; |
237 | 6574 break; |
6575 } | |
6576 if ( !_strnicmp(test_string, "min", 3) ) | |
6577 { | |
1411 | 6578 p2DEvents[i].uType = BuildingType_MindGuild; |
237 | 6579 break; |
6580 } | |
6581 if ( !_strnicmp(test_string, "bod", 3) ) | |
6582 { | |
1411 | 6583 p2DEvents[i].uType = BuildingType_BodyGuild; |
237 | 6584 break; |
6585 } | |
6586 if ( !_strnicmp(test_string, "lig", 3) ) | |
6587 { | |
1411 | 6588 p2DEvents[i].uType = BuildingType_LightGuild; |
237 | 6589 break; |
6590 } | |
6591 if ( !_strnicmp(test_string, "dar", 3) ) | |
6592 { | |
1411 | 6593 p2DEvents[i].uType = BuildingType_DarkGuild; |
237 | 6594 break; |
6595 } | |
6596 if ( !_strnicmp(test_string, "ele", 3) ) | |
6597 { | |
1411 | 6598 p2DEvents[i].uType = BuildingType_14; |
237 | 6599 break; |
6600 } | |
6601 if ( !_strnicmp(test_string, "sel", 3) ) | |
6602 { | |
1411 | 6603 p2DEvents[i].uType = BuildingType_15; |
237 | 6604 break; |
6605 } | |
6606 if ( !_strnicmp(test_string, "mir", 3) ) | |
6607 { | |
1411 | 6608 p2DEvents[i].uType = BuildingType_16; |
237 | 6609 break; |
6610 } | |
6611 if ( !_strnicmp(test_string, "mer", 3) ) | |
6612 { | |
1411 | 6613 p2DEvents[i].uType = BuildingType_TownHall; |
237 | 6614 break; |
6615 } | |
1411 | 6616 p2DEvents[i].uType = BuildingType_18; |
237 | 6617 } |
6618 break; | |
6619 | |
6620 case 4: | |
6621 p2DEvents[i].uAnimationID = atoi(test_string); | |
6622 break; | |
6623 case 5: | |
6624 p2DEvents[i].pName = RemoveQuotes(test_string); | |
6625 break; | |
6626 case 6: | |
6627 p2DEvents[i].pProprieterName = RemoveQuotes(test_string); | |
6628 break; | |
6629 case 7: | |
6630 p2DEvents[i].pProprieterTitle = RemoveQuotes(test_string); | |
6631 break; | |
6632 case 8: | |
6633 p2DEvents[i].field_14 = atoi(test_string); | |
6634 break; | |
6635 case 9: | |
6636 p2DEvents[i]._state = atoi(test_string); | |
6637 break; | |
6638 case 10: | |
6639 p2DEvents[i]._rep = atoi(test_string); | |
6640 break; | |
6641 case 11: | |
6642 p2DEvents[i]._per = atoi(test_string); | |
6643 break; | |
6644 case 12: | |
6645 p2DEvents[i].fPriceMultiplier = atof(test_string); | |
6646 break; | |
6647 case 13: | |
6648 p2DEvents[i].flt_24 = atof(test_string); | |
6649 break; | |
6650 case 15: | |
6651 p2DEvents[i].field_1C = atoi(test_string); | |
6652 break; | |
6653 case 18: | |
6654 p2DEvents[i].uOpenTime = atoi(test_string); | |
6655 break; | |
6656 case 19: | |
6657 p2DEvents[i].uCloseTime = atoi(test_string); | |
6658 break; | |
6659 case 20: | |
6660 p2DEvents[i].uExitPicID = atoi(test_string); | |
6661 break; | |
6662 case 21: | |
6663 p2DEvents[i].uExitMapID = atoi(test_string); | |
6664 break; | |
6665 case 22: | |
6666 p2DEvents[i]._quest_related = atoi(test_string); | |
6667 break; | |
6668 case 23: | |
6669 p2DEvents[i].pEnterText = RemoveQuotes(test_string); | |
6670 break; | |
6671 } | |
6672 } | |
6673 ++decode_step; | |
6674 test_string=tmp_pos+1; | |
6675 } while ((decode_step<24)&&!break_loop); | |
6676 } | |
6677 | |
0 | 6678 } |
6679 | |
6680 //----- (00443E31) -------------------------------------------------------- | |
601 | 6681 void LoadLevel_InitializeLevelStr() |
6682 { | |
329 | 6683 |
6684 char Args[100]; | |
6685 int string_num; | |
6686 int max_string_length; | |
6687 int current_string_length; | |
6688 int prev_string_offset; | |
6689 | |
6690 if (sizeof(pLevelStrOffsets) != 2000) | |
0 | 6691 Log::Warning(L"pLevelStrOffsets: deserialization warning"); |
1202 | 6692 memset(pLevelStrOffsets.data(), 0, 2000); |
0 | 6693 |
329 | 6694 max_string_length = 0; |
6695 string_num = 1; | |
6696 prev_string_offset = 0; | |
336 | 6697 pLevelStrOffsets[0]=0; |
0 | 6698 for (uint i = 0; i < uLevelStrFileSize; ++i) |
6699 { | |
6700 if ( !pLevelStr[i] ) | |
6701 { | |
329 | 6702 pLevelStrOffsets[string_num] = i + 1; |
6703 ++string_num; | |
6704 if ( i - prev_string_offset > max_string_length ) | |
6705 max_string_length = i - prev_string_offset; | |
6706 prev_string_offset = i; | |
6707 } | |
6708 } | |
6709 | |
6710 uLevelStrNumStrings = string_num - 1; | |
6711 if ( max_string_length > 800 ) | |
6712 { | |
6713 sprintf(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length+1); | |
0 | 6714 Abortf(Args); |
6715 } | |
329 | 6716 |
6717 if ( uLevelStrNumStrings > 0 ) | |
6718 { | |
336 | 6719 for(uint i = 0; i <uLevelStrNumStrings ; ++i) |
329 | 6720 { |
6721 if ( RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]] ) | |
6722 ++pLevelStrOffsets[i]; | |
6723 } | |
0 | 6724 } |
6725 } | |
6726 | |
6727 //----- (00443F95) -------------------------------------------------------- | |
6728 void __cdecl OnMapLeave() | |
6729 { | |
336 | 6730 _evt_raw *test_event; |
6731 if ( uLevelEVT_NumEvents > 0 ) | |
6732 { | |
6733 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
6734 { | |
6735 test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; | |
1052 | 6736 if ( test_event->_e_type == EVENT_OnMapLeave ) |
6737 { | |
6738 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); | |
336 | 6739 } |
6740 } | |
0 | 6741 } |
6742 } | |
6743 | |
6744 //----- (00443FDC) -------------------------------------------------------- | |
6745 void OnMapLoad() | |
781 | 6746 { |
363 | 6747 stru176 *v3; // esi@7 |
6748 __int16 v4; // cx@9 | |
6749 __int16 v5; // di@9 | |
6750 int v6; // eax@9 | |
6751 signed __int64 v8; // qax@26 | |
6752 unsigned int v9; // ecx@26 | |
6753 signed __int64 v10; // qax@26 | |
6754 signed __int64 v11; // qax@26 | |
6755 int v12; // ST50_4@26 | |
6756 signed __int64 v13; // qax@26 | |
6757 signed __int64 v14; // qax@26 | |
6758 int v15; // ST58_4@26 | |
6759 signed __int64 v16; // qax@26 | |
6760 int hours; // ebx@26 | |
6761 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 | |
6762 signed __int64 seconds; // [sp+14h] [bp-3Ch]@26 | |
6763 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 | |
6764 int minutes; // [sp+2Ch] [bp-24h]@26 | |
6765 int years; // [sp+34h] [bp-1Ch]@26 | |
6766 int weeks; // [sp+38h] [bp-18h]@26 | |
6767 int v26; // [sp+3Ch] [bp-14h]@15 | |
6768 int days; // [sp+3Ch] [bp-14h]@26 | |
6769 int months; // [sp+40h] [bp-10h]@26 | |
6770 __int16 v29; // [sp+46h] [bp-Ah]@9 | |
6771 __int16 v30; // [sp+48h] [bp-8h]@9 | |
6772 __int16 v31; // [sp+4Ah] [bp-6h]@9 | |
6773 __int16 v32; // [sp+4Ch] [bp-4h]@9 | |
6774 __int16 v33; // [sp+4Eh] [bp-2h]@9 | |
6775 | |
6776 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
781 | 6777 { |
363 | 6778 auto pEvent = pLevelEVT_Index[i]; |
6779 | |
1202 | 6780 auto _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); |
363 | 6781 |
6782 if (_evt->_e_type == EVENT_PlaySound) | |
781 | 6783 { |
601 | 6784 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); |
781 | 6785 } |
363 | 6786 else if (_evt->_e_type == EVENT_OnMapReload) |
781 | 6787 { |
1052 | 6788 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); |
781 | 6789 } |
1052 | 6790 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) |
781 | 6791 { |
363 | 6792 v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; |
810 | 6793 v20 = pOutdoor->loc_time.uLastVisitDay; |
363 | 6794 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
6795 v20 = pIndoor->stru1.uLastVisitDay; | |
6796 | |
6797 v3->timer_evt_type = _evt->_e_type; | |
6798 v3->timer_evt_ID = pEvent.uEventID; | |
6799 v3->timer_evt_seq_num = pEvent.event_sequence_num; | |
6800 | |
6801 v3->field_10 = _evt->v5; | |
6802 v3->field_12 = _evt->v6; | |
6803 v3->field_14 = _evt->v7; | |
6804 v3->field_16 = _evt->v8; | |
6805 v3->field_18 = _evt->v9; | |
6806 v3->field_1A = _evt->v10; | |
6807 | |
6808 | |
6809 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
6810 | |
789 | 6811 v3->time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; |
6812 v3->fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
1052 | 6813 if (v3->timer_evt_type == EVENT_Initialize && !(short)v6 ) |
781 | 6814 { |
363 | 6815 if ( v20 ) |
6816 v18 = pParty->uTimePlayed - v20; | |
6817 else | |
6818 v18 = 0i64; | |
6819 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; | |
6820 | |
6821 if ( v26 / 7 / 4 / 12 ) | |
781 | 6822 { |
363 | 6823 if ( v3->field_10 ) |
781 | 6824 { |
363 | 6825 ++dword_5B65C8_timers_count; |
789 | 6826 v3->next_fire_time = 0; |
363 | 6827 continue; |
6828 } | |
781 | 6829 } |
363 | 6830 if (v26 / 7 / 4 != 0 && v3->field_12 != 0 || |
6831 v26 / 7 != 0 && v3->field_14 != 0 || | |
6832 v26 != 0 || !v20) | |
781 | 6833 { |
363 | 6834 ++dword_5B65C8_timers_count; |
789 | 6835 v3->next_fire_time = 0; |
363 | 6836 continue; |
6837 } | |
781 | 6838 } |
363 | 6839 else |
781 | 6840 { |
363 | 6841 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); |
6842 v9 = v8; | |
6843 v10 = (signed int)v8 / 60; | |
6844 minutes = v10 % 60; | |
6845 v11 = (signed int)(v10 / 60); | |
6846 v12 = v11 % 24; | |
6847 v13 = (signed int)(v11 / 24); | |
6848 days = v13 % 7; | |
6849 v14 = (signed int)(v13 / 7); | |
6850 v15 = v14 % 4; | |
6851 v16 = (signed int)(v14 / 4); | |
6852 years = v16 / 12; | |
6853 | |
6854 auto _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32; | |
6855 auto _2 = ((__int64)v9 << 32) | _1; | |
6856 | |
6857 seconds = _2 % 60; | |
6858 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32, | |
6859 // v9) | |
6860 // % 60; | |
6861 | |
6862 hours = v12; | |
6863 weeks = v15; | |
6864 months = v16 % 12; | |
6865 if ( v3->field_10 ) | |
781 | 6866 { |
363 | 6867 ++years; |
781 | 6868 } |
363 | 6869 else |
781 | 6870 { |
363 | 6871 if ( v3->field_12 ) |
781 | 6872 { |
6873 ++months; | |
6874 } | |
6875 else | |
6876 { | |
6877 if ( v3->field_14 ) | |
363 | 6878 { |
781 | 6879 ++weeks; |
363 | 6880 } |
781 | 6881 else |
363 | 6882 { |
6883 ++days; | |
6884 minutes = v3->field_18; | |
6885 hours = v3->field_16; | |
6886 seconds = v3->field_1A; | |
6887 } | |
6888 } | |
781 | 6889 } |
789 | 6890 v3->next_fire_time = (signed __int64)((double)((seconds |
363 | 6891 + 60 * minutes |
6892 + 3600 * hours | |
6893 + 0x93A80 * weeks | |
6894 + 0x15180 * days | |
6895 + 0x24EA00 * (months + 12i64 * years)) << 7) | |
6896 * 0.033333335); | |
6897 | |
6898 ++dword_5B65C8_timers_count; | |
6899 } | |
6900 } | |
6901 } | |
781 | 6902 } |
0 | 6903 |
6904 //----- (00444360) -------------------------------------------------------- | |
1411 | 6905 void Level_LoadEvtAndStr(const char *pLevelName) |
0 | 6906 { |
6907 char pContainerName[120]; // [sp+8h] [bp-98h]@1 | |
6908 | |
6909 sprintf(pContainerName, "%s.evt", pLevelName); | |
1202 | 6910 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 0x2400u); |
0 | 6911 |
6912 sprintf(pContainerName, "%s.str", pLevelName); | |
1202 | 6913 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 0x2400u); |
0 | 6914 if (uLevelStrFileSize) |
6915 LoadLevel_InitializeLevelStr(); | |
6916 } | |
6917 | |
6918 //----- (00444564) -------------------------------------------------------- | |
6919 const char *__cdecl sub_444564() | |
6920 { | |
6921 double v0; // st7@3 | |
6922 int v1; // ebx@3 | |
6923 int v2; // edi@3 | |
6924 int v3; // eax@3 | |
6925 int v5; // edi@6 | |
6926 int v6; // eax@6 | |
6927 int v7; // eax@6 | |
6928 unsigned __int8 v9; // zf@7 | |
6929 unsigned __int8 v10; // sf@7 | |
6930 ODMFace *v11; // eax@9 | |
6931 __int16 v12; // cx@9 | |
6932 const char *v13; // eax@11 | |
6933 const char *v14; // edi@11 | |
6934 const char *result; // eax@15 | |
6935 unsigned int v16; // [sp+0h] [bp-20h]@3 | |
6936 const char *v17; // [sp+4h] [bp-1Ch]@3 | |
6937 unsigned int pY; // [sp+8h] [bp-18h]@3 | |
6938 float v19; // [sp+Ch] [bp-14h]@1 | |
695 | 6939 int v20; |
0 | 6940 int v21; // [sp+14h] [bp-Ch]@1 |
6941 unsigned int v22; // [sp+18h] [bp-8h]@8 | |
6942 int pX; // [sp+1Ch] [bp-4h]@3 | |
6943 | |
693 | 6944 v20 = viewparams->sViewCenterX; |
6945 v21 = viewparams->sViewCenterY; | |
0 | 6946 v19 = (double)viewparams->field_2C * 0.000015258789; |
6947 if ( viewparams->field_2C == 384 ) | |
6948 { | |
711 | 6949 v20 = viewparams->indoor_center_x; |
6950 v21 = viewparams->indoor_center_y; | |
0 | 6951 } |
6952 v17 = 0; | |
6953 v16 = pOutdoor->uNumBModels; | |
6954 pMouse->GetClickPos((unsigned int *)&pX, &pY); | |
6955 v0 = 1.0 / v19; | |
6956 v1 = (signed __int64)((double)(pX - 229) * v0 + (double)v20); | |
6957 LODWORD(v19) = (signed __int64)((double)v21 - (double)(signed int)(pY - 181) * v0); | |
6958 v2 = abs(v1 + 22528) / 512; | |
6959 v3 = abs((signed)LODWORD(v19) - 22528); | |
695 | 6960 result = 0; |
0 | 6961 if ( pOutdoor->_47F04C(v2, v3 / 512) |
6962 && uCurrentlyLoadedLevelType == LEVEL_Outdoor | |
695 | 6963 && (signed int)v16 > 0 ) |
6964 { | |
6965 for(int i = 0; i < pOutdoor->uNumBModels && !v17; i++) | |
6966 { | |
6967 pX = pOutdoor->pBModels[i].vBoundingCenter.x - v1; | |
6968 pY = pOutdoor->pBModels[i].vBoundingCenter.y - LODWORD(v19); | |
0 | 6969 v5 = abs((signed)pY); |
6970 v6 = abs((signed)pX); | |
322 | 6971 v7 = int_get_vector_length(v6, v5, 0); |
695 | 6972 if ( v7 < pOutdoor->pBModels[i].sBoundingRadius ) |
6973 { | |
6974 if ( pOutdoor->pBModels[i].uNumFaces > 0 ) | |
6975 { | |
6976 for(int j = 0; j < pOutdoor->pBModels[i].uNumFaces; j++) | |
6977 { | |
6978 v11 = &pOutdoor->pBModels[i].pFaces[j];//&v8[v4]->pFaces[v22 / 0x134]; | |
0 | 6979 v12 = v11->sCogTriggeredID; |
6980 if ( v12 ) | |
6981 { | |
6982 if ( !(BYTE2(v11->uAttributes) & 0x10) ) | |
6983 { | |
428 | 6984 v13 = GetEventHintString(v12); |
0 | 6985 v14 = v13; |
6986 if ( v13 ) | |
6987 { | |
1104 | 6988 if ( _stricmp(v13, "") ) |
0 | 6989 v17 = v14; |
6990 } | |
6991 } | |
6992 } | |
695 | 6993 } |
0 | 6994 } |
6995 result = v17; | |
695 | 6996 } |
6997 } | |
0 | 6998 } |
6999 return result; | |
7000 } | |
7001 | |
7002 //----- (00444D80) -------------------------------------------------------- | |
1411 | 7003 int GetTravelTime() |
0 | 7004 { |
7005 signed int v0; // esi@1 | |
7006 | |
7007 v0 = uDefaultTravelTime_ByFoot; | |
652 | 7008 if ( CheckHiredNPCSpeciality(Guide) ) |
0 | 7009 --v0; |
652 | 7010 if ( CheckHiredNPCSpeciality(Tracker) ) |
0 | 7011 v0 -= 2; |
652 | 7012 if ( CheckHiredNPCSpeciality(Pathfinder) ) |
0 | 7013 v0 -= 3; |
652 | 7014 if ( CheckHiredNPCSpeciality(Explorer) ) |
0 | 7015 --v0; |
7016 if ( v0 < 1 ) | |
7017 v0 = 1; | |
7018 return v0; | |
7019 } | |
7020 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; | |
7021 | |
7022 //----- (004451A8) -------------------------------------------------------- | |
7023 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) | |
7024 { | |
7025 int v3; // esi@1 | |
7026 int v4; // edi@1 | |
7027 | |
7028 v3 = a2; | |
7029 v4 = a1; | |
7030 if ( !pGUIWindow2 ) | |
7031 { | |
7032 if ( pParty->uFlags & 2 ) | |
7033 pGame->Draw(); | |
1052 | 7034 pAudioPlayer->StopChannels(-1, -1); |
0 | 7035 pMiscTimer->Pause(); |
7036 pEventTimer->Pause(); | |
7037 dword_5C3418 = v4; | |
7038 dword_5C341C = v3; | |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
7039 _591094_decoration = activeLevelDecoration; |
948 | 7040 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0); |
7041 pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); | |
7042 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
7043 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
7044 pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
0 | 7045 } |
7046 } | |
7047 | |
7048 //----- (004452BB) -------------------------------------------------------- | |
7049 void __cdecl sub_4452BB() | |
7050 { | |
7051 pGUIWindow2->Release(); | |
7052 pGUIWindow2 = 0; | |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
7053 activeLevelDecoration = _591094_decoration; |
1052 | 7054 EventProcessor(dword_5C3418, 0, 1, dword_5C341C); |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
7055 activeLevelDecoration = NULL; |
0 | 7056 pEventTimer->Resume(); |
7057 } | |
7058 | |
7059 //----- (004465DF) -------------------------------------------------------- | |
7060 int sub_4465DF_check_season(int a1) | |
7061 { | |
7062 unsigned int v1; // eax@1 | |
7063 unsigned int v2; // edx@1 | |
7064 int v3; // ecx@2 | |
7065 int v4; // ecx@3 | |
7066 char v6; // zf@9 | |
7067 | |
7068 v1 = pParty->uCurrentMonth + 1; | |
7069 v2 = pParty->uDaysPlayed + 1; | |
7070 if ( a1 ) | |
7071 { | |
7072 v3 = a1 - 1; | |
7073 if ( v3 ) | |
7074 { | |
7075 v4 = v3 - 1; | |
7076 if ( v4 ) | |
7077 { | |
7078 if ( v4 != 1 ) | |
7079 return 0; | |
7080 if ( v1 != 12 ) | |
7081 { | |
7082 if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 ) | |
7083 return 1; | |
7084 v6 = v1 == 3; | |
7085 LABEL_24: | |
7086 if ( !v6 || (signed int)v2 >= 21 ) | |
7087 return 0; | |
7088 return 1; | |
7089 } | |
7090 } | |
7091 else | |
7092 { | |
7093 if ( v1 != 9 ) | |
7094 { | |
7095 if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 ) | |
7096 return 1; | |
7097 v6 = v1 == 12; | |
7098 goto LABEL_24; | |
7099 } | |
7100 } | |
7101 } | |
7102 else | |
7103 { | |
7104 if ( v1 != 6 ) | |
7105 { | |
7106 if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 ) | |
7107 return 1; | |
7108 v6 = v1 == 9; | |
7109 goto LABEL_24; | |
7110 } | |
7111 } | |
7112 } | |
7113 else | |
7114 { | |
7115 if ( v1 != 3 ) | |
7116 { | |
7117 if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 ) | |
7118 return 1; | |
7119 v6 = v1 == 6; | |
7120 goto LABEL_24; | |
7121 } | |
7122 } | |
7123 if ( (signed int)v2 >= 21 ) | |
7124 return 1; | |
7125 return 0; | |
7126 } | |
7127 | |
7128 //----- (0044861E) -------------------------------------------------------- | |
7129 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) | |
7130 { | |
7131 unsigned int v2; // eax@2 | |
7132 unsigned __int16 v3; // di@2 | |
7133 signed int v4; // esi@5 | |
7134 BLVFace *v5; // eax@7 | |
7135 unsigned int *v6; // eax@8 | |
7136 char *v7; // eax@9 | |
7137 int v8; // edi@16 | |
7138 char *v9; // esi@16 | |
7139 ODMFace *v10; // eax@17 | |
7140 unsigned int *v11; // eax@19 | |
7141 unsigned __int16 v12; // [sp+Ch] [bp-18h]@2 | |
7142 const char *Str2; // [sp+10h] [bp-14h]@1 | |
7143 unsigned int v14; // [sp+14h] [bp-10h]@1 | |
7144 signed int v15; // [sp+18h] [bp-Ch]@14 | |
7145 int v16; // [sp+1Ch] [bp-8h]@15 | |
7146 signed int v17; // [sp+20h] [bp-4h]@4 | |
7147 signed int v18; // [sp+20h] [bp-4h]@16 | |
7148 | |
7149 Str2 = pFilename; | |
7150 v14 = uFaceCog; | |
7151 if ( uFaceCog ) | |
7152 { | |
7153 v2 = pBitmaps_LOD->LoadTexture(pFilename); | |
7154 v3 = v2; | |
7155 v12 = v2; | |
7156 if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 ) | |
7157 { | |
7158 pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1); | |
7159 | |
7160 if ( uCurrentlyLoadedLevelType == 1 ) | |
7161 { | |
7162 v17 = 1; | |
7163 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) | |
7164 { | |
7165 v4 = 1; | |
7166 do | |
7167 { | |
7168 if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 ) | |
7169 { | |
7170 v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C]; | |
7171 if ( BYTE1(v5->uAttributes) & 0x40 ) | |
7172 { | |
7173 pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName( | |
7174 Str2); | |
7175 v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID; | |
7176 if ( *(_WORD *)v6 ) | |
7177 { | |
7178 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6); | |
7179 } | |
7180 else | |
7181 { | |
7182 *(_WORD *)v6 = v3; | |
7183 v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes; | |
7184 v7[1] &= 0xBFu; | |
7185 } | |
7186 } | |
7187 else | |
7188 { | |
7189 v5->uBitmapID = v3; | |
7190 } | |
7191 } | |
7192 ++v17; | |
7193 ++v4; | |
7194 } | |
7195 while ( v17 < (signed int)pIndoor->uNumFaceExtras ); | |
7196 } | |
7197 pParty->uFlags |= 2u; | |
7198 } | |
7199 else | |
7200 { | |
7201 v15 = 0; | |
7202 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
7203 { | |
7204 v16 = 0; | |
7205 do | |
7206 { | |
7207 v8 = 0; | |
7208 v9 = (char *)&pOutdoor->pBModels[v16].pVertices; | |
7209 v18 = 0; | |
7210 if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 ) | |
7211 { | |
7212 do | |
7213 { | |
7214 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4)); | |
7215 if ( v10->sCogNumber == v14 ) | |
7216 { | |
7217 if ( BYTE1(v10->uAttributes) & 0x40 ) | |
7218 { | |
7219 *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName( | |
7220 Str2); | |
7221 v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272); | |
7222 if ( *(_WORD *)v11 ) | |
7223 { | |
7224 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11); | |
7225 } | |
7226 else | |
7227 { | |
7228 *(_WORD *)v11 = v12; | |
7229 *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu; | |
7230 } | |
7231 } | |
7232 else | |
7233 { | |
7234 v10->uTextureID = v12; | |
7235 } | |
7236 } | |
7237 ++v18; | |
7238 v8 += 308; | |
7239 } | |
7240 while ( v18 < *((_DWORD *)v9 + 2) ); | |
7241 } | |
7242 ++v15; | |
7243 ++v16; | |
7244 } | |
7245 while ( v15 < (signed int)pOutdoor->uNumBModels ); | |
7246 } | |
7247 } | |
7248 pParty->uFlags |= 2u; | |
7249 } | |
7250 } | |
7251 } | |
7252 | |
7253 //----- (0044882F) -------------------------------------------------------- | |
7254 void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName) | |
7255 { | |
7256 signed int v3; // ebp@1 | |
7257 char *v4; // esi@2 | |
7258 unsigned __int16 v5; // ax@6 | |
7259 unsigned int v6; // [sp+4h] [bp-8h]@1 | |
7260 int v7; // [sp+8h] [bp-4h]@1 | |
7261 | |
7262 v3 = 0; | |
7263 v7 = a2; | |
7264 v6 = uCog; | |
7265 if ( (signed int)uNumLevelDecorations > 0 ) | |
7266 { | |
7267 v4 = (char *)&pLevelDecorations[0].field_2; | |
7268 do | |
7269 { | |
7270 if ( *((_WORD *)v4 + 9) == v6 ) | |
7271 { | |
1104 | 7272 if ( pFileName && _stricmp(pFileName, "0") ) |
0 | 7273 { |
7274 v5 = pDecorationList->GetDecorIdByName(pFileName); | |
7275 *((_WORD *)v4 - 1) = v5; | |
7276 pDecorationList->InitializeDecorationSprite((signed __int16)v5); | |
7277 } | |
7278 if ( v7 ) | |
7279 *v4 &= 0xDFu; | |
7280 else | |
7281 *v4 |= 0x20u; | |
7282 pParty->uFlags |= 2u; | |
7283 } | |
7284 ++v3; | |
7285 v4 += 32; | |
7286 } | |
7287 while ( v3 < (signed int)uNumLevelDecorations ); | |
7288 } | |
7289 } | |
7290 | |
7291 //----- (0044892E) -------------------------------------------------------- | |
7292 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) | |
7293 { | |
7294 signed int v3; // esi@2 | |
7295 signed int v4; // ecx@4 | |
7296 char *v5; // eax@6 | |
7297 int v6; // edi@13 | |
7298 char *v7; // esi@13 | |
7299 signed int v8; // ecx@13 | |
7300 ODMFace *v9; // eax@14 | |
7301 int v10; // [sp+0h] [bp-Ch]@1 | |
7302 signed int v11; // [sp+4h] [bp-8h]@11 | |
7303 int v12; // [sp+8h] [bp-4h]@12 | |
7304 | |
7305 v10 = sCogNumber; | |
7306 if ( sCogNumber ) | |
7307 { | |
7308 v3 = 1; | |
7309 if ( uCurrentlyLoadedLevelType == 1 ) | |
7310 { | |
7311 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) | |
7312 { | |
7313 v4 = 1; | |
7314 do | |
7315 { | |
7316 if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 ) | |
7317 { | |
7318 v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes; | |
7319 if ( on ) | |
7320 *(_DWORD *)v5 |= bit; | |
7321 else | |
7322 *(_DWORD *)v5 &= ~bit; | |
7323 } | |
7324 ++v3; | |
7325 ++v4; | |
7326 } | |
7327 while ( v3 < (signed int)pIndoor->uNumFaceExtras ); | |
7328 } | |
7329 pParty->uFlags |= 2u; | |
7330 } | |
7331 else | |
7332 { | |
7333 v11 = 0; | |
7334 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
7335 { | |
7336 v12 = 0; | |
7337 do | |
7338 { | |
7339 v6 = 0; | |
7340 v7 = (char *)&pOutdoor->pBModels[v12].pVertices; | |
7341 v8 = 0; | |
7342 if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 ) | |
7343 { | |
7344 do | |
7345 { | |
7346 v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4)); | |
7347 if ( v9->sCogNumber == v10 ) | |
7348 { | |
7349 if ( on ) | |
7350 v9->uAttributes |= bit; | |
7351 else | |
7352 v9->uAttributes &= ~bit; | |
7353 } | |
7354 ++v8; | |
7355 v6 += 308; | |
7356 } | |
7357 while ( v8 < *((_DWORD *)v7 + 2) ); | |
7358 } | |
7359 ++v11; | |
7360 ++v12; | |
7361 } | |
7362 while ( v11 < (signed int)pOutdoor->uNumBModels ); | |
7363 } | |
7364 } | |
7365 pParty->uFlags |= 2u; | |
7366 } | |
7367 } | |
7368 | |
7369 //----- (00448A98) -------------------------------------------------------- | |
7370 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) | |
7371 { | |
7372 unsigned int v3; // ebx@1 | |
7373 unsigned int v4; // ebp@1 | |
7374 signed int v5; // edi@1 | |
82 | 7375 Actor *v6; // esi@4 |
0 | 7376 size_t v7; // ecx@10 |
82 | 7377 Actor *v8; // eax@11 |
0 | 7378 unsigned __int16 v9; // dx@14 |
7379 | |
7380 v4 = uGroupID; | |
7381 v5 = Standing; | |
7382 v3 = uFlag; | |
7383 if ( uGroupID ) | |
7384 { | |
7385 if ( bToggle ) | |
7386 { | |
7387 if ( (signed int)uNumActors > Standing ) | |
7388 { | |
1202 | 7389 v6 = pActors.data();//[0].uAttributes; |
0 | 7390 do |
7391 { | |
82 | 7392 if ( v6->uGroup == v4 ) |
7393 { | |
7394 v6->uAttributes |= v3; | |
0 | 7395 if ( v3 == 0x10000 ) |
7396 { | |
82 | 7397 v6->uAIState = Disabled; |
7398 v6->UpdateAnimation(); | |
0 | 7399 } |
7400 } | |
7401 ++v5; | |
82 | 7402 ++v6; |
0 | 7403 } |
7404 while ( v5 < (signed int)uNumActors ); | |
7405 } | |
7406 } | |
7407 else | |
7408 { | |
7409 v7 = uNumActors; | |
7410 if ( (signed int)uNumActors > Standing ) | |
7411 { | |
1202 | 7412 v8 = pActors.data();//[0].uAIState; |
0 | 7413 do |
7414 { | |
82 | 7415 if ( v8->uGroup == v4 ) |
0 | 7416 { |
7417 if ( v3 == 0x10000 ) | |
7418 { | |
82 | 7419 v9 = v8->uAIState; |
7420 if ( v8->uAIState != Dead ) | |
0 | 7421 { |
7422 if ( v9 != 4 && v9 != 11 ) | |
82 | 7423 v8->uAIState = Standing; |
7424 } | |
7425 } | |
7426 LODWORD(v8->uAttributes) &= ~v3; | |
7427 } | |
7428 ++v8; | |
0 | 7429 --v7; |
7430 } | |
7431 while ( v7 ); | |
7432 } | |
7433 } | |
7434 } | |
7435 } | |
7436 | |
7437 //----- (00448B45) -------------------------------------------------------- | |
7438 void __thiscall GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) | |
7439 { | |
783 | 7440 if ( bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft ) |
7441 GameUI_Footer_TimeLeft = 0; | |
0 | 7442 } |
7443 | |
7444 //----- (00448B67) -------------------------------------------------------- | |
790 | 7445 void OnTimer(int __unused) |
7446 { | |
789 | 7447 if (pEventTimer->bPaused) |
7448 return; | |
7449 | |
790 | 7450 if (__unused) |
7451 _5773C0_unused = 0; | |
789 | 7452 |
790 | 7453 auto v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; |
789 | 7454 if (!v13) |
7455 return; | |
7456 | |
7457 //uint _v2v3 = pParty->uTimePlayed; | |
7458 //v3 = HIDWORD(pParty->uTimePlayed); | |
7459 //v2 = LODWORD(pParty->uTimePlayed); | |
7460 | |
7461 _5773B8_event_timer = pParty->uTimePlayed; | |
7462 | |
7463 for (uint i = 0; i < dword_5B65C8_timers_count; ++i) | |
7464 { | |
7465 //v4 = (char *)&array_5B5928_timers[0].field_C; | |
7466 auto timer = array_5B5928_timers + i; | |
7467 //while ( 1 ) | |
7468 //{ | |
7469 //v5 = *(short *)v4; | |
7470 if (timer->time_left_to_fire) | |
7471 { | |
7472 if (v13 < timer->time_left_to_fire) | |
7473 timer->time_left_to_fire -= v13; | |
7474 else | |
7475 { | |
7476 timer->time_left_to_fire = timer->fire_interval; | |
1052 | 7477 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); |
789 | 7478 } |
7479 } | |
7480 else | |
7481 { | |
7482 if (timer->next_fire_time < pParty->uTimePlayed) | |
7483 { | |
7484 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day | |
7485 if (timer->field_10) | |
7486 next_trigger_time = 336 * 60 * 60 * 24; // 1 year | |
7487 else if (timer->field_12) | |
7488 next_trigger_time = 28 * 60 * 60 * 24; // 1 month | |
7489 else if (timer->field_14) | |
7490 next_trigger_time = 7 * 60 * 60 * 24; // 1 week | |
7491 | |
7492 timer->next_fire_time += (next_trigger_time * 128) / 3.0f; | |
1052 | 7493 if (timer->next_fire_time < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed |
789 | 7494 timer->next_fire_time = pParty->uTimePlayed; |
7495 | |
1052 | 7496 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); |
0 | 7497 } |
7498 } | |
7499 } | |
7500 } | |
7501 | |
7502 //----- (00481D77) -------------------------------------------------------- | |
7503 void _outdoor_project(RenderVertexSoft *v) | |
7504 { | |
7505 double v1; // st7@1 | |
7506 double v2; // st7@1 | |
7507 | |
7508 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001); | |
168 | 7509 v->_rhw = v1; |
0 | 7510 v2 = v1 * (double)pOutdoorCamera->int_fov_rad; |
7511 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y; | |
7512 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z; | |
7513 } | |
7514 | |
7515 //----- (00448CF4) -------------------------------------------------------- | |
7516 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) | |
7517 { | |
7518 __int16 v8; // di@1 | |
7519 __int16 v9; // si@1 | |
7520 unsigned int v10; // eax@1 | |
7521 size_t v11; // ebx@2 | |
7522 signed int v12; // esi@2 | |
35 | 7523 Actor *pActor;//Actor_uYawAngle_cr *v13; // ebx@3 |
0 | 7524 AIDirection a3; // [sp+Ch] [bp-50h]@2 |
7525 AIDirection v15; // [sp+28h] [bp-34h]@2 | |
7526 //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 | |
7527 | |
7528 v8 = typeindex; | |
7529 v9 = level; | |
7530 | |
7531 SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 | |
7532 //SpawnPointMM7::SpawnPointMM7(&v16); | |
7533 | |
7534 v16.vPosition.x = x; | |
7535 v16.vPosition.y = y; | |
7536 v16.vPosition.z = z; | |
7537 v16.uGroup = group; | |
7538 v16.uRadius = 32; | |
7539 v16.uKind = 3; | |
7540 v16.uIndex = v8 + 2 * v9 + v9; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7541 v10 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 7542 if ( v10 ) |
7543 { | |
7544 v11 = uNumActors; | |
7545 SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0); | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
7546 memcpy(&v15, Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &a3, 1), sizeof(v15)); |
0 | 7547 v12 = v11; |
7548 if ( (signed int)v11 < (signed int)uNumActors ) | |
7549 { | |
35 | 7550 for ( pActor = &pActors[v11]; v12 < (signed int)uNumActors; ++pActor ) |
7551 { | |
7552 pActor->PrepareSprites(0); | |
0 | 7553 ++v12; |
35 | 7554 pActor->uYawAngle = v15.uYawAngle; |
7555 pActor->dword_000334_unique_name = uUniqueName; | |
7556 } | |
0 | 7557 } |
7558 } | |
7559 } | |
7560 | |
7561 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; | |
7562 | |
7563 //----- (0044987B) -------------------------------------------------------- | |
783 | 7564 void sub_44987B(const char *pMapName, MapStartPoint start_point) |
0 | 7565 { |
7566 const char *v2; // edi@1 | |
7567 | |
7568 v2 = pMapName; | |
7569 pAudioPlayer->StopChannels(-1, -1); | |
434 | 7570 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7571 if ( _stricmp(pCurrentMapName.data(), v2) ) |
0 | 7572 SaveGame(1, 0); |
783 | 7573 |
978 | 7574 uGameState = GAME_STATE_2; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7575 strcpy(pCurrentMapName.data(), v2); |
783 | 7576 uLevel_StartingPointType = start_point; |
0 | 7577 } |
7578 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
7579 | |
7580 //----- (004498D5) -------------------------------------------------------- | |
783 | 7581 void TeleportToStartingPoint(MapStartPoint point) |
7582 { | |
7583 //unsigned int v1; // ecx@2 | |
7584 //int v2; // ecx@3 | |
7585 //int v3; // ecx@4 | |
0 | 7586 unsigned __int16 v4; // ax@11 |
7587 signed int v5; // ecx@12 | |
7588 LevelDecoration *v6; // edx@13 | |
7589 signed int v7; // ecx@17 | |
7590 int v8; // eax@17 | |
7591 int v9; // ecx@17 | |
7592 const char *v10; // [sp-4h] [bp-84h]@6 | |
7593 char pName[128]; // [sp+8h] [bp-78h]@11 | |
7594 | |
783 | 7595 switch (point) |
7596 { | |
7597 case MapStartPoint_Party: v10 = "Party Start"; break; | |
7598 case MapStartPoint_North: v10 = "North Start"; break; | |
7599 case MapStartPoint_South: v10 = "South Start"; break; | |
7600 case MapStartPoint_East: v10 = "East Start"; break; | |
7601 case MapStartPoint_West: v10 = "West Start"; break; | |
7602 } | |
7603 | |
0 | 7604 strcpy(pName, v10); |
7605 v4 = pDecorationList->GetDecorIdByName(pName); | |
7606 if ( v4 ) | |
7607 { | |
7608 v5 = 0; | |
7609 if ( (signed int)uNumLevelDecorations > 0 ) | |
7610 { | |
1202 | 7611 v6 = pLevelDecorations.data(); |
0 | 7612 while ( v6->uDecorationDescID != (signed __int16)v4 ) |
7613 { | |
7614 ++v5; | |
7615 ++v6; | |
7616 if ( v5 >= (signed int)uNumLevelDecorations ) | |
7617 goto LABEL_20; | |
7618 } | |
7619 v7 = v5; | |
7620 pParty->vPosition.x = pLevelDecorations[v7].vPosition.x; | |
7621 pParty->vPosition.y = pLevelDecorations[v7].vPosition.y; | |
7622 pParty->vPosition.z = pLevelDecorations[v7].vPosition.z; | |
7623 pParty->uFallStartY = pParty->vPosition.z; | |
7624 v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90; | |
7625 v9 = pLevelDecorations[v7].field_10_y_rot; | |
7626 pParty->sRotationY = v8; | |
7627 if ( v9 ) | |
7628 pParty->sRotationY = v9; | |
7629 pParty->sRotationX = 0; | |
7630 pParty->uFallSpeed = 0; | |
7631 } | |
7632 LABEL_20: | |
7633 if ( dword_5B65C0 ) | |
7634 { | |
7635 if ( _5B65A8_npcdata_uflags_or_other ) | |
7636 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other; | |
7637 if ( _5B65AC_npcdata_fame_or_other ) | |
7638 pParty->vPosition.y = _5B65AC_npcdata_fame_or_other; | |
7639 if ( _5B65B0_npcdata_rep_or_other ) | |
7640 { | |
7641 pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; | |
7642 pParty->uFallStartY = _5B65B0_npcdata_rep_or_other; | |
7643 } | |
7644 if ( _5B65B4_npcdata_loword_house_or_other ) | |
7645 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; | |
7646 if ( _5B65B8_npcdata_hiword_house_or_other ) | |
7647 pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other; | |
7648 if ( dword_5B65BC ) | |
7649 pParty->uFallSpeed = dword_5B65BC; | |
7650 } | |
7651 _5B65B4_npcdata_loword_house_or_other = -1; | |
7652 dword_5B65C0 = 0; | |
7653 dword_5B65BC = 0; | |
7654 _5B65B8_npcdata_hiword_house_or_other = 0; | |
7655 _5B65B0_npcdata_rep_or_other = 0; | |
7656 _5B65AC_npcdata_fame_or_other = 0; | |
7657 _5B65A8_npcdata_uflags_or_other = 0; | |
7658 } | |
7659 } | |
1035 | 7660 |
7661 | |
0 | 7662 |
7663 //----- (00449A49) -------------------------------------------------------- | |
7664 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2) | |
7665 { | |
7666 int v2; // eax@1 | |
7667 int v3; // ebx@1 | |
7668 signed int v4; // esi@2 | |
7669 int v5; // edx@2 | |
7670 BLVDoor *v6; // ecx@8 | |
7671 unsigned int v7; // edx@18 | |
7672 signed int v8; // esi@19 | |
7673 int v9; // eax@19 | |
7674 char Args; // [sp+Ch] [bp-78h]@6 | |
7675 | |
7676 LOWORD(v2) = LOWORD(pIndoor->pDoors); | |
7677 v3 = a2; | |
7678 if ( !pIndoor->pDoors ) | |
7679 return v2; | |
7680 v4 = 0; | |
7681 v5 = (int)&pIndoor->pDoors->uDoorID; | |
7682 do | |
7683 { | |
7684 if ( *(int *)v5 == uDoorID ) | |
7685 break; | |
7686 ++v4; | |
7687 v5 += 80; | |
7688 } | |
7689 while ( v4 < 200 ); | |
7690 if ( v4 >= 200 ) | |
7691 { | |
7692 sprintf(&Args, "Unable to find Door ID: %i!", uDoorID); | |
7693 Abortf(&Args); | |
7694 } | |
7695 v6 = &pIndoor->pDoors[v4]; | |
7696 if ( v3 == 2 ) | |
7697 { | |
7698 LOWORD(v2) = v6->uState; | |
7699 if ( (short)v2 == 3 || (short)v2 == 1 ) | |
7700 return v2; | |
7701 if ( (short)v2 ) | |
7702 goto LABEL_14; | |
7703 } | |
7704 else | |
7705 { | |
7706 if ( !v3 ) | |
7707 { | |
7708 LABEL_14: | |
7709 LOWORD(v2) = v6->uState; | |
7710 if ( (short)v2 && (short)v2 != 3 ) | |
7711 { | |
7712 v6->uState = BLVDoor::Closing; | |
7713 if ( (short)v2 == 2 ) | |
7714 { | |
7715 LABEL_17: | |
7716 v6->uTimeSinceTriggered = 0; | |
7717 return v2; | |
7718 } | |
7719 v7 = v6->uTimeSinceTriggered; | |
7720 v2 = 15360; | |
7721 if ( v7 != 15360 ) | |
7722 { | |
7723 v8 = v6->uOpenSpeed; | |
7724 v9 = v6->uCloseSpeed; | |
7725 LABEL_26: | |
7726 v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8; | |
7727 goto LABEL_27; | |
7728 } | |
7729 goto LABEL_27; | |
7730 } | |
7731 return v2; | |
7732 } | |
7733 if ( v3 != 1 ) | |
7734 return v2; | |
7735 } | |
7736 LOWORD(v2) = v6->uState; | |
7737 if ( (short)v2 != 2 && (short)v2 != 1 ) | |
7738 { | |
7739 v6->uState = BLVDoor::Opening; | |
7740 if ( !(short)v2 ) | |
7741 goto LABEL_17; | |
7742 v7 = v6->uTimeSinceTriggered; | |
7743 v2 = 15360; | |
7744 if ( v7 != 15360 ) | |
7745 { | |
7746 v8 = v6->uCloseSpeed; | |
7747 v9 = v6->uOpenSpeed; | |
7748 goto LABEL_26; | |
7749 } | |
7750 LABEL_27: | |
7751 v6->uTimeSinceTriggered = v2; | |
7752 } | |
7753 return v2; | |
7754 } | |
7755 | |
7756 //----- (00449B57) -------------------------------------------------------- | |
521 | 7757 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 ) |
1035 | 7758 { |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1112
diff
changeset
|
7759 return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0; |
0 | 7760 } |
7761 | |
7762 //----- (00449B7E) -------------------------------------------------------- | |
501 | 7763 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) |
0 | 7764 { |
7765 signed int v3; // esi@1 | |
501 | 7766 unsigned char set_bit; // edx@1 |
0 | 7767 |
7768 v3 = a2 - 1; | |
501 | 7769 set_bit = 0x80 >> v3 % 8; |
0 | 7770 if ( bToggle ) |
501 | 7771 pArray[v3 / 8] |= set_bit; |
7772 else | |
7773 pArray[v3 / 8] &= ~set_bit; | |
0 | 7774 } |
7775 | |
7776 //----- (0044C175) -------------------------------------------------------- | |
1160 | 7777 void ShowStatusBarString( const char *pString, unsigned int uNumSeconds ) |
7778 { | |
0 | 7779 unsigned int v2; // esi@1 |
7780 int i; // eax@1 | |
7781 | |
7782 v2 = uNumSeconds; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7783 strcpy(GameUI_Footer_TimedString.data(), pString); |
783 | 7784 GameUI_Footer_TimeLeft = 1000 * v2 + GetTickCount(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7785 for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); |
0 | 7786 i > 450; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7787 i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7788 byte_5C3427[strlen(GameUI_Footer_TimedString.data())] = 0; |
0 | 7789 } |
7790 | |
7791 //----- (0044C1D0) -------------------------------------------------------- | |
1035 | 7792 void ShowNothingHereStatus() |
0 | 7793 { |
783 | 7794 if ( !GameUI_Footer_TimeLeft ) |
0 | 7795 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here |
7796 } | |
7797 | |
7798 //----- (0044C28B) -------------------------------------------------------- | |
7799 signed int __cdecl const_2() | |
7800 { | |
7801 return 2; | |
7802 } | |
7803 | |
7804 //----- (0044C28F) -------------------------------------------------------- | |
7805 bool __cdecl sub_44C28F_open_nwc_dungeon() | |
7806 { | |
7807 bool result; // eax@1 | |
7808 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
7809 result = _stricmp("nwc.blv", pCurrentMapName.data()); |
0 | 7810 if ( result ) |
7811 { | |
7812 _5B65A8_npcdata_uflags_or_other = 0; | |
7813 _5B65AC_npcdata_fame_or_other = 0; | |
7814 _5B65B0_npcdata_rep_or_other = 0; | |
7815 _5B65B4_npcdata_loword_house_or_other = 0; | |
7816 _5B65B8_npcdata_hiword_house_or_other = 0; | |
7817 dword_5B65BC = 0; | |
7818 dword_5B65C0 = 0; | |
7819 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
783 | 7820 sub_44987B("nwc.blv", MapStartPoint_Party); |
151 | 7821 pCurrentScreen = SCREEN_GAME; |
0 | 7822 result = 1; |
7823 } | |
7824 return result; | |
7825 } | |
7826 | |
7827 //----- (0044C2F4) -------------------------------------------------------- | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1112
diff
changeset
|
7828 bool LevelDecoration::IsInteractive() |
0 | 7829 { |
1035 | 7830 switch (uDecorationDescID) |
7831 { | |
7832 case 4: // trash pile | |
7833 case 5: // campfire | |
7834 case 6: // cauldron | |
7835 case 11: // fruit plate | |
7836 case 13: // trash pile | |
7837 case 14: // dirt | |
7838 case 24: // keg | |
7839 case 184: // fire | |
7840 case 187: // fire | |
7841 case 190: // fire | |
7842 return true; | |
7843 } | |
7844 | |
7845 if (uDecorationDescID >= 206 && uDecorationDescID <= 209) // lighthouse fire | |
7846 return true; | |
7847 if (uDecorationDescID >= 210 && uDecorationDescID <= 221) // magic pedistal | |
7848 return true; | |
7849 | |
7850 return false; | |
0 | 7851 } |
7852 | |
7853 //----- (0044C362) -------------------------------------------------------- | |
7854 void Vec3_int_::Normalize_float() | |
7855 { | |
1025 | 7856 //Vec3_int_ *v1; // esi@1 |
0 | 7857 double v2; // st6@1 |
7858 float v3; // ST20_4@1 | |
7859 double v4; // st5@1 | |
7860 float v5; // ST18_4@1 | |
7861 double v6; // st4@1 | |
7862 float v7; // ST14_4@1 | |
7863 float v8; // ST24_4@1 | |
7864 float v9; // ST20_4@1 | |
7865 double v10; // ST0C_8@1 | |
7866 float v11; // ST18_4@1 | |
7867 double v12; // ST0C_8@1 | |
7868 float v13; // ST14_4@1 | |
7869 double v14; // ST0C_8@1 | |
7870 | |
1035 | 7871 assert(false); |
1025 | 7872 //v1 = this; |
0 | 7873 v2 = (double)this->x * 0.000015258789; |
7874 v3 = v2; | |
7875 v4 = (double)this->y * 0.000015258789; | |
7876 v5 = v4; | |
7877 v6 = (double)this->z * 0.000015258789; | |
7878 v7 = v6; | |
7879 v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2); | |
7880 v9 = v8 * v3 * 65536.0; | |
7881 v10 = v9 + 6.7553994e15; | |
1025 | 7882 this->x = LODWORD(v10); |
0 | 7883 v11 = v8 * v5 * 65536.0; |
7884 v12 = v11 + 6.7553994e15; | |
1025 | 7885 this->y = LODWORD(v12); |
0 | 7886 v13 = v8 * v7 * 65536.0; |
7887 v14 = v13 + 6.7553994e15; | |
1025 | 7888 this->z = LODWORD(v14); |
0 | 7889 } |
7890 | |
7891 //----- (00401000) -------------------------------------------------------- | |
7892 void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int)) | |
7893 { | |
7894 void *v4; // esi@2 | |
7895 int v5; // edi@2 | |
7896 | |
7897 if ( numObjs - 1 >= 0 ) | |
7898 { | |
7899 v4 = a1; | |
7900 v5 = numObjs; | |
7901 do | |
7902 { | |
7903 constructor((int)v4); | |
7904 v4 = (char *)v4 + objSize; | |
7905 --v5; | |
7906 } | |
7907 while ( v5 ); | |
7908 } | |
7909 } | |
7910 | |
7911 // 4F75D8: using guessed type int ai_arrays_size; | |
7912 | |
1295 | 7913 // 4F75D8: using guessed type int ai_arrays_size; |
0 | 7914 |
7915 //----- (0040261D) -------------------------------------------------------- | |
7916 int stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8) | |
7917 { | |
7918 int result; // eax@1 | |
7919 | |
7920 result = this->count; | |
7921 if ( this->count < 100 ) | |
7922 { | |
7923 this->pIDs[result] = uID; | |
7924 this->pXs[this->count] = x; | |
7925 this->pYs[this->count] = y; | |
7926 this->pZs[this->count] = z; | |
7927 this->field_324[this->count] = a3; | |
7928 this->field_3EC[this->count] = a8; | |
7929 result = this->count; | |
7930 this->field_450[this->count++] = a7; | |
7931 } | |
7932 return result; | |
7933 } | |
7934 | |
7935 //----- (00402CAE) -------------------------------------------------------- | |
323 | 7936 int stru193_math::Cos(int angle) |
0 | 7937 { |
7938 int v2; // eax@1 | |
7939 | |
7940 //a2: (angle - uIntegerHalfPi) for sin(angle) | |
7941 // (angle) for cos(angle) | |
7942 | |
7943 v2 = uDoublePiMask & angle; | |
7944 | |
7945 if ( v2 > uIntegerPi ) | |
7946 v2 = uIntegerDoublePi - v2; | |
7947 if ( v2 >= uIntegerHalfPi ) | |
7948 return -pCosTable[uIntegerPi - v2]; | |
7949 else | |
7950 return pCosTable[v2]; | |
7951 } | |
7952 |