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