comparison mm7_3.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children ac0fb48cd27a
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "MapInfo.h"
2 #include "Game.h"
3 #include "GUIWindow.h"
4 #include "GUIFont.h"
5 #include "GUIButton.h"
6 #include "GUIProgressBar.h"
7 #include "Party.h"
8 #include "AudioPlayer.h"
9 #include "Outdoor.h"
10 #include "IndoorCamera.h"
11 #include "Overlays.h"
12 #include "Monsters.h"
13 #include "Arcomage.h"
14 #include "LOD.h"
15 #include "Actor.h"
16 #include "Allocator.h"
17 #include "Events.h"
18 #include "Viewport.h"
19 #include "FrameTableInc.h"
20 #include "Math.h"
21 #include "LayingItem.h"
22 #include "ObjectList.h"
23 #include "Chest.h"
24 #include "PaletteManager.h"
25 #include "DecorationList.h"
26 #include "SaveLoad.h"
27 #include "stru123.h"
28 #include "stru287.h"
29 #include "Time.h"
30 #include "IconFrameTable.h"
31 #include "TurnEngine.h"
32 #include "Awards.h"
33 #include "Autonotes.h"
34 #include "stru160.h"
35 #include "stru279.h"
36 #include "Weather.h"
37 #include "stru220.h"
38 #include "Events2D.h"
39 #include "stru176.h"
40 #include "stru159.h"
41 #include "stru298.h"
42
43 #include "mm7_data.h"
44
45
46
47
48
49
50
51
52 //----- (0046E44E) --------------------------------------------------------
53 int __thiscall _46E44E_collide_against_faces_and_portals(unsigned int b1)
54 {
55 BLVSector *v1; // edi@1
56 signed int v2; // ebx@1
57 BLVFace *v3; // esi@2
58 __int16 v4; // si@10
59 int v5; // ecx@12
60 unsigned __int8 v6; // sf@12
61 unsigned __int8 v7; // of@12
62 int result; // eax@14
63 BLVSector *v9; // ebx@15
64 int v10; // ecx@15
65 int v11; // eax@16
66 BLVFace *v12; // ebp@16
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
87 int v33[10]; // [sp+30h] [bp-28h]@1
88
89 v1 = &pIndoor->pSectors[stru_721530.uSectorID];
90 v2 = 0;
91 a10 = b1;
92 v33[0] = stru_721530.uSectorID;
93 for ( i = 1; v2 < v1->uNumPortals; ++v2 )
94 {
95 v3 = &pIndoor->pFaces[v1->pPortals[v2]];
96 if ( stru_721530.sMaxX <= v3->pBounding.x2
97 && stru_721530.sMinX >= v3->pBounding.x1
98 && stru_721530.sMaxY <= v3->pBounding.y2
99 && stru_721530.sMinY >= v3->pBounding.y1
100 && stru_721530.sMaxZ <= v3->pBounding.z2
101 && stru_721530.sMinZ >= v3->pBounding.z1
102 && abs((v3->pFacePlane_old.dist
103 + stru_721530.normal.x * v3->pFacePlane_old.vNormal.x
104 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
105 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 )
106 {
107 v4 = v3->uSectorID == stru_721530.uSectorID ? v3->uBackSectorID : v3->uSectorID;
108 v5 = i++;
109 v7 = __OFSUB__(i, 10);
110 v6 = i - 10 < 0;
111 v33[v5] = v4;
112 if ( !(v6 ^ v7) )
113 break;
114 }
115 }
116 result = 0;
117 v29 = 0;
118 if ( i > 0 )
119 {
120 while ( 1 )
121 {
122 v9 = &pIndoor->pSectors[v33[result]];
123 v10 = 0;
124 v32 = v9->field_4 + v9->field_C + v9->field_14;
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 {
135 v11 = v9->pFloors[v10];
136 v12 = &pIndoor->pFaces[v11];
137 if ( v12->uAttributes & 1
138 || stru_721530.sMaxX > v12->pBounding.x2
139 || stru_721530.sMinX < v12->pBounding.x1
140 || stru_721530.sMaxY > v12->pBounding.y2
141 || stru_721530.sMinY < v12->pBounding.y1
142 || stru_721530.sMaxZ > v12->pBounding.z2
143 || stru_721530.sMinZ < v12->pBounding.z1
144 || v11 == stru_721530.field_84 )
145 goto LABEL_45;
146 v13 = v12->pFacePlane_old.vNormal.y;
147 v14 = v12->pFacePlane_old.dist;
148 v31 = v13;
149 v15 = (stru_721530.normal.x * v12->pFacePlane_old.vNormal.x
150 + v14
151 + stru_721530.normal.y * v13
152 + stru_721530.normal.z * v12->pFacePlane_old.vNormal.z) >> 16;
153 if ( v15 > 0 )
154 {
155 v16 = (stru_721530.normal2.y * v31
156 + v12->pFacePlane_old.dist
157 + stru_721530.normal2.z * v12->pFacePlane_old.vNormal.z
158 + stru_721530.normal2.x * v12->pFacePlane_old.vNormal.x) >> 16;
159 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
160 {
161 if ( v16 <= v15 )
162 {
163 a3 = stru_721530.field_6C;
164 if ( sub_47531C(
165 stru_721530.prolly_normal_d,
166 &a3,
167 stru_721530.normal.x,
168 stru_721530.normal.y,
169 stru_721530.normal.z,
170 stru_721530.field_58.x,
171 stru_721530.field_58.y,
172 stru_721530.field_58.z,
173 v12,
174 a10) )
175 {
176 v17 = a3;
177 }
178 else
179 {
180 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d;
181 if ( !sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v12) )
182 goto LABEL_34;
183 v17 = a3 - stru_721530.prolly_normal_d;
184 a3 -= stru_721530.prolly_normal_d;
185 }
186 if ( v17 < stru_721530.field_7C )
187 {
188 stru_721530.field_7C = v17;
189 v18 = 8 * v9->pFloors[v26];
190 LOBYTE(v18) = v18 | 6;
191 stru_721530.uFaceID = v18;
192 }
193 }
194 }
195 }
196 LABEL_34:
197 if ( !(stru_721530.field_0 & 1)
198 || (v19 = v12->pFacePlane_old.vNormal.x,
199 v20 = v12->pFacePlane_old.vNormal.y,
200 v30 = v19,
201 v21 = (stru_721530.field_34.x * v19
202 + v12->pFacePlane_old.dist
203 + stru_721530.field_34.y * v20
204 + stru_721530.field_34.z * v12->pFacePlane_old.vNormal.z) >> 16,
205 v21 <= 0)
206 || (v22 = (stru_721530.field_4C * v30
207 + v12->pFacePlane_old.dist
208 + stru_721530.field_50 * v20
209 + stru_721530.field_54 * v12->pFacePlane_old.vNormal.z) >> 16,
210 v21 > stru_721530.prolly_normal_d)
211 && v22 > stru_721530.prolly_normal_d
212 || v22 > v21 )
213 goto LABEL_45;
214 a3 = stru_721530.field_6C;
215 if ( sub_47531C(
216 stru_721530.field_8,
217 &a3,
218 stru_721530.field_34.x,
219 stru_721530.field_34.y,
220 stru_721530.field_34.z,
221 stru_721530.field_58.x,
222 stru_721530.field_58.y,
223 stru_721530.field_58.z,
224 v12,
225 a10) )
226 {
227 v23 = a3;
228 goto LABEL_43;
229 }
230 a3 = stru_721530.field_6C + stru_721530.field_8;
231 if ( sub_475D85(&stru_721530.field_34, &stru_721530.field_58, &a3, v12) )
232 {
233 v23 = a3 - stru_721530.prolly_normal_d;
234 a3 -= stru_721530.prolly_normal_d;
235 LABEL_43:
236 if ( v23 < stru_721530.field_7C )
237 {
238 stru_721530.field_7C = v23;
239 v24 = 8 * v9->pFloors[v26];
240 LOBYTE(v24) = v24 | 6;
241 stru_721530.uFaceID = v24;
242 }
243 }
244 LABEL_45:
245 v10 = v26++ + 1;
246 if ( v26 >= v32 )
247 goto LABEL_46;
248 }
249 }
250 return result;
251 }
252 // 46E44E: using guessed type int var_28[10];
253
254 //----- (0046E889) --------------------------------------------------------
255 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
256 {
257 int result; // eax@1
258 BSPModel *v2; // ecx@3
259 int v3; // ebx@9
260 ODMFace *v4; // eax@11
261 int v5; // edi@17
262 int v6; // esi@17
263 unsigned int v7; // ecx@17
264 int v8; // eax@19
265 int v9; // ecx@20
266 int v10; // eax@24
267 int v11; // ST18_4@25
268 int v12; // ST1C_4@25
269 int v13; // ST0C_4@25
270 unsigned int v14; // eax@28
271 int v15; // eax@30
272 int v16; // ecx@31
273 unsigned int v17; // eax@36
274 int v18; // ST18_4@41
275 int v19; // ST1C_4@41
276 int v20; // ST0C_4@41
277 int v21; // eax@42
278 unsigned int v22; // eax@43
279 //BLVFace f; // [sp+Ch] [bp-7Ch]@1
280 int v24; // [sp+6Ch] [bp-1Ch]@9
281 int a11; // [sp+70h] [bp-18h]@1
282 unsigned int v26; // [sp+74h] [bp-14h]@2
283 unsigned int v27; // [sp+78h] [bp-10h]@10
284 BSPModel *v28; // [sp+7Ch] [bp-Ch]@3
285 int a10; // [sp+80h] [bp-8h]@1
286 int a2; // [sp+84h] [bp-4h]@23
287
288 a11 = ecx0;
289
290 BLVFace f; // [sp+Ch] [bp-7Ch]@1
291 //BLVFace::BLVFace(&f);
292
293 result = 0;
294 a10 = 0;
295 if ( (signed int)pOutdoor->uNumBModels > 0 )
296 {
297 v26 = 0;
298 while ( 1 )
299 {
300 v2 = &pOutdoor->pBModels[v26 / 0xBC];
301 v28 = &pOutdoor->pBModels[v26 / 0xBC];
302 if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX )
303 {
304 if ( stru_721530.sMinX >= v2->sMinX )
305 {
306 if ( stru_721530.sMaxY <= v2->sMaxY )
307 {
308 if ( stru_721530.sMinY >= v2->sMinY )
309 {
310 if ( stru_721530.sMaxZ <= v2->sMaxZ )
311 {
312 if ( stru_721530.sMinZ >= v2->sMinZ )
313 {
314 v3 = 0;
315 v24 = v2->uNumFaces;
316 if ( v24 > 0 )
317 break;
318 }
319 }
320 }
321 }
322 }
323 }
324 LABEL_39:
325 ++a10;
326 v26 += 188;
327 result = a10;
328 if ( a10 >= (signed int)pOutdoor->uNumBModels )
329 return result;
330 }
331 v27 = 0;
332 while ( 1 )
333 {
334 v4 = &v2->pFaces[v27 / 0x134];
335 if ( stru_721530.sMaxX > v4->pBoundingBox.x2
336 || stru_721530.sMinX < v4->pBoundingBox.x1
337 || stru_721530.sMaxY > v4->pBoundingBox.y2
338 || stru_721530.sMinY < v4->pBoundingBox.y1
339 || stru_721530.sMaxZ > v4->pBoundingBox.z2
340 || stru_721530.sMinZ < v4->pBoundingBox.z1 )
341 goto LABEL_38;
342 f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x;
343 f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y;
344 v5 = v4->pFacePlane.vNormal.z;
345 f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
346 v6 = v4->pFacePlane.dist;
347 f.pFacePlane_old.dist = v4->pFacePlane.dist;
348 v7 = v4->uFaceAttributes;
349 f.uAttributes = v7;
350 f.pBounding.x1 = v4->pBoundingBox.x1;
351 f.pBounding.y1 = v4->pBoundingBox.y1;
352 f.pBounding.z1 = v4->pBoundingBox.z1;
353 f.pBounding.x2 = v4->pBoundingBox.x2;
354 f.pBounding.y2 = v4->pBoundingBox.y2;
355 f.pBounding.z2 = v4->pBoundingBox.z2;
356 f.zCalc1 = v4->zCalc1;
357 f.zCalc2 = v4->zCalc2;
358 f.zCalc3 = v4->zCalc3;
359 f.pXInterceptDisplacements = v4->pXInterceptDisplacements;
360 f.pYInterceptDisplacements = v4->pYInterceptDisplacements;
361 f.pZInterceptDisplacements = v4->pZInterceptDisplacements;
362 f.uPolygonType = (PolygonType)v4->uPolygonType;
363 f.uNumVertices = v4->uNumVertices;
364 f.uBitmapID = v4->uTextureID;
365 f.pVertexIDs = v4->pVertexIDs;
366 if ( !(v7 & 0x20000000) )
367 {
368 if ( !(v7 & 1) )
369 break;
370 }
371 LABEL_37:
372 v2 = v28;
373 LABEL_38:
374 v27 += 308;
375 ++v3;
376 if ( v3 >= v24 )
377 goto LABEL_39;
378 }
379 v8 = (v5 * stru_721530.normal.z
380 + v6
381 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
382 + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16;
383 if ( v8 > 0 )
384 {
385 v9 = (v5 * stru_721530.normal2.z
386 + v6
387 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
388 + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16;
389 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
390 {
391 if ( v9 <= v8 )
392 {
393 a2 = stru_721530.field_6C;
394 if ( sub_4754BF(
395 stru_721530.prolly_normal_d,
396 &a2,
397 stru_721530.normal.x,
398 stru_721530.normal.y,
399 stru_721530.normal.z,
400 stru_721530.field_58.x,
401 stru_721530.field_58.y,
402 stru_721530.field_58.z,
403 &f,
404 a10,
405 a11) )
406 {
407 v10 = a2;
408 }
409 else
410 {
411 v11 = stru_721530.field_58.y;
412 v12 = stru_721530.field_58.z;
413 v13 = stru_721530.normal.y;
414 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
415 if ( !sub_475F30(
416 &a2,
417 &f,
418 stru_721530.normal.x,
419 v13,
420 stru_721530.normal.z,
421 stru_721530.field_58.x,
422 v11,
423 v12,
424 a10) )
425 goto LABEL_29;
426 v10 = a2 - stru_721530.prolly_normal_d;
427 a2 -= stru_721530.prolly_normal_d;
428 }
429 if ( v10 < stru_721530.field_7C )
430 {
431 stru_721530.field_7C = v10;
432 v14 = 8 * (v3 | (a10 << 6));
433 LOBYTE(v14) = v14 | 6;
434 stru_721530.uFaceID = v14;
435 }
436 }
437 }
438 }
439 LABEL_29:
440 if ( stru_721530.field_0 & 1 )
441 {
442 v15 = (f.pFacePlane_old.vNormal.z * stru_721530.field_34.z
443 + f.pFacePlane_old.dist
444 + f.pFacePlane_old.vNormal.y * stru_721530.field_34.y
445 + f.pFacePlane_old.vNormal.x * stru_721530.field_34.x) >> 16;
446 if ( v15 > 0 )
447 {
448 v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
449 + f.pFacePlane_old.dist
450 + f.pFacePlane_old.vNormal.y * stru_721530.field_50
451 + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16;
452 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
453 {
454 if ( v16 <= v15 )
455 {
456 a2 = stru_721530.field_6C;
457 if ( sub_4754BF(
458 stru_721530.field_8,
459 &a2,
460 stru_721530.field_34.x,
461 stru_721530.field_34.y,
462 stru_721530.field_34.z,
463 stru_721530.field_58.x,
464 stru_721530.field_58.y,
465 stru_721530.field_58.z,
466 &f,
467 a10,
468 a11) )
469 {
470 if ( a2 < stru_721530.field_7C )
471 {
472 stru_721530.field_7C = a2;
473 v17 = 8 * (v3 | (a10 << 6));
474 LOBYTE(v17) = v17 | 6;
475 stru_721530.uFaceID = v17;
476 }
477 }
478 else
479 {
480 v18 = stru_721530.field_58.y;
481 v19 = stru_721530.field_58.z;
482 v20 = stru_721530.field_34.y;
483 a2 = stru_721530.field_6C + stru_721530.field_8;
484 if ( sub_475F30(
485 &a2,
486 &f,
487 stru_721530.field_34.x,
488 v20,
489 stru_721530.field_34.z,
490 stru_721530.field_58.x,
491 v18,
492 v19,
493 a10) )
494 {
495 v2 = v28;
496 v21 = a2 - stru_721530.prolly_normal_d;
497 a2 -= stru_721530.prolly_normal_d;
498 if ( a2 < stru_721530.field_7C )
499 {
500 stru_721530.field_7C = v21;
501 v22 = 8 * (v3 | (a10 << 6));
502 LOBYTE(v22) = v22 | 6;
503 stru_721530.uFaceID = v22;
504 }
505 goto LABEL_38;
506 }
507 }
508 }
509 }
510 }
511 }
512 goto LABEL_37;
513 }
514 return result;
515 }
516
517
518
519 //----- (0046ED1B) --------------------------------------------------------
520 int __fastcall _46ED1B_collide_against_floor(signed int a1, signed int a2, int a3, unsigned int *pSectorID, int *a5)
521 {
522 unsigned int *v5; // edi@1
523 int result; // eax@1
524 int v7; // eax@3
525 int v8; // [sp+Ch] [bp-8h]@1
526 int v9; // [sp+10h] [bp-4h]@1
527
528 v5 = pSectorID;
529 v9 = a2;
530 v8 = a1;
531 result = _46CEC3_get_floor_level(a1, a2, a3, *pSectorID, (int *)&pSectorID);
532 if ( result != -30000 && result <= a3 + 50
533 || (v7 = pIndoor->GetSector(v8, v9, a3), (*v5 = v7) != 0)
534 && (result = _46CEC3_get_floor_level(v8, v9, a3, v7, (int *)&pSectorID), result != -30000) )
535 *a5 = (int)pSectorID;
536 else
537 result = -30000;
538 return result;
539 }
540
541 //----- (0046ED8A) --------------------------------------------------------
542 void __fastcall _46ED8A_collide_against_layingItems(unsigned int _this)
543 {
544 int v1; // ebx@2
545 ObjectDesc *v2; // edx@4
546 int v3; // esi@5
547 int v4; // ecx@5
548 int v5; // eax@7
549 int v6; // edi@9
550 int v7; // edx@9
551 int v8; // edi@11
552 int v9; // ebx@11
553 int v10; // ecx@12
554 int v11; // esi@13
555 signed int v12; // [sp+0h] [bp-14h]@1
556 int v13; // [sp+4h] [bp-10h]@9
557 char *v14; // [sp+8h] [bp-Ch]@2
558 unsigned int v15; // [sp+10h] [bp-4h]@1
559
560 v15 = 0;
561 v12 = _this;
562 if ( (signed int)uNumLayingItems > 0 )
563 {
564 v1 = (int)&pLayingItems[0].uObjectDescID;
565 v14 = (char *)&pLayingItems[0].uObjectDescID;
566 do
567 {
568 if ( *(short *)v1 )
569 {
570 v2 = &pObjectList->pObjects[*(short *)v1];
571 if ( !(v2->uFlags & 2) )
572 {
573 v3 = v2->uRadius;
574 v4 = *(int *)(v1 + 2);
575 if ( stru_721530.sMaxX <= v4 + v3 )
576 {
577 if ( stru_721530.sMinX >= v4 - v3 )
578 {
579 v5 = *(int *)(v1 + 6);
580 if ( stru_721530.sMaxY <= v5 + v3 )
581 {
582 if ( stru_721530.sMinY >= v5 - v3 )
583 {
584 v6 = v2->uHeight;
585 v7 = *(int *)(v1 + 10);
586 v13 = v6;
587 if ( stru_721530.sMaxZ <= v7 + v6 )
588 {
589 if ( stru_721530.sMinZ >= v7 )
590 {
591 v8 = v4 - stru_721530.normal.x;
592 v9 = v5 - stru_721530.normal.y;
593 if ( abs(((v4 - stru_721530.normal.x) * stru_721530.field_58.y
594 - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16) <= v3
595 + stru_721530.prolly_normal_d )
596 {
597 v10 = (v8 * stru_721530.field_58.x + v9 * stru_721530.field_58.y) >> 16;
598 if ( v10 > 0 )
599 {
600 v11 = stru_721530.normal.z
601 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v10) >> 16);
602 if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d )
603 {
604 if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
605 {
606 if ( v10 < stru_721530.field_7C )
607 sub_46DEF2(v12, v15);
608 }
609 }
610 }
611 }
612 }
613 }
614 }
615 }
616 }
617 }
618 }
619 }
620 ++v15;
621 v1 = (int)(v14 + 112);
622 v14 += 112;
623 }
624 while ( (signed int)v15 < (signed int)uNumLayingItems );
625 }
626 }
627
628 //----- (0046EF01) --------------------------------------------------------
629 int __thiscall _46EF01_collision_chech_player(int a1)
630 {
631 int v1; // edx@1
632 int result; // eax@1
633 int v3; // ebx@7
634 int v4; // esi@7
635 int v5; // edi@8
636 int v6; // ecx@9
637 int v7; // edi@12
638 int v8; // [sp+Ch] [bp-10h]@1
639 unsigned int v9; // [sp+10h] [bp-Ch]@1
640 int v10; // [sp+14h] [bp-8h]@7
641 int v11; // [sp+18h] [bp-4h]@7
642
643 v8 = a1;
644 v1 = 2 * pParty->field_14;
645 result = pParty->vPosition.x;
646 v9 = pParty->uPartyHeight;
647 if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14 )
648 {
649 if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
650 {
651 if ( stru_721530.sMaxY <= pParty->vPosition.z + v1 )
652 {
653 if ( stru_721530.sMinY >= pParty->vPosition.z - v1 )
654 {
655 if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.y + pParty->uPartyHeight) )
656 {
657 if ( stru_721530.sMinZ >= pParty->vPosition.y )
658 {
659 v3 = stru_721530.prolly_normal_d + v1;
660 v11 = pParty->vPosition.x - stru_721530.normal.x;
661 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
662 - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
663 v10 = pParty->vPosition.z - stru_721530.normal.y;
664 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
665 - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
666 if ( result <= v3 )
667 {
668 result = v10 * stru_721530.field_58.y;
669 v5 = (v10 * stru_721530.field_58.y + v11 * stru_721530.field_58.x) >> 16;
670 if ( v5 > 0 )
671 {
672 v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
673 result = pParty->vPosition.y;
674 if ( v6 >= pParty->vPosition.y )
675 {
676 result = v9 + pParty->vPosition.y;
677 if ( v6 <= (signed int)(v9 + pParty->vPosition.y) || v8 )
678 {
679 result = sub_452A9E(v3 * v3 - v4 * v4);
680 v7 = v5 - result;
681 if ( v7 < 0 )
682 v7 = 0;
683 if ( v7 < stru_721530.field_7C )
684 {
685 stru_721530.field_7C = v7;
686 stru_721530.uFaceID = 4;
687 }
688 }
689 }
690 }
691 }
692 }
693 }
694 }
695 }
696 }
697 }
698 return result;
699 }
700
701 //----- (0046F04E) --------------------------------------------------------
702 signed int __cdecl _46F04E_collide_against_portals()
703 {
704 BLVSector *v0; // ecx@1
705 unsigned int v1; // eax@1
706 int v2; // eax@2
707 BLVFace *v3; // eax@3
708 int v4; // ecx@9
709 int v5; // edx@9
710 signed int result; // eax@21
711 BLVFace *v7; // eax@22
712 signed int v8; // [sp+0h] [bp-14h]@1
713 BLVSector *v9; // [sp+4h] [bp-10h]@1
714 unsigned int v10; // [sp+8h] [bp-Ch]@1
715 int a3; // [sp+Ch] [bp-8h]@13
716 int v12; // [sp+10h] [bp-4h]@15
717
718 v8 = 0;
719 v0 = &pIndoor->pSectors[stru_721530.uSectorID];
720 v1 = 0xFFFFFFu;
721 v10 = 0xFFFFFFu;
722 v9 = v0;
723 if ( v0->uNumPortals > 0 )
724 {
725 do
726 {
727 v2 = v0->pPortals[v8];
728 if ( v2 != stru_721530.field_80 )
729 {
730 v3 = &pIndoor->pFaces[v2];
731 if ( stru_721530.sMaxX <= v3->pBounding.x2 )
732 {
733 if ( stru_721530.sMinX >= v3->pBounding.x1
734 && stru_721530.sMaxY <= v3->pBounding.y2
735 && stru_721530.sMinY >= v3->pBounding.y1
736 && stru_721530.sMaxZ <= v3->pBounding.z2
737 && stru_721530.sMinZ >= v3->pBounding.z1 )
738 {
739 v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x
740 + v3->pFacePlane_old.dist
741 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
742 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
743 v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z
744 + v3->pFacePlane_old.dist
745 + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
746 + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
747 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
748 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
749 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v3))
750 && a3 < (signed int)v10 )
751 {
752 v0 = v9;
753 v10 = a3;
754 v12 = v9->pPortals[v8];
755 }
756 else
757 {
758 v0 = v9;
759 }
760 }
761 }
762 }
763 ++v8;
764 }
765 while ( v8 < v0->uNumPortals );
766 v1 = v10;
767 }
768 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C )
769 {
770 stru_721530.field_80 = v12;
771 v7 = &pIndoor->pFaces[v12];
772 if ( v7->uSectorID == stru_721530.uSectorID )
773 stru_721530.uSectorID = v7->uBackSectorID;
774 else
775 stru_721530.uSectorID = v7->uSectorID;
776 stru_721530.field_7C = 268435455;
777 result = 0;
778 }
779 else
780 {
781 result = 1;
782 }
783 return result;
784 }
785
786 //----- (0046F228) --------------------------------------------------------
787 void __cdecl BLV_UpdateDoors()
788 {
789 int v0; // ebx@1
790 int v1; // edi@1
791 BLVDoor *v2; // esi@3
792 unsigned __int16 v3; // ax@3
793 unsigned int v4; // ecx@5
794 int v5; // eax@8
795 int v6; // ecx@8
796 int v7; // eax@12
797 int v8; // eax@16
798 unsigned __int8 v9; // zf@18
799 char v10; // sf@18
800 unsigned __int8 v11; // of@18
801 int v12; // edi@19
802 int v13; // ecx@19
803 __int16 v14; // ax@19
804 BLVFace *v15; // ebx@24
805 unsigned __int16 *v16; // ecx@24
806 Vec3_short_ *v17; // esi@24
807 int v18; // eax@24
808 int v19; // edx@24
809 signed int v20; // eax@24
810 Vec3_short_ *v21; // ecx@24
811 double v22; // st7@24
812 double v23; // st6@24
813 int v24; // esi@25
814 int v25; // eax@25
815 BLVDoor *v26; // edi@25
816 signed __int64 v27; // qtt@27
817 BLVFaceExtra *v28; // esi@32
818 int v29; // ecx@34
819 int v30; // edx@34
820 unsigned __int64 v31; // qax@34
821 int v32; // eax@34
822 unsigned __int16 *v33; // eax@35
823 Vec3_short_ *v34; // eax@35
824 int v35; // ecx@35
825 int v36; // edx@35
826 signed int v37; // eax@35
827 signed int v38; // edx@35
828 int v39; // eax@35
829 int v40; // edx@35
830 unsigned __int8 v41; // cf@35
831 unsigned __int16 *v42; // edi@36
832 Vec3_short_ *v43; // edi@36
833 int v44; // ecx@36
834 int v45; // edi@36
835 int v46; // ecx@36
836 unsigned __int16 *v47; // edx@44
837 int v48; // ecx@44
838 unsigned int v49; // ecx@46
839 unsigned __int16 v50; // ax@48
840 unsigned int v51; // eax@51
841 unsigned __int16 v52; // ax@54
842 int v53; // ecx@57
843 int v54; // edx@57
844 unsigned __int64 v55; // qax@57
845 int v56; // ecx@58
846 int v57; // eax@58
847 int v58; // eax@59
848 SoundID v59; // [sp-24h] [bp-88h]@12
849 signed int v60; // [sp-20h] [bp-84h]@12
850 unsigned int v61; // [sp-1Ch] [bp-80h]@12
851 signed int v62; // [sp-18h] [bp-7Ch]@12
852 signed int v63; // [sp-14h] [bp-78h]@12
853 int v64; // [sp-10h] [bp-74h]@12
854 unsigned int v65; // [sp-Ch] [bp-70h]@12
855 int v66; // [sp-8h] [bp-6Ch]@12
856 int v67; // [sp+8h] [bp-5Ch]@31
857 int v68; // [sp+Ch] [bp-58h]@34
858 int v69; // [sp+10h] [bp-54h]@34
859 int v70; // [sp+14h] [bp-50h]@31
860 int v71; // [sp+18h] [bp-4Ch]@34
861 int v72; // [sp+1Ch] [bp-48h]@34
862 int v73; // [sp+20h] [bp-44h]@24
863 __int16 v74; // [sp+24h] [bp-40h]@24
864 int v75; // [sp+28h] [bp-3Ch]@36
865 int v76; // [sp+2Ch] [bp-38h]@36
866 int v77; // [sp+30h] [bp-34h]@36
867 int v78; // [sp+34h] [bp-30h]@36
868 int v79; // [sp+38h] [bp-2Ch]@19
869 unsigned int v80; // [sp+3Ch] [bp-28h]@2
870 int v81; // [sp+40h] [bp-24h]@1
871 int v82; // [sp+44h] [bp-20h]@35
872 int v83; // [sp+48h] [bp-1Ch]@34
873 int v84; // [sp+4Ch] [bp-18h]@34
874 int v85; // [sp+50h] [bp-14h]@19
875 SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1
876 BLVDoor *v87; // [sp+58h] [bp-Ch]@3
877 int v88; // [sp+5Ch] [bp-8h]@18
878 int v89; // [sp+60h] [bp-4h]@6
879
880 v0 = 0;
881 v1 = 0;
882 eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID];
883 v81 = 0;
884 if ( pIndoor->uNumDoors > 0 )
885 {
886 v80 = 0;
887 do
888 {
889 v2 = &pIndoor->pDoors[v80 / 0x50];
890 v87 = &pIndoor->pDoors[v80 / 0x50];
891 v3 = pIndoor->pDoors[v80 / 0x50].uState;
892 if ( v3 == (short)v0 || v3 == 2 )
893 {
894 v2->uAttributes &= 0xFFFFFFFDu;
895 goto LABEL_62;
896 }
897 v2->uTimeSinceTriggered += pEventTimer->uTimeElapsed;
898 v4 = v2->uTimeSinceTriggered;
899 if ( v2->uState == 1 )
900 {
901 v89 = (signed int)(v4 * v2->uCloseSpeed) / 128;
902 if ( v89 >= v2->uMoveLength )
903 {
904 v89 = v2->uMoveLength;
905 v2->uState = 2;
906 LABEL_10:
907 if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
908 {
909 v66 = v0;
910 v65 = v0;
911 v64 = v0;
912 v7 = 8 * v1;
913 v63 = v0;
914 v62 = -1;
915 LOBYTE(v7) = 8 * v1 | 1;
916 v61 = v0;
917 v60 = v7;
918 v59 = (SoundID)((int)eDoorSoundID + 1);
919 LABEL_17:
920 pAudioPlayer->PlaySound(v59, v60, v61, v62, v63, v64, v65, v66);
921 goto LABEL_18;
922 }
923 goto LABEL_18;
924 }
925 }
926 else
927 {
928 v5 = (signed int)(v4 * v2->uOpenSpeed) / 128;
929 v6 = v2->uMoveLength;
930 if ( v5 >= v6 )
931 {
932 v89 = v0;
933 v2->uState = v0;
934 goto LABEL_10;
935 }
936 v89 = v6 - v5;
937 }
938 if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
939 {
940 v66 = v0;
941 v65 = v0;
942 v64 = v0;
943 v8 = 8 * v1;
944 v63 = v0;
945 v62 = -1;
946 LOBYTE(v8) = 8 * v1 | 1;
947 v61 = 1;
948 v60 = v8;
949 v59 = eDoorSoundID;
950 goto LABEL_17;
951 }
952 LABEL_18:
953 v11 = __OFSUB__(v2->uNumVertices, (short)v0);
954 v9 = v2->uNumVertices == (short)v0;
955 v10 = (signed __int16)(v2->uNumVertices - v0) < 0;
956 v88 = v0;
957 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
958 {
959 do
960 {
961 v12 = v88;
962 v13 = v2->pVertexIDs[v88];
963 v85 = v89;
964 v79 = v2->vDirection.x;
965 v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
966 v13 *= 6;
967 *(__int16 *)((char *)&pIndoor->pVertices->x + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pXOffsets[v88];
968 v85 = v89;
969 v79 = v2->vDirection.y;
970 v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
971 *(__int16 *)((char *)&pIndoor->pVertices->y + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pYOffsets[v12];
972 v85 = v89;
973 v79 = v2->vDirection.z;
974 v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
975 v14 = ((unsigned int)(v79 * v89) >> 16) + v2->pZOffsets[v12];
976 ++v88;
977 *(__int16 *)((char *)&pIndoor->pVertices->z + v13) = v14;
978 }
979 while ( v88 < v2->uNumVertices );
980 v1 = v81;
981 }
982 v11 = __OFSUB__(v2->uNumFaces, (short)v0);
983 v9 = v2->uNumFaces == (short)v0;
984 v10 = (signed __int16)(v2->uNumFaces - v0) < 0;
985 v88 = v0;
986 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
987 {
988 while ( 1 )
989 {
990 v15 = &pIndoor->pFaces[v2->pFaceIDs[v88]];
991 v16 = v15->pVertexIDs;
992 v17 = &pIndoor->pVertices[*v16];
993 v18 = v15->pFacePlane_old.vNormal.y;
994 v73 = *(int *)&v17->x;
995 v74 = v17->z;
996 v19 = v15->pFacePlane_old.vNormal.z;
997 v20 = -(v19 * v74 + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18);
998 v15->pFacePlane_old.dist = v20;
999 v21 = &pIndoor->pVertices[*v16];
1000 v79 = v21->x;
1001 v22 = (double)v79;
1002 v23 = (double)v21->y;
1003 v79 = v21->z;
1004 v15->pFacePlane.dist = -((double)v79 * v15->pFacePlane.vNormal.z
1005 + v23 * v15->pFacePlane.vNormal.y
1006 + v22 * v15->pFacePlane.vNormal.x);
1007 if ( v19 )
1008 {
1009 v24 = abs(v20 >> 15);
1010 v25 = abs(v15->pFacePlane_old.vNormal.z);
1011 v26 = v87;
1012 if ( v24 > v25 )
1013 Abortf(
1014 "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
1015 v87->uDoorID,
1016 v87->pFaceIDs[v88],
1017 v15->pFacePlane_old.dist,
1018 v15->pFacePlane_old.vNormal.z);
1019 v79 = v15->pFacePlane_old.vNormal.z;
1020 v85 = v15->pFacePlane_old.dist;
1021 LODWORD(v27) = v85 << 16;
1022 HIDWORD(v27) = v85 >> 16;
1023 v85 = v27 / v79;
1024 v15->zCalc3 = -(v27 / v79);
1025 }
1026 else
1027 {
1028 v26 = v87;
1029 }
1030 if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D )
1031 v15->_get_normals((Vec3_int_ *)&v70, (Vec3_int_ *)&v67);
1032 v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID];
1033 if ( !pRenderer->pRenderD3D )
1034 {
1035 if ( !(BYTE2(v15->uAttributes) & 4) )
1036 goto LABEL_59;
1037 v79 = v26->vDirection.x;
1038 v83 = (unsigned __int64)(v79 * (signed __int64)v70) >> 16;
1039 v85 = v71;
1040 v79 = v26->vDirection.y;
1041 v85 = (unsigned __int64)(v79 * (signed __int64)v71) >> 16;
1042 v84 = v72;
1043 v79 = v26->vDirection.z;
1044 v84 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
1045 v79 = v83 + v85 + ((unsigned __int64)(v79 * (signed __int64)v72) >> 16);
1046 v29 = v89;
1047 v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
1048 v28->sTextureDeltaU = -((unsigned int)(v79 * v89) >> 16);
1049 v79 = v26->vDirection.x;
1050 v85 = (unsigned __int64)(v79 * (signed __int64)v67) >> 16;
1051 v83 = v68;
1052 v79 = v26->vDirection.y;
1053 v83 = (unsigned __int64)(v79 * (signed __int64)v68) >> 16;
1054 v84 = v69;
1055 v79 = v26->vDirection.z;
1056 v84 = (unsigned __int64)(v79 * (signed __int64)v69) >> 16;
1057 v30 = v83 + ((unsigned __int64)(v79 * (signed __int64)v69) >> 16);
1058 v79 = v85 + v30;
1059 v31 = (v85 + v30) * (signed __int64)v29;
1060 v83 = v31 >> 16;
1061 v32 = v31 >> 16;
1062 goto LABEL_58;
1063 }
1064 v28->sTextureDeltaU = 0;
1065 v28->sTextureDeltaV = 0;
1066 v33 = v15->pVertexIDs;
1067 v85 = 1;
1068 v34 = &pIndoor->pVertices[*v33];
1069 v35 = v34->z;
1070 v36 = v34->y;
1071 v82 = v34->x;
1072 v79 = v36;
1073 v37 = v70 * v82 + v71 * v36 + v72 * v35;
1074 v38 = v67 * v82 + v68 * v36 + v35 * v69;
1075 v39 = v37 >> 16;
1076 *v15->pVertexUIDs = v39;
1077 v40 = v38 >> 16;
1078 *v15->pVertexVIDs = v40;
1079 v41 = v15->uNumVertices < 1u;
1080 v9 = v15->uNumVertices == 1;
1081 v83 = v40;
1082 v84 = v39;
1083 v82 = v40;
1084 if ( !(v41 | v9) )
1085 {
1086 do
1087 {
1088 v42 = v15->pVertexIDs;
1089 v75 = 2 * v85;
1090 v43 = &pIndoor->pVertices[v42[v85]];
1091 v79 = v43->z;
1092 v44 = v43->y;
1093 v45 = v43->x;
1094 v78 = v44;
1095 v76 = (v72 * v79 + v70 * v45 + v71 * v44) >> 16;
1096 v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16;
1097 v77 = v46;
1098 if ( v76 < v39 )
1099 v39 = v76;
1100 if ( v46 < v40 )
1101 v83 = v46;
1102 if ( v76 > v84 )
1103 v84 = v76;
1104 if ( v46 > v82 )
1105 v82 = v46;
1106 v47 = v15->pVertexUIDs;
1107 v48 = v75;
1108 ++v85;
1109 *(unsigned __int16 *)((char *)v47 + v75) = v76;
1110 *(unsigned __int16 *)((char *)v15->pVertexVIDs + v48) = v77;
1111 v40 = v83;
1112 }
1113 while ( v85 < v15->uNumVertices );
1114 v26 = v87;
1115 }
1116 v49 = v15->uAttributes;
1117 if ( BYTE1(v49) & 0x10 )
1118 goto LABEL_50;
1119 if ( SBYTE1(v49) < 0 )
1120 {
1121 v50 = v15->uBitmapID;
1122 if ( v50 != -1 )
1123 break;
1124 }
1125 LABEL_51:
1126 v51 = v15->uAttributes;
1127 if ( v51 & 8 )
1128 {
1129 v28->sTextureDeltaV -= v40;
1130 }
1131 else
1132 {
1133 if ( v51 & 0x20000 )
1134 {
1135 v52 = v15->uBitmapID;
1136 if ( v52 != -1 )
1137 v28->sTextureDeltaV -= v82
1138 + *(short *)((signed __int16)v52 != -1 ? 72 * (signed __int16)v52 + 7278780 + 0x1A : 26);
1139 }
1140 }
1141 if ( BYTE2(v15->uAttributes) & 4 )
1142 {
1143 v75 = v26->vDirection.x;
1144 v84 = (unsigned __int64)(v75 * (signed __int64)v70) >> 16;
1145 v82 = v71;
1146 v75 = v26->vDirection.y;
1147 v82 = (unsigned __int64)(v75 * (signed __int64)v71) >> 16;
1148 v83 = v72;
1149 v75 = v26->vDirection.z;
1150 v83 = (unsigned __int64)(v75 * (signed __int64)v72) >> 16;
1151 v75 = v84 + v82 + ((unsigned __int64)(v75 * (signed __int64)v72) >> 16);
1152 v53 = v89;
1153 v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
1154 v28->sTextureDeltaU = -((unsigned int)(v75 * v89) >> 16);
1155 v75 = v26->vDirection.x;
1156 v84 = (unsigned __int64)(v75 * (signed __int64)v67) >> 16;
1157 v82 = v68;
1158 v75 = v26->vDirection.y;
1159 v82 = (unsigned __int64)(v75 * (signed __int64)v68) >> 16;
1160 v83 = v69;
1161 v75 = v26->vDirection.z;
1162 v83 = (unsigned __int64)(v75 * (signed __int64)v69) >> 16;
1163 v54 = v82 + ((unsigned __int64)(v75 * (signed __int64)v69) >> 16);
1164 v75 = v84 + v54;
1165 v55 = (v84 + v54) * (signed __int64)v53;
1166 v82 = v55 >> 16;
1167 v32 = v55 >> 16;
1168 LABEL_58:
1169 v56 = v88;
1170 v57 = -v32;
1171 v28->sTextureDeltaV = v57;
1172 v28->sTextureDeltaU += v26->pDeltaUs[v56];
1173 v28->sTextureDeltaV = v57 + v26->pDeltaVs[v56];
1174 }
1175 LABEL_59:
1176 v58 = v26->uNumFaces;
1177 ++v88;
1178 if ( v88 >= v58 )
1179 {
1180 v1 = v81;
1181 v0 = 0;
1182 goto LABEL_62;
1183 }
1184 v2 = v87;
1185 }
1186 LOWORD(v39) = v84
1187 + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24);
1188 LABEL_50:
1189 v28->sTextureDeltaU -= v39;
1190 goto LABEL_51;
1191 }
1192 LABEL_62:
1193 v80 += 80;
1194 ++v1;
1195 v81 = v1;
1196 }
1197 while ( v1 < pIndoor->uNumDoors );
1198 }
1199 }
1200 // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID;
1201
1202 //----- (0046F90C) --------------------------------------------------------
1203 void __cdecl UpdateActors_BLV()
1204 {
1205 Actor *v0; // esi@2
1206 unsigned __int16 v1; // ax@2
1207 int v2; // edi@6
1208 int v3; // eax@6
1209 int v4; // eax@8
1210 __int16 v5; // ax@11
1211 signed int v6; // ebx@14
1212 unsigned __int8 v7; // zf@14
1213 unsigned __int8 v8; // sf@14
1214 signed __int16 v9; // ax@17
1215 signed __int64 v10; // qax@18
1216 unsigned __int16 v11; // ax@21
1217 int v12; // eax@29
1218 unsigned __int64 v13; // qax@29
1219 int v14; // eax@30
1220 unsigned __int64 v15; // qax@30
1221 int v16; // ecx@33
1222 BLVFace *v17; // edx@33
1223 int v18; // ecx@33
1224 BLVFace *v19; // eax@34
1225 int v20; // ecx@46
1226 int v21; // eax@46
1227 int v22; // edi@46
1228 int v23; // eax@48
1229 unsigned int v24; // eax@51
1230 int v25; // eax@52
1231 int v26; // ebx@54
1232 int v27; // ST08_4@54
1233 int v28; // edi@54
1234 int v29; // eax@54
1235 int v30; // ecx@62
1236 int v31; // ebx@62
1237 int v32; // eax@62
1238 int v33; // eax@64
1239 unsigned int v34; // ecx@64
1240 int v35; // ecx@64
1241 signed int v36; // edx@85
1242 signed int v37; // ebx@85
1243 BLVFace *v38; // edi@89
1244 int v39; // ecx@90
1245 int v40; // ebx@90
1246 PolygonType v41; // al@94
1247 int v42; // eax@96
1248 __int16 v43; // dx@96
1249 int v44; // ecx@96
1250 int v45; // edi@101
1251 int v46; // edi@101
1252 int v47; // eax@101
1253 unsigned __int64 v48; // qax@101
1254 unsigned __int8 v49; // zf@103
1255 unsigned __int8 v50; // sf@103
1256 unsigned __int8 v51; // of@103
1257 AIDirection v52; // [sp+0h] [bp-60h]@75
1258 AIDirection v53; // [sp+1Ch] [bp-44h]@116
1259 int v54; // [sp+38h] [bp-28h]@53
1260 int v55; // [sp+3Ch] [bp-24h]@6
1261 int v56; // [sp+40h] [bp-20h]@6
1262 unsigned int _this; // [sp+44h] [bp-1Ch]@51
1263 int v58; // [sp+48h] [bp-18h]@51
1264 int v59; // [sp+4Ch] [bp-14h]@8
1265 int v60; // [sp+50h] [bp-10h]@6
1266 int v61; // [sp+54h] [bp-Ch]@14
1267 int v62; // [sp+58h] [bp-8h]@6
1268 unsigned int v63; // [sp+5Ch] [bp-4h]@1
1269
1270 v63 = 0;
1271 if ( (signed int)uNumActors > 0 )
1272 {
1273 while ( 1 )
1274 {
1275 v0 = &pActors[v63];
1276 v1 = v0->uAIState;
1277 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
1278 goto LABEL_123;
1279 v55 = v0->uSectorID;
1280 v2 = _46ED1B_collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, (unsigned int *)&v55, &v60);
1281 v0->uSectorID = v55;
1282 v3 = v0->pMonsterInfo.uFlying;
1283 v56 = v2;
1284 v62 = v3;
1285 if ( !v0->CanAct() )
1286 v62 = 0;
1287 v4 = v0->vPosition.z;
1288 v59 = 0;
1289 if ( v4 > v2 + 1 )
1290 v59 = 1;
1291 if ( v2 <= -30000 )
1292 {
1293 v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4);
1294 v0->uSectorID = v5;
1295 if ( !v5
1296 || (v56 = _46CEC3_get_floor_level(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &v60), v56 == -30000) )
1297 goto LABEL_123;
1298 }
1299 if ( v0->uCurrentActionAnimation == 1 )
1300 {
1301 v6 = v0->uMovementSpeed;
1302 v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0;
1303 v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0;
1304 v61 = v0->uMovementSpeed;
1305 if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) )
1306 {
1307 v9 = v0->pActorBuffs[7].uPower;
1308 if ( v9 )
1309 LODWORD(v10) = v6 / (unsigned __int16)v9;
1310 else
1311 v10 = (signed __int64)((double)v61 * 0.5);
1312 v6 = v10;
1313 v61 = v10;
1314 }
1315 v11 = v0->uAIState;
1316 if ( v11 == 6 || v11 == 7 )
1317 {
1318 v6 *= 2;
1319 v61 = v6;
1320 }
1321 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 1 )
1322 v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6);
1323 if ( v6 > 1000 )
1324 v6 = 1000;
1325 v12 = stru_5C6E00->SinCos(v0->uYawAngle);
1326 v55 = v12;
1327 v13 = v12 * (signed __int64)v6;
1328 v61 = v13 >> 16;
1329 v0->vVelocity.x = WORD1(v13);
1330 v55 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
1331 v61 = (unsigned __int64)(v55 * (signed __int64)v6) >> 16;
1332 v7 = v62 == 0;
1333 v0->vVelocity.y = (unsigned int)(v55 * v6) >> 16;
1334 if ( !v7 )
1335 {
1336 v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
1337 v55 = v14;
1338 v15 = v14 * (signed __int64)v6;
1339 v61 = v15 >> 16;
1340 v0->vVelocity.z = WORD1(v15);
1341 }
1342 }
1343 else
1344 {
1345 v61 = v0->vVelocity.x;
1346 v55 = 55000;
1347 v61 = (unsigned __int64)(55000i64 * v61) >> 16;
1348 v0->vVelocity.x = v61;
1349 v61 = v0->vVelocity.y;
1350 v61 = (unsigned __int64)(v55 * (signed __int64)v61) >> 16;
1351 v7 = v62 == 0;
1352 v0->vVelocity.y = v61;
1353 if ( !v7 )
1354 {
1355 v55 = 55000;
1356 v61 = v0->vVelocity.z;
1357 v61 = (unsigned __int64)(55000i64 * v61) >> 16;
1358 v0->vVelocity.z = v61;
1359 }
1360 }
1361 v16 = v0->vPosition.z;
1362 v17 = pIndoor->pFaces;
1363 v51 = __OFSUB__(v16, v56);
1364 v8 = v16 - v56 < 0;
1365 v18 = v60;
1366 if ( v8 ^ v51 )
1367 {
1368 v0->vPosition.z = v56 + 1;
1369 v19 = &v17[v18];
1370 if ( v19->uPolygonType == 3 )
1371 {
1372 if ( v0->vVelocity.z < 0 )
1373 v0->vVelocity.z = 0;
1374 }
1375 else
1376 {
1377 if ( v19->pFacePlane_old.vNormal.z < 45000 )
1378 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1379 }
1380 }
1381 else
1382 {
1383 if ( v59 && !v62 )
1384 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1385 }
1386 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y + v0->vVelocity.z * v0->vVelocity.z >= 400 )
1387 break;
1388 v0->vVelocity.z = 0;
1389 v0->vVelocity.y = 0;
1390 v0->vVelocity.x = 0;
1391 if ( BYTE2(v17[v18].uAttributes) & 0x40 )
1392 {
1393 if ( v0->uAIState == 5 )
1394 v0->uAIState = 11;
1395 }
1396 LABEL_123:
1397 ++v63;
1398 if ( (signed int)v63 >= (signed int)uNumActors )
1399 return;
1400 }
1401 v20 = v0->uActorRadius;
1402 v21 = v0->uActorHeight;
1403 stru_721530.field_84 = -1;
1404 stru_721530.field_70 = 0;
1405 v55 = 0;
1406 stru_721530.field_0 = 1;
1407 stru_721530.field_8 = v20;
1408 stru_721530.prolly_normal_d = v20;
1409 stru_721530.field_C = v21;
1410 v22 = 0;
1411 while ( 1 )
1412 {
1413 stru_721530.field_34.x = v0->vPosition.x;
1414 stru_721530.normal.x = stru_721530.field_34.x;
1415 stru_721530.field_34.y = v0->vPosition.y;
1416 stru_721530.normal.y = stru_721530.field_34.y;
1417 v23 = v0->vPosition.z;
1418 stru_721530.normal.z = v23 + v20 + 1;
1419 stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1;
1420 if ( stru_721530.field_34.z < stru_721530.normal.z )
1421 stru_721530.field_34.z = v23 + v20 + 1;
1422 stru_721530.field_1C = v0->vVelocity.x;
1423 stru_721530.field_20 = v0->vVelocity.y;
1424 stru_721530.field_24 = v0->vVelocity.z;
1425 stru_721530.uSectorID = v0->uSectorID;
1426 if ( !stru_721530._47050A(v22) )
1427 {
1428 v58 = v22;
1429 v24 = 8 * v63;
1430 LOBYTE(v24) = 8 * v63 | 3;
1431 v61 = v22;
1432 _this = v24;
1433 do
1434 {
1435 _46E44E_collide_against_faces_and_portals(1u);
1436 _46E0B2_collide_against_decorations();
1437 _46EF01_collision_chech_player(0);
1438 _46ED8A_collide_against_layingItems(_this);
1439 v25 = 0;
1440 v56 = 0;
1441 if ( ai_arrays_size > v22 )
1442 {
1443 do
1444 {
1445 v54 = ai_array_4F7DB0_actor_ids[v25];
1446 if ( v54 != v63 )
1447 {
1448 v26 = v54;
1449 v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z);
1450 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y);
1451 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x);
1452 if ( sub_4621DA(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius
1453 && _46DF1A_collide_against_actor(v54, 40) )
1454 ++v58;
1455 v22 = 0;
1456 }
1457 v25 = v56++ + 1;
1458 }
1459 while ( v56 < ai_arrays_size );
1460 }
1461 if ( _46F04E_collide_against_portals() )
1462 break;
1463 ++v61;
1464 }
1465 while ( v61 < 100 );
1466 v56 = v58 > 1;
1467 if ( stru_721530.field_7C >= stru_721530.field_6C )
1468 {
1469 v30 = stru_721530.normal2.x;
1470 v31 = stru_721530.normal2.y;
1471 v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1472 }
1473 else
1474 {
1475 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
1476 v30 = v58 + v0->vPosition.x;
1477 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1478 v31 = v58 + v0->vPosition.y;
1479 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1480 v32 = v58 + v0->vPosition.z;
1481 }
1482 v33 = _46ED1B_collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &v60);
1483 v34 = pIndoor->pFaces[v60].uAttributes;
1484 v35 = v34 & 0x400000;
1485 if ( v35 && v0->uAIState == 5 )
1486 {
1487 v0->uAIState = 11;
1488 goto LABEL_120;
1489 }
1490 if ( v59 != v22 || v62 != v22 || v35 == v22 )
1491 {
1492 if ( v33 == -30000 )
1493 goto LABEL_120;
1494 if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 )
1495 {
1496 if ( stru_721530.field_7C >= stru_721530.field_6C )
1497 {
1498 v0->vPosition.x = LOWORD(stru_721530.normal2.x);
1499 v0->vPosition.y = LOWORD(stru_721530.normal2.y);
1500 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
1501 v0->uSectorID = LOWORD(stru_721530.uSectorID);
1502 goto LABEL_123;
1503 }
1504 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
1505 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
1506 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1507 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
1508 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1509 v36 = stru_721530.uFaceID;
1510 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
1511 v0->uSectorID = LOWORD(stru_721530.uSectorID);
1512 stru_721530.field_70 += stru_721530.field_7C;
1513 v37 = v36 >> 3;
1514 if ( (v36 & 7) != 3 )
1515 {
1516 if ( (v36 & 7) != 4 )
1517 {
1518 if ( (v36 & 7) == 5 )
1519 {
1520 _this = sub_452A9E(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
1521 v45 = stru_5C6E00->Atan2(
1522 v0->vPosition.x - pLevelDecorations[v37].vPosition.x,
1523 v0->vPosition.y - pLevelDecorations[v37].vPosition.y);
1524 v54 = stru_5C6E00->SinCos(v45);
1525 v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16;
1526 v46 = v45 - stru_5C6E00->uIntegerHalfPi;
1527 v0->vVelocity.x = v54 * _this >> 16;
1528 v47 = stru_5C6E00->SinCos(v46);
1529 v54 = v47;
1530 v48 = v47 * (signed __int64)(signed int)_this;
1531 v56 = v48 >> 16;
1532 v0->vVelocity.y = WORD1(v48);
1533 goto LABEL_119;
1534 }
1535 if ( (v36 & 7) == 6 )
1536 {
1537 stru_721530.field_84 = v36 >> 3;
1538 v38 = &pIndoor->pFaces[v37];
1539 if ( v38->uPolygonType == 3 )
1540 {
1541 v39 = v0->vVelocity.x;
1542 v40 = v0->vVelocity.y * v0->vVelocity.y;
1543 v0->vVelocity.z = 0;
1544 v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1;
1545 if ( v39 * v39 + v40 < 400 )
1546 {
1547 v0->vVelocity.y = 0;
1548 v0->vVelocity.x = 0;
1549 goto LABEL_119;
1550 }
1551 }
1552 else
1553 {
1554 v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y
1555 * v0->vVelocity.y
1556 + v38->pFacePlane_old.vNormal.z
1557 * v0->vVelocity.z) >> 16;
1558 if ( stru_721530.field_64 >> 3 > v61 )
1559 v61 = stru_721530.field_64 >> 3;
1560 v58 = v38->pFacePlane_old.vNormal.x;
1561 v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16;
1562 _this = v38->pFacePlane_old.vNormal.y;
1563 _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16;
1564 v56 = v38->pFacePlane_old.vNormal.z;
1565 v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16;
1566 v0->vVelocity.x += v58;
1567 v0->vVelocity.y += _this;
1568 v0->vVelocity.z += v56;
1569 v41 = v38->uPolygonType;
1570 if ( v41 != 4 && v41 != 3 )
1571 {
1572 v42 = v38->pFacePlane_old.vNormal.x;
1573 v43 = v0->vPosition.z;
1574 v44 = stru_721530.prolly_normal_d
1575 - ((v38->pFacePlane_old.dist
1576 + v38->pFacePlane_old.vNormal.z * v0->vPosition.z
1577 + v38->pFacePlane_old.vNormal.y * v0->vPosition.y
1578 + v42 * v0->vPosition.x) >> 16);
1579 if ( v44 > 0 )
1580 {
1581 v0->vPosition.x += (unsigned int)(v44 * v42) >> 16;
1582 v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16;
1583 v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16);
1584 }
1585 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
1586 }
1587 }
1588 if ( BYTE3(v38->uAttributes) & 8 )
1589 EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1);
1590 }
1591 LABEL_119:
1592 v56 = v0->vVelocity.x;
1593 v54 = 58500;
1594 v56 = (unsigned __int64)(58500i64 * v56) >> 16;
1595 v0->vVelocity.x = v56;
1596 v56 = v0->vVelocity.y;
1597 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
1598 v54 = 58500;
1599 v0->vVelocity.y = v56;
1600 v56 = v0->vVelocity.z;
1601 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
1602 v22 = 0;
1603 v0->vVelocity.z = v56;
1604 goto LABEL_120;
1605 }
1606 if ( v0->GetActorsRelation(0) )
1607 {
1608 v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[11].uExpireTime), v22);
1609 v49 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == v22;
1610 v50 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) - v22 < 0;
1611 v0->vVelocity.y = v22;
1612 v0->vVelocity.x = v22;
1613 if ( !(v50 ^ v51)
1614 && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v22) )
1615 pParty->pPartyBuffs[11].Reset();
1616 viewparams->bRedrawGameUI = 1;
1617 goto LABEL_119;
1618 }
1619 v36 = stru_721530.uFaceID;
1620 LABEL_118:
1621 Actor::FaceObject(v63, v36, v22, (AIDirection *)v22);
1622 goto LABEL_119;
1623 }
1624 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 3) )
1625 goto LABEL_119;
1626 if ( v0->pMonsterInfo.uHostilityType )
1627 {
1628 if ( v56 == v22 )
1629 goto LABEL_114;
1630 }
1631 else
1632 {
1633 if ( v56 == v22 )
1634 {
1635 if ( !pActors[v37].pMonsterInfo.uHostilityType )
1636 goto LABEL_118;
1637 LABEL_114:
1638 Actor::_402968(v63, v36, v22, (AIDirection *)v22);
1639 goto LABEL_119;
1640 }
1641 }
1642 Actor::_403F58(v63, 4, v22, &v53);
1643 goto LABEL_119;
1644 }
1645 if ( v0->vPosition.x & 1 )
1646 v0->uYawAngle += 100;
1647 else
1648 v0->uYawAngle -= 100;
1649 }
1650 else
1651 {
1652 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 3) )
1653 goto LABEL_123;
1654 if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 )
1655 {
1656 Actor::_403F58(v63, 4, v22, &v52);
1657 goto LABEL_123;
1658 }
1659 }
1660 }
1661 LABEL_120:
1662 ++v55;
1663 if ( v55 >= 100 )
1664 goto LABEL_123;
1665 v20 = stru_721530.prolly_normal_d;
1666 }
1667 }
1668 }
1669 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
1670 // 4F75D8: using guessed type int ai_arrays_size;
1671
1672
1673
1674 //----- (0047050A) --------------------------------------------------------
1675 int stru141::_47050A(int a2)
1676 {
1677 stru141 *v2; // esi@1
1678 signed int v3; // eax@1
1679 int v4; // ecx@1
1680 int v5; // edx@1
1681 int v6; // edx@1
1682 int v7; // eax@1
1683 int v8; // eax@3
1684 signed int result; // eax@4
1685 int v10; // eax@5
1686 int v11; // eax@5
1687 int v12; // ebx@5
1688 int v13; // edx@5
1689 int v14; // edi@5
1690 int v15; // ecx@5
1691 int v16; // eax@5
1692 int v17; // eax@5
1693 int v18; // eax@7
1694 int v19; // edx@9
1695 int v20; // edi@9
1696 int v21; // eax@9
1697 int v22; // eax@11
1698 int v23; // edx@13
1699 int v24; // eax@13
1700 int v25; // eax@14
1701 int v26; // eax@16
1702 int v27; // eax@17
1703 int v28; // [sp+14h] [bp+8h]@5
1704
1705 v2 = this;
1706 v3 = sub_452A9E(this->field_24 * this->field_24 + this->field_20 * this->field_20 + this->field_1C * this->field_1C);
1707 v4 = v3 | 1;
1708 v5 = v2->field_1C;
1709 v2->field_64 = v3 | 1;
1710 v2->field_58.x = 65536 / (v3 | 1) * v5;
1711 v2->field_58.y = 65536 / (v3 | 1) * v2->field_20;
1712 v6 = 65536 / (v3 | 1) * v2->field_24;
1713 v2->field_68 = 65536 / (v3 | 1);
1714 v7 = a2;
1715 v2->field_58.z = v6;
1716 if ( !a2 )
1717 v7 = pEventTimer->dt_in_some_format;
1718 v8 = ((unsigned __int64)(v7 * (signed __int64)v4) >> 16) - v2->field_70;
1719 v2->field_6C = v8;
1720 if ( v8 > 0 )
1721 {
1722 v10 = ((unsigned __int64)(v8 * (signed __int64)v2->field_58.x) >> 16) + v2->normal.x;
1723 v2->field_4C = v10;
1724 v2->normal2.x = v10;
1725 v11 = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.y) >> 16) + v2->normal.y;
1726 v2->field_50 = v11;
1727 v2->normal2.y = v11;
1728 v2->normal2.z = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16) + v2->normal.z;
1729 v12 = v2->field_34.z;
1730 v13 = v2->normal.x;
1731 v14 = v2->normal2.x;
1732 v15 = v2->prolly_normal_d;
1733 v16 = v12 + ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16);
1734 v28 = v16;
1735 v2->field_54 = v16;
1736 v17 = v13;
1737 if ( v13 >= v14 )
1738 v17 = v14;
1739 v2->sMaxX = v17 - v15;
1740 v18 = v15 + v13;
1741 if ( v13 <= v14 )
1742 v18 = v15 + v14;
1743 v19 = v2->normal.y;
1744 v20 = v2->normal2.y;
1745 v2->sMinX = v18;
1746 v21 = v19;
1747 if ( v19 >= v20 )
1748 v21 = v20;
1749 v2->sMaxY = v21 - v15;
1750 v22 = v15 + v19;
1751 if ( v19 <= v20 )
1752 v22 = v20 + v15;
1753 v23 = v2->normal2.z;
1754 v2->sMinY = v22;
1755 v24 = v2->normal.z;
1756 if ( v24 >= v23 )
1757 v25 = v23 - v15;
1758 else
1759 v25 = v24 - v15;
1760 v2->sMaxZ = v25;
1761 v26 = v2->field_8;
1762 if ( v12 <= v28 )
1763 v27 = v28 + v26;
1764 else
1765 v27 = v12 + v26;
1766 v2->uFaceID = 0;
1767 v2->field_80 = -1;
1768 v2->field_88 = -1;
1769 v2->sMinZ = v27;
1770 v2->field_7C = 0xFFFFFFu;
1771 result = 0;
1772 }
1773 else
1774 {
1775 result = 1;
1776 }
1777 return result;
1778 }
1779
1780 //----- (004706C6) --------------------------------------------------------
1781 void __cdecl UpdateActors_ODM()
1782 {
1783 Actor *v0; // esi@2
1784 unsigned __int16 v1; // ax@2
1785 unsigned int v2; // ecx@6
1786 int v3; // ebx@6
1787 int v4; // eax@8
1788 int v5; // eax@10
1789 int v6; // ecx@10
1790 signed int v7; // ebx@10
1791 signed int v8; // ebx@17
1792 unsigned __int8 v9; // zf@17
1793 unsigned __int8 v10; // sf@17
1794 unsigned __int16 v11; // ax@21
1795 int v12; // eax@29
1796 unsigned __int64 v13; // qax@29
1797 int v14; // eax@30
1798 unsigned __int64 v15; // qax@30
1799 int v16; // eax@33
1800 int v17; // edi@34
1801 int v18; // edx@42
1802 int v19; // ecx@42
1803 __int16 v20; // ax@42
1804 int v21; // ebx@42
1805 int v22; // edi@42
1806 int v23; // ecx@42
1807 __int16 v24; // ax@42
1808 int v25; // eax@45
1809 signed int v26; // ecx@50
1810 int v27; // eax@52
1811 int v28; // eax@54
1812 signed int v29; // ebx@57
1813 signed int v30; // eax@57
1814 int v31; // edi@57
1815 signed int i; // ebx@57
1816 unsigned int v33; // ecx@58
1817 int v34; // ebx@64
1818 int v35; // edi@64
1819 int v36; // eax@64
1820 unsigned __int16 v37; // cx@66
1821 signed int v38; // edx@71
1822 signed int v39; // edi@71
1823 BSPModel *v40; // eax@75
1824 ODMFace *v41; // edi@75
1825 int v42; // ebx@76
1826 int v43; // ecx@77
1827 int v44; // edx@77
1828 __int16 v45; // dx@82
1829 int v46; // ecx@82
1830 signed int v47; // ebx@85
1831 int v48; // edi@85
1832 int v49; // edi@85
1833 int v50; // eax@85
1834 unsigned __int64 v51; // qax@85
1835 unsigned __int8 v52; // zf@87
1836 unsigned __int8 v53; // sf@87
1837 unsigned __int8 v54; // of@104
1838 int v55; // eax@107
1839 unsigned int v56; // edi@107
1840 int v57; // ST10_4@107
1841 unsigned int v58; // edi@107
1842 unsigned int v59; // ebx@107
1843 signed int v60; // eax@107
1844 int v61; // eax@124
1845 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
1846 char v63; // [sp+18h] [bp-38h]@64
1847 int v64; // [sp+1Ch] [bp-34h]@64
1848 int v65; // [sp+20h] [bp-30h]@2
1849 int v66; // [sp+24h] [bp-2Ch]@2
1850 bool v67; // [sp+28h] [bp-28h]@10
1851 unsigned int v68; // [sp+2Ch] [bp-24h]@10
1852 unsigned int v69; // [sp+30h] [bp-20h]@6
1853 unsigned int v70; // [sp+34h] [bp-1Ch]@10
1854 int v71; // [sp+38h] [bp-18h]@62
1855 int v72; // [sp+3Ch] [bp-14h]@10
1856 int v73; // [sp+40h] [bp-10h]@17
1857 int v74; // [sp+44h] [bp-Ch]@8
1858 unsigned int v75; // [sp+48h] [bp-8h]@1
1859 int v76; // [sp+4Ch] [bp-4h]@10
1860
1861 v75 = 0;
1862 if ( (signed int)uNumActors <= 0 )
1863 return;
1864 do
1865 {
1866 v0 = &pActors[v75];
1867 v66 = v0->vPosition.x;
1868 v65 = v0->vPosition.y;
1869 v1 = v0->uAIState;
1870 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
1871 goto LABEL_121;
1872 v2 = v0->pMonsterInfo.uID;
1873 v3 = 0;
1874 v69 = 0;
1875 if ( MonsterStats::BelongsToSupertype(v2, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
1876 v3 = 1;
1877 v4 = v0->pMonsterInfo.uFlying;
1878 v0->uSectorID = 0;
1879 v74 = v4;
1880 if ( !v0->CanAct() )
1881 v74 = 0;
1882 v70 = GetTerrainHeightsAroundParty(v0->vPosition.x, v0->vPosition.y);
1883 v5 = sub_46D49E_prolly_get_world_y_under_party(
1884 v0->vPosition.x,
1885 v0->vPosition.y,
1886 v0->vPosition.z,
1887 v0->uActorHeight,
1888 &v76,
1889 (int *)&v69,
1890 v3);
1891 v6 = v0->vPosition.z;
1892 v7 = v5;
1893 v68 = v5;
1894 v72 = 0;
1895 v67 = v69 == 0;
1896 if ( v6 > v5 + 1 )
1897 v72 = 1;
1898 if ( v0->uAIState == 5 && v76 && !v72 )
1899 {
1900 v0->uAIState = 11;
1901 goto LABEL_121;
1902 }
1903 if ( v0->uCurrentActionAnimation == 1 )
1904 {
1905 v8 = v0->uMovementSpeed;
1906 v9 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0;
1907 v10 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0;
1908 v73 = v0->uMovementSpeed;
1909 if ( !v10 && (!(v10 | v9) || LODWORD(v0->pActorBuffs[7].uExpireTime) > 0) )
1910 {
1911 v8 = (signed __int64)((double)v73 * 0.5);
1912 v73 = (signed __int64)((double)v73 * 0.5);
1913 }
1914 v11 = v0->uAIState;
1915 if ( v11 == 7 || v11 == 6 )
1916 {
1917 v8 *= 2;
1918 v73 = v8;
1919 }
1920 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 1 )
1921 v8 = (signed __int64)((double)v73 * flt_6BE3AC_debug_recmod1_x_1_6);
1922 if ( v8 > 1000 )
1923 v8 = 1000;
1924 v12 = stru_5C6E00->SinCos(v0->uYawAngle);
1925 v69 = v12;
1926 v13 = v12 * (signed __int64)v8;
1927 v73 = v13 >> 16;
1928 v0->vVelocity.x = WORD1(v13);
1929 v69 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
1930 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16;
1931 v9 = v74 == 0;
1932 v0->vVelocity.y = v69 * v8 >> 16;
1933 if ( !v9 )
1934 {
1935 v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
1936 v69 = v14;
1937 v15 = v14 * (signed __int64)v8;
1938 v73 = v15 >> 16;
1939 v0->vVelocity.z = WORD1(v15);
1940 }
1941 v7 = v68;
1942 }
1943 else
1944 {
1945 v73 = v0->vVelocity.x;
1946 v69 = 55000;
1947 v73 = (unsigned __int64)(55000i64 * v73) >> 16;
1948 v0->vVelocity.x = v73;
1949 v73 = v0->vVelocity.y;
1950 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16;
1951 v9 = v74 == 0;
1952 v0->vVelocity.y = v73;
1953 if ( !v9 )
1954 {
1955 v69 = 55000;
1956 v73 = v0->vVelocity.z;
1957 v73 = (unsigned __int64)(55000i64 * v73) >> 16;
1958 v0->vVelocity.z = v73;
1959 }
1960 }
1961 if ( v0->vPosition.z < v7 )
1962 {
1963 v16 = v74;
1964 v0->vPosition.z = v7;
1965 v0->vVelocity.z = v16 != 0 ? 0x14 : 0;
1966 }
1967 v17 = 0;
1968 if ( !v72 || v74 )
1969 {
1970 if ( v70 && !v72 && v67 )
1971 {
1972 v18 = v0->vPosition.y;
1973 v19 = v0->vPosition.x;
1974 v0->vPosition.z = v7;
1975 _46DCC8_get_gravity_direction_outdoor(v19, v18, &v62);
1976 v20 = GetGravityStrength();
1977 v21 = v62.y;
1978 v22 = v62.z;
1979 v23 = v62.y * v0->vVelocity.y;
1980 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
1981 v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16;
1982 v72 = v21;
1983 v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16;
1984 v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16;
1985 v24 = v72;
1986 v72 = v22;
1987 v0->vVelocity.y += v24;
1988 v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16;
1989 v0->vVelocity.z += v72;
1990 v17 = 0;
1991 }
1992 }
1993 else
1994 {
1995 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1996 }
1997 if ( pParty->field_1613C != v17 && v0->CanAct() )
1998 {
1999 v0->vVelocity.x += rand() % 100 - 50;
2000 v0->vVelocity.y += rand() % 100 - 50;
2001 v0->vVelocity.z += rand() % 100 - 20;
2002 v25 = rand();
2003 v0->uAIState = 8;
2004 v0->uYawAngle += v25 % 32 - 16;
2005 v0->UpdateAnimation();
2006 }
2007 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == v17 )
2008 {
2009 v0->vVelocity.y = v17;
2010 v0->vVelocity.x = v17;
2011 }
2012 v9 = v0->pMonsterInfo.uFlying == 0;
2013 stru_721530.field_0 = 1;
2014 if ( v9 )
2015 v26 = 40;
2016 else
2017 v26 = v0->uActorRadius;
2018 v27 = v0->uActorHeight;
2019 stru_721530.field_84 = -1;
2020 stru_721530.field_8 = v26;
2021 stru_721530.prolly_normal_d = v26;
2022 stru_721530.field_C = v27;
2023 stru_721530.field_70 = v17;
2024 v69 = v17;
2025 while ( 1 )
2026 {
2027 stru_721530.field_34.x = v0->vPosition.x;
2028 stru_721530.normal.x = stru_721530.field_34.x;
2029 stru_721530.field_34.y = v0->vPosition.y;
2030 stru_721530.normal.y = stru_721530.field_34.y;
2031 v28 = v0->vPosition.z;
2032 stru_721530.normal.z = v28 + v26 + 1;
2033 stru_721530.field_34.z = v28 - v26 + stru_721530.field_C - 1;
2034 if ( stru_721530.field_34.z < stru_721530.normal.z )
2035 stru_721530.field_34.z = v28 + v26 + 1;
2036 stru_721530.field_1C = v0->vVelocity.x;
2037 stru_721530.uSectorID = 0;
2038 stru_721530.field_20 = v0->vVelocity.y;
2039 stru_721530.field_24 = v0->vVelocity.z;
2040 if ( stru_721530._47050A(0) )
2041 break;
2042 _46E889_collide_against_bmodels(1u);
2043 v29 = WorldPosToGridCellZ(v0->vPosition.y);
2044 v30 = WorldPosToGridCellX(v0->vPosition.x);
2045 _46E26D_collide_against_sprites(v30, v29);
2046 _46EF01_collision_chech_player(0);
2047 _46ED8A_collide_against_layingItems(8 * v75 | 3);
2048 v31 = 0;
2049 for ( i = 0; v31 < ai_arrays_size; ++v31 )
2050 {
2051 v33 = ai_array_4F7DB0_actor_ids[v31];
2052 if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) )
2053 ++i;
2054 }
2055 v71 = i > 1;
2056 if ( stru_721530.field_7C < stru_721530.field_6C )
2057 v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2058 v34 = 0;
2059 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2060 v36 = sub_46D49E_prolly_get_world_y_under_party(
2061 stru_721530.normal2.x,
2062 stru_721530.normal2.y,
2063 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
2064 v0->uActorHeight,
2065 (int *)&v63,
2066 &v64,
2067 0);
2068 if ( v76 )
2069 {
2070 if ( v35 < v36 + 60 )
2071 {
2072 v37 = v0->uAIState;
2073 if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 )
2074 {
2075 if ( v64 )
2076 v61 = v36 + 30;
2077 else
2078 v61 = v68 + 60;
2079 sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
2080 v0->uAIState = 11;
2081 return;
2082 }
2083 }
2084 }
2085 if ( stru_721530.field_7C >= stru_721530.field_6C )
2086 {
2087 v0->vPosition.x = LOWORD(stru_721530.normal2.x);
2088 v0->vPosition.y = LOWORD(stru_721530.normal2.y);
2089 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
2090 break;
2091 }
2092 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2093 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
2094 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2095 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
2096 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2097 v38 = stru_721530.uFaceID;
2098 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
2099 stru_721530.field_70 += stru_721530.field_7C;
2100 v39 = v38 >> 3;
2101 switch ( v38 & 7 )
2102 {
2103 case 3:
2104 if ( pParty->bTurnBasedModeOn != 1 )
2105 goto LABEL_97;
2106 if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 )
2107 {
2108 v34 = 0;
2109 LABEL_97:
2110 if ( v0->pMonsterInfo.uHostilityType )
2111 {
2112 if ( v71 == v34 )
2113 goto LABEL_99;
2114 LABEL_101:
2115 Actor::_403F58(v75, 4, v34, (AIDirection *)v34);
2116 break;
2117 }
2118 if ( v71 != v34 )
2119 goto LABEL_101;
2120 if ( pActors[v39].pMonsterInfo.uHostilityType )
2121 {
2122 LABEL_99:
2123 Actor::_402968(v75, v38, v34, (AIDirection *)v34);
2124 break;
2125 }
2126 LABEL_103:
2127 Actor::FaceObject(v75, v38, v34, (AIDirection *)v34);
2128 break;
2129 }
2130 break;
2131 case 4:
2132 if ( !v0->GetActorsRelation(0) )
2133 {
2134 v38 = stru_721530.uFaceID;
2135 goto LABEL_103;
2136 }
2137 v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
2138 v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0;
2139 v0->vVelocity.y = 0;
2140 v0->vVelocity.x = 0;
2141 if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) )
2142 pParty->pPartyBuffs[11].Reset();
2143 viewparams->bRedrawGameUI = 1;
2144 break;
2145 case 5:
2146 v47 = sub_452A9E(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
2147 v48 = stru_5C6E00->Atan2(
2148 v0->vPosition.x - pLevelDecorations[v39].vPosition.x,
2149 v0->vPosition.y - pLevelDecorations[v39].vPosition.y);
2150 v71 = stru_5C6E00->SinCos(v48);
2151 v70 = (unsigned __int64)(v71 * (signed __int64)v47) >> 16;
2152 v49 = v48 - stru_5C6E00->uIntegerHalfPi;
2153 v0->vVelocity.x = (unsigned int)(v71 * v47) >> 16;
2154 v50 = stru_5C6E00->SinCos(v49);
2155 v71 = v50;
2156 v51 = v50 * (signed __int64)v47;
2157 v70 = v51 >> 16;
2158 v0->vVelocity.y = WORD1(v51);
2159 break;
2160 case 6:
2161 v40 = &pOutdoor->pBModels[v38 >> 9];
2162 v41 = &v40->pFaces[v39 & 0x3F];
2163 if ( !(BYTE3(v41->uFaceAttributes) & 0x20) )
2164 {
2165 v42 = v41->uPolygonType;
2166 if ( v42 == 3 )
2167 {
2168 v43 = v0->vVelocity.y;
2169 v44 = v0->vVelocity.x;
2170 v0->vVelocity.z = 0;
2171 v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1;
2172 if ( v44 * v44 + v43 * v43 < 400 )
2173 {
2174 v0->vVelocity.y = 0;
2175 v0->vVelocity.x = 0;
2176 }
2177 }
2178 else
2179 {
2180 v72 = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z
2181 + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16;
2182 if ( stru_721530.field_64 >> 3 > v72 )
2183 v72 = stru_721530.field_64 >> 3;
2184 v73 = v41->pFacePlane.vNormal.x;
2185 v73 = (unsigned __int64)(v72 * (signed __int64)v73) >> 16;
2186 v71 = v41->pFacePlane.vNormal.y;
2187 v71 = (unsigned __int64)(v72 * (signed __int64)v71) >> 16;
2188 v70 = v41->pFacePlane.vNormal.z;
2189 v70 = (unsigned __int64)(v72 * (signed __int64)(signed int)v70) >> 16;
2190 v0->vVelocity.x += v73;
2191 v0->vVelocity.y += v71;
2192 v0->vVelocity.z += v70;
2193 if ( v42 != 4 )
2194 {
2195 v45 = v0->vPosition.z;
2196 v46 = stru_721530.prolly_normal_d
2197 - ((v41->pFacePlane.dist
2198 + v41->pFacePlane.vNormal.x * v0->vPosition.x
2199 + v41->pFacePlane.vNormal.y * v0->vPosition.y
2200 + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16);
2201 if ( v46 > 0 )
2202 {
2203 v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16;
2204 v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16;
2205 v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16);
2206 }
2207 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
2208 }
2209 }
2210 }
2211 break;
2212 }
2213 v70 = v0->vVelocity.x;
2214 v71 = 58500;
2215 v70 = (unsigned __int64)(58500i64 * (signed int)v70) >> 16;
2216 v0->vVelocity.x = v70;
2217 v70 = v0->vVelocity.y;
2218 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
2219 v71 = 58500;
2220 v0->vVelocity.y = v70;
2221 v70 = v0->vVelocity.z;
2222 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
2223 ++v69;
2224 v54 = __OFSUB__(v69, 100);
2225 v10 = ((v69 - 100) & 0x80000000u) != 0;
2226 v0->vVelocity.z = v70;
2227 if ( !(v10 ^ v54) )
2228 break;
2229 v26 = stru_721530.prolly_normal_d;
2230 }
2231 v69 = WorldPosToGridCellX(v66);
2232 v55 = WorldPosToGridCellZ(v65);
2233 v56 = v55 - 1;
2234 v57 = v0->vPosition.x;
2235 v71 = v55 - 1;
2236 v68 = WorldPosToGridCellX(v57);
2237 v70 = WorldPosToGridCellZ(v0->vPosition.y) - 1;
2238 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v69, v56) >> 1) & 1;
2239 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v68, v70) >> 1) & 1;
2240 v60 = 0;
2241 if ( v69 == v68 && v71 == v70 && v58 )
2242 v60 = 1;
2243 if ( !v67 )
2244 v60 = 1;
2245 if ( !v60 )
2246 {
2247 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
2248 {
2249 v58 = v58 == 0;
2250 v59 = v59 == 0;
2251 }
2252 if ( !v74 && v58 && !v59 )
2253 {
2254 v0->vPosition.x = v66;
2255 v0->vPosition.y = v65;
2256 if ( v0->CanAct() )
2257 {
2258 v0->uYawAngle -= 32;
2259 v0->uCurrentActionTime = 0;
2260 v0->uCurrentActionLength = 128;
2261 v0->uAIState = 7;
2262 }
2263 }
2264 }
2265 LABEL_121:
2266 ++v75;
2267 }
2268 while ( (signed int)v75 < (signed int)uNumActors );
2269 }
2270 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
2271 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
2272 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
2273 // 4F75D8: using guessed type int ai_arrays_size;
2274
2275
2276
2277 //----- (0047136C) --------------------------------------------------------
2278 void LayingItem::UpdateObject_fn0_BLV(unsigned int uLayingItemID)
2279 {
2280 LayingItem *v1; // esi@1
2281 ObjectDesc *v2; // edi@1
2282 int v3; // ST08_4@1
2283 __int16 v4; // ax@5
2284 __int16 v5; // ax@7
2285 BLVFace *v6; // ecx@11
2286 BLVFace *v7; // eax@11
2287 signed int v8; // ebx@12
2288 int v9; // ecx@16
2289 __int16 v10; // di@18
2290 char v11; // al@19
2291 int v12; // eax@25
2292 int v13; // eax@31
2293 int v14; // ebx@34
2294 signed int v15; // ebx@46
2295 BLVFace *v16; // edi@48
2296 int v17; // eax@50
2297 int v18; // eax@52
2298 int v19; // ecx@52
2299 Vec3_short_ *v20; // ecx@53
2300 int v21; // ecx@57
2301 __int16 v22; // ax@57
2302 int v23; // edi@62
2303 int v24; // edi@62
2304 int v25; // eax@62
2305 unsigned __int64 v26; // qax@62
2306 unsigned __int8 v27; // sf@64
2307 unsigned __int8 v28; // of@64
2308 __int16 v29; // di@67
2309 char v30; // al@68
2310 const char *v31; // [sp-8h] [bp-98h]@19
2311 const char *v32; // [sp-8h] [bp-98h]@68
2312 enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19
2313 enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68
2314 Particle_ Dst; // [sp+Ch] [bp-84h]@18
2315 unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
2316 ObjectDesc *v37; // [sp+78h] [bp-18h]@1
2317 int v38; // [sp+7Ch] [bp-14h]@4
2318 int v39; // [sp+80h] [bp-10h]@33
2319 int v40; // [sp+84h] [bp-Ch]@28
2320 int v41; // [sp+88h] [bp-8h]@34
2321 int v42; // [sp+8Ch] [bp-4h]@4
2322
2323 uLayingItemID_ = uLayingItemID;
2324 v1 = &pLayingItems[uLayingItemID];
2325 v2 = &pObjectList->pObjects[v1->uObjectDescID];
2326 v3 = v1->vPosition.x;
2327 v37 = &pObjectList->pObjects[v1->uObjectDescID];
2328 if ( abs(v3) > 32767
2329 || abs(v1->vPosition.y) > 32767
2330 || abs(v1->vPosition.z) > 20000
2331 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &v38),
2332 v42 <= -30000)
2333 && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z),
2334 (v1->uSectorID = v4) == 0)
2335 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &v38), v42 == -30000)) )
2336 {
2337 LayingItem::_42F933(uLayingItemID_);
2338 return;
2339 }
2340 v5 = v2->uFlags;
2341 if ( v5 & 0x20 )
2342 {
2343 LABEL_24:
2344 v8 = 0;
2345 LABEL_25:
2346 stru_721530.field_0 = v8;
2347 v38 = v8;
2348 stru_721530.prolly_normal_d = v2->uRadius;
2349 v12 = v2->uHeight;
2350 stru_721530.field_84 = -1;
2351 stru_721530.field_C = v12;
2352 stru_721530.field_8 = v8;
2353 stru_721530.field_70 = v8;
2354 while ( 1 )
2355 {
2356 stru_721530.field_34.x = v1->vPosition.x;
2357 stru_721530.normal.x = stru_721530.field_34.x;
2358 stru_721530.field_34.y = v1->vPosition.y;
2359 stru_721530.normal.y = stru_721530.field_34.y;
2360 stru_721530.field_34.z = stru_721530.prolly_normal_d + v1->vPosition.z + 1;
2361 stru_721530.normal.z = stru_721530.field_34.z;
2362 stru_721530.field_1C = v1->vVelocity.x;
2363 stru_721530.field_20 = v1->vVelocity.y;
2364 stru_721530.field_24 = v1->vVelocity.z;
2365 stru_721530.uSectorID = v1->uSectorID;
2366 if ( stru_721530._47050A(v8) )
2367 return;
2368 v40 = v8;
2369 do
2370 {
2371 _46E44E_collide_against_faces_and_portals(0);
2372 _46E0B2_collide_against_decorations();
2373 if ( (v1->field_58 & 7) != 4 )
2374 _46EF01_collision_chech_player(1);
2375 v13 = v1->field_58;
2376 v42 = v8;
2377 if ( (v13 & 7) == 3 )
2378 {
2379 if ( (signed int)uNumActors > v8 )
2380 {
2381 v39 = (int)&pActors[0].word_000086_some_monster_id;
2382 do
2383 {
2384 v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
2385 v14 = (signed __int64)((double)v41 * 0.3333333333333333);
2386 v41 = *(short *)(v39 - 38) - 1;
2387 if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
2388 _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
2389 ++v42;
2390 v39 += 836;
2391 }
2392 while ( v42 < (signed int)uNumActors );
2393 v8 = 0;
2394 }
2395 }
2396 else
2397 {
2398 if ( (signed int)uNumActors > v8 )
2399 {
2400 v39 = (int)&pActors[0].word_000086_some_monster_id;
2401 do
2402 {
2403 _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
2404 v39 += 836;
2405 }
2406 while ( v42 < (signed int)uNumActors );
2407 }
2408 }
2409 if ( _46F04E_collide_against_portals() )
2410 break;
2411 ++v40;
2412 }
2413 while ( v40 < 100 );
2414 if ( stru_721530.field_7C >= stru_721530.field_6C )
2415 {
2416 v1->vPosition.x = stru_721530.normal2.x;
2417 v1->vPosition.y = stru_721530.normal2.y;
2418 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2419 v1->uSectorID = LOWORD(stru_721530.uSectorID);
2420 if ( !(HIBYTE(v2->uFlags) & 1) )
2421 return;
2422 memset(&Dst, v8, 0x68u);
2423 v29 = v2->uFlags;
2424 Dst.x = (double)v1->vPosition.x;
2425 Dst.y = (double)v1->vPosition.y;
2426 Dst.z = (double)v1->vPosition.z;
2427 Dst.flt_10 = 0.0;
2428 Dst.flt_14 = 0.0;
2429 Dst.flt_18 = 0.0;
2430 if ( v29 & 0x200 )
2431 {
2432 Dst.bFree = 1036;
2433 Dst.uDiffuse = 0xFF3C1Eu;
2434 v30 = rand();
2435 v34 = (TEXTURE_TYPE)v8;
2436 v32 = "effpar01";
2437 }
2438 else
2439 {
2440 if ( v29 & 0x400 )
2441 goto LABEL_70;
2442 Dst.bFree = 1032;
2443 Dst.uDiffuse = rand();
2444 v30 = rand();
2445 v34 = (TEXTURE_TYPE)v8;
2446 v32 = "effpar03";
2447 }
2448 Dst.field_20 = (unsigned __int8)(v30 & 0x80) + 128;
2449 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
2450 goto LABEL_71;
2451 }
2452 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2453 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2454 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2455 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2456 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2457 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2458 v1->uSectorID = LOWORD(stru_721530.uSectorID);
2459 stru_721530.field_70 += stru_721530.field_7C;
2460 if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
2461 return;
2462 v15 = (signed int)stru_721530.uFaceID >> 3;
2463 if ( (stru_721530.uFaceID & 7) == 5 )
2464 {
2465 v40 = sub_452A9E(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y);
2466 v23 = stru_5C6E00->Atan2(
2467 v1->vPosition.x - pLevelDecorations[v15].vPosition.x,
2468 v1->vPosition.y - pLevelDecorations[v15].vPosition.y);
2469 v42 = stru_5C6E00->SinCos(v23);
2470 v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
2471 v24 = v23 - stru_5C6E00->uIntegerHalfPi;
2472 v1->vVelocity.x = (unsigned int)(v42 * v40) >> 16;
2473 v25 = stru_5C6E00->SinCos(v24);
2474 v42 = v25;
2475 v26 = v25 * (signed __int64)v40;
2476 v41 = v26 >> 16;
2477 v1->vVelocity.y = WORD1(v26);
2478 }
2479 else
2480 {
2481 if ( (stru_721530.uFaceID & 7) != 6 )
2482 goto LABEL_64;
2483 stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3;
2484 v16 = &pIndoor->pFaces[v15];
2485 if ( v16->uPolygonType != 3 )
2486 {
2487 v42 = abs(v16->pFacePlane_old.vNormal.x * v1->vVelocity.x + v16->pFacePlane_old.vNormal.z * v1->vVelocity.z
2488 + v16->pFacePlane_old.vNormal.y * v1->vVelocity.y) >> 16;
2489 if ( stru_721530.field_64 >> 3 > v42 )
2490 v42 = stru_721530.field_64 >> 3;
2491 v40 = v16->pFacePlane_old.vNormal.x;
2492 v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
2493 v41 = v16->pFacePlane_old.vNormal.y;
2494 v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16;
2495 v39 = v16->pFacePlane_old.vNormal.z;
2496 v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16;
2497 v1->vVelocity.x += 2 * v40;
2498 v1->vVelocity.y += 2 * v41;
2499 if ( v16->pFacePlane_old.vNormal.z <= 32000 )
2500 {
2501 v22 = 2 * v39;
2502 }
2503 else
2504 {
2505 v21 = v39;
2506 v40 = 32000;
2507 v1->vVelocity.z += v39;
2508 v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16;
2509 v22 = (unsigned int)(v40 * v21) >> 16;
2510 }
2511 v1->vVelocity.z += v22;
2512 goto LABEL_60;
2513 }
2514 if ( v37->uFlags & 0x80 )
2515 {
2516 v17 = -v1->vVelocity.z >> 1;
2517 v1->vVelocity.z = v17;
2518 if ( (signed __int16)v17 < 10 )
2519 v1->vVelocity.z = 0;
2520 LABEL_60:
2521 if ( BYTE3(v16->uAttributes) & 0x10 )
2522 EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
2523 goto LABEL_63;
2524 }
2525 v18 = v1->vVelocity.y;
2526 v19 = v1->vVelocity.x;
2527 v1->vVelocity.z = 0;
2528 if ( v19 * v19 + v18 * v18 >= 400 )
2529 goto LABEL_60;
2530 v20 = pIndoor->pVertices;
2531 v1->vVelocity.z = 0;
2532 v1->vVelocity.y = 0;
2533 v1->vVelocity.x = 0;
2534 v1->vPosition.z = v20[*v16->pVertexIDs].z + 1;
2535 }
2536 LABEL_63:
2537 v2 = v37;
2538 LABEL_64:
2539 v41 = v1->vVelocity.x;
2540 v40 = 58500;
2541 v41 = (unsigned __int64)(58500i64 * v41) >> 16;
2542 v1->vVelocity.x = v41;
2543 v41 = v1->vVelocity.y;
2544 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
2545 v40 = 58500;
2546 v1->vVelocity.y = v41;
2547 v41 = v1->vVelocity.z;
2548 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
2549 ++v38;
2550 v28 = __OFSUB__(v38, 100);
2551 v27 = v38 - 100 < 0;
2552 v1->vVelocity.z = v41;
2553 if ( !(v27 ^ v28) )
2554 return;
2555 v8 = 0;
2556 }
2557 }
2558 if ( v42 <= v1->vPosition.z - 3 )
2559 {
2560 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
2561 goto LABEL_24;
2562 }
2563 if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID_, 0) )
2564 {
2565 v6 = pIndoor->pFaces;
2566 v1->vPosition.z = v42 + 1;
2567 v7 = &v6[v38];
2568 if ( v7->uPolygonType == 3 )
2569 {
2570 v8 = 0;
2571 v1->vVelocity.z = 0;
2572 }
2573 else
2574 {
2575 if ( v7->pFacePlane_old.vNormal.z < 45000 )
2576 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
2577 v8 = 0;
2578 }
2579 v42 = v1->vVelocity.x;
2580 v38 = 58500;
2581 v42 = (unsigned __int64)(58500i64 * v42) >> 16;
2582 v1->vVelocity.x = v42;
2583 v42 = v1->vVelocity.y;
2584 v42 = (unsigned __int64)(v38 * (signed __int64)v42) >> 16;
2585 v38 = 58500;
2586 v1->vVelocity.y = v42;
2587 v42 = v1->vVelocity.z;
2588 v42 = (unsigned __int64)(v38 * (signed __int64)v42) >> 16;
2589 v9 = v1->vVelocity.x;
2590 v1->vVelocity.z = v42;
2591 if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 )
2592 {
2593 v1->vVelocity.z = v8;
2594 v1->vVelocity.y = v8;
2595 v1->vVelocity.x = v8;
2596 if ( !(HIBYTE(v2->uFlags) & 1) )
2597 return;
2598 memset(&Dst, v8, 0x68u);
2599 v10 = v2->uFlags;
2600 Dst.x = (double)v1->vPosition.x;
2601 Dst.y = (double)v1->vPosition.y;
2602 Dst.z = (double)v1->vPosition.z;
2603 Dst.flt_10 = 0.0;
2604 Dst.flt_14 = 0.0;
2605 Dst.flt_18 = 0.0;
2606 if ( v10 & 0x200 )
2607 {
2608 Dst.bFree = 1036;
2609 Dst.uDiffuse = 0xFF3C1Eu;
2610 Dst.flt_28 = 1.0;
2611 v11 = rand();
2612 v33 = (TEXTURE_TYPE)v8;
2613 v31 = "effpar01";
2614 }
2615 else
2616 {
2617 if ( v10 & 0x400 )
2618 {
2619 LABEL_70:
2620 Dst.bFree = 512;
2621 Dst.uDiffuse = rand();
2622 Dst.field_20 = 64;
2623 Dst.uTextureID = v8;
2624 LABEL_71:
2625 Dst.flt_28 = 1.0;
2626 goto LABEL_72;
2627 }
2628 Dst.bFree = 1032;
2629 Dst.uDiffuse = rand();
2630 Dst.flt_28 = 1.0;
2631 v11 = rand();
2632 v33 = (TEXTURE_TYPE)v8;
2633 v31 = "effpar03";
2634 }
2635 Dst.field_20 = (unsigned __int8)(v11 & 0x80) + 128;
2636 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
2637 LABEL_72:
2638 pGame->pParticleEngine->AddParticle(&Dst);
2639 return;
2640 }
2641 goto LABEL_25;
2642 }
2643 }
2644 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
2645
2646 //----- (00471C03) --------------------------------------------------------
2647 void LayingItem::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
2648 {
2649 LayingItem *v1; // esi@1
2650 ObjectDesc *v2; // ebx@1
2651 signed int v3; // edx@1
2652 int v4; // ecx@1
2653 int v5; // ST04_4@1
2654 int v6; // eax@1
2655 int v7; // ecx@1
2656 int v8; // edi@1
2657 int v9; // eax@4
2658 __int16 v10; // ax@7
2659 int v11; // edx@11
2660 int v12; // ecx@11
2661 signed int v13; // edx@14
2662 signed int v14; // edx@16
2663 int v15; // eax@24
2664 int v16; // eax@25
2665 int v17; // ST10_4@25
2666 signed int v18; // eax@25
2667 signed int v19; // eax@28
2668 Actor *v20; // edi@31
2669 int v21; // eax@41
2670 int v22; // ecx@43
2671 __int16 v23; // bx@45
2672 char v24; // al@46
2673 signed int i; // edi@50
2674 int v26; // edi@52
2675 int v27; // eax@52
2676 __int16 v28; // cx@55
2677 int v29; // eax@55
2678 signed int v30; // edi@59
2679 BSPModel *v31; // ecx@61
2680 ODMFace *v32; // edi@61
2681 int v33; // eax@62
2682 int v34; // ecx@62
2683 int v35; // eax@63
2684 Actor *v36; // ecx@67
2685 __int16 v37; // ax@67
2686 int v38; // eax@72
2687 int v39; // eax@72
2688 unsigned __int64 v40; // qax@72
2689 int v41; // eax@72
2690 unsigned __int8 v42; // sf@74
2691 unsigned __int8 v43; // of@74
2692 int v44; // eax@77
2693 __int16 v45; // bx@81
2694 int v46; // eax@85
2695 const char *v47; // [sp-8h] [bp-B0h]@83
2696 enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46
2697 int v49; // [sp+Ch] [bp-9Ch]@52
2698 int v50; // [sp+10h] [bp-98h]@52
2699 Vec3_int_ v51; // [sp+14h] [bp-94h]@11
2700 Particle_ Dst; // [sp+20h] [bp-88h]@45
2701 unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1
2702 int v54; // [sp+8Ch] [bp-1Ch]@1
2703 int v55; // [sp+90h] [bp-18h]@1
2704 int v56; // [sp+94h] [bp-14h]@11
2705 int v57; // [sp+98h] [bp-10h]@1
2706 int v58; // [sp+9Ch] [bp-Ch]@1
2707 int v59; // [sp+A0h] [bp-8h]@1
2708 Actor *v60; // [sp+A4h] [bp-4h]@11
2709
2710 uLayingItemID_ = uLayingItemID;
2711 v1 = &pLayingItems[uLayingItemID];
2712 v58 = 0;
2713 v2 = &pObjectList->pObjects[v1->uObjectDescID];
2714 v57 = GetTerrainHeightsAroundParty(v1->vPosition.x, v1->vPosition.y);
2715 v3 = v1->vPosition.y;
2716 v4 = v1->vPosition.x;
2717 v5 = v2->uHeight;
2718 v55 = 0;
2719 v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0);
2720 v7 = v6;
2721 v54 = v6;
2722 v8 = v6 + 1;
2723 if ( v1->vPosition.z <= v6 + 1 )
2724 {
2725 if ( v59 )
2726 {
2727 v9 = v6 + 60;
2728 if ( v55 )
2729 v9 = v7 + 30;
2730 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9);
2731 LayingItem::_42F933(uLayingItemID_);
2732 v7 = v54;
2733 }
2734 }
2735 else
2736 {
2737 v58 = 1;
2738 }
2739 v10 = v2->uFlags;
2740 if ( !(v10 & 0x20) )
2741 {
2742 if ( v58 )
2743 {
2744 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
2745 goto LABEL_13;
2746 }
2747 if ( v57 )
2748 {
2749 v11 = v1->vPosition.y;
2750 v12 = v1->vPosition.x;
2751 v1->vPosition.z = v8;
2752 _46DCC8_get_gravity_direction_outdoor(v12, v11, &v51);
2753 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
2754 v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16;
2755 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
2756 v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16;
2757 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
2758 v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16;
2759 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
2760 v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16;
2761 LABEL_12:
2762 v7 = v54;
2763 goto LABEL_13;
2764 }
2765 if ( v10 & 0x40 )
2766 {
2767 if ( v1->vPosition.z < v7 )
2768 v1->vPosition.z = v8;
2769 if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) )
2770 return;
2771 }
2772 v1->vPosition.z = v8;
2773 if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) )
2774 v1->vVelocity.z = 0;
2775 v60 = (Actor *)v1->vVelocity.x;
2776 v55 = 58500;
2777 v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16);
2778 v1->vVelocity.x = (signed __int16)v60;
2779 v60 = (Actor *)v1->vVelocity.y;
2780 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
2781 v55 = 58500;
2782 v1->vVelocity.y = (signed __int16)v60;
2783 v60 = (Actor *)v1->vVelocity.z;
2784 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
2785 v22 = v1->vVelocity.x;
2786 v1->vVelocity.z = (signed __int16)v60;
2787 if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 )
2788 goto LABEL_12;
2789 v1->vVelocity.y = 0;
2790 v1->vVelocity.x = 0;
2791 if ( !(HIBYTE(v2->uFlags) & 1) )
2792 return;
2793 memset(&Dst, 0, 0x68u);
2794 v23 = v2->uFlags;
2795 Dst.x = (double)v1->vPosition.x;
2796 Dst.y = (double)v1->vPosition.y;
2797 Dst.z = (double)v1->vPosition.z;
2798 Dst.flt_10 = 0.0;
2799 Dst.flt_14 = 0.0;
2800 Dst.flt_18 = 0.0;
2801 if ( HIBYTE(v23) & 2 )
2802 {
2803 Dst.bFree = 1036;
2804 Dst.uDiffuse = 16727070;
2805 v24 = rand();
2806 v48 = (TEXTURE_TYPE)0;
2807 LABEL_83:
2808 v47 = "effpar01";
2809 }
2810 else
2811 {
2812 if ( HIBYTE(v23) & 4 )
2813 {
2814 Dst.bFree = 512;
2815 Dst.uDiffuse = rand();
2816 Dst.field_20 = 64;
2817 Dst.uTextureID = 0;
2818 LABEL_89:
2819 Dst.flt_28 = 1.0;
2820 pGame->pParticleEngine->AddParticle(&Dst);
2821 return;
2822 }
2823 Dst.bFree = 1032;
2824 Dst.uDiffuse = rand();
2825 v24 = rand();
2826 v48 = (TEXTURE_TYPE)0;
2827 LABEL_87:
2828 v47 = "effpar03";
2829 }
2830 Dst.field_20 = (unsigned __int8)(v24 & 0x80) + 128;
2831 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48);
2832 goto LABEL_89;
2833 }
2834 LABEL_13:
2835 if ( v1->vPosition.z > v7
2836 && (v13 = v1->vPosition.x, v13 >= -32768)
2837 && v13 <= 32768
2838 && (v14 = v1->vPosition.y, v14 >= -32768)
2839 && v14 <= 32768
2840 && v1->vPosition.z <= 13000
2841 || !(v2->uFlags & 0x40) )
2842 goto LABEL_92;
2843 if ( v1->vPosition.z < v7 )
2844 v1->vPosition.z = v8;
2845 if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) )
2846 {
2847 LABEL_92:
2848 stru_721530.field_0 = 0;
2849 v55 = 0;
2850 stru_721530.prolly_normal_d = v2->uRadius;
2851 stru_721530.field_C = v2->uHeight;
2852 stru_721530.field_8 = 0;
2853 stru_721530.field_70 = 0;
2854 while ( 1 )
2855 {
2856 stru_721530.field_34.x = v1->vPosition.x;
2857 stru_721530.normal.x = stru_721530.field_34.x;
2858 v15 = v1->vPosition.y;
2859 stru_721530.uSectorID = 0;
2860 stru_721530.field_34.y = v15;
2861 stru_721530.normal.y = v15;
2862 stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1;
2863 stru_721530.normal.z = stru_721530.field_34.z;
2864 stru_721530.field_1C = v1->vVelocity.x;
2865 stru_721530.field_20 = v1->vVelocity.y;
2866 stru_721530.field_24 = v1->vVelocity.z;
2867 if ( stru_721530._47050A(0) )
2868 return;
2869 _46E889_collide_against_bmodels(0);
2870 v16 = WorldPosToGridCellZ(v1->vPosition.y);
2871 v17 = v1->vPosition.x;
2872 v58 = v16;
2873 v18 = WorldPosToGridCellX(v17);
2874 _46E26D_collide_against_sprites(v18, v58);
2875 if ( (v1->field_58 & 7) != 4 )
2876 _46EF01_collision_chech_player(0);
2877 if ( (v1->field_58 & 7) == 3 )
2878 {
2879 v19 = v1->field_58 >> 3;
2880 if ( v19 >= 0 )
2881 {
2882 if ( v19 < (signed int)(uNumActors - 1) )
2883 {
2884 v56 = 0;
2885 if ( (signed int)uNumActors > 0 )
2886 {
2887 v60 = pActors;
2888 v20 = &pActors[v19];
2889 do
2890 {
2891 if ( v20->GetActorsRelation(v60) )
2892 _46DF1A_collide_against_actor(v56, 0);
2893 ++v56;
2894 ++v60;
2895 }
2896 while ( v56 < (signed int)uNumActors );
2897 }
2898 }
2899 }
2900 }
2901 else
2902 {
2903 for ( i = 0; i < (signed int)uNumActors; ++i )
2904 _46DF1A_collide_against_actor(i, 0);
2905 }
2906 v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2907 v27 = sub_46D49E_prolly_get_world_y_under_party(
2908 stru_721530.normal2.x,
2909 stru_721530.normal2.y,
2910 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
2911 v2->uHeight,
2912 &v49,
2913 &v50,
2914 0);
2915 if ( v59 && v26 < v27 + 60 )
2916 {
2917 if ( v50 )
2918 v44 = v27 + 30;
2919 else
2920 v44 = v54 + 60;
2921 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44);
2922 LayingItem::_42F933(uLayingItemID_);
2923 return;
2924 }
2925 if ( stru_721530.field_7C >= stru_721530.field_6C )
2926 {
2927 v1->vPosition.x = stru_721530.normal2.x;
2928 v1->vPosition.y = stru_721530.normal2.y;
2929 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2930 v1->uSectorID = LOWORD(stru_721530.uSectorID);
2931 if ( !(HIBYTE(v2->uFlags) & 1) )
2932 return;
2933 memset(&Dst, 0, 0x68u);
2934 v45 = v2->uFlags;
2935 Dst.x = (double)v1->vPosition.x;
2936 Dst.y = (double)v1->vPosition.y;
2937 Dst.z = (double)v1->vPosition.z;
2938 Dst.flt_10 = 0.0;
2939 Dst.flt_14 = 0.0;
2940 Dst.flt_18 = 0.0;
2941 if ( HIBYTE(v45) & 2 )
2942 {
2943 Dst.bFree = 1036;
2944 Dst.uDiffuse = 16727070;
2945 v24 = rand();
2946 v48 = (TEXTURE_TYPE)0;
2947 goto LABEL_83;
2948 }
2949 if ( HIBYTE(v45) & 4 )
2950 {
2951 Dst.bFree = 512;
2952 v46 = rand();
2953 Dst.uTextureID = 0;
2954 Dst.uDiffuse = v46;
2955 Dst.field_20 = 64;
2956 goto LABEL_89;
2957 }
2958 Dst.bFree = 1032;
2959 Dst.uDiffuse = rand();
2960 v24 = rand();
2961 v48 = (TEXTURE_TYPE)0;
2962 goto LABEL_87;
2963 }
2964 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
2965 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2966 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
2967 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2968 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
2969 v28 = LOWORD(stru_721530.uSectorID);
2970 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2971 v29 = v1->vPosition.z;
2972 v1->uSectorID = v28;
2973 stru_721530.field_70 += stru_721530.field_7C;
2974 if ( v2->uFlags & 0x40 )
2975 {
2976 if ( v29 < v54 )
2977 v1->vPosition.z = v54 + 1;
2978 if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
2979 return;
2980 }
2981 v30 = (signed int)stru_721530.uFaceID >> 3;
2982 if ( (stru_721530.uFaceID & 7) == 5 )
2983 break;
2984 if ( (stru_721530.uFaceID & 7) == 6 )
2985 {
2986 v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
2987 v32 = &v31->pFaces[v30 & 0x3F];
2988 if ( v32->uPolygonType != 3 )
2989 {
2990 v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y
2991 + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16;
2992 if ( stru_721530.field_64 >> 3 > v56 )
2993 v56 = stru_721530.field_64 >> 3;
2994 v57 = v32->pFacePlane.vNormal.x;
2995 v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
2996 v58 = v32->pFacePlane.vNormal.y;
2997 v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
2998 v60 = (Actor *)v32->pFacePlane.vNormal.z;
2999 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16);
3000 v1->vVelocity.x += 2 * v57;
3001 v1->vVelocity.y += 2 * v58;
3002 if ( v32->pFacePlane.vNormal.z <= 32000 )
3003 {
3004 v37 = 2 * (short)v60;
3005 }
3006 else
3007 {
3008 v36 = v60;
3009 v57 = 32000;
3010 v1->vVelocity.z += (signed __int16)v60;
3011 v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16;
3012 v37 = (unsigned int)(v57 * (int)v36) >> 16;
3013 }
3014 v1->vVelocity.z += v37;
3015 LABEL_70:
3016 if ( BYTE3(v32->uFaceAttributes) & 0x10 )
3017 EventProcessor(v32->sCogTriggeredID, 0, 1);
3018 goto LABEL_74;
3019 }
3020 v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z;
3021 v34 = v1->vVelocity.x;
3022 v1->vPosition.z = v33 + 1;
3023 if ( v1->vVelocity.y * v1->vVelocity.y + v34 * v34 >= 400 )
3024 goto LABEL_70;
3025 LOWORD(v35) = 0;
3026 v1->vVelocity.z = 0;
3027 v1->vVelocity.x = 0;
3028 goto LABEL_73;
3029 }
3030 LABEL_74:
3031 v58 = v1->vVelocity.x;
3032 v57 = 58500;
3033 v58 = (unsigned __int64)(58500i64 * v58) >> 16;
3034 v1->vVelocity.x = v58;
3035 v58 = v1->vVelocity.y;
3036 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
3037 v57 = 58500;
3038 v1->vVelocity.y = v58;
3039 v58 = v1->vVelocity.z;
3040 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
3041 ++v55;
3042 v43 = __OFSUB__(v55, 100);
3043 v42 = v55 - 100 < 0;
3044 v1->vVelocity.z = v58;
3045 if ( !(v42 ^ v43) )
3046 return;
3047 }
3048 v57 = sub_452A9E(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x);
3049 v38 = stru_5C6E00->Atan2(
3050 v1->vPosition.x - pLevelDecorations[v30].vPosition.x,
3051 v1->vPosition.y - pLevelDecorations[v30].vPosition.y);
3052 v56 = v38;
3053 v39 = stru_5C6E00->SinCos(v38);
3054 v60 = (Actor *)v39;
3055 v40 = v39 * (signed __int64)v57;
3056 v58 = v40 >> 16;
3057 v1->vVelocity.x = WORD1(v40);
3058 v41 = stru_5C6E00->SinCos(v56 - stru_5C6E00->uIntegerHalfPi);
3059 v60 = (Actor *)v41;
3060 v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16;
3061 v58 = v35;
3062 LABEL_73:
3063 v1->vVelocity.y = v35;
3064 goto LABEL_74;
3065 }
3066 }
3067 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
3068 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
3069 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
3070
3071
3072
3073
3074 //----- (0047253E) --------------------------------------------------------
3075 void __cdecl UpdateObjects()
3076 {
3077 unsigned int v0; // ebx@0
3078 unsigned int v1; // edi@1
3079 char *v2; // esi@2
3080 __int16 v3; // dx@5
3081 ObjectDesc *v4; // eax@5
3082 int v5; // ecx@6
3083 __int16 v6; // cx@7
3084 signed int v7; // eax@9
3085 __int16 v8; // cx@14
3086 __int16 v9; // dx@14
3087 unsigned int v10; // ecx@16
3088 signed int v11; // eax@17
3089 int v12; // edi@27
3090 int v13; // eax@27
3091 int v14; // ebx@27
3092 unsigned int v15; // ecx@27
3093 unsigned int v16; // edx@30
3094 unsigned int v17; // edx@32
3095 int v18; // [sp+4h] [bp-10h]@27
3096 int v19; // [sp+8h] [bp-Ch]@27
3097 signed int v20; // [sp+10h] [bp-4h]@1
3098
3099 v1 = 0;
3100 v20 = 0;
3101 if ( (signed int)uNumLayingItems > 0 )
3102 {
3103 v2 = (char *)&pLayingItems[0].uSpriteFrameID;
3104 do
3105 {
3106 LOWORD(v0) = *((short *)v2 - 2);
3107 if ( v0 & 0x40 )
3108 {
3109 v0 &= 0xFFFFFFBFu;
3110 *((short *)v2 - 2) = v0;
3111 }
3112 else
3113 {
3114 v3 = *((short *)v2 - 14);
3115 v4 = &pObjectList->pObjects[*((short *)v2 - 14)];
3116 if ( (v0 & 0x80u) != 0 )
3117 {
3118 v5 = *(int *)(v2 + 62) >> 3;
3119 *(int *)(v2 - 26) = pActors[v5].vPosition.x;
3120 *(int *)(v2 - 22) = pActors[v5].vPosition.y;
3121 *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
3122 if ( !v3 || (v6 = LOWORD(pEventTimer->uTimeElapsed) + *(short *)v2, *(short *)v2 = v6, !(v4->uFlags & 4)) )
3123 goto LABEL_36;
3124 if ( v6 >= 0 )
3125 {
3126 v7 = v4->uLifetime;
3127 if ( v0 & 2 )
3128 v7 = *((short *)v2 + 1);
3129 if ( v6 < v7 )
3130 goto LABEL_36;
3131 }
3132 goto LABEL_34;
3133 }
3134 if ( v3 )
3135 {
3136 v8 = LOWORD(pEventTimer->uTimeElapsed) + *(short *)v2;
3137 *(short *)v2 = v8;
3138 v9 = v4->uFlags;
3139 if ( !(v9 & 4) )
3140 goto LABEL_22;
3141 if ( v8 < 0 )
3142 {
3143 v10 = v1;
3144 LABEL_35:
3145 LayingItem::_42F933(v10);
3146 goto LABEL_36;
3147 }
3148 v11 = v4->uLifetime;
3149 if ( v0 & 2 )
3150 v11 = *((short *)v2 + 1);
3151 if ( v8 < v11 )
3152 {
3153 LABEL_22:
3154 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
3155 LayingItem::UpdateObject_fn0_BLV(v1);
3156 else
3157 LayingItem::UpdateObject_fn0_ODM(v1);
3158 if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
3159 goto LABEL_36;
3160 v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
3161 v18 = abs(pParty->vPosition.z - *(int *)(v2 - 22));
3162 v19 = abs(pParty->vPosition.y - *(int *)(v2 - 18));
3163 v13 = v12;
3164 v14 = v18;
3165 v15 = v19;
3166 if ( v12 < v18 )
3167 {
3168 v13 = v18;
3169 v14 = v12;
3170 }
3171 if ( v13 < v19 )
3172 {
3173 v16 = v13;
3174 v13 = v19;
3175 v15 = v16;
3176 }
3177 if ( v14 < (signed int)v15 )
3178 {
3179 v17 = v15;
3180 v15 = v14;
3181 v14 = v17;
3182 }
3183 v0 = (unsigned int)(11 * v14) >> 5;
3184 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
3185 goto LABEL_36;
3186 LABEL_34:
3187 v10 = v20;
3188 goto LABEL_35;
3189 }
3190 v10 = v1;
3191 if ( !(v9 & 0x40) )
3192 goto LABEL_35;
3193 _46BFFA_check_object_intercept(v1, 8 * v1 | OBJECT_Item);
3194 }
3195 }
3196 LABEL_36:
3197 v2 += 112;
3198 v1 = v20++ + 1;
3199 }
3200 while ( v20 < (signed int)uNumLayingItems );
3201 }
3202 }
3203
3204 //----- (0047272C) --------------------------------------------------------
3205 int __fastcall _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, int *a5)
3206 {
3207 signed int v5; // ebx@1
3208 int result; // eax@1
3209 int v7; // [sp+10h] [bp-8h]@1
3210 signed int v8; // [sp+14h] [bp-4h]@1
3211
3212 v5 = x - 2;
3213 v7 = x;
3214 v8 = y;
3215 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
3216 result = _46ED1B_collide_against_floor(v5, v8, z + 40, pSectorID, a5);
3217 if ( result == -30000 || !*pSectorID )
3218 {
3219 *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40);
3220 result = _46ED1B_collide_against_floor(v7 + 2, v8, z + 40, pSectorID, a5);
3221 if ( result == -30000 || !*pSectorID )
3222 {
3223 *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40);
3224 result = _46ED1B_collide_against_floor(v7, v8 - 2, z + 40, pSectorID, a5);
3225 if ( result == -30000 || !*pSectorID )
3226 {
3227 *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40);
3228 result = _46ED1B_collide_against_floor(v7, v8 + 2, z + 40, pSectorID, a5);
3229 if ( result == -30000 || !*pSectorID )
3230 {
3231 *pSectorID = pIndoor->GetSector(v7, v8, z + 140);
3232 result = _46ED1B_collide_against_floor(v7, v8, z + 140, pSectorID, a5);
3233 }
3234 }
3235 }
3236 }
3237 return result;
3238 }
3239
3240 //----- (00472866) --------------------------------------------------------
3241 void __cdecl BLV_ProcessPartyActions()
3242 {
3243 int v0; // esi@1
3244 int v1; // ebx@1
3245 int v2; // edi@1
3246 int v3; // esi@1
3247 float v4; // ST40_4@8
3248 Player **v5; // esi@15
3249 int v6; // eax@18
3250 Player **v7; // esi@24
3251 signed __int64 v8; // qax@27
3252 int v9; // eax@27
3253 double v10; // st7@27
3254 BLVFace *v11; // edx@41
3255 unsigned int v12; // eax@49
3256 double v13; // st7@50
3257 int v14; // eax@51
3258 signed __int64 v15; // qax@53
3259 double v16; // st7@54
3260 int v17; // eax@62
3261 double v18; // st7@62
3262 int v19; // ST40_4@62
3263 int v20; // eax@65
3264 double v21; // st7@65
3265 int v22; // ST40_4@65
3266 int v23; // eax@66
3267 double v24; // st7@66
3268 int v25; // ST40_4@66
3269 int v26; // eax@67
3270 double v27; // st7@67
3271 int v28; // ST40_4@67
3272 int v29; // eax@69
3273 double v30; // st7@69
3274 int v31; // ST3C_4@69
3275 int v32; // eax@71
3276 double v33; // st7@71
3277 int v34; // ST3C_4@71
3278 unsigned int v35; // eax@74
3279 int v36; // ecx@88
3280 int v37; // esi@96
3281 int v38; // eax@96
3282 int v39; // ecx@106
3283 int v40; // eax@106
3284 Player **v41; // esi@113
3285 int v42; // eax@120
3286 signed int v43; // ecx@123
3287 BLVFace *v44; // esi@126
3288 PolygonType v45; // al@126
3289 int v46; // ecx@133
3290 char v47; // zf@133
3291 int v48; // eax@133
3292 int v49; // ST40_4@136
3293 int v50; // ST40_4@140
3294 int v51; // eax@140
3295 int v52; // eax@140
3296 signed int v53; // edi@146
3297 int v54; // ebx@146
3298 int v55; // ST30_4@146
3299 AudioPlayer *v56; // ecx@162
3300 SoundID v57; // [sp-20h] [bp-80h]@163
3301 signed int v58; // [sp-1Ch] [bp-7Ch]@161
3302 unsigned int v59; // [sp-18h] [bp-78h]@161
3303 signed int v60; // [sp-14h] [bp-74h]@161
3304 signed int v61; // [sp-10h] [bp-70h]@161
3305 int v62; // [sp-Ch] [bp-6Ch]@161
3306 int v63; // [sp-8h] [bp-68h]@75
3307 unsigned int v64; // [sp-8h] [bp-68h]@161
3308 int v65; // [sp-4h] [bp-64h]@75
3309 int v66; // [sp-4h] [bp-64h]@161
3310 double v67; // [sp+Ch] [bp-54h]@8
3311 int v68; // [sp+10h] [bp-50h]@45
3312 int v69; // [sp+10h] [bp-50h]@140
3313 int v70; // [sp+14h] [bp-4Ch]@1
3314 signed int v71; // [sp+18h] [bp-48h]@1
3315 signed int v72; // [sp+1Ch] [bp-44h]@1
3316 signed int v73; // [sp+20h] [bp-40h]@100
3317 int v74; // [sp+20h] [bp-40h]@140
3318 signed int bFeatherFall; // [sp+24h] [bp-3Ch]@15
3319 bool bFeatherFalla; // [sp+24h] [bp-3Ch]@33
3320 unsigned int v77; // [sp+28h] [bp-38h]@1
3321 int v78; // [sp+2Ch] [bp-34h]@1
3322 int v79; // [sp+30h] [bp-30h]@1
3323 int i; // [sp+34h] [bp-2Ch]@1
3324 int v81; // [sp+38h] [bp-28h]@47
3325 int v82; // [sp+3Ch] [bp-24h]@47
3326 int v83; // [sp+40h] [bp-20h]@47
3327 int bJumping; // [sp+44h] [bp-1Ch]@1
3328 int v85; // [sp+48h] [bp-18h]@1
3329 int v86; // [sp+4Ch] [bp-14h]@1
3330 int v87; // [sp+50h] [bp-10h]@1
3331 float v88; // [sp+54h] [bp-Ch]@62
3332 int v89; // [sp+58h] [bp-8h]@1
3333 int angle; // [sp+5Ch] [bp-4h]@47
3334
3335 v0 = pParty->vPosition.y;
3336 v89 = pParty->uFallSpeed;
3337 v1 = 0;
3338 v85 = pParty->vPosition.z;
3339 v70 = 0;
3340 v2 = 0;
3341 v86 = pParty->vPosition.x;
3342 v87 = pParty->vPosition.y;
3343 v77 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
3344 v72 = 0;
3345 v78 = 0;
3346 v71 = 0;
3347 bJumping = 0;
3348 v3 = v0 + 40;
3349 i = _46ED1B_collide_against_floor(v86, v85, v3, &v77, &v79);
3350 if ( pParty->bFlying )
3351 {
3352 pParty->bFlying = 0;
3353 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
3354 stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing]
3355 }
3356 if ( i == -30000 )
3357 {
3358 i = _47272C_collide_agains_some_secotors_floors(v86, v85, v3, &v77, &v79);
3359 if ( i == -30000 )
3360 {
3361 pParty->vPosition.x = blv_prev_party_x;
3362 pParty->vPosition.z = blv_prev_party_z;
3363 pParty->vPosition.y = blv_prev_party_y;
3364 pParty->uFallStartY = blv_prev_party_y;
3365 return;
3366 }
3367 }
3368 blv_prev_party_x = pParty->vPosition.x;
3369 blv_prev_party_z = pParty->vPosition.z;
3370 blv_prev_party_y = pParty->vPosition.y;
3371 if ( pParty->bTurnBasedModeOn != 1 )
3372 {
3373 v4 = (double)(GetTickCount() / 0x1F4);
3374 v67 = v4 + 6.7553994e15;
3375 if ( *(int *)&word_720C10_intercepts_xs[102] != LODWORD(v67) )
3376 {
3377 dword_4F8584[3 * dword_4F8580[0]] = pParty->vPosition.x;
3378 dword_4F8588[3 * dword_4F8580[0]] = pParty->vPosition.z;
3379 dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.y;
3380 if ( dword_4F8580[0] > 60 )
3381 dword_4F8580[0] = 1;
3382 }
3383 *(int *)&word_720C10_intercepts_xs[102] = LODWORD(v67);
3384 }
3385 if ( SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0
3386 || SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 )
3387 {
3388 bFeatherFall = 0;
3389 v5 = &pPlayers[1];
3390 while ( !(*v5)->WearsItem(536, 16) )
3391 {
3392 ++v5;
3393 if ( (signed int)v5 > (signed int)&pPlayers[4] )
3394 {
3395 v6 = pParty->uFallStartY;
3396 goto LABEL_20;
3397 }
3398 }
3399 }
3400 v6 = i;
3401 bFeatherFall = 1;
3402 pParty->uFallStartY = i;
3403 LABEL_20:
3404 if ( v6 - v87 > 512 && !bFeatherFall && v87 <= i + 1 )
3405 {
3406 if ( BYTE1(pParty->uFlags) & 1 )
3407 {
3408 BYTE1(pParty->uFlags) &= 0xFEu;
3409 }
3410 else
3411 {
3412 v7 = &pPlayers[1]; // receive falling damage
3413 do
3414 {
3415 if ( !(*v7)->HasEnchantedItemEquipped(72) && !(*v7)->WearsItem(529, 8) )
3416 {
3417 v8 = (signed __int64)((double)(*v7)->GetMaxHealth() * 0.1);
3418 (*v7)->ReceiveDamage((pParty->uFallStartY - v87) * (signed int)v8 / 256, 4);
3419 v9 = (*v7)->GetActualEndurance();
3420 v10 = (double)(20 - (*v7)->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
3421 (*v7)->SetRecoveryTime((signed __int64)v10);
3422 }
3423 ++v7;
3424 }
3425 while ( (signed int)v7 <= (signed int)&pPlayers[4] );
3426 }
3427 }
3428 if ( v87 > i + 1 )
3429 bJumping = 1;
3430 bFeatherFalla = v87 - i <= 32;
3431 if ( v87 - i <= 32 )
3432 pParty->uFallStartY = v87;
3433 if ( bWalkSound && pParty->field_6F8 > 0 )
3434 pParty->field_6F8 -= pEventTimer->uTimeElapsed;
3435 if ( v87 > i + 1 )
3436 {
3437 LABEL_43:
3438 if ( bJumping )
3439 goto LABEL_45;
3440 goto LABEL_44;
3441 }
3442 v87 = i + 1;
3443 pParty->uFallStartY = i + 1;
3444 if ( bJumping )
3445 goto LABEL_45;
3446 if ( pParty->field_6F4_packedid != v79 )
3447 {
3448 v11 = &pIndoor->pFaces[v79];
3449 if ( BYTE3(v11->uAttributes) & 4 )
3450 {
3451 v70 = pIndoor->pFaceExtras[v11->uFaceExtraID].uEventID;
3452 goto LABEL_43;
3453 }
3454 }
3455 LABEL_44:
3456 pParty->field_6F4_packedid = v79;
3457 LABEL_45:
3458 v68 = v79;
3459 if ( pIndoor->pFaces[v79].uAttributes & 0x10 )
3460 v71 = 1;
3461 v81 = pParty->uWalkSpeed;
3462 angle = pParty->sRotationY;
3463 v83 = pParty->sRotationX;
3464 v82 = (unsigned __int64)(pEventTimer->dt_in_some_format
3465 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed * stru_5C6E00->uIntegerPi)
3466 / 180)) >> 16;
3467 LABEL_87:
3468 while ( pPartyActionQueue->uNumActions )
3469 {
3470 switch ( pPartyActionQueue->Next() )
3471 {
3472 case PARTY_TurnLeft:
3473 v12 = uTurnSpeed;
3474 if ( uTurnSpeed )
3475 goto LABEL_58;
3476 v13 = (double)v82 * fTurnSpeedMultiplier;
3477 goto LABEL_51;
3478 case PARTY_TurnRight:
3479 LODWORD(v15) = uTurnSpeed;
3480 if ( uTurnSpeed )
3481 goto LABEL_56;
3482 v16 = (double)v82 * fTurnSpeedMultiplier;
3483 goto LABEL_55;
3484 case PARTY_FastTurnLeft:
3485 v12 = uTurnSpeed;
3486 if ( uTurnSpeed )
3487 {
3488 LABEL_58:
3489 v14 = angle + v12;
3490 }
3491 else
3492 {
3493 v13 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82;
3494 LABEL_51:
3495 v14 = angle + (unsigned __int64)(signed __int64)v13;
3496 }
3497 angle = stru_5C6E00->uDoublePiMask & v14;
3498 goto LABEL_87;
3499 case PARTY_FastTurnRight:
3500 LODWORD(v15) = uTurnSpeed;
3501 if ( !uTurnSpeed )
3502 {
3503 v16 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82;
3504 LABEL_55:
3505 v15 = (signed __int64)v16;
3506 }
3507 LABEL_56:
3508 angle = stru_5C6E00->uDoublePiMask & (angle - v15);
3509 goto LABEL_87;
3510 case PARTY_StrafeLeft:
3511 v17 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3512 v18 = (double)v81;
3513 v88 = v18;
3514 v78 = (unsigned __int64)(v17 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16;
3515 v2 -= v78;
3516 v19 = stru_5C6E00->SinCos(angle);
3517 v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16;
3518 goto LABEL_63;
3519 case PARTY_StrafeRight:
3520 v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3521 v21 = (double)v81;
3522 v88 = v21;
3523 v78 = (unsigned __int64)(v20 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16;
3524 v2 += v78;
3525 v22 = stru_5C6E00->SinCos(angle);
3526 v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16;
3527 goto LABEL_68;
3528 case PARTY_WalkForward:
3529 v23 = stru_5C6E00->SinCos(angle);
3530 v24 = (double)v81;
3531 v88 = v24;
3532 v78 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
3533 v2 += v78;
3534 v25 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3535 v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v88 * fWalkSpeedMultiplier)) >> 16;
3536 LABEL_63:
3537 v1 += v78;
3538 goto LABEL_64;
3539 case PARTY_WalkBackward:
3540 v26 = stru_5C6E00->SinCos(angle);
3541 v27 = (double)v81;
3542 v88 = v27;
3543 v78 = (unsigned __int64)(v26
3544 * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardMovementSlowdownMultiplier)) >> 16;
3545 v2 -= v78;
3546 v28 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3547 v78 = (unsigned __int64)(v28
3548 * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16;
3549 LABEL_68:
3550 v1 -= v78;
3551 LABEL_64:
3552 v78 = 1;
3553 goto LABEL_87;
3554 case PARTY_RunForward:
3555 v29 = stru_5C6E00->SinCos(angle);
3556 v30 = (double)v81;
3557 v88 = v30;
3558 v2 += (unsigned __int64)(v29
3559 * (signed __int64)(signed int)(2
3560 * (unsigned __int64)(signed __int64)(v30
3561 * fWalkSpeedMultiplier))) >> 16;
3562 v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3563 v1 += (unsigned __int64)(v31
3564 * (signed __int64)(signed int)(2
3565 * (unsigned __int64)(signed __int64)(v88
3566 * fWalkSpeedMultiplier))) >> 16;
3567 goto LABEL_70;
3568 case PARTY_RunBackward:
3569 v32 = stru_5C6E00->SinCos(angle);
3570 v33 = (double)v81;
3571 v88 = v33;
3572 v2 -= (unsigned __int64)(v32
3573 * (signed __int64)(signed int)(signed __int64)(v33 * fBackwardMovementSlowdownMultiplier)) >> 16;
3574 v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
3575 v1 -= (unsigned __int64)(v34
3576 * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16;
3577 LABEL_70:
3578 v72 = 1;
3579 goto LABEL_87;
3580 case PARTY_LookUp:
3581 v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
3582 if ( v83 > 128 )
3583 v83 = 128;
3584 v35 = uActiveCharacter;
3585 if ( !uActiveCharacter )
3586 goto LABEL_87;
3587 v65 = 0;
3588 v63 = 63;
3589 goto LABEL_76;
3590 case PARTY_LookDown:
3591 v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
3592 if ( v83 < -128 )
3593 v83 = -128;
3594 v35 = uActiveCharacter;
3595 if ( uActiveCharacter )
3596 {
3597 v65 = 0;
3598 v63 = 64;
3599 LABEL_76:
3600 pPlayers[v35]->PlaySound(v63, v65);
3601 }
3602 break;
3603 case PARTY_CenterView:
3604 v83 = 0;
3605 break;
3606 case PARTY_Jump:
3607 if ( (!bJumping || v87 <= i + 6 && v89 <= 0) && pParty->field_24 )
3608 {
3609 bJumping = 1;
3610 v89 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v89);
3611 }
3612 break;
3613 default:
3614 goto LABEL_87;
3615 }
3616 }
3617 v36 = 0;
3618 pParty->sRotationY = angle;
3619 pParty->sRotationX = v83;
3620 if ( bJumping )
3621 {
3622 v89 += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
3623 }
3624 else
3625 {
3626 if ( pIndoor->pFaces[v68].pFacePlane_old.vNormal.z < 32768 )
3627 {
3628 v89 -= pEventTimer->uTimeElapsed * GetGravityStrength();
3629 goto LABEL_92;
3630 }
3631 if ( BYTE1(pParty->uFlags) & 1 )
3632 goto LABEL_92;
3633 v89 = 0;
3634 }
3635 if ( bJumping != v36 && v89 <= v36 )
3636 {
3637 if ( v89 < -500 && !pParty->bFlying )
3638 {
3639 v41 = &pPlayers[1];
3640 do
3641 {
3642 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) )
3643 (*v41)->PlayEmotion(46, 0);
3644 ++v41;
3645 }
3646 while ( (signed int)v41 <= (signed int)&pPlayers[4] );
3647 }
3648 goto LABEL_93;
3649 }
3650 LABEL_92:
3651 pParty->uFallStartY = v87;
3652 LABEL_93:
3653 if ( v2 * v2 + v1 * v1 < 400 )
3654 {
3655 v1 = 0;
3656 v2 = 0;
3657 }
3658 stru_721530.field_84 = -1;
3659 stru_721530.field_70 = 0;
3660 stru_721530.prolly_normal_d = pParty->field_14;
3661 stru_721530.field_8 = pParty->field_14 >> 1;
3662 v83 = 0;
3663 stru_721530.field_0 = 1;
3664 stru_721530.field_C = pParty->uPartyHeight - 32;
3665 while ( 1 )
3666 {
3667 v37 = v87;
3668 stru_721530.field_34.x = v86;
3669 stru_721530.normal.x = v86;
3670 stru_721530.field_1C = v2;
3671 stru_721530.field_34.y = v85;
3672 stru_721530.normal.y = v85;
3673 stru_721530.field_20 = v1;
3674 stru_721530.normal.z = stru_721530.prolly_normal_d + v87 + 1;
3675 stru_721530.field_34.z = stru_721530.field_C + v87 + 1;
3676 stru_721530.field_24 = v89;
3677 stru_721530.uSectorID = v77;
3678 v38 = 0;
3679 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
3680 v38 = 13312;
3681 if ( stru_721530._47050A(v38) )
3682 break;
3683 v73 = 0;
3684 do
3685 {
3686 _46E44E_collide_against_faces_and_portals(1u);
3687 _46E0B2_collide_against_decorations();
3688 for ( i = 0; i < (signed int)uNumActors; ++i )
3689 _46DF1A_collide_against_actor(i, 0);
3690 if ( _46F04E_collide_against_portals() )
3691 break;
3692 ++v73;
3693 }
3694 while ( v73 < 100 );
3695 if ( stru_721530.field_7C >= stru_721530.field_6C )
3696 {
3697 v39 = stru_721530.normal2.x;
3698 v77 = stru_721530.normal2.y;
3699 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
3700 }
3701 else
3702 {
3703 v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + v86;
3704 v77 = v85 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
3705 v40 = v37 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
3706 }
3707 v42 = _46ED1B_collide_against_floor(v39, v77, v40 + 40, &stru_721530.uSectorID, &v79);
3708 if ( v42 == -30000 || v42 - v37 > 128 )
3709 return;
3710 if ( stru_721530.field_7C >= stru_721530.field_6C )
3711 {
3712 v86 = stru_721530.normal2.x;
3713 v85 = stru_721530.normal2.y;
3714 v37 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
3715 break;
3716 }
3717 v86 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
3718 v85 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
3719 v43 = stru_721530.uFaceID;
3720 v77 = stru_721530.uSectorID;
3721 stru_721530.field_70 += stru_721530.field_7C;
3722 v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + v37;
3723 if ( (stru_721530.uFaceID & 7) == 3 )
3724 {
3725 if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
3726 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) )
3727 pParty->pPartyBuffs[11].Reset();
3728 viewparams->bRedrawGameUI = 1;
3729 goto LABEL_152;
3730 }
3731 if ( (stru_721530.uFaceID & 7) == 5 )
3732 {
3733 v53 = sub_452A9E(v2 * v2 + v1 * v1);
3734 i = v53;
3735 v54 = stru_5C6E00->Atan2(
3736 v86 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
3737 v85 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
3738 v2 = (unsigned __int64)(stru_5C6E00->SinCos(v54) * (signed __int64)v53) >> 16;
3739 v55 = stru_5C6E00->SinCos(v54 - stru_5C6E00->uIntegerHalfPi);
3740 v1 = (unsigned __int64)(v55 * (signed __int64)i) >> 16;
3741 }
3742 else
3743 {
3744 if ( (stru_721530.uFaceID & 7) == 6 )
3745 {
3746 v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
3747 v45 = v44->uPolygonType;
3748 if ( v45 == 3 )
3749 {
3750 if ( v89 < 0 )
3751 v89 = 0;
3752 v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1;
3753 if ( pParty->uFallStartY - v87 < 512 )
3754 pParty->uFallStartY = v87;
3755 if ( v2 * v2 + v1 * v1 < 400 )
3756 {
3757 v1 = 0;
3758 v2 = 0;
3759 }
3760 goto LABEL_143;
3761 }
3762 v46 = v89 * v44->pFacePlane_old.vNormal.z;
3763 v47 = v45 == 4;
3764 v48 = v44->pFacePlane_old.vNormal.x;
3765 if ( !v47 )
3766 {
3767 i = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
3768 if ( stru_721530.field_64 >> 3 > i )
3769 i = stru_721530.field_64 >> 3;
3770 v50 = (unsigned __int64)(i * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
3771 v81 = v44->pFacePlane_old.vNormal.y;
3772 v81 = (unsigned __int64)(i * (signed __int64)v81) >> 16;
3773 v82 = v44->pFacePlane_old.vNormal.z;
3774 v82 = (unsigned __int64)(i * (signed __int64)v82) >> 16;
3775 v2 += v50;
3776 v89 += v82;
3777 v74 = v44->pFacePlane_old.vNormal.z;
3778 v51 = v44->pFacePlane_old.vNormal.y;
3779 v69 = v44->pFacePlane_old.vNormal.x;
3780 i = v51;
3781 v1 += v81;
3782 v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + v85 * v51 + v86 * v69) >> 16);
3783 if ( v52 > 0 )
3784 {
3785 v86 += v52 * v69 >> 16;
3786 v85 += v52 * i >> 16;
3787 v87 += v52 * v74 >> 16;
3788 }
3789 LABEL_142:
3790 v43 = stru_721530.uFaceID;
3791 LABEL_143:
3792 if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 )
3793 v70 = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
3794 goto LABEL_152;
3795 }
3796 i = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
3797 if ( stru_721530.field_64 >> 3 > i )
3798 i = stru_721530.field_64 >> 3;
3799 v49 = (unsigned __int64)(i * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
3800 v81 = v44->pFacePlane_old.vNormal.y;
3801 v81 = (unsigned __int64)(i * (signed __int64)v81) >> 16;
3802 v82 = v44->pFacePlane_old.vNormal.z;
3803 v82 = (unsigned __int64)(i * (signed __int64)v82) >> 16;
3804 v2 += v49;
3805 v1 += v81;
3806 v89 += v82;
3807 if ( v2 * v2 + v1 * v1 >= 400 )
3808 goto LABEL_142;
3809 v2 = 0;
3810 v1 = 0;
3811 v89 = 0;
3812 }
3813 }
3814 LABEL_152:
3815 v2 = (unsigned __int64)(58500i64 * v2) >> 16;
3816 v1 = (unsigned __int64)(58500i64 * v1) >> 16;
3817 ++v83;
3818 v89 = (unsigned __int64)(58500i64 * v89) >> 16;
3819 if ( v83 >= 100 )
3820 {
3821 v37 = v87;
3822 break;
3823 }
3824 }
3825 if ( bWalkSound && pParty->field_6F8 <= 0 )
3826 {
3827 if ( sub_452A9E((pParty->vPosition.x - v86) * (pParty->vPosition.x - v86) + (pParty->vPosition.z - v85)
3828 * (pParty->vPosition.z - v85)
3829 + (pParty->vPosition.y - v37)
3830 * (pParty->vPosition.y - v37)) <= 16 )
3831 goto LABEL_188;
3832 if ( v72 && (!bJumping || bFeatherFalla) )
3833 {
3834 v66 = 0;
3835 v64 = 0;
3836 v62 = 0;
3837 v61 = 0;
3838 v60 = -1;
3839 v59 = 1;
3840 v58 = 804;
3841 if ( !v71 )
3842 {
3843 v56 = pAudioPlayer;
3844 if ( BYTE2(pIndoor->pFaces[v79].uAttributes) & 0x20 )
3845 v57 = (SoundID)50;
3846 else
3847 v57 = (SoundID)64;
3848 goto LABEL_175;
3849 }
3850 v57 = (SoundID)63;
3851 LABEL_174:
3852 v56 = pAudioPlayer;
3853 goto LABEL_175;
3854 }
3855 if ( v78 && (!bJumping || bFeatherFalla) )
3856 {
3857 v66 = 0;
3858 v64 = 0;
3859 v62 = 0;
3860 v61 = 0;
3861 v60 = -1;
3862 v59 = 1;
3863 v58 = 804;
3864 if ( v71 )
3865 {
3866 v57 = (SoundID)102;
3867 goto LABEL_174;
3868 }
3869 v56 = pAudioPlayer;
3870 if ( BYTE2(pIndoor->pFaces[v79].uAttributes) & 0x20 )
3871 v57 = (SoundID)89;
3872 else
3873 v57 = (SoundID)103;
3874 LABEL_175:
3875 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
3876 }
3877 else
3878 {
3879 LABEL_188:
3880 pAudioPlayer->_4AA258(804);
3881 pParty->field_6F8 = 64;
3882 }
3883 }
3884 if ( !bJumping || bFeatherFalla )
3885 pParty->uFlags &= 0xFFFFFFF7u;
3886 else
3887 pParty->uFlags |= 8u;
3888 BYTE1(pParty->uFlags) &= 0xFDu;
3889 pParty->vPosition.x = v86;
3890 pParty->vPosition.y = v37;
3891 pParty->vPosition.z = v85;
3892 pParty->uFallSpeed = v89;
3893 if ( !bJumping && BYTE3(pIndoor->pFaces[v79].uAttributes) & 0x40 )
3894 BYTE1(pParty->uFlags) |= 2u;
3895 if ( v70 )
3896 EventProcessor(v70, 0, 1);
3897 }
3898
3899
3900 //----- (00473893) --------------------------------------------------------
3901 void __cdecl ODM_ProcessPartyActions()
3902 {
3903 int _zero; // esi@1
3904 int v1; // edi@1
3905 int v2; // ebx@1
3906 int v3; // eax@14
3907 Player **v4; // esi@21
3908 int v5; // eax@24
3909 int v6; // esi@45
3910 ODMFace *v7; // ecx@45
3911 unsigned int v8; // eax@71
3912 double v9; // st7@72
3913 signed __int64 v10; // qax@74
3914 double v11; // st7@75
3915 int v12; // ecx@77
3916 int v13; // eax@84
3917 double v14; // st7@84
3918 int v15; // eax@87
3919 double v16; // st7@87
3920 int v17; // eax@88
3921 double v18; // st7@88
3922 int v19; // eax@89
3923 double v20; // st7@89
3924 int v21; // eax@92
3925 double v22; // st7@92
3926 int v23; // eax@96
3927 double v24; // st7@96
3928 int v25; // eax@97
3929 double v26; // st7@97
3930 int v27; // eax@98
3931 double v28; // st7@98
3932 signed __int64 v29; // qax@98
3933 unsigned int v30; // eax@103
3934 int v31; // eax@130
3935 int v32; // ecx@141
3936 signed int v33; // eax@143
3937 int v34; // esi@143
3938 unsigned int v35; // esi@147
3939 int v36; // eax@155
3940 signed int v37; // esi@159
3941 signed int v38; // eax@159
3942 signed int i; // esi@159
3943 int v40; // esi@162
3944 Player **v41; // esi@172
3945 bool v42; // eax@180
3946 signed int v43; // ecx@184
3947 signed int v44; // edx@184
3948 int v45; // ecx@200
3949 BSPModel *v46; // eax@203
3950 ODMFace *v47; // esi@203
3951 int v48; // eax@203
3952 char v49; // zf@203
3953 char v50; // sf@203
3954 unsigned __int8 v51; // of@203
3955 int v52; // eax@203
3956 unsigned __int8 v53; // dl@205
3957 BSPModel *v54; // eax@215
3958 int v55; // eax@217
3959 signed int v56; // ebx@228
3960 int v57; // eax@228
3961 BSPModel *v58; // eax@228
3962 unsigned __int64 v59; // qax@228
3963 BSPModel *v60; // eax@228
3964 unsigned __int64 v61; // qax@228
3965 int v62; // eax@241
3966 signed int v63; // ST04_4@255
3967 signed int v64; // eax@255
3968 unsigned int v65; // ebx@263
3969 unsigned int v66; // esi@263
3970 int v67; // eax@263
3971 signed int v68; // ecx@263
3972 int v69; // eax@263
3973 int v70; // ebx@271
3974 int v71; // esi@271
3975 int v72; // edi@271
3976 int v73; // eax@271
3977 Player **v74; // esi@283
3978 int v75; // eax@284
3979 unsigned int v76; // edi@293
3980 bool v77; // edx@297
3981 bool v78; // ecx@303
3982 int v79; // ecx@314
3983 __int16 v80; // dx@317
3984 int v81; // ebx@318
3985 int v82; // ecx@318
3986 int v83; // eax@321
3987 Player **v84; // esi@333
3988 int v85; // eax@334
3989 int v86; // [sp-20h] [bp-B4h]@246
3990 int v87; // [sp-20h] [bp-B4h]@248
3991 signed int v88; // [sp-1Ch] [bp-B0h]@246
3992 unsigned int v89; // [sp-18h] [bp-ACh]@246
3993 signed int v90; // [sp-14h] [bp-A8h]@246
3994 signed int v91; // [sp-10h] [bp-A4h]@246
3995 int v92; // [sp-Ch] [bp-A0h]@246
3996 int v93; // [sp-8h] [bp-9Ch]@104
3997 unsigned int v94; // [sp-8h] [bp-9Ch]@246
3998 int v95; // [sp-4h] [bp-98h]@104
3999 int v96; // [sp-4h] [bp-98h]@246
4000 int v97; // [sp+Ch] [bp-88h]@180
4001 int v98; // [sp+10h] [bp-84h]@147
4002 int v99; // [sp+14h] [bp-80h]@147
4003 int v100; // [sp+18h] [bp-7Ch]@147
4004 bool v101; // [sp+1Ch] [bp-78h]@33
4005 int v102; // [sp+20h] [bp-74h]@1
4006 int v103; // [sp+24h] [bp-70h]@1
4007 int bFeatherFall; // [sp+28h] [bp-6Ch]@4
4008 int v105; // [sp+2Ch] [bp-68h]@24
4009 int bWaterWalk; // [sp+30h] [bp-64h]@1
4010 bool v107; // [sp+34h] [bp-60h]@30
4011 int v108; // [sp+38h] [bp-5Ch]@1
4012 int v109; // [sp+3Ch] [bp-58h]@28
4013 int v110; // [sp+40h] [bp-54h]@180
4014 int v111; // [sp+44h] [bp-50h]@14
4015 int bJumping; // [sp+48h] [bp-4Ch]@1
4016 int v113; // [sp+4Ch] [bp-48h]@1
4017 unsigned int v114; // [sp+50h] [bp-44h]@1
4018 int _walk_speed; // [sp+54h] [bp-40h]@48
4019 int v116; // [sp+58h] [bp-3Ch]@1
4020 int v117; // [sp+5Ch] [bp-38h]@1
4021 int v118; // [sp+60h] [bp-34h]@1
4022 Player **v119; // [sp+64h] [bp-30h]@4
4023 int _angle_x; // [sp+68h] [bp-2Ch]@48
4024 int v121; // [sp+6Ch] [bp-28h]@1
4025 unsigned int v122; // [sp+70h] [bp-24h]@180
4026 int v123; // [sp+74h] [bp-20h]@1
4027 int v124; // [sp+78h] [bp-1Ch]@1
4028 int _angle_y; // [sp+7Ch] [bp-18h]@48
4029 int v126; // [sp+80h] [bp-14h]@48
4030 BSPModel *v127; // [sp+84h] [bp-10h]@1
4031 int v128; // [sp+88h] [bp-Ch]@1
4032 int v129; // [sp+8Ch] [bp-8h]@92
4033 int v130; // [sp+90h] [bp-4h]@14
4034
4035 v121 = pParty->uFallSpeed;
4036 v123 = pParty->vPosition.y;
4037 _zero = 0;
4038 v1 = 0;
4039 v103 = 0;
4040 v2 = 0;
4041 *(float *)&v128 = 0.0;
4042 v116 = pParty->vPosition.x;
4043 v117 = pParty->vPosition.z;
4044 v113 = pParty->field_6F0;
4045 bJumping = 0;
4046 v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.z);
4047 v114 = 0;
4048 v124 = 0;
4049 v108 = 0;
4050 v102 = 0;
4051 v127 = 0;
4052 bWaterWalk = 0;
4053 if ( SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0
4054 || SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 )
4055 {
4056 bFeatherFall = 0;
4057 v119 = &pPlayers[1];
4058 while ( !(*v119)->WearsItem(536, 16) )
4059 {
4060 ++v119;
4061 if ( (signed int)v119 > (signed int)&pPlayers[4] )
4062 goto LABEL_9;
4063 }
4064 }
4065 bFeatherFall = 1;
4066 LABEL_9:
4067 if ( (signed __int64)pParty->pPartyBuffs[18].uExpireTime <= 0 )
4068 {
4069 LOBYTE(pParty->uFlags) &= 0x7Fu;
4070 }
4071 else
4072 {
4073 LOBYTE(pParty->uFlags) &= 0x7Fu;
4074 bWaterWalk = 1;
4075 *(short *)&stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
4076 if ( !(pParty->pPartyBuffs[18].uFlags & 1)
4077 && *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
4078 bWaterWalk = 0;
4079 }
4080 v3 = sub_46D49E_prolly_get_world_y_under_party(v116, v117, v123, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
4081 v111 = v3;
4082 if ( bFeatherFall )
4083 pParty->uFallStartY = v3;
4084 else
4085 v3 = pParty->uFallStartY;
4086 if ( v3 - v123 > 512 && !bFeatherFall && v123 <= v111 + 1 )
4087 {
4088 if ( BYTE1(pParty->uFlags) & 1 )
4089 {
4090 BYTE1(pParty->uFlags) &= 0xFEu;
4091 }
4092 else
4093 {
4094 v4 = &pPlayers[1]; // receive falling damage
4095 do
4096 {
4097 if ( !(*v4)->HasEnchantedItemEquipped(72) && !(*v4)->WearsItem(529, 8) )
4098 {
4099 v105 = (*v4)->GetMaxHealth();
4100 (*v4)->ReceiveDamage(
4101 (signed int)((pParty->uFallStartY - v123) * (unsigned __int64)(signed __int64)((double)v105 * 0.1)) / 256,
4102 4);
4103 v5 = (*v4)->GetActualEndurance();
4104 v105 = 20 - (*v4)->_48EA1B_get_static_effect(v5);
4105 (*v4)->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
4106 }
4107 ++v4;
4108 }
4109 while ( (signed int)v4 <= (signed int)&pPlayers[4] );
4110 _zero = 0;
4111 }
4112 }
4113 v109 = -1;
4114 if ( pParty->bFlying != _zero )
4115 v109 = sub_46D8E3(v116, v117, v123 + pParty->uPartyHeight, (int)&v102);
4116 v107 = v108 == _zero;
4117 v105 = v111 + 1;
4118 if ( v123 <= v111 + 1 )
4119 {
4120 v109 = -1;
4121 pParty->bFlying = _zero;
4122 }
4123 else
4124 {
4125 bJumping = 1;
4126 }
4127 v101 = v123 - v111 <= 32;
4128 if ( bWalkSound != _zero && pParty->field_6F8 > _zero )
4129 pParty->field_6F8 -= pEventTimer->uTimeElapsed;
4130 if ( !bUnderwater
4131 && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero
4132 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < _zero || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero) )
4133 pParty->bFlying = _zero;
4134 if ( bJumping == _zero )
4135 {
4136 if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) )
4137 {
4138 if ( v108 != _zero )
4139 {
4140 if ( v108 >> 6 < pOutdoor->uNumBModels )
4141 {
4142 v7 = (ODMFace *)&pOutdoor->pBModels[v108 >> 6].pFaces;
4143 v6 = v108 & 0x3F;
4144 if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 )
4145 {
4146 pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel;
4147 v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292);
4148 }
4149 }
4150 }
4151 }
4152 pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel;
4153 }
4154 _walk_speed = pParty->uWalkSpeed;
4155 _angle_y = pParty->sRotationY;
4156 _angle_x = pParty->sRotationX;
4157 v126 = pEventTimer->dt_in_some_format;
4158 v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format
4159 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed
4160 * stru_5C6E00->uIntegerPi)
4161 / 180)) >> 16);
4162 LABEL_118:
4163 while ( pPartyActionQueue->uNumActions )
4164 {
4165 switch ( pPartyActionQueue->Next() )
4166 {
4167 case PARTY_FlyUp:
4168 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 )
4169 {
4170 pParty->bFlying = 0;
4171 if ( bUnderwater
4172 || pParty->pPartyBuffs[7].uFlags & 1
4173 || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
4174 {
4175 if ( pParty->vPosition.y < 4000 || bJumping )
4176 {
4177 v123 += 30;
4178 v113 += 30;
4179 pParty->bFlying = 1;
4180 if ( v123 > 4000 )
4181 {
4182 v123 = 4000;
4183 v113 = 4000;
4184 }
4185 v1 = 0;
4186 v2 = 0;
4187 v121 = 0;
4188 *(float *)&v128 = 0.0;
4189 if ( v102 && v123 < v109 && (signed int)(pParty->uPartyHeight + v123) >= v109 )
4190 {
4191 pParty->field_6E0 = 0;
4192 pParty->field_6E4 = 0;
4193 pPartyActionQueue->uNumActions = 0;
4194 BYTE1(pParty->uFlags) |= 1u;
4195 pParty->vPosition.y = v109 - pParty->uPartyHeight - 31;
4196 pParty->field_6F0 = v123;
4197 pParty->bFlying = 0;
4198 v123 = v109 - pParty->uPartyHeight - 31;
4199 v113 = pParty->field_6F0;
4200 }
4201 pParty->uFallSpeed = 0;
4202 v127 = (BSPModel *)1;
4203 }
4204 }
4205 }
4206 goto LABEL_118;
4207 case PARTY_FlyDown:
4208 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 )
4209 {
4210 pParty->bFlying = 0;
4211 if ( bUnderwater
4212 || pParty->pPartyBuffs[7].uFlags & 1
4213 || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
4214 {
4215 v123 -= 30;
4216 v113 -= 30;
4217 pParty->uFallSpeed = 0;
4218 v121 = 0;
4219 pParty->bFlying = 1;
4220 v127 = (BSPModel *)1;
4221 if ( v123 <= v111 )
4222 {
4223 pParty->bFlying = 0;
4224 pPartyActionQueue->uNumActions = 0;
4225 }
4226 }
4227 }
4228 goto LABEL_118;
4229 case PARTY_TurnLeft:
4230 v8 = uTurnSpeed;
4231 if ( uTurnSpeed )
4232 goto LABEL_80;
4233 v9 = (double)(signed int)v119 * fTurnSpeedMultiplier;
4234 goto LABEL_73;
4235 case PARTY_TurnRight:
4236 LODWORD(v10) = uTurnSpeed;
4237 if ( uTurnSpeed )
4238 goto LABEL_77;
4239 v11 = (double)(signed int)v119 * fTurnSpeedMultiplier;
4240 goto LABEL_76;
4241 case PARTY_FastTurnLeft:
4242 v8 = uTurnSpeed;
4243 if ( uTurnSpeed )
4244 {
4245 LABEL_80:
4246 v12 = v8 + _angle_y;
4247 LABEL_78:
4248 _angle_y = stru_5C6E00->uDoublePiMask & v12;
4249 }
4250 else
4251 {
4252 v9 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)(signed int)v119;
4253 LABEL_73:
4254 _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9);
4255 }
4256 goto LABEL_118;
4257 case PARTY_FastTurnRight:
4258 LODWORD(v10) = uTurnSpeed;
4259 if ( !uTurnSpeed )
4260 {
4261 v11 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)(signed int)v119;
4262 LABEL_76:
4263 v10 = (signed __int64)v11;
4264 }
4265 LABEL_77:
4266 v12 = _angle_y - v10;
4267 goto LABEL_78;
4268 case PARTY_StrafeLeft:
4269 v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4270 v14 = (double)_walk_speed;
4271 v126 = v13;
4272 *(float *)&v128 = v14;
4273 v124 = (unsigned __int64)(v13 * (signed __int64)((signed int)(signed __int64)(v14 * fWalkSpeedMultiplier) >> 1)) >> 16;
4274 v2 -= v124;
4275 v126 = stru_5C6E00->SinCos(_angle_y);
4276 v124 = (unsigned __int64)(v126
4277 * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16;
4278 goto LABEL_85;
4279 case PARTY_StrafeRight:
4280 v15 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4281 v16 = (double)_walk_speed;
4282 v126 = v15;
4283 *(float *)&v128 = v16;
4284 v124 = (unsigned __int64)(v15 * (signed __int64)((signed int)(signed __int64)(v16 * fWalkSpeedMultiplier) >> 1)) >> 16;
4285 v2 += v124;
4286 v126 = stru_5C6E00->SinCos(_angle_y);
4287 v124 = (unsigned __int64)(v126
4288 * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16;
4289 goto LABEL_90;
4290 case PARTY_WalkForward:
4291 v17 = stru_5C6E00->SinCos(_angle_y);
4292 v18 = (double)_walk_speed;
4293 v126 = v17;
4294 *(float *)&v128 = v18;
4295 v124 = (unsigned __int64)(v17 * (signed __int64)(signed int)(signed __int64)(v18 * fWalkSpeedMultiplier)) >> 16;
4296 v2 += v124;
4297 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4298 v124 = (unsigned __int64)(v126
4299 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
4300 LABEL_85:
4301 v1 += v124;
4302 goto LABEL_86;
4303 case PARTY_WalkBackward:
4304 v19 = stru_5C6E00->SinCos(_angle_y);
4305 v20 = (double)_walk_speed;
4306 v126 = v19;
4307 *(float *)&v128 = v20;
4308 v124 = (unsigned __int64)(v19
4309 * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardMovementSlowdownMultiplier)) >> 16;
4310 v2 -= v124;
4311 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4312 v124 = (unsigned __int64)(v126
4313 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
4314 * fBackwardMovementSlowdownMultiplier)) >> 16;
4315 LABEL_90:
4316 v1 -= v124;
4317 goto LABEL_86;
4318 case PARTY_RunForward:
4319 if ( pParty->bFlying )
4320 {
4321 v21 = stru_5C6E00->SinCos(_angle_y);
4322 v22 = (double)_walk_speed;
4323 v126 = v21;
4324 *(float *)&v128 = v22;
4325 v129 = (unsigned __int64)(v21
4326 * (signed __int64)(signed int)(4
4327 * (unsigned __int64)(signed __int64)(v22
4328 * fWalkSpeedMultiplier))) >> 16;
4329 v2 += v129;
4330 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4331 v129 = (unsigned __int64)(v126
4332 * (signed __int64)(signed int)(4
4333 * (unsigned __int64)(signed __int64)(*(float *)&v128
4334 * fWalkSpeedMultiplier))) >> 16;
4335 v1 += v129;
4336 goto LABEL_93;
4337 }
4338 if ( v118 && !v108 )
4339 {
4340 v23 = stru_5C6E00->SinCos(_angle_y);
4341 v24 = (double)_walk_speed;
4342 v126 = v23;
4343 *(float *)&v128 = v24;
4344 v129 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
4345 v2 += v129;
4346 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4347 v129 = (unsigned __int64)(v126
4348 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
4349 v1 += v129;
4350 goto LABEL_86;
4351 }
4352 v25 = stru_5C6E00->SinCos(_angle_y);
4353 v26 = (double)_walk_speed;
4354 v114 = v25;
4355 *(float *)&v128 = v26;
4356 v129 = (unsigned __int64)(v25
4357 * (signed __int64)(signed int)(2
4358 * (unsigned __int64)(signed __int64)(v26
4359 * fWalkSpeedMultiplier))) >> 16;
4360 v2 += v129;
4361 v114 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4362 v129 = (unsigned __int64)((signed int)v114
4363 * (signed __int64)(signed int)(2
4364 * (unsigned __int64)(signed __int64)(*(float *)&v128
4365 * fWalkSpeedMultiplier))) >> 16;
4366 v1 += v129;
4367 v114 = 1;
4368 v128 = v1;
4369 break;
4370 case PARTY_RunBackward:
4371 v27 = stru_5C6E00->SinCos(_angle_y);
4372 v28 = (double)_walk_speed;
4373 v126 = v27;
4374 *(float *)&v128 = v28;
4375 v29 = (signed __int64)(v28 * fBackwardMovementSlowdownMultiplier);
4376 if ( pParty->bFlying )
4377 {
4378 v129 = (unsigned __int64)(v126 * (signed __int64)(4 * (signed int)v29)) >> 16;
4379 v2 -= v129;
4380 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4381 v129 = (unsigned __int64)(v126
4382 * (signed __int64)(signed int)(4
4383 * (unsigned __int64)(signed __int64)(*(float *)&v128
4384 * fBackwardMovementSlowdownMultiplier))) >> 16;
4385 v1 -= v129;
4386 LABEL_93:
4387 v128 = v1;
4388 }
4389 else
4390 {
4391 v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)v29) >> 16;
4392 v2 -= v129;
4393 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
4394 v129 = (unsigned __int64)(v126
4395 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
4396 * fBackwardMovementSlowdownMultiplier)) >> 16;
4397 v1 -= v129;
4398 LABEL_86:
4399 v128 = v1;
4400 v124 = 1;
4401 }
4402 break;
4403 case PARTY_LookUp:
4404 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
4405 if ( _angle_x > 128 )
4406 _angle_x = 128;
4407 v30 = uActiveCharacter;
4408 if ( !uActiveCharacter )
4409 goto LABEL_118;
4410 v95 = 0;
4411 v93 = 63;
4412 goto _play_player_sound;
4413 case PARTY_LookDown:
4414 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
4415 if ( _angle_x < -128 )
4416 _angle_x = -128;
4417 v30 = uActiveCharacter;
4418 if ( uActiveCharacter )
4419 {
4420 v95 = 0;
4421 v93 = 64;
4422 _play_player_sound:
4423 pPlayers[v30]->PlaySound(v93, v95);
4424 }
4425 goto LABEL_118;
4426 case PARTY_CenterView:
4427 _angle_x = 0;
4428 goto LABEL_118;
4429 case PARTY_Jump:
4430 if ( (!v118 || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
4431 {
4432 v126 = pParty->field_24 << 6;
4433 bJumping = 1;
4434 v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121);
4435 }
4436 goto LABEL_118;
4437 default:
4438 goto LABEL_118;
4439 case PARTY_Land:
4440 if ( pParty->bFlying )
4441 {
4442 BYTE1(pParty->uFlags) |= 1u;
4443 pParty->uFallSpeed = 0;
4444 }
4445 pParty->bFlying = 0;
4446 pPartyActionQueue->uNumActions = 0;
4447 goto LABEL_123;
4448 }
4449 }
4450 LABEL_123:
4451 pParty->sRotationY = _angle_y;
4452 pParty->sRotationX = _angle_x;
4453 if ( v123 < v111 )
4454 {
4455 if ( pParty->bFlying )
4456 {
4457 LABEL_130:
4458 v31 = GetTickCount();
4459 v126 = stru_5C6E00->SinCos(v31);
4460 v129 = (unsigned __int64)(4i64 * v126) >> 16;
4461 v123 = v113 + v129;
4462 if ( v127 )
4463 v123 = v113;
4464 if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0
4465 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) )
4466 stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu;
4467 pParty->uFallStartY = v123;
4468 goto LABEL_141;
4469 }
4470 if ( v130 && v121 )
4471 sub_42F960_create_object(v116, v117, v111);
4472 v121 = 0;
4473 v123 = v111;
4474 pParty->uFallStartY = v111;
4475 }
4476 if ( pParty->bFlying )
4477 goto LABEL_130;
4478 v113 = v123;
4479 if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0
4480 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) )
4481 stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
4482 LABEL_141:
4483 v32 = 0;
4484 if ( bJumping && !pParty->bFlying )
4485 {
4486 v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
4487 v34 = v121 + 2 * v33;
4488 v121 += 2 * v33;
4489 goto LABEL_149;
4490 }
4491 if ( !v118 )
4492 {
4493 v34 = v121;
4494 LABEL_149:
4495 if ( bJumping == v32 )
4496 goto LABEL_150;
4497 goto LABEL_164;
4498 }
4499 if ( !bJumping )
4500 {
4501 if ( v108 )
4502 goto LABEL_150;
4503 v123 = v111;
4504 _46DCC8_get_gravity_direction_outdoor(v116, v117, (Vec3_int_ *)&v98);
4505 v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
4506 v129 = abs((signed __int64)v2 * (signed __int64)v98 + (signed __int64)v1 * (signed __int64)v99 + (signed __int64)v35 * (signed __int64)v100) >> 16;
4507 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98) >> 16);
4508 v2 += (int)v127;
4509 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v99) >> 16);
4510 v1 += (int)v127;
4511 v128 = v1;
4512 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v100) >> 16);
4513 v34 = (int)((char *)v127 + v35);
4514 v32 = 0;
4515 v121 = v34;
4516 goto LABEL_149;
4517 }
4518 v34 = v121;
4519 LABEL_164:
4520 if ( !bUnderwater && v34 <= v32 )
4521 {
4522 if ( v34 < -500
4523 && !pParty->bFlying
4524 && pParty->vPosition.y - v111 > 1000
4525 && SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0
4526 && (SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 || !LODWORD(pParty->pPartyBuffs[5].uExpireTime)) )
4527 {
4528 v41 = &pPlayers[1];
4529 do
4530 {
4531 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) && (*v41)->CanAct() )
4532 (*v41)->PlaySound(66, 0);
4533 ++v41;
4534 }
4535 while ( (signed int)v41 <= (signed int)&pPlayers[4] );
4536 }
4537 goto LABEL_151;
4538 }
4539 LABEL_150:
4540 pParty->uFallStartY = v123;
4541 LABEL_151:
4542 if ( v2 * v2 + v1 * v1 < 400 && !v118 )
4543 {
4544 *(float *)&v128 = 0.0;
4545 v2 = 0;
4546 }
4547 stru_721530.field_84 = -1;
4548 stru_721530.field_70 = 0;
4549 stru_721530.prolly_normal_d = pParty->field_14;
4550 stru_721530.field_8 = pParty->field_14 >> 1;
4551 v126 = 0;
4552 stru_721530.field_0 = 1;
4553 stru_721530.field_C = pParty->uPartyHeight - 32;
4554 do
4555 {
4556 stru_721530.field_34.x = v116;
4557 stru_721530.normal.x = v116;
4558 stru_721530.field_1C = v2;
4559 stru_721530.field_34.y = v117;
4560 stru_721530.normal.y = v117;
4561 stru_721530.normal.z = stru_721530.prolly_normal_d + v123 + 1;
4562 stru_721530.field_34.z = stru_721530.field_C + v123 + 1;
4563 stru_721530.field_20 = v128;
4564 stru_721530.field_24 = v121;
4565 v36 = 0;
4566 stru_721530.uSectorID = 0;
4567 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
4568 v36 = 13312;
4569 if ( stru_721530._47050A(v36) )
4570 break;
4571 _46E889_collide_against_bmodels(1u);
4572 v37 = WorldPosToGridCellZ(pParty->vPosition.z);
4573 v38 = WorldPosToGridCellX(pParty->vPosition.x);
4574 _46E26D_collide_against_sprites(v38, v37);
4575 _46ED8A_collide_against_layingItems(4u);
4576 for ( i = 0; i < (signed int)uNumActors; ++i )
4577 _46DF1A_collide_against_actor(i, 0);
4578 if ( stru_721530.field_7C >= stru_721530.field_6C )
4579 {
4580 _angle_x = stru_721530.normal2.x;
4581 _angle_y = stru_721530.normal2.y;
4582 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
4583 }
4584 else
4585 {
4586 _angle_x = v116 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
4587 _angle_y = v117 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
4588 v127 = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
4589 v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + v123;
4590 }
4591 v122 = v40;
4592 sub_46D49E_prolly_get_world_y_under_party(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
4593 v129 = sub_46D49E_prolly_get_world_y_under_party(_angle_x, v117, v40, pParty->uPartyHeight, &v130, &v97, 0);
4594 v119 = (Player **)sub_46D49E_prolly_get_world_y_under_party(
4595 v116,
4596 _angle_y,
4597 v40,
4598 pParty->uPartyHeight,
4599 &v130,
4600 &v110,
4601 0);
4602 v127 = (BSPModel *)GetTerrainHeightsAroundParty(_angle_x, v117);
4603 v42 = GetTerrainHeightsAroundParty(v116, _angle_y);
4604 v107 = 0;
4605 v118 = v42;
4606 if ( !v97 && !v110 && !v108 )
4607 v107 = 1;
4608 v43 = 1;
4609 v44 = 1;
4610 if ( bUnderwater || !v107 )
4611 goto LABEL_197;
4612 if ( v127 && v129 > v123 )
4613 v44 = 0;
4614 if ( v118 && (signed int)v119 > v123 )
4615 v43 = 0;
4616 if ( v44 )
4617 goto LABEL_197;
4618 if ( v43 )
4619 goto LABEL_198;
4620 v127 = (BSPModel *)sub_46D49E_prolly_get_world_y_under_party(
4621 _angle_x,
4622 _angle_y,
4623 v40,
4624 pParty->uPartyHeight,
4625 &v130,
4626 &v108,
4627 0);
4628 if ( GetTerrainHeightsAroundParty(_angle_x, _angle_y) && (signed int)v127 <= v123 )
4629 {
4630 v43 = 1;
4631 LABEL_197:
4632 v116 = _angle_x;
4633 if ( !v43 )
4634 goto LABEL_199;
4635 LABEL_198:
4636 v117 = _angle_y;
4637 }
4638 LABEL_199:
4639 if ( stru_721530.field_7C >= stru_721530.field_6C )
4640 {
4641 if ( !v107 )
4642 {
4643 v116 = stru_721530.normal2.x;
4644 v117 = stru_721530.normal2.y;
4645 }
4646 v123 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
4647 break;
4648 }
4649 stru_721530.field_70 += stru_721530.field_7C;
4650 v116 = _angle_x;
4651 v117 = _angle_y;
4652 v45 = stru_721530.uFaceID;
4653 v123 = v40;
4654 if ( (stru_721530.uFaceID & 7) == 3 )
4655 {
4656 if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
4657 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) )
4658 pParty->pPartyBuffs[11].Reset();
4659 viewparams->bRedrawGameUI = 1;
4660 goto LABEL_234;
4661 }
4662 if ( (stru_721530.uFaceID & 7) == 5 )
4663 {
4664 v56 = sub_452A9E(v2 * v2 + v128 * v128);
4665 v118 = v56;
4666 v57 = stru_5C6E00->Atan2(
4667 _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
4668 _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
4669 v129 = v57;
4670 v58 = (BSPModel *)stru_5C6E00->SinCos(v57);
4671 v127 = v58;
4672 v59 = (signed int)v58 * (signed __int64)v56;
4673 v122 = v59 >> 16;
4674 v2 = v59 >> 16;
4675 v60 = (BSPModel *)stru_5C6E00->SinCos(v129 - stru_5C6E00->uIntegerHalfPi);
4676 v127 = v60;
4677 v61 = (signed int)v60 * (signed __int64)v118;
4678 v122 = v61 >> 16;
4679 v128 = v61 >> 16;
4680 }
4681 else
4682 {
4683 if ( (stru_721530.uFaceID & 7) == 6 )
4684 {
4685 pParty->bFlying = 0;
4686 v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
4687 v127 = v46;
4688 v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
4689 v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1;
4690 v51 = __OFSUB__(v48, 32);
4691 v49 = v48 == 32;
4692 v50 = v48 - 32 < 0;
4693 v52 = v47->pFacePlane.vNormal.z;
4694 v129 = (unsigned __int8)(v50 ^ v51 | v49);
4695 v119 = (Player **)(v52 < 46378);
4696 if ( bUnderwater == 1 )
4697 v119 = 0;
4698 v53 = v47->uPolygonType;
4699 if ( v53 == 3 )
4700 {
4701 if ( v121 < 0 )
4702 v121 = 0;
4703 v123 = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
4704 if ( v2 * v2 + v128 * v128 < 400 )
4705 {
4706 v2 = 0;
4707 *(float *)&v128 = 0.0;
4708 }
4709 goto LABEL_221;
4710 }
4711 if ( !v129 && (v53 != 4 || v119) )
4712 {
4713 v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
4714 if ( stru_721530.field_64 >> 3 > v118 )
4715 v118 = stru_721530.field_64 >> 3;
4716 v129 = v47->pFacePlane.vNormal.x;
4717 v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
4718 _walk_speed = v47->pFacePlane.vNormal.y;
4719 _walk_speed = (unsigned __int64)(v118 * (signed __int64)_walk_speed) >> 16;
4720 v54 = 0;
4721 if ( !v119 )
4722 {
4723 v127 = (BSPModel *)v47->pFacePlane.vNormal.z;
4724 v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
4725 v54 = v127;
4726 }
4727 v121 += (int)v54;
4728 v128 += _walk_speed;
4729 v2 += v129;
4730 v55 = stru_721530.prolly_normal_d
4731 - ((signed int)(v47->pFacePlane.dist
4732 + v122 * v47->pFacePlane.vNormal.z
4733 + _angle_y * v47->pFacePlane.vNormal.y
4734 + _angle_x * v47->pFacePlane.vNormal.x) >> 16);
4735 if ( v55 > 0 )
4736 {
4737 v116 = _angle_x + (v47->pFacePlane.vNormal.x * v55 >> 16);
4738 v117 = _angle_y + (v47->pFacePlane.vNormal.y * v55 >> 16);
4739 if ( !v119 )
4740 v123 = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
4741 }
4742 LABEL_220:
4743 v45 = stru_721530.uFaceID;
4744 LABEL_221:
4745 if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uFaceAttributes) & 4 )
4746 {
4747 pParty->field_6F4_packedid = v45;
4748 v103 = v47->sCogTriggeredID;
4749 }
4750 goto LABEL_234;
4751 }
4752 v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
4753 if ( stru_721530.field_64 >> 3 > v118 )
4754 v118 = stru_721530.field_64 >> 3;
4755 v122 = v47->pFacePlane.vNormal.x;
4756 v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
4757 v127 = (BSPModel *)v47->pFacePlane.vNormal.y;
4758 v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
4759 v129 = v47->pFacePlane.vNormal.z;
4760 v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
4761 v121 += v129;
4762 v2 += v122;
4763 v128 += (int)v127;
4764 if ( v2 * v2 + v128 * v128 >= 400 )
4765 goto LABEL_220;
4766 v2 = 0;
4767 v121 = 0;
4768 *(float *)&v128 = 0.0;
4769 }
4770 }
4771 LABEL_234:
4772 v2 = (unsigned __int64)(58500i64 * v2) >> 16;
4773 v127 = (BSPModel *)58500;
4774 v128 = (unsigned __int64)(58500i64 * v128) >> 16;
4775 v122 = (unsigned __int64)(58500i64 * v121) >> 16;
4776 ++v126;
4777 v121 = (unsigned __int64)(58500i64 * v121) >> 16;
4778 }
4779 while ( v126 < 100 );
4780 if ( bWalkSound && pParty->field_6F8 <= 0 )
4781 {
4782 v122 = abs(pParty->vPosition.x - v116);
4783 v126 = abs(pParty->vPosition.z - v117);
4784 v62 = abs(pParty->vPosition.y - v123);
4785 if ( sub_452A9E(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
4786 goto LABEL_344;
4787 if ( v114 && (!bJumping || v101) )
4788 {
4789 if ( !v107
4790 && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20) )
4791 {
4792 v96 = 0;
4793 v94 = 0;
4794 v92 = 0;
4795 v91 = 0;
4796 v90 = -1;
4797 v89 = 1;
4798 v88 = 804;
4799 v87 = 64;
4800 goto LABEL_257;
4801 }
4802 v96 = 0;
4803 v94 = 0;
4804 v92 = 0;
4805 v91 = 0;
4806 v90 = -1;
4807 v89 = 1;
4808 v88 = 804;
4809 v86 = 1;
4810 LABEL_255:
4811 v63 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
4812 v64 = WorldPosToGridCellX(pParty->vPosition.x);
4813 v87 = pOutdoor->_47EE49(v64, v63, v86);
4814 goto LABEL_257;
4815 }
4816 if ( v124 && (!bJumping || v101) )
4817 {
4818 if ( v107
4819 || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20 )
4820 {
4821 v96 = 0;
4822 v94 = 0;
4823 v92 = 0;
4824 v91 = 0;
4825 v90 = -1;
4826 v89 = 1;
4827 v88 = 804;
4828 v86 = 0;
4829 goto LABEL_255;
4830 }
4831 v96 = 0;
4832 v94 = 0;
4833 v92 = 0;
4834 v91 = 0;
4835 v90 = -1;
4836 v89 = 1;
4837 v88 = 804;
4838 v87 = 103;
4839 LABEL_257:
4840 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, v91, v92, v94, v96);
4841 }
4842 else
4843 {
4844 LABEL_344:
4845 pAudioPlayer->_4AA258(804);
4846 pParty->field_6F8 = 64;
4847 }
4848 }
4849 if ( !bJumping || v101 )
4850 pParty->uFlags &= 0xFFFFFFF7u;
4851 else
4852 pParty->uFlags |= 8u;
4853 v126 = WorldPosToGridCellX(pParty->vPosition.x);
4854 v65 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
4855 v114 = WorldPosToGridCellX(v116);
4856 v66 = WorldPosToGridCellZ(v117) - 1;
4857 v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
4858 v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
4859 v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
4860 v68 = 0;
4861 v69 = ((unsigned int)~v67 >> 1) & 1;
4862 if ( v114 == v126 && v66 == v65 && v122 && v69 )
4863 v68 = 1;
4864 if ( !v107 )
4865 v68 = 1;
4866 if ( v68 )
4867 {
4868 v70 = v123;
4869 v71 = v116;
4870 v72 = v117;
4871 pParty->uFallSpeed = v121;
4872 v73 = v123;
4873 pParty->vPosition.x = v116;
4874 pParty->vPosition.z = v117;
4875 pParty->vPosition.y = v123;
4876 pParty->field_6F0 = v113;
4877 if ( v123 > 8160 )
4878 {
4879 v73 = 8160;
4880 pParty->uFallStartY = 8160;
4881 pParty->vPosition.y = 8160;
4882 }
4883 if ( !v103
4884 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
4885 && pParty->vPosition.z == v72
4886 && (v73 = pParty->vPosition.y, pParty->vPosition.y == v70) )
4887 {
4888 if ( v73 < v111 )
4889 {
4890 pParty->uFallSpeed = 0;
4891 v73 = v105;
4892 pParty->vPosition.y = v105;
4893 if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
4894 {
4895 if ( pParty->uFlags & 0x100 )
4896 {
4897 BYTE1(pParty->uFlags) &= 0xFEu;
4898 }
4899 else
4900 {
4901 v74 = &pPlayers[1];
4902 do
4903 {
4904 v110 = (*v74)->GetMaxHealth();
4905 (*v74)->ReceiveDamage(
4906 (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
4907 4);
4908 v75 = (*v74)->GetActualEndurance();
4909 v110 = 20 - (*v74)->_48EA1B_get_static_effect(v75);
4910 (*v74)->SetRecoveryTime(
4911 (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
4912 ++v74;
4913 }
4914 while ( (signed int)v74 <= (signed int)&pPlayers[4] );
4915 v73 = pParty->vPosition.y;
4916 }
4917 }
4918 pParty->uFallStartY = v70;
4919 }
4920 if ( v102 && v73 < v109 )
4921 {
4922 if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
4923 {
4924 pParty->vPosition.y = v109 - pParty->uPartyHeight - 1;
4925 pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
4926 }
4927 }
4928 LOWORD(pParty->uFlags) &= 0xFDFBu;
4929 }
4930 return;
4931 }
4932 v76 = pParty->bFlying;
4933 if ( pParty->bFlying || v101 == 0 || bWaterWalk || !v127 )
4934 v77 = 1;
4935 else
4936 v77 = v122 != 0;
4937 v114 = 0;
4938 if ( !pParty->bFlying && v101 != 0 && !bWaterWalk )
4939 {
4940 if ( v127 )
4941 {
4942 v78 = v69 != 0;
4943 goto LABEL_306;
4944 }
4945 v114 = 1;
4946 }
4947 v78 = 1;
4948 LABEL_306:
4949 if ( v77 )
4950 {
4951 pParty->vPosition.x = v116;
4952 if ( !v78 )
4953 goto LABEL_313;
4954 goto LABEL_312;
4955 }
4956 if ( v78 )
4957 {
4958 LABEL_312:
4959 pParty->vPosition.z = v117;
4960 LABEL_313:
4961 if ( bWaterWalk )
4962 {
4963 LOBYTE(pParty->uFlags) &= 0x7Fu;
4964 v79 = 20 * pParty->pPartyBuffs[18].uOverlayID + 6180178;
4965 *(short *)&stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
4966 if ( !v122 || !v69 )
4967 {
4968 if ( !v76 )
4969 {
4970 v80 = *(short *)v79;
4971 LOBYTE(pParty->uFlags) |= 0x80u;
4972 *(short *)v79 = v80 & 0xFFFE;
4973 }
4974 }
4975 }
4976 goto LABEL_318;
4977 }
4978 if ( bWalkSound && pParty->field_6F8 <= 0 )
4979 {
4980 pAudioPlayer->_4AA258(804);
4981 pParty->field_6F8 = 64;
4982 }
4983 LABEL_318:
4984 v81 = v123;
4985 v82 = v123;
4986 pParty->vPosition.y = v123;
4987 if ( v123 > 8160 )
4988 {
4989 v82 = 8160;
4990 pParty->uFallStartY = 8160;
4991 pParty->vPosition.y = 8160;
4992 }
4993 LOWORD(pParty->uFlags) &= 0xFDFBu;
4994 pParty->uFallSpeed = v121;
4995 pParty->field_6F0 = v113;
4996 if ( v114 )
4997 {
4998 v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, &v110, 1);
4999 v82 = pParty->vPosition.y;
5000 if ( pParty->vPosition.y <= v83 )
5001 pParty->uFlags |= 4u;
5002 }
5003 if ( !v103
5004 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v116)
5005 && pParty->vPosition.z == v117
5006 && (v82 = pParty->vPosition.y, pParty->vPosition.y == v81) )
5007 {
5008 if ( v82 < v111 )
5009 {
5010 v82 = v105;
5011 pParty->uFallSpeed = 0;
5012 pParty->vPosition.y = v105;
5013 if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
5014 {
5015 if ( pParty->uFlags & 0x100 )
5016 {
5017 BYTE1(pParty->uFlags) &= 0xFEu;
5018 }
5019 else
5020 {
5021 v84 = &pPlayers[1];
5022 do
5023 {
5024 v110 = (*v84)->GetMaxHealth();
5025 (*v84)->ReceiveDamage(
5026 (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
5027 4);
5028 v85 = (*v84)->GetActualEndurance();
5029 v110 = 20 - (*v84)->_48EA1B_get_static_effect(v85);
5030 (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
5031 ++v84;
5032 }
5033 while ( (signed int)v84 <= (signed int)&pPlayers[4] );
5034 v82 = pParty->vPosition.y;
5035 }
5036 }
5037 pParty->uFallStartY = v81;
5038 }
5039 if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
5040 {
5041 pParty->vPosition.y = v82 + pParty->uPartyHeight - v109 + 1;
5042 pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
5043 }
5044 }
5045 }
5046
5047
5048
5049
5050
5051 //----- (0047531C) --------------------------------------------------------
5052 bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10)
5053 {
5054 BLVFace *v10; // ebx@1
5055 int v11; // ST1C_4@3
5056 int v12; // edi@3
5057 int v13; // esi@3
5058 int v14; // edi@4
5059 signed __int64 v15; // qtt@6
5060 __int16 v16; // si@7
5061 int *v18; // [sp+Ch] [bp-Ch]@1
5062 int v19; // [sp+10h] [bp-8h]@1
5063 int a7a; // [sp+30h] [bp+18h]@7
5064 int a9b; // [sp+38h] [bp+20h]@3
5065 int a9a; // [sp+38h] [bp+20h]@3
5066 int a10b; // [sp+3Ch] [bp+24h]@3
5067 signed int a10a; // [sp+3Ch] [bp+24h]@4
5068 int a10c; // [sp+3Ch] [bp+24h]@5
5069
5070 v10 = a9;
5071 v18 = a2;
5072 v19 = a1;
5073 if ( a10 && BYTE3(a9->uAttributes) & 0x20 )
5074 return 0;
5075 v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
5076 a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
5077 a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
5078 v12 = v11 + a9b + a10b;
5079 a9a = v11 + a9b + a10b;
5080 v13 = (a1 << 16)
5081 - a3 * v10->pFacePlane_old.vNormal.x
5082 - a4 * v10->pFacePlane_old.vNormal.y
5083 - a5 * v10->pFacePlane_old.vNormal.z
5084 - v10->pFacePlane_old.dist;
5085 if ( abs((a1 << 16)
5086 - a3 * v10->pFacePlane_old.vNormal.x
5087 - a4 * v10->pFacePlane_old.vNormal.y
5088 - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 )
5089 {
5090 a10c = abs(v13) >> 14;
5091 if ( a10c > abs(v12) )
5092 return 0;
5093 LODWORD(v15) = v13 << 16;
5094 HIDWORD(v15) = v13 >> 16;
5095 v14 = v19;
5096 a10a = v15 / a9a;
5097 }
5098 else
5099 {
5100 a10a = 0;
5101 v14 = abs(v13) >> 16;
5102 }
5103 v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16);
5104 LOWORD(a7a) = (short)a3
5105 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16)
5106 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16);
5107 HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16);
5108 if ( !sub_475665(
5109 v10,
5110 a7a,
5111 (short)a5
5112 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16)
5113 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) )
5114 return 0;
5115 *v18 = a10a >> 16;
5116 if ( a10a >> 16 < 0 )
5117 *v18 = 0;
5118 return 1;
5119 }
5120
5121 //----- (004754BF) --------------------------------------------------------
5122 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)
5123 {
5124 BLVFace *v11; // ebx@1
5125 int v12; // ST1C_4@3
5126 int v13; // edi@3
5127 int v14; // esi@3
5128 int v15; // edi@4
5129 signed __int64 v16; // qtt@6
5130 __int16 v17; // si@7
5131 int *v19; // [sp+Ch] [bp-Ch]@1
5132 int v20; // [sp+10h] [bp-8h]@1
5133 int a7a; // [sp+30h] [bp+18h]@7
5134 int a1b; // [sp+38h] [bp+20h]@3
5135 int a1a; // [sp+38h] [bp+20h]@3
5136 int a11b; // [sp+40h] [bp+28h]@3
5137 signed int a11a; // [sp+40h] [bp+28h]@4
5138 int a11c; // [sp+40h] [bp+28h]@5
5139
5140 v11 = a9;
5141 v19 = a2;
5142 v20 = a1;
5143 if ( a11 && BYTE3(a9->uAttributes) & 0x20 )
5144 return 0;
5145 v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
5146 a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
5147 a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
5148 v13 = v12 + a1b + a11b;
5149 a1a = v12 + a1b + a11b;
5150 v14 = (a1 << 16)
5151 - a3 * v11->pFacePlane_old.vNormal.x
5152 - a4 * v11->pFacePlane_old.vNormal.y
5153 - a5 * v11->pFacePlane_old.vNormal.z
5154 - v11->pFacePlane_old.dist;
5155 if ( abs((a1 << 16)
5156 - a3 * v11->pFacePlane_old.vNormal.x
5157 - a4 * v11->pFacePlane_old.vNormal.y
5158 - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 )
5159 {
5160 a11c = abs(v14) >> 14;
5161 if ( a11c > abs(v13) )
5162 return 0;
5163 LODWORD(v16) = v14 << 16;
5164 HIDWORD(v16) = v14 >> 16;
5165 v15 = v20;
5166 a11a = v16 / a1a;
5167 }
5168 else
5169 {
5170 a11a = 0;
5171 v15 = abs(v14) >> 16;
5172 }
5173 v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16);
5174 LOWORD(a7a) = (short)a3
5175 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16)
5176 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16);
5177 HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16);
5178 if ( !sub_4759C9(
5179 v11,
5180 a10,
5181 a7a,
5182 (short)a5
5183 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16)
5184 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) )
5185 return 0;
5186 *v19 = a11a >> 16;
5187 if ( a11a >> 16 < 0 )
5188 *v19 = 0;
5189 return 1;
5190 }
5191
5192
5193
5194 //----- (00475665) --------------------------------------------------------
5195 signed int __thiscall sub_475665(BLVFace *_this, int a2, __int16 a3)
5196 {
5197 unsigned int v3; // eax@1
5198 Vec3_short_ *v4; // edx@3
5199 signed int v5; // eax@4
5200 int v6; // esi@4
5201 signed int v7; // eax@7
5202 Vec3_short_ *v8; // edx@8
5203 signed int v9; // eax@9
5204 int v10; // esi@9
5205 signed int v11; // eax@11
5206 Vec3_short_ *v12; // edx@12
5207 signed int v13; // eax@13
5208 int v14; // esi@13
5209 int v15; // esi@14
5210 bool v16; // edi@14
5211 int v17; // ecx@16
5212 signed int v18; // edx@16
5213 int v19; // eax@17
5214 signed int v20; // ebx@18
5215 int v21; // edi@20
5216 signed int v22; // ST14_4@22
5217 signed __int64 v23; // qtt@22
5218 signed int result; // eax@25
5219 int v25; // [sp+14h] [bp-10h]@14
5220 int v26; // [sp+1Ch] [bp-8h]@2
5221 signed int v27; // [sp+20h] [bp-4h]@2
5222 signed int v28; // [sp+30h] [bp+Ch]@2
5223 signed int v29; // [sp+30h] [bp+Ch]@7
5224 signed int v30; // [sp+30h] [bp+Ch]@11
5225 signed int v31; // [sp+30h] [bp+Ch]@14
5226
5227 v3 = _this->uAttributes;
5228 if ( BYTE1(v3) & 1 )
5229 {
5230 v28 = 0;
5231 v26 = (signed __int16)a2;
5232 v27 = SHIWORD(a2);
5233 if ( _this->uNumVertices )
5234 {
5235 v4 = pIndoor->pVertices;
5236 do
5237 {
5238 v5 = v28;
5239 v6 = 2 * v28;
5240 word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x;
5241 word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y;
5242 word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1]
5243 + v4[_this->pVertexIDs[v5 + 1]].x;
5244 word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y;
5245 }
5246 while ( v28 < _this->uNumVertices );
5247 }
5248 }
5249 else
5250 {
5251 if ( BYTE1(v3) & 2 )
5252 {
5253 v26 = (signed __int16)a2;
5254 v7 = a3;
5255 v29 = 0;
5256 v27 = v7;
5257 if ( _this->uNumVertices )
5258 {
5259 v8 = pIndoor->pVertices;
5260 do
5261 {
5262 v9 = v29;
5263 v10 = 2 * v29;
5264 word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x;
5265 word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z;
5266 word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x;
5267 word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z;
5268 }
5269 while ( v29 < _this->uNumVertices );
5270 }
5271 }
5272 else
5273 {
5274 v26 = SHIWORD(a2);
5275 v11 = a3;
5276 v30 = 0;
5277 v27 = v11;
5278 if ( _this->uNumVertices )
5279 {
5280 v12 = pIndoor->pVertices;
5281 do
5282 {
5283 v13 = v30;
5284 v14 = 2 * v30;
5285 word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y;
5286 word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z;
5287 word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y;
5288 word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z;
5289 }
5290 while ( v30 < _this->uNumVertices );
5291 }
5292 }
5293 }
5294 v15 = 2 * _this->uNumVertices;
5295 v31 = 0;
5296 word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0];
5297 word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0];
5298 v25 = 0;
5299 v16 = word_720B40_intercepts_zs[0] >= v27;
5300 if ( v15 <= 0 )
5301 goto LABEL_29;
5302 do
5303 {
5304 if ( v31 >= 2 )
5305 break;
5306 v17 = v25;
5307 v18 = word_720B40_intercepts_zs[v25 + 1];
5308 if ( v16 ^ v18 >= v27 )
5309 {
5310 v19 = word_720C10_intercepts_xs[v17 + 1];
5311 if ( v19 >= v26 )
5312 v20 = 0;
5313 else
5314 v20 = 2;
5315 v21 = v20 | word_720C10_intercepts_xs[v17] < v26;
5316 if ( v21 != 3 )
5317 {
5318 if ( !v21
5319 || (v22 = v19 - word_720C10_intercepts_xs[v17],
5320 LODWORD(v23) = v22 << 16,
5321 HIDWORD(v23) = v22 >> 16,
5322 word_720C10_intercepts_xs[v17]
5323 + ((signed int)(((unsigned __int64)(v23
5324 / (v18 - word_720B40_intercepts_zs[v17])
5325 * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16)
5326 + 32768) >> 16) >= v26) )
5327 ++v31;
5328 }
5329 }
5330 ++v25;
5331 v16 = v18 >= v27;
5332 }
5333 while ( v25 < v15 );
5334 result = 1;
5335 if ( v31 != 1 )
5336 LABEL_29:
5337 result = 0;
5338 return result;
5339 }
5340
5341 //----- (004759C9) --------------------------------------------------------
5342 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
5343 {
5344 unsigned int v4; // eax@1
5345 int v5; // edx@4
5346 __int16 v6; // si@4
5347 int v7; // edx@9
5348 __int16 v8; // si@9
5349 int v9; // edx@13
5350 __int16 v10; // si@13
5351 int v11; // esi@14
5352 bool v12; // edi@14
5353 int v13; // ecx@16
5354 signed int v14; // edx@16
5355 int v15; // eax@17
5356 signed int v16; // ebx@18
5357 int v17; // edi@20
5358 signed int v18; // ST14_4@22
5359 signed __int64 v19; // qtt@22
5360 bool result; // eax@25
5361 int v21; // [sp+14h] [bp-10h]@14
5362 signed int v22; // [sp+18h] [bp-Ch]@1
5363 int v23; // [sp+1Ch] [bp-8h]@2
5364 signed int v24; // [sp+20h] [bp-4h]@2
5365 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
5366 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
5367 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
5368 signed int a4d; // [sp+30h] [bp+Ch]@14
5369
5370 v4 = a1->uAttributes;
5371 v22 = 0;
5372 if ( BYTE1(v4) & 1 )
5373 {
5374 v23 = (signed __int16)a3;
5375 v24 = SHIWORD(a3);
5376 if ( a1->uNumVertices )
5377 {
5378 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
5379 do
5380 {
5381 v5 = 2 * v22;
5382 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x);
5383 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y);
5384 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x);
5385 word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
5386 ++v22;
5387 }
5388 while ( v22 < a1->uNumVertices );
5389 }
5390 }
5391 else
5392 {
5393 if ( BYTE1(v4) & 2 )
5394 {
5395 v23 = (signed __int16)a3;
5396 v24 = a4;
5397 if ( a1->uNumVertices )
5398 {
5399 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
5400 do
5401 {
5402 v7 = 2 * v22;
5403 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x);
5404 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z);
5405 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x);
5406 word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
5407 ++v22;
5408 }
5409 while ( v22 < a1->uNumVertices );
5410 }
5411 }
5412 else
5413 {
5414 v23 = SHIWORD(a3);
5415 v24 = a4;
5416 if ( a1->uNumVertices )
5417 {
5418 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
5419 do
5420 {
5421 v9 = 2 * v22;
5422 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y);
5423 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z);
5424 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y);
5425 word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
5426 ++v22;
5427 }
5428 while ( v22 < a1->uNumVertices );
5429 }
5430 }
5431 }
5432 v11 = 2 * a1->uNumVertices;
5433 a4d = 0;
5434 word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
5435 word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0];
5436 v21 = 0;
5437 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
5438 if ( v11 <= 0 )
5439 goto LABEL_29;
5440 do
5441 {
5442 if ( a4d >= 2 )
5443 break;
5444 v13 = v21;
5445 v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1];
5446 if ( v12 ^ v14 >= v24 )
5447 {
5448 v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
5449 if ( v15 >= v23 )
5450 v16 = 0;
5451 else
5452 v16 = 2;
5453 v17 = v16 | word_720A70_intercepts_xs_plus_xs[v13] < v23;
5454 if ( v17 != 3 )
5455 {
5456 if ( !v17
5457 || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13],
5458 LODWORD(v19) = v18 << 16,
5459 HIDWORD(v19) = v18 >> 16,
5460 word_720A70_intercepts_xs_plus_xs[v13]
5461 + ((signed int)(((unsigned __int64)(v19
5462 / (v14 - word_7209A0_intercepts_ys_plus_ys[v13])
5463 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16)
5464 + 32768) >> 16) >= v23) )
5465 ++a4d;
5466 }
5467 }
5468 ++v21;
5469 v12 = v14 >= v24;
5470 }
5471 while ( v21 < v11 );
5472 result = 1;
5473 if ( a4d != 1 )
5474 LABEL_29:
5475 result = 0;
5476 return result;
5477 }
5478
5479 //----- (00475D85) --------------------------------------------------------
5480 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4)
5481 {
5482 BLVFace *v4; // ebx@1
5483 int v5; // ST24_4@2
5484 int v6; // ST28_4@2
5485 int v7; // edi@2
5486 int v8; // eax@5
5487 signed int v9; // esi@5
5488 signed __int64 v10; // qtt@10
5489 Vec3_int_ *v11; // esi@11
5490 int v12; // ST14_4@11
5491 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1
5492 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1
5493 int v16; // [sp+18h] [bp-Ch]@2
5494 int v17; // [sp+20h] [bp-4h]@10
5495 int a4b; // [sp+30h] [bp+Ch]@2
5496 int a4c; // [sp+30h] [bp+Ch]@9
5497 signed int a4a; // [sp+30h] [bp+Ch]@10
5498
5499 v4 = a4;
5500 v15 = a2;
5501 v14 = a1;
5502 if ( BYTE3(a4->uAttributes) & 0x20
5503 || (v5 = (unsigned __int64)(a2->x * (signed __int64)a4->pFacePlane_old.vNormal.x) >> 16,
5504 a4b = (unsigned __int64)(a2->y * (signed __int64)a4->pFacePlane_old.vNormal.y) >> 16,
5505 v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16,
5506 v7 = v5 + v6 + a4b,
5507 (v16 = v5 + v6 + a4b) == 0)
5508 || v7 > 0 && !(v4->uAttributes & 1) )
5509 return 0;
5510 v8 = v4->pFacePlane_old.vNormal.z * a1->z;
5511 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x);
5512 if ( v7 <= 0 )
5513 {
5514 if ( v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0 )
5515 return 0;
5516 }
5517 else
5518 {
5519 if ( v9 < 0 )
5520 return 0;
5521 }
5522 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14;
5523 if ( a4c > abs(v7)
5524 || (LODWORD(v10) = v9 << 16, HIDWORD(v10) = v9 >> 16, a4a = v10 / v16, v17 = v10 / v16, v17 > *a3 << 16)
5525 || (v11 = v14,
5526 LOWORD(v12) = LOWORD(v14->x)
5527 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->x) >> 16) + 32768) >> 16),
5528 HIWORD(v12) = LOWORD(v11->y)
5529 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->y) >> 16) + 32768) >> 16),
5530 !sub_475665(
5531 v4,
5532 v12,
5533 LOWORD(v11->z) + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->z) >> 16) + 32768) >> 16))) )
5534 return 0;
5535 *a3 = a4a >> 16;
5536 return 1;
5537 }
5538
5539 //----- (00475F30) --------------------------------------------------------
5540 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
5541 {
5542 BLVFace *v9; // ebx@1
5543 int v10; // ST20_4@2
5544 int v11; // ST28_4@2
5545 int v12; // ST24_4@2
5546 char v13; // zf@2
5547 int v14; // edi@2
5548 int v15; // eax@5
5549 signed int v16; // esi@5
5550 int v17; // ST20_4@9
5551 signed __int64 v18; // qtt@10
5552 int v19; // ST14_4@11
5553 int *v21; // [sp+14h] [bp-10h]@1
5554 int v22; // [sp+1Ch] [bp-8h]@2
5555 int v23; // [sp+1Ch] [bp-8h]@10
5556 signed int v24; // [sp+20h] [bp-4h]@10
5557
5558 v9 = a2;
5559 v21 = a1;
5560 if ( BYTE3(a2->uAttributes) & 0x20
5561 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
5562 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
5563 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
5564 v13 = v10 + v12 + v11 == 0,
5565 v14 = v10 + v12 + v11,
5566 v22 = v10 + v12 + v11,
5567 v13)
5568 || v14 > 0 && !(a2->uAttributes & 1) )
5569 return 0;
5570 v15 = a4 * a2->pFacePlane_old.vNormal.y;
5571 v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
5572 if ( v14 <= 0 )
5573 {
5574 if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
5575 return 0;
5576 }
5577 else
5578 {
5579 if ( v16 < 0 )
5580 return 0;
5581 }
5582 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
5583 if ( v17 > abs(v14)
5584 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16)
5585 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
5586 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
5587 !sub_4759C9(
5588 v9,
5589 a9,
5590 v19,
5591 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) )
5592 return 0;
5593 *v21 = v24 >> 16;
5594 return 1;
5595 }
5596
5597
5598
5599
5600
5601 //----- (004760D5) --------------------------------------------------------
5602 PartyAction ActionQueue::Next()
5603 {
5604 if (!uNumActions)
5605 return PARTY_INVALID;
5606
5607 auto result = pActions[0];
5608 for (unsigned int i = 0; i < uNumActions - 1; ++i)
5609 pActions[i] = pActions[i + 1];
5610 --uNumActions;
5611
5612 return result;
5613 }
5614
5615 //----- (00476387) --------------------------------------------------------
5616 bool __cdecl sub_476387()
5617 {
5618 return (pNPCStats->pNewNPCData[57].uFlags & 0x80) != 0;
5619 }
5620
5621 //----- (00476395) --------------------------------------------------------
5622 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
5623 {
5624 bool result; // eax@2
5625 signed int v2; // esi@3
5626 char *v3; // eax@4
5627
5628 if ( bNoNPCHiring == 1 )
5629 return 0;
5630 v2 = 0;
5631 if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
5632 {
5633 LABEL_8:
5634 result = 0;
5635 if ( pParty->pHirelings[0].uProfession != uProfession )
5636 {
5637 LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
5638 return result;
5639 }
5640 }
5641 else
5642 {
5643 v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
5644 while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
5645 {
5646 ++v2;
5647 v3 += 76;
5648 if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
5649 goto LABEL_8;
5650 }
5651 result = 0;
5652 }
5653 ++result;
5654 return result;
5655 }
5656 // 6BE3C5: using guessed type char bNoNPCHiring;
5657
5658 //----- (004763E0) --------------------------------------------------------
5659 void __cdecl InitializeAwards()
5660 {
5661 char *v0; // ebx@1
5662 char *v1; // eax@4
5663 char v2; // dl@5
5664 char *v3; // ecx@5
5665 int v4; // esi@9
5666 signed int v5; // [sp+Ch] [bp-Ch]@4
5667 char *v6; // [sp+10h] [bp-8h]@4
5668 Award *v7; // [sp+14h] [bp-4h]@3
5669
5670 v0 = 0;
5671 if ( pAwardsTXT_Raw )
5672 pAllocator->FreeChunk(pAwardsTXT_Raw);
5673 pAwardsTXT_Raw = 0;
5674 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
5675 strtok(pAwardsTXT_Raw, "\r");
5676 v7 = pAwards;
5677 do
5678 {
5679 v1 = strtok(v0, "\r") + 1;
5680 v6 = v0;
5681 v5 = (signed int)v0;
5682 do
5683 {
5684 v2 = *v1;
5685 v3 = 0;
5686 if ( *v1 != 9 )
5687 {
5688 v0 = 0;
5689 do
5690 {
5691 if ( !v2 )
5692 break;
5693 ++v3;
5694 v2 = v1[(int)v3];
5695 }
5696 while ( v2 != 9 );
5697 }
5698 v4 = (int)&v1[(int)v3];
5699 if ( v1[(int)v3] == (char)v0 )
5700 v5 = 1;
5701 *(char *)v4 = (char)v0;
5702 if ( v3 == v0 )
5703 {
5704 v5 = 1;
5705 }
5706 else
5707 {
5708 if ( v6 == (char *)1 )
5709 {
5710 v7->pText = RemoveQuotes(v1);
5711 }
5712 else
5713 {
5714 if ( v6 == (char *)2 )
5715 v7->uSort = atoi(v1);
5716 }
5717 }
5718 ++v6;
5719 v1 = (char *)(v4 + 1);
5720 }
5721 while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 );
5722 ++v7;
5723 }
5724 while ( (signed int)v7 < (signed int)&dword_7241C8 );
5725 }
5726 // 7241C8: using guessed type int dword_7241C8;
5727
5728 //----- (004764C2) --------------------------------------------------------
5729 void __cdecl InitializeScrolls()
5730 {
5731 char *v0; // ebx@1
5732 char *v1; // eax@4
5733 int v2; // edi@4
5734 char v3; // dl@5
5735 char *v4; // ecx@5
5736 int v5; // esi@9
5737 const char **v6; // [sp+10h] [bp-8h]@3
5738 signed int v7; // [sp+14h] [bp-4h]@4
5739
5740 v0 = 0;
5741 if ( pScrollsTXT_Raw )
5742 pAllocator->FreeChunk(pScrollsTXT_Raw);
5743 pScrollsTXT_Raw = 0;
5744 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
5745 strtok(pScrollsTXT_Raw, "\r");
5746 v6 = pScrolls;
5747 do
5748 {
5749 v1 = strtok(v0, "\r") + 1;
5750 v2 = 0;
5751 v7 = (signed int)v0;
5752 do
5753 {
5754 v3 = *v1;
5755 v4 = 0;
5756 if ( *v1 != 9 )
5757 {
5758 v0 = 0;
5759 do
5760 {
5761 if ( !v3 )
5762 break;
5763 ++v4;
5764 v3 = v1[(int)v4];
5765 }
5766 while ( v3 != 9 );
5767 }
5768 v5 = (int)&v1[(int)v4];
5769 if ( v1[(int)v4] == (char)v0 )
5770 v7 = 1;
5771 *(char *)v5 = (char)v0;
5772 if ( v4 == v0 )
5773 {
5774 v7 = 1;
5775 }
5776 else
5777 {
5778 if ( v2 == 1 )
5779 *v6 = RemoveQuotes(v1);
5780 }
5781 ++v2;
5782 v1 = (char *)(v5 + 1);
5783 }
5784 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
5785 ++v6;
5786 }
5787 while ( (signed int)v6 < (signed int)dword_723E80_award_related );
5788 }
5789 // 723E80: using guessed type int dword_723E80_award_related[];
5790
5791 //----- (00476590) --------------------------------------------------------
5792 void __cdecl InitializeMerchants()
5793 {
5794 char *v0; // ebx@1
5795 char **v1; // edi@3
5796 char *v2; // ecx@4
5797 char v3; // dl@5
5798 char *v4; // eax@5
5799 int v5; // esi@9
5800 signed int v6; // [sp+Ch] [bp-8h]@4
5801 char *v7; // [sp+10h] [bp-4h]@4
5802
5803 v0 = 0;
5804 if ( pMerchantsTXT_Raw )
5805 pAllocator->FreeChunk(pMerchantsTXT_Raw);
5806 pMerchantsTXT_Raw = 0;
5807 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
5808 strtok(pMerchantsTXT_Raw, "\r");
5809 v1 = (char **)pMerchantsRepairPhrases;
5810 do
5811 {
5812 v7 = v0;
5813 v6 = (signed int)v0;
5814 v2 = strtok(v0, "\r") + 1;
5815 do
5816 {
5817 v3 = *v2;
5818 v4 = 0;
5819 if ( *v2 != 9 )
5820 {
5821 v0 = 0;
5822 do
5823 {
5824 if ( !v3 )
5825 break;
5826 ++v4;
5827 v3 = v2[(int)v4];
5828 }
5829 while ( v3 != 9 );
5830 }
5831 v5 = (int)&v2[(int)v4];
5832 if ( v2[(int)v4] == (char)v0 )
5833 v6 = 1;
5834 *(char *)v5 = (char)v0;
5835 if ( v4 == v0 )
5836 {
5837 v6 = 1;
5838 }
5839 else
5840 {
5841 if ( v7 == (char *)1 )
5842 {
5843 *(v1 - 14) = RemoveQuotes(v2);
5844 }
5845 else
5846 {
5847 if ( v7 == (char *)2 )
5848 {
5849 *(v1 - 7) = RemoveQuotes(v2);
5850 }
5851 else
5852 {
5853 if ( v7 == (char *)3 )
5854 {
5855 *v1 = RemoveQuotes(v2);
5856 }
5857 else
5858 {
5859 if ( v7 - 3 == (char *)1 )
5860 v1[7] = RemoveQuotes(v2);
5861 }
5862 }
5863 }
5864 }
5865 ++v7;
5866 v2 = (char *)(v5 + 1);
5867 }
5868 while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 );
5869 ++v1;
5870 }
5871 while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases );
5872 }
5873
5874 //----- (00476682) --------------------------------------------------------
5875 void __cdecl InitializeTransitions()
5876 {
5877 char *v0; // ebx@1
5878 char *v1; // eax@4
5879 int v2; // edi@4
5880 char v3; // dl@5
5881 char *v4; // ecx@5
5882 int v5; // esi@9
5883 char **v6; // [sp+10h] [bp-8h]@3
5884 signed int v7; // [sp+14h] [bp-4h]@4
5885
5886 v0 = 0;
5887 if ( pTransitionsTXT_Raw )
5888 pAllocator->FreeChunk(pTransitionsTXT_Raw);
5889 pTransitionsTXT_Raw = 0;
5890 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
5891 strtok(pTransitionsTXT_Raw, "\r");
5892 v6 = pTransitionStrings;
5893 do
5894 {
5895 v1 = strtok(v0, "\r") + 1;
5896 v2 = 0;
5897 v7 = (signed int)v0;
5898 do
5899 {
5900 v3 = *v1;
5901 v4 = 0;
5902 if ( *v1 != 9 )
5903 {
5904 v0 = 0;
5905 do
5906 {
5907 if ( !v3 )
5908 break;
5909 ++v4;
5910 v3 = v1[(int)v4];
5911 }
5912 while ( v3 != 9 );
5913 }
5914 v5 = (int)&v1[(int)v4];
5915 if ( v1[(int)v4] == (char)v0 )
5916 v7 = 1;
5917 *(char *)v5 = (char)v0;
5918 if ( v4 == v0 )
5919 {
5920 v7 = 1;
5921 }
5922 else
5923 {
5924 if ( v2 == 1 )
5925 *v6 = (char *)RemoveQuotes(v1);
5926 }
5927 ++v2;
5928 v1 = (char *)(v5 + 1);
5929 }
5930 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
5931 ++v6;
5932 }
5933 while ( (signed int)v6 < (signed int)"awards.txt" );
5934 }
5935
5936 //----- (00476750) --------------------------------------------------------
5937 void __cdecl InitializeAutonotes()
5938 {
5939 char *v0; // ebp@3
5940 int v1; // ebx@4
5941 char *v2; // esi@4
5942 char v3; // cl@5
5943 int v4; // eax@5
5944 int v5; // edi@9
5945 signed int v6; // [sp+0h] [bp-4h]@4
5946
5947 if ( pAutonoteTXT_Raw )
5948 pAllocator->FreeChunk(pAutonoteTXT_Raw);
5949 pAutonoteTXT_Raw = 0;
5950 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
5951 strtok(pAutonoteTXT_Raw, "\r");
5952 v0 = (char *)&stru_723720[0].eType;
5953 do
5954 {
5955 v1 = 0;
5956 v2 = strtok(0, "\r") + 1;
5957 v6 = 0;
5958 do
5959 {
5960 v3 = *v2;
5961 v4 = 0;
5962 while ( v3 != 9 && v3 )
5963 {
5964 ++v4;
5965 v3 = v2[v4];
5966 }
5967 v5 = (int)&v2[v4];
5968 if ( !v2[v4] )
5969 v6 = 1;
5970 *(char *)v5 = 0;
5971 if ( v4 )
5972 {
5973 if ( v1 == 1 )
5974 {
5975 *((int *)v0 - 1) = (int)RemoveQuotes(v2);
5976 }
5977 else
5978 {
5979 if ( v1 == 2 )
5980 {
5981 if ( _strcmpi(v2, "potion") )
5982 {
5983 if ( _strcmpi(v2, "stat") )
5984 {
5985 if ( _strcmpi(v2, "seer") )
5986 {
5987 if ( _strcmpi(v2, "obelisk") )
5988 *(int *)v0 = 5 - (_strcmpi(v2, "teacher") != 0);
5989 else
5990 *(int *)v0 = 2;
5991 }
5992 else
5993 {
5994 *(int *)v0 = 3;
5995 }
5996 }
5997 else
5998 {
5999 *(int *)v0 = 1;
6000 }
6001 }
6002 else
6003 {
6004 *(int *)v0 = 0;
6005 }
6006 }
6007 }
6008 }
6009 else
6010 {
6011 v6 = 1;
6012 }
6013 ++v1;
6014 v2 = (char *)(v5 + 1);
6015 }
6016 while ( v1 - 1 <= 2 && !v6 );
6017 v0 += 8;
6018 }
6019 while ( (signed int)v0 < (signed int)&pScrolls[1] );
6020 }
6021 // 723720: using guessed type Autonote stru_723720[195];
6022
6023 //----- (004768A9) --------------------------------------------------------
6024 void __cdecl InitializeQuests()
6025 {
6026 char *v0; // ebx@1
6027 char *v1; // eax@4
6028 int v2; // edi@4
6029 char v3; // dl@5
6030 char *v4; // ecx@5
6031 int v5; // esi@9
6032 const char **v6; // [sp+10h] [bp-8h]@3
6033 signed int v7; // [sp+14h] [bp-4h]@4
6034
6035 v0 = 0;
6036 if ( pQuestsTXT_Raw )
6037 pAllocator->FreeChunk(pQuestsTXT_Raw);
6038 pQuestsTXT_Raw = 0;
6039 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
6040 strtok(pQuestsTXT_Raw, "\r");
6041 v6 = pQuestTable;
6042 do
6043 {
6044 v1 = strtok(v0, "\r") + 1;
6045 v2 = 0;
6046 v7 = (signed int)v0;
6047 do
6048 {
6049 v3 = *v1;
6050 v4 = 0;
6051 if ( *v1 != '\t' )
6052 {
6053 v0 = 0;
6054 do
6055 {
6056 if ( !v3 )
6057 break;
6058 ++v4;
6059 v3 = v1[(int)v4];
6060 }
6061 while ( v3 != '\t' );
6062 }
6063 v5 = (int)&v1[(int)v4];
6064 if ( v1[(int)v4] == (char)v0 )
6065 v7 = 1;
6066 *(char *)v5 = (char)v0;
6067 if ( v4 == v0 )
6068 {
6069 v7 = 1;
6070 }
6071 else
6072 {
6073 if ( v2 == 1 )
6074 *v6 = RemoveQuotes(v1);
6075 }
6076 ++v2;
6077 v1 = (char *)(v5 + 1);
6078 }
6079 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
6080 ++v6;
6081 }
6082 while ( (signed int)v6 < (signed int)&unk_723714 );
6083 }
6084
6085
6086
6087 //----- (00476977) --------------------------------------------------------
6088 void NPCStats::Initialize2()
6089 {
6090 NPCStats *v1; // esi@1
6091 char *v2; // ebx@1
6092 char *v3; // eax@3
6093 char *v4; // eax@4
6094 char v5; // dl@5
6095 char *v6; // ecx@5
6096 int v7; // edi@9
6097 char *v8; // eax@20
6098 char *v9; // eax@21
6099 char v10; // dl@22
6100 char *v11; // ecx@22
6101 int v12; // edi@26
6102 char *v13; // eax@37
6103 char *v14; // eax@39
6104 char v15; // dl@40
6105 int v16; // ecx@40
6106 int v17; // edi@44
6107 char v18; // zf@47
6108 NPCStats_stru0 *v19; // eax@57
6109 signed int v20; // edx@57
6110 signed int v21; // ecx@58
6111 char *v22; // [sp+10h] [bp-10h]@4
6112 char *v23; // [sp+10h] [bp-10h]@21
6113 char *v24; // [sp+10h] [bp-10h]@39
6114 char *v25; // [sp+14h] [bp-Ch]@4
6115 char *v26; // [sp+14h] [bp-Ch]@21
6116 signed int v27; // [sp+14h] [bp-Ch]@39
6117 signed int v28; // [sp+18h] [bp-8h]@3
6118 signed int v29; // [sp+18h] [bp-8h]@20
6119 signed int v30; // [sp+18h] [bp-8h]@37
6120 char *v31; // [sp+1Ch] [bp-4h]@37
6121
6122 v1 = this;
6123 v2 = 0;
6124 if ( this->pNPCTextTXT_Raw )
6125 pAllocator->FreeChunk(this->pNPCTextTXT_Raw);
6126 v1->pNPCTextTXT_Raw = 0;
6127 v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
6128 v1->pNPCTextTXT_Raw = v3;
6129 strtok(v3, "\r");
6130 v28 = (signed int)&unk_72166C_pNPCText;
6131 do
6132 {
6133 v4 = strtok(v2, "\r") + 1;
6134 v22 = v2;
6135 v25 = v2;
6136 do
6137 {
6138 v5 = *v4;
6139 v6 = 0;
6140 if ( *v4 != 9 )
6141 {
6142 do
6143 {
6144 if ( !v5 )
6145 break;
6146 ++v6;
6147 v5 = v4[(int)v6];
6148 }
6149 while ( v5 != 9 );
6150 v2 = 0;
6151 }
6152 v7 = (int)&v4[(int)v6];
6153 if ( !v4[(int)v6] )
6154 v25 = (char *)1;
6155 *(char *)v7 = 0;
6156 if ( v6 == v2 )
6157 {
6158 v25 = (char *)1;
6159 }
6160 else
6161 {
6162 if ( v22 == (char *)1 )
6163 *(int *)v28 = (int)RemoveQuotes(v4);
6164 }
6165 ++v22;
6166 v4 = (char *)(v7 + 1);
6167 }
6168 while ( (signed int)(v22 - 1) <= 1 && v25 == v2 );
6169 v28 += 8;
6170 }
6171 while ( v28 < (signed int)pQuestTable );
6172 if ( v1->pNPCTopicTXT_Raw != v2 )
6173 pAllocator->FreeChunk(v1->pNPCTopicTXT_Raw);
6174 v1->pNPCTopicTXT_Raw = v2;
6175 v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2);
6176 v1->pNPCTopicTXT_Raw = v8;
6177 strtok(v8, "\r");
6178 v29 = (signed int)&unk_721668_pNPCTopic;
6179 do
6180 {
6181 v9 = strtok(v2, "\r") + 1;
6182 v23 = v2;
6183 v26 = v2;
6184 do
6185 {
6186 v10 = *v9;
6187 v11 = 0;
6188 if ( *v9 != 9 )
6189 {
6190 do
6191 {
6192 if ( !v10 )
6193 break;
6194 ++v11;
6195 v10 = v9[(int)v11];
6196 }
6197 while ( v10 != 9 );
6198 v2 = 0;
6199 }
6200 v12 = (int)&v9[(int)v11];
6201 if ( !v9[(int)v11] )
6202 v26 = (char *)1;
6203 *(char *)v12 = 0;
6204 if ( v11 == v2 )
6205 {
6206 v26 = (char *)1;
6207 }
6208 else
6209 {
6210 if ( v23 == (char *)1 )
6211 *(int *)v29 = (int)RemoveQuotes(v9);
6212 }
6213 ++v23;
6214 v9 = (char *)(v12 + 1);
6215 }
6216 while ( (signed int)(v23 - 1) <= 1 && v26 == v2 );
6217 v29 += 8;
6218 }
6219 while ( v29 < (signed int)&unk_722880 );
6220 if ( v1->pNPCDistTXT_Raw != v2 )
6221 pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
6222 v1->pNPCDistTXT_Raw = v2;
6223 v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2);
6224 v1->pNPCDistTXT_Raw = v13;
6225 strtok(v13, "\r");
6226 strtok(v2, "\r");
6227 v30 = 1;
6228 v31 = &v1->array_16544[0].field_4[1];
6229 while ( 2 )
6230 {
6231 v14 = strtok(v2, "\r") + 1;
6232 v27 = 0;
6233 v24 = v2;
6234 do
6235 {
6236 v15 = *v14;
6237 v16 = 0;
6238 if ( *v14 != 9 )
6239 {
6240 do
6241 {
6242 if ( !v15 )
6243 break;
6244 ++v16;
6245 v15 = v14[v16];
6246 }
6247 while ( v15 != 9 );
6248 v2 = v24;
6249 }
6250 v17 = (int)&v14[v16];
6251 if ( !v14[v16] )
6252 v27 = 1;
6253 *(char *)v17 = 0;
6254 if ( !v16 )
6255 {
6256 v27 = 1;
6257 goto LABEL_54;
6258 }
6259 v18 = v2 == 0;
6260 if ( (signed int)v2 > 0 )
6261 {
6262 if ( (signed int)v2 < 77 )
6263 {
6264 v1->array_16544[(int)v2].field_4[v30] = atoi(v14);
6265 goto LABEL_54;
6266 }
6267 v18 = v2 == 0;
6268 }
6269 if ( v18 )
6270 *v31 = 10;
6271 LABEL_54:
6272 ++v2;
6273 v14 = (char *)(v17 + 1);
6274 v24 = v2;
6275 }
6276 while ( (signed int)(v2 - 1) <= 77 && !v27 );
6277 ++v30;
6278 ++v31;
6279 if ( v30 < 59 )
6280 {
6281 v2 = 0;
6282 continue;
6283 }
6284 break;
6285 }
6286 v19 = v1->array_16544;
6287 v20 = 77;
6288 do
6289 {
6290 v19->field_0 = 0;
6291 v21 = 1;
6292 do
6293 v19->field_0 += v19->field_4[v21++];
6294 while ( v21 < 59 );
6295 ++v19;
6296 --v20;
6297 }
6298 while ( v20 );
6299 if ( v1->pNPCDistTXT_Raw )
6300 {
6301 pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
6302 v1->pNPCDistTXT_Raw = 0;
6303 }
6304 }
6305
6306 //----- (00476C60) --------------------------------------------------------
6307 void NPCStats::_476C60()
6308 {
6309 signed int v1; // esi@1
6310 NPCData *v2; // edx@2
6311 char **v3; // eax@2
6312
6313 v1 = 1;
6314 if ( (signed int)this->uNumNewNPCs > 1 )
6315 {
6316 v2 = &this->pNewNPCData[1];
6317 v3 = this->pNPCNames2;
6318 do
6319 {
6320 ++v1;
6321 v2->pName = *v3;
6322 ++v3;
6323 ++v2;
6324 }
6325 while ( v1 < (signed int)this->uNumNewNPCs );
6326 }
6327 if ( pParty->pHirelings[0].pName )
6328 pParty->pHirelings[0].pName = pParty->pHireling1Name;
6329 if ( pParty->pHirelings[1].pName )
6330 pParty->pHirelings[1].pName = pParty->pHireling2Name;
6331 }
6332
6333 //----- (00476CB5) --------------------------------------------------------
6334 void NPCStats::Initialize1()
6335 {
6336 NPCStats *v1; // esi@1
6337 char *v2; // eax@1
6338 char *v3; // edi@1
6339 char *v4; // eax@2
6340 char v5; // dl@3
6341 int v6; // ecx@3
6342 char *v7; // eax@11
6343 char *v8; // eax@26
6344 char *v9; // ecx@27
6345 char v10; // dl@28
6346 int v11; // eax@28
6347 int v12; // edi@32
6348 char *v13; // eax@42
6349 char *v14; // eax@43
6350 char v15; // dl@44
6351 int v16; // ecx@44
6352 int v17; // edi@48
6353 char *v18; // eax@56
6354 char *v19; // eax@57
6355 char v20; // cl@58
6356 int v21; // edi@58
6357 int v22; // esi@62
6358 int v23; // [sp+Ch] [bp-14h]@7
6359 signed int v24; // [sp+10h] [bp-10h]@1
6360 signed int v25; // [sp+10h] [bp-10h]@26
6361 signed int v26; // [sp+10h] [bp-10h]@42
6362 signed int v27; // [sp+10h] [bp-10h]@56
6363 char *Str; // [sp+14h] [bp-Ch]@1
6364 NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26
6365 unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42
6366 char **pCatchPhrase; // [sp+14h] [bp-Ch]@56
6367 signed int v32; // [sp+18h] [bp-8h]@2
6368 signed int v33; // [sp+18h] [bp-8h]@27
6369 signed int v34; // [sp+18h] [bp-8h]@43
6370 signed int v35; // [sp+18h] [bp-8h]@57
6371 signed int v36; // [sp+1Ch] [bp-4h]@2
6372 signed int v37; // [sp+1Ch] [bp-4h]@27
6373 signed int v38; // [sp+1Ch] [bp-4h]@43
6374 signed int v39; // [sp+1Ch] [bp-4h]@57
6375
6376 v1 = this;
6377 v2 = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
6378 v1->pNPCDataTXT_Raw = v2;
6379 strtok(v2, "\r");
6380 strtok(0, "\r");
6381 v3 = (char *)&v1->pNPCData[1].house;
6382 Str = (char *)v1->pNPCNames2;
6383 v24 = 500;
6384 do
6385 {
6386 v32 = 0;
6387 v4 = strtok(0, "\r") + 1;
6388 v36 = -1;
6389 do
6390 {
6391 v5 = *v4;
6392 v6 = 0;
6393 while ( v5 != 9 && v5 )
6394 {
6395 ++v6;
6396 v5 = v4[v6];
6397 }
6398 v23 = (int)&v4[v6];
6399 if ( !v4[v6] )
6400 v32 = 1;
6401 v4[v6] = 0;
6402 if ( v6 )
6403 {
6404 switch ( v36 )
6405 {
6406 case 0:
6407 v7 = RemoveQuotes(v4);
6408 *((int *)v3 - 5) = (int)v7;
6409 *(int *)Str = (int)v7;
6410 break;
6411 case 1:
6412 *((int *)v3 - 4) = atoi(v4);
6413 break;
6414 case 5:
6415 *(int *)v3 = atoi(v4);
6416 break;
6417 case 6:
6418 *((int *)v3 + 1) = atoi(v4);
6419 break;
6420 case 7:
6421 *((int *)v3 + 2) = atoi(v4);
6422 break;
6423 case 8:
6424 *((int *)v3 + 3) = *v4 == 121;
6425 break;
6426 case 9:
6427 *((int *)v3 + 5) = atoi(v4);
6428 break;
6429 case 10:
6430 *((int *)v3 + 6) = atoi(v4);
6431 break;
6432 case 11:
6433 *((int *)v3 + 7) = atoi(v4);
6434 break;
6435 case 12:
6436 *((int *)v3 + 8) = atoi(v4);
6437 break;
6438 case 13:
6439 *((int *)v3 + 9) = atoi(v4);
6440 break;
6441 case 14:
6442 *((int *)v3 + 10) = atoi(v4);
6443 break;
6444 default:
6445 break;
6446 }
6447 }
6448 ++v36;
6449 v4 = (char *)(v23 + 1);
6450 }
6451 while ( v36 + 1 <= 15 && !v32 );
6452 Str += 4;
6453 v3 += 76;
6454 --v24;
6455 }
6456 while ( v24 );
6457 v1->uNumNewNPCs = 501;
6458 v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
6459 v1->pNPCGreetTXT_Raw = v8;
6460 strtok(v8, "\r");
6461 pGreetings = v1->pNPCGreetings;
6462 v25 = 205;
6463 do
6464 {
6465 v37 = 0;
6466 v33 = 0;
6467 v9 = strtok(0, "\r") + 1;
6468 do
6469 {
6470 v10 = *v9;
6471 v11 = 0;
6472 while ( v10 != 9 && v10 )
6473 {
6474 ++v11;
6475 v10 = v9[v11];
6476 }
6477 v12 = (int)&v9[v11];
6478 if ( !v9[v11] )
6479 v33 = 1;
6480 *(char *)v12 = 0;
6481 if ( v11 )
6482 {
6483 if ( v37 == 1 )
6484 {
6485 pGreetings->pGreeting1 = (char *)RemoveQuotes(v9);
6486 }
6487 else
6488 {
6489 if ( v37 == 2 )
6490 pGreetings->pGreeting2 = (char *)RemoveQuotes(v9);
6491 }
6492 }
6493 ++v37;
6494 v9 = (char *)(v12 + 1);
6495 }
6496 while ( v37 <= 2 && !v33 );
6497 ++pGreetings;
6498 --v25;
6499 }
6500 while ( v25 );
6501 v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
6502 v1->pNCPGroupTXT_Raw = v13;
6503 strtok(v13, "\r");
6504 pGroups = v1->pGroups;
6505 v26 = 51;
6506 do
6507 {
6508 v14 = strtok(0, "\r") + 1;
6509 v38 = 0;
6510 v34 = 0;
6511 do
6512 {
6513 v15 = *v14;
6514 v16 = 0;
6515 while ( v15 != 9 && v15 )
6516 {
6517 ++v16;
6518 v15 = v14[v16];
6519 }
6520 v17 = (int)&v14[v16];
6521 if ( !v14[v16] )
6522 v34 = 1;
6523 *(char *)v17 = 0;
6524 if ( v16 && v38 == 1 )
6525 *pGroups = atoi(v14);
6526 ++v38;
6527 v14 = (char *)(v17 + 1);
6528 }
6529 while ( v38 <= 1 && !v34 );
6530 ++pGroups;
6531 --v26;
6532 }
6533 while ( v26 );
6534 v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0);
6535 v1->pNPCNewsTXT_Raw = v18;
6536 strtok(v18, "\r");
6537 pCatchPhrase = v1->pCatchPhrases;
6538 v27 = 51;
6539 do
6540 {
6541 v19 = strtok(0, "\r") + 1;
6542 v39 = 0;
6543 v35 = 0;
6544 do
6545 {
6546 v20 = *v19;
6547 v21 = 0;
6548 while ( v20 != 9 && v20 )
6549 {
6550 ++v21;
6551 v20 = v19[v21];
6552 }
6553 v22 = (int)&v19[v21];
6554 if ( !v19[v21] )
6555 v35 = 1;
6556 *(char *)v22 = 0;
6557 if ( v21 && v39 == 1 )
6558 *pCatchPhrase = (char *)RemoveQuotes(v19);
6559 ++v39;
6560 v19 = (char *)(v22 + 1);
6561 }
6562 while ( v39 <= 1 && !v35 );
6563 ++pCatchPhrase;
6564 --v27;
6565 }
6566 while ( v27 );
6567 }
6568
6569 //----- (0047702F) --------------------------------------------------------
6570 void NPCStats::Initialize()
6571 {
6572 NPCStats *v1; // edi@1
6573 char *v2; // ebx@1
6574 char *v3; // eax@1
6575 char *v4; // ebx@3
6576 char v5; // al@4
6577 int v6; // ecx@4
6578 char *v7; // eax@18
6579 char *v8; // ebx@18
6580 char *v9; // ecx@19
6581 char v10; // dl@20
6582 int v11; // eax@20
6583 char v12; // zf@41
6584 signed int v13; // [sp+Ch] [bp-14h]@18
6585 int v14; // [sp+10h] [bp-10h]@4
6586 int v15; // [sp+10h] [bp-10h]@24
6587 char *v16; // [sp+14h] [bp-Ch]@1
6588 signed int v17; // [sp+14h] [bp-Ch]@19
6589 unsigned int v18; // [sp+18h] [bp-8h]@1
6590 char *v19; // [sp+18h] [bp-8h]@18
6591 signed int v20; // [sp+1Ch] [bp-4h]@3
6592 signed int v21; // [sp+1Ch] [bp-4h]@19
6593
6594 v1 = this;
6595
6596 Initialize1();
6597 Initialize2();
6598
6599 InitializeQuests();
6600 InitializeAutonotes();
6601 InitializeAwards();
6602 InitializeTransitions();
6603 InitializeMerchants();
6604 InitializeScrolls();
6605 v2 = 0;
6606 v1->field_17FC0 = 0;
6607 v1->pNPCNamesTXT_Raw = 0;
6608 v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
6609 v1->pNPCNamesTXT_Raw = v3;
6610 strtok(v3, "\r");
6611 v18 = 0;
6612 v16 = (char *)v1->pNPCNames;
6613 while ( 1 )
6614 {
6615 v4 = strtok(v2, "\r") + 1;
6616 v20 = 0;
6617 do
6618 {
6619 v5 = *v4;
6620 v6 = 0;
6621 v14 = 0;
6622 if ( *v4 == 9 )
6623 goto LABEL_45;
6624 do
6625 {
6626 if ( !v5 )
6627 break;
6628 if ( v5 == 10 )
6629 break;
6630 ++v6;
6631 v14 = v6;
6632 v5 = v4[v6];
6633 }
6634 while ( v5 != 9 );
6635 if ( v6 )
6636 {
6637 v4[v6] = 0;
6638 if ( v20 )
6639 {
6640 if ( v20 == 1 )
6641 *((int *)v16 + 1) = (int)RemoveQuotes(v4);
6642 }
6643 else
6644 {
6645 *(int *)v16 = (int)RemoveQuotes(v4);
6646 }
6647 }
6648 else
6649 {
6650 LABEL_45:
6651 if ( v20 == 1 && !v1->uNumNPCNames[1] )
6652 v1->uNumNPCNames[1] = v18;
6653 }
6654 ++v20;
6655 v4 += v14 + 1;
6656 }
6657 while ( v20 <= 1 );
6658 ++v18;
6659 v16 += 8;
6660 if ( (signed int)v18 >= 540 )
6661 break;
6662 v2 = 0;
6663 }
6664 v1->pNPCProfTXT_Raw = 0;
6665 v1->uNumNPCNames[0] = v18;
6666 v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
6667 v1->pNPCProfTXT_Raw = v7;
6668 strtok(v7, "\r");
6669 strtok(0, "\r");
6670 strtok(0, "\r");
6671 strtok(0, "\r");
6672 v8 = (char *)&v1->pProfessions[0].pJoinText;
6673 v19 = (char *)&v1->pProfessions[0].pJoinText;
6674 v13 = 58;
6675 do
6676 {
6677 v21 = 0;
6678 v9 = strtok(0, "\r") + 1;
6679 v17 = 0;
6680 do
6681 {
6682 v10 = *v9;
6683 v11 = 0;
6684 if ( *v9 != 9 )
6685 {
6686 do
6687 {
6688 if ( !v10 )
6689 break;
6690 ++v11;
6691 v10 = v9[v11];
6692 }
6693 while ( v10 != 9 );
6694 v8 = v19;
6695 }
6696 v15 = (int)&v9[v11];
6697 if ( !v9[v11] )
6698 v17 = 1;
6699 *(char *)v15 = 0;
6700 if ( v11 )
6701 {
6702 switch ( v21 )
6703 {
6704 case 2:
6705 *((int *)v8 - 3) = atoi(v9);
6706 break;
6707 case 3:
6708 *((int *)v8 - 1) = (int)RemoveQuotes(v9);
6709 break;
6710 case 4:
6711 *((int *)v8 - 2) = (int)RemoveQuotes(v9);
6712 break;
6713 case 5:
6714 *(int *)v8 = (int)RemoveQuotes(v9);
6715 break;
6716 case 6:
6717 *((int *)v8 + 1) = (int)RemoveQuotes(v9);
6718 break;
6719 }
6720 }
6721 else
6722 {
6723 if ( !v21 )
6724 v17 = 1;
6725 }
6726 ++v21;
6727 v9 = (char *)(v15 + 1);
6728 }
6729 while ( v21 <= 6 && !v17 );
6730 v8 += 20;
6731 v12 = v13-- == 1;
6732 v19 = v8;
6733 }
6734 while ( !v12 );
6735 v1->uNumNPCProfessions = 59;
6736 }
6737
6738 //----- (00477266) --------------------------------------------------------
6739 void NPCStats::Release()
6740 {
6741 NPCStats *v1; // esi@1
6742 void *v2; // ST00_4@1
6743 int v3; // ebx@1
6744
6745 v1 = this;
6746 pAllocator->FreeChunk(this->pNPCTopicTXT_Raw);
6747 v2 = v1->pNPCTextTXT_Raw;
6748 v1->pNPCNewsTXT_Raw = 0;
6749 pAllocator->FreeChunk(v2);
6750 v1->pNPCNewsTXT_Raw = 0;
6751 pAllocator->FreeChunk(0);
6752 v1->pNPCNewsTXT_Raw = 0;
6753 pAllocator->FreeChunk(v1->pNPCProfTXT_Raw);
6754 v1->pNPCProfTXT_Raw = 0;
6755 pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw);
6756 v1->pNPCNamesTXT_Raw = 0;
6757 pAllocator->FreeChunk(v1->pNPCDataTXT_Raw);
6758 v1->pNPCDataTXT_Raw = 0;
6759 pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
6760 v1->pNPCDistTXT_Raw = 0;
6761 v3 = (int)&v1->pNPCGreetTXT_Raw;
6762 pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw);
6763 v1 = (NPCStats *)((char *)v1 + 98296);
6764 *(int *)v3 = 0;
6765 pAllocator->FreeChunk(v1->pNPCData[0].pName);
6766 v1->pNPCData[0].pName = 0;
6767 }
6768
6769 //----- (0047730C) --------------------------------------------------------
6770 signed int __stdcall const_1(int a1)
6771 {
6772 return 1;
6773 }
6774 // 47730C: using guessed type int __stdcall const_1(int);
6775
6776 //----- (0047732C) --------------------------------------------------------
6777 int NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5)
6778 {
6779 NPCStats *v5; // ebx@1
6780 signed __int64 v6; // qax@1
6781 int v7; // esi@1
6782 int v8; // edx@1
6783 int v9; // eax@1
6784 unsigned int v10; // ecx@23
6785 int v11; // edx@28
6786 int v12; // esi@37
6787 int v13; // edx@37
6788 int v14; // ecx@37
6789 int v15; // eax@37
6790 int v16; // edx@37
6791 signed int result; // eax@39
6792 int v18; // [sp+Ch] [bp-Ch]@1
6793 signed int v19; // [sp+10h] [bp-8h]@1
6794 signed int v20; // [sp+14h] [bp-4h]@1
6795 int v21; // [sp+24h] [bp+Ch]@1
6796
6797 v21 = a3 - 1;
6798 v5 = this;
6799 v6 = (signed __int64)((double)v21 * -0.33333334);
6800 v7 = *((char *)&unk_4E83B0 - v6);
6801 v18 = *((char *)&unk_4E8408 - v6);
6802 v8 = rand() % (signed int)this->uNumNPCNames[v7];
6803 a2->uSex = v7;
6804 a2->pName = (char *)*((int *)&v5->pNPCData[0].pName + v7 + 2 * v8 + 19038);
6805 v9 = 0;
6806 v20 = 0;
6807 v19 = 0;
6808 while ( 1 )
6809 {
6810 if ( v18 == v9 )
6811 {
6812 if ( v7 == v9 )
6813 {
6814 v21 = 2;
6815 }
6816 else
6817 {
6818 if ( v7 - v9 == 1 )
6819 v21 = 201;
6820 }
6821 }
6822 else
6823 {
6824 switch ( v18 - v9 )
6825 {
6826 case 1:
6827 if ( v7 == v9 )
6828 {
6829 v21 = 400;
6830 }
6831 else
6832 {
6833 if ( v7 - v9 == 1 )
6834 v21 = 460;
6835 }
6836 break;
6837 case 2:
6838 if ( v7 == v9 )
6839 {
6840 v21 = 500;
6841 }
6842 else
6843 {
6844 if ( v7 - v9 == 1 )
6845 v21 = 530;
6846 }
6847 break;
6848 case 3:
6849 if ( v7 == v9 )
6850 {
6851 v21 = 300;
6852 }
6853 else
6854 {
6855 if ( v7 - v9 == 1 )
6856 v21 = 360;
6857 }
6858 break;
6859 }
6860 }
6861 rand();
6862 if ( const_1(v18) == 1 )
6863 v19 = 1;
6864 ++v20;
6865 if ( v20 >= 4 )
6866 {
6867 v10 = v21;
6868 v19 = 1;
6869 }
6870 if ( v19 )
6871 break;
6872 v9 = 0;
6873 }
6874 a2->uPortraitID = v10;
6875 a2->uFlags = 0;
6876 a2->fame = 0;
6877 v11 = rand() % 100 + 1;
6878 if ( v11 >= 60 )
6879 {
6880 if ( v11 >= 90 )
6881 {
6882 if ( v11 >= 95 )
6883 {
6884 if ( v11 >= 98 )
6885 a2->rep = -600;
6886 else
6887 a2->rep = 400;
6888 }
6889 else
6890 {
6891 a2->rep = -300;
6892 }
6893 }
6894 else
6895 {
6896 a2->rep = 200;
6897 }
6898 }
6899 else
6900 {
6901 a2->rep = 0;
6902 }
6903 v12 = (int)((char *)v5 + 64 * a5);
6904 v13 = rand() % *(int *)(v12 + 91460);
6905 v14 = 0;
6906 v15 = 0;
6907 v16 = v13 + 1;
6908 if ( v16 > 0 )
6909 {
6910 do
6911 v14 += *(char *)(v12 + v15++ + 91464);
6912 while ( v14 < v16 );
6913 }
6914 a2->uProfession = v15 - 1;
6915 a2->house = a4;
6916 result = 1;
6917 a2->field_24 = 1;
6918 a2->joins = 1;
6919 return result;
6920 }
6921 // 47730C: using guessed type int __stdcall const_1(int);
6922
6923 //----- (0047752B) --------------------------------------------------------
6924 int __cdecl GetPartyReputation()
6925 {
6926 DDM_DLV_Header *v0; // ebx@1
6927 signed int v1; // esi@3
6928
6929 v0 = &pOutdoor->ddm;
6930 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
6931 v0 = &pIndoor->dlv;
6932 v1 = 0;
6933 if ( CheckHiredNPCSpeciality(0x2Du) )
6934 v1 = 5;
6935 if ( CheckHiredNPCSpeciality(0x33u) )
6936 v1 += 5;
6937 if ( CheckHiredNPCSpeciality(0x30u) )
6938 v1 += 5;
6939 if ( CheckHiredNPCSpeciality(0x32u) )
6940 v1 += 5;
6941 if ( CheckHiredNPCSpeciality(0x34u) )
6942 v1 += 5;
6943 return v1 + v0->uReputation;
6944 }
6945
6946
6947
6948
6949
6950 //----- (004775ED) --------------------------------------------------------
6951 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2)
6952 {
6953 char *v2; // edi@1
6954 int v3; // eax@1
6955 char *v4; // edx@2
6956 char *v5; // esi@3
6957 double v6; // st7@6
6958 signed __int64 v7; // ST84_8@6
6959 double v8; // ST0C_8@6
6960 int v9; // esi@6
6961 double v10; // ST44_8@6
6962 int v11; // ecx@6
6963 double v12; // ST34_8@6
6964 int v13; // ecx@6
6965 double v14; // ST14_8@6
6966 double v15; // st7@8
6967 unsigned int v16; // ecx@8
6968 signed __int64 v17; // ST64_8@8
6969 double v18; // ST24_8@8
6970 int v19; // edi@8
6971 double v20; // ST3C_8@8
6972 int v21; // ecx@8
6973 double v22; // ST2C_8@8
6974 int v23; // ST9C_4@8
6975 double v24; // ST1C_8@8
6976 int *v25; // edi@8
6977 int v26; // esi@8
6978 int *v27; // edi@10
6979 int v28; // esi@10
6980 int result; // eax@12
6981 __int64 v30; // [sp+A8h] [bp-30h]@8
6982 float v31; // [sp+B0h] [bp-28h]@6
6983 float v32; // [sp+B4h] [bp-24h]@6
6984 int v33; // [sp+B8h] [bp-20h]@6
6985 int v34; // [sp+BCh] [bp-1Ch]@2
6986 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1
6987 float v36; // [sp+C4h] [bp-14h]@6
6988 int v37; // [sp+C8h] [bp-10h]@6
6989 int v38; // [sp+CCh] [bp-Ch]@1
6990 float v39; // [sp+D0h] [bp-8h]@6
6991 int *v40; // [sp+D4h] [bp-4h]@2
6992
6993 v2 = (char *)&this->field_14[4 * this->field_10 + 20];
6994 v38 = 0;
6995 *(int *)v2 = this->field_14[20];
6996 v2 += 4;
6997 *(int *)v2 = this->field_14[21];
6998 v2 += 4;
6999 *(int *)v2 = this->field_14[22];
7000 *((int *)v2 + 1) = this->field_14[23];
7001 v3 = this->field_10;
7002 v35 = this;
7003 if ( v3 > 0 )
7004 {
7005 v40 = &this->field_14[40];
7006 v4 = (char *)&this->field_14[23] + 3;
7007 v34 = v3;
7008 while ( 1 )
7009 {
7010 v5 = v4 - 15;
7011 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
7012 goto LABEL_11;
7013 if ( *(float *)v5 <= (double)a2 )
7014 break;
7015 if ( *(float *)(v4 + 1) <= (double)a2 )
7016 {
7017 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
7018 v16 = (unsigned __int8)*v4;
7019 HIDWORD(v30) = LODWORD(a2);
7020 v17 = (unsigned __int8)v4[16] - v16;
7021 v36 = v15;
7022 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11);
7023 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7);
7024 v39 = (double)v17 * v15;
7025 v18 = v39 + 6.7553994e15;
7026 v19 = (unsigned __int8)*v4;
7027 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
7028 v20 = v39 + 6.7553994e15;
7029 v21 = (unsigned __int8)*(v4 - 2);
7030 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1);
7031 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36;
7032 v22 = v39 + 6.7553994e15;
7033 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2);
7034 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
7035 v24 = v39 + 6.7553994e15;
7036 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8);
7037 v25 = v40;
7038 *v40 = *(int *)v5;
7039 v26 = (int)(v5 + 4);
7040 ++v25;
7041 *v25 = *(int *)v26;
7042 v26 += 4;
7043 ++v25;
7044 ++v38;
7045 v40 += 4;
7046 *v25 = *(int *)v26;
7047 v25[1] = *(int *)(v26 + 4);
7048 goto LABEL_9;
7049 }
7050 LABEL_10:
7051 v27 = v40;
7052 ++v38;
7053 *v40 = *(int *)v5;
7054 v28 = (int)(v5 + 4);
7055 ++v27;
7056 *v27 = *(int *)v28;
7057 v28 += 4;
7058 ++v27;
7059 v40 += 4;
7060 *v27 = *(int *)v28;
7061 v27[1] = *(int *)(v28 + 4);
7062 LABEL_11:
7063 v4 += 16;
7064 --v34;
7065 if ( !v34 )
7066 goto LABEL_12;
7067 }
7068 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
7069 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
7070 v36 = v6;
7071 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
7072 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
7073 *(float *)&v37 = (double)v7 * v6;
7074 v8 = *(float *)&v37 + 6.7553994e15;
7075 v9 = (unsigned __int8)*v4;
7076 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
7077 v10 = *(float *)&v37 + 6.7553994e15;
7078 v11 = (unsigned __int8)*(v4 - 2);
7079 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
7080 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
7081 v12 = v39 + 6.7553994e15;
7082 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
7083 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
7084 v14 = v39 + 6.7553994e15;
7085 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
7086 LABEL_9:
7087 //this = v35;
7088 v5 = (char *)&v30 + 4;
7089 goto LABEL_10;
7090 }
7091 LABEL_12:
7092 result = v38;
7093 this->field_10 = v38;
7094 return result;
7095 }
7096
7097 //----- (00477927) --------------------------------------------------------
7098 int stru6_stru1_indoor_sw_billboard::_477927(float a2)
7099 {
7100 char *v2; // edi@1
7101 int v3; // eax@1
7102 char *v4; // edx@2
7103 char *v5; // esi@3
7104 double v6; // st7@6
7105 signed __int64 v7; // ST84_8@6
7106 double v8; // ST0C_8@6
7107 int v9; // esi@6
7108 double v10; // ST44_8@6
7109 int v11; // ecx@6
7110 double v12; // ST34_8@6
7111 int v13; // ecx@6
7112 double v14; // ST14_8@6
7113 double v15; // st7@8
7114 unsigned int v16; // ecx@8
7115 signed __int64 v17; // ST64_8@8
7116 double v18; // ST24_8@8
7117 int v19; // edi@8
7118 double v20; // ST3C_8@8
7119 int v21; // ecx@8
7120 double v22; // ST2C_8@8
7121 int v23; // ST9C_4@8
7122 double v24; // ST1C_8@8
7123 int *v25; // edi@8
7124 int v26; // esi@8
7125 int *v27; // edi@10
7126 int v28; // esi@10
7127 int result; // eax@12
7128 __int64 v30; // [sp+A8h] [bp-30h]@8
7129 float v31; // [sp+B0h] [bp-28h]@6
7130 float v32; // [sp+B4h] [bp-24h]@6
7131 int v33; // [sp+B8h] [bp-20h]@6
7132 int v34; // [sp+BCh] [bp-1Ch]@2
7133 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1
7134 float v36; // [sp+C4h] [bp-14h]@6
7135 int v37; // [sp+C8h] [bp-10h]@6
7136 int v38; // [sp+CCh] [bp-Ch]@1
7137 float v39; // [sp+D0h] [bp-8h]@6
7138 int *v40; // [sp+D4h] [bp-4h]@2
7139
7140 v2 = (char *)&this->field_14[4 * this->field_10 + 20];
7141 v38 = 0;
7142 *(int *)v2 = this->field_14[20];
7143 v2 += 4;
7144 *(int *)v2 = this->field_14[21];
7145 v2 += 4;
7146 *(int *)v2 = this->field_14[22];
7147 *((int *)v2 + 1) = this->field_14[23];
7148 v3 = this->field_10;
7149 v35 = this;
7150 if ( v3 > 0 )
7151 {
7152 v40 = &this->field_14[40];
7153 v4 = (char *)&this->field_14[23] + 3;
7154 v34 = v3;
7155 while ( 1 )
7156 {
7157 v5 = v4 - 15;
7158 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 )
7159 goto LABEL_11;
7160 if ( *(float *)v5 >= (double)a2 )
7161 break;
7162 if ( *(float *)(v4 + 1) >= (double)a2 )
7163 {
7164 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
7165 v16 = (unsigned __int8)*v4;
7166 HIDWORD(v30) = LODWORD(a2);
7167 v17 = (unsigned __int8)v4[16] - v16;
7168 v36 = v15;
7169 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11);
7170 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7);
7171 v39 = (double)v17 * v15;
7172 v18 = v39 + 6.7553994e15;
7173 v19 = (unsigned __int8)*v4;
7174 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
7175 v20 = v39 + 6.7553994e15;
7176 v21 = (unsigned __int8)*(v4 - 2);
7177 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1);
7178 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36;
7179 v22 = v39 + 6.7553994e15;
7180 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2);
7181 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
7182 v24 = v39 + 6.7553994e15;
7183 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8);
7184 v25 = v40;
7185 *v40 = *(int *)v5;
7186 v26 = (int)(v5 + 4);
7187 ++v25;
7188 *v25 = *(int *)v26;
7189 v26 += 4;
7190 ++v25;
7191 ++v38;
7192 v40 += 4;
7193 *v25 = *(int *)v26;
7194 v25[1] = *(int *)(v26 + 4);
7195 goto LABEL_9;
7196 }
7197 LABEL_10:
7198 v27 = v40;
7199 ++v38;
7200 *v40 = *(int *)v5;
7201 v28 = (int)(v5 + 4);
7202 ++v27;
7203 *v27 = *(int *)v28;
7204 v28 += 4;
7205 ++v27;
7206 v40 += 4;
7207 *v27 = *(int *)v28;
7208 v27[1] = *(int *)(v28 + 4);
7209 LABEL_11:
7210 v4 += 16;
7211 --v34;
7212 if ( !v34 )
7213 goto LABEL_12;
7214 }
7215 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
7216 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
7217 v36 = v6;
7218 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
7219 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
7220 *(float *)&v37 = (double)v7 * v6;
7221 v8 = *(float *)&v37 + 6.7553994e15;
7222 v9 = (unsigned __int8)*v4;
7223 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
7224 v10 = *(float *)&v37 + 6.7553994e15;
7225 v11 = (unsigned __int8)*(v4 - 2);
7226 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
7227 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
7228 v12 = v39 + 6.7553994e15;
7229 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
7230 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
7231 v14 = v39 + 6.7553994e15;
7232 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
7233 LABEL_9:
7234 //this = v35;
7235 v5 = (char *)&v30 + 4;
7236 goto LABEL_10;
7237 }
7238 LABEL_12:
7239 result = v38;
7240 this->field_10 = v38;
7241 return result;
7242 }
7243
7244 //----- (00477C61) --------------------------------------------------------
7245 int stru6_stru1_indoor_sw_billboard::sub_477C61()
7246 {
7247 stru6_stru1_indoor_sw_billboard *v1; // ebx@1
7248 int v2; // ecx@2
7249 int v3; // eax@3
7250 double v4; // st7@4
7251 double v5; // st7@5
7252 double v6; // st6@5
7253 double v7; // st5@6
7254 float v8; // ST30_4@8
7255 float v9; // ST24_4@8
7256 double v10; // st7@8
7257 double v11; // st6@8
7258 double v12; // st5@8
7259 float v13; // ST24_4@13
7260 int v14; // esi@13
7261 char *v15; // esi@15
7262 signed int v16; // eax@16
7263 __int16 v17; // fps@16
7264 unsigned __int8 v18; // c2@16
7265 unsigned __int8 v19; // c3@16
7266 double v20; // st6@16
7267 float v21; // ST18_4@17
7268 float v22; // ST2C_4@17
7269 float v23; // ST34_4@17
7270 float v24; // ST24_4@17
7271 double v25; // st7@17
7272 double v26; // st6@17
7273 float v27; // ST34_4@18
7274 float v28; // ST30_4@18
7275 int v29; // eax@19
7276 signed int v31; // [sp+8h] [bp-28h]@15
7277 float v32; // [sp+Ch] [bp-24h]@16
7278 float v33; // [sp+14h] [bp-1Ch]@16
7279 float v34; // [sp+18h] [bp-18h]@16
7280 float v35; // [sp+1Ch] [bp-14h]@17
7281 float v36; // [sp+20h] [bp-10h]@4
7282 float v37; // [sp+24h] [bp-Ch]@4
7283 float v38; // [sp+24h] [bp-Ch]@16
7284 float v39; // [sp+28h] [bp-8h]@9
7285 float v40; // [sp+28h] [bp-8h]@16
7286 float v41; // [sp+2Ch] [bp-4h]@6
7287 float v42; // [sp+2Ch] [bp-4h]@9
7288
7289 v1 = this;
7290 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7291 {
7292 v2 = 0;
7293 if ( v1->field_10 > 0 )
7294 {
7295 v3 = (int)&v1->field_14[1];
7296 do
7297 {
7298 v4 = *(float *)(v3 - 4);
7299 LODWORD(v37) = *(int *)v3;
7300 LODWORD(v36) = *(int *)(v3 + 4);
7301 if ( pBLVRenderParams->sPartyRotX )
7302 {
7303 v5 = v4 - (double)pBLVRenderParams->vPartyPos.x;
7304 v6 = v37 - (double)pBLVRenderParams->vPartyPos.y;
7305 if ( pRenderer->pRenderD3D )
7306 {
7307 v41 = pBLVRenderParams->fSineY * v6 + pBLVRenderParams->fCosineY * v5;
7308 v7 = pBLVRenderParams->fSineY * v5 - pBLVRenderParams->fCosineY * v6;
7309 }
7310 else
7311 {
7312 v41 = pBLVRenderParams->fCosineY * v5 - pBLVRenderParams->fSineY * v6;
7313 v7 = pBLVRenderParams->fSineY * v5 + pBLVRenderParams->fCosineY * v6;
7314 }
7315 v8 = v7;
7316 v9 = v36 - (double)pBLVRenderParams->vPartyPos.z;
7317 v10 = pBLVRenderParams->fCosineNegX * v41 - pBLVRenderParams->fSineNegX * v9;
7318 v11 = v8;
7319 v12 = pBLVRenderParams->fCosineNegX * v9 + pBLVRenderParams->fSineNegX * v41;
7320 }
7321 else
7322 {
7323 v42 = v4 - (double)pBLVRenderParams->vPartyPos.x;
7324 v39 = v37 - (double)pBLVRenderParams->vPartyPos.y;
7325 if ( pRenderer->pRenderD3D )
7326 {
7327 v10 = pBLVRenderParams->fSineY * v39 + pBLVRenderParams->fCosineY * v42;
7328 v11 = pBLVRenderParams->fSineY * v42 - pBLVRenderParams->fCosineY * v39;
7329 }
7330 else
7331 {
7332 v10 = pBLVRenderParams->fCosineY * v42 - pBLVRenderParams->fSineY * v39;
7333 v11 = pBLVRenderParams->fSineY * v42 + pBLVRenderParams->fCosineY * v39;
7334 }
7335 v12 = v36 - (double)pBLVRenderParams->vPartyPos.z;
7336 }
7337 v13 = v12;
7338 ++v2;
7339 *(int *)(v3 + 84) = LODWORD(v13);
7340 v14 = *(int *)(v3 + 8);
7341 *(float *)(v3 + 76) = v10;
7342 *(int *)(v3 + 88) = v14;
7343 *(float *)(v3 + 80) = v11;
7344 v3 += 16;
7345 }
7346 while ( v2 < v1->field_10 );
7347 }
7348 }
7349 else
7350 {
7351 v15 = (char *)&this->field_14[1];
7352 v31 = 3;
7353 do
7354 {
7355 v40 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationX) * 0.0000152587890625;
7356 v32 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi)
7357 * 0.0000152587890625;
7358 v34 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationY) * 0.0000152587890625;
7359 v16 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
7360 LODWORD(v38) = *(int *)v15;
7361 v33 = (double)v16 * 0.0000152587890625;
7362 //UNDEF(v17);
7363 v20 = *((float *)v15 - 1) - (double)pIndoorCamera->pos.x;
7364 if ( v19 | v18 )
7365 {
7366 v27 = v20;
7367 LODWORD(v35) = *((int *)v15 + 1);
7368 v28 = v38 - (double)pIndoorCamera->pos.y;
7369 v25 = v33 * v28 + v34 * v27;
7370 v26 = v34 * v28 - v33 * v27;
7371 }
7372 else
7373 {
7374 v21 = v20;
7375 v22 = v38 - (double)pIndoorCamera->pos.y;
7376 v23 = v33 * v22 + v34 * v21;
7377 v24 = *((float *)v15 + 1) - (double)pIndoorCamera->pos.z;
7378 v25 = v32 * v24 + v40 * v23;
7379 v26 = v34 * v22 - v33 * v21;
7380 v35 = v40 * v24 - v32 * v23;
7381 }
7382 *((int *)v15 + 21) = LODWORD(v35);
7383 v29 = *((int *)v15 + 2);
7384 *((float *)v15 + 19) = v25;
7385 *((int *)v15 + 22) = v29;
7386 *((float *)v15 + 20) = v26;
7387 v15 += 16;
7388 --v31;
7389 }
7390 while ( v31 );
7391 }
7392 v1->field_10 = 3;
7393 return 1;
7394 }
7395
7396 //----- (00477F63) --------------------------------------------------------
7397 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
7398 {
7399 signed int v1; // ebx@1
7400 stru6_stru1_indoor_sw_billboard *v2; // esi@1
7401 double v3; // st7@2
7402 int v4; // edx@4
7403 char *v5; // ecx@5
7404 int v6; // edi@5
7405 float v7; // ST08_4@13
7406 signed int v9; // [sp+Ch] [bp-8h]@1
7407 float v10; // [sp+10h] [bp-4h]@2
7408
7409 auto a1 = this;
7410
7411 v1 = 0;
7412 v2 = a1;
7413 v9 = 0;
7414 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7415 {
7416 v10 = 16192.0;
7417 v3 = (double)pBLVRenderParams->field_40 * 0.000015258789;
7418 }
7419 else
7420 {
7421 v10 = (double)pOutdoorCamera->shading_dist_mist;
7422 v3 = 8.0;
7423 }
7424 v4 = a1->field_10;
7425 if ( v4 <= 0 )
7426 goto LABEL_16;
7427 v5 = (char *)&a1->field_14[20];
7428 v6 = v4;
7429 do
7430 {
7431 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 )
7432 {
7433 if ( v3 < *(float *)v5 )
7434 v9 = 1;
7435 else
7436 v1 = 1;
7437 }
7438 v5 += 16;
7439 --v6;
7440 }
7441 while ( v6 );
7442 if ( !v1 )
7443 {
7444 if ( v9 )
7445 {
7446 v2->_477927(v10);
7447 return v2->field_10 != 0;
7448 }
7449 LABEL_16:
7450 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
7451 return v2->field_10 != 0;
7452 }
7453 v7 = v3;
7454 _4775ED(v7);
7455 return v2->field_10 != 0;
7456 }
7457
7458 //----- (0047802A) --------------------------------------------------------
7459 int stru6_stru1_indoor_sw_billboard::sub_47802A()
7460 {
7461 int v1; // edx@1
7462 stru6_stru1_indoor_sw_billboard *v2; // edi@1
7463 int v3; // ebx@2
7464 char *v4; // esi@3
7465 float v5; // eax@4
7466 double v6; // st7@4
7467 double v7; // ST30_8@5
7468 double v8; // st6@6
7469 double v9; // st5@6
7470 char *v10; // ecx@15
7471 float v11; // eax@16
7472 double v12; // st7@16
7473 double v13; // st6@16
7474 double v14; // st5@16
7475 signed int v16; // [sp+38h] [bp-Ch]@1
7476 int a6; // [sp+3Ch] [bp-8h]@5
7477 int a5; // [sp+40h] [bp-4h]@5
7478
7479 auto a1 = this;
7480
7481 v1 = 0;
7482 v2 = a1;
7483 v16 = 0;
7484 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7485 {
7486 v3 = 0;
7487 if ( a1->field_10 > 0 )
7488 {
7489 v4 = (char *)&a1->field_14[42];
7490 do
7491 {
7492 LODWORD(v5) = *((int *)v4 - 2);
7493 v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / *((float *)v4 - 2);
7494 if ( pRenderer->pRenderD3D )
7495 {
7496 v7 = v5 + 6.7553994e15;
7497 pGame->pIndoorCameraD3D->Project(
7498 COERCE_UNSIGNED_INT64(v5 + 6.7553994e15),
7499 COERCE_UNSIGNED_INT64(*((float *)v4 - 1) + 6.7553994e15),
7500 COERCE_UNSIGNED_INT64(*(float *)v4 + 6.7553994e15),
7501 &a5,
7502 &a6);
7503 *((float *)v4 + 18) = (double)a5;
7504 *((float *)v4 + 19) = (double)a6;
7505 *((float *)v4 + 20) = (double)SLODWORD(v7);
7506 }
7507 else
7508 {
7509 *((float *)v4 + 18) = (double)pBLVRenderParams->uViewportCenterX - v6 * *((float *)v4 - 1);
7510 v8 = (double)pBLVRenderParams->uViewportCenterY;
7511 v9 = v6 * *(float *)v4;
7512 *((int *)v4 + 20) = LODWORD(v5);
7513 *((float *)v4 + 19) = v8 - v9;
7514 }
7515 *((int *)v4 + 21) = *((int *)v4 + 1);
7516 if ( (double)(signed int)pViewport->uViewportX <= *((float *)v4 + 18)
7517 && (double)(signed int)pViewport->uViewportZ > *((float *)v4 + 18)
7518 && (double)(signed int)pViewport->uViewportY <= *((float *)v4 + 19)
7519 && (double)(signed int)pViewport->uViewportW > *((float *)v4 + 19) )
7520 v16 = 1;
7521 ++v3;
7522 v4 += 16;
7523 }
7524 while ( v3 < v2->field_10 );
7525 }
7526 }
7527 else
7528 {
7529 if ( a1->field_10 > 0 )
7530 {
7531 v10 = (char *)&a1->field_14[40];
7532 do
7533 {
7534 LODWORD(v11) = *(int *)v10;
7535 v12 = (double)pOutdoorCamera->int_fov_rad / *(float *)v10;
7536 *((float *)v10 + 20) = (double)pViewport->uScreenCenterX - v12 * *((float *)v10 + 1);
7537 v13 = (double)pViewport->uScreenCenterY;
7538 v14 = v12 * *((float *)v10 + 2);
7539 *((int *)v10 + 22) = LODWORD(v11);
7540 *((int *)v10 + 23) = *((int *)v10 + 3);
7541 *((float *)v10 + 21) = v13 - v14;
7542 if ( (double)(signed int)pViewport->uViewportX <= *((float *)v10 + 20)
7543 && (double)(signed int)pViewport->uViewportZ > *((float *)v10 + 20)
7544 && (double)(signed int)pViewport->uViewportY <= *((float *)v10 + 21)
7545 && (double)(signed int)pViewport->uViewportW > *((float *)v10 + 21) )
7546 v16 = 1;
7547 ++v1;
7548 v10 += 16;
7549 }
7550 while ( v1 < v2->field_10 );
7551 }
7552 }
7553 return v16;
7554 }
7555
7556
7557
7558 //----- (004783FA) --------------------------------------------------------
7559 void __cdecl sub_4783FA_construct_global_73D150()
7560 {
7561 char *v0; // eax@1
7562 signed int v1; // ecx@1
7563
7564 v0 = (char *)&array_73D150[0].flt_2C;
7565 v1 = 20;
7566 do
7567 {
7568 *(float *)v0 = 0.0;
7569 v0 += 48;
7570 --v1;
7571 }
7572 while ( v1 );
7573 }
7574
7575
7576
7577 //----- (0047840D) --------------------------------------------------------
7578 char Render::DrawBuildingsD3D()
7579 {
7580 IndoorCameraD3D *v0; // eax@3
7581 char result; // al@3
7582 Vec3_int_ **v2; // ebx@4
7583 Vec3_int_ *v3; // eax@6
7584 ODMFace *pFace; // esi@6
7585 int v5; // ecx@8
7586 int v6; // eax@8
7587 stru148 *v7; // ebx@8
7588 LightmapBuilder *v8; // eax@8
7589 int v9; // ecx@8
7590 char v10; // zf@8
7591 Texture *pFaceTexture; // eax@10
7592 signed int v12; // ecx@10
7593 unsigned int v13; // eax@14
7594 unsigned int v14; // eax@18
7595 unsigned int v15; // eax@22
7596 unsigned int v16; // edi@22
7597 int v17; // eax@24
7598 int v18; // edi@34
7599 char *v19; // eax@35
7600 char *v20; // ecx@35
7601 Vec3_int_ *v21; // edx@36
7602 int v22; // edx@36
7603 char *v23; // edi@37
7604 int v24; // eax@50
7605 int v25; // ecx@55
7606 int v26; // eax@57
7607 int v27; // eax@57
7608 int v28; // eax@58
7609 int v29; // edx@58
7610 double v30; // st7@59
7611 LightmapBuilder *v31; // edi@63
7612 signed int v32; // eax@73
7613 int v33; // eax@78
7614 unsigned int v34; // eax@80
7615 std::string v35; // [sp-18h] [bp-70h]@2
7616 int v36; // [sp-14h] [bp-6Ch]@69
7617 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69
7618 int v38; // [sp-Ch] [bp-64h]@69
7619 LightmapBuilder *v39; // [sp-8h] [bp-60h]@2
7620 int v40; // [sp-4h] [bp-5Ch]@2
7621 std::string *v41; // [sp+Ch] [bp-4Ch]@2
7622 Vec3_int_ *v42; // [sp+10h] [bp-48h]@6
7623 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8
7624 float v44; // [sp+18h] [bp-40h]@10
7625 float v45; // [sp+1Ch] [bp-3Ch]@10
7626 ODMFace *v46; // [sp+20h] [bp-38h]@6
7627 IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
7628 unsigned int v48; // [sp+28h] [bp-30h]@8
7629 int v49; // [sp+2Ch] [bp-2Ch]@10
7630 int v50; // [sp+30h] [bp-28h]@34
7631 int v51; // [sp+34h] [bp-24h]@35
7632 int v52; // [sp+38h] [bp-20h]@36
7633 int v53; // [sp+3Ch] [bp-1Ch]@8
7634 Vec3_int_ *v54; // [sp+40h] [bp-18h]@6
7635 int a1; // [sp+44h] [bp-14h]@3
7636 Vec3_int_ **v56; // [sp+48h] [bp-10h]@4
7637 int uNumVertices; // [sp+4Ch] [bp-Ch]@34
7638 int unused; // [sp+50h] [bp-8h]@3
7639 int a3; // [sp+57h] [bp-1h]@2
7640
7641 if ( !pRenderer->pRenderD3D )
7642 {
7643 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
7644 }
7645 unused = 0;
7646 v0 = pGame->pIndoorCameraD3D;
7647 a1 = 0;
7648 v47 = v0;
7649 result = LOBYTE(pOutdoor->pBModels);
7650 v41 = (std::string *)pOutdoor->uNumBModels;
7651 if ( (signed int)pOutdoor->uNumBModels > 0 )
7652 {
7653 v2 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces;
7654 v56 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces;
7655 while ( 1 )
7656 {
7657 if ( IsBModelVisible(a1, &unused) )
7658 {
7659 *(v2 - 3) = (Vec3_int_ *)((unsigned int)*(v2 - 3) | 1);
7660 v3 = *v2;
7661 pFace = (ODMFace *)v2[2];
7662 v54 = 0;
7663 v46 = pFace;
7664 v42 = v3;
7665 if ( (signed int)v3 > 0 )
7666 break;
7667 }
7668 LABEL_86:
7669 ++a1;
7670 v2 += 47;
7671 result = a1;
7672 v56 = v2;
7673 if ( a1 >= (signed int)v41 )
7674 return result;
7675 }
7676 while ( 1 )
7677 {
7678 if ( pFace->uFaceAttributes & 0x2000 )
7679 goto LABEL_85;
7680 v5 = (int)*(v2 - 1);
7681 v6 = pFace->pVertexIDs[0];
7682 v53 = 0;
7683 v7 = &array_77EC08[pOutdoorCamera->numStru148s];
7684 v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8);
7685 *(int *)&v7->flags = 0;
7686 pLightmapBuilder = v8;
7687 v9 = pFace->uTextureID;
7688 v10 = (BYTE1(pFace->uFaceAttributes) & 0x40) == 0;
7689 v48 = pFace->uTextureID;
7690 if ( !v10 )
7691 {
7692 v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
7693 v9 = v48;
7694 }
7695 pFaceTexture = (Texture *)(v9 != -1 ? (int)&pBitmaps_LOD->pTextures[v9] : 0);
7696 v7->pTexture = pFaceTexture;
7697 v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
7698 v49 = v12;
7699 v49 = pFaceTexture->uTextureHeight;
7700 v10 = (pFace->uFaceAttributes & 0x10) == 0;
7701 v45 = 1.0 / (double)v12;
7702 v44 = 1.0 / (double)v49;
7703 if ( !v10 )
7704 *(int *)&v7->flags |= 2u;
7705 if ( BYTE2(pFace->uFaceAttributes) & 0x40 )
7706 HIBYTE(v7->flags) |= 4u;
7707 v13 = pFace->uFaceAttributes;
7708 if ( v13 & 4 )
7709 {
7710 HIBYTE(v7->flags) |= 4u;
7711 }
7712 else
7713 {
7714 if ( v13 & 0x20 )
7715 HIBYTE(v7->flags) |= 8u;
7716 }
7717 v14 = pFace->uFaceAttributes;
7718 if ( BYTE1(v14) & 8 )
7719 {
7720 *(int *)&v7->flags |= 0x2000u;
7721 }
7722 else
7723 {
7724 if ( v14 & 0x40 )
7725 HIBYTE(v7->flags) |= 0x10u;
7726 }
7727 v15 = GetTickCount();
7728 v7->sTextureDeltaU = pFace->sTextureDeltaU;
7729 v7->sTextureDeltaV = pFace->sTextureDeltaV;
7730 v16 = v15 >> 4;
7731 if ( pFace->pFacePlane.vNormal.z && (v40 = pFace->pFacePlane.vNormal.z, abs(v40) >= 59082) )
7732 {
7733 v17 = *(int *)&v7->flags;
7734 if ( BYTE1(v17) & 4 )
7735 goto LABEL_29;
7736 if ( BYTE1(v17) & 8 )
7737 {
7738 LABEL_26:
7739 v7->sTextureDeltaV -= v16 & v7->pTexture->uHeightMinus1;
7740 goto LABEL_30;
7741 }
7742 }
7743 else
7744 {
7745 v17 = *(int *)&v7->flags;
7746 if ( BYTE1(v17) & 4 )
7747 goto LABEL_26;
7748 if ( BYTE1(v17) & 8 )
7749 {
7750 LABEL_29:
7751 v7->sTextureDeltaV += v16 & v7->pTexture->uHeightMinus1;
7752 goto LABEL_30;
7753 }
7754 }
7755 LABEL_30:
7756 if ( BYTE1(v17) & 0x10 )
7757 {
7758 v7->sTextureDeltaU -= v16 & v7->pTexture->uWidthMinus1;
7759 }
7760 else
7761 {
7762 if ( BYTE1(v17) & 0x20 )
7763 v7->sTextureDeltaU += v16 & v7->pTexture->uWidthMinus1;
7764 }
7765 v18 = pFace->uNumVertices;
7766 v50 = 0;
7767 v49 = 0;
7768 uNumVertices = v18;
7769 if ( v18 > 0 )
7770 {
7771 v19 = (char *)&array_73D150[0].vWorldPosition.z;
7772 v20 = (char *)pFace->pTextureUIDs;
7773 v51 = v18;
7774 do
7775 {
7776 v21 = &(*(v56 - 1))[*((short *)v20 - 20)];
7777 *((float *)v19 - 2) = (double)v21->x;
7778 *((float *)v19 - 1) = (double)v21->y;
7779 *(float *)v19 = (double)v21->z;
7780 v19 += 48;
7781 v52 = v7->sTextureDeltaU + *(short *)v20;
7782 *((float *)v19 - 5) = (double)v52 * v45;
7783 v22 = v7->sTextureDeltaV + *((short *)v20 + 20);
7784 v20 += 2;
7785 v10 = v51-- == 1;
7786 v52 = v22;
7787 *((float *)v19 - 4) = (double)v22 * v44;
7788 }
7789 while ( !v10 );
7790 v23 = (char *)&array_73D150[0].vWorldViewPosition;
7791 v51 = uNumVertices;
7792 *(float *)&pLightmapBuilder = (double)(signed int)pLightmapBuilder;
7793 do
7794 {
7795 if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) )
7796 ++v53;
7797 v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u);
7798 if ( *(float *)v23 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v23 )
7799 {
7800 if ( *(float *)v23 >= 8.0 )
7801 v49 = 1;
7802 else
7803 v50 = 1;
7804 }
7805 else
7806 {
7807 v47->_436BB7_project_and_stuff((RenderVertexSoft *)(v23 - 12), 1u, 0);
7808 }
7809 v23 += 48;
7810 --v51;
7811 }
7812 while ( v51 );
7813 v18 = uNumVertices;
7814 }
7815 if ( v53 == v18 )
7816 LOBYTE(v7->field_32) |= 1u;
7817 v24 = pOutdoor->vSunlight.x;
7818 v7->pODMFace = pFace;
7819 v7->uNumVertices = v18;
7820 v7->field_59 = 5;
7821 pLightmapBuilder = (LightmapBuilder *)-v24;
7822 v51 = pFace->pFacePlane.vNormal.x;
7823 v51 = (unsigned __int64)(-v24 * (signed __int64)v51) >> 16;
7824 v53 = pFace->pFacePlane.vNormal.y;
7825 pLightmapBuilder = (LightmapBuilder *)-pOutdoor->vSunlight.y;
7826 v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)v53) >> 16;
7827 v52 = pFace->pFacePlane.vNormal.z;
7828 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16;
7829 pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52);
7830 v51 = 20 * (int)pLightmapBuilder;
7831 result = 20 - (20 * (signed int)pLightmapBuilder >> 16);
7832 v7->field_58 = result;
7833 if ( result < 0 )
7834 v7->field_58 = 0;
7835 if ( v7->field_58 > 31 )
7836 v7->field_58 = 31;
7837 if ( pOutdoorCamera->numStru148s >= 1999 )
7838 return result;
7839 ++pOutdoorCamera->numStru148s;
7840 ++pOutdoorCamera->field_44;
7841 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) )
7842 {
7843 LOBYTE(v25) = (char)v54;
7844 v26 = a1;
7845 pFace->bVisible = 1;
7846 v7->uBModelFaceID = v25;
7847 LOWORD(v25) = (unsigned __int8)v25;
7848 v7->uBModelID = v26;
7849 v27 = 8 * (v25 | (v26 << 6));
7850 LOBYTE(v27) = v27 | 6;
7851 v7->field_50 = v27;
7852 if ( v18 > 0 )
7853 {
7854 v28 = 0;
7855 v29 = v18;
7856 do
7857 {
7858 v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
7859 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28]));
7860 ++v28;
7861 --v29;
7862 array_50A2B0[v28 + 49].flt_20 = v30;
7863 }
7864 while ( v29 );
7865 pFace = v46;
7866 }
7867
7868 static stru154 static_RenderBuildingsD3D_stru_73C834;
7869 /*static bool __init_flag = false;
7870 if (!__init_flag)
7871 {
7872 __init_flag = true;
7873
7874 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u;
7875 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834);
7876 atexit(loc_4789D4);
7877 }*/
7878
7879 v40 = (int)pFace;
7880 pLightmapBuilder = pGame->pLightmapBuilder;
7881 v31 = pLightmapBuilder;
7882 pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
7883 pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
7884 v31->std__vector_000004_size = 0;
7885 LOBYTE(v31) = 0;
7886 if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
7887 {
7888 v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0);
7889 static_RenderBuildingsD3D_stru_73C834._49B04D(pFace, (BSPVertexBuffer *)v56 - 1);
7890 if ( pDecalBuilder->uNumDecals > 0 )
7891 {
7892 v40 = -1;
7893 v39 = v31;
7894 v38 = 0;
7895 v37 = array_50AC10;
7896 v36 = uNumVertices;
7897 pDecalBuilder->ApplyDecals(
7898 31 - v7->field_58,
7899 2,
7900 &static_RenderBuildingsD3D_stru_73C834,
7901 uNumVertices,
7902 array_50AC10,
7903 0,
7904 (char)v31,
7905 -1);
7906 }
7907 }
7908 if ( stru_F8AD28.field_AC > 0 )
7909 pLightmapBuilder->ApplyLights(
7910 &stru_F8AD28,
7911 &static_RenderBuildingsD3D_stru_73C834,
7912 uNumVertices,
7913 array_50AC10,
7914 0.0,
7915 (char)v31);
7916 if ( v50 )
7917 {
7918 v32 = sr_424CD7(uNumVertices);
7919 goto LABEL_76;
7920 }
7921 if ( v49 )
7922 {
7923 v32 = sr_424EE0_MakeFanFromTriangle(uNumVertices);
7924 LABEL_76:
7925 v7->uNumVertices = v32;
7926 uNumVertices = v32;
7927 OutdoorCamera::Project(v32);
7928 }
7929 if ( uNumVertices )
7930 {
7931 v33 = *(int *)&v7->flags;
7932 if ( v33 & 2 )
7933 {
7934 if ( BYTE1(v33) & 0x3C )
7935 v34 = pRenderer->pHDWaterBitmapIDs[0];
7936 else
7937 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
7938 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34];
7939 }
7940 else
7941 {
7942 v40 = (int)pBitmaps_LOD->pHardwareTextures[v48];
7943 }
7944 pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40);
7945 }
7946 goto LABEL_85;
7947 }
7948 --pOutdoorCamera->numStru148s;
7949 --pOutdoorCamera->field_44;
7950 LABEL_85:
7951 v54 = (Vec3_int_ *)((char *)v54 + 1);
7952 v2 = v56;
7953 ++pFace;
7954 v46 = pFace;
7955 if ( (signed int)v54 >= (signed int)v42 )
7956 goto LABEL_86;
7957 }
7958 }
7959 return result;
7960 }
7961 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag;
7962
7963 //----- (004789DE) --------------------------------------------------------
7964 BSPModel *Render::DrawBuildingsSW()
7965 {
7966 BSPModel *result; // eax@1
7967 unsigned int *v1; // ebx@2
7968 int v2; // eax@4
7969 int v3; // edi@4
7970 int v4; // ecx@6
7971 int v5; // eax@6
7972 int v6; // ecx@6
7973 int v7; // ecx@6
7974 double v8; // st7@7
7975 char *v9; // ebx@7
7976 int v10; // eax@9
7977 double v11; // st7@9
7978 stru148 *v12; // ebx@19
7979 double v13; // st7@21
7980 double v14; // ST4C_8@23
7981 int v15; // eax@23
7982 int v16; // eax@27
7983 int v17; // ecx@29
7984 unsigned __int8 v18; // sf@29
7985 unsigned __int8 v19; // of@29
7986 int v20; // ecx@30
7987 int v21; // eax@31
7988 int v22; // eax@31
7989 int v23; // eax@35
7990 int v24; // eax@39
7991 Texture *v25; // eax@43
7992 int v26; // esi@43
7993 signed int v27; // ecx@43
7994 double v28; // st6@43
7995 double v29; // st5@43
7996 int v30; // edx@44
7997 int v31; // eax@44
7998 double v32; // st4@45
7999 int v33; // ecx@45
8000 char v34; // zf@45
8001 BSPVertexBuffer *v35; // eax@50
8002 unsigned int v36; // eax@53
8003 signed int v37; // esi@53
8004 int v38; // eax@54
8005 signed int v39; // edx@55
8006 char *v40; // ecx@56
8007 double v41; // ST1C_8@57
8008 double v42; // ST24_8@57
8009 signed int v43; // eax@60
8010 signed int v44; // esi@60
8011 int v45; // eax@61
8012 signed int v46; // edx@62
8013 char *v47; // ecx@63
8014 double v48; // ST34_8@64
8015 double v49; // ST44_8@64
8016 int v50; // eax@66
8017 signed int v51; // ecx@67
8018 char *v52; // edx@68
8019 double v53; // ST3C_8@69
8020 double v54; // ST2C_8@69
8021 float v55; // [sp+44h] [bp-7Ch]@50
8022 float v56; // [sp+48h] [bp-78h]@50
8023 float v57; // [sp+4Ch] [bp-74h]@50
8024 float v58; // [sp+50h] [bp-70h]@64
8025 int v59; // [sp+54h] [bp-6Ch]@64
8026 int v60; // [sp+58h] [bp-68h]@69
8027 float v61; // [sp+5Ch] [bp-64h]@64
8028 float v62; // [sp+60h] [bp-60h]@69
8029 float v63; // [sp+64h] [bp-5Ch]@57
8030 float v64; // [sp+68h] [bp-58h]@57
8031 int v65; // [sp+6Ch] [bp-54h]@64
8032 int v66; // [sp+70h] [bp-50h]@1
8033 int v67; // [sp+74h] [bp-4Ch]@6
8034 int v68; // [sp+78h] [bp-48h]@4
8035 int v69; // [sp+7Ch] [bp-44h]@57
8036 int v70; // [sp+80h] [bp-40h]@69
8037 int v71; // [sp+84h] [bp-3Ch]@23
8038 float v72; // [sp+88h] [bp-38h]@69
8039 int v73; // [sp+8Ch] [bp-34h]@57
8040 int v74; // [sp+90h] [bp-30h]@6
8041 int v75; // [sp+94h] [bp-2Ch]@6
8042 int v76; // [sp+98h] [bp-28h]@4
8043 int v77; // [sp+9Ch] [bp-24h]@6
8044 unsigned int *v78; // [sp+A0h] [bp-20h]@2
8045 int v79; // [sp+A4h] [bp-1Ch]@4
8046 int a1; // [sp+A8h] [bp-18h]@1
8047 int v81; // [sp+ACh] [bp-14h]@7
8048 int v82; // [sp+B0h] [bp-10h]@6
8049 int v83; // [sp+B4h] [bp-Ch]@6
8050 signed int v84; // [sp+B8h] [bp-8h]@7
8051 int a2; // [sp+BCh] [bp-4h]@1
8052
8053 a2 = 0;
8054 a1 = 0;
8055 result = pOutdoor->pBModels;
8056 v66 = pOutdoor->uNumBModels;
8057 if ( (signed int)pOutdoor->uNumBModels > 0 )
8058 {
8059 v1 = &pOutdoor->pBModels->uNumFaces;
8060 v78 = &pOutdoor->pBModels->uNumFaces;
8061 while ( 1 )
8062 {
8063 if ( IsBModelVisible(a1, &a2) )
8064 {
8065 *(v1 - 3) |= 1u;
8066 v2 = *v1;
8067 v3 = v1[2];
8068 v79 = 0;
8069 v76 = v3;
8070 v68 = v2;
8071 if ( v2 > 0 )
8072 break;
8073 }
8074 LABEL_73:
8075 ++a1;
8076 v1 += 47;
8077 result = (BSPModel *)a1;
8078 v78 = v1;
8079 if ( a1 >= v66 )
8080 return result;
8081 }
8082 while ( 1 )
8083 {
8084 if ( !(*(char *)(v3 + 29) & 0x20) )
8085 {
8086 v4 = 3 * *(short *)(v3 + 32);
8087 v5 = (int)(v1 - 2);
8088 v67 = (int)(v1 - 2);
8089 v6 = *(int *)(*(v1 - 1) + 4 * v4 + 8) + 4;
8090 v82 = 0;
8091 v83 = v6;
8092 v74 = 0;
8093 v7 = *(char *)(v3 + 302);
8094 v75 = 0;
8095 v77 = v7;
8096 if ( v7 > 0 )
8097 {
8098 v8 = (double)v83;
8099 v9 = (char *)&array_73D150[0].vWorldViewPosition;
8100 v81 = v3 + 32;
8101 v83 = v7;
8102 *(float *)&v84 = v8;
8103 while ( 1 )
8104 {
8105 v10 = *(int *)(v5 + 4) + 12 * *(short *)v81;
8106 *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0;
8107 *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0;
8108 v11 = (double)*(signed int *)(v10 + 8) + 4.0;
8109 *((float *)v9 - 1) = v11;
8110 if ( *(float *)&v84 == v11 )
8111 ++v82;
8112 pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u);
8113 if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 )
8114 {
8115 if ( *(float *)v9 >= 8.0 )
8116 v75 = 1;
8117 else
8118 v74 = 1;
8119 }
8120 else
8121 {
8122 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff((RenderVertexSoft *)(v9 - 12), 1u, 0);
8123 }
8124 v81 += 2;
8125 v9 += 48;
8126 --v83;
8127 if ( !v83 )
8128 break;
8129 v5 = v67;
8130 }
8131 v7 = v77;
8132 }
8133 v12 = &array_77EC08[pOutdoorCamera->numStru148s];
8134 *(int *)&v12->flags = 0;
8135 if ( v82 == v7 )
8136 *(int *)&v12->flags = 65536;
8137 v12->pODMFace = (ODMFace *)v3;
8138 v12->uNumVertices = v7;
8139 v12->field_59 = 5;
8140 v84 = *(int *)v3;
8141 v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
8142 v82 = -pOutdoor->vSunlight.y;
8143 v84 = *(int *)(v3 + 4);
8144 v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
8145 v81 = -pOutdoor->vSunlight.z;
8146 v84 = *(int *)(v3 + 8);
8147 v81 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16;
8148 v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
8149 v13 = (double)v84 * 0.000015258789;
8150 if ( v13 < 0.0 )
8151 v13 = 0.0;
8152 *(float *)&v84 = v13 * 31.0;
8153 v14 = *(float *)&v84 + 6.7553994e15;
8154 v71 = LODWORD(v14);
8155 v15 = (int)&v12->field_58;
8156 v12->field_58 = 31 - LOBYTE(v14);
8157 if ( (char)(31 - LOBYTE(v14)) < 0 )
8158 *(char *)v15 = 0;
8159 if ( *(char *)v15 > 31 )
8160 *(char *)v15 = 31;
8161 v16 = *(short *)(v3 + 272);
8162 if ( *(char *)(v3 + 29) & 0x40 )
8163 v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
8164 v17 = v16;
8165 result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
8166 v19 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
8167 v18 = pOutdoorCamera->numStru148s - 1999 < 0;
8168 v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0);
8169 if ( !(v18 ^ v19) )
8170 return result;
8171 ++pOutdoorCamera->numStru148s;
8172 ++pOutdoorCamera->field_44;
8173 if ( !ODMFace::IsBackfaceCulled((ODMFace *)v3, array_73D150, v12) )
8174 {
8175 LABEL_71:
8176 --pOutdoorCamera->numStru148s;
8177 --pOutdoorCamera->field_44;
8178 goto LABEL_72;
8179 }
8180 LOBYTE(v20) = v79;
8181 v21 = a1;
8182 *(char *)(v3 + 305) = 1;
8183 v12->uBModelFaceID = v20;
8184 LOWORD(v20) = (unsigned __int8)v20;
8185 v12->uBModelID = v21;
8186 v22 = 8 * (v20 | (v21 << 6));
8187 LOBYTE(v22) = v22 | 6;
8188 v12->field_50 = v22;
8189 if ( *(char *)(v3 + 28) & 0x10 )
8190 *(int *)&v12->flags |= 2u;
8191 if ( *(char *)(v3 + 30) & 0x40 )
8192 HIBYTE(v12->flags) |= 4u;
8193 v23 = *(int *)(v3 + 28);
8194 if ( v23 & 4 )
8195 {
8196 HIBYTE(v12->flags) |= 4u;
8197 }
8198 else
8199 {
8200 if ( v23 & 0x20 )
8201 HIBYTE(v12->flags) |= 8u;
8202 }
8203 v24 = *(int *)(v3 + 28);
8204 if ( BYTE1(v24) & 8 )
8205 {
8206 HIBYTE(v12->flags) |= 0x20u;
8207 }
8208 else
8209 {
8210 if ( v24 & 0x40 )
8211 HIBYTE(v12->flags) |= 0x10u;
8212 }
8213 v25 = v12->pTexture;
8214 v26 = v77;
8215 v27 = v25->uTextureWidth;
8216 v84 = v25->uTextureHeight;
8217 v28 = 1.0 / (double)v27;
8218 v29 = 1.0 / (double)v84;
8219 if ( v77 > 0 )
8220 {
8221 v30 = v3 + 112;
8222 v31 = 0;
8223 v83 = v77;
8224 do
8225 {
8226 v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001);
8227 memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31]));
8228 ++v31;
8229 array_50A2B0[v31 + 49].flt_20 = v32;
8230 v84 = v12->sTextureDeltaU + *(short *)(v30 - 40);
8231 array_50A2B0[v31 + 49].u = (double)v84 * v28;
8232 v33 = v12->sTextureDeltaV + *(short *)v30;
8233 v30 += 2;
8234 v34 = v83-- == 1;
8235 v84 = v33;
8236 array_50A2B0[v31 + 49].v = (double)v33 * v29;
8237 }
8238 while ( !v34 );
8239 v3 = v76;
8240 v26 = v77;
8241 }
8242
8243 static stru154 static_sub_004789DE_stru_73C818; // idb
8244 /*static bool __init_flag = false;
8245 if (!__init_flag)
8246 {
8247 __init_flag = true;
8248
8249 static_sub_004789DE_byte_73C830__init_flag |= 1u;
8250 stru154::stru154(&static_sub_004789DE_stru_73C818);
8251 }*/
8252
8253 pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
8254 if ( stru_F8AD28.field_AC <= 0 )
8255 {
8256 v12->field_108 = 0;
8257 }
8258 else
8259 {
8260 v35 = (BSPVertexBuffer *)(v78 - 2);
8261 v12->field_108 = 1;
8262
8263 static_sub_004789DE_stru_73C818._49B04D((ODMFace *)v3, v35);
8264 v55 = static_sub_004789DE_stru_73C818.vNormal.x;
8265 v56 = static_sub_004789DE_stru_73C818.vNormal.y;
8266 v57 = static_sub_004789DE_stru_73C818.vNormal.z;
8267 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
8268 }
8269 if ( v74 )
8270 {
8271 v36 = sr_4250FE(v26);
8272 v37 = v36;
8273 if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) )
8274 goto LABEL_71;
8275 v12->_48276F_sr();
8276 v39 = 0;
8277 if ( (signed int)v12->uNumVertices > 0 )
8278 {
8279 v40 = (char *)&array_508690[0].vWorldViewProjY;
8280 do
8281 {
8282 LODWORD(v64) = *((int *)v40 - 1);
8283 v41 = v64 + 6.7553994e15;
8284 v69 = LODWORD(v41);
8285 dword_50B638[v39] = LODWORD(v41);
8286 LODWORD(v63) = *(int *)v40;
8287 v42 = v63 + 6.7553994e15;
8288 v73 = LODWORD(v42);
8289 v40 += 48;
8290 dword_50B570[v39++] = LODWORD(v42);
8291 }
8292 while ( v39 < (signed int)v12->uNumVertices );
8293 }
8294 }
8295 else
8296 {
8297 if ( v75 )
8298 {
8299 v43 = sr_4252E8(v26);
8300 v44 = v43;
8301 if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) )
8302 goto LABEL_71;
8303 v12->_48276F_sr();
8304 v46 = 0;
8305 if ( (signed int)v12->uNumVertices > 0 )
8306 {
8307 v47 = (char *)&array_508690[0].vWorldViewProjY;
8308 do
8309 {
8310 LODWORD(v61) = *((int *)v47 - 1);
8311 v48 = v61 + 6.7553994e15;
8312 v65 = LODWORD(v48);
8313 dword_50B638[v46] = LODWORD(v48);
8314 LODWORD(v58) = *(int *)v47;
8315 v49 = v58 + 6.7553994e15;
8316 v59 = LODWORD(v49);
8317 v47 += 48;
8318 dword_50B570[v46++] = LODWORD(v49);
8319 }
8320 while ( v46 < (signed int)v12->uNumVertices );
8321 }
8322 }
8323 else
8324 {
8325 v50 = sr_4254D2(v26);
8326 v12->uNumVertices = v50;
8327 if ( !v50 )
8328 goto LABEL_71;
8329 sr_sub_4829B9(
8330 &array_73D150[*(char *)(v3 + 298)],
8331 &array_73D150[*(char *)(v3 + 299)],
8332 &array_73D150[*(char *)(v3 + 300)],
8333 v12,
8334 0);
8335 v51 = 0;
8336 if ( (signed int)v12->uNumVertices > 0 )
8337 {
8338 v52 = (char *)&array_508690[0].vWorldViewProjY;
8339 do
8340 {
8341 LODWORD(v62) = *((int *)v52 - 1);
8342 v53 = v62 + 6.7553994e15;
8343 v60 = LODWORD(v53);
8344 dword_50B638[v51] = LODWORD(v53);
8345 LODWORD(v72) = *(int *)v52;
8346 v54 = v72 + 6.7553994e15;
8347 v70 = LODWORD(v54);
8348 v52 += 48;
8349 dword_50B570[v51++] = LODWORD(v54);
8350 }
8351 while ( v51 < (signed int)v12->uNumVertices );
8352 }
8353 }
8354 }
8355 sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638, dword_50B570, v12);
8356 }
8357 LABEL_72:
8358 ++v79;
8359 v1 = v78;
8360 v3 += 308;
8361 v76 = v3;
8362 if ( v79 >= v68 )
8363 goto LABEL_73;
8364 }
8365 }
8366 return result;
8367 }
8368 // 50B570: using guessed type int dword_50B570[];
8369 // 50B638: using guessed type int dword_50B638[];
8370 // 73C830: using guessed type char static_sub_004789DE_byte_73C830__init_flag;
8371
8372 //----- (00479089) --------------------------------------------------------
8373 bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused)
8374 {
8375 BSPModel *v2; // eax@1
8376 int v3; // edi@1
8377 int v4; // ebx@1
8378 int v5; // ST28_4@1
8379 int v6; // ecx@1
8380 int v7; // ebx@3
8381 int v8; // eax@3
8382 int v9; // eax@3
8383 int v10; // ebx@3
8384 signed int v11; // esi@6
8385 int v12; // esi@8
8386 bool result; // eax@9
8387 unsigned int v14; // [sp+Ch] [bp-20h]@1
8388 int v15; // [sp+Ch] [bp-20h]@5
8389 int *v16; // [sp+10h] [bp-1Ch]@1
8390 int v17; // [sp+1Ch] [bp-10h]@1
8391 int v18; // [sp+20h] [bp-Ch]@1
8392 int v19; // [sp+20h] [bp-Ch]@3
8393 int angle; // [sp+24h] [bp-8h]@1
8394 int v21; // [sp+28h] [bp-4h]@1
8395 int v22; // [sp+28h] [bp-4h]@3
8396
8397 v16 = unused;
8398 angle = (signed int)(pOutdoorCamera->uCameraFovInDegrees << 11) / 360 >> 1;
8399 v14 = uModelID;
8400 v2 = &pOutdoor->pBModels[uModelID];
8401 v3 = v2->vBoundingCenter.x - pIndoorCamera->pos.x;
8402 v4 = v2->vBoundingCenter.y - pIndoorCamera->pos.y;
8403 v5 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
8404 v21 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
8405 v18 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX);
8406 stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi);
8407 v6 = v5;
8408 v17 = v3 * v5 + v4 * v21;
8409 if ( pIndoorCamera->sRotationX )
8410 v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16;
8411 v19 = v4 * v6 - v3 * v21;
8412 v7 = abs(v4);
8413 v8 = abs(v3);
8414 v9 = sub_4621DA(v8, v7, 0);
8415 v10 = v14 * 188;
8416 v22 = v9;
8417 *v16 = 0;
8418 if ( v9 < pOutdoor->pBModels[v14].sBoundingRadius + 256 )
8419 *v16 = 1;
8420 v15 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8421 if ( v19 >= 0 )
8422 v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16)
8423 - ((unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)v19) >> 16);
8424 else
8425 v11 = ((unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)v19) >> 16)
8426 + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16);
8427 v12 = v11 >> 16;
8428 if ( v22 <= pOutdoorCamera->shading_dist_mist + 2048 )
8429 {
8430 if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 )
8431 {
8432 result = v12 < 0;
8433 LOBYTE(result) = v12 >= 0;
8434 }
8435 else
8436 {
8437 result = 1;
8438 }
8439 }
8440 else
8441 {
8442 result = 0;
8443 }
8444 return result;
8445 }
8446
8447
8448
8449
8450 //----- (00479295) --------------------------------------------------------
8451 int stru148::_479295()
8452 {
8453 stru148 *v1; // edi@1
8454 ODMFace *v2; // esi@1
8455 int v3; // ecx@4
8456 int v4; // eax@4
8457 int v5; // edx@4
8458 int v6; // ST14_4@5
8459 int v7; // ST04_4@5
8460 stru149 *v8; // ecx@5
8461 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
8462 int v11; // [sp+18h] [bp-4h]@4
8463
8464 v1 = this;
8465 v2 = this->pODMFace;
8466 if ( !v2->pFacePlane.vNormal.z )
8467 {
8468 v3 = v2->pFacePlane.vNormal.x;
8469 v4 = -v2->pFacePlane.vNormal.y;
8470 LABEL_9:
8471 v5 = 0;
8472 v11 = 65536;
8473 goto LABEL_5;
8474 }
8475 if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
8476 {
8477 thisa.x = -v2->pFacePlane.vNormal.y;
8478 thisa.y = v2->pFacePlane.vNormal.x;
8479 thisa.z = 0;
8480 thisa.Normalize_float();
8481 v4 = thisa.x;
8482 v3 = thisa.y;
8483 goto LABEL_9;
8484 }
8485 v3 = 0;
8486 v4 = 65536;
8487 v11 = 0;
8488 v5 = -65536;
8489 LABEL_5:
8490 v6 = v11;
8491 v1->sTextureDeltaU = v2->sTextureDeltaU;
8492 v7 = v3;
8493 v8 = v1->ptr_38;
8494 v1->sTextureDeltaV = v2->sTextureDeltaV;
8495 v8->_48616B(v4, v7, 0, 0, v5, v6);
8496 return 1;
8497 }
8498
8499 //----- (00479332) --------------------------------------------------------
8500 int Render::OnOutdoorRedrawSW()
8501 {
8502 signed int result; // eax@1
8503 unsigned int v1; // edi@1
8504 char *v2; // esi@2
8505 char v3; // cl@3
8506 double v4; // st7@4
8507 float v5; // ST34_4@6
8508 double v6; // ST24_8@6
8509 int v7; // eax@6
8510 unsigned int v8; // eax@11
8511 signed int v9; // eax@13
8512 Vec3_float_ *v10; // eax@14
8513 double v11; // st7@17
8514 float v12; // ST34_4@19
8515 double v13; // ST1C_8@19
8516 float v14; // [sp+4h] [bp-34h]@1
8517 float v15; // [sp+8h] [bp-30h]@1
8518 float v16; // [sp+Ch] [bp-2Ch]@1
8519
8520 v14 = (double)pOutdoor->vSunlight.x * 0.000015258789;
8521 result = 0;
8522 v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s];
8523 v15 = (double)pOutdoor->vSunlight.y * 0.000015258789;
8524 v16 = (double)pOutdoor->vSunlight.z * 0.000015258789;
8525 if ( v1 > (unsigned int)array_77EC08 )
8526 {
8527 v2 = (char *)&array_77EC08[0].pODMFace;
8528 while ( 1 )
8529 {
8530 v3 = v2[5];
8531 if ( v3 == 5 )
8532 break;
8533 if ( v3 == 1 )
8534 {
8535 v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1)
8536 + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))];
8537 if ( v9 > (signed int)(uNumTerrainNormals - 1) )
8538 v10 = 0;
8539 else
8540 v10 = &pTerrainNormals[v9];
8541 if ( v10 )
8542 {
8543 v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x);
8544 if ( v11 < 0.0 )
8545 v11 = 0.0;
8546 v12 = v11 * 31.0;
8547 v13 = v12 + 6.7553994e15;
8548 v2[4] = 31 - LOBYTE(v13);
8549 }
8550 else
8551 {
8552 v2[4] = 0;
8553 }
8554 if ( v2[4] < 0 )
8555 v2[4] = 0;
8556 goto LABEL_23;
8557 }
8558 LABEL_24:
8559 v2 += 268;
8560 if ( (unsigned int)(v2 - 84) >= v1 )
8561 return result;
8562 }
8563 v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16)
8564 + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16)
8565 + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16))
8566 * 0.000015258789;
8567 if ( v4 < 0.0 )
8568 v4 = 0.0;
8569 v5 = v4 * 31.0;
8570 v6 = v5 + 6.7553994e15;
8571 v7 = (int)(v2 + 4);
8572 v2[4] = 31 - LOBYTE(v6);
8573 if ( (char)(31 - LOBYTE(v6)) < 0 )
8574 *(char *)v7 = 0;
8575 if ( *(char *)v7 > 31 )
8576 *(char *)v7 = 31;
8577 if ( *(char *)(*(int *)v2 + 29) & 0x40 )
8578 {
8579 v8 = pTextureFrameTable->GetFrameTexture(
8580 *((short *)v2 - 4),
8581 pEventTimer->uTotalGameTimeElapsed);
8582 *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0;
8583 }
8584 LABEL_23:
8585 result = 1;
8586 goto LABEL_24;
8587 }
8588 return result;
8589 }
8590
8591 //----- (00479543) --------------------------------------------------------
8592 void Render::DrawSkyD3D()
8593 {
8594 int v0; // esi@2
8595 int v1; // eax@2
8596 double v2; // st7@2
8597 double v3; // st6@2
8598 double v4; // st5@2
8599 double v5; // st4@2
8600 double v6; // st7@2
8601 char *v7; // esi@3
8602 int v8; // eax@4
8603 int v9; // eax@4
8604 int v10; // ebx@4
8605 signed __int64 v11; // qax@6
8606 double v12; // st7@6
8607 int v13; // edi@6
8608 int v14; // ecx@6
8609 int v15; // eax@8
8610 int v16; // eax@12
8611 signed __int64 v17; // qtt@13
8612 signed int v18; // ecx@13
8613 Texture *v19; // eax@15
8614 double v20; // st6@15
8615 double v21; // st7@15
8616 double v22; // st6@15
8617 unsigned __int8 v23; // sf@15
8618 unsigned __int8 v24; // of@15
8619 stru148 _this; // [sp+14h] [bp-150h]@1
8620 double v26; // [sp+120h] [bp-44h]@4
8621 float v27; // [sp+128h] [bp-3Ch]@4
8622 float v28; // [sp+12Ch] [bp-38h]@2
8623 int v29; // [sp+130h] [bp-34h]@4
8624 int v30; // [sp+134h] [bp-30h]@1
8625 int v31; // [sp+138h] [bp-2Ch]@2
8626 int v32; // [sp+13Ch] [bp-28h]@6
8627 int v33; // [sp+140h] [bp-24h]@2
8628 float v34; // [sp+144h] [bp-20h]@1
8629 int v35; // [sp+148h] [bp-1Ch]@4
8630 double v36; // [sp+14Ch] [bp-18h]@2
8631 int v37; // [sp+154h] [bp-10h]@8
8632 int v38; // [sp+158h] [bp-Ch]@1
8633 int v39; // [sp+15Ch] [bp-8h]@4
8634 int v40; // [sp+160h] [bp-4h]@7
8635
8636 v30 = (signed __int64)((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
8637 / ((double)pOutdoorCamera->int_fov_rad + 8192.0)
8638 + (double)pViewport->uScreenCenterY);
8639 v34 = cos((double)pIndoorCamera->sRotationX * 0.0030664064) * (double)pOutdoorCamera->shading_dist_mist;
8640 v38 = (signed __int64)((double)pViewport->uScreenCenterY
8641 - (double)pOutdoorCamera->int_fov_rad
8642 / (v34 + 0.0000001)
8643 * (sin((double)pIndoorCamera->sRotationX * 0.0030664064)
8644 * (double)-pOutdoorCamera->shading_dist_mist
8645 - (double)pIndoorCamera->pos.z));
8646 _this._48607B(&stru_8019C8);
8647 _this.ptr_38->_48694B();
8648 _this.uTileBitmapID = LOWORD(pOutdoor->uSky_TextureID);
8649 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
8650 if ( _this.pTexture )
8651 {
8652 v0 = pIndoorCamera->sRotationX;
8653 _this.field_58 = 0;
8654 _this.uNumVertices = 4;
8655 _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16);
8656 _this.v_18.y = 0;
8657 v1 = stru_5C6E00->SinCos(v0 + 16);
8658 v2 = (double)(signed int)pViewport->uViewportX;
8659 _this.v_18.z = -v1;
8660 array_50AC10[0].vWorldViewProjX = v2;
8661 v3 = (double)(signed int)pViewport->uViewportY;
8662 array_50AC10[0].vWorldViewProjY = v3;
8663 array_50AC10[1].vWorldViewProjX = v2;
8664 v4 = (double)v38;
8665 _this.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
8666 _this.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
8667 v28 = v4;
8668 array_50AC10[1].vWorldViewProjY = v4;
8669 v5 = (double)(signed int)pViewport->uViewportZ;
8670 array_50AC10[2].vWorldViewProjX = v5;
8671 v38 = pViewport->uViewportZ - pViewport->uViewportX;
8672 _this.field_24 = 0x2000000u;
8673 array_50AC10[2].vWorldViewProjY = v4;
8674 array_50AC10[3].vWorldViewProjX = v5;
8675 array_50AC10[3].vWorldViewProjY = v3;
8676 v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
8677 v6 = tan(0.6457717418670654);
8678 v31 = 0;
8679 v33 = 65536 / (signed int)(signed __int64)(v36 / v6 + 0.5);
8680 if ( (signed int)_this.uNumVertices <= 0 )
8681 goto LABEL_16;
8682 v7 = (char *)&array_50AC10[0].vWorldViewProjY;
8683 while ( 1 )
8684 {
8685 LODWORD(v27) = *(int *)v7;
8686 v26 = v27 + 6.7553994e15;
8687 v29 = LODWORD(v26);
8688 v38 = _this.ptr_38->field_14;
8689 v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
8690 v8 = v39 + _this.ptr_38->field_C;
8691 v39 = v33 * (v30 - LODWORD(v26));
8692 v35 = v8;
8693 v38 = _this.ptr_38->field_20;
8694 v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
8695 HIDWORD(v36) = v39 + _this.ptr_38->field_18;
8696 v38 = _this.v_18.z;
8697 v9 = (unsigned __int64)(_this.v_18.z * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
8698 v10 = _this.v_18.x + v9;
8699 v39 = _this.v_18.x + v9;
8700 if ( _this.v_18.x + v9 > 0 )
8701 {
8702 v10 = 0;
8703 v39 = 0;
8704 }
8705 v11 = (signed __int64)*((float *)v7 - 1);
8706 v38 = v10;
8707 v12 = *(float *)v7 - 1.0;
8708 v13 = v33 * (pViewport->uScreenCenterX - v11);
8709 LODWORD(v34) = -_this.field_24;
8710 v32 = (signed __int64)v12;
8711 v14 = v33 * (v30 - v32);
8712 while ( 1 )
8713 {
8714 v40 = v14;
8715 if ( !v10 )
8716 goto LABEL_12;
8717 v37 = abs(SLODWORD(v34) >> 14);
8718 v15 = abs(v10);
8719 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportY )
8720 {
8721 if ( v39 <= 0 )
8722 break;
8723 }
8724 v14 = v40;
8725 LABEL_12:
8726 v37 = _this.v_18.z;
8727 v16 = (unsigned __int64)(_this.v_18.z * (signed __int64)v14) >> 16;
8728 --v32;
8729 v14 += v33;
8730 v10 = _this.v_18.x + v16;
8731 v39 = _this.v_18.x + v16;
8732 v38 = _this.v_18.x + v16;
8733 }
8734 LODWORD(v17) = LODWORD(v34) << 16;
8735 HIDWORD(v17) = SLODWORD(v34) >> 16;
8736 v40 = v17 / v38;
8737 v18 = v17 / v38;
8738 if ( v18 < 0 )
8739 v18 = pOutdoorCamera->shading_dist_mist;
8740 v40 = v13;
8741 v37 = _this.ptr_38->field_10;
8742 v40 = v13;
8743 v37 = v35 + ((unsigned __int64)(v37 * (signed __int64)v13) >> 16);
8744 v35 = _this.ptr_38->field_1C;
8745 HIDWORD(v36) += (unsigned __int64)(v35 * (signed __int64)v13) >> 16;
8746 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed
8747 + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3);
8748 v40 = (unsigned __int64)(SHIDWORD(v36) * (signed __int64)v18) >> 16;
8749 v19 = _this.pTexture;
8750 HIDWORD(v36) = _this.pTexture->uTextureWidth;
8751 v7 += 48;
8752 v20 = (double)SHIDWORD(v36) * 65536.0;
8753 HIDWORD(v36) = 224 * pMiscTimer->uTotalGameTimeElapsed + (v40 >> 3);
8754 ++v31;
8755 *((float *)v7 - 10) = (double)v35 / v20;
8756 v21 = (double)SHIDWORD(v36);
8757 HIDWORD(v36) = v19->uTextureHeight;
8758 v22 = (double)SHIDWORD(v36);
8759 HIDWORD(v36) = v18 >> 16;
8760 v24 = __OFSUB__(v31, _this.uNumVertices);
8761 v23 = ((v31 - _this.uNumVertices) & 0x80000000u) != 0;
8762 *((float *)v7 - 9) = v21 / (v22 * 65536.0);
8763 *((float *)v7 - 16) = (double)pOutdoorCamera->shading_dist_mist;
8764 *((float *)v7 - 11) = 1.0 / (double)SHIDWORD(v36);
8765 if ( !(v23 ^ v24) )
8766 {
8767 LABEL_16:
8768 pRenderer->DrawFan(
8769 _this.uNumVertices,
8770 &_this,
8771 pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
8772 array_50AC10[0].vWorldViewProjY = v28;
8773 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
8774 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
8775 array_50AC10[3].vWorldViewProjY = v28;
8776 pRenderer->DrawFan(
8777 _this.uNumVertices,
8778 &_this,
8779 pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
8780 return;
8781 }
8782 }
8783 }
8784 }
8785
8786
8787 //----- (00479A53) --------------------------------------------------------
8788 void __fastcall sub_479A53(unsigned int uNumVertices, unsigned int uFaceID)
8789 {
8790 BLVFace *pFace; // esi@1
8791 unsigned int v3; // edi@1
8792 PolygonType v4; // al@1
8793 double v5; // st7@3
8794 signed __int64 v6; // qax@3
8795 PolygonType v7; // cl@3
8796 int v8; // esi@7
8797 int v9; // eax@7
8798 unsigned int v10; // eax@7
8799 double v11; // st6@7
8800 int v12; // edx@7
8801 int v13; // eax@7
8802 char *v14; // esi@8
8803 void *v15; // ecx@9
8804 int v16; // eax@9
8805 int v17; // edi@9
8806 double v18; // st7@9
8807 signed int v19; // ebx@9
8808 void *v20; // ecx@9
8809 int v21; // ebx@11
8810 int v22; // eax@14
8811 signed __int64 v23; // qtt@16
8812 double v24; // st7@16
8813 unsigned __int8 v25; // sf@16
8814 unsigned __int8 v26; // of@16
8815 Render *v27; // ecx@17
8816 double v28; // st7@20
8817 char *v29; // ebx@20
8818 char *v30; // edx@20
8819 unsigned __int8 v31; // c0@21
8820 unsigned __int8 v32; // c3@21
8821 double v33; // st6@23
8822 char *v34; // esi@30
8823 const void *v35; // ecx@31
8824 int v36; // eax@31
8825 const void *v37; // edi@31
8826 signed __int64 v38; // qax@31
8827 int v39; // ecx@31
8828 int v40; // ebx@33
8829 int v41; // eax@36
8830 signed __int64 v42; // qtt@39
8831 int v43; // eax@39
8832 char v44; // zf@39
8833 double v45; // st7@39
8834 double v46; // st7@39
8835 unsigned int v47; // edx@40
8836 double v48; // st7@41
8837 RenderVertexSoft *v49; // ebx@41
8838 void *v50; // edi@43
8839 double v51; // st7@46
8840 RenderVertexSoft *v52; // edx@46
8841 void *v53; // edi@48
8842 char *v54; // ebx@52
8843 unsigned int v55; // eax@53
8844 unsigned int v56; // eax@55
8845 int v57; // ST10_4@55
8846 Texture *v58; // eax@55
8847 signed int v59; // [sp-4h] [bp-178h]@17
8848 stru148 *v60; // [sp+0h] [bp-174h]@17
8849 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
8850 stru148 v62; // [sp+14h] [bp-160h]@6
8851 unsigned int v63; // [sp+120h] [bp-54h]@7
8852 double v64; // [sp+124h] [bp-50h]@7
8853 unsigned int v65; // [sp+128h] [bp-4Ch]@1
8854 unsigned int v66; // [sp+12Ch] [bp-48h]@7
8855 float v67; // [sp+130h] [bp-44h]@7
8856 __int64 v68; // [sp+134h] [bp-40h]@3
8857 __int64 v69; // [sp+13Ch] [bp-38h]@3
8858 int v70; // [sp+144h] [bp-30h]@3
8859 int X; // [sp+148h] [bp-2Ch]@9
8860 int v72; // [sp+14Ch] [bp-28h]@7
8861 float v73; // [sp+150h] [bp-24h]@16
8862 unsigned int v74; // [sp+154h] [bp-20h]@3
8863 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
8864 float v76; // [sp+15Ch] [bp-18h]@9
8865 int v77; // [sp+160h] [bp-14h]@9
8866 int v78; // [sp+164h] [bp-10h]@7
8867 void *v79; // [sp+168h] [bp-Ch]@9
8868 float v80; // [sp+16Ch] [bp-8h]@3
8869 const void *v81; // [sp+170h] [bp-4h]@7
8870
8871 pFace = &pIndoor->pFaces[uFaceID];
8872 v65 = uFaceID;
8873 v3 = uNumVertices;
8874 v4 = pFace->uPolygonType;
8875 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
8876 {
8877 if ( (signed int)uNumVertices > 0 )
8878 {
8879 v54 = (char *)&array_507D30[0].u;
8880 LODWORD(v80) = uNumVertices;
8881 do
8882 {
8883 v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x;
8884 *(float *)v54 = (double)v69 + *(float *)v54;
8885 *(float *)v54 = *(float *)v54 * 0.25;
8886 v55 = GetTickCount();
8887 v54 += 48;
8888 v44 = LODWORD(v80)-- == 1;
8889 v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5);
8890 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
8891 }
8892 while ( !v44 );
8893 uFaceID = v65;
8894 }
8895 v56 = 8 * uFaceID;
8896 LOBYTE(v56) = 8 * uFaceID | 6;
8897 v57 = v56;
8898 v58 = pFace->GetTexture();
8899 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
8900 return;
8901 }
8902 HIDWORD(v69) = pIndoorCamera->sRotationX;
8903 HIDWORD(v68) = pIndoorCamera->pos.z;
8904 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
8905 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z)
8906 / (((double)pBLVRenderParams->field_40 + 16192.0)
8907 * 65536.0)
8908 + *(float *)&v74);
8909 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064;
8910 *(float *)&v75 = v5;
8911 v80 = cos(v5) * 16192.0;
8912 v6 = (signed __int64)(*(float *)&v74
8913 - (double)pBLVRenderParams->field_40
8914 / ((v80 + 0.0000001)
8915 * 65535.0)
8916 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
8917 v7 = pFace->uPolygonType;
8918 if ( v7 == 4 || v7 == 3 )
8919 v70 = v6;
8920 stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
8921 v62._48607B(&stru_8019C8);
8922 v62.uTileBitmapID = pFace->uBitmapID;
8923 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
8924 if ( !v62.pTexture )
8925 return;
8926 v8 = pBLVRenderParams->sPartyRotX;
8927 v62.field_58 = 0;
8928 v62.uNumVertices = v3;
8929 v9 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX - stru_5C6E00->uIntegerHalfPi + 16);
8930 v62.v_18.y = 0;
8931 v62.v_18.x = -v9;
8932 v62.v_18.z = -stru_5C6E00->SinCos(v8 + 16);
8933 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
8934 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
8935 LODWORD(v80) = v10;
8936 v62.field_24 = 33554432;
8937 v64 = (double)(signed int)v10 * 0.5;
8938 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
8939 LODWORD(v80) = v62.pTexture->uTextureWidth;
8940 v11 = 1.0 / (double)SLODWORD(v80);
8941 LODWORD(v80) = v62.pTexture->uTextureHeight;
8942 v12 = v62.pTexture->uWidthMinus1;
8943 v13 = v62.pTexture->uHeightMinus1;
8944 v67 = v11;
8945 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
8946 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
8947 v78 = 0;
8948 v81 = 0;
8949 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
8950 if ( (signed int)v62.uNumVertices <= 0 )
8951 {
8952 LABEL_17:
8953 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
8954 v27 = pRenderer;
8955 v60 = &v62;
8956 v59 = v62.uNumVertices;
8957 goto LABEL_18;
8958 }
8959 v14 = (char *)&array_507D30[0].vWorldViewProjY;
8960 while ( 2 )
8961 {
8962 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
8963 LODWORD(v80) = v62.ptr_38->field_14;
8964 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
8965 v16 = v77 + v62.ptr_38->field_C;
8966 v77 = (int)v15;
8967 v74 = v16;
8968 LODWORD(v80) = v62.ptr_38->field_20;
8969 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
8970 v79 = v15;
8971 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
8972 LODWORD(v80) = v62.v_18.z;
8973 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
8974 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
8975 v18 = *(float *)v14 - 1.0;
8976 v19 = -v62.field_24;
8977 v77 = -v62.field_24;
8978 X = (int)((char *)v79 + v62.v_18.x);
8979 LODWORD(v76) = (signed __int64)v18;
8980 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
8981 while ( 1 )
8982 {
8983 v79 = v20;
8984 if ( !X )
8985 goto LABEL_14;
8986 v21 = abs(v19 >> 14);
8987 if ( v21 <= abs(X) )
8988 break;
8989 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
8990 break;
8991 v19 = v77;
8992 v20 = v79;
8993 LABEL_14:
8994 LODWORD(v80) = v62.v_18.z;
8995 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
8996 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
8997 --LODWORD(v76);
8998 v20 = (char *)v20 + v72;
8999 X = v22 + v62.v_18.x;
9000 v78 = 1;
9001 }
9002 if ( !v78 )
9003 {
9004 LODWORD(v23) = v77 << 16;
9005 HIDWORD(v23) = v77 >> 16;
9006 v79 = (void *)(v23 / X);
9007 v77 = v17;
9008 LODWORD(v80) = v62.ptr_38->field_10;
9009 v77 = v17;
9010 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
9011 LODWORD(v80) = v62.ptr_38->field_1C;
9012 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
9013 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
9014 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
9015 v14 += 48;
9016 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
9017 v81 = (char *)v81 + 1;
9018 v24 = (double)SLODWORD(v80) * 0.000015259022;
9019 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
9020 v26 = __OFSUB__((int)v81, v62.uNumVertices);
9021 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
9022 *((float *)v14 - 10) = v24 * v67;
9023 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
9024 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
9025 if ( !(v25 ^ v26) )
9026 goto LABEL_17;
9027 continue;
9028 }
9029 break;
9030 }
9031 LODWORD(v73) = 0;
9032 v80 = v76;
9033 if ( (signed int)v62.uNumVertices > 0 )
9034 {
9035 v28 = (double)SLODWORD(v76);
9036 LODWORD(v76) = (int)(char *)array_50AC10 + 28;
9037 v29 = (char *)&array_50AC10[0].vWorldViewProjX;
9038 v30 = (char *)&array_507D30[1].vWorldViewProjY;
9039 v79 = array_50AC10;
9040 v81 = array_507D30;
9041 v78 = v62.uNumVertices;
9042 do
9043 {
9044 v31 = v28 < *((float *)v30 - 12);
9045 v32 = v28 == *((float *)v30 - 12);
9046 ++LODWORD(v73);
9047 memcpy(v79, v81, 0x30u);
9048 v79 = (char *)v79 + 48;
9049 LODWORD(v76) += 48;
9050 v29 += 48;
9051 if ( v31 | v32 || v28 >= *(float *)v30 )
9052 {
9053 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 )
9054 goto LABEL_28;
9055 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12))
9056 + *((float *)v30 - 1);
9057 }
9058 else
9059 {
9060 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30)
9061 + *((float *)v30 - 13);
9062 }
9063 *(float *)v29 = v33;
9064 v79 = (char *)v79 + 48;
9065 v29 += 48;
9066 ++LODWORD(v73);
9067 *(unsigned int *)LODWORD(v76) = v28;
9068 LODWORD(v76) += 48;
9069 LABEL_28:
9070 v81 = (char *)v81 + 48;
9071 v30 += 48;
9072 --v78;
9073 }
9074 while ( v78 );
9075 }
9076 if ( SLODWORD(v73) <= 0 )
9077 goto LABEL_40;
9078 v34 = (char *)&array_50AC10[0].vWorldViewProjY;
9079 v65 = v77 >> 14;
9080 HIDWORD(v69) = LODWORD(v73);
9081 do
9082 {
9083 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
9084 v78 = v62.ptr_38->field_14;
9085 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
9086 v36 = (int)((char *)v81 + v62.ptr_38->field_C);
9087 v81 = v35;
9088 v74 = v36;
9089 v78 = v62.ptr_38->field_20;
9090 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
9091 v78 = (int)v35;
9092 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18);
9093 v81 = (const void *)v62.v_18.z;
9094 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16;
9095 v37 = (const void *)(v72
9096 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1)));
9097 v38 = (signed __int64)(*(float *)v34 - 1.0);
9098 v81 = 0;
9099 LODWORD(v76) = v38;
9100 v39 = v72 * (v70 - v38);
9101 while ( 1 )
9102 {
9103 v78 = v39;
9104 if ( !X )
9105 goto LABEL_36;
9106 v40 = abs(X);
9107 if ( abs((signed __int64)v65) <= v40 )
9108 break;
9109 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
9110 break;
9111 v39 = v78;
9112 LABEL_36:
9113 v78 = v62.v_18.z;
9114 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16;
9115 --LODWORD(v76);
9116 v39 += v72;
9117 X = v41 + v62.v_18.x;
9118 v81 = (const void *)1;
9119 }
9120 if ( v81 )
9121 {
9122 v79 = (void *)v62.v_18.z;
9123 v78 = 2 * LODWORD(v76);
9124 v81 = (const void *)((unsigned __int64)(v62.v_18.z
9125 * (signed __int64)(signed int)(signed __int64)(((double)v70
9126 - ((double)(2 * LODWORD(v76))
9127 - *(float *)v34))
9128 * (double)v72)) >> 16);
9129 X = (int)((char *)v81 + v62.v_18.x);
9130 }
9131 LODWORD(v42) = v77 << 16;
9132 HIDWORD(v42) = v77 >> 16;
9133 v79 = (void *)(v42 / X);
9134 v81 = v37;
9135 v78 = v62.ptr_38->field_10;
9136 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
9137 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
9138 v74 = (unsigned int)v37;
9139 LODWORD(v76) = v43;
9140 v78 = v62.ptr_38->field_1C;
9141 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
9142 v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
9143 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
9144 v34 += 48;
9145 v78 = v66 + ((signed int)v74 >> 4);
9146 v44 = HIDWORD(v69)-- == 1;
9147 v45 = (double)v78 * 0.000015259022;
9148 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
9149 *((float *)v34 - 10) = v45 * v67;
9150 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
9151 v46 = (double)(signed int)v79;
9152 *((float *)v34 - 16) = 0.000015258789 * v46;
9153 *((float *)v34 - 11) = 65536.0 / v46;
9154 }
9155 while ( !v44 );
9156 LABEL_40:
9157 v47 = 0;
9158 if ( SLODWORD(v73) > 0 )
9159 {
9160 v48 = (double)SLODWORD(v80);
9161 v75 = array_507D30;
9162 v49 = array_50AC10;
9163 HIDWORD(v69) = LODWORD(v73);
9164 do
9165 {
9166 if ( v48 >= v49->vWorldViewProjY )
9167 {
9168 v50 = v75;
9169 ++v47;
9170 ++v75;
9171 memcpy(v50, v49, 0x30u);
9172 }
9173 ++v49;
9174 --HIDWORD(v69);
9175 }
9176 while ( HIDWORD(v69) );
9177 }
9178 v62.uNumVertices = v47;
9179 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]);
9180 *(float *)&v74 = 0.0;
9181 if ( SLODWORD(v73) > 0 )
9182 {
9183 v51 = (double)SLODWORD(v80);
9184 v75 = array_507D30;
9185 v52 = array_50AC10;
9186 v80 = v73;
9187 do
9188 {
9189 if ( v51 <= v52->vWorldViewProjY )
9190 {
9191 v53 = v75;
9192 ++v74;
9193 ++v75;
9194 memcpy(v53, v52, 0x30u);
9195 }
9196 ++v52;
9197 --LODWORD(v80);
9198 }
9199 while ( v80 != 0.0 );
9200 }
9201 v62.uNumVertices = v74;
9202 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
9203 v60 = &v62;
9204 v59 = v74;
9205 v27 = pRenderer;
9206 LABEL_18:
9207 v27->_4A2ED5(v59, v60, v61);
9208 }
9209
9210 //----- (0047A384) --------------------------------------------------------
9211 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa)
9212 {
9213 int v2; // ebx@3
9214 unsigned int v3; // eax@3
9215 MapInfo *v4; // edi@4
9216 int v5; // eax@8
9217 SpawnPointMM7 *v6; // edx@14
9218 size_t v7; // eax@19
9219 char *v8; // eax@19
9220 char *v9; // eax@21
9221 char Source[120]; // [sp+Ch] [bp-84h]@19
9222 const char *pFilename; // [sp+84h] [bp-Ch]@1
9223 unsigned int v12; // [sp+88h] [bp-8h]@12
9224 int v13; // [sp+8Ch] [bp-4h]@11
9225
9226 pFilename = pLevelFilename;
9227 thisa->AllocSoftwareDrawBuffers();
9228 pOutdoorCamera->_485F64();
9229 pWeather->bRenderSnow = 0;
9230 pRenderer->ClearZBuffer(0, 479);
9231 thisa = (OutdoorCamera *)1;
9232 GetAlertStatus();
9233 if ( qword_A750D8 )
9234 qword_A750D8 = 0i64;
9235 v2 = pMapStats->GetMapInfo(pCurrentMapName);
9236 v3 = 0;
9237 if ( v2 )
9238 {
9239 v4 = &pMapStats->pInfos[v2];
9240 v3 = v4->uRespawnIntervalDays;
9241 }
9242 else
9243 {
9244 v4 = (MapInfo *)thisa;
9245 }
9246 day_attrib &= 0xFFFFFFFEu;
9247 dword_6BE13C_uCurrentlyLoadedLocationID = v2;
9248 pOutdoor->Initialize(
9249 pFilename,
9250 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1,
9251 v3,
9252 (int)&thisa);
9253 if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x20) )
9254 {
9255 UpdateActors();
9256 UpdateLayingItems();
9257 }
9258 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu;
9259 v5 = 0;
9260 if ( !v2 )
9261 thisa = 0;
9262 if ( thisa == (OutdoorCamera *)1 )
9263 {
9264 v13 = 0;
9265 if ( (signed int)pOutdoor->uNumSpawnPoints > 0 )
9266 {
9267 v12 = 0;
9268 while ( 1 )
9269 {
9270 v6 = &pOutdoor->pSpawnPoints[v12 / 0x18];
9271 if ( pOutdoor->pSpawnPoints[v12 / 0x18].uKind == 3 )
9272 SpawnEncounter(v4, v6, v5, v5, v5);
9273 else
9274 v4->SpawnRandomTreasure(v6);
9275 ++v13;
9276 v12 += 24;
9277 if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints )
9278 break;
9279 v5 = 0;
9280 }
9281 }
9282 RespawnGlobalDecorations();
9283 }
9284 pOutdoor->PrepareDecorations();
9285 pOutdoor->_47F223_LooksLikeGenerateMonsterLoot();
9286 pOutdoor->InitalizeActors(v2);
9287 pOutdoor->MessWithLUN();
9288 v7 = strlen("levels\\");
9289 strcpy(Source, &pFilename[v7]);
9290 strcpy(pOutdoor->pLevelFilename, Source);
9291 pWeather->Initialize();
9292 pIndoorCamera->sRotationY = pParty->sRotationY;
9293 pIndoorCamera->sRotationX = pParty->sRotationX;
9294 pOutdoorCamera->RotationToInts();
9295 pOutdoor->UpdateSunlightVectors();
9296 pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov;
9297 pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C;
9298 v8 = (char *)&array_77EC08[0].ptr_38;
9299 do
9300 {
9301 *(int *)v8 = (int)&stru_8019C8;
9302 v8 += 268;
9303 }
9304 while ( (signed int)v8 < (signed int)&unk_801A00 );
9305 v9 = (char *)&array_77EC08[0].prolly_tail;
9306 do
9307 {
9308 *((int *)v9 - 1) = 0;
9309 *(int *)v9 = 0;
9310 *((int *)v9 - 5) = 0;
9311 v9 += 268;
9312 }
9313 while ( (signed int)v9 < (signed int)&unk_801A0C );
9314 MM7Initialization();
9315 }
9316
9317
9318
9319 //----- (0047A825) --------------------------------------------------------
9320 bool LevelDecoration::_47A825()
9321 {
9322 bool v1; // ebx@1
9323 LevelDecoration *v2; // edi@1
9324
9325 v1 = 0;
9326 v2 = this;
9327 if ( pParty->uCurrentHour >= 1 || (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 178) )
9328 {
9329 v1 = 0;
9330 }
9331 else
9332 {
9333 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 164)
9334 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 165)
9335 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 166)
9336 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 167)
9337 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 168)
9338 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 169)
9339 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 170)
9340 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 171)
9341 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 172)
9342 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 173)
9343 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 174)
9344 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 175)
9345 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 176)
9346 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 177) )
9347 {
9348 v1 = 1;
9349 LOBYTE(v2->field_2) &= 0xDFu;
9350 return v1;
9351 }
9352 }
9353 LOBYTE(v2->field_2) |= 0x20u;
9354 return v1;
9355 }
9356
9357
9358
9359 //----- (0047BC6F) --------------------------------------------------------
9360 unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4)
9361 {
9362 int v4; // ebx@1
9363 int v6; // edx@4
9364 int v7; // ecx@5
9365 signed int v8; // eax@6
9366 signed __int64 v9; // qtt@11
9367 signed int v10; // eax@12
9368 int v11; // esi@17
9369 signed __int64 v12; // qtt@19
9370 double v13; // ST10_8@19
9371 int v14; // edi@25
9372 signed int v15; // edx@26
9373 signed __int64 v16; // qtt@29
9374 signed int v17; // eax@30
9375 int v18; // [sp+10h] [bp-8h]@1
9376 float a3a; // [sp+20h] [bp+8h]@19
9377
9378 v4 = a2;
9379 v18 = a2;
9380 if ( pParty->field_1613C )
9381 return PaletteManager::Get(a2);
9382 if ( !pWeather->field_FA0 )
9383 {
9384 if ( day_attrib & 1 )
9385 {
9386 v14 = day_fogrange_1 << 16;
9387 if ( a3 >= day_fogrange_1 << 16 )
9388 {
9389 if ( a3 <= day_fogrange_2 << 16 )
9390 {
9391 LODWORD(v16) = (a3 - v14) << 16;
9392 HIDWORD(v16) = (a3 - v14) >> 16;
9393 v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
9394 }
9395 else
9396 {
9397 v15 = 27;
9398 }
9399 }
9400 else
9401 {
9402 v15 = 0;
9403 }
9404 v17 = sub_43F55F(a1, v15);
9405 if ( v17 > 27 )
9406 v17 = 27;
9407 if ( !a3 )
9408 v17 = 27;
9409 v7 = v18;
9410 v6 = v17;
9411 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
9412 }
9413 v11 = a4;
9414 if ( a4 < 0 )
9415 v11 = 0;
9416 LODWORD(v12) = a3 << 16;
9417 HIDWORD(v12) = a3 >> 16;
9418 a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20)
9419 * pOutdoor->fFogDensity;
9420 v13 = a3a + 6.7553994e15;
9421 v10 = sub_43F55F(a1, LODWORD(v13) + v11);
9422 if ( v10 > 27 )
9423 v10 = 27;
9424 if ( v10 < a4 )
9425 v10 = a4;
9426 if ( v10 > pOutdoor->field_CBC_terrain_triangles_shade_type )
9427 v10 = pOutdoor->field_CBC_terrain_triangles_shade_type;
9428 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
9429 }
9430 v6 = 0;
9431 if ( pWeather->field_FA0 == 1 )
9432 {
9433 v8 = 67108864;
9434 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
9435 v8 = pParty->pPartyBuffs[16].uPower << 26;
9436 if ( a3 <= v8 )
9437 {
9438 if ( a3 > 0 )
9439 {
9440 LODWORD(v9) = a3 << 16;
9441 HIDWORD(v9) = a3 >> 16;
9442 v6 = (unsigned __int64)(27 * v9 / v8) >> 16;
9443 }
9444 }
9445 else
9446 {
9447 v6 = 27;
9448 }
9449 v10 = sub_43F55F(a1, v6);
9450 if ( v10 > 27 || !a3 )
9451 v10 = 27;
9452 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
9453 }
9454 v7 = 0;
9455 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
9456 }
9457 // 6BE030: using guessed type int day_attrib;
9458 // 6BE040: using guessed type int day_fogrange_1;
9459 // 6BE044: using guessed type int day_fogrange_2;
9460
9461
9462
9463
9464
9465
9466
9467
9468 //----- (0047BEB1) --------------------------------------------------------
9469 int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8)
9470 {
9471 stru148 *v8; // ebx@1
9472 signed int v9; // edx@1
9473 int v10; // eax@5
9474 signed int v11; // eax@9
9475 signed int v12; // eax@15
9476 signed __int64 v13; // qtt@21
9477 int *v14; // ecx@30
9478 int *v15; // edi@30
9479 int v16; // ebx@32
9480 signed __int64 v17; // qtt@37
9481 double v18; // ST10_8@37
9482 double v19; // ST10_8@38
9483 int v20; // edi@39
9484 int result; // eax@46
9485 int *v22; // eax@48
9486 signed int v23; // edx@51
9487 signed __int64 v24; // qtt@51
9488 int v25; // ecx@51
9489 signed int v26; // [sp+14h] [bp-4h]@1
9490 float v27; // [sp+28h] [bp+10h]@37
9491 float v28; // [sp+28h] [bp+10h]@38
9492 int v29; // [sp+2Ch] [bp+14h]@37
9493
9494 v8 = a2;
9495 v9 = a1;
9496 v26 = a1;
9497 if ( pParty->field_1613C )
9498 {
9499 *a5 = -1;
9500 *a6 = -1;
9501 *(char *)a7 = 1;
9502 LABEL_46:
9503 result = a8;
9504 *(char *)a8 = 0;
9505 return result;
9506 }
9507 if ( a1 < 0 )
9508 {
9509 v26 = v8->field_34 << 16;
9510 v9 = v8->field_34 << 16;
9511 }
9512 v10 = pWeather->field_FA0;
9513 if ( bUnderwater == 1 )
9514 v10 = 0;
9515 if ( !v10 )
9516 {
9517 if ( !(day_attrib & 1) && !bUnderwater )
9518 {
9519 v14 = a5;
9520 v15 = a6;
9521 if ( !v9 )
9522 {
9523 *a5 = 31;
9524 *a6 = -1;
9525 }
9526 v16 = v8->field_58 - terrain_gamma;
9527 if ( v16 >= 0 )
9528 {
9529 if ( v16 > 27 )
9530 v16 = 27;
9531 }
9532 else
9533 {
9534 v16 = 0;
9535 }
9536 *a6 = 27;
9537 if ( a4 )
9538 {
9539 v28 = pOutdoor->fFogDensity * 27.0;
9540 v19 = v28 + 6.7553994e15;
9541 v29 = LODWORD(v19);
9542 }
9543 else
9544 {
9545 LODWORD(v17) = v9 << 16;
9546 HIDWORD(v17) = v9 >> 16;
9547 v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16)
9548 + *a6)
9549 * pOutdoor->fFogDensity;
9550 v18 = v27 + 6.7553994e15;
9551 v29 = LODWORD(v18);
9552 }
9553 *v14 = v16 + v29;
9554 v20 = *v15;
9555 if ( v16 + v29 > v20 )
9556 *v14 = v20;
9557 if ( *v14 < v16 )
9558 *v14 = v16;
9559 if ( *v14 > pOutdoor->field_CBC_terrain_triangles_shade_type )
9560 *v14 = pOutdoor->field_CBC_terrain_triangles_shade_type;
9561 goto LABEL_45;
9562 }
9563 if ( v9 >= day_fogrange_1 << 16 )
9564 {
9565 if ( v9 <= day_fogrange_2 << 16 )
9566 {
9567 v23 = v9 - (day_fogrange_1 << 16);
9568 LODWORD(v24) = v23 << 16;
9569 HIDWORD(v24) = v23 >> 16;
9570 v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
9571 v22 = a5;
9572 *a5 = v25;
9573 if ( v25 > 27 )
9574 goto LABEL_54;
9575 v9 = v26;
9576 }
9577 else
9578 {
9579 v22 = a5;
9580 *a5 = 27;
9581 }
9582 }
9583 else
9584 {
9585 v22 = a5;
9586 *a5 = 0;
9587 }
9588 if ( v9 )
9589 {
9590 LABEL_55:
9591 if ( a4 )
9592 *v22 = 31;
9593 *a6 = 31;
9594 *(char *)a7 = 0;
9595 goto LABEL_59;
9596 }
9597 LABEL_54:
9598 *v22 = 27;
9599 goto LABEL_55;
9600 }
9601 if ( v10 == 1 )
9602 {
9603 v11 = 1;
9604 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 )
9605 {
9606 v12 = 0;
9607 }
9608 else
9609 {
9610 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
9611 {
9612 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime <= 0 )
9613 v11 = 0;
9614 else
9615 v11 = pParty->pPartyBuffs[16].uPower;
9616 }
9617 v12 = v11 << 26;
9618 }
9619 if ( a4 )
9620 goto LABEL_24;
9621 if ( v9 <= v12 )
9622 {
9623 if ( v9 > 0 )
9624 {
9625 LODWORD(v13) = v9 << 16;
9626 HIDWORD(v13) = v9 >> 16;
9627 v9 = v26;
9628 *a5 = (unsigned __int64)(27 * v13 / v12) >> 16;
9629 }
9630 if ( *a5 > 27 )
9631 goto LABEL_24;
9632 }
9633 else
9634 {
9635 *a5 = 27;
9636 }
9637 if ( v9 )
9638 {
9639 LABEL_25:
9640 if ( v8->field_32 & 4 )
9641 *a5 = 27;
9642 *a6 = 27;
9643 LABEL_45:
9644 *(char *)a7 = 0;
9645 goto LABEL_46;
9646 }
9647 LABEL_24:
9648 *a5 = 27;
9649 goto LABEL_25;
9650 }
9651 *a5 = -1;
9652 *a6 = -1;
9653 *(char *)a7 = 1;
9654 LABEL_59:
9655 result = a8;
9656 *(char *)a8 = 1;
9657 return result;
9658 }
9659 // 4D864C: using guessed type char byte_4D864C;
9660 // 6BE030: using guessed type int day_attrib;
9661 // 6BE040: using guessed type int day_fogrange_1;
9662 // 6BE044: using guessed type int day_fogrange_2;
9663 // 6BE3C4: using guessed type char bUnderwater;
9664
9665 //----- (0047C178) --------------------------------------------------------
9666 void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4)
9667 {
9668 stru148 *v4; // esi@1
9669 void *result; // eax@2
9670 int v6; // [sp+4h] [bp-8h]@3
9671 int v7; // [sp+8h] [bp-4h]@3
9672
9673 v4 = a2;
9674 if ( pParty->field_1613C )
9675 {
9676 result = PaletteManager::Get(HIWORD(a2->pTexture->palette));
9677 }
9678 else
9679 {
9680 sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3));
9681 result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7);
9682 }
9683 return result;
9684 }
9685
9686 //----- (0047C1CA) --------------------------------------------------------
9687 void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4)
9688 {
9689 stru148 *v4; // esi@1
9690 void *result; // eax@2
9691 int v6; // edx@3
9692 int v7; // ecx@8
9693 int a3a; // [sp+4h] [bp-8h]@1
9694 char v9; // [sp+8h] [bp-4h]@1
9695
9696 v9 = a2;
9697 v4 = a1;
9698 a3a = 1;
9699 if ( pParty->field_1613C )
9700 {
9701 result = PaletteManager::Get(HIWORD(a1->pTexture->palette));
9702 }
9703 else
9704 {
9705 v6 = pGame->_44EC23(a1, &a3a, a4);
9706 if ( v6 == -1 )
9707 v6 = a3;
9708 if ( v9 == 1 )
9709 {
9710 if ( v6 != -1 || a4 != -1 )
9711 {
9712 v7 = HIWORD(v4->pTexture->palette);
9713 }
9714 else
9715 {
9716 v6 = 0;
9717 v7 = 0;
9718 }
9719 result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a);
9720 }
9721 else
9722 {
9723 result = PaletteManager::Get_Dark_or_Red_LUT(HIWORD(v4->pTexture->palette), v6, a3a);
9724 }
9725 }
9726 return result;
9727 }
9728
9729 //----- (0047C24C) --------------------------------------------------------
9730 unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4)
9731 {
9732 int v4; // esi@1
9733 int v5; // eax@2
9734 int a3a; // [sp+4h] [bp-4h]@1
9735
9736 v4 = a2;
9737 a3a = 1;
9738 if ( a4 )
9739 {
9740 v5 = pGame->_44ED0A(a1, &a3a, 31);
9741 if ( v5 != -1 )
9742 a3 = v5;
9743 }
9744 return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a);
9745 }
9746
9747 //----- (0047C28C) --------------------------------------------------------
9748 char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4)
9749 {
9750 stru148 *v4; // esi@1
9751 char *result; // eax@2
9752 signed int v6; // eax@3
9753 int v7; // ecx@8
9754 int a2a; // [sp+4h] [bp-8h]@1
9755 char v9; // [sp+8h] [bp-4h]@1
9756
9757 v9 = a2;
9758 v4 = a1;
9759 a2a = 1;
9760 if ( pParty->field_1613C )
9761 {
9762 result = (char *)pPaletteManager->field_199600_palettes[HIWORD(a1->pTexture->palette)];
9763 }
9764 else
9765 {
9766 v6 = pGame->_44EC23(a1, &a2a, a4);
9767 if ( v6 != -1 )
9768 a3 = v6;
9769 if ( v9 == 1 )
9770 {
9771 if ( a3 != -1 || a4 != -1 )
9772 v7 = HIWORD(v4->pTexture->palette);
9773 else
9774 v7 = 0;
9775 result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a);
9776 }
9777 else
9778 {
9779 result = (char *)PaletteManager::_47C33F_get_palette(HIWORD(v4->pTexture->palette), a2a);
9780 }
9781 }
9782 return result;
9783 }
9784
9785 // 4D864C: using guessed type char byte_4D864C;
9786
9787
9788 //----- (0047C370) --------------------------------------------------------
9789 unsigned int __cdecl GetLevelFogColor()
9790 {
9791 unsigned int result; // eax@2
9792 signed __int64 v1; // qax@5
9793 int v2; // eax@6
9794
9795 if ( bUnderwater )
9796 {
9797 result = 0xFF258F5Cu;
9798 }
9799 else
9800 {
9801 if ( day_attrib & 1 )
9802 {
9803 if ( pWeather->field_FA0 )
9804 {
9805 v2 = -(pWeather->field_FA0 != 1);
9806 result = (v2 & 0xE0E0E1) - 0xE0E0E1;
9807 }
9808 else
9809 {
9810 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0);
9811 result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8);
9812 }
9813 }
9814 else
9815 {
9816 result = 0;
9817 }
9818 }
9819 return result;
9820 }
9821 // 6BE030: using guessed type int day_attrib;
9822 // 6BE3C4: using guessed type char bUnderwater;
9823
9824 //----- (0047C3D7) --------------------------------------------------------
9825 int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3)
9826 {
9827 int v3; // ecx@1
9828 double v5; // st7@10
9829 signed int v6; // esi@10
9830 signed int v7; // ecx@11
9831 double v8; // st6@12
9832 double v9; // st7@15
9833 double v10; // st6@16
9834 float v11; // ST14_4@17
9835 double v12; // ST08_8@17
9836
9837 v3 = pWeather->field_FA0;
9838 if ( bUnderwater == 1 )
9839 v3 = 0;
9840 if ( pParty->field_1613C || !(day_attrib & 1) && !bUnderwater )
9841 return 0xFF000000u;
9842 if ( v3 )
9843 {
9844 if ( v3 != 1 )
9845 return 0;
9846 v5 = (double)day_fogrange_1;
9847 v6 = 216;
9848 if ( a3 < v5 )
9849 goto LABEL_11;
9850 v8 = (double)day_fogrange_2;
9851 if ( a3 > v8 )
9852 {
9853 LABEL_13:
9854 v7 = v6;
9855 goto LABEL_19;
9856 }
9857 v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
9858 }
9859 else
9860 {
9861 v9 = (double)day_fogrange_1;
9862 v6 = 216;
9863 if ( a3 < v9 )
9864 {
9865 LABEL_11:
9866 v7 = 0;
9867 goto LABEL_19;
9868 }
9869 v10 = (double)day_fogrange_2;
9870 if ( a3 > v10 )
9871 goto LABEL_13;
9872 v11 = (a3 - v9) * 216.0 / (v10 - v9);
9873 v12 = v11 + 6.7553994e15;
9874 v7 = LODWORD(v12);
9875 }
9876 if ( v7 > v6 )
9877 {
9878 LABEL_20:
9879 v7 = v6;
9880 goto LABEL_21;
9881 }
9882 LABEL_19:
9883 if ( a3 == 0.0 )
9884 goto LABEL_20;
9885 LABEL_21:
9886 if ( a2 )
9887 v7 = 248;
9888 return (-1 - v7) << 24;
9889 }
9890 // 6BE030: using guessed type int day_attrib;
9891 // 6BE040: using guessed type int day_fogrange_1;
9892 // 6BE044: using guessed type int day_fogrange_2;
9893 // 6BE3C4: using guessed type char bUnderwater;
9894
9895 //----- (0047C4FC) --------------------------------------------------------
9896 signed int __fastcall GetActorTintColor(int a1, int a2, float a3, int a4, RenderBillboard *a5)
9897 {
9898 int v5; // esi@1
9899 signed int v6; // edx@1
9900 signed int result; // eax@2
9901 int v8; // eax@3
9902 double v9; // st7@12
9903 double v10; // ST0C_8@18
9904 int v11; // ecx@28
9905 signed int v12; // edi@28
9906 double v13; // ST0C_8@33
9907 double v14; // ST0C_8@34
9908 double v15; // st7@44
9909 double v16; // ST0C_8@44
9910 double v17; // ST0C_8@44
9911 int v18; // ST14_4@44
9912 double v19; // ST0C_8@44
9913 signed int v20; // [sp+10h] [bp-4h]@10
9914 float a3a; // [sp+1Ch] [bp+8h]@33
9915 float a3b; // [sp+1Ch] [bp+8h]@34
9916 float a3c; // [sp+1Ch] [bp+8h]@44
9917 float a3d; // [sp+1Ch] [bp+8h]@44
9918 float a4b; // [sp+20h] [bp+Ch]@18
9919 int a4a; // [sp+20h] [bp+Ch]@33
9920 float a4c; // [sp+20h] [bp+Ch]@44
9921 float a4d; // [sp+20h] [bp+Ch]@44
9922 int a5a; // [sp+24h] [bp+10h]@44
9923
9924 v5 = a2;
9925 v6 = 0;
9926 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
9927 return 8 * (31 - a1) | ((8 * (31 - a1) | ((31 - a1) << 11)) << 8);
9928 v8 = pWeather->field_FA0;
9929 if ( bUnderwater == 1 )
9930 v8 = 0;
9931 if ( pParty->field_1613C )
9932 return 16711680;
9933 if ( v8 )
9934 {
9935 if ( v8 != 1 )
9936 return 0;
9937 v20 = 1;
9938 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
9939 v20 = pParty->pPartyBuffs[16].uPower;
9940 v9 = (double)v20 * 1024.0;
9941 if ( a4 )
9942 goto LABEL_19;
9943 if ( a3 <= v9 )
9944 {
9945 if ( a3 > 0.0 )
9946 {
9947 a4b = a3 * 216.0 / v9;
9948 v10 = a4b + 6.7553994e15;
9949 v6 = LODWORD(v10);
9950 if ( SLODWORD(v10) > 216 )
9951 goto LABEL_19;
9952 }
9953 }
9954 else
9955 {
9956 v6 = 216;
9957 }
9958 if ( a3 != 0.0 )
9959 {
9960 LABEL_20:
9961 if ( a5 )
9962 v6 = 8 * sub_43F55F(a5, v6 >> 3);
9963 if ( v6 > 216 )
9964 v6 = 216;
9965 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
9966 }
9967 LABEL_19:
9968 v6 = 216;
9969 goto LABEL_20;
9970 }
9971 if ( a3 == 0.0 )
9972 {
9973 result = (signed int)0xF8F8F8;
9974 }
9975 else
9976 {
9977 v11 = 8 * (a1 - v5);
9978 v12 = v11;
9979 if ( v11 >= 0 )
9980 {
9981 if ( v11 > 216 )
9982 v12 = 216;
9983 }
9984 else
9985 {
9986 v12 = 0;
9987 }
9988 if ( a4 )
9989 {
9990 a3b = pOutdoor->fFogDensity * 216.0;
9991 v14 = a3b + 6.7553994e15;
9992 a4a = LODWORD(v14);
9993 }
9994 else
9995 {
9996 a3a = (a3 / (double)pOutdoorCamera->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity;
9997 v13 = a3a + 6.7553994e15;
9998 a4a = LODWORD(v13);
9999 }
10000 v6 = a4a + v12;
10001 if ( a5 )
10002 v6 = 8 * sub_43F55F(a5, v6 >> 3);
10003 if ( v6 > 216 )
10004 v6 = 216;
10005 if ( v6 < v12 )
10006 v6 = v12;
10007 if ( v6 > 8 * pOutdoor->field_CBC_terrain_triangles_shade_type )
10008 v6 = 8 * pOutdoor->field_CBC_terrain_triangles_shade_type;
10009 if ( !bUnderwater )
10010 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
10011 v15 = (double)(255 - v6) * 0.0039215689;
10012 a3c = v15;
10013 a4c = v15 * 16.0;
10014 v16 = a4c + 6.7553994e15;
10015 a5a = LODWORD(v16);
10016 a4d = a3c * 194.0;
10017 v17 = a4d + 6.7553994e15;
10018 v18 = LODWORD(v17);
10019 a3d = a3c * 153.0;
10020 v19 = a3d + 6.7553994e15;
10021 result = LODWORD(v19) | ((v18 | (a5a << 8)) << 8);
10022 }
10023 return result;
10024 }
10025 // 6BE3C4: using guessed type char bUnderwater;
10026
10027
10028
10029
10030 //----- (0047F44B) --------------------------------------------------------
10031 int __stdcall WorldPosToGridCellX(signed int a1)
10032 {
10033 return (a1 >> 9) + 64;
10034 }
10035 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
10036
10037 //----- (0047F458) --------------------------------------------------------
10038 int __stdcall WorldPosToGridCellZ(signed int a1)
10039 {
10040 return 64 - (a1 >> 9);
10041 }
10042 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
10043
10044 //----- (0047F469) --------------------------------------------------------
10045 int __stdcall GridCellToWorldPosX(int a1)
10046 {
10047 return (a1 - 64) << 9;
10048 }
10049 // 47F469: using guessed type int __stdcall GridCellToWorldPosX(int);
10050
10051 //----- (0047F476) --------------------------------------------------------
10052 int __stdcall GridCellToWorldPosZ(int a1)
10053 {
10054 return (64 - a1) << 9;
10055 }
10056 // 47F476: using guessed type int __stdcall GridCellToWorldPosZ(int);
10057
10058 //----- (0047F4D3) --------------------------------------------------------
10059 void __fastcall sub_47F4D3(int band1, int band2, int band3)
10060 {
10061 int v3; // edi@1
10062 stru220 *v4; // esi@1
10063 double v5; // ST2C_8@3
10064 double v6; // st7@3
10065 double v7; // [sp+18h] [bp-28h]@3
10066 double v8; // [sp+20h] [bp-20h]@2
10067 int v9; // [sp+34h] [bp-Ch]@1
10068 int v10; // [sp+38h] [bp-8h]@1
10069 signed int band3a; // [sp+48h] [bp+8h]@2
10070
10071 v9 = band2 << 9;
10072 pOutdoorCamera->outdoor_grid_band_3 = band3;
10073 v10 = band1 << 9;
10074 v3 = band3 << 9;
10075 pOutdoorCamera->uPickDepth = band3 << 9;
10076 v4 = stru_76E5C8; // v4: 0 -> 65536
10077 do
10078 {
10079 band3a = 256;
10080 v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8);
10081 do // band3a: 0 -> 128
10082 {
10083 v5 = pow((double)band3a, 2.0);
10084 v6 = pow(v8, 2.0);
10085 *((float *)&v5 + 1) = sqrt(v6 + v5);
10086 v7 = *((float *)&v5 + 1) + 6.7553994e15;
10087 if ( SLODWORD(v7) >= v10 )
10088 {
10089 if ( SLODWORD(v7) >= v9 )
10090 v4->field_0 = ((SLODWORD(v7) >= v3) - 1) & 2;
10091 else
10092 v4->field_0 = 2;
10093 }
10094 else
10095 {
10096 v4->field_0 = 1;
10097 }
10098 band3a += 512;
10099 v4->distance = LOWORD(v7);
10100 ++v4;
10101 }
10102 while ( band3a < 65792 );
10103 }
10104 while ( (signed int)v4 < (signed int)arary_77E5C8 );
10105 }
10106
10107
10108
10109
10110 //----- (004811A3) --------------------------------------------------------
10111 void stru148::_4811A3()
10112 {
10113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
10114 pRenderer->DrawTerrainPolygon(uNumVertices, this,
10115 pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]],
10116 0, 0);
10117
10118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
10119 pRenderer->DrawTerrainPolygon(uNumVertices, this,
10120 pBitmaps_LOD->pHardwareTextures[uTileBitmapID],
10121 1, 1);
10122 }
10123
10124
10125
10126 //----- (00481DB2) --------------------------------------------------------
10127 char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3)
10128 {
10129 int v3; // eax@2
10130 int v4; // esi@2
10131 signed int v5; // esi@2
10132 char *v6; // edi@3
10133 double v7; // ST14_8@4
10134 double v8; // ST0C_8@4
10135 char result; // al@5
10136
10137 if ( a2 >= 3 )
10138 {
10139 v3 = a3->uTileBitmapID;
10140 v4 = a3->uTileBitmapID;
10141 a3->ptr_38 = &stru_8019C8;
10142 a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0);
10143 v5 = 0;
10144 if ( (signed int)a3->uNumVertices > 0 )
10145 {
10146 v6 = (char *)&array_508690[0].vWorldViewProjY;
10147 do
10148 {
10149 v7 = *((float *)v6 - 1) + 6.7553994e15;
10150 dword_50B638[v5] = LODWORD(v7);
10151 v8 = *(float *)v6 + 6.7553994e15;
10152 v6 += 48;
10153 dword_50B570[v5++] = LODWORD(v8);
10154 }
10155 while ( v5 < (signed int)a3->uNumVertices );
10156 }
10157 result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638, dword_50B570, a3);
10158 }
10159 return result;
10160 }
10161 // 50B570: using guessed type int dword_50B570[];
10162 // 50B638: using guessed type int dword_50B638[];
10163
10164
10165
10166 //----- (00481E55) --------------------------------------------------------
10167 void OutdoorCamera::Project(unsigned int uNumVertices)
10168 {
10169 double v1; // st7@2
10170 double v2; // st6@2
10171 double v3; // st5@2
10172 int v4; // eax@2
10173 unsigned int v5; // edx@2
10174 double v6; // st4@3
10175 double v7; // st3@3
10176
10177 if ( (signed int)uNumVertices > 0 )
10178 {
10179 v1 = (double)pOutdoorCamera->int_fov_rad;
10180 v2 = (double)pViewport->uScreenCenterX;
10181 v3 = (double)pViewport->uScreenCenterY;
10182 v4 = 0;
10183 v5 = uNumVertices;
10184 do
10185 {
10186 v6 = v1 * array_507D30[v4].flt_20;
10187 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
10188 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
10189 array_50AC10[v4].vWorldViewProjX = v2 - v7;
10190 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
10191 ++v4;
10192 --v5;
10193 }
10194 while ( v5 );
10195 }
10196 }
10197
10198 //----- (00481EB7) --------------------------------------------------------
10199 void __cdecl ResetStru148s()
10200 {
10201 int v0; // ecx@1
10202 char *v1; // eax@2
10203
10204 v0 = pOutdoorCamera->numStru148s;
10205 if ( pOutdoorCamera->numStru148s > 0 )
10206 {
10207 v1 = (char *)&array_77EC08[0].prolly_tail;
10208 do
10209 {
10210 *((int *)v1 - 1) = 0;
10211 *(int *)v1 = 0;
10212 *((int *)v1 - 5) = 0;
10213 v1 += 268;
10214 --v0;
10215 }
10216 while ( v0 );
10217 }
10218 }
10219
10220 //----- (00481ED9) --------------------------------------------------------
10221 void __cdecl sub_481ED9_MessWithOutdoorCamera()
10222 {
10223 stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0);
10224 pOutdoorCamera->numStru148s = 0;
10225 pOutdoorCamera->uNumEdges = 0;
10226 pOutdoorCamera->uNumSpans = 0;
10227 pOutdoorCamera->uNumSurfs = 0;
10228 pOutdoorCamera->field_3C = 0;
10229 pOutdoorCamera->field_44 = 0;
10230 }
10231
10232 //----- (00481EFA) --------------------------------------------------------
10233 bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5)
10234 {
10235 RenderVertexSoft *v5; // esi@1
10236 RenderVertexSoft *v6; // edx@1
10237 bool v7; // edi@2
10238 bool v8; // ecx@5
10239 bool v9; // esi@8
10240 bool v10; // eax@11
10241 double v11; // st7@14
10242 signed int v12; // esi@15
10243 signed int v13; // edx@18
10244 signed int v14; // ecx@21
10245 signed int v15; // eax@24
10246 RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1
10247
10248 v5 = a2;
10249 v6 = a1;
10250 v17 = v5;
10251 v7 = a1->vWorldViewPosition.x < 8.0;
10252 v8 = v5->vWorldViewPosition.x < 8.0;
10253 v9 = a3->vWorldViewPosition.x < 8.0;
10254 v10 = a4->vWorldViewPosition.x < 8.0;
10255 return !(v8 & v9 & v10 & v7)
10256 && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1),
10257 v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1),
10258 v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1),
10259 v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1),
10260 !(v13 & v14 & v15 & v12));
10261 }
10262
10263 //----- (00481FC9) --------------------------------------------------------
10264 int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)
10265 {
10266 __debugbreak();
10267 return 0;
10268 /*signed int result; // eax@5
10269 __int64 v11; // ST08_8@6
10270 __int64 v12; // ST08_8@6
10271 __int64 v13; // ST08_8@6
10272 __int64 v14; // ST08_8@6
10273
10274 __asm { fld dword ptr [ecx+8] }
10275 _ESI = a2;
10276 _EDX = a3;
10277 __asm { fcomp dword ptr [esi+8] }
10278 _EDI = a4;
10279 __asm { fnstsw ax }
10280 if ( !__SETP__(HIBYTE(_AX) & 0x44, 0) )
10281 {
10282 __asm
10283 {
10284 fld dword ptr [esi+8]
10285 fcomp dword ptr [edx+8]
10286 fnstsw ax
10287 }
10288 if ( !__SETP__(HIBYTE(_AX) & 0x44, 0) )
10289 *(int *)&a4->flags |= 0x10u;
10290 }
10291 __asm
10292 {
10293 fld dword ptr [ecx+0Ch]
10294 fsub dword ptr [esi+0Ch]
10295 fstp [ebp+var_C]
10296 fld dword ptr [ecx+10h]
10297 fsub dword ptr [esi+10h]
10298 fstp [ebp+var_14]
10299 fld dword ptr [ecx+14h]
10300 fsub dword ptr [esi+14h]
10301 fstp [ebp+arg_0]
10302 fld dword ptr [edx+0Ch]
10303 fsub dword ptr [esi+0Ch]
10304 fstp [ebp+var_10]
10305 fld dword ptr [edx+10h]
10306 fsub dword ptr [esi+10h]
10307 fstp [ebp+var_8]
10308 fld dword ptr [edx+14h]
10309 fsub dword ptr [esi+14h]
10310 fstp [ebp+var_4]
10311 fld dword ptr [ecx]
10312 fsub dword ptr [esi]
10313 fld dword ptr [ecx+4]
10314 fsub dword ptr [esi+4]
10315 fld dword ptr [ecx+8]
10316 fsub dword ptr [esi+8]
10317 fld dword ptr [edx]
10318 fsub dword ptr [esi]
10319 fld dword ptr [edx+4]
10320 fsub dword ptr [esi+4]
10321 fld dword ptr [edx+8]
10322 fsub dword ptr [esi+8]
10323 fstp [ebp+arg_4]
10324 fld st
10325 fmul st, st(3)
10326 fld [ebp+arg_4]
10327 fmul st, st(5)
10328 fsubp st(1), st
10329 fild pIndoorCamera->pos.x
10330 fsub dword ptr [esi]
10331 fmulp st(1), st
10332 fld [ebp+arg_4]
10333 fmul st, st(6)
10334 fld st(3)
10335 fmul st, st(5)
10336 fsubp st(1), st
10337 fild pIndoorCamera->pos.y
10338 fsub dword ptr [esi+4]
10339 fmulp st(1), st
10340 faddp st(1), st
10341 fld st(2)
10342 fmul st, st(5)
10343 fld st(2)
10344 fmul st, st(7)
10345 fsubp st(1), st
10346 fild pIndoorCamera->pos.z
10347 fsub dword ptr [esi+8]
10348 fmulp st(1), st
10349 faddp st(1), st
10350 fcomp ds:flt_4D84E8
10351 fstp st
10352 fstp st
10353 fstp st
10354 fnstsw ax
10355 fstp st
10356 fstp st
10357 }
10358 if ( __SETP__(HIBYTE(_AX) & 0x41, 0) )
10359 {
10360 __asm
10361 {
10362 fld [ebp+var_4]
10363 fmul [ebp+var_14]
10364 fld [ebp+var_8]
10365 fmul [ebp+arg_0]
10366 fsubp st(1), st
10367 fstp [ebp+arg_4]
10368 fld [ebp+arg_4]
10369 fadd ds:flt_4D87D0
10370 fstp [ebp+var_20]
10371 fld [ebp+var_10]
10372 fmul [ebp+arg_0]
10373 fld [ebp+var_4]
10374 fmul [ebp+var_C]
10375 }
10376 _EDI->v_18.x = v11;
10377 __asm
10378 {
10379 fsubp st(1), st
10380 fstp [ebp+arg_4]
10381 fld [ebp+arg_4]
10382 fadd ds:flt_4D87D0
10383 fstp [ebp+var_20]
10384 fld [ebp+var_8]
10385 fmul [ebp+var_C]
10386 fld [ebp+var_10]
10387 fmul [ebp+var_14]
10388 }
10389 _EDI->v_18.y = v12;
10390 __asm
10391 {
10392 fsubp st(1), st
10393 fstp [ebp+arg_4]
10394 fld [ebp+arg_4]
10395 fadd ds:flt_4D87D0
10396 fstp [ebp+var_20]
10397 }
10398 _EDI->v_18.z = v13;
10399 stru148::_486089_normalize_v_18(_EDI);
10400 __asm
10401 {
10402 fild dword ptr [edi+18h]
10403 fmul dword ptr [esi+0Ch]
10404 fchs
10405 fild dword ptr [edi+1Ch]
10406 fmul dword ptr [esi+10h]
10407 fsubp st(1), st
10408 fild dword ptr [edi+20h]
10409 fmul dword ptr [esi+14h]
10410 fsubp st(1), st
10411 fstp [ebp+arg_4]
10412 fld [ebp+arg_4]
10413 fadd ds:flt_4D87D0
10414 fstp [ebp+var_20]
10415 }
10416 _EDI->field_24 = v14;
10417 result = 1;
10418 }
10419 else
10420 {
10421 result = 0;
10422 }
10423 return result;*/
10424 }
10425
10426
10427
10428 //----- (004823F4) --------------------------------------------------------
10429 bool __fastcall GetTerrainHeightsAroundParty(int a1, int a2)
10430 {
10431 unsigned int v2; // ebx@1
10432 unsigned int v3; // edi@1
10433 int v4; // eax@1
10434 int v6; // esi@5
10435 int v7; // ecx@6
10436 int v8; // edx@6
10437 int v9; // eax@6
10438 int v10; // esi@10
10439 int v11; // [sp+14h] [bp-8h]@1
10440 int v12; // [sp+18h] [bp-4h]@1
10441
10442 v12 = a1;
10443 v11 = a2;
10444 v2 = WorldPosToGridCellX(a1);
10445 v3 = WorldPosToGridCellZ(v11) - 1;
10446 dword_76D568_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2);
10447 dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1);
10448 dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1);
10449 dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2);
10450 dword_76D558_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3);
10451 dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3);
10452 dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1);
10453 dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1);
10454 dword_76D548_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2, v3);
10455 dword_76D54C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3);
10456 dword_76D550_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3 + 1);
10457 v4 = pOutdoor->DoGetHeightOnTerrain(v2, v3 + 1);
10458 dword_76D554_terrain_cell_world_pos_around_party_y = v4;
10459 if ( dword_76D548_terrain_cell_world_pos_around_party_y == dword_76D54C_terrain_cell_world_pos_around_party_y
10460 && dword_76D54C_terrain_cell_world_pos_around_party_y == dword_76D550_terrain_cell_world_pos_around_party_y
10461 && dword_76D550_terrain_cell_world_pos_around_party_y == v4 )
10462 return 0;
10463 v6 = abs(v12 - dword_76D568_terrain_cell_world_pos_around_party_x);
10464 if ( abs(dword_76D558_terrain_cell_world_pos_around_party_z - v11) >= v6 )
10465 {
10466 v7 = dword_76D554_terrain_cell_world_pos_around_party_y;
10467 v8 = dword_76D550_terrain_cell_world_pos_around_party_y;
10468 v9 = dword_76D548_terrain_cell_world_pos_around_party_y;
10469 }
10470 else
10471 {
10472 v7 = dword_76D54C_terrain_cell_world_pos_around_party_y;
10473 v8 = dword_76D548_terrain_cell_world_pos_around_party_y;
10474 v9 = dword_76D550_terrain_cell_world_pos_around_party_y;
10475 }
10476 if ( v7 >= v8 )
10477 {
10478 v10 = v8;
10479 if ( v8 < v9 )
10480 goto LABEL_13;
10481 LABEL_12:
10482 v10 = v9;
10483 goto LABEL_13;
10484 }
10485 if ( v7 >= v9 )
10486 goto LABEL_12;
10487 v10 = v7;
10488 LABEL_13:
10489 if ( v7 <= v8 )
10490 {
10491 if ( v8 > v9 )
10492 v9 = v8;
10493 }
10494 else
10495 {
10496 if ( v7 > v9 )
10497 v9 = v7;
10498 }
10499 return v9 - v10 > 512;
10500 }
10501
10502
10503 //----- (0048257A) --------------------------------------------------------
10504 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4)
10505 {
10506 unsigned int v4; // ebx@1
10507 unsigned int v5; // edi@1
10508 int result; // eax@9
10509 int v7; // ebx@10
10510 int v8; // ebx@11
10511 int v9; // eax@11
10512 int v10; // ecx@11
10513 int v11; // [sp+Ch] [bp-Ch]@1
10514 int v12; // [sp+10h] [bp-8h]@1
10515 int v13; // [sp+10h] [bp-8h]@11
10516 signed int v14; // [sp+14h] [bp-4h]@3
10517 int v15; // [sp+24h] [bp+Ch]@11
10518
10519 v11 = a1;
10520 v12 = a2;
10521 v4 = WorldPosToGridCellX(a1);
10522 v5 = WorldPosToGridCellZ(v12) - 1;
10523 dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
10524 dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
10525 dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
10526 dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
10527 dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
10528 dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
10529 dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
10530 dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
10531 dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
10532 dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
10533 dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
10534 dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
10535 *a3 = 0;
10536 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(v4, v5) & 2 )
10537 *a3 = 1;
10538 v14 = 0;
10539 if ( !a4 && *a3 )
10540 v14 = -60;
10541 if ( dword_76D518_terrain_cell_world_pos_around_party_y != dword_76D51C_terrain_cell_world_pos_around_party_y
10542 || dword_76D51C_terrain_cell_world_pos_around_party_y != dword_76D520_terrain_cell_world_pos_around_party_y
10543 || dword_76D520_terrain_cell_world_pos_around_party_y != dword_76D524_terrain_cell_world_pos_around_party_y )
10544 {
10545 v7 = abs(v11 - dword_76D538_terrain_cell_world_pos_around_party_x);
10546 if ( abs(dword_76D528_terrain_cell_world_pos_around_party_z - v12) >= v7 )
10547 {
10548 v8 = dword_76D524_terrain_cell_world_pos_around_party_y;
10549 v9 = dword_76D520_terrain_cell_world_pos_around_party_y;
10550 v10 = dword_76D518_terrain_cell_world_pos_around_party_y;
10551 v15 = v11 - dword_76D544_terrain_cell_world_pos_around_party_x;
10552 v13 = v12 - dword_76D534_terrain_cell_world_pos_around_party_z;
10553 }
10554 else
10555 {
10556 v8 = dword_76D51C_terrain_cell_world_pos_around_party_y;
10557 v9 = dword_76D518_terrain_cell_world_pos_around_party_y;
10558 v10 = dword_76D520_terrain_cell_world_pos_around_party_y;
10559 v15 = dword_76D53C_terrain_cell_world_pos_around_party_x - v11;
10560 v13 = dword_76D52C_terrain_cell_world_pos_around_party_z - v12;
10561 }
10562 result = v14
10563 + v8
10564 + ((unsigned __int64)(v13 * (signed __int64)((v10 - v8) << 7)) >> 16)
10565 + ((unsigned __int64)(v15 * (signed __int64)((v9 - v8) << 7)) >> 16);
10566 }
10567 else
10568 {
10569 result = v14 + dword_76D518_terrain_cell_world_pos_around_party_y;
10570 }
10571 return result;
10572 }
10573
10574
10575 //----- (0048276F) --------------------------------------------------------
10576 void stru148::_48276F_sr()
10577 {
10578 unsigned int v1; // ebx@1
10579 float v2; // edx@2
10580 double v3; // st7@2
10581 char *v4; // ecx@3
10582 float v5; // eax@5
10583 float v6; // eax@7
10584 float v7; // eax@9
10585 float v8; // ecx@13
10586 int i; // eax@16
10587 int v10; // edx@20
10588 RenderVertexSoft *v11; // ecx@22
10589 RenderVertexSoft *v12; // edx@22
10590 RenderVertexSoft *v13; // esi@22
10591 int v14; // ebx@26
10592 RenderVertexSoft *v15; // ebx@27
10593 double v16; // st6@28
10594 double v17; // st5@28
10595 double v18; // st4@28
10596 int v19; // [sp+4h] [bp-2Ch]@20
10597 int v20; // [sp+8h] [bp-28h]@22
10598 int v21; // [sp+Ch] [bp-24h]@22
10599 stru148 *v22; // [sp+10h] [bp-20h]@1
10600 float v23; // [sp+14h] [bp-1Ch]@11
10601 float v24; // [sp+18h] [bp-18h]@7
10602 float v25; // [sp+1Ch] [bp-14h]@5
10603 float v26; // [sp+20h] [bp-10h]@2
10604 float v27; // [sp+24h] [bp-Ch]@2
10605 float v28; // [sp+28h] [bp-8h]@2
10606 float v29; // [sp+2Ch] [bp-4h]@9
10607
10608 v1 = this->uNumVertices;
10609 v22 = this;
10610 if ( (signed int)v1 >= 3 )
10611 {
10612 LODWORD(v2) = 0;
10613 v26 = 10000.0;
10614 v28 = 10000.0;
10615 v3 = -10000.0;
10616 v27 = -10000.0;
10617 if ( (signed int)v1 > 0 )
10618 {
10619 v4 = (char *)&array_508690[0].vWorldViewProjY;
10620 do
10621 {
10622 if ( *((float *)v4 - 1) < (double)v26 )
10623 {
10624 LODWORD(v5) = *((int *)v4 - 1);
10625 v25 = v2;
10626 v26 = v5;
10627 }
10628 if ( *((float *)v4 - 1) > (double)v27 )
10629 {
10630 LODWORD(v6) = *((int *)v4 - 1);
10631 v24 = v2;
10632 v27 = v6;
10633 }
10634 if ( *(float *)v4 < (double)v28 )
10635 {
10636 LODWORD(v7) = *(int *)v4;
10637 v29 = v2;
10638 v28 = v7;
10639 }
10640 if ( v3 < *(float *)v4 )
10641 {
10642 v3 = *(float *)v4;
10643 v23 = v2;
10644 }
10645 ++LODWORD(v2);
10646 v4 += 48;
10647 }
10648 while ( SLODWORD(v2) < (signed int)v1 );
10649 }
10650 v8 = v29;
10651 if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) )
10652 v8 = v23;
10653 v29 = 0.0;
10654 for ( i = 0; i < (signed int)v1; ++i )
10655 {
10656 if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) )
10657 {
10658 v10 = LODWORD(v29)++;
10659 *(&v19 + v10) = i;
10660 }
10661 }
10662 v11 = &array_508690[v19];
10663 v12 = &array_508690[v20];
10664 v13 = &array_508690[v21];
10665 if ( LODWORD(v29) != 3 )
10666 {
10667 v11 = array_508690;
10668 v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3));
10669 v12 = &array_508690[1];
10670 v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x;
10671 v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y;
10672 v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z;
10673 v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x;
10674 v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y;
10675 v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z;
10676 if ( v24 * v27 - v25 * v29 == 0.0 )
10677 {
10678 if ( v26 * v29 - v24 * v28 == 0.0 )
10679 {
10680 if ( v25 * v28 - v26 * v27 == 0.0 )
10681 {
10682 v14 = v1 - 2;
10683 LODWORD(v26) = v14;
10684 if ( v14 >= 2 )
10685 {
10686 v15 = &array_508690[v14];
10687 do
10688 {
10689 v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x;
10690 v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y;
10691 v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z;
10692 v13 = v15;
10693 if ( v27 * v18 - v17 * v29 != 0.0 )
10694 break;
10695 if ( v16 * v29 - v18 * v28 != 0.0 )
10696 break;
10697 if ( v28 * v17 - v16 * v27 != 0.0 )
10698 break;
10699 --LODWORD(v26);
10700 --v15;
10701 }
10702 while ( SLODWORD(v26) >= 2 );
10703 }
10704 }
10705 }
10706 }
10707 }
10708 sr_sub_4829B9(v11, v12, v13, v22, 1);
10709 }
10710 }
10711
10712 //----- (004829B9) --------------------------------------------------------
10713 stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5)
10714 {
10715 double v5; // st7@1
10716 RenderVertexSoft *v6; // esi@1
10717 double v7; // st6@1
10718 stru148 *result; // eax@3
10719 double v9; // st6@3
10720 double v10; // st5@3
10721 float v11; // ST0C_4@3
10722 float v12; // ST04_4@3
10723 double v13; // st4@3
10724 float v14; // [sp+8h] [bp-Ch]@1
10725 float v15; // [sp+10h] [bp-4h]@1
10726 float v16; // [sp+1Ch] [bp+8h]@1
10727 float v17; // [sp+1Ch] [bp+8h]@3
10728
10729 v5 = a2->vWorldViewProjX - a1->vWorldViewProjX;
10730 v6 = a3;
10731 v16 = a3->vWorldViewProjY - a1->vWorldViewProjY;
10732 v15 = a2->vWorldViewProjY - a1->vWorldViewProjY;
10733 v14 = v6->vWorldViewProjX - a1->vWorldViewProjX;
10734 v7 = v16 * v5 - v14 * v15;
10735 if ( v7 == 0.0 )
10736 v7 = 0.0000001;
10737 result = a4;
10738 v9 = 1.0 / v7;
10739 v10 = 1.0 / a1->vWorldViewPosition.x;
10740 v11 = 1.0 / a2->vWorldViewPosition.x - v10;
10741 v12 = 1.0 / v6->vWorldViewPosition.x - v10;
10742 v13 = (v11 * v16 - v12 * v15) * v9;
10743 v17 = (v11 * v14 - v12 * v5) * -v9;
10744 a4->field_C = a1->vWorldViewProjX;
10745 a4->field_10 = a1->vWorldViewProjY;
10746 a4->field_0 = v10;
10747 a4->field_8 = v17;
10748 a4->field_4 = v13;
10749 return result;
10750 }
10751
10752 //----- (00482A90) --------------------------------------------------------
10753 signed int __cdecl const_1_0()
10754 {
10755 return 1;
10756 }
10757
10758
10759 //----- (00482A94) --------------------------------------------------------
10760 int sr_sub_482A94(Span *_this)
10761 {
10762 stru315 *v1; // ebp@0
10763 Span *v2; // edi@1
10764 stru148 *v3; // esi@1
10765 int v4; // ecx@1
10766 stru149 *v5; // eax@1
10767 stru149 *v6; // eax@1
10768 int v7; // edx@1
10769 int v8; // eax@1
10770 int v9; // ecx@1
10771 int v10; // edx@1
10772 int v11; // ebx@1
10773 int v12; // eax@1
10774 signed int v13; // ebx@1
10775 int v14; // ebx@2
10776 signed __int64 v15; // qtt@3
10777 stru149 *v16; // eax@3
10778 signed int v17; // ebx@3
10779 Texture *v18; // eax@14
10780 unsigned __int16 *v19; // eax@15
10781 stru149 *v20; // eax@21
10782 signed int v21; // eax@21
10783 int v22; // eax@21
10784 int v23; // ecx@21
10785 Texture *v24; // edx@21
10786 signed int v25; // eax@21
10787 signed int v27; // [sp-4h] [bp-A4h]@8
10788 int v28; // [sp+Ch] [bp-94h]@1
10789 int v29; // [sp+10h] [bp-90h]@1
10790 stru316 a2; // [sp+14h] [bp-8Ch]@21
10791 stru315 a1; // [sp+3Ch] [bp-64h]@1
10792 int v32; // [sp+80h] [bp-20h]@1
10793 int v33; // [sp+84h] [bp-1Ch]@1
10794 int v34; // [sp+88h] [bp-18h]@1
10795 int v35; // [sp+8Ch] [bp-14h]@1
10796 int v36; // [sp+90h] [bp-10h]@1
10797 int v37; // [sp+94h] [bp-Ch]@1
10798 int v38; // [sp+98h] [bp-8h]@1
10799 int X; // [sp+9Ch] [bp-4h]@1
10800
10801 v2 = _this;
10802 v3 = _this->pParent;
10803 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
10804 v5 = v3->ptr_38;
10805 v38 = v4;
10806 v37 = v5->field_14;
10807 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
10808 v6 = v3->ptr_38;
10809 v7 = v38 + v6->field_C;
10810 v37 = v6->field_20;
10811 v33 = v7;
10812 v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
10813 v38 = v4;
10814 v34 = v8;
10815 v37 = v3->v_18.z;
10816 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
10817 v9 = v3->v_18.x;
10818 v28 = v3->sTextureDeltaU << 16;
10819 v35 = v3->sTextureDeltaV << 16;
10820 v10 = v2->field_8;
10821 v29 = pOutdoorCamera->camera_rotation_y_int_sine;
10822 v32 = pOutdoorCamera->camera_rotation_y_int_cosine;
10823 a1.field_28 = v2->field_C;
10824 v11 = v3->field_24;
10825 v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10);
10826 v12 = v3->v_18.y;
10827 v13 = -v11;
10828 v36 = v13;
10829 X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9;
10830 if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) )
10831 return 0;
10832 LODWORD(v15) = v36 << 16;
10833 HIDWORD(v15) = v36 >> 16;
10834 v38 = v15 / X;
10835 v16 = v3->ptr_38;
10836 X = v37;
10837 v36 = v16->field_10;
10838 X = v37;
10839 v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16);
10840 v33 = v3->ptr_38->field_1C;
10841 X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
10842 v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
10843 v17 = 2;
10844 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
10845 if ( v38 >= mipmapping_building_mm1 << 16 )
10846 {
10847 if ( v38 >= mipmapping_building_mm2 << 16 )
10848 {
10849 if ( v38 >= mipmapping_building_mm3 << 16 )
10850 {
10851 if ( bUseLoResSprites )
10852 goto LABEL_12;
10853 v27 = 3;
10854 }
10855 else
10856 {
10857 v27 = 2;
10858 }
10859 v17 = v27;
10860 goto LABEL_12;
10861 }
10862 v17 = 1;
10863 }
10864 else
10865 {
10866 v17 = 0;
10867 }
10868 LABEL_12:
10869 if ( v17 < (signed int)v3->ptr_48 )
10870 v17 = (signed int)v3->ptr_48;
10871 v18 = v3->pTexture;
10872 if ( v17 )
10873 {
10874 if ( v17 == 1 )
10875 {
10876 v19 = (unsigned __int16 *)v18->pLevelOfDetail1;
10877 }
10878 else
10879 {
10880 if ( v17 == 2 )
10881 v19 = (unsigned __int16 *)v18->pLevelOfDetail2;
10882 else
10883 v19 = (unsigned __int16 *)v18->pLevelOfDetail3;
10884 }
10885 }
10886 else
10887 {
10888 v19 = (unsigned __int16 *)v18->pLevelOfDetail0;
10889 }
10890 a1.pTextureLOD = v19;
10891 X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16;
10892 v20 = v3->ptr_38;
10893 X = v38;
10894 a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24;
10895 X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16;
10896 v21 = X - v3->ptr_38->field_28 - v35;
10897 a1.field_30 >>= v17 + bUseLoResSprites;
10898 a1.field_2C = v21 >> (v17 + bUseLoResSprites);
10899 v35 = pOutdoorCamera->int_fov_rad_inv;
10900 v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites);
10901 a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16;
10902 X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16;
10903 a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16);
10904 v22 = v2->field_A;
10905 a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A];
10906 HIWORD(v23) = HIWORD(v38);
10907 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22];
10908 LOWORD(v23) = 0;
10909 a1.field_24 = v23 | v3->field_50;
10910 v24 = v3->pTexture;
10911 v32 = (signed int)v24->uTextureWidth >> v17;
10912 v25 = (signed int)v24->uTextureHeight >> v17;
10913 a1.field_10 = v17 - v24->uWidthLn2 + 16;
10914 a1.field_C = v32 - 1;
10915 a1.field_8 = (v25 << 16) - 65536;
10916 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1);
10917 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10918 sr_sub_485975(&a1, (stru315 *)&a2);
10919 else
10920 sr_sub_4D6FB0(v1);
10921 return 1;
10922 }
10923
10924 //----- (00482E07) --------------------------------------------------------
10925 signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget)
10926 {
10927 stru315 *v2; // ebp@0
10928 stru148 *v3; // esi@1
10929 int v4; // edi@1
10930 int v5; // edi@1
10931 stru149 *v6; // eax@1
10932 stru149 *v7; // eax@1
10933 int v8; // edx@1
10934 int v9; // eax@1
10935 int v10; // edi@1
10936 int v11; // eax@1
10937 unsigned __int64 v12; // qax@1
10938 int v13; // eax@1
10939 signed __int64 v14; // qtt@3
10940 int v15; // ebx@4
10941 signed __int64 v16; // qtt@5
10942 int v17; // eax@5
10943 unsigned __int16 *v18; // eax@7
10944 Texture *v19; // eax@8
10945 Texture *v20; // eax@10
10946 Texture *v21; // eax@12
10947 Texture *v22; // eax@14
10948 int v23; // ecx@17
10949 Texture *v24; // ebx@17
10950 signed int v25; // edx@17
10951 signed int v26; // eax@17
10952 char v27; // bl@17
10953 stru149 *v28; // eax@18
10954 stru149 *v29; // eax@18
10955 int v30; // eax@18
10956 int v31; // eax@18
10957 unsigned int v32; // edx@18
10958 int v33; // edi@21
10959 signed __int64 v34; // qtt@22
10960 signed int v35; // ecx@22
10961 int v36; // eax@24
10962 stru149 *v37; // eax@24
10963 int v38; // edi@24
10964 int v39; // eax@24
10965 int v40; // edi@35
10966 signed __int64 v41; // qtt@36
10967 int v42; // edx@36
10968 stru149 *v43; // eax@36
10969 int v44; // edi@36
10970 int v45; // eax@36
10971 Span *v46; // edi@44
10972 stru149 *v47; // eax@44
10973 stru149 *v48; // eax@44
10974 int v49; // eax@44
10975 int v50; // ecx@44
10976 unsigned int v51; // edx@44
10977 int v52; // edi@46
10978 signed __int64 v53; // qtt@47
10979 unsigned int v54; // ecx@47
10980 int v55; // eax@49
10981 stru149 *v56; // eax@49
10982 int v57; // edi@49
10983 int v58; // eax@49
10984 int v59; // edi@60
10985 signed __int64 v60; // qtt@61
10986 int v61; // edx@61
10987 stru149 *v62; // eax@61
10988 int v63; // edi@61
10989 int v64; // eax@61
10990 int v66; // [sp+Ch] [bp-B8h]@1
10991 int v67; // [sp+10h] [bp-B4h]@1
10992 int v68; // [sp+14h] [bp-B0h]@1
10993 int v69; // [sp+18h] [bp-ACh]@1
10994 int v70; // [sp+1Ch] [bp-A8h]@5
10995 int v71; // [sp+20h] [bp-A4h]@1
10996 signed int v72; // [sp+24h] [bp-A0h]@1
10997 stru316 a2; // [sp+28h] [bp-9Ch]@18
10998 int v74; // [sp+50h] [bp-74h]@17
10999 stru315 a1; // [sp+54h] [bp-70h]@5
11000 Span *v76; // [sp+98h] [bp-2Ch]@1
11001 unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1
11002 int v78; // [sp+A0h] [bp-24h]@17
11003 int v79; // [sp+A4h] [bp-20h]@3
11004 int v80; // [sp+A8h] [bp-1Ch]@3
11005 int v81; // [sp+ACh] [bp-18h]@1
11006 int X; // [sp+B0h] [bp-14h]@2
11007 int v83; // [sp+B4h] [bp-10h]@1
11008 int v84; // [sp+B8h] [bp-Ch]@1
11009 int v85; // [sp+BCh] [bp-8h]@1
11010 int v86; // [sp+C0h] [bp-4h]@18
11011
11012 v85 = ecx0->field_C;
11013 v3 = ecx0->pParent;
11014 v4 = pViewport->uScreenCenterY - ecx0->field_A;
11015 v77 = pRenderTarget;
11016 v5 = pOutdoorCamera->int_fov_rad_inv * v4;
11017 v6 = v3->ptr_38;
11018 v76 = ecx0;
11019 v81 = v5;
11020 v83 = v6->field_14;
11021 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
11022 v7 = v3->ptr_38;
11023 v8 = v81 + v7->field_C;
11024 v83 = v7->field_20;
11025 v67 = v8;
11026 v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18;
11027 v81 = v5;
11028 v71 = v9;
11029 v83 = v3->v_18.z;
11030 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
11031 v68 = v3->sTextureDeltaU << 16;
11032 v69 = v3->sTextureDeltaV << 16;
11033 v72 = -v3->field_24;
11034 v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8);
11035 v11 = v3->v_18.y;
11036 v66 = v81 + v3->v_18.x;
11037 v83 = v10;
11038 v12 = v10 * (signed __int64)v11;
11039 v81 = v12 >> 16;
11040 v13 = v66 + (v12 >> 16);
11041 v84 = v13;
11042 if ( !v13
11043 || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83)
11044 || (LODWORD(v14) = v72 << 16,
11045 HIDWORD(v14) = v72 >> 16,
11046 v79 = v14 / v84,
11047 v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv,
11048 v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16,
11049 (v84 = v66 + v81) == 0)
11050 || (v15 = abs(v66 + v81), abs(X) >= v15) )
11051 return 0;
11052 LODWORD(v16) = v72 << 16;
11053 HIDWORD(v16) = v72 >> 16;
11054 v70 = v16 / v84;
11055 v17 = v16 / v84;
11056 a1.field_24 = v79;
11057 if ( v79 >= v17 )
11058 a1.field_24 = v17;
11059 v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11060 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11061 v84 = 2;
11062 if ( a1.field_24 >= mipmapping_building_mm1 << 16 )
11063 {
11064 if ( a1.field_24 >= mipmapping_building_mm2 << 16 )
11065 {
11066 if ( a1.field_24 >= mipmapping_building_mm3 << 16 )
11067 {
11068 if ( bUseLoResSprites )
11069 goto LABEL_16;
11070 v22 = v3->pTexture;
11071 v84 = 3;
11072 v18 = (unsigned __int16 *)v22->pLevelOfDetail3;
11073 }
11074 else
11075 {
11076 v21 = v3->pTexture;
11077 v84 = 2;
11078 v18 = (unsigned __int16 *)v21->pLevelOfDetail2;
11079 }
11080 }
11081 else
11082 {
11083 v20 = v3->pTexture;
11084 v84 = 1;
11085 v18 = (unsigned __int16 *)v20->pLevelOfDetail1;
11086 }
11087 }
11088 else
11089 {
11090 v19 = v3->pTexture;
11091 v84 = 0;
11092 v18 = (unsigned __int16 *)v19->pLevelOfDetail0;
11093 }
11094 a1.pTextureLOD = v18;
11095 LABEL_16:
11096 if ( v18 )
11097 {
11098 v23 = v3->field_5A;
11099 v83 = v3->field_52;
11100 v24 = v3->pTexture;
11101 v74 = v23;
11102 v78 = v85 >> v23;
11103 v25 = v24->uTextureWidth;
11104 v81 = v85 - (v85 >> v23 << v23);
11105 v26 = (signed int)v24->uTextureHeight >> v84;
11106 a1.field_10 = v84 - v24->uWidthLn2 + 16;
11107 v27 = v84 + bUseLoResSprites;
11108 a1.field_8 = (v26 << 16) - 65536;
11109 a1.field_C = (v25 >> v84) - 1;
11110 if ( v79 >= v70 )
11111 {
11112 v46 = v76;
11113 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1);
11114 v47 = v3->ptr_38;
11115 v79 = v80;
11116 v86 = v47->field_10;
11117 v79 = v80;
11118 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
11119 v86 = v3->ptr_38->field_1C;
11120 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
11121 v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16;
11122 v48 = v3->ptr_38;
11123 v79 = v70;
11124 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24;
11125 v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16;
11126 v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28;
11127 a1.field_30 >>= v27;
11128 a1.field_2C = (v69 + v49) >> v27;
11129 a1.field_14 = dword_80AA20 >> v27;
11130 a1.field_18 = dword_80AA1C >> v27;
11131 a1.field_1C = dword_80AA18 >> v27;
11132 v50 = v46->field_8;
11133 a1.field_20 = dword_80AA14 >> v27;
11134 v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A;
11135 a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50);
11136 a1.pColorBuffer = &v77[v85 - 1] + v51;
11137 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
11138 if ( v78 > 0 )
11139 {
11140 do
11141 {
11142 v77 = (unsigned __int16 *)v3->v_18.y;
11143 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16;
11144 v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16);
11145 if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)
11146 && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) )
11147 {
11148 LODWORD(v53) = v72 << 16;
11149 HIDWORD(v53) = v72 >> 16;
11150 v86 = v53 / v84;
11151 v54 = v53 / v84;
11152 v84 = v53 / v84;
11153 }
11154 else
11155 {
11156 v84 = 0x40000000u;
11157 v54 = 0x40000000u;
11158 }
11159 HIWORD(v55) = HIWORD(v54);
11160 LOWORD(v55) = 0;
11161 a1.field_24 = v3->field_50 | v55;
11162 v77 = (unsigned __int16 *)v3->ptr_38->field_10;
11163 v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
11164 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
11165 v56 = v3->ptr_38;
11166 v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24;
11167 v77 = (unsigned __int16 *)v56->field_1C;
11168 v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
11169 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
11170 v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
11171 a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74;
11172 a1.field_0 = v58;
11173 a1.field_28 = v83;
11174 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11175 {
11176 if ( v3->pODMFace->uPolygonType == 1 )
11177 sr_sub_485BAE(&a1, &a2);
11178 else
11179 sr_sub_485AFF(&a1, &a2);
11180 }
11181 else
11182 {
11183 if ( v3->pODMFace->uPolygonType == 1 )
11184 sr_sub_4D71F8(&a1);
11185 else
11186 sr_sub_4D714C(&a1);
11187 }
11188 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
11189 &a2,
11190 v76,
11191 v84,
11192 v3,
11193 pOutdoorCamera->building_gamme,
11194 0,
11195 0);
11196 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
11197 --v78;
11198 }
11199 while ( v78 );
11200 }
11201 if ( !v81 )
11202 return 1;
11203 v83 = v3->v_18.y;
11204 v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16;
11205 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11206 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
11207 {
11208 v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
11209 if ( abs(X) < v59 )
11210 {
11211 LODWORD(v60) = v72 << 16;
11212 HIDWORD(v60) = v72 >> 16;
11213 v86 = v60 / v84;
11214 HIWORD(v61) = (unsigned int)(v60 / v84) >> 16;
11215 LOWORD(v61) = 0;
11216 a1.field_24 = v61 | v3->field_50;
11217 v83 = v3->ptr_38->field_10;
11218 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11219 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
11220 v62 = v3->ptr_38;
11221 v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24;
11222 v83 = v62->field_1C;
11223 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11224 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
11225 v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
11226 - a1.field_2C) >> v74;
11227 a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74;
11228 a1.field_0 = v64;
11229 a1.field_28 = v81;
11230 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11231 {
11232 if ( v3->pODMFace->uPolygonType == 1 )
11233 sr_sub_485BAE(&a1, &a2);
11234 else
11235 sr_sub_485AFF(&a1, &a2);
11236 }
11237 else
11238 {
11239 if ( v3->pODMFace->uPolygonType == 1 )
11240 sr_sub_4D71F8(&a1);
11241 else
11242 sr_sub_4D714C(&a1);
11243 }
11244 return 1;
11245 }
11246 }
11247 }
11248 else
11249 {
11250 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1);
11251 v28 = v3->ptr_38;
11252 v85 = v10;
11253 v86 = v28->field_10;
11254 v85 = v10;
11255 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
11256 v86 = v3->ptr_38->field_1C;
11257 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
11258 v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16;
11259 v29 = v3->ptr_38;
11260 v85 = v79;
11261 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24;
11262 v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16;
11263 v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28;
11264 a1.field_30 >>= v27;
11265 a1.field_2C = (v69 + v30) >> v27;
11266 a1.field_14 = dword_80AA20 >> v27;
11267 a1.field_18 = dword_80AA1C >> v27;
11268 a1.field_1C = dword_80AA18 >> v27;
11269 a1.field_20 = dword_80AA14 >> v27;
11270 v31 = v76->field_A;
11271 v32 = pRenderer->uTargetSurfacePitch * v76->field_A;
11272 v86 = v76->field_8;
11273 a1.pColorBuffer = &v77[v86 + v32];
11274 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31];
11275 v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74);
11276 if ( v78 > 0 )
11277 {
11278 v86 = v78;
11279 do
11280 {
11281 v78 = v3->v_18.y;
11282 v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16;
11283 v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
11284 if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16)
11285 && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) )
11286 {
11287 LODWORD(v34) = v72 << 16;
11288 HIDWORD(v34) = v72 >> 16;
11289 v85 = v34 / v84;
11290 v35 = v34 / v84;
11291 v84 = v34 / v84;
11292 }
11293 else
11294 {
11295 v84 = 1073741824;
11296 v35 = 1073741824;
11297 }
11298 HIWORD(v36) = HIWORD(v35);
11299 LOWORD(v36) = 0;
11300 a1.field_24 = v3->field_50 | v36;
11301 v78 = v3->ptr_38->field_10;
11302 v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
11303 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
11304 v37 = v3->ptr_38;
11305 v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24;
11306 v78 = v37->field_1C;
11307 v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
11308 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
11309 v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
11310 a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74;
11311 a1.field_0 = v39;
11312 a1.field_28 = v83;
11313 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11314 {
11315 if ( v3->pODMFace->uPolygonType == 1 )
11316 sr_sub_485A24(&a1, (stru315 *)&a2);
11317 else
11318 sr_sub_485975(&a1, (stru315 *)&a2);
11319 }
11320 else
11321 {
11322 if ( v3->pODMFace->uPolygonType == 1 )
11323 sr_sub_4D705A(v2);
11324 else
11325 sr_sub_4D6FB0(v2);
11326 }
11327 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
11328 &a2,
11329 v76,
11330 v84,
11331 v3,
11332 pOutdoorCamera->building_gamme,
11333 1u,
11334 0);
11335 v80 -= pOutdoorCamera->int_fov_rad_inv << v74;
11336 --v86;
11337 }
11338 while ( v86 );
11339 }
11340 if ( !v81 )
11341 return 1;
11342 v83 = v3->v_18.y;
11343 v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11344 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11345 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
11346 {
11347 v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
11348 if ( abs(X) < v40 )
11349 {
11350 LODWORD(v41) = v72 << 16;
11351 HIDWORD(v41) = v72 >> 16;
11352 X = v41 / v84;
11353 HIWORD(v42) = (unsigned int)(v41 / v84) >> 16;
11354 LOWORD(v42) = 0;
11355 a1.field_24 = v42 | v3->field_50;
11356 v83 = v3->ptr_38->field_10;
11357 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11358 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
11359 v43 = v3->ptr_38;
11360 v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24;
11361 v83 = v43->field_1C;
11362 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
11363 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
11364 v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
11365 - a1.field_2C) >> v74;
11366 a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74;
11367 a1.field_0 = v45;
11368 a1.field_28 = v81;
11369 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11370 {
11371 if ( v3->pODMFace->uPolygonType == 1 )
11372 sr_sub_485A24(&a1, (stru315 *)&a2);
11373 else
11374 sr_sub_485975(&a1, (stru315 *)&a2);
11375 }
11376 else
11377 {
11378 if ( v3->pODMFace->uPolygonType == 1 )
11379 sr_sub_4D705A(v2);
11380 else
11381 sr_sub_4D6FB0(v2);
11382 }
11383 return 1;
11384 }
11385 }
11386 }
11387 }
11388 return 0;
11389 }
11390 // 4D864C: using guessed type char byte_4D864C;
11391 // 6BE0E4: using guessed type int mipmapping_building_mm1;
11392 // 6BE0E8: using guessed type int mipmapping_building_mm2;
11393 // 6BE0EC: using guessed type int mipmapping_building_mm3;
11394 // 80AA14: using guessed type int dword_80AA14;
11395 // 80AA18: using guessed type int dword_80AA18;
11396 // 80AA1C: using guessed type int dword_80AA1C;
11397 // 80AA20: using guessed type int dword_80AA20;
11398
11399 //----- (004839BD) --------------------------------------------------------
11400 signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface)
11401 {
11402 stru315 *v2; // ebp@0
11403 int v3; // eax@1
11404 int v4; // edi@1
11405 stru148 *v5; // esi@1
11406 unsigned int v6; // ebx@1
11407 int v7; // ecx@1
11408 int v8; // ebx@1
11409 int v9; // ecx@1
11410 int v10; // eax@1
11411 stru149 *v11; // eax@1
11412 int v12; // edx@1
11413 int v13; // eax@1
11414 int v14; // edi@1
11415 int v15; // ecx@1
11416 int v16; // eax@1
11417 signed int v17; // edi@1
11418 int v18; // edi@2
11419 signed __int64 v19; // qtt@3
11420 int v20; // edi@3
11421 unsigned __int16 *v21; // eax@3
11422 Texture *v22; // eax@4
11423 Texture *v23; // eax@6
11424 Texture *v24; // eax@8
11425 Texture *v25; // eax@10
11426 stru149 *v26; // eax@13
11427 int v27; // edi@13
11428 signed int v28; // edx@13
11429 Texture *v29; // ebx@13
11430 int v30; // edi@13
11431 signed int v31; // edx@13
11432 signed int v32; // eax@13
11433 signed int v33; // eax@13
11434 int v34; // ebx@13
11435 int v35; // eax@15
11436 int v36; // ebx@15
11437 int v37; // eax@16
11438 signed __int64 v38; // qtt@17
11439 int v39; // ecx@17
11440 int v40; // eax@19
11441 stru149 *v41; // eax@21
11442 int v42; // ebx@21
11443 int v43; // ebx@21
11444 int v44; // eax@21
11445 char v45; // zf@25
11446 int v46; // eax@28
11447 int v47; // eax@28
11448 int v48; // ebx@28
11449 int v49; // eax@29
11450 signed __int64 v50; // qtt@30
11451 int v51; // ecx@30
11452 int v52; // eax@30
11453 int v53; // edx@31
11454 stru149 *v54; // eax@33
11455 int v55; // ebx@33
11456 signed int v56; // ebx@33
11457 int v57; // eax@33
11458 unsigned __int64 v58; // qax@33
11459 int v60; // [sp+Ch] [bp-BCh]@1
11460 Span *v61; // [sp+10h] [bp-B8h]@1
11461 int v62; // [sp+14h] [bp-B4h]@2
11462 int v63; // [sp+18h] [bp-B0h]@1
11463 stru315 a1; // [sp+1Ch] [bp-ACh]@1
11464 stru316 a2; // [sp+60h] [bp-68h]@13
11465 int v66; // [sp+88h] [bp-40h]@13
11466 int v67; // [sp+8Ch] [bp-3Ch]@1
11467 int v68; // [sp+90h] [bp-38h]@13
11468 int v69; // [sp+94h] [bp-34h]@3
11469 int v70; // [sp+98h] [bp-30h]@1
11470 int v71; // [sp+9Ch] [bp-2Ch]@1
11471 int v72; // [sp+A0h] [bp-28h]@1
11472 int v73; // [sp+A4h] [bp-24h]@13
11473 int v74; // [sp+A8h] [bp-20h]@1
11474 int v75; // [sp+ACh] [bp-1Ch]@3
11475 int v76; // [sp+B0h] [bp-18h]@1
11476 int v77; // [sp+B4h] [bp-14h]@1
11477 int X; // [sp+B8h] [bp-10h]@1
11478 int v79; // [sp+BCh] [bp-Ch]@21
11479 int v80; // [sp+C0h] [bp-8h]@13
11480 unsigned int v81; // [sp+C4h] [bp-4h]@1
11481
11482 v3 = ecx0->field_A;
11483 v4 = ecx0->field_8;
11484 v5 = ecx0->pParent;
11485 v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A;
11486 v61 = ecx0;
11487 v7 = ecx0->field_C;
11488 a1.pColorBuffer = &pTargetSurface[v6];
11489 v74 = v7;
11490 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3];
11491 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
11492 v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3);
11493 v10 = v5->ptr_38->field_14;
11494 v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
11495 v72 = v10;
11496 v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16;
11497 v11 = v5->ptr_38;
11498 v12 = v81 + v11->field_C;
11499 v72 = v11->field_20;
11500 v67 = v12;
11501 v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18;
11502 v81 = v9;
11503 v70 = v13;
11504 v72 = v5->v_18.z;
11505 v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16;
11506 v14 = v5->field_24;
11507 v15 = v81 + v5->v_18.x;
11508 v71 = v5->sTextureDeltaU << 16;
11509 v63 = v5->sTextureDeltaV << 16;
11510 v16 = v5->v_18.y;
11511 v17 = -v14;
11512 v60 = v15;
11513 v77 = v17;
11514 v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16;
11515 X = v81 + v15;
11516 if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) )
11517 return 0;
11518 LODWORD(v19) = v77 << 16;
11519 HIDWORD(v19) = v77 >> 16;
11520 v69 = v19 / X;
11521 v20 = v19 / X;
11522 v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
11523 a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
11524 v75 = 2;
11525 if ( v20 >= mipmapping_building_mm1 << 16 )
11526 {
11527 if ( v20 >= mipmapping_building_mm2 << 16 )
11528 {
11529 if ( v20 >= mipmapping_building_mm3 << 16 )
11530 {
11531 if ( bUseLoResSprites )
11532 goto LABEL_12;
11533 v25 = v5->pTexture;
11534 v75 = 3;
11535 v21 = (unsigned __int16 *)v25->pLevelOfDetail3;
11536 }
11537 else
11538 {
11539 v24 = v5->pTexture;
11540 v75 = 2;
11541 v21 = (unsigned __int16 *)v24->pLevelOfDetail2;
11542 }
11543 }
11544 else
11545 {
11546 v23 = v5->pTexture;
11547 v75 = 1;
11548 v21 = (unsigned __int16 *)v23->pLevelOfDetail1;
11549 }
11550 }
11551 else
11552 {
11553 v22 = v5->pTexture;
11554 v75 = 0;
11555 v21 = (unsigned __int16 *)v22->pLevelOfDetail0;
11556 }
11557 a1.pTextureLOD = v21;
11558 LABEL_12:
11559 if ( v21 )
11560 {
11561 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1);
11562 a1.field_28 = 16;
11563 v66 = v74 >> 4;
11564 v81 = v8;
11565 v26 = v5->ptr_38;
11566 v72 = v74 - 16 * (v74 >> 4);
11567 v76 = v26->field_10;
11568 v81 = v8;
11569 v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
11570 v76 = v5->ptr_38->field_1C;
11571 v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
11572 v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16;
11573 v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24;
11574 v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16;
11575 v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28;
11576 v76 = v75 + bUseLoResSprites;
11577 v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv;
11578 v29 = v5->pTexture;
11579 v30 = (v71 + v27) >> v76;
11580 v31 = v28 >> v76;
11581 v32 = (signed int)v29->uTextureWidth >> v75;
11582 v74 = (signed __int16)v75;
11583 v68 = v31;
11584 v80 = v32;
11585 v33 = (signed int)v29->uTextureHeight >> v75;
11586 v34 = v75 - v29->uWidthLn2;
11587 a1.field_8 = (v33 << 16) - 65536;
11588 v81 = 2 * pMiscTimer->uTotalGameTimeElapsed;
11589 a1.field_10 = v34 + 16;
11590 a1.field_C = v80 - 1;
11591 if ( v66 > 0 )
11592 {
11593 v74 = v66;
11594 v66 = 12 - v75;
11595 do
11596 {
11597 v80 = v5->v_18.y;
11598 v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16;
11599 v36 = v35 + v60;
11600 X = v35 + v60;
11601 if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) )
11602 {
11603 LODWORD(v38) = v77 << 16;
11604 HIDWORD(v38) = v77 >> 16;
11605 v80 = v38 / X;
11606 v39 = v38 / X;
11607 X = v38 / X;
11608 }
11609 else
11610 {
11611 X = 0x40000000u;
11612 v39 = 0x40000000u;
11613 }
11614 HIWORD(v40) = HIWORD(v39);
11615 if ( v39 <= v69 )
11616 HIWORD(v40) = HIWORD(v69);
11617 LOWORD(v40) = 0;
11618 a1.field_24 = v5->field_50 | v40;
11619 v79 = v5->ptr_38->field_10;
11620 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
11621 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
11622 v41 = v5->ptr_38;
11623 v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24;
11624 v79 = v41->field_1C;
11625 v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
11626 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
11627 v43 = (v71 + v42) >> v76;
11628 v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76;
11629 a1.field_4 = (v43 - v30) >> 4;
11630 a1.field_0 = (v79 - v68) >> 4;
11631 a1.field_30 = v30 + 4 * stru_5C6E00->SinCos(v81 + (v68 >> v66));
11632 v44 = stru_5C6E00->SinCos(v81 + (v30 >> v66) - stru_5C6E00->uIntegerHalfPi);
11633 a1.field_2C = v68 + 4 * v44;
11634 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11635 sr_sub_485975(&a1, (stru315 *)&a2);
11636 else
11637 sr_sub_4D6FB0(v2);
11638 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0);
11639 v73 -= 16 * pOutdoorCamera->int_fov_rad_inv;
11640 v45 = v74-- == 1;
11641 a1.field_28 = 16;
11642 v30 = v43;
11643 v68 = v79;
11644 }
11645 while ( !v45 );
11646 v31 = v79;
11647 }
11648 if ( !v72 )
11649 return 1;
11650 v66 = 12 - v75;
11651 a1.field_30 = v30 + 4 * stru_5C6E00->SinCos(v81 + (v31 >> (12 - v75)));
11652 v46 = stru_5C6E00->SinCos(v81 + (v30 >> v66) - stru_5C6E00->uIntegerHalfPi);
11653 a1.field_2C = v68 + 4 * v46;
11654 v79 = v5->v_18.y;
11655 v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
11656 v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
11657 v48 = v47 + v60;
11658 X = v47 + v60;
11659 if ( v47 + v60 )
11660 {
11661 v79 = abs(v62);
11662 v49 = abs(v48);
11663 if ( v79 <= v49 )
11664 {
11665 LODWORD(v50) = v77 << 16;
11666 HIDWORD(v50) = v77 >> 16;
11667 v77 = v50 / X;
11668 v51 = v50 / X;
11669 HIWORD(v52) = HIWORD(v69);
11670 if ( v51 <= v69 )
11671 {
11672 LOWORD(v52) = 0;
11673 a1.field_24 = v52 | v5->field_50;
11674 }
11675 else
11676 {
11677 HIWORD(v53) = HIWORD(v51);
11678 LOWORD(v53) = 0;
11679 a1.field_24 = v53 | v5->field_50;
11680 }
11681 v79 = v5->ptr_38->field_10;
11682 v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
11683 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
11684 v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16;
11685 v54 = v5->ptr_38;
11686 v55 = v67 - v54->field_24;
11687 v79 = v54->field_1C;
11688 v56 = v71 + v55;
11689 v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
11690 v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
11691 v79 = v57;
11692 v58 = v57 * (signed __int64)v51;
11693 v70 = v58 >> 16;
11694 LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76;
11695 a1.field_4 = ((v56 >> v76) - v30) >> 4;
11696 a1.field_0 = ((signed int)v58 - v68) >> 4;
11697 a1.field_28 = v72;
11698 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11699 sr_sub_485975(&a1, (stru315 *)&a2);
11700 else
11701 sr_sub_4D6FB0(v2);
11702 return 1;
11703 }
11704 }
11705 }
11706 return 0;
11707 }
11708 // 4D864C: using guessed type char byte_4D864C;
11709 // 6BE0E4: using guessed type int mipmapping_building_mm1;
11710 // 6BE0E8: using guessed type int mipmapping_building_mm2;
11711 // 6BE0EC: using guessed type int mipmapping_building_mm3;
11712
11713
11714
11715 //----- (0048408A) --------------------------------------------------------
11716 signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this)
11717 {
11718 stru315 *v1; // ebp@0
11719 Span *v2; // edi@1
11720 stru148 *v3; // esi@1
11721 int v4; // ecx@1
11722 stru149 *v5; // eax@1
11723 stru149 *v6; // eax@1
11724 int v7; // edx@1
11725 int v8; // eax@1
11726 int v9; // ebx@1
11727 int v10; // eax@1
11728 int v11; // ecx@1
11729 int v12; // eax@1
11730 int v13; // ecx@1
11731 int v14; // eax@1
11732 signed int v15; // ecx@1
11733 int v16; // ebx@1
11734 signed __int64 v17; // qtt@3
11735 stru149 *v18; // eax@3
11736 int v19; // ebx@3
11737 Texture *v20; // eax@4
11738 unsigned __int16 *v21; // eax@4
11739 Texture *v22; // eax@6
11740 Texture *v23; // ecx@8
11741 Texture *v24; // eax@10
11742 stru149 *v25; // eax@12
11743 signed int v26; // eax@12
11744 int v27; // ecx@12
11745 int v28; // eax@14
11746 int v29; // edx@14
11747 int v30; // ecx@14
11748 Texture *v31; // esi@14
11749 int v32; // edx@14
11750 int v33; // eax@14
11751 int v35; // [sp+Ch] [bp-8Ch]@1
11752 int v36; // [sp+10h] [bp-88h]@1
11753 stru316 a2; // [sp+14h] [bp-84h]@14
11754 stru315 a1; // [sp+3Ch] [bp-5Ch]@1
11755 int v39; // [sp+80h] [bp-18h]@1
11756 int v40; // [sp+84h] [bp-14h]@1
11757 int v41; // [sp+88h] [bp-10h]@1
11758 int v42; // [sp+8Ch] [bp-Ch]@1
11759 int v43; // [sp+90h] [bp-8h]@2
11760 int v44; // [sp+94h] [bp-4h]@1
11761
11762 v2 = _this;
11763 v3 = _this->pParent;
11764 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
11765 v5 = v3->ptr_38;
11766 v44 = v4;
11767 v42 = v5->field_14;
11768 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
11769 v6 = v3->ptr_38;
11770 v7 = v44 + v6->field_C;
11771 v42 = v6->field_20;
11772 v39 = v7;
11773 v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
11774 v44 = v4;
11775 v41 = v8;
11776 v42 = v3->v_18.z;
11777 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
11778 v9 = v44 + v3->v_18.x;
11779 v35 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
11780 v10 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
11781 v11 = v2->field_8;
11782 v36 = v10;
11783 a1.field_28 = v2->field_C;
11784 v12 = pViewport->uScreenCenterX - v11;
11785 v13 = v3->field_24;
11786 v42 = pOutdoorCamera->int_fov_rad_inv * v12;
11787 v14 = v3->v_18.y;
11788 v15 = -v13;
11789 v40 = v15;
11790 v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9;
11791 v44 = v16;
11792 if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) )
11793 return 0;
11794 LODWORD(v17) = v40 << 16;
11795 HIDWORD(v17) = v40 >> 16;
11796 v43 = v17 / v44;
11797 v18 = v3->ptr_38;
11798 v44 = v42;
11799 v40 = v18->field_10;
11800 v44 = v42;
11801 v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16);
11802 v39 = v3->ptr_38->field_1C;
11803 v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
11804 v19 = v43;
11805 v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
11806 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11807 v44 = 2;
11808 if ( v43 < mipmapping_terrain_mm1 << 16 )
11809 {
11810 v20 = v3->pTexture;
11811 v44 = 0;
11812 v21 = (unsigned __int16 *)v20->pLevelOfDetail0;
11813 LABEL_11:
11814 a1.pTextureLOD = v21;
11815 goto LABEL_12;
11816 }
11817 if ( v43 < mipmapping_terrain_mm2 << 16 )
11818 {
11819 v22 = v3->pTexture;
11820 v44 = 1;
11821 v21 = (unsigned __int16 *)v22->pLevelOfDetail1;
11822 goto LABEL_11;
11823 }
11824 if ( v43 >= mipmapping_terrain_mm3 << 16 )
11825 {
11826 if ( !bUseLoResSprites )
11827 {
11828 v24 = v3->pTexture;
11829 v44 = 3;
11830 v21 = (unsigned __int16 *)v24->pLevelOfDetail3;
11831 goto LABEL_11;
11832 }
11833 }
11834 else
11835 {
11836 v23 = v3->pTexture;
11837 v44 = 2;
11838 a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2;
11839 }
11840 LABEL_12:
11841 v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16;
11842 v25 = v3->ptr_38;
11843 v43 = v19;
11844 a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24;
11845 v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16;
11846 v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28;
11847 v27 = bUseLoResSprites + v44 + 2;
11848 a1.field_30 >>= v27;
11849 v41 = bUseLoResSprites + v44 + 2;
11850 a1.field_2C = v26 >> v27;
11851 if ( byte_80AA10 )
11852 {
11853 a1.field_14 = dword_80AA20 >> v27;
11854 a1.field_18 = dword_80AA1C >> v27;
11855 a1.field_1C = dword_80AA18 >> v27;
11856 a1.field_20 = dword_80AA14 >> v27;
11857 }
11858 v41 = pOutdoorCamera->int_fov_rad_inv;
11859 v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27;
11860 a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16;
11861 v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
11862 a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
11863 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
11864 LOWORD(v19) = 0;
11865 v28 = v2->field_A;
11866 v29 = v2->field_A;
11867 a1.field_24 = v19;
11868 v30 = v2->field_8;
11869 a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29];
11870 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28];
11871 v31 = v3->pTexture;
11872 v32 = ((signed int)v31->uTextureWidth >> v44) - 1;
11873 v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536;
11874 a1.field_10 = v44 - v31->uWidthLn2 + 16;
11875 a1.field_C = v32;
11876 a1.field_8 = v33;
11877 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11878 {
11879 if ( byte_80AA10 )
11880 sr_sub_485A24(&a1, (stru315 *)&a2);
11881 else
11882 sr_sub_485975(&a1, (stru315 *)&a2);
11883 }
11884 else
11885 {
11886 if ( byte_80AA10 )
11887 sr_sub_4D705A(v1);
11888 else
11889 sr_sub_4D6FB0(v1);
11890 }
11891 return 1;
11892 }
11893
11894
11895
11896 //----- (00484442) --------------------------------------------------------
11897 signed int sr_sub_484442(Span *_this)
11898 {
11899 int v1; // ebp@0
11900 Span *v2; // edi@1
11901 stru148 *v3; // esi@1
11902 int v4; // ecx@1
11903 stru149 *v5; // eax@1
11904 stru149 *v6; // eax@1
11905 int v7; // edx@1
11906 int v8; // eax@1
11907 int v9; // ebx@1
11908 int v10; // eax@1
11909 int v11; // ecx@1
11910 int v12; // eax@1
11911 int v13; // ecx@1
11912 signed int v14; // ecx@1
11913 int v15; // ebx@1
11914 signed __int64 v16; // qtt@3
11915 int v17; // ecx@3
11916 int v18; // ebx@3
11917 int v19; // eax@3
11918 signed int v20; // ebx@3
11919 unsigned __int16 *v21; // eax@4
11920 stru149 *v22; // eax@12
11921 signed int v23; // eax@12
11922 int v24; // ecx@12
11923 int v25; // ecx@14
11924 unsigned int *v26; // eax@14
11925 Texture *v27; // esi@14
11926 signed int v28; // edi@14
11927 signed int v29; // eax@14
11928 signed int v31; // [sp+Ch] [bp-90h]@1
11929 int v32; // [sp+10h] [bp-8Ch]@1
11930 int v33; // [sp+14h] [bp-88h]@1
11931 stru316 v34; // [sp+18h] [bp-84h]@14
11932 stru315 v35; // [sp+40h] [bp-5Ch]@1
11933 int v36; // [sp+84h] [bp-18h]@1
11934 int v37; // [sp+88h] [bp-14h]@1
11935 int v38; // [sp+8Ch] [bp-10h]@1
11936 int v39; // [sp+90h] [bp-Ch]@1
11937 int v40; // [sp+94h] [bp-8h]@1
11938 int v41; // [sp+98h] [bp-4h]@1
11939
11940 v2 = _this;
11941 v3 = _this->pParent;
11942 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
11943 v5 = v3->ptr_38;
11944 v40 = v4;
11945 v39 = v5->field_14;
11946 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
11947 v6 = v3->ptr_38;
11948 v7 = v40 + v6->field_C;
11949 v39 = v6->field_20;
11950 v36 = v7;
11951 v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
11952 v40 = v4;
11953 v38 = v8;
11954 v39 = v3->v_18.z;
11955 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
11956 v9 = v40 + v3->v_18.x;
11957 v32 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
11958 v10 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
11959 v11 = v2->field_8;
11960 v33 = v10;
11961 v35.field_28 = v2->field_C;
11962 v12 = pViewport->uScreenCenterX - v11;
11963 v13 = v3->field_24;
11964 v41 = pOutdoorCamera->int_fov_rad_inv * v12;
11965 v14 = -v13;
11966 v31 = v14;
11967 v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9;
11968 v37 = v15;
11969 if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) )
11970 return 0;
11971 LODWORD(v16) = v31 << 16;
11972 HIDWORD(v16) = v31 >> 16;
11973 v40 = v16 / v37;
11974 v17 = v16 / v37;
11975 v18 = v41;
11976 HIWORD(v19) = (unsigned int)(v16 / v37) >> 16;
11977 LOWORD(v19) = 0;
11978 v35.field_24 = v19;
11979 v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16);
11980 v36 = v3->ptr_38->field_1C;
11981 v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16;
11982 v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16;
11983 v20 = 2;
11984 v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11985 if ( v17 < mipmapping_terrain_mm1 << 16 )
11986 {
11987 v20 = 0;
11988 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0;
11989 LABEL_11:
11990 v35.pTextureLOD = v21;
11991 goto LABEL_12;
11992 }
11993 if ( v17 < mipmapping_terrain_mm2 << 16 )
11994 {
11995 v20 = 1;
11996 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1;
11997 goto LABEL_11;
11998 }
11999 if ( v17 < mipmapping_terrain_mm3 << 16 )
12000 {
12001 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
12002 goto LABEL_11;
12003 }
12004 if ( !bUseLoResSprites )
12005 {
12006 v20 = 3;
12007 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3;
12008 goto LABEL_11;
12009 }
12010 LABEL_12:
12011 v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16;
12012 v22 = v3->ptr_38;
12013 v41 = v17;
12014 v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24;
12015 v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28;
12016 v24 = bUseLoResSprites + v20 + 2;
12017 v35.field_30 >>= v24;
12018 v38 = bUseLoResSprites + v20 + 2;
12019 v35.field_2C = v23 >> v24;
12020 if ( byte_80AA10 )
12021 {
12022 v35.field_14 = dword_80AA20 >> v24;
12023 v35.field_18 = dword_80AA1C >> v24;
12024 v35.field_1C = dword_80AA18 >> v24;
12025 v35.field_20 = dword_80AA14 >> v24;
12026 }
12027 v38 = pOutdoorCamera->int_fov_rad_inv;
12028 v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24;
12029 v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16;
12030 v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
12031 v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
12032 v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
12033 v25 = v2->field_8;
12034 v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A];
12035 v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A];
12036 v35.pDepthBuffer = v26;
12037 v27 = v3->pTexture;
12038 v28 = (signed int)v27->uTextureWidth >> v20;
12039 v29 = (signed int)v27->uTextureHeight >> v20;
12040 v35.field_10 = v20 - v27->uWidthLn2 + 16;
12041 v35.field_C = v28 - 1;
12042 v35.field_8 = (v29 << 16) - 65536;
12043 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12044 {
12045 if ( byte_80AA10 )
12046 sr_sub_485D3E(&v35, &v34);
12047 else
12048 sr_sub_485C89(&v35, &v34);
12049 }
12050 else
12051 {
12052 if ( byte_80AA10 )
12053 sr_sub_4D72EC(v1);
12054 else
12055 sr_sub_4D73DF(v1);
12056 }
12057 return 1;
12058 }
12059
12060
12061 //----- (004847EB) --------------------------------------------------------
12062 int sr_sub_4847EB(Span *_this)
12063 {
12064 stru315 *v1; // ebp@0
12065 int v2; // ebx@1
12066 int v3; // edx@1
12067 stru148 *v4; // esi@1
12068 int v5; // eax@1
12069 signed int v6; // eax@3
12070 int v7; // edi@3
12071 stru149 *v8; // eax@3
12072 stru149 *v9; // eax@3
12073 int v10; // edx@3
12074 int v11; // eax@3
12075 signed int v12; // ebx@3
12076 int v13; // ebx@4
12077 signed __int64 v14; // qtt@5
12078 int v15; // eax@5
12079 signed int v16; // ebx@5
12080 unsigned __int16 *v17; // ecx@6
12081 stru149 *v18; // eax@14
12082 stru149 *v19; // eax@14
12083 signed int v20; // eax@14
12084 int v21; // ecx@14
12085 Texture *v22; // edx@16
12086 signed int v23; // eax@16
12087 int v24; // ebx@16
12088 int v25; // edi@17
12089 int v26; // ebx@17
12090 int v27; // eax@17
12091 int v28; // edi@17
12092 int v29; // eax@18
12093 signed __int64 v30; // qtt@19
12094 int v31; // ecx@19
12095 int v32; // eax@19
12096 stru149 *v33; // eax@21
12097 signed int v34; // edi@21
12098 int v35; // ebx@21
12099 signed int v36; // edi@21
12100 signed __int64 v37; // qtt@21
12101 signed int v38; // ebx@21
12102 int v39; // ebx@29
12103 int v40; // eax@32
12104 unsigned __int64 v41; // qax@32
12105 int v42; // edi@32
12106 int v43; // eax@33
12107 signed __int64 v44; // qtt@34
12108 int v45; // ecx@34
12109 int v46; // eax@34
12110 stru149 *v47; // eax@36
12111 signed int v48; // edi@36
12112 int v49; // eax@36
12113 int v50; // eax@47
12114 unsigned __int64 v51; // qax@47
12115 int v52; // edi@47
12116 int v53; // eax@48
12117 signed __int64 v54; // qtt@49
12118 int v55; // ecx@49
12119 int v56; // eax@49
12120 stru149 *v57; // eax@51
12121 signed int v58; // edi@51
12122 int v59; // eax@51
12123 Span *v61; // [sp+Ch] [bp-B0h]@1
12124 int v62; // [sp+10h] [bp-ACh]@3
12125 int v63; // [sp+14h] [bp-A8h]@3
12126 int v64; // [sp+18h] [bp-A4h]@3
12127 int v65; // [sp+1Ch] [bp-A0h]@3
12128 signed int v66; // [sp+20h] [bp-9Ch]@3
12129 signed int v67; // [sp+24h] [bp-98h]@3
12130 int v68; // [sp+28h] [bp-94h]@1
12131 char v69; // [sp+2Ch] [bp-90h]@1
12132 stru315 sr; // [sp+30h] [bp-8Ch]@1
12133 stru316 sr2; // [sp+74h] [bp-48h]@14
12134 int v72; // [sp+9Ch] [bp-20h]@5
12135 int v73; // [sp+A0h] [bp-1Ch]@1
12136 int v74; // [sp+A4h] [bp-18h]@3
12137 int v75; // [sp+A8h] [bp-14h]@21
12138 int v76; // [sp+ACh] [bp-10h]@1
12139 int v77; // [sp+B0h] [bp-Ch]@14
12140 int v78; // [sp+B4h] [bp-8h]@3
12141 int v79; // [sp+B8h] [bp-4h]@3
12142
12143 v2 = _this->field_A;
12144 v3 = _this->field_8;
12145 v4 = _this->pParent;
12146 v73 = 0;
12147 v61 = _this;
12148 sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
12149 v76 = v3;
12150 v5 = _this->field_C;
12151 sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2];
12152 v68 = texmapping_terrain_subdivsize;
12153 v69 = texmapping_terrain_subdivpow2;
12154 if ( v5 >= texmapping_terrain_subdivsize )
12155 v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1));
12156 v6 = v5 - v73;
12157 v67 = v6 >> texmapping_terrain_subdivpow2;
12158 v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2);
12159 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
12160 v8 = v4->ptr_38;
12161 v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
12162 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
12163 v76 = v8->field_14;
12164 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
12165 v9 = v4->ptr_38;
12166 v10 = v78 + v9->field_C;
12167 v76 = v9->field_20;
12168 v65 = v10;
12169 v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16)
12170 + v4->ptr_38->field_18;
12171 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
12172 v64 = v11;
12173 v76 = v4->v_18.z;
12174 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
12175 v12 = -v4->field_24;
12176 v63 = v78 + v4->v_18.x;
12177 v66 = -v4->field_24;
12178 v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16;
12179 v74 = v78 + v63;
12180 if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) )
12181 return 0;
12182 LODWORD(v14) = v66 << 16;
12183 HIDWORD(v14) = v66 >> 16;
12184 v72 = v14 / v74;
12185 sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
12186 v15 = v14 / v74;
12187 v16 = 2;
12188 if ( v15 >= mipmapping_terrain_mm1 << 16 )
12189 {
12190 if ( v15 >= mipmapping_terrain_mm2 << 16 )
12191 {
12192 if ( v15 >= mipmapping_terrain_mm3 << 16 )
12193 {
12194 if ( bUseLoResSprites )
12195 goto LABEL_14;
12196 v16 = 3;
12197 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3;
12198 }
12199 else
12200 {
12201 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
12202 }
12203 }
12204 else
12205 {
12206 v16 = 1;
12207 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1;
12208 }
12209 }
12210 else
12211 {
12212 v16 = 0;
12213 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0;
12214 }
12215 sr.pTextureLOD = v17;
12216 LABEL_14:
12217 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1);
12218 v18 = v4->ptr_38;
12219 v78 = v7;
12220 v79 = v18->field_10;
12221 v78 = v7;
12222 v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
12223 v79 = v4->ptr_38->field_1C;
12224 v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
12225 v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16;
12226 v19 = v4->ptr_38;
12227 v78 = v72;
12228 sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24;
12229 v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
12230 v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28;
12231 v21 = bUseLoResSprites + v16 + 2;
12232 sr.field_30 >>= v21;
12233 v78 = bUseLoResSprites + v16 + 2;
12234 sr.field_2C = v20 >> v21;
12235 if ( byte_80AA10 )
12236 {
12237 sr.field_14 = dword_80AA20 >> v21;
12238 sr.field_18 = dword_80AA1C >> v21;
12239 sr.field_1C = dword_80AA18 >> v21;
12240 sr.field_20 = dword_80AA14 >> v21;
12241 }
12242 v22 = v4->pTexture;
12243 v79 = (signed int)v22->uTextureWidth >> v16;
12244 v23 = (signed int)v22->uTextureHeight >> v16;
12245 v24 = v16 - v22->uWidthLn2 + 16;
12246 sr.field_8 = (v23 << 16) - 65536;
12247 sr.field_10 = v24;
12248 sr.field_C = v79 - 1;
12249 if ( v73 )
12250 {
12251 v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv;
12252 v26 = v25;
12253 v77 = v4->v_18.y;
12254 v79 = v25;
12255 v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16;
12256 v28 = v27 + v63;
12257 v74 = v27 + v63;
12258 if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) )
12259 return 0;
12260 LODWORD(v30) = v66 << 16;
12261 HIDWORD(v30) = v66 >> 16;
12262 v77 = v30 / v74;
12263 v31 = v30 / v74;
12264 HIWORD(v32) = HIWORD(v72);
12265 if ( v72 <= v31 )
12266 HIWORD(v32) = HIWORD(v31);
12267 LOWORD(v32) = 0;
12268 v77 = v26;
12269 sr.field_24 = v32;
12270 v74 = v4->ptr_38->field_10;
12271 v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
12272 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
12273 v33 = v4->ptr_38;
12274 v77 = v26;
12275 v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24;
12276 v74 = v33->field_1C;
12277 v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
12278 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
12279 v35 = (v77 - v4->ptr_38->field_28) >> v78;
12280 v74 = v73 << 16;
12281 v36 = (v34 >> v78) - sr.field_30;
12282 LODWORD(v37) = v36 << 16;
12283 HIDWORD(v37) = v36 >> 16;
12284 v38 = v35 - sr.field_2C;
12285 sr.field_4 = v37 / (v73 << 16);
12286 v75 = v73 << 16;
12287 LODWORD(v37) = v38 << 16;
12288 HIDWORD(v37) = v38 >> 16;
12289 v77 = v37 / (v73 << 16);
12290 sr.field_0 = v37 / (v73 << 16);
12291 sr.field_28 = v73;
12292 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12293 {
12294 if ( byte_80AA10 )
12295 sr_sub_485A24(&sr, (stru315 *)&sr2);
12296 else
12297 sr_sub_485975(&sr, (stru315 *)&sr2);
12298 }
12299 else
12300 {
12301 if ( byte_80AA10 )
12302 sr_sub_4D705A(v1);
12303 else
12304 sr_sub_4D6FB0(v1);
12305 }
12306 v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69);
12307 }
12308 else
12309 {
12310 v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
12311 v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
12312 }
12313 sr.field_28 = v68;
12314 while ( v67 > 0 )
12315 {
12316 v40 = v4->v_18.y;
12317 --v67;
12318 v75 = v40;
12319 v41 = v40 * (signed __int64)v39;
12320 v79 = v41 >> 16;
12321 LODWORD(v41) = v41 >> 16;
12322 v42 = v41 + v63;
12323 v74 = v41 + v63;
12324 if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) )
12325 return 0;
12326 LODWORD(v44) = v66 << 16;
12327 HIDWORD(v44) = v66 >> 16;
12328 v73 = v44 / v74;
12329 v45 = v44 / v74;
12330 HIWORD(v46) = HIWORD(v72);
12331 if ( v72 <= v45 )
12332 HIWORD(v46) = HIWORD(v45);
12333 LOWORD(v46) = 0;
12334 v79 = v39;
12335 sr.field_24 = v46;
12336 v75 = v4->ptr_38->field_10;
12337 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
12338 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
12339 v47 = v4->ptr_38;
12340 v79 = v39;
12341 v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24;
12342 v75 = v47->field_1C;
12343 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
12344 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
12345 v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
12346 sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69;
12347 sr.field_0 = v49;
12348 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12349 {
12350 if ( byte_80AA10 )
12351 sr_sub_485A24(&sr, (stru315 *)&sr2);
12352 else
12353 sr_sub_485975(&sr, (stru315 *)&sr2);
12354 }
12355 else
12356 {
12357 if ( byte_80AA10 )
12358 sr_sub_4D705A(v1);
12359 else
12360 sr_sub_4D6FB0(v1);
12361 }
12362 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0);
12363 sr.field_28 = v68;
12364 v39 -= pOutdoorCamera->int_fov_rad_inv << v69;
12365 }
12366 if ( !v62 )
12367 return 1;
12368 v50 = v4->v_18.y;
12369 v75 = v50;
12370 v51 = v50 * (signed __int64)v39;
12371 v79 = v51 >> 16;
12372 LODWORD(v51) = v51 >> 16;
12373 v52 = v51 + v63;
12374 v74 = v51 + v63;
12375 if ( (int)v51 + v63 )
12376 {
12377 v75 = abs(v76);
12378 v53 = abs(v52);
12379 if ( v75 <= v53 )
12380 {
12381 LODWORD(v54) = v66 << 16;
12382 HIDWORD(v54) = v66 >> 16;
12383 v76 = v54 / v74;
12384 v55 = v54 / v74;
12385 HIWORD(v56) = HIWORD(v72);
12386 if ( v72 <= v55 )
12387 HIWORD(v56) = HIWORD(v55);
12388 LOWORD(v56) = 0;
12389 v76 = v39;
12390 sr.field_24 = v56;
12391 v75 = v4->ptr_38->field_10;
12392 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
12393 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
12394 v57 = v4->ptr_38;
12395 v76 = v39;
12396 v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24;
12397 v75 = v57->field_1C;
12398 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
12399 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
12400 v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
12401 sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69;
12402 sr.field_0 = v59;
12403 sr.field_28 = v62;
12404 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12405 {
12406 if ( byte_80AA10 )
12407 sr_sub_485A24(&sr, (stru315 *)&sr2);
12408 else
12409 sr_sub_485975(&sr, (stru315 *)&sr2);
12410 }
12411 else
12412 {
12413 if ( byte_80AA10 )
12414 sr_sub_4D705A(v1);
12415 else
12416 sr_sub_4D6FB0(v1);
12417 }
12418 return 1;
12419 }
12420 }
12421 return 0;
12422 }
12423 // 4D864C: using guessed type char byte_4D864C;
12424 // 6BE050: using guessed type int texmapping_terrain_subdivsize;
12425 // 6BE054: using guessed type int texmapping_terrain_subdivpow2;
12426 // 6BE0F0: using guessed type int mipmapping_terrain_mm1;
12427 // 6BE0F4: using guessed type int mipmapping_terrain_mm2;
12428 // 6BE0F8: using guessed type int mipmapping_terrain_mm3;
12429 // 80AA10: using guessed type char byte_80AA10;
12430 // 80AA14: using guessed type int dword_80AA14;
12431 // 80AA18: using guessed type int dword_80AA18;
12432 // 80AA1C: using guessed type int dword_80AA1C;
12433 // 80AA20: using guessed type int dword_80AA20;
12434
12435
12436
12437 //----- (00485407) --------------------------------------------------------
12438 signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1)
12439 {
12440 stru315 *v1; // ebp@0
12441 int v2; // eax@1
12442 int v3; // edx@1
12443 unsigned int v4; // edi@1
12444 stru148 *v5; // esi@1
12445 int v6; // ecx@1
12446 int v7; // ebx@1
12447 int v8; // ecx@1
12448 stru149 *v9; // eax@1
12449 stru149 *v10; // eax@1
12450 int v11; // edx@1
12451 int v12; // eax@1
12452 int v13; // eax@1
12453 int v14; // ecx@1
12454 signed int v15; // edi@1
12455 int v16; // edi@2
12456 signed __int64 v17; // qtt@3
12457 int v18; // edi@3
12458 int v19; // eax@3
12459 unsigned __int8 *pLOD; // eax@3
12460 Texture *v21; // eax@4
12461 Texture *v22; // eax@6
12462 Texture *v23; // eax@8
12463 Texture *v24; // eax@10
12464 stru149 *v25; // eax@13
12465 stru149 *v26; // eax@13
12466 signed int v27; // ebx@13
12467 stru149 *v28; // eax@13
12468 Texture *v29; // esi@13
12469 signed int v30; // ebx@13
12470 signed int v31; // edi@13
12471 signed int v32; // edx@13
12472 signed int v33; // eax@13
12473 int v34; // esi@13
12474 int v35; // eax@13
12475 unsigned __int64 v36; // qax@13
12476 int v37; // eax@13
12477 unsigned __int64 v38; // qax@13
12478 char v39; // cl@14
12479 stru316 a2; // [sp+Ch] [bp-90h]@13
12480 stru315 a1a; // [sp+34h] [bp-68h]@1
12481 Span *v43; // [sp+78h] [bp-24h]@1
12482 int v44; // [sp+7Ch] [bp-20h]@1
12483 int v45; // [sp+80h] [bp-1Ch]@1
12484 int v46; // [sp+84h] [bp-18h]@1
12485 Span *v47; // [sp+88h] [bp-14h]@1
12486 int v48; // [sp+8Ch] [bp-10h]@1
12487 int v49; // [sp+90h] [bp-Ch]@3
12488 int i; // [sp+94h] [bp-8h]@3
12489 int X; // [sp+98h] [bp-4h]@1
12490
12491 v2 = a1->field_A;
12492 v3 = a1->field_8;
12493 v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A;
12494 v5 = a1->pParent;
12495 v43 = a1;
12496 v6 = a1->field_C;
12497 a1a.pColorBuffer = &pRenderer->pTargetSurface[v4];
12498 v46 = v6;
12499 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3);
12500 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
12501 a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
12502 v9 = v5->ptr_38;
12503 v47 = (Span *)v7;
12504 X = v8;
12505 v48 = v9->field_14;
12506 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
12507 v10 = v5->ptr_38;
12508 v11 = X + v10->field_C;
12509 v48 = v10->field_20;
12510 v44 = v11;
12511 v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18;
12512 X = v8;
12513 v45 = v12;
12514 v48 = v5->v_18.z;
12515 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
12516 v13 = v5->v_18.y;
12517 v14 = X + v5->v_18.x;
12518 v15 = -v5->field_24;
12519 v48 = -v5->field_24;
12520 X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14;
12521 if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) )
12522 return 0;
12523 LODWORD(v17) = v48 << 16;
12524 HIDWORD(v17) = v48 >> 16;
12525 i = v17 / X;
12526 v18 = v17 / X;
12527 HIWORD(v19) = (unsigned int)(v17 / X) >> 16;
12528 LOWORD(v19) = 0;
12529 a1a.field_24 = v19;
12530 pLOD = v5->pTexture->pLevelOfDetail2;
12531 a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
12532 v49 = 2;
12533 if ( v18 >= mipmapping_terrain_mm1 << 16 )
12534 {
12535 if ( v18 >= mipmapping_terrain_mm2 << 16 )
12536 {
12537 if ( v18 >= mipmapping_terrain_mm3 << 16 )
12538 {
12539 if ( bUseLoResSprites )
12540 goto LABEL_12;
12541 v24 = v5->pTexture;
12542 v49 = 3;
12543 pLOD = v24->pLevelOfDetail3;
12544 }
12545 else
12546 {
12547 v23 = v5->pTexture;
12548 v49 = 2;
12549 pLOD = v23->pLevelOfDetail2;
12550 }
12551 }
12552 else
12553 {
12554 v22 = v5->pTexture;
12555 v49 = 1;
12556 pLOD = v22->pLevelOfDetail1;
12557 }
12558 }
12559 else
12560 {
12561 v21 = v5->pTexture;
12562 v49 = 0;
12563 pLOD = v21->pLevelOfDetail0;
12564 }
12565 a1a.pTextureLOD = (unsigned __int16 *)pLOD;
12566 LABEL_12:
12567 if ( !pLOD )
12568 return 0;
12569 a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1);
12570 a1a.field_28 = 16;
12571 v43 = (Span *)(v46 >> 4);
12572 X = v7;
12573 v25 = v5->ptr_38;
12574 v48 = v46 - 16 * (v46 >> 4);
12575 v46 = v25->field_10;
12576 X = v7;
12577 v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16);
12578 v44 = v5->ptr_38->field_1C;
12579 v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16;
12580 X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16;
12581 v26 = v5->ptr_38;
12582 X = v18;
12583 v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24;
12584 X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16;
12585 v28 = v5->ptr_38;
12586 v29 = v5->pTexture;
12587 v44 = bUseLoResSprites + v49 + 2;
12588 v30 = v27 >> v44;
12589 v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44;
12590 v32 = (signed int)v29->uTextureWidth >> v49;
12591 v33 = (signed int)v29->uTextureHeight >> v49;
12592 v34 = v49 - v29->uWidthLn2;
12593 a1a.field_8 = (v33 << 16) - 65536;
12594 X = 2 * pMiscTimer->uTotalGameTimeElapsed;
12595 v45 = pOutdoorCamera->int_fov_rad_inv;
12596 a1a.field_10 = v34 + 16;
12597 a1a.field_C = v32 - 1;
12598 i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16;
12599 v47 = (Span *)(i >> v44);
12600 v35 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
12601 v36 = (signed int)v47 * (signed __int64)v35;
12602 i = v36 >> 16;
12603 a1a.field_4 = v36 >> 16;
12604 v37 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
12605 v38 = (signed int)v47 * (signed __int64)v37;
12606 i = v38 >> 16;
12607 a1a.field_0 = v38 >> 16;
12608 if ( (signed int)v43 > 0 )
12609 {
12610 v47 = v43;
12611 v39 = 12 - v49;
12612 for ( i = 12 - v49; ; v39 = i )
12613 {
12614 a1a.field_30 = v30 + 4 * stru_5C6E00->SinCos(X + (v31 >> v39));
12615 a1a.field_2C = v31 + 4 * stru_5C6E00->SinCos(X + (v30 >> i) - stru_5C6E00->uIntegerHalfPi);
12616 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12617 sr_sub_485975(&a1a, (stru315 *)&a2);
12618 else
12619 sr_sub_4D6FB0(v1);
12620 a1a.field_28 = 16;
12621 v30 += 16 * a1a.field_4;
12622 v31 += 16 * a1a.field_0;
12623 v47 = (Span *)((char *)v47 - 1);
12624 if ( !v47 )
12625 break;
12626 }
12627 }
12628 if ( v48 )
12629 {
12630 i = 12 - v49;
12631 a1a.field_30 = v30 + 4 * stru_5C6E00->SinCos(X + (v31 >> (12 - v49)));
12632 a1a.field_2C = v31 + 4 * stru_5C6E00->SinCos(X + (v30 >> i) - stru_5C6E00->uIntegerHalfPi);
12633 a1a.field_28 = v48;
12634 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
12635 sr_sub_485975(&a1a, (stru315 *)&a2);
12636 else
12637 sr_sub_4D6FB0(v1);
12638 }
12639 return 1;
12640 }
12641
12642
12643 //----- (0048585C) --------------------------------------------------------
12644 signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4)
12645 {
12646 Span *v3; // esi@1
12647 stru148 *v4; // edi@1
12648 int v5; // ebx@2
12649 signed __int64 v6; // qtt@3
12650 int v7; // ebx@3
12651 signed int v8; // ecx@3
12652 void *v9; // eax@5
12653 int v10; // ecx@5
12654 unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1
12655 signed int v13; // [sp+10h] [bp-10h]@1
12656 int X; // [sp+18h] [bp-8h]@1
12657
12658 v3 = a1;
12659 pPixels = pRenderTarget;
12660 v4 = a1->pParent;
12661 v13 = -v4->field_24;
12662 X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv
12663 * (pViewport->uScreenCenterX - (signed int)a1->field_8)
12664 * (signed __int64)v4->v_18.y) >> 16)
12665 + ((unsigned __int64)(v4->v_18.z
12666 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv
12667 * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16)
12668 + v4->v_18.x;
12669 if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) )
12670 {
12671 LODWORD(v6) = v13 << 16;
12672 HIDWORD(v6) = v13 >> 16;
12673 v7 = v6 / X;
12674 v8 = v6 / X;
12675 }
12676 else
12677 {
12678 v7 = pOutdoorCamera->shading_dist_mist << 16;
12679 v8 = pOutdoorCamera->shading_dist_mist << 16;
12680 }
12681 v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4);
12682 fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C);
12683 HIWORD(v10) = HIWORD(v7);
12684 LOWORD(v10) = 0;
12685 j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C);
12686 return 1;
12687 }
12688
12689 //----- (00485975) --------------------------------------------------------
12690 stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2)
12691 {
12692 stru315 *result; // eax@1
12693 int i; // ecx@1
12694 int v4; // esi@2
12695 int v5; // esi@2
12696 int v6; // ecx@2
12697 int v7; // esi@3
12698 int v8; // edi@3
12699 int v9; // ebx@3
12700 int v10; // ecx@8
12701 unsigned __int16 *v11; // esi@10
12702 unsigned int *v12; // ecx@12
12703 int v13; // esi@12
12704 int v14; // [sp+0h] [bp-4h]@2
12705
12706 result = a1;
12707 for ( i = a1->field_28; i; i = result->field_28 )
12708 {
12709 v4 = result->field_8 & result->field_2C;
12710 result->field_28 = i - 1;
12711 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
12712 v6 = *((char *)result->pTextureLOD + v5);
12713 v14 = *((char *)result->pTextureLOD + v5);
12714 if ( a2->field_20 )
12715 {
12716 v7 = HIWORD(a2->field_10);
12717 v8 = a2->field_C;
12718 v9 = v7;
12719 if ( v7 >= v8 )
12720 v9 = a2->field_C;
12721 if ( a2->field_8 - v9 <= 0 )
12722 {
12723 v10 = 0;
12724 }
12725 else
12726 {
12727 if ( v7 >= v8 )
12728 v7 = a2->field_C;
12729 v10 = a2->field_8 - v7;
12730 }
12731 v11 = (unsigned __int16 *)a2->field_24;
12732 v6 = v14 + (v10 << 8);
12733 }
12734 else
12735 {
12736 v11 = result->field_34_palette;
12737 }
12738 *result->pColorBuffer = v11[v6];
12739 v12 = result->pDepthBuffer;
12740 v13 = result->field_24;
12741 ++result->pColorBuffer;
12742 *v12 = v13;
12743 ++result->pDepthBuffer;
12744 a2->field_10 += a2->field_18;
12745 result->field_30 += result->field_4;
12746 result->field_2C += result->field_0;
12747 }
12748 --result->field_28;
12749 return result;
12750 }
12751
12752 //----- (00485A24) --------------------------------------------------------
12753 stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2)
12754 {
12755 stru315 *result; // eax@1
12756 int i; // ecx@1
12757 int v4; // ecx@2
12758 int v5; // ecx@4
12759 int v6; // ecx@6
12760 int v7; // ecx@8
12761 int v8; // esi@10
12762 int v9; // ecx@10
12763 int v10; // esi@11
12764 int v11; // edi@11
12765 int v12; // ebx@11
12766 int v13; // ecx@16
12767 unsigned __int16 *v14; // esi@18
12768 unsigned int *v15; // ecx@20
12769 int v16; // esi@20
12770 int v17; // [sp+0h] [bp-4h]@10
12771
12772 result = a1;
12773 for ( i = a1->field_28; i; i = result->field_28 )
12774 {
12775 result->field_28 = i - 1;
12776 v4 = result->field_18;
12777 if ( result->field_30 > v4 )
12778 result->field_30 = v4;
12779 v5 = result->field_20;
12780 if ( result->field_2C > v5 )
12781 result->field_2C = v5;
12782 v6 = result->field_14;
12783 if ( result->field_30 < v6 )
12784 result->field_30 = v6;
12785 v7 = result->field_1C;
12786 if ( result->field_2C < v7 )
12787 result->field_2C = v7;
12788 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
12789 v9 = *((char *)result->pTextureLOD + v8);
12790 v17 = *((char *)result->pTextureLOD + v8);
12791 if ( a2->field_20 )
12792 {
12793 v10 = HIWORD(a2->field_10);
12794 v11 = a2->field_C;
12795 v12 = v10;
12796 if ( v10 >= v11 )
12797 v12 = a2->field_C;
12798 if ( a2->field_8 - v12 <= 0 )
12799 {
12800 v13 = 0;
12801 }
12802 else
12803 {
12804 if ( v10 >= v11 )
12805 v10 = a2->field_C;
12806 v13 = a2->field_8 - v10;
12807 }
12808 v14 = (unsigned __int16 *)a2->field_24;
12809 v9 = v17 + (v13 << 8);
12810 }
12811 else
12812 {
12813 v14 = result->field_34_palette;
12814 }
12815 *result->pColorBuffer = v14[v9];
12816 v15 = result->pDepthBuffer;
12817 v16 = result->field_24;
12818 ++result->pColorBuffer;
12819 *v15 = v16;
12820 ++result->pDepthBuffer;
12821 a2->field_10 += a2->field_18;
12822 result->field_30 += result->field_4;
12823 result->field_2C += result->field_0;
12824 }
12825 --result->field_28;
12826 return result;
12827 }
12828
12829 //----- (00485AFF) --------------------------------------------------------
12830 stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2)
12831 {
12832 stru315 *result; // eax@1
12833 int i; // ecx@1
12834 int v4; // esi@2
12835 int v5; // esi@2
12836 int v6; // ecx@2
12837 int v7; // esi@3
12838 int v8; // edi@3
12839 int v9; // ebx@3
12840 int v10; // ecx@8
12841 unsigned __int16 *v11; // esi@10
12842 unsigned int *v12; // ecx@12
12843 int v13; // esi@12
12844 int v14; // [sp+0h] [bp-4h]@2
12845
12846 result = a1;
12847 for ( i = a1->field_28; i; i = result->field_28 )
12848 {
12849 v4 = result->field_8 & result->field_2C;
12850 result->field_28 = i - 1;
12851 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
12852 v6 = *((char *)result->pTextureLOD + v5);
12853 v14 = *((char *)result->pTextureLOD + v5);
12854 if ( a2->field_20 )
12855 {
12856 v7 = HIWORD(a2->field_14);
12857 v8 = a2->field_C;
12858 v9 = v7;
12859 if ( v7 >= v8 )
12860 v9 = a2->field_C;
12861 if ( a2->field_8 - v9 <= 0 )
12862 {
12863 v10 = 0;
12864 }
12865 else
12866 {
12867 if ( v7 >= v8 )
12868 v7 = a2->field_C;
12869 v10 = a2->field_8 - v7;
12870 }
12871 v11 = a2->field_24_palette;
12872 v6 = v14 + (v10 << 8);
12873 }
12874 else
12875 {
12876 v11 = result->field_34_palette;
12877 }
12878 *result->pColorBuffer = v11[v6];
12879 v12 = result->pDepthBuffer;
12880 v13 = result->field_24;
12881 --result->pColorBuffer;
12882 *v12 = v13;
12883 --result->pDepthBuffer;
12884 a2->field_14 -= a2->field_18;
12885 result->field_30 += result->field_4;
12886 result->field_2C += result->field_0;
12887 }
12888 --result->field_28;
12889 return result;
12890 }
12891
12892 //----- (00485BAE) --------------------------------------------------------
12893 stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2)
12894 {
12895 stru315 *result; // eax@1
12896 int i; // ecx@1
12897 int v4; // ecx@2
12898 int v5; // ecx@4
12899 int v6; // ecx@6
12900 int v7; // ecx@8
12901 int v8; // esi@10
12902 int v9; // ecx@10
12903 int v10; // esi@11
12904 int v11; // edi@11
12905 int v12; // ebx@11
12906 int v13; // ecx@16
12907 unsigned __int16 *v14; // esi@18
12908 unsigned int *v15; // ecx@20
12909 int v16; // esi@20
12910 int v17; // [sp+0h] [bp-4h]@10
12911
12912 result = a1;
12913 for ( i = a1->field_28; i; i = result->field_28 )
12914 {
12915 result->field_28 = i - 1;
12916 v4 = result->field_18;
12917 if ( result->field_30 > v4 )
12918 result->field_30 = v4;
12919 v5 = result->field_20;
12920 if ( result->field_2C > v5 )
12921 result->field_2C = v5;
12922 v6 = result->field_14;
12923 if ( result->field_30 < v6 )
12924 result->field_30 = v6;
12925 v7 = result->field_1C;
12926 if ( result->field_2C < v7 )
12927 result->field_2C = v7;
12928 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
12929 v9 = *((char *)result->pTextureLOD + v8);
12930 v17 = *((char *)result->pTextureLOD + v8);
12931 if ( a2->field_20 )
12932 {
12933 v10 = HIWORD(a2->field_14);
12934 v11 = a2->field_C;
12935 v12 = v10;
12936 if ( v10 >= v11 )
12937 v12 = a2->field_C;
12938 if ( a2->field_8 - v12 <= 0 )
12939 {
12940 v13 = 0;
12941 }
12942 else
12943 {
12944 if ( v10 >= v11 )
12945 v10 = a2->field_C;
12946 v13 = a2->field_8 - v10;
12947 }
12948 v14 = a2->field_24_palette;
12949 v9 = v17 + (v13 << 8);
12950 }
12951 else
12952 {
12953 v14 = result->field_34_palette;
12954 }
12955 *result->pColorBuffer = v14[v9];
12956 v15 = result->pDepthBuffer;
12957 v16 = result->field_24;
12958 --result->pColorBuffer;
12959 *v15 = v16;
12960 --result->pDepthBuffer;
12961 a2->field_14 -= a2->field_18;
12962 result->field_30 += result->field_4;
12963 result->field_2C += result->field_0;
12964 }
12965 --result->field_28;
12966 return result;
12967 }
12968
12969 //----- (00485C89) --------------------------------------------------------
12970 stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2)
12971 {
12972 stru315 *result; // eax@1
12973 int i; // ecx@1
12974 int v4; // esi@2
12975 int v5; // esi@2
12976 int v6; // ecx@2
12977 int v7; // esi@4
12978 int v8; // edi@4
12979 int v9; // ecx@9
12980 unsigned __int16 *v10; // esi@11
12981 unsigned int *v11; // ecx@14
12982 int v12; // esi@14
12983 int v13; // [sp+0h] [bp-4h]@2
12984
12985 result = a1;
12986 for ( i = a1->field_28; i; i = result->field_28 )
12987 {
12988 v4 = result->field_8 & result->field_2C;
12989 result->field_28 = i - 1;
12990 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
12991 v6 = *((char *)result->pTextureLOD + v5);
12992 v13 = *((char *)result->pTextureLOD + v5);
12993 if ( *((char *)result->pTextureLOD + v5) )
12994 {
12995 if ( a2->field_20 )
12996 {
12997 v7 = HIWORD(a2->field_10);
12998 v8 = v7;
12999 if ( v7 >= a2->field_C )
13000 v8 = a2->field_C;
13001 if ( a2->field_8 - v8 <= 0 )
13002 {
13003 v9 = 0;
13004 }
13005 else
13006 {
13007 if ( v7 >= a2->field_C )
13008 v7 = a2->field_C;
13009 v9 = a2->field_8 - v7;
13010 }
13011 v10 = a2->field_24_palette;
13012 v6 = v13 + (v9 << 8);
13013 }
13014 else
13015 {
13016 v10 = result->field_34_palette;
13017 }
13018 *result->pColorBuffer = v10[v6];
13019 }
13020 v11 = result->pDepthBuffer;
13021 v12 = result->field_24;
13022 ++result->pColorBuffer;
13023 *v11 = v12;
13024 ++result->pDepthBuffer;
13025 a2->field_10 += a2->field_18;
13026 result->field_30 += result->field_4;
13027 result->field_2C += result->field_0;
13028 }
13029 --result->field_28;
13030 return result;
13031 }
13032
13033 //----- (00485D3E) --------------------------------------------------------
13034 stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2)
13035 {
13036 stru315 *result; // eax@1
13037 int i; // ecx@1
13038 int v4; // ecx@2
13039 int v5; // ecx@4
13040 int v6; // ecx@6
13041 int v7; // ecx@8
13042 int v8; // esi@10
13043 int v9; // ecx@10
13044 int v10; // esi@12
13045 int v11; // edi@12
13046 int v12; // ecx@17
13047 unsigned __int16 *v13; // esi@19
13048 unsigned int *v14; // ecx@22
13049 int v15; // esi@22
13050 int v16; // [sp+0h] [bp-4h]@10
13051
13052 result = a1;
13053 for ( i = a1->field_28; i; i = result->field_28 )
13054 {
13055 result->field_28 = i - 1;
13056 v4 = result->field_18;
13057 if ( result->field_30 > v4 )
13058 result->field_30 = v4;
13059 v5 = result->field_20;
13060 if ( result->field_2C > v5 )
13061 result->field_2C = v5;
13062 v6 = result->field_14;
13063 if ( result->field_30 < v6 )
13064 result->field_30 = v6;
13065 v7 = result->field_1C;
13066 if ( result->field_2C < v7 )
13067 result->field_2C = v7;
13068 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
13069 v9 = *((char *)result->pTextureLOD + v8);
13070 v16 = *((char *)result->pTextureLOD + v8);
13071 if ( *((char *)result->pTextureLOD + v8) )
13072 {
13073 if ( a2->field_20 )
13074 {
13075 v10 = HIWORD(a2->field_10);
13076 v11 = v10;
13077 if ( v10 >= a2->field_C )
13078 v11 = a2->field_C;
13079 if ( a2->field_8 - v11 <= 0 )
13080 {
13081 v12 = 0;
13082 }
13083 else
13084 {
13085 if ( v10 >= a2->field_C )
13086 v10 = a2->field_C;
13087 v12 = a2->field_8 - v10;
13088 }
13089 v13 = a2->field_24_palette;
13090 v9 = v16 + (v12 << 8);
13091 }
13092 else
13093 {
13094 v13 = result->field_34_palette;
13095 }
13096 *result->pColorBuffer = v13[v9];
13097 }
13098 v14 = result->pDepthBuffer;
13099 v15 = result->field_24;
13100 ++result->pColorBuffer;
13101 *v14 = v15;
13102 ++result->pDepthBuffer;
13103 a2->field_10 += a2->field_18;
13104 result->field_30 += result->field_4;
13105 result->field_2C += result->field_0;
13106 }
13107 --result->field_28;
13108 return result;
13109 }
13110
13111 //----- (00485E1F) --------------------------------------------------------
13112 void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, stru148 *a4, int a5, unsigned __int8 a6, char a7)
13113 {
13114 stru316 *v7; // esi@1
13115 signed int *v8; // edi@1
13116 signed int *v9; // ebx@1
13117 char v10; // zf@1
13118 int v11; // eax@1
13119 Span *v12; // ecx@3
13120 double v13; // ST24_8@3
13121 double v14; // ST24_8@3
13122 int v15; // eax@3
13123 signed int v16; // ST14_4@4
13124 char v17; // dl@4
13125 signed int v18; // ST10_4@4
13126 void *v19; // eax@4
13127 signed int v20; // ST14_4@5
13128 char v21; // dl@5
13129 int v22; // ST10_4@5
13130 signed int v23; // ST14_4@6
13131 char v24; // dl@6
13132 Span *v26; // [sp+10h] [bp-8h]@1
13133 char v27; // [sp+16h] [bp-2h]@1
13134 char v28; // [sp+17h] [bp-1h]@1
13135 float v29; // [sp+30h] [bp+18h]@3
13136 float v30; // [sp+30h] [bp+18h]@3
13137
13138 v7 = a1;
13139 v26 = a2;
13140 v8 = &a1->field_C;
13141 v9 = &a1->field_8;
13142 v10 = a1->field_0 == 0;
13143 v27 = a1->field_4 != 0;
13144 v28 = !v10;
13145 sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28);
13146 v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8);
13147 v11 = a4->field_108;
13148 v7->field_20 = v11;
13149 if ( v11 )
13150 {
13151 if ( a7 )
13152 {
13153 v12 = v26;
13154 v29 = v26->field_10 * 31.0;
13155 v13 = v29 + 6.7553994e15;
13156 v7->field_10 = LODWORD(v13) << 16;
13157 v30 = v12->field_14 * 31.0;
13158 v14 = v30 + 6.7553994e15;
13159 v15 = v7->field_10;
13160 v7->field_14 = LODWORD(v14) << 16;
13161 v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C);
13162 }
13163 v16 = *v8;
13164 v17 = v28;
13165 v18 = *v9;
13166 v7->field_1C = a6;
13167 v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16);
13168 }
13169 else
13170 {
13171 v20 = *v8;
13172 v21 = v28;
13173 v7->field_10 = 0;
13174 v7->field_14 = 0;
13175 v22 = *v9;
13176 v7->field_18 = 0;
13177 v7->field_1C = 0;
13178 v19 = sr_sub_47C1CA(a4, v21, v22, v20);
13179 }
13180 v23 = *v8;
13181 v24 = v28;
13182 v7->field_24_palette = (unsigned __int16 *)v19;
13183 return sr_sub_47C1CA(a4, v24, *v9, v23);
13184 }
13185
13186 //----- (00485F53) --------------------------------------------------------
13187 void __thiscall sub_485F53(Vec2_int_ *v)
13188 {
13189 ++v->y;
13190 if ( v->y > 1000 )
13191 v->y = 0;
13192 }
13193
13194
13195
13196 //----- (00485F64) --------------------------------------------------------
13197 void OutdoorCamera::_485F64()
13198 {
13199 int v1; // eax@1
13200 int v2; // eax@2
13201 signed __int64 v3; // qtt@4
13202 int v4; // eax@4
13203
13204 this->uCameraFovInDegrees = 75;
13205 v1 = stru_5C6E00->uPiMask & 0xD5;
13206 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
13207 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
13208 else
13209 v2 = stru_5C6E00->pTanTable[v1];
13210 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
13211 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
13212 v4 = (signed int)(v3 / v2) >> 16;
13213 this->int_fov_rad = v4;
13214 this->field_4C = 360000;
13215 this->int_fov_rad_inv = 65536 / v4;
13216 this->field_50 = 115;
13217 unnamed_6BE060[1] = 1;
13218 RotationToInts();
13219 }
13220
13221 //----- (0048600E) --------------------------------------------------------
13222 void OutdoorCamera::RotationToInts()
13223 {
13224 camera_rotation_y_int_sine = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
13225 camera_rotation_y_int_cosine = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
13226 camera_rotation_x_int_sine = stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi);
13227 camera_rotation_x_int_cosine = stru_5C6E00->SinCos(pIndoorCamera->sRotationX);
13228 }
13229
13230
13231 //----- (0048607B) --------------------------------------------------------
13232 void stru148::_48607B(stru149 *a2)
13233 {
13234 this->pTexture = 0;
13235 this->ptr_38 = a2;
13236 }
13237
13238 //----- (00486089) --------------------------------------------------------
13239 void stru148::_486089_normalize_v_18()
13240 {
13241 stru148 *v1; // esi@1
13242 double v2; // st7@1
13243 double v3; // st6@1
13244 float v4; // ST18_4@2
13245 double v5; // st5@1
13246 float v6; // ST14_4@2
13247 double v7; // st7@1
13248 float v8; // ST24_4@2
13249 float v9; // ST20_4@2
13250 double v10; // ST0C_8@2
13251 float v11; // ST18_4@2
13252 double v12; // ST0C_8@2
13253 float v13; // ST14_4@2
13254 double v14; // ST0C_8@2
13255 float v15; // [sp+20h] [bp-8h]@1
13256
13257 v1 = this;
13258 v2 = (double)this->v_18.x;
13259 v15 = v2;
13260 v3 = (double)this->v_18.y;
13261 v5 = (double)this->v_18.z;
13262 v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2);
13263 if ( v7 == 0.0 )
13264 {
13265 v1->v_18.x = 0;
13266 v1->v_18.y = 0;
13267 v1->v_18.z = 65536;
13268 }
13269 else
13270 {
13271 v8 = 1.0 / v7;
13272 v9 = v8 * v15 * 65536.0;
13273 v10 = v9 + 6.7553994e15;
13274 v1->v_18.x = LODWORD(v10);
13275 v4 = v3;
13276 v11 = v8 * v4 * 65536.0;
13277 v12 = v11 + 6.7553994e15;
13278 v1->v_18.y = LODWORD(v12);
13279 v6 = v5;
13280 v13 = v8 * v6 * 65536.0;
13281 v14 = v13 + 6.7553994e15;
13282 v1->v_18.z = LODWORD(v14);
13283 }
13284 }
13285
13286 //----- (0048616B) --------------------------------------------------------
13287 int stru149::_48616B(int a2, int a3, int a4, int a5, int a6, int a7)
13288 {
13289 int v7; // ebx@1
13290 int v8; // esi@1
13291 int v9; // edi@1
13292 int v10; // eax@1
13293 int v11; // edx@1
13294 int v12; // esi@2
13295 int v13; // eax@2
13296 int v14; // ST10_4@3
13297 int v15; // esi@3
13298 int v16; // eax@5
13299 int v17; // ST0C_4@6
13300 int v18; // eax@8
13301 int v19; // ST0C_4@9
13302 int v20; // eax@10
13303 int v21; // edx@10
13304 int v22; // eax@10
13305 int result; // eax@10
13306 int v24; // [sp+14h] [bp-14h]@1
13307 int v25; // [sp+18h] [bp-10h]@1
13308 int v26; // [sp+1Ch] [bp-Ch]@1
13309 int v27; // [sp+24h] [bp-4h]@1
13310 int v28; // [sp+30h] [bp+8h]@10
13311 int v29; // [sp+3Ch] [bp+14h]@10
13312
13313 v25 = pOutdoorCamera->camera_rotation_x_int_cosine;
13314 v7 = pOutdoorCamera->camera_rotation_y_int_sine;
13315 v27 = pOutdoorCamera->camera_rotation_x_int_sine;
13316 v8 = -pIndoorCamera->pos.y;
13317 v9 = pOutdoorCamera->camera_rotation_y_int_cosine;
13318 v26 = -pIndoorCamera->pos.z;
13319 v24 = -pIndoorCamera->pos.x;
13320 v10 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.x;
13321 v11 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
13322 if ( pIndoorCamera->sRotationX )
13323 {
13324 v14 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
13325 v15 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
13326 this->field_0 = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
13327 + ((unsigned __int64)(-65536
13328 * pIndoorCamera->pos.z
13329 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16);
13330 this->field_4 = v15;
13331 v12 = v25;
13332 v13 = ((unsigned __int64)((v26 << 16) * (signed __int64)v25) >> 16)
13333 - ((unsigned __int64)(v14 * (signed __int64)v27) >> 16);
13334 }
13335 else
13336 {
13337 this->field_4 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
13338 v12 = v25;
13339 this->field_0 = v11;
13340 v13 = v26 << 16;
13341 }
13342 this->field_8 = v13;
13343 if ( pIndoorCamera->sRotationX )
13344 {
13345 v17 = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
13346 this->field_C = ((unsigned __int64)(v17 * (signed __int64)v12) >> 16)
13347 + ((unsigned __int64)(a4 * (signed __int64)v27) >> 16);
13348 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
13349 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
13350 v16 = ((unsigned __int64)(a4 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v17 * (signed __int64)v27) >> 16);
13351 }
13352 else
13353 {
13354 this->field_C = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16)
13355 + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
13356 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
13357 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
13358 v16 = a4;
13359 }
13360 this->field_14 = v16;
13361 if ( pIndoorCamera->sRotationX )
13362 {
13363 v19 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
13364 this->field_18 = ((unsigned __int64)(v19 * (signed __int64)v12) >> 16)
13365 + ((unsigned __int64)(a7 * (signed __int64)v27) >> 16);
13366 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
13367 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
13368 v18 = ((unsigned __int64)(a7 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v27) >> 16);
13369 }
13370 else
13371 {
13372 this->field_18 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16)
13373 + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
13374 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
13375 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
13376 v18 = a7;
13377 }
13378 this->field_18 = -this->field_18;
13379 this->field_1C = -this->field_1C;
13380 this->field_20 = v18;
13381 v20 = this->field_C;
13382 this->field_20 = -this->field_20;
13383 v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0) >> 16)
13384 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
13385 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
13386 v28 = this->field_18;
13387 v22 = this->field_0;
13388 this->field_24 = v21;
13389 v29 = (unsigned __int64)(v28 * (signed __int64)v22) >> 16;
13390 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
13391 this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
13392 return result;
13393 }
13394
13395 //----- (0048653D) --------------------------------------------------------
13396 int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)
13397 {
13398 stru149 *v7; // esi@1
13399 int v8; // edi@1
13400 int v9; // eax@1
13401 int v10; // edx@1
13402 int v11; // ecx@1
13403 int v12; // eax@1
13404 int v13; // ebx@2
13405 int v14; // ecx@2
13406 int v15; // eax@2
13407 int v16; // ST14_4@3
13408 int v17; // ST10_4@3
13409 int v18; // eax@5
13410 int v19; // ST10_4@6
13411 int v20; // eax@8
13412 int v21; // ST10_4@9
13413 int v22; // eax@10
13414 int v23; // ecx@10
13415 int v24; // eax@10
13416 int result; // eax@10
13417 int v26; // [sp+14h] [bp-14h]@1
13418 int v27; // [sp+18h] [bp-10h]@1
13419 int v28; // [sp+1Ch] [bp-Ch]@1
13420 int v29; // [sp+24h] [bp-4h]@1
13421 int v30; // [sp+30h] [bp+8h]@10
13422 int v31; // [sp+3Ch] [bp+14h]@10
13423
13424 v7 = this;
13425 v8 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotY);
13426 v29 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotY - stru_5C6E00->uIntegerHalfPi);
13427 v28 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX);
13428 v9 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX - stru_5C6E00->uIntegerHalfPi);
13429 v11 = -pBLVRenderParams->vPartyPos.y;
13430 v26 = -pBLVRenderParams->vPartyPos.x;
13431 v27 = v9;
13432 v12 = -pBLVRenderParams->vPartyPos.z;
13433 if ( pBLVRenderParams->sPartyRotX )
13434 {
13435 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
13436 v13 = v28;
13437 v17 = -65536 * pBLVRenderParams->vPartyPos.z;
13438 v7->field_0 = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
13439 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16);
13440 v7->field_4 = v8 * v11 - v29 * v26;
13441 v14 = v27;
13442 v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16);
13443 }
13444 else
13445 {
13446 v7->field_0 = v10 + v29 * -pBLVRenderParams->vPartyPos.y;
13447 v13 = v28;
13448 v7->field_4 = v8 * v11 - v29 * v26;
13449 v14 = v27;
13450 v15 = v12 << 16;
13451 }
13452 v7->field_8 = v15;
13453 if ( pBLVRenderParams->sPartyRotX )
13454 {
13455 v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
13456 v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16)
13457 + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16);
13458 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
13459 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
13460 v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16);
13461 }
13462 else
13463 {
13464 v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16)
13465 + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
13466 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
13467 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
13468 v18 = a4;
13469 }
13470 v7->field_14 = v18;
13471 if ( pBLVRenderParams->sPartyRotX )
13472 {
13473 v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
13474 v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16)
13475 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16);
13476 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
13477 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
13478 v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16);
13479 }
13480 else
13481 {
13482 v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16)
13483 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
13484 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
13485 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
13486 v20 = a7;
13487 }
13488 v7->field_18 = -v7->field_18;
13489 v7->field_1C = -v7->field_1C;
13490 v7->field_20 = v20;
13491 v22 = v7->field_C;
13492 v7->field_20 = -v7->field_20;
13493 v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0) >> 16)
13494 + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4) >> 16)
13495 + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16);
13496 v30 = v7->field_18;
13497 v24 = v7->field_0;
13498 v7->field_24 = v23;
13499 v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16;
13500 result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4) >> 16;
13501 v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16);
13502 return result;
13503 }
13504
13505 //----- (0048694B) --------------------------------------------------------
13506 int stru149::_48694B()
13507 {
13508 int v1; // eax@1
13509 int v2; // ST04_4@1
13510 int v3; // ST00_4@1
13511 int v4; // eax@1
13512 int v5; // ST0C_4@1
13513 int result; // eax@1
13514
13515 v1 = this->field_C;
13516 this->field_18 = -this->field_18;
13517 this->field_1C = -this->field_1C;
13518 this->field_20 = -this->field_20;
13519 v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0) >> 16;
13520 v3 = this->field_18;
13521 v4 = this->field_0;
13522 this->field_24 = v2
13523 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
13524 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
13525 v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
13526 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
13527 this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
13528 return result;
13529 }
13530
13531
13532 //----- (00486A28) --------------------------------------------------------
13533 void OutdoorCamera::AllocSoftwareDrawBuffers()
13534 {
13535 if ( !this || !pSpans )
13536 {
13537 ReleaseSoftwareDrawBuffers();
13538 pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
13539 pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
13540 pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
13541 pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
13542 memset(pSpans, 0, 0x493E0u);
13543 memset(pEdges, 0, 0x4C2C0u);
13544 memset(pSurfs, 0, 0x11940u);
13545 memset(pNewEdges, 0, 0x6180u);
13546 }
13547 }
13548
13549 //----- (00486AFC) --------------------------------------------------------
13550 void OutdoorCamera::ReleaseSoftwareDrawBuffers()
13551 {
13552 pAllocator->FreeChunk(pSpans);
13553 pAllocator->FreeChunk(pEdges);
13554 pAllocator->FreeChunk(pSurfs);
13555 pAllocator->FreeChunk(pNewEdges);
13556 pSpans = 0;
13557 pEdges = 0;
13558 pSurfs = 0;
13559 pNewEdges = 0;
13560 }
13561
13562 //----- (00486B4E) --------------------------------------------------------
13563 char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)
13564 {
13565 stru148 *v4; // esi@1
13566 RenderVertexSoft *v5; // edi@1
13567 char v6; // zf@1
13568 unsigned int v7; // eax@3
13569 int v8; // ebx@3
13570 int *v9; // ecx@7
13571 int v10; // ebx@8
13572 int v11; // eax@10
13573 double v12; // st7@14
13574 int *v13; // edx@14
13575 double v14; // st6@14
13576 double v15; // st7@16
13577 int v16; // edi@16
13578 double v17; // st7@16
13579 double v18; // st7@16
13580 int v19; // edi@18
13581 double v20; // st7@18
13582 double v21; // st7@18
13583 Edge *i; // edx@20
13584 double v23; // st7@28
13585 Edge *v24; // eax@28
13586 std::string v26; // [sp-18h] [bp-98h]@2
13587 const char *v27; // [sp-8h] [bp-88h]@2
13588 int v28; // [sp-4h] [bp-84h]@2
13589 double v29; // [sp+Ch] [bp-74h]@28
13590 double v30; // [sp+14h] [bp-6Ch]@28
13591 double v31; // [sp+1Ch] [bp-64h]@20
13592 double v32; // [sp+24h] [bp-5Ch]@16
13593 double v33; // [sp+2Ch] [bp-54h]@14
13594 unsigned int v34; // [sp+34h] [bp-4Ch]@2
13595 unsigned __int64 v35; // [sp+38h] [bp-48h]@28
13596 int v36; // [sp+40h] [bp-40h]@28
13597 int v37; // [sp+44h] [bp-3Ch]@20
13598 float v38; // [sp+48h] [bp-38h]@18
13599 int v39; // [sp+4Ch] [bp-34h]@16
13600 int v40; // [sp+50h] [bp-30h]@14
13601 int v41; // [sp+54h] [bp-2Ch]@3
13602 RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1
13603 int v43; // [sp+5Ch] [bp-24h]@14
13604 int v44; // [sp+60h] [bp-20h]@6
13605 int v45; // [sp+64h] [bp-1Ch]@6
13606 unsigned int v46; // [sp+68h] [bp-18h]@7
13607 int *v47; // [sp+6Ch] [bp-14h]@1
13608 int v48; // [sp+70h] [bp-10h]@7
13609 float *v49; // [sp+74h] [bp-Ch]@7
13610 float v50; // [sp+78h] [bp-8h]@10
13611 float v51; // [sp+7Ch] [bp-4h]@14
13612
13613 v4 = a4;
13614 v5 = a1;
13615 v47 = a2;
13616 v6 = (HIBYTE(a4->flags) & 0x40) == 0;
13617 v42 = a1;
13618 if ( !v6 )
13619 {
13620 MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0);
13621 }
13622 LOBYTE(v7) = v4->field_108;
13623 v8 = v4->uNumVertices;
13624 v4->field_108 = 0;
13625 BYTE3(a4) = v7;
13626 v41 = v8;
13627 if ( v8 > 0 )
13628 {
13629 if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 )
13630 {
13631 v7 = pOutdoorCamera->uNumEdges;
13632 if ( (signed int)pOutdoorCamera->uNumEdges < 5979 )
13633 {
13634 v4->uEdgeList1Size = 0;
13635 v4->uEdgeList2Size = 0;
13636 v45 = -1;
13637 v34 = v7;
13638 v28 = v8;
13639 v27 = (const char *)v5;
13640 v44 = 10000;
13641 pGame->pLightmapBuilder->_45CB89(v5, v8);
13642 if ( v8 > 0 )
13643 {
13644 v9 = a3;
13645 v48 = 1;
13646 v49 = &v5->flt_2C;
13647 v46 = (char *)v47 - (char *)a3;
13648 do
13649 {
13650 v10 = v48;
13651 ++pOutdoorCamera->uNumEdges;
13652 if ( v48 >= v41 )
13653 v10 = 0;
13654 v11 = *v9;
13655 LODWORD(v50) = *v9;
13656 if ( SLODWORD(v50) > v45 )
13657 v45 = v11;
13658 if ( v11 < v44 )
13659 v44 = v11;
13660 v12 = (double)SLODWORD(v50);
13661 v13 = &a3[v10];
13662 v51 = v12;
13663 v14 = (double)*v13;
13664 v50 = v14;
13665 *(float *)&v40 = v14 - v12;
13666 v33 = *(float *)&v40 + 6.7553994e15;
13667 v43 = LODWORD(v33);
13668 if ( LODWORD(v33) )
13669 {
13670 if ( SLODWORD(v33) >= 0 )
13671 {
13672 v19 = (int)((char *)v9 + v46);
13673 ptr_80C978_Edges->field_8 = 1;
13674 LODWORD(v38) = (int)&v47[v10];
13675 v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19;
13676 v6 = BYTE3(a4) == 0;
13677 v20 = (double)v40;
13678 v40 = *v13 - *v9;
13679 v21 = v20 / (double)v40;
13680 ptr_80C978_Edges->field_4 = v21;
13681 ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19;
13682 if ( !v6 )
13683 {
13684 ptr_80C978_Edges->field_1C = *v49;
13685 ptr_80C978_Edges->field_20 = v42[v10].flt_2C;
13686 ptr_80C978_Edges->field_24 = (double)*(signed int *)v19;
13687 ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38);
13688 ptr_80C978_Edges->field_2C = (double)*v9;
13689 ptr_80C978_Edges->field_30 = (double)*v13;
13690 v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges;
13691 }
13692 }
13693 else
13694 {
13695 v32 = v51 + 6.7553994e15;
13696 v39 = LODWORD(v32);
13697 v51 = v50;
13698 v15 = (double)SLODWORD(v32);
13699 ptr_80C978_Edges->field_8 = 0;
13700 v16 = (int)&v47[v10];
13701 v50 = v15;
13702 v40 = *(int *)((char *)v9 + v46) - *(int *)v16;
13703 v6 = BYTE3(a4) == 0;
13704 v17 = (double)v40;
13705 v40 = *v9 - *v13;
13706 v18 = v17 / (double)v40;
13707 ptr_80C978_Edges->field_4 = v18;
13708 ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16;
13709 if ( !v6 )
13710 {
13711 ptr_80C978_Edges->field_1C = v42[v10].flt_2C;
13712 ptr_80C978_Edges->field_20 = *v49;
13713 ptr_80C978_Edges->field_24 = (double)*(signed int *)v16;
13714 ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46);
13715 ptr_80C978_Edges->field_2C = (double)*v13;
13716 ptr_80C978_Edges->field_30 = (double)*v9;
13717 v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges;
13718 }
13719 }
13720 v31 = v51 + 6.7553994e15;
13721 v37 = LODWORD(v31);
13722 for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext )
13723 ;
13724 if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 )
13725 {
13726 ptr_80C978_Edges->pNext = i->pNext;
13727 i->pNext = ptr_80C978_Edges;
13728 }
13729 else
13730 {
13731 ptr_80C978_Edges->pNext = i;
13732 i->pPrev->pNext = ptr_80C978_Edges;
13733 }
13734 v23 = v50 - 1.0;
13735 *(float *)&v40 = v23;
13736 v38 = v23;
13737 v30 = v38 + 6.7553994e15;
13738 v36 = LODWORD(v30);
13739 ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)];
13740 v29 = *(float *)&v40 + 6.7553994e15;
13741 v35 = __PAIR__(v40, LODWORD(v29));
13742 v24 = ptr_80C978_Edges;
13743 ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges;
13744 v24->pSurf = ptr_80C97C_Surfs;
13745 if ( ptr_80C978_Edges < &pEdges[5999] )
13746 ++ptr_80C978_Edges;
13747 }
13748 ++v48;
13749 v49 += 12;
13750 ++v9;
13751 }
13752 while ( v48 - 1 < v41 );
13753 }
13754 LOBYTE(v7) = v34;
13755 if ( pOutdoorCamera->uNumEdges != v34 )
13756 {
13757 v4->ptr_48 = 0;
13758 ptr_80C97C_Surfs->field_22 = 0;
13759 ptr_80C97C_Surfs->pParent = v4;
13760 ptr_80C97C_Surfs->field_4 = v4->field_4;
13761 ptr_80C97C_Surfs->field_8 = v4->field_8;
13762 ptr_80C97C_Surfs->field_0 = v4->field_0;
13763 ptr_80C97C_Surfs->field_C = v4->field_C;
13764 ptr_80C97C_Surfs->field_10 = v4->field_10;
13765 LOBYTE(v7) = (char)pSurfs + 28;
13766 if ( ptr_80C97C_Surfs < &pSurfs[1999] )
13767 {
13768 ++ptr_80C97C_Surfs;
13769 ++pOutdoorCamera->uNumSurfs;
13770 }
13771 if ( BYTE3(a4) )
13772 v4->field_108 = 1;
13773 }
13774 }
13775 }
13776 }
13777 return v7;
13778 }
13779
13780
13781
13782 //----- (0043F953) --------------------------------------------------------
13783 int __cdecl PrepareWallsRenderList_BLV()
13784 {
13785 pStru170->uNumFaceIDs = 0;
13786 if ( pBLVRenderParams->uRadius )
13787 {
13788 pStru170->field_FA8[0].uSectorID = LOWORD(pBLVRenderParams->uRadius);
13789 pStru170->field_FA8[0].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
13790 pStru170->field_FA8[0].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
13791 pStru170->field_FA8[0].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
13792 pStru170->field_FA8[0].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
13793 pStru170->field_FA8[0].field_C._43F9E1(
13794 SLOWORD(pBLVRenderParams->uViewportX),
13795 SLOWORD(pBLVRenderParams->uViewportY),
13796 SLOWORD(pBLVRenderParams->uViewportZ),
13797 SLOWORD(pBLVRenderParams->uViewportW));
13798 pStru170->field_FA8[0].uFaceID = -1;
13799 pStru170->field_FA8[0].std__vector_0007A8 = -1;
13800 pStru170->std__vector_000FA8 = 1;
13801 sub_440639(0);
13802 }
13803 return pStru170->RenderWalls();
13804 }
13805
13806 //----- (0043F9E1) --------------------------------------------------------
13807 __int16 *stru170_stru2::_43F9E1(__int16 x, int y, __int16 z, int w)
13808 {
13809 signed int v5; // edx@1
13810 __int16 *result; // eax@1
13811
13812 auto a2 = x;
13813 auto a3 = y;
13814 auto a4 = z;
13815 auto a5 = w;
13816
13817 this->_viewport_space_y = a3;
13818 this->field_4 = a5;
13819 v5 = 0;
13820 result = this->array_3D8;
13821 do
13822 {
13823 if ( v5 < a3 || v5 > a5 )
13824 {
13825 *result = -1;
13826 *(result - 480) = 640;
13827 }
13828 else
13829 {
13830 *(result - 480) = a2;
13831 *result = a4;
13832 }
13833 ++v5;
13834 ++result;
13835 }
13836 while ( v5 < 480 );
13837 return result;
13838 }
13839
13840 //----- (0043FA33) --------------------------------------------------------
13841 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID)
13842 {
13843 LevelDecoration *v2; // esi@1
13844 DecorationDesc *v3; // ebx@2
13845 __int16 v4; // ax@2
13846 double v5; // st7@3
13847 int v6; // eax@5
13848 int v7; // edx@5
13849 unsigned int v8; // edi@5
13850 int v9; // edi@5
13851 int v10; // eax@7
13852 SpriteFrame *v11; // eax@7
13853 SpriteFrame *v12; // esi@7
13854 int v13; // eax@7
13855 int v14; // ebx@16
13856 RenderBillboard *v15; // ecx@17
13857 char v16; // zf@18
13858 IndoorCameraD3D **v17; // eax@19
13859 double v18; // st7@19
13860 float v19; // eax@19
13861 signed __int64 v20; // qtt@19
13862 signed __int64 v21; // qtt@20
13863 int v22; // edx@21
13864 int v23; // eax@21
13865 Particle_ local_0; // [sp+Ch] [bp-A0h]@3
13866 double v25; // [sp+74h] [bp-38h]@19
13867 unsigned int v26; // [sp+7Ch] [bp-30h]@1
13868 int a2; // [sp+80h] [bp-2Ch]@5
13869 int a3; // [sp+84h] [bp-28h]@5
13870 int a1; // [sp+88h] [bp-24h]@5
13871 int v30; // [sp+8Ch] [bp-20h]@7
13872 float v31; // [sp+90h] [bp-1Ch]@1
13873 int a5; // [sp+94h] [bp-18h]@17
13874 int z; // [sp+98h] [bp-14h]@15
13875 int a6; // [sp+9Ch] [bp-10h]@17
13876 int y; // [sp+A0h] [bp-Ch]@15
13877 int x; // [sp+A4h] [bp-8h]@15
13878 int v37; // [sp+A8h] [bp-4h]@5
13879
13880 v26 = uDecorationID;
13881 LODWORD(v31) = uSectorID;
13882 v2 = &pLevelDecorations[uDecorationID];
13883 if ( !(v2->field_2 & 0x20) )
13884 {
13885 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID];
13886 v4 = v3->uFlags;
13887 if ( (char)v4 >= 0 )
13888 {
13889 if ( !(v4 & DECORATION_DONT_DRAW) )
13890 {
13891 v6 = v2->vPosition.x;
13892 v7 = v2->vPosition.z;
13893 a2 = v2->vPosition.y;
13894 a1 = v6;
13895 a3 = v7;
13896 v8 = v2->field_10_y_rot
13897 + ((signed int)stru_5C6E00->uIntegerPi >> 3)
13898 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
13899 v37 = pBLVRenderParams->field_0_timer_;
13900 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7;
13901 if ( pParty->bTurnBasedModeOn == 1 )
13902 v37 = pMiscTimer->uTotalGameTimeElapsed;
13903 v10 = abs(v2->vPosition.x + v2->vPosition.y);
13904 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10);
13905 v30 = 0;
13906 v12 = v11;
13907 v13 = v11->uFlags;
13908 if ( v13 & 2 )
13909 v30 = 2;
13910 if ( v13 & 0x40000 )
13911 v30 |= 0x40u;
13912 if ( v13 & 0x20000 )
13913 LOBYTE(v30) = v30 | 0x80;
13914 if ( (256 << v9) & v13 )
13915 v30 |= 4u;
13916 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) )
13917 {
13918 v14 = abs(x);
13919 if ( v14 >= abs(y) )
13920 {
13921 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6);
13922 v15 = &pBillboardRenderList[uNumBillboardsToDraw];
13923 if ( (signed int)uNumBillboardsToDraw < 500 )
13924 {
13925 ++uNumBillboardsToDraw;
13926 ++uNumDecorationsDrawnThisFrame;
13927 v16 = pRenderer->pRenderD3D == 0;
13928 v15->uHwSpriteID = v12->pHwSpriteIDs[v9];
13929 v15->uPalette = v12->uPaletteIndex;
13930 v15->uIndoorSectorID = LOWORD(v31);
13931 if ( v16 )
13932 {
13933 LODWORD(v21) = pBLVRenderParams->field_40 << 16;
13934 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16;
13935 v37 = v21 / x;
13936 LODWORD(v31) = v12->scale;
13937 v37 = v21 / x;
13938 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16;
13939 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16;
13940 }
13941 else
13942 {
13943 v17 = &pGame->pIndoorCameraD3D;
13944 v15->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
13945 v18 = (*v17)->flt_D4;
13946 v19 = v15->flt_8;
13947 v15->flt_C = v18;
13948 v31 = v19;
13949 v25 = v19 + 6.7553994e15;
13950 LODWORD(v20) = 0;
13951 HIDWORD(v20) = SLOWORD(v25);
13952 v37 = v20 / x;
13953 LODWORD(v31) = v12->scale;
13954 v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
13955 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
13956 v31 = v15->flt_C;
13957 v25 = v31 + 6.7553994e15;
13958 LODWORD(v20) = 0;
13959 HIDWORD(v20) = SLOWORD(v25);
13960 v37 = v20 / x;
13961 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16;
13962 }
13963 HIWORD(v22) = HIWORD(x);
13964 v15->field_4 = v37;
13965 v15->field_1E = v30;
13966 v15->field_20 = a1;
13967 v15->field_22 = a2;
13968 v15->field_24 = a3;
13969 v15->field_26 = a5;
13970 v15->field_28 = a6;
13971 v23 = 8 * v26;
13972 LOBYTE(v23) = 8 * v26 | 5;
13973 LOWORD(v22) = 0;
13974 v15->field_2C_prolly_tint = 0;
13975 v15->sZValue = v22 + v23;
13976 v15->pSpriteFrame = v12;
13977 }
13978 }
13979 }
13980 }
13981 }
13982 else
13983 {
13984 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern
13985 v5 = (double)v2->vPosition.x;
13986 local_0.bFree = 1036;
13987 local_0.uDiffuse = 0xFF3C1Eu;
13988 local_0.x = v5;
13989 local_0.y = (double)v2->vPosition.y;
13990 local_0.z = (double)v2->vPosition.z;
13991 local_0.flt_10 = 0.0;
13992 local_0.flt_14 = 0.0;
13993 local_0.flt_18 = 0.0;
13994 local_0.flt_28 = 1.0;
13995 local_0.field_20 = (rand() & 0x80) + 128;
13996 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
13997 pGame->pParticleEngine->AddParticle(&local_0);
13998 }
13999 }
14000 }
14001
14002
14003 //----- (0044028F) --------------------------------------------------------
14004 void __cdecl PrepareItemsRenderList_BLV()
14005 {
14006 char *v0; // edi@2
14007 ObjectDesc *v1; // ebx@4
14008 __int16 v2; // ax@5
14009 RenderBillboard *v3; // esi@12
14010 SpriteFrame *v4; // eax@12
14011 SpriteFrame *v5; // ebx@12
14012 unsigned int v6; // eax@12
14013 int v7; // ecx@12
14014 int v8; // edx@12
14015 int v9; // ecx@12
14016 unsigned __int16 v10; // ax@12
14017 int *v11; // eax@20
14018 char v12; // zf@26
14019 IndoorCameraD3D **v13; // eax@27
14020 double v14; // st7@27
14021 float v15; // eax@27
14022 double v16; // ST30_8@27
14023 signed __int64 v17; // qtt@27
14024 int v18; // ST5C_4@27
14025 signed __int64 v19; // qtt@28
14026 int v20; // ST5C_4@28
14027 int v21; // edx@29
14028 __int16 v22; // ax@29
14029 int v23; // eax@29
14030 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12
14031 ObjectDesc *v25; // [sp+20h] [bp-3Ch]@4
14032 __int16 a5; // [sp+28h] [bp-34h]@12
14033 int a6; // [sp+2Ch] [bp-30h]@12
14034 int a2; // [sp+30h] [bp-2Ch]@12
14035 int a1; // [sp+34h] [bp-28h]@12
14036 int v30; // [sp+38h] [bp-24h]@12
14037 int v31; // [sp+38h] [bp-24h]@27
14038 signed int v32; // [sp+3Ch] [bp-20h]@1
14039 int a3; // [sp+40h] [bp-1Ch]@12
14040 signed __int16 v34; // [sp+44h] [bp-18h]@14
14041 int v35; // [sp+48h] [bp-14h]@25
14042 int v36; // [sp+4Ch] [bp-10h]@25
14043 signed int z; // [sp+50h] [bp-Ch]@24
14044 signed int y; // [sp+54h] [bp-8h]@24
14045 signed int x; // [sp+58h] [bp-4h]@24
14046
14047 v32 = 0;
14048 if ( (signed int)uNumLayingItems > 0 )
14049 {
14050 v0 = (char *)&pLayingItems[0].uSectorID;
14051 do
14052 {
14053 if ( *((short *)v0 - 13) )
14054 {
14055 v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
14056 v25 = v1;
14057 if ( !(v1->uFlags & 1) )
14058 {
14059 if ( ((v2 = *((short *)v0 - 14), v2 < 1000) || v2 >= 10000)
14060 && (v2 < 500 || v2 >= 600)
14061 && (v2 < 811 || v2 >= 815)
14062 || pGame->pStru6Instance->_4A81CA((LayingItem *)(v0 - 28)) )
14063 {
14064 a5 = *(short *)v0;
14065 a1 = *((int *)v0 - 6);
14066 a2 = *((int *)v0 - 5);
14067 a3 = *((int *)v0 - 4);
14068 v3 = &pBillboardRenderList[uNumBillboardsToDraw];
14069 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1));
14070 v5 = v4;
14071 v24 = v4;
14072 v30 = v4->uFlags;
14073 a6 = v4->uGlowRadius * *((short *)v0 + 3);
14074 v6 = stru_5C6E00->Atan2(
14075 *((int *)v0 - 6) - pBLVRenderParams->vPartyPos.x,
14076 *((int *)v0 - 5) - pBLVRenderParams->vPartyPos.y);
14077 LOWORD(v7) = *((short *)v0 - 3);
14078 v8 = v30;
14079 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
14080 v10 = v5->pHwSpriteIDs[v9];
14081 v3->uHwSpriteID = v10;
14082 if ( v30 & 0x20 )
14083 {
14084 v8 = v30;
14085 a3 -= (signed int)((unsigned __int64)(v5->scale
14086 * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1;
14087 }
14088 v34 = 0;
14089 if ( v8 & 2 )
14090 v34 = 2;
14091 if ( v8 & 0x40000 )
14092 v34 |= 0x40u;
14093 if ( v8 & 0x20000 )
14094 LOBYTE(v34) = v34 | 0x80;
14095 v11 = (int *)(256 << v9);
14096 if ( (256 << v9) & v8 )
14097 v34 |= 4u;
14098 if ( a6 )
14099 {
14100 LOBYTE(v11) = byte_4E94D3;
14101 pMobileLightsStack->AddLight(
14102 a1,
14103 a2,
14104 a3,
14105 a5,
14106 a6,
14107 v25->uParticleTrailColorR,
14108 v25->uParticleTrailColorG,
14109 v25->uParticleTrailColorB,
14110 v11);
14111 }
14112 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
14113 a1,
14114 a2,
14115 a3,
14116 &x,
14117 &y,
14118 &z,
14119 1) )
14120 {
14121 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35);
14122 if ( (signed int)uNumBillboardsToDraw >= 500 )
14123 return;
14124 ++uNumBillboardsToDraw;
14125 ++uNumSpritesDrawnThisFrame;
14126 *(v0 - 2) |= 1u;
14127 v12 = pRenderer->pRenderD3D == 0;
14128 v3->uPalette = v24->uPaletteIndex;
14129 v3->uIndoorSectorID = a5;
14130 if ( v12 )
14131 {
14132 LODWORD(v19) = pBLVRenderParams->field_40 << 16;
14133 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16;
14134 v20 = v19 / x;
14135 v3->field_0 = (unsigned __int64)(v24->scale * v19 / x) >> 16;
14136 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;
14137 }
14138 else
14139 {
14140 v13 = &pGame->pIndoorCameraD3D;
14141 v3->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
14142 v14 = (*v13)->flt_D4;
14143 v15 = v3->flt_8;
14144 v3->flt_C = v14;
14145 v16 = v15 + 6.7553994e15;
14146 LODWORD(v17) = 0;
14147 HIDWORD(v17) = SLOWORD(v16);
14148 v18 = v17 / x;
14149 v3->field_0 = (unsigned __int64)(v24->scale * v17 / x) >> 16;
14150 v31 = (unsigned __int64)(v24->scale * (signed __int64)v18) >> 16;
14151 }
14152 HIWORD(v21) = HIWORD(x);
14153 v3->field_4 = v31;
14154 v3->field_1E = v34;
14155 v3->field_20 = a1;
14156 v3->field_22 = a2;
14157 v3->field_24 = a3;
14158 v3->field_26 = v36;
14159 v22 = v35;
14160 v3->field_2C_prolly_tint = 0;
14161 v3->field_28 = v22;
14162 LOWORD(v21) = 0;
14163 v23 = 8 * v32;
14164 LOBYTE(v23) = 8 * v32 | 2;
14165 v3->pSpriteFrame = v24;
14166 v12 = (*(v0 - 2) & 0x20) == 0;
14167 v3->sZValue = v21 + v23;
14168 if ( !v12 )
14169 {
14170 if ( !pRenderer->pRenderD3D )
14171 v3->sZValue = 0;
14172 }
14173 }
14174 }
14175 }
14176 }
14177 ++v32;
14178 v0 += 112;
14179 }
14180 while ( v32 < (signed int)uNumLayingItems );
14181 }
14182 }
14183
14184
14185
14186 //----- (00440639) --------------------------------------------------------
14187 void __fastcall sub_440639(int a1)
14188 {
14189 int v1; // ebx@1
14190 signed int v2; // edi@1
14191 BLVSector *v3; // esi@1
14192
14193 v1 = a1;
14194 v2 = 0;
14195 v3 = &pIndoor->pSectors[pStru170->field_FA8[a1].uSectorID];
14196 if ( pRenderer->pRenderD3D )
14197 {
14198 if ( v3->uNumNonBSPFaces > 0 )
14199 {
14200 do
14201 pStru170->_4B0EA8(v1, v3->pFaceIDs[v2++]);
14202 while ( v2 < v3->uNumNonBSPFaces );
14203 }
14204 }
14205 else
14206 {
14207 if ( v3->uNumNonBSPFaces > 0 )
14208 {
14209 do
14210 pStru170->_4AFB86(v1, v3->pFaceIDs[v2++]);
14211 while ( v2 < v3->uNumNonBSPFaces );
14212 }
14213 }
14214 if ( v3->field_0 & 0x10 )
14215 sub_4406BC(v1, v3->uFirstBSPNode);
14216 }
14217
14218 //----- (004406BC) --------------------------------------------------------
14219 void __fastcall sub_4406BC(int a1, unsigned int uFirstNode)
14220 {
14221 BLVSector *v2; // esi@2
14222 BSPNode *v3; // edi@2
14223 BLVFace *v4; // eax@2
14224 int v5; // ecx@2
14225 __int16 v6; // ax@6
14226 int v7; // ebp@10
14227 int v8; // ebx@10
14228 __int16 v9; // di@18
14229 int v10; // [sp+10h] [bp-Ch]@1
14230 bool v11; // [sp+14h] [bp-8h]@5
14231 stru170_stru0 *v12; // [sp+18h] [bp-4h]@1
14232
14233 v10 = a1;
14234 v12 = &pStru170->field_FA8[a1];
14235 while ( 1 )
14236 {
14237 v2 = &pIndoor->pSectors[v12->uSectorID];
14238 v3 = &pIndoor->pNodes[uFirstNode];
14239 v4 = &pIndoor->pFaces[v2->pFaceIDs[v3->uCoplanarOffset]];
14240 v5 = v4->pFacePlane_old.dist
14241 + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x
14242 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y
14243 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z;
14244 if ( v4->uAttributes & 1 && v4->uSectorID != v12->uSectorID )
14245 v5 = -v5;
14246 v11 = v5 > 0;
14247 if ( v5 <= 0 )
14248 v6 = v3->uFront;
14249 else
14250 v6 = v3->uBack;
14251 if ( v6 != -1 )
14252 sub_4406BC(v10, v6);
14253 v7 = v3->uCoplanarOffset;
14254 v8 = v7 + v3->uCoplanarSize;
14255 if ( pRenderer->pRenderD3D )
14256 {
14257 while ( v7 < v8 )
14258 pStru170->_4B0EA8(v10, v2->pFaceIDs[v7++]);
14259 }
14260 else
14261 {
14262 while ( v7 < v8 )
14263 pStru170->_4AFB86(v10, v2->pFaceIDs[v7++]);
14264 }
14265 v9 = v11 ? v3->uFront : v3->uBack;
14266 if ( v9 == -1 )
14267 break;
14268 uFirstNode = v9;
14269 }
14270 }
14271
14272 //----- (00440DF5) --------------------------------------------------------
14273 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)
14274 {
14275 stru167_wrap *v6; // esi@1
14276 int result; // eax@1
14277
14278 v6 = this;
14279 v6->pElements[v6->uNumElements].field_6 = a2;
14280 this->pElements[this->uNumElements].field_8 = a3;
14281 this->pElements[this->uNumElements].field_A = a4;
14282 v6->pElements[v6->uNumElements].field_C = rand() % 64 + 256;
14283 v6->pElements[v6->uNumElements].field_E = v6->pElements[v6->uNumElements].field_C;
14284 result = 3 * v6->uNumElements;
14285 v6->pElements[v6->uNumElements++].bgr16 = bgr;
14286 if ( v6->uNumElements >= 100 )
14287 v6->uNumElements = 0;
14288 return result;
14289 }
14290
14291 //----- (00440E91) --------------------------------------------------------
14292 void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr)
14293 {
14294 stru167_wrap *v6; // edi@1
14295 int i; // esi@1
14296 int v8; // ST08_4@2
14297 int v9; // ST04_4@2
14298 int v10; // eax@2
14299
14300 v6 = this;
14301 for ( i = 0; i < rand() % 6 + 5; ++i )
14302 {
14303 v8 = z + rand() % 33;
14304 v9 = rand() % 33 + y - 16;
14305 v10 = rand();
14306 Push(v10 % 33 + x - 16, v9, v8, a5, bgr);
14307 }
14308 }
14309
14310 //----- (00440F07) --------------------------------------------------------
14311 void stru167_wrap::_440F07()
14312 {
14313 char *v1; // esi@1
14314 signed int v2; // edi@1
14315
14316 v1 = (char *)&this->pElements[0].field_6;
14317 v2 = 100;
14318 do
14319 {
14320 if ( *((short *)v1 + 3) > 0 )
14321 {
14322 *((short *)v1 + 2) += rand() % 5 + 4;
14323 *(short *)v1 += rand() % 5 - 2;
14324 *((short *)v1 + 1) += rand() % 5 - 2;
14325 *((short *)v1 + 3) -= LOWORD(pEventTimer->uTimeElapsed);
14326 }
14327 v1 += 24;
14328 --v2;
14329 }
14330 while ( v2 );
14331 }
14332
14333 //----- (0044100D) --------------------------------------------------------
14334 bool __cdecl sub_44100D()
14335 {
14336 return uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4
14337 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 7
14338 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 12
14339 && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 14
14340 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 16
14341 && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 18
14342 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 23));
14343 }
14344 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
14345
14346 //----- (00441498) --------------------------------------------------------
14347 void __cdecl GameUI_DrawTorchlightAndWizardEye()
14348 {
14349 unsigned int v0; // eax@15
14350 IconFrame *v1; // eax@15
14351 unsigned int v2; // eax@19
14352 IconFrame *v3; // eax@19
14353
14354 if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
14355 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 1
14356 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 2
14357 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 5
14358 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8
14359 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10
14360 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11
14361 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 12
14362 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15
14363 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 3
14364 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 19 )
14365 {
14366 if ( SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) >= 0
14367 && (SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[16].uExpireTime)) )
14368 {
14369 v0 = pEventTimer->Time();
14370 v1 = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, v0);
14371 pRenderer->DrawTextureTransparent(
14372 pUIAnum_Torchlight->x,
14373 pUIAnum_Torchlight->y,
14374 &pIcons_LOD->pTextures[v1->uTextureID]);
14375 }
14376 if ( SHIDWORD(pParty->pPartyBuffs[19].uExpireTime) >= 0
14377 && (SHIDWORD(pParty->pPartyBuffs[19].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[19].uExpireTime)) )
14378 {
14379 v2 = pEventTimer->Time();
14380 v3 = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, v2);
14381 pRenderer->DrawTextureTransparent(
14382 pUIAnim_WizardEye->x,
14383 pUIAnim_WizardEye->y,
14384 &pIcons_LOD->pTextures[v3->uTextureID]);
14385 }
14386 }
14387 }
14388 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
14389
14390 //----- (0044158F) --------------------------------------------------------
14391 void __cdecl GameUI_DrawCharacterSelectionFrame()
14392 {
14393 if ( uActiveCharacter )
14394 pRenderer->DrawTextureTransparent(
14395 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[uActiveCharacter] - 9,
14396 0x17Cu,
14397 &pIcons_LOD->pTextures[dword_50C98C]);
14398 }
14399 // 4ED746: using guessed type __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[];
14400 // 50C98C: using guessed type int dword_50C98C;
14401
14402 //----- (004415C5) --------------------------------------------------------
14403 void __cdecl Load_isn_spells_21_27()
14404 {
14405 signed int v0; // esi@1
14406 char pContainer[120]; // [sp+8h] [bp-20h]@2
14407
14408 v0 = 0;
14409 do
14410 {
14411 sprintf(pContainer, "isn-%02d", v0 + 1);
14412 pTextureIDs_isns[v0++] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
14413 }
14414 while ( v0 < 14 );
14415 uIconIdx_Spell21 = pIconsFrameTable->FindIcon("spell21");
14416 uIconIdx_Spell27 = pIconsFrameTable->FindIcon("spell27");
14417 }
14418
14419 //----- (0044162D) --------------------------------------------------------
14420 void __cdecl GameUI_DrawPartySpells()
14421 {
14422 unsigned int v0; // ebp@1
14423 signed int v1; // edi@1
14424 int v2; // eax@2
14425 int v3; // ecx@5
14426 __int16 *v4; // ebx@25
14427 Player *v5; // edi@26
14428 unsigned int v6; // [sp-4h] [bp-1Ch]@11
14429 Texture *v7; // [sp-4h] [bp-1Ch]@12
14430 unsigned int v8; // [sp-4h] [bp-1Ch]@20
14431 Texture *v9; // [sp-4h] [bp-1Ch]@21
14432 Player **v10; // [sp+10h] [bp-8h]@25
14433
14434 v0 = (signed __int64)((double)GetTickCount() * 0.050000001);
14435 v1 = 0;
14436 do
14437 {
14438 v2 = (unsigned __int8)byte_4E5DD8[v1];
14439 if ( SHIDWORD(pParty->pPartyBuffs[v2].uExpireTime) >= 0
14440 && (SHIDWORD(pParty->pPartyBuffs[v2].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[v2].uExpireTime) > 0) )
14441 {
14442 v3 = pTextureIDs_isns[v1];
14443 pRenderer->_4A65CC(
14444 pPartySpellbuffsUI_XYs[v1][0],
14445 pPartySpellbuffsUI_XYs[v1][1],
14446 (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
14447 (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
14448 v0 + 20 * pPartySpellbuffsUI_smthns[v1],
14449 0,
14450 63);
14451 }
14452 ++v1;
14453 }
14454 while ( v1 < 14 );
14455 if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
14456 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4 )
14457 {
14458 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
14459 {
14460 if ( pParty->bFlying )
14461 v6 = v0;
14462 else
14463 v6 = 0;
14464 v7 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_Spell21, v6)->uTextureID];
14465 if ( pRenderer->pRenderD3D )
14466 pRenderer->DrawTextureIndexed(8u, 8u, v7);
14467 else
14468 pRenderer->DrawTextureTransparent(8u, 8u, v7);
14469 }
14470 if ( SHIDWORD(pParty->pPartyBuffs[18].uExpireTime) >= 0
14471 && (SHIDWORD(pParty->pPartyBuffs[18].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[18].uExpireTime)) )
14472 {
14473 if ( pParty->uFlags & 0x80 )
14474 v8 = v0;
14475 else
14476 v8 = 0;
14477 v9 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_Spell27, v8)->uTextureID];
14478 if ( pRenderer->pRenderD3D )
14479 pRenderer->DrawTextureIndexed(396u, 8u, v9);
14480 else
14481 pRenderer->DrawTextureTransparent(396u, 8u, v9);
14482 }
14483 }
14484 v10 = &pPlayers[1];
14485 v4 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
14486 do
14487 {
14488 v5 = *v10;
14489 if ( (signed __int64)(*v10)->pPlayerBuffs[6].uExpireTime > 0 )
14490 pRenderer->DrawTextureIndexed(
14491 *v4 + 72,
14492 0x1ABu,
14493 (Texture *)(dword_507964 != -1 ? (int)&pIcons_LOD->pTextures[dword_507964] : 0));
14494 if ( (signed __int64)v5->pPlayerBuffs[1].uExpireTime > 0 )
14495 pRenderer->DrawTextureIndexed(
14496 *v4 + 72,
14497 0x189u,
14498 (Texture *)(dword_50796C != -1 ? (int)&pIcons_LOD->pTextures[dword_50796C] : 0));
14499 if ( (signed __int64)v5->pPlayerBuffs[11].uExpireTime > 0 )
14500 pRenderer->DrawTextureIndexed(
14501 *v4 + 72,
14502 0x19Au,
14503 (Texture *)(dword_507968 != -1 ? (int)&pIcons_LOD->pTextures[dword_507968] : 0));
14504 if ( (signed __int64)v5->pPlayerBuffs[10].uExpireTime > 0 )
14505 pRenderer->DrawTextureIndexed(
14506 *v4 + 72,
14507 0x1BCu,
14508 (Texture *)(dword_507960 != -1 ? (int)&pIcons_LOD->pTextures[dword_507960] : 0));
14509 ++v10;
14510 ++v4;
14511 }
14512 while ( (signed int)v4 < (signed int)pBaseHealthByClass );
14513 }
14514
14515
14516 //----- (00441A4E) --------------------------------------------------------
14517 __int16 __fastcall sub_441A4E(int a1)
14518 {
14519 __int16 result; // ax@1
14520 int v2; // ebx@1
14521 char *v3; // esi@1
14522 int v4; // edi@4
14523 int v5; // ecx@4
14524 SpriteFrame *v6; // eax@6
14525 SpriteFrame *v7; // edi@6
14526 int v8; // eax@6
14527 unsigned __int16 v9; // ax@6
14528 RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1
14529 int v11; // [sp+5Ch] [bp-Ch]@6
14530 int v12; // [sp+60h] [bp-8h]@1
14531 int v13; // [sp+64h] [bp-4h]@6
14532
14533 v10.uParentBillboardID = -1;
14534 v10.pTarget = pRenderer->pTargetSurface;
14535 v10.pTargetZ = pRenderer->pActiveZBuffer;
14536 v10.uTargetPitch = pRenderer->field_10;
14537 result = 0;
14538 v2 = a1;
14539 v10.uViewportX = 0;
14540 v10.uViewportY = 0;
14541 v10.uViewportZ = 639;
14542 v10.uViewportW = 479;
14543 v12 = 0;
14544 v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C;
14545 do
14546 {
14547 if ( *((short *)v3 - 3) > 0 )
14548 {
14549 result = *((short *)v3 - 6);
14550 if ( result >= 300 )
14551 {
14552 v4 = result;
14553 v5 = result == v2 + 320 | result == v2 + 330 | result == v2 + 340 | result == v2 + 350;
14554 result = v2 + 310;
14555 if ( v4 == v2 + 310 | v5 )
14556 {
14557 if ( !*(short *)v3 )
14558 {
14559 v6 = pSpriteFrameTable->GetFrame(
14560 pOverlayList->pOverlays[*((short *)v3 - 5)].uSpriteFramesetID,
14561 *((short *)v3 - 4));
14562 v7 = v6;
14563 v11 = *((int *)v3 + 1);
14564 v13 = v6->scale;
14565 v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16;
14566 v10.field_8 = *((short *)v3 - 2);
14567 v10.field_C = *((short *)v3 - 1);
14568 v10.field_10 = v13;
14569 v10.field_14 = v13;
14570 v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1);
14571 v8 = *((short *)v3 - 5);
14572 v10.field_28 = 0;
14573 v10.uFlags = 0;
14574 v9 = pOverlayList->pOverlays[v8].uOverlayType;
14575 if ( !v9 || v9 == 2 )
14576 v10.field_C += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
14577 result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0);
14578 ++v12;
14579 if ( v12 == 5 )
14580 break;
14581 }
14582 }
14583 }
14584 }
14585 v3 += 20;
14586 }
14587 while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays );
14588 return result;
14589 }
14590
14591
14592
14593 //----- (00441D38) --------------------------------------------------------
14594 void __fastcall GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags)
14595 {
14596 int v6; // ebx@6
14597 BLVFace *v7; // eax@8
14598 unsigned int *v8; // edi@9
14599 unsigned int v9; // edx@9
14600 unsigned int v10; // ebx@10
14601 __int16 v11; // cx@11
14602 int v12; // ecx@17
14603 unsigned int v13; // ecx@21
14604 unsigned int v14; // ebx@23
14605 int v15; // eax@23
14606 unsigned int *v16; // ecx@28
14607 __int16 v17; // di@30
14608 double v18; // st7@30
14609 float v19; // ST38_4@30
14610 double v20; // st7@30
14611 double v21; // st6@30
14612 double v22; // st5@33
14613 float v23; // ST3C_4@37
14614 double v24; // ST20_8@37
14615 double v25; // ST20_8@37
14616 unsigned __int16 *v26; // edx@37
14617 signed int v27; // eax@37
14618 unsigned __int16 *v28; // ecx@37
14619 signed int v29; // edi@40
14620 int v30; // eax@42
14621 unsigned __int16 *v31; // ebx@43
14622 signed int v32; // edi@46
14623 signed int v33; // ebx@50
14624 unsigned int v34; // eax@50
14625 signed int v35; // ecx@50
14626 unsigned __int16 v36; // di@66
14627 int v37; // edi@72
14628 int v38; // ebx@72
14629 __int16 v39; // ax@87
14630 int v40; // edi@91
14631 int v41; // ebx@91
14632 unsigned int v42; // eax@101
14633 unsigned int v43; // ebx@101
14634 unsigned int v44; // ST30_4@101
14635 char *v45; // ebx@106
14636 int v46; // edi@108
14637 int v47; // eax@108
14638 unsigned int v48; // ebx@114
14639 unsigned int v49; // ST64_4@114
14640 double v50; // ST20_8@117
14641 unsigned int v51; // [sp-10h] [bp-64h]@79
14642 unsigned int v52; // [sp-10h] [bp-64h]@100
14643 unsigned int v53; // [sp-Ch] [bp-60h]@79
14644 unsigned int v54; // [sp-Ch] [bp-60h]@100
14645 unsigned int v55; // [sp-8h] [bp-5Ch]@77
14646 unsigned int v56; // [sp-8h] [bp-5Ch]@100
14647 signed int v57; // [sp-4h] [bp-58h]@54
14648 unsigned __int16 v58; // [sp-4h] [bp-58h]@77
14649 unsigned __int16 v59; // [sp-4h] [bp-58h]@100
14650 unsigned __int16 v60; // [sp+10h] [bp-44h]@66
14651 unsigned int v61; // [sp+10h] [bp-44h]@85
14652 unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
14653 unsigned int v63; // [sp+14h] [bp-40h]@85
14654 int v64; // [sp+18h] [bp-3Ch]@39
14655 unsigned int v65; // [sp+18h] [bp-3Ch]@85
14656 unsigned int lPitch; // [sp+20h] [bp-34h]@1
14657 unsigned int lPitcha; // [sp+20h] [bp-34h]@23
14658 char *lPitchb; // [sp+20h] [bp-34h]@106
14659 unsigned int v69; // [sp+24h] [bp-30h]@23
14660 signed int v70; // [sp+24h] [bp-30h]@37
14661 unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
14662 signed int uBluea; // [sp+28h] [bp-2Ch]@37
14663 int v73; // [sp+2Ch] [bp-28h]@30
14664 unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
14665 signed int v75; // [sp+34h] [bp-20h]@4
14666 int v76; // [sp+34h] [bp-20h]@91
14667 int v77; // [sp+34h] [bp-20h]@108
14668 signed int v78; // [sp+38h] [bp-1Ch]@37
14669 int v79; // [sp+38h] [bp-1Ch]@72
14670 bool v80; // [sp+3Ch] [bp-18h]@2
14671 unsigned int a2; // [sp+40h] [bp-14h]@1
14672 int a2a; // [sp+40h] [bp-14h]@8
14673 signed int a2b; // [sp+40h] [bp-14h]@41
14674 char *a2c; // [sp+40h] [bp-14h]@68
14675 unsigned int a3; // [sp+44h] [bp-10h]@1
14676 int a3a; // [sp+44h] [bp-10h]@40
14677 signed int uHeight; // [sp+48h] [bp-Ch]@1
14678 signed int uWidth; // [sp+4Ch] [bp-8h]@1
14679 signed int uZa; // [sp+5Ch] [bp+8h]@7
14680 signed int uZb; // [sp+5Ch] [bp+8h]@27
14681 signed int uZc; // [sp+5Ch] [bp+8h]@30
14682 signed int uZd; // [sp+5Ch] [bp+8h]@45
14683 signed int uZe; // [sp+5Ch] [bp+8h]@67
14684 signed int uZf; // [sp+5Ch] [bp+8h]@85
14685 signed int uZg; // [sp+5Ch] [bp+8h]@105
14686 unsigned int uWa; // [sp+60h] [bp+Ch]@23
14687 float uWb; // [sp+60h] [bp+Ch]@30
14688 float uWe; // [sp+60h] [bp+Ch]@37
14689 unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
14690 unsigned int uWd; // [sp+60h] [bp+Ch]@95
14691 float uZooma; // [sp+64h] [bp+10h]@117
14692 signed int flagsa; // [sp+68h] [bp+14h]@42
14693 unsigned int flagsb; // [sp+68h] [bp+14h]@66
14694 char *flagsc; // [sp+68h] [bp+14h]@86
14695 unsigned int flagsd; // [sp+68h] [bp+14h]@105
14696
14697 a3 = uY;
14698 a2 = uX;
14699 uWidth = (signed int)(uX + uZ) >> 1;
14700 uHeight = (signed int)(uY + uW) >> 1;
14701 lPitch = pRenderer->uTargetSurfacePitch;
14702 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
14703 uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
14704 v80 = (signed __int64)pParty->pPartyBuffs[19].uExpireTime > 0;
14705 v75 = pParty->pPartyBuffs[19].uSkill;
14706 if ( CheckHiredNPCSpeciality(0x26u) )
14707 {
14708 v80 = 1;
14709 v75 = 2;
14710 }
14711 pRenderer->Clip_v2(a2, a3, uZ - 1, uW - 1);
14712 v6 = uW - a3;
14713 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
14714 {
14715 uZc = uZ - a2;
14716 v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
14717 v74 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
14718 v62 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
14719 v73 = (1 << (v17 + 16)) / (signed int)uZoom;
14720 v18 = (double)(1 << (16 - v17));
14721 v19 = v18;
14722 v20 = (double)(pParty->vPosition.x + 32768) / v18;
14723 v21 = (double)(32768 - pParty->vPosition.z) / v19;
14724 uWb = v21;
14725 if ( uZoom == 512 )
14726 {
14727 v20 = v20 - (double)(uZc / 2);
14728 v22 = (double)(v6 / 2);
14729 }
14730 else
14731 {
14732 if ( uZoom == 1024 )
14733 {
14734 v20 = v20 - (double)(uZc / 4);
14735 v22 = (double)(v6 / 4);
14736 }
14737 else
14738 {
14739 if ( uZoom != 2048 )
14740 goto LABEL_37;
14741 v20 = v20 - (double)(uZc / 8);
14742 v22 = (double)(v6 / 8);
14743 }
14744 }
14745 uWb = v21 - v22;
14746 LABEL_37:
14747 v23 = v20 * 65536.0;
14748 v24 = v23 + 6.7553994e15;
14749 v70 = LODWORD(v24);
14750 uWe = uWb * 65536.0;
14751 v25 = uWe + 6.7553994e15;
14752 v78 = v70;
14753 uBluea = LODWORD(v25);
14754 v26 = (unsigned __int16 *)_56EFD8_minimap;
14755 v27 = SLODWORD(v25) >> 16;
14756 uWc = (unsigned __int16 *)_56EFD8_minimap;
14757 v28 = &pRenderer->pTargetSurface[a2 + a3 * lPitch];
14758 if ( flags )
14759 {
14760 if ( v74 )
14761 {
14762 v64 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
14763 if ( v6 > 0 )
14764 {
14765 a3a = v6;
14766 v29 = v70 >> 16;
14767 do
14768 {
14769 a2b = 0;
14770 if ( uZc > 0 )
14771 {
14772 v30 = (int)&v74[v27 * v64];
14773 flagsa = uZc;
14774 a2b = uZc;
14775 do
14776 {
14777 v31 = uWc;
14778 ++uWc;
14779 *v31 = v62[*(char *)(v30 + v29)];
14780 v78 += v73;
14781 v29 = v78 >> 16;
14782 --flagsa;
14783 }
14784 while ( flagsa );
14785 }
14786 v78 = v70;
14787 v29 = v70 >> 16;
14788 v28 += 137 - a2b;
14789 uBluea += v73;
14790 v27 = uBluea >> 16;
14791 --a3a;
14792 }
14793 while ( a3a );
14794 }
14795 }
14796 }
14797 uZd = 117;
14798 do
14799 {
14800 v32 = 137;
14801 do
14802 {
14803 *v28 = *v26;
14804 ++v28;
14805 ++v26;
14806 --v32;
14807 }
14808 while ( v32 );
14809 v28 += lPitch - 137;
14810 --uZd;
14811 }
14812 while ( uZd );
14813 uNumBlueFacesInBLVMinimap = 0;
14814 goto LABEL_50;
14815 }
14816 pRenderer->FillRect2(v6, a2, a3, uZ - a2, v6, 0xFu);
14817 uNumBlueFacesInBLVMinimap = 0;
14818 uZa = 0;
14819 if ( (signed int)*pIndoor->pMapVertices > 0 )
14820 {
14821 a2a = 0;
14822 v7 = pIndoor->pFaces;
14823 while ( 1 )
14824 {
14825 v8 = &pIndoor->pMapVertices[a2a + 1];
14826 v9 = v7[LOWORD(pIndoor->pMapVertices[a2a + 2])].uAttributes;
14827 if ( !(BYTE1(v9) & 0x20) )
14828 {
14829 v10 = v7[HIWORD(pIndoor->pMapVertices[a2a + 2])].uAttributes;
14830 if ( !(BYTE1(v10) & 0x20) )
14831 {
14832 v11 = HIWORD(pIndoor->pMapVertices[a2a + 3]);
14833 if ( v11 & 1 )
14834 goto LABEL_15;
14835 if ( (v9 & 0x80u) != 0 || (v10 & 0x80u) != 0 )
14836 break;
14837 }
14838 }
14839 LABEL_26:
14840 ++uZa;
14841 a2a += 3;
14842 if ( uZa >= (signed int)*pIndoor->pMapVertices )
14843 goto LABEL_27;
14844 }
14845 HIWORD(pIndoor->pMapVertices[a2a + 3]) = v11 | 1;
14846 pIndoor->_visible_outlines[uZa >> 3] |= 1 << (7 - uZa % 8);
14847 v7 = pIndoor->pFaces;
14848 LABEL_15:
14849 if ( v80
14850 && v75 >= 3
14851 && ((v12 = (int)&v7[*((short *)v8 + 2)], *(int *)(v12 + 44) & 0x2000000)
14852 || v7[*((short *)v8 + 3)].uAttributes & 0x2000000)
14853 && (pIndoor->pFaceExtras[*(short *)(v12 + 72)].uEventID
14854 || pIndoor->pFaceExtras[v7[*((short *)v8 + 3)].uFaceExtraID].uEventID)
14855 && (v13 = uNumBlueFacesInBLVMinimap, (signed int)uNumBlueFacesInBLVMinimap < 49) )
14856 {
14857 pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap] = uZa;
14858 uNumBlueFacesInBLVMinimap = v13 + 1;
14859 }
14860 else
14861 {
14862 v69 = uWidth
14863 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14864 * (signed __int64)pIndoor->pVertices[*(short *)v8].x) >> 16) << 16)
14865 - uZoom * pParty->vPosition.x) >> 16);
14866 lPitcha = uHeight
14867 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14868 * (signed __int64)pIndoor->pVertices[*(short *)v8].y) >> 16) << 16)
14869 - uZoom * pParty->vPosition.z) >> 16);
14870 uWa = uWidth
14871 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14872 * (signed __int64)pIndoor->pVertices[*((short *)v8 + 1)].x) >> 16) << 16)
14873 - uZoom * pParty->vPosition.x) >> 16);
14874 v14 = uHeight
14875 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14876 * (signed __int64)pIndoor->pVertices[*((short *)v8 + 1)].y) >> 16) << 16)
14877 - uZoom * pParty->vPosition.z) >> 16);
14878 v15 = abs(*((short *)v8 + 4) - pParty->vPosition.y) / 8;
14879 if ( v15 > 100 )
14880 v15 = 100;
14881 pRenderer->FillRect(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
14882 v7 = pIndoor->pFaces;
14883 }
14884 goto LABEL_26;
14885 }
14886 LABEL_27:
14887 for ( uZb = 0; uZb < (signed int)uNumBlueFacesInBLVMinimap; ++uZb )
14888 {
14889 v16 = &pIndoor->pMapVertices[3 * pBlueFacesInBLVMinimapIDs[uZb] + 1];
14890 pRenderer->FillRect(
14891 uWidth
14892 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14893 * (signed __int64)pIndoor->pVertices[*(short *)v16].x) >> 16) << 16)
14894 - uZoom * pParty->vPosition.x) >> 16),
14895 uHeight
14896 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14897 * (signed __int64)pIndoor->pVertices[*(short *)v16].y) >> 16) << 16)
14898 - uZoom * pParty->vPosition.z) >> 16),
14899 uWidth
14900 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14901 * (signed __int64)pIndoor->pVertices[HIWORD(pIndoor->pMapVertices[3 * pBlueFacesInBLVMinimapIDs[uZb] + 1])].x) >> 16) << 16)
14902 - uZoom * pParty->vPosition.x) >> 16),
14903 uHeight
14904 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
14905 * (signed __int64)pIndoor->pVertices[HIWORD(pIndoor->pMapVertices[3 * pBlueFacesInBLVMinimapIDs[uZb] + 1])].y) >> 16) << 16)
14906 - uZoom * pParty->vPosition.z) >> 16),
14907 uBlue);
14908 }
14909 LABEL_50:
14910 v33 = 0;
14911 v34 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
14912 v35 = 0;
14913 if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) < 128 )
14914 goto LABEL_66;
14915 if ( (signed int)v34 <= 384 )
14916 {
14917 v35 = 1;
14918 goto LABEL_66;
14919 }
14920 if ( (signed int)v34 >= 640 )
14921 {
14922 if ( (signed int)v34 > 896 )
14923 {
14924 if ( (signed int)v34 >= 1152 )
14925 {
14926 if ( (signed int)v34 > 1408 )
14927 {
14928 if ( (signed int)v34 >= 1664 )
14929 {
14930 if ( (signed int)v34 > 1920 )
14931 goto LABEL_66;
14932 v57 = 7;
14933 }
14934 else
14935 {
14936 v57 = 6;
14937 }
14938 }
14939 else
14940 {
14941 v57 = 5;
14942 }
14943 }
14944 else
14945 {
14946 v57 = 4;
14947 }
14948 }
14949 else
14950 {
14951 v57 = 3;
14952 }
14953 }
14954 else
14955 {
14956 v57 = 2;
14957 }
14958 v35 = v57;
14959 LABEL_66:
14960 pRenderer->DrawTextureTransparent(
14961 uWidth - 3,
14962 uHeight - 3,
14963 (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
14964 v36 = 255;
14965 flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
14966 v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
14967 if ( v80 )
14968 {
14969 uZe = 0;
14970 if ( (signed int)uNumLayingItems > 0 )
14971 {
14972 a2c = (char *)&pLayingItems[0].uObjectDescID;
14973 while ( 1 )
14974 {
14975 if ( !*((short *)a2c - 1)
14976 || !*(short *)a2c
14977 || v75 == 1
14978 || (v37 = ((unsigned __int64)((*(int *)(a2c + 2) - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
14979 + uWidth,
14980 v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16,
14981 v38 = uHeight - v79,
14982 v37 < pRenderer->field_1C_clipx)
14983 || v37 > pRenderer->field_24_clipz
14984 || v38 < pRenderer->field_20_clipy
14985 || v38 > pRenderer->field_28_clipw )
14986 goto LABEL_83;
14987 if ( pObjectList->pObjects[*(short *)a2c].uFlags & 0x10 )
14988 break;
14989 if ( (signed int)uZoom > 512 )
14990 {
14991 pRenderer->FillRect(v37 - 1, v38 - 1, v37 - 1, v38 + 1, flagsb);
14992 pRenderer->FillRect(v37, v38 - 2, v37, v38 + 1, flagsb);
14993 pRenderer->FillRect(v37 + 1, v38 - 1, v37 + 1, v38 + 1, flagsb);
14994 pRenderer->FillRect(v37 - 2, v38, v37 - 2, v38 + 1, flagsb);
14995 v37 += 2;
14996 v58 = flagsb;
14997 v55 = v38 + 1;
14998 goto LABEL_81;
14999 }
15000 pRenderer->FillRect(v37 - 1, v38 - 1, v37 - 1, uHeight - v79, flagsb);
15001 v58 = flagsb;
15002 v55 = uHeight - v79;
15003 v53 = v37;
15004 v51 = v38 - 1;
15005 LABEL_82:
15006 pRenderer->FillRect(v37, v51, v53, v55, v58);
15007 LABEL_83:
15008 ++uZe;
15009 a2c += 112;
15010 if ( uZe >= (signed int)uNumLayingItems )
15011 {
15012 v36 = 255;
15013 v33 = 0;
15014 goto LABEL_85;
15015 }
15016 }
15017 v58 = v60;
15018 v55 = uHeight - v79;
15019 LABEL_81:
15020 v53 = v37;
15021 v51 = uHeight - v79;
15022 goto LABEL_82;
15023 }
15024 LABEL_85:
15025 v63 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, 0, v33);
15026 v61 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, v36, v33);
15027 v65 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, v36, v33);
15028 uZf = v33;
15029 if ( (signed int)uNumActors > v33 )
15030 {
15031 flagsc = (char *)&pActors[0].uAIState;
15032 do
15033 {
15034 v39 = *(short *)flagsc;
15035 if ( *(short *)flagsc != 11 && v39 != 19 && (v39 == 5 || *(flagsc - 139) & 0x80) )
15036 {
15037 v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
15038 * (signed __int64)(signed int)uZoom) >> 16)
15039 + uWidth;
15040 v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.z)
15041 * (signed __int64)(signed int)uZoom) >> 16;
15042 v41 = uHeight - v76;
15043 if ( v40 >= pRenderer->field_1C_clipx )
15044 {
15045 if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
15046 {
15047 uWd = v61;
15048 if ( *(flagsc - 137) & 1 )
15049 uWd = v63;
15050 if ( *(short *)flagsc == 5 )
15051 uWd = v65;
15052 if ( (signed int)uZoom > 1024 )
15053 {
15054 pRenderer->FillRect(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd);
15055 pRenderer->FillRect(v40, v41 - 2, v40, v41 + 2, uWd);
15056 pRenderer->FillRect(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd);
15057 v42 = v41 + 1;
15058 v43 = v41 - 1;
15059 v44 = v42;
15060 pRenderer->FillRect(v40 - 2, v43, v40 - 2, v42, uWd);
15061 v40 += 2;
15062 v59 = uWd;
15063 v56 = v44;
15064 v54 = v40;
15065 v52 = v43;
15066 }
15067 else
15068 {
15069 pRenderer->FillRect(v40 - 1, v41 - 1, v40 - 1, uHeight - v76, uWd);
15070 v59 = uWd;
15071 v56 = uHeight - v76;
15072 v54 = v40;
15073 v52 = v41 - 1;
15074 }
15075 pRenderer->FillRect(v40, v52, v54, v56, v59);
15076 }
15077 }
15078 }
15079 ++uZf;
15080 flagsc += 836;
15081 }
15082 while ( uZf < (signed int)uNumActors );
15083 v36 = 255;
15084 v33 = 0;
15085 }
15086 }
15087 flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, v36, v36);
15088 uZg = v33;
15089 if ( (signed int)uNumLevelDecorations > v33 )
15090 {
15091 v45 = (char *)&pLevelDecorations[0].vPosition;
15092 lPitchb = (char *)&pLevelDecorations[0].vPosition;
15093 do
15094 {
15095 if ( *(v45 - 2) & 8 )
15096 {
15097 v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
15098 + uWidth;
15099 v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16;
15100 v47 = uHeight - v77;
15101 if ( v46 >= pRenderer->field_1C_clipx )
15102 {
15103 if ( v46 <= pRenderer->field_24_clipz && v47 >= pRenderer->field_20_clipy && v47 <= pRenderer->field_28_clipw )
15104 {
15105 if ( (signed int)uZoom > 512 )
15106 {
15107 v48 = v47 + 1;
15108 v49 = v47 - 1;
15109 pRenderer->FillRect(v46 - 1, v47 - 1, v46 - 1, v47 + 1, flagsd);
15110 pRenderer->FillRect(v46, v49, v46, v48, flagsd);
15111 pRenderer->FillRect(v46 + 1, v49, v46 + 1, v48, flagsd);
15112 v45 = lPitchb;
15113 }
15114 else
15115 {
15116 pRenderer->FillRect(v46, uHeight - v77, v46, uHeight - v77, flagsd);
15117 }
15118 }
15119 }
15120 }
15121 ++uZg;
15122 v45 += 32;
15123 lPitchb = v45;
15124 }
15125 while ( uZg < (signed int)uNumLevelDecorations );
15126 v33 = 0;
15127 }
15128 pRenderer->DrawTextureTransparent(
15129 0x1D4u,
15130 v33,
15131 (Texture *)(dword_5079D8 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079D8] : 0));
15132 uZooma = (double)pParty->sRotationY * 0.1171875;
15133 v50 = uZooma + 6.7553994e15;
15134 pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
15135 pRenderer->DrawTextureIndexed(
15136 LODWORD(v50) + 285,
15137 0x88u,
15138 (Texture *)(dword_5079B4 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079B4] : 0));
15139 pRenderer->ResetClip();
15140 }
15141
15142
15143 //----- (00442955) --------------------------------------------------------
15144 int __fastcall DrawSpellbook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074)
15145 {
15146 int v5; // ebx@1
15147 int v6; // edi@1
15148 unsigned int *v7; // eax@8
15149 unsigned __int8 v8; // zf@8
15150 unsigned __int8 v9; // sf@8
15151 int v10; // esi@10
15152 unsigned int v11; // edx@11
15153 __int16 v12; // cx@12
15154 signed int v13; // eax@15
15155 int v14; // eax@16
15156 Vec3_short_ *v15; // ecx@16
15157 int v16; // edx@16
15158 int v17; // ecx@16
15159 Vec3_short_ *v18; // eax@16
15160 int v19; // ecx@16
15161 int v20; // eax@16
15162 signed int v21; // esi@18
15163 int v22; // ecx@21
15164 int v23; // ecx@21
15165 Vec3_short_ *v24; // edx@21
15166 Vec3_short_ *v25; // eax@21
15167 int v26; // ecx@21
15168 unsigned __int16 *v27; // edi@21
15169 int v28; // edx@21
15170 int v29; // eax@21
15171 double v30; // st7@23
15172 signed __int64 v31; // qax@23
15173 char *v32; // edx@23
15174 int v33; // esi@23
15175 signed int v34; // eax@23
15176 signed int v35; // ecx@23
15177 int v36; // esi@27
15178 int v37; // ecx@27
15179 int v38; // edx@31
15180 unsigned int v39; // eax@33
15181 const void *v40; // esi@33
15182 unsigned __int16 *v41; // edi@33
15183 unsigned __int8 v42; // cf@33
15184 unsigned int v43; // ecx@33
15185 int v44; // edi@33
15186 int v45; // esi@33
15187 int v46; // ecx@33
15188 signed int v47; // esi@38
15189 signed int v48; // ecx@38
15190 int v49; // eax@38
15191 signed int v50; // edx@55
15192 unsigned int v51; // ecx@55
15193 int result; // eax@72
15194 int v53; // eax@75
15195 int v54; // esi@75
15196 int v55; // eax@75
15197 __int16 v56; // si@85
15198 double v57; // st7@85
15199 int v58; // ebx@85
15200 signed __int64 v59; // qax@85
15201 signed int v60; // edi@85
15202 signed __int64 v61; // qax@85
15203 signed int v62; // ebx@85
15204 signed int v63; // esi@85
15205 int v64; // eax@87
15206 unsigned int v65; // ebx@95
15207 char *v66; // edx@95
15208 unsigned __int16 *v67; // esi@96
15209 int v68; // edi@98
15210 unsigned __int16 v69; // cx@99
15211 unsigned int v70; // [sp-10h] [bp-48074h]@80
15212 unsigned int v71; // [sp-Ch] [bp-48070h]@80
15213 unsigned int v72; // [sp-8h] [bp-4806Ch]@80
15214 signed int v73; // [sp-4h] [bp-48068h]@59
15215 unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
15216 char v75; // [sp+Ch] [bp-48058h]@23
15217 int v76; // [sp+4800Ch] [bp-58h]@23
15218 unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
15219 unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23
15220 unsigned int v79; // [sp+48018h] [bp-4Ch]@1
15221 unsigned int y_; // [sp+4801Ch] [bp-48h]@1
15222 int v81; // [sp+48020h] [bp-44h]@23
15223 unsigned int x_; // [sp+48024h] [bp-40h]@1
15224 unsigned int teal; // [sp+48028h] [bp-3Ch]@8
15225 int v84; // [sp+4802Ch] [bp-38h]@1
15226 int v85; // [sp+48030h] [bp-34h]@1
15227 int v86; // [sp+48034h] [bp-30h]@1
15228 int v87; // [sp+48038h] [bp-2Ch]@16
15229 unsigned int v88; // [sp+4803Ch] [bp-28h]@16
15230 int black; // [sp+48040h] [bp-24h]@8
15231 int v90; // [sp+48044h] [bp-20h]@1
15232 unsigned int i; // [sp+48048h] [bp-1Ch]@9
15233 unsigned int v92; // [sp+4804Ch] [bp-18h]@16
15234 unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
15235 unsigned int v94; // [sp+48054h] [bp-10h]@8
15236 unsigned int v95; // [sp+48058h] [bp-Ch]@16
15237 int v96; // [sp+4805Ch] [bp-8h]@10
15238 const void *v97; // [sp+48060h] [bp-4h]@16
15239 char *a4a; // [sp+4806Ch] [bp+8h]@85
15240 int a5a; // [sp+48070h] [bp+Ch]@86
15241
15242 x_ = x;
15243 y_ = y;
15244 v85 = (signed int)(x + a4) >> 1;
15245 v90 = (signed int)(y + a5) >> 1;
15246 v79 = pRenderer->uTargetSurfacePitch;
15247 pRenderer->Clip_v2(x, y, a4, a5);
15248 v5 = viewparams->field_2C;
15249 v6 = viewparams->sPartyPosX;
15250 v86 = viewparams->sPartyPosX;
15251 v84 = viewparams->sPartyPosZ;
15252 if ( viewparams->field_2C != 384 )
15253 {
15254 if ( viewparams->field_2C == 768 )
15255 {
15256 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
15257 goto LABEL_23;
15258 v5 = 680;
15259 }
15260 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
15261 goto LABEL_8;
15262 LABEL_23:
15263 v94 = a4 - x_ + 1;
15264 v92 = a5 - y_ + 1;
15265 v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
15266 v95 = (unsigned int)pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
15267 v78 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
15268 v87 = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
15269 v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
15270 black = 22528 / (v5 / 384);
15271 teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
15272 v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
15273 v96 = 32768 - black - v84;
15274 v31 = (signed __int64)((double)v96 / v30);
15275 v32 = &v75;
15276 v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
15277 v34 = (int)v31 << 16;
15278 v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
15279 black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
15280 v76 = v33;
15281 v35 = v34 >> 16;
15282 if ( v95 && (signed int)v92 > 0 )
15283 {
15284 v96 = v92;
15285 do
15286 {
15287 v88 = 0;
15288 if ( (signed int)v94 > 0 )
15289 {
15290 v36 = v95 + v35 * v76;
15291 i = v94;
15292 v88 = v94;
15293 v37 = black;
15294 v77 = (unsigned __int16 *)v36;
15295 do
15296 {
15297 *(short *)v32 = v78[*((char *)v77 + v37)];
15298 v32 += 2;
15299 v97 = (char *)v97 + v87;
15300 v37 = (signed int)v97 >> 16;
15301 --i;
15302 }
15303 while ( i );
15304 }
15305 v34 += v87;
15306 v97 = (const void *)teal;
15307 black = v81;
15308 v32 += 2 * (v94 - v88);
15309 v35 = v34 >> 16;
15310 --v96;
15311 }
15312 while ( v96 );
15313 }
15314 v97 = &v75;
15315 if ( (signed int)v92 > 0 )
15316 {
15317 v96 = v92;
15318 v38 = 2 * (v79 - v94);
15319 do
15320 {
15321 if ( (signed int)v94 > 0 )
15322 {
15323 v39 = v94;
15324 v40 = v97;
15325 v41 = v93;
15326 v42 = v94 & 1;
15327 v43 = v94 >> 1;
15328 memcpy(v93, v97, 4 * (v94 >> 1));
15329 v45 = (int)((char *)v40 + 4 * v43);
15330 v44 = (int)&v41[2 * v43];
15331 v46 = v42;
15332 v39 *= 2;
15333 v93 = (unsigned __int16 *)((char *)v93 + v39);
15334 v97 = (char *)v97 + v39;
15335 while ( v46 )
15336 {
15337 *(short *)v44 = *(short *)v45;
15338 v45 += 2;
15339 v44 += 2;
15340 --v46;
15341 }
15342 v6 = v86;
15343 }
15344 v93 = (unsigned __int16 *)((char *)v93 + v38);
15345 --v96;
15346 }
15347 while ( v96 );
15348 }
15349 goto LABEL_38;
15350 }
15351 v6 = viewparams->field_38;
15352 v86 = viewparams->field_38;
15353 v84 = viewparams->field_3A;
15354 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
15355 goto LABEL_23;
15356 v5 = viewparams->field_2C - 34;
15357 LABEL_8:
15358 black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
15359 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
15360 v7 = pIndoor->pMapVertices;
15361 uNumBlueFacesInBLVMinimap = 0;
15362 v8 = *pIndoor->pMapVertices == 0;
15363 v9 = (*pIndoor->pMapVertices & 0x80000000u) != 0;
15364 v94 = 0;
15365 if ( !(v9 | v8) )
15366 {
15367 i = 0;
15368 do
15369 {
15370 v10 = (int)((char *)v7 + i + 4);
15371 v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
15372 if ( BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )
15373 goto LABEL_17;
15374 v12 = *(short *)((char *)v7 + i + 14);
15375 if ( !(v12 & 1) )
15376 {
15377 if ( !(v96 & 0x80) && (v11 & 0x80u) == 0 )
15378 goto LABEL_17;
15379 v96 = (signed int)v94 >> 3;
15380 v13 = v94;
15381 *(short *)(v10 + 10) = v12 | 1;
15382 pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
15383 }
15384 v14 = *(short *)v10;
15385 v88 = v5;
15386 v15 = &pIndoor->pVertices[v14];
15387 v16 = v15->x;
15388 v17 = v15->y - v84;
15389 v93 = (unsigned __int16 *)(v16 - v6);
15390 v92 = v17;
15391 v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
15392 v19 = v18->x;
15393 v20 = v18->y - v84;
15394 v95 = v19 - v6;
15395 v97 = (const void *)v20;
15396 v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
15397 v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
15398 v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
15399 v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
15400 pRenderer->FillRect(
15401 v85 + v88,
15402 v90 - v87,
15403 v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
15404 v90 - v92,
15405 black);
15406 v7 = pIndoor->pMapVertices;
15407 LABEL_17:
15408 ++v94;
15409 i += 12;
15410 }
15411 while ( (signed int)v94 < (signed int)*v7 );
15412 }
15413 v21 = 0;
15414 if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
15415 {
15416 while ( 1 )
15417 {
15418 v22 = pBlueFacesInBLVMinimapIDs[v21];
15419 v87 = v5;
15420 v23 = (int)&v7[3 * v22 + 1];
15421 v24 = &pIndoor->pVertices[*(short *)v23];
15422 v25 = &pIndoor->pVertices[*(short *)(v23 + 2)];
15423 v26 = v25->x;
15424 v27 = (unsigned __int16 *)(v24->x - v86);
15425 v28 = v24->y - v84;
15426 v29 = v25->y - v84;
15427 v93 = v27;
15428 v92 = v28;
15429 v97 = (const void *)v29;
15430 v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
15431 v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
15432 i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
15433 v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
15434 pRenderer->FillRect(
15435 v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
15436 v90 - v88,
15437 v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
15438 v90 - v95,
15439 teal);
15440 ++v21;
15441 if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
15442 break;
15443 v7 = pIndoor->pMapVertices;
15444 }
15445 v6 = v86;
15446 }
15447 LABEL_38:
15448 v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
15449 v81 = pParty->vPosition.z - v84;
15450 v97 = (const void *)((unsigned __int64)((pParty->vPosition.z - v84) * (signed __int64)v5) >> 16);
15451 v48 = 1;
15452 v49 = v90 - (int)v97 - 3;
15453 if ( v47 >= (signed int)x_ )
15454 {
15455 if ( v47 > (signed int)a4 )
15456 {
15457 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 6) > (signed int)a4 )
15458 v48 = 0;
15459 v47 = a4;
15460 }
15461 }
15462 else
15463 {
15464 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85) < (signed int)x_ )
15465 v48 = 0;
15466 v47 = x_;
15467 }
15468 if ( v49 >= (signed int)y_ )
15469 {
15470 if ( v49 > a5 )
15471 {
15472 if ( v90 - (signed int)v97 - 6 > a5 )
15473 v48 = 0;
15474 v49 = a5;
15475 }
15476 }
15477 else
15478 {
15479 if ( v90 - (signed int)v97 < (signed int)y_ )
15480 v48 = 0;
15481 v49 = y_;
15482 }
15483 if ( v48 == 1 )
15484 {
15485 v50 = 0;
15486 v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
15487 if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 )
15488 {
15489 if ( (signed int)v51 > 384 )
15490 {
15491 if ( (signed int)v51 >= 640 )
15492 {
15493 if ( (signed int)v51 > 896 )
15494 {
15495 if ( (signed int)v51 >= 1152 )
15496 {
15497 if ( (signed int)v51 > 1408 )
15498 {
15499 if ( (signed int)v51 >= 1664 )
15500 {
15501 if ( (signed int)v51 > 1920 )
15502 goto LABEL_71;
15503 v73 = 7;
15504 }
15505 else
15506 {
15507 v73 = 6;
15508 }
15509 }
15510 else
15511 {
15512 v73 = 5;
15513 }
15514 }
15515 else
15516 {
15517 v73 = 4;
15518 }
15519 }
15520 else
15521 {
15522 v73 = 3;
15523 }
15524 }
15525 else
15526 {
15527 v73 = 2;
15528 }
15529 v50 = v73;
15530 goto LABEL_71;
15531 }
15532 v50 = 1;
15533 }
15534 LABEL_71:
15535 pRenderer->_4A6776(
15536 v47,
15537 v49,
15538 (Texture *)(pTextureIDs_pMapDirs[v50] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v50]] : 0));
15539 }
15540 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
15541 v95 = 0;
15542 v86 = result;
15543 if ( (signed int)uNumLevelDecorations > 0 )
15544 {
15545 v94 = (unsigned int)&pLevelDecorations[0].vPosition;
15546 do
15547 {
15548 if ( *(char *)(v94 - 2) & 8 )
15549 {
15550 v53 = *(int *)(v94 + 4) - v84;
15551 v93 = (unsigned __int16 *)(*(int *)v94 - v6);
15552 v92 = v53;
15553 v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
15554 v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
15555 v55 = v90 - (int)v97;
15556 if ( v54 >= pRenderer->field_1C_clipx )
15557 {
15558 if ( v54 <= pRenderer->field_24_clipz && v55 >= pRenderer->field_20_clipy && v55 <= pRenderer->field_28_clipw )
15559 {
15560 v74 = v86;
15561 if ( v5 > 512 )
15562 {
15563 v96 = v55 + 1;
15564 black = v55 - 1;
15565 pRenderer->FillRect(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
15566 pRenderer->FillRect(v54, black, v54, v96, v86);
15567 ++v54;
15568 v74 = v86;
15569 v72 = v96;
15570 v71 = v54;
15571 v70 = black;
15572 }
15573 else
15574 {
15575 v72 = v90 - (int)v97;
15576 v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
15577 v70 = v90 - (int)v97;
15578 }
15579 pRenderer->FillRect(v54, v70, v71, v72, v74);
15580 }
15581 }
15582 }
15583 ++v95;
15584 result = v95;
15585 v94 += 32;
15586 }
15587 while ( (signed int)v95 < (signed int)uNumLevelDecorations );
15588 }
15589 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
15590 {
15591 v90 = a4 - x_ + 1;
15592 v95 = a5 - y_ + 1;
15593 v77 = &pRenderer->pTargetSurface[x_ + y_ * v79];
15594 v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
15595 black = (1 << (v56 + 16)) / v5;
15596 v57 = (double)(1 << (16 - v56));
15597 v58 = 22528 / (v5 / 384);
15598 v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57);
15599 v60 = (int)v59 << 16;
15600 v97 = (const void *)((int)v59 << 16);
15601 v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
15602 v78 = (unsigned __int16 *)(v60 >> 16);
15603 v62 = (int)v61 << 16;
15604 teal = v60 >> 16;
15605 v63 = (signed __int16)v61;
15606 a4a = &v75;
15607 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
15608 v85 = 0;
15609 for ( i = result; v85 < (signed int)v95; result = v85 )
15610 {
15611 a5a = 0;
15612 if ( v90 > 0 )
15613 {
15614 v96 = (v63 - 80) / 4;
15615 v64 = teal;
15616 do
15617 {
15618 v81 = (v64 - 80) / 4;
15619 if ( !pOutdoor->_47F04C(v81, v96) )
15620 {
15621 if ( pOutdoor->_47F097(v81, v96) )
15622 {
15623 if ( !((a5a + v85) % 2) )
15624 *(short *)a4a = i;
15625 }
15626 else
15627 {
15628 *(short *)a4a = 0;
15629 }
15630 }
15631 a4a += 2;
15632 v97 = (char *)v97 + black;
15633 v64 = (signed int)v97 >> 16;
15634 ++a5a;
15635 }
15636 while ( a5a < v90 );
15637 }
15638 v62 += black;
15639 v97 = (const void *)v60;
15640 a4a += 2 * (v90 - a5a);
15641 v63 = v62 >> 16;
15642 ++v85;
15643 teal = (unsigned int)v78;
15644 }
15645 v65 = v95;
15646 v66 = &v75;
15647 if ( (signed int)v95 > 0 )
15648 {
15649 v67 = v77;
15650 result = 2 * (v79 - v90);
15651 do
15652 {
15653 if ( v90 > 0 )
15654 {
15655 v68 = v90;
15656 do
15657 {
15658 v69 = *(short *)v66;
15659 if ( !*(short *)v66 || v69 == (short)i )
15660 *v67 = v69;
15661 v66 += 2;
15662 ++v67;
15663 --v68;
15664 }
15665 while ( v68 );
15666 }
15667 v67 = (unsigned __int16 *)((char *)v67 + result);
15668 --v65;
15669 }
15670 while ( v65 );
15671 }
15672 }
15673 return result;
15674 }
15675
15676 //----- (00443219) --------------------------------------------------------
15677 int ViewingParams::_443219()
15678 {
15679 this->sPartyPosZ += 512;
15680 return _4432E7();
15681 }
15682
15683 //----- (00443225) --------------------------------------------------------
15684 int ViewingParams::_443225()
15685 {
15686 this->sPartyPosX -= 512;
15687 return _4432E7();
15688 }
15689
15690 //----- (00443231) --------------------------------------------------------
15691 int ViewingParams::_443231()
15692 {
15693 this->sPartyPosZ -= 512;
15694 return _4432E7();
15695 }
15696
15697 //----- (0044323D) --------------------------------------------------------
15698 int ViewingParams::_44323D()
15699 {
15700 this->sPartyPosX += 512;
15701 return _4432E7();
15702 }
15703
15704 //----- (00443249) --------------------------------------------------------
15705 int ViewingParams::_443249()
15706 {
15707 int v1; // edx@1
15708
15709 v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
15710 this->field_2C = v1;
15711 if ( v1 < 384 )
15712 this->field_2C = 384;
15713 this->sPartyPosX = pParty->vPosition.x;
15714 this->sPartyPosZ = pParty->vPosition.z;
15715 return _4432E7();
15716 }
15717
15718 //----- (00443291) --------------------------------------------------------
15719 int ViewingParams::_443291()
15720 {
15721 int v1; // edx@1
15722 int v2; // eax@1
15723
15724 v1 = 2 * this->field_2C;
15725 v2 = 1536;
15726 this->field_2C = v1;
15727 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
15728 v2 = 3072;
15729 if ( v1 > v2 )
15730 this->field_2C = v2;
15731 this->sPartyPosX = pParty->vPosition.x;
15732 this->sPartyPosZ = pParty->vPosition.z;
15733 return _4432E7();
15734 }
15735
15736 //----- (004432E7) --------------------------------------------------------
15737 int ViewingParams::_4432E7()
15738 {
15739 ViewingParams *v1; // esi@1
15740 int v2; // ebx@1
15741 signed int v3; // edx@1
15742 int v4; // ecx@1
15743 int v5; // edi@3
15744 int v6; // eax@3
15745 int v7; // eax@5
15746 int result; // eax@7
15747
15748 v1 = this;
15749 v2 = this->field_3A;
15750 v3 = 88 >> this->field_2C / 384;
15751 v4 = (44 - v3) << 9;
15752 if ( v1->sPartyPosZ > v2 + v4 )
15753 v1->sPartyPosZ = v2 + v4;
15754 v5 = v1->field_38;
15755 v6 = (v3 - 44) << 9;
15756 if ( v1->sPartyPosX < v5 + v6 )
15757 v1->sPartyPosX = v5 + v6;
15758 v7 = v2 + v6;
15759 if ( v1->sPartyPosZ < v7 )
15760 v1->sPartyPosZ = v7;
15761 result = v5 + v4;
15762 if ( v1->sPartyPosX > v5 + v4 )
15763 v1->sPartyPosX = result;
15764 return result;
15765 }
15766
15767 //----- (00443343) --------------------------------------------------------
15768 unsigned int ViewingParams::_443343()
15769 {
15770 signed int v1; // esi@1
15771 unsigned __int16 *v2; // edi@1
15772 unsigned int result; // eax@2
15773
15774 v1 = 0;
15775 v2 = this->pPalette;
15776 do
15777 {
15778 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, v1);
15779 *v2 = result;
15780 ++v1;
15781 ++v2;
15782 }
15783 while ( v1 < 256 );
15784 return result;
15785 }
15786
15787 //----- (00443365) --------------------------------------------------------
15788 int ViewingParams::_443365()
15789 {
15790 ViewingParams *v1; // esi@1
15791 __int16 *v2; // edi@3
15792 Vec3_short_ *v3; // eax@4
15793 unsigned int v4; // edx@4
15794 signed int v5; // eax@8
15795 Vec3_short_ *v6; // eax@12
15796 signed int v7; // edi@12
15797 signed int v8; // eax@16
15798 char v9; // zf@20
15799 int result; // eax@21
15800 unsigned int v11; // [sp+4h] [bp-1Ch]@3
15801 unsigned int *v12; // [sp+8h] [bp-18h]@3
15802 unsigned int v13; // [sp+Ch] [bp-14h]@8
15803 unsigned int v14; // [sp+10h] [bp-10h]@2
15804 unsigned int v15; // [sp+14h] [bp-Ch]@2
15805 unsigned int v16; // [sp+18h] [bp-8h]@2
15806 unsigned int v17; // [sp+1Ch] [bp-4h]@2
15807
15808 v1 = this;
15809 _443343();
15810 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
15811 {
15812 v16 = 0x40000000u;
15813 v14 = 0x40000000u;
15814 v17 = 0xC0000000u;
15815 v15 = 0xC0000000u;
15816 if ( (signed int)*pIndoor->pMapVertices > 0 )
15817 {
15818 v2 = (__int16 *)(pIndoor->pMapVertices + 1);
15819 v11 = *pIndoor->pMapVertices;
15820 v12 = pIndoor->pMapVertices + 1;
15821 do
15822 {
15823 v3 = &pIndoor->pVertices[*v2];
15824 v4 = v3->x;
15825 if ( (signed int)v4 < (signed int)v16 )
15826 v16 = v3->x;
15827 if ( (signed int)v4 > (signed int)v17 )
15828 v17 = v3->x;
15829 v5 = v3->y;
15830 v13 = v5;
15831 if ( v5 < (signed int)v14 )
15832 v14 = v4;
15833 if ( v5 > (signed int)v15 )
15834 v15 = v4;
15835 v6 = &pIndoor->pVertices[v2[1]];
15836 v7 = v6->x;
15837 if ( v7 < (signed int)v16 )
15838 v16 = v4;
15839 if ( v7 > (signed int)v17 )
15840 v17 = v4;
15841 v8 = v6->y;
15842 if ( v8 < (signed int)v14 )
15843 v14 = v13;
15844 if ( v8 > (signed int)v15 )
15845 v15 = v13;
15846 v2 = (__int16 *)(v12 + 3);
15847 v9 = v11-- == 1;
15848 v12 += 3;
15849 }
15850 while ( !v9 );
15851 }
15852 v1->uMinimapZoom = 1024;
15853 v1->field_38 = (signed int)(v16 + v17) / 2;
15854 v1->field_28 = 10;
15855 result = (signed int)(v14 + v15) / 2;
15856 v1->field_3A = result;
15857 }
15858 else
15859 {
15860 v1->field_38 = 0;
15861 v1->field_3A = 0;
15862 v1->uMinimapZoom = dword_576E2C;
15863 result = dword_576E28;
15864 v1->field_28 = dword_576E28;
15865 }
15866 v1->field_2C = 384;
15867 return result;
15868 }
15869
15870
15871 //----- (00443801) --------------------------------------------------------
15872 int __cdecl Initialize2DA()
15873 {
15874 const char *v0; // esi@3
15875 _2devent *v1; // edi@3
15876 char *v2; // esi@5
15877 int v3; // edx@5
15878 char v4; // cl@6
15879 int v5; // eax@6
15880 int v6; // ebx@10
15881 int v7; // eax@60
15882 int result; // eax@78
15883 signed int v9; // [sp+10h] [bp-8h]@5
15884 signed int v10; // [sp+14h] [bp-4h]@5
15885
15886 int it = 0;
15887
15888 if ( p2DEventsTXT_Raw )
15889 pAllocator->FreeChunk(p2DEventsTXT_Raw);
15890 p2DEventsTXT_Raw = 0;
15891 v0 = "\r";
15892 p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
15893 strtok(p2DEventsTXT_Raw, "\r");
15894 strtok(0, "\r");
15895 v1 = p2DEvents;
15896 while ( 1 )
15897 {
15898 v2 = strtok(0, v0) + 1;
15899 v10 = 0;
15900 v3 = -2;
15901 v9 = -2;
15902 do
15903 {
15904 v4 = *v2;
15905 v5 = 0;
15906 while ( v4 != 9 && v4 )
15907 {
15908 ++v5;
15909 v4 = v2[v5];
15910 }
15911 v6 = (int)&v2[v5];
15912 if ( !v2[v5] )
15913 v10 = 1;
15914 *(char *)v6 = 0;
15915 if ( v5 )
15916 {
15917 switch ( v3 )
15918 {
15919 case 0:
15920 if ( _strnicmp(v2, "wea", 3u) )
15921 {
15922 if ( _strnicmp(v2, "arm", 3u) )
15923 {
15924 if ( _strnicmp(v2, "mag", 3u) )
15925 {
15926 if ( _strnicmp(v2, "alc", 3u) )
15927 {
15928 if ( _strnicmp(v2, "sta", 3u) )
15929 {
15930 if ( _strnicmp(v2, "boa", 3u) )
15931 {
15932 if ( _strnicmp(v2, "tem", 3u) )
15933 {
15934 if ( _strnicmp(v2, "tra", 3u) )
15935 {
15936 if ( _strnicmp(v2, "tow", 3u) )
15937 {
15938 if ( _strnicmp(v2, "tav", 3u) )
15939 {
15940 if ( _strnicmp(v2, "ban", 3u) )
15941 {
15942 if ( _strnicmp(v2, "fir", 3u) )
15943 {
15944 if ( _strnicmp(v2, "air", 3u) )
15945 {
15946 if ( _strnicmp(v2, "wat", 3u) )
15947 {
15948 if ( _strnicmp(v2, "ear", 3u) )
15949 {
15950 if ( _strnicmp(v2, "spi", 3u) )
15951 {
15952 if ( _strnicmp(v2, "min", 3u) )
15953 {
15954 if ( _strnicmp(v2, "bod", 3u) )
15955 {
15956 if ( _strnicmp(v2, "lig", 3u) )
15957 {
15958 if ( _strnicmp(v2, "dar", 3u) )
15959 {
15960 if ( _strnicmp(v2, "ele", 3u) )
15961 {
15962 if ( _strnicmp(v2, "sel", 3u) )
15963 {
15964 if ( _strnicmp(v2, "mir", 3u) )
15965 {
15966 v7 = -(_strnicmp(v2, "mer", 3u) != 0);
15967 LOBYTE(v7) = v7 & 0xEE;
15968 v1->uType = v7 + 18;
15969 }
15970 else
15971 {
15972 v1->uType = 16;
15973 }
15974 }
15975 else
15976 {
15977 v1->uType = 15;
15978 }
15979 }
15980 else
15981 {
15982 v1->uType = 14;
15983 }
15984 }
15985 else
15986 {
15987 v1->uType = 13;
15988 }
15989 }
15990 else
15991 {
15992 v1->uType = 12;
15993 }
15994 }
15995 else
15996 {
15997 v1->uType = 11;
15998 }
15999 }
16000 else
16001 {
16002 v1->uType = 10;
16003 }
16004 }
16005 else
16006 {
16007 v1->uType = 9;
16008 }
16009 }
16010 else
16011 {
16012 v1->uType = 8;
16013 }
16014 }
16015 else
16016 {
16017 v1->uType = 7;
16018 }
16019 }
16020 else
16021 {
16022 v1->uType = 6;
16023 }
16024 }
16025 else
16026 {
16027 v1->uType = 5;
16028 }
16029 }
16030 else
16031 {
16032 v1->uType = 22;
16033 }
16034 }
16035 else
16036 {
16037 v1->uType = 21;
16038 }
16039 }
16040 else
16041 {
16042 v1->uType = 17;
16043 }
16044 }
16045 else
16046 {
16047 v1->uType = 30;
16048 }
16049 }
16050 else
16051 {
16052 v1->uType = 23;
16053 }
16054 }
16055 else
16056 {
16057 v1->uType = 28;
16058 }
16059 }
16060 else
16061 {
16062 v1->uType = 27;
16063 }
16064 }
16065 else
16066 {
16067 v1->uType = 4;
16068 }
16069 }
16070 else
16071 {
16072 v1->uType = 3;
16073 }
16074 }
16075 else
16076 {
16077 v1->uType = 2;
16078 }
16079 }
16080 else
16081 {
16082 v1->uType = 1;
16083 }
16084 break;
16085 case 2:
16086 v1->uAnimationID = atoi(v2);
16087 break;
16088 case 3:
16089 v1->pName = (char *)RemoveQuotes(v2);
16090 break;
16091 case 4:
16092 v1->pProprieterName = RemoveQuotes(v2);
16093 break;
16094 case 5:
16095 v1->pProprieterTitle = RemoveQuotes(v2);
16096 break;
16097 case 6:
16098 v1->field_14 = atoi(v2);
16099 break;
16100 case 7:
16101 v1->_state = atoi(v2);
16102 break;
16103 case 8:
16104 v1->_rep = atoi(v2);
16105 break;
16106 case 9:
16107 v1->_per = atoi(v2);
16108 break;
16109 case 10:
16110 v1->fPriceMultiplier = atof(v2);
16111 break;
16112 case 11:
16113 v1->flt_24 = atof(v2);
16114 break;
16115 case 13:
16116 v1->field_1C = atoi(v2);
16117 break;
16118 case 16:
16119 v1->uOpenTime = atoi(v2);
16120 break;
16121 case 17:
16122 v1->uCloseTime = atoi(v2);
16123 break;
16124 case 18:
16125 v1->uExitPicID = atoi(v2);
16126 break;
16127 case 19:
16128 v1->uExitMapID = atoi(v2);
16129 break;
16130 case 20:
16131 v1->_quest_related = atoi(v2);
16132 break;
16133 case 21:
16134 v1->pEnterText = RemoveQuotes(v2);
16135 break;
16136 default:
16137 break;
16138 }
16139 }
16140 v2 = (char *)(v6 + 1);
16141 v3 = v9 + 1;
16142 v9 = v3;
16143 result = v3 + 1;
16144 }
16145 while ( v3 + 1 <= 23 && !v10 );
16146 ++v1;
16147 //if ( (signed int)v1 >= (signed int)&unk_597F10 )
16148 if (++it >= 525)
16149 return result;
16150 v0 = "\r";
16151 }
16152 }
16153
16154 //----- (00443CE1) --------------------------------------------------------
16155 unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize)
16156 {
16157 const char *v3; // edi@1
16158 FILE *v4; // eax@1
16159 unsigned int v5; // esi@3
16160 char Args; // [sp+8h] [bp-B4h]@6
16161 //Texture DstBuf; // [sp+6Ch] [bp-50h]@1
16162 void *Dst; // [sp+B4h] [bp-8h]@1
16163 void *ptr; // [sp+B8h] [bp-4h]@1
16164
16165 v3 = pContainerName;
16166 Dst = a2;
16167 ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
16168
16169 Texture DstBuf; // [sp+6Ch] [bp-50h]@1
16170 //Texture::Texture(&DstBuf);
16171
16172 v4 = pEvents_LOD->FindContainer(v3, 0);
16173 if ( !v4 )
16174 Abortf("Unable to load %s", v3);
16175 fread(&DstBuf, 1u, 0x30u, v4);
16176 v5 = DstBuf.uDecompressedSize;
16177 if ( !DstBuf.uDecompressedSize )
16178 v5 = DstBuf.uTextureSize;
16179 memset(&DstBuf, 0, 0x48u);
16180 if ( (signed int)v5 >= (signed int)uBufferSize )
16181 {
16182 sprintfex(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
16183 Abortf(&Args);
16184 }
16185 memcpy(Dst, ptr, v5);
16186 pAllocator->FreeChunk(ptr);
16187 return v5;
16188 }
16189
16190 //----- (00443DA1) --------------------------------------------------------
16191 void __cdecl Initialize_GlobalEVT()
16192 {
16193 signed int v0; // esi@1
16194 unsigned int v1; // ecx@2
16195 char *v2; // eax@2
16196
16197 v0 = 0;
16198 uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT, 0xB400u);
16199 if ( uGlobalEVT_Size )
16200 {
16201 uGlobalEVT_NumEvents = 0;
16202 memset(pGlobalEVT_Events, 128, 0xCE40u);
16203 v1 = uGlobalEVT_NumEvents;
16204 v2 = (char *)&pGlobalEVT_Events[uGlobalEVT_NumEvents].field_4;
16205 do
16206 {
16207 ++v1;
16208 *((int *)v2 - 1) = (unsigned __int8)pGlobalEVT[v0 + 1] + ((unsigned __int8)pGlobalEVT[v0 + 2] << 8);
16209 *(int *)v2 = (unsigned __int8)pGlobalEVT[v0 + 3];
16210 *((int *)v2 + 1) = v0;
16211 v2 += 12;
16212 v0 += (unsigned __int8)pGlobalEVT[v0] + 1;
16213 }
16214 while ( v0 < (signed int)uGlobalEVT_Size );
16215 uGlobalEVT_NumEvents = v1;
16216 }
16217 }
16218
16219 //----- (00443E31) --------------------------------------------------------
16220 void __cdecl LoadLevel_InitializeLevelStr()
16221 {
16222 signed __int16 v0; // si@1
16223 unsigned int v1; // ecx@1
16224 signed int v2; // edi@1
16225 int v3; // edx@1
16226 int v4; // eax@2
16227 int v5; // ebx@4
16228 int v6; // ebx@11
16229 int v7; // eax@12
16230 unsigned int *v8; // edi@13
16231 char Args[100]; // [sp+Ch] [bp-68h]@9
16232 int v10; // [sp+70h] [bp-4h]@1
16233
16234 v0 = 0;
16235 memset(pLevelStrOffsets, 0, 0x7D0u);
16236 v1 = uLevelStrFileSize;
16237 v2 = 1;
16238 v3 = 0;
16239 v10 = 0;
16240 if ( (signed int)uLevelStrFileSize > 0 )
16241 {
16242 v4 = 0;
16243 do
16244 {
16245 if ( !pLevelStr[v4] )
16246 {
16247 v5 = (signed __int16)v2++;
16248 pLevelStrOffsets[v5] = v4 + 1;
16249 if ( (signed __int16)(v3 - (short)v10) > v0 )
16250 v0 = v3 - v10;
16251 v10 = v3;
16252 }
16253 ++v3;
16254 v4 = (signed __int16)v3;
16255 }
16256 while ( (signed __int16)v3 < (signed int)v1 );
16257 }
16258 uLevelStrNumStrings = (signed __int16)v2 - 1;
16259 if ( v0 > 800 )
16260 {
16261 sprintfex(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", v0 + 1);
16262 Abortf(Args);
16263 }
16264 v6 = 0;
16265 if ( (signed __int16)v2 - 1 > 0 )
16266 {
16267 v7 = 0;
16268 do
16269 {
16270 v8 = &pLevelStrOffsets[v7];
16271 if ( RemoveQuotes(&pLevelStr[*v8]) != &pLevelStr[*v8] )
16272 ++*v8;
16273 ++v6;
16274 v7 = (signed __int16)v6;
16275 }
16276 while ( (signed __int16)v6 < (signed int)uLevelStrNumStrings );
16277 }
16278 }
16279
16280 //----- (00443EF8) --------------------------------------------------------
16281 void __cdecl LoadLevel_InitializeLevelEvt()
16282 {
16283 int v0; // esi@1
16284 unsigned int v1; // edx@2
16285 int v2; // eax@2
16286 unsigned int v3; // ecx@2
16287
16288 v0 = 0;
16289 if ( uLevelEVT_Size )
16290 {
16291 memset(array_5B5928, 0, 0xC80u);
16292 uLevelEVT_NumEvents = 0;
16293 dword_5B65C8 = 0;
16294 memset(pLevelEVT_Events, 128, 0xCE40u);
16295 v1 = uLevelEVT_NumEvents;
16296 v2 = 0;
16297 v3 = 12 * uLevelEVT_NumEvents + 5989852;
16298 do
16299 {
16300 ++v1;
16301 *(int *)(v3 - 4) = (unsigned __int8)pLevelEVT[v2 + 1] + ((unsigned __int8)pLevelEVT[v2 + 2] << 8);
16302 *(int *)v3 = (unsigned __int8)pLevelEVT[v2 + 3];
16303 *(int *)(v3 + 4) = v2;
16304 LOWORD(v2) = (unsigned __int8)pLevelEVT[v2];
16305 v3 += 12;
16306 v0 += v2 + 1;
16307 v2 = (signed __int16)v0;
16308 }
16309 while ( (signed __int16)v0 < (signed int)uLevelEVT_Size );
16310 uLevelEVT_NumEvents = v1;
16311 }
16312 }
16313 // 5B65C8: using guessed type int dword_5B65C8;
16314
16315 //----- (00443F95) --------------------------------------------------------
16316 void __cdecl OnMapLeave()
16317 {
16318 signed int v0; // edi@1
16319 char *v1; // esi@2
16320 int v2; // ecx@4
16321
16322 v0 = 0;
16323 if ( (signed int)uLevelEVT_NumEvents > 0 )
16324 {
16325 v1 = (char *)&pLevelEVT_Events[0].field_4;
16326 do
16327 {
16328 if ( pLevelEVT[*((short *)v1 + 2) + 4] == 53 )
16329 {
16330 v2 = *((int *)v1 - 1);
16331 dword_597F18 = *(int *)v1;
16332 EventProcessor(v2, 0, 1);
16333 dword_597F18 = 0;
16334 }
16335 ++v0;
16336 v1 += 12;
16337 }
16338 while ( v0 < (signed int)uLevelEVT_NumEvents );
16339 }
16340 }
16341 // 597F18: using guessed type int dword_597F18;
16342
16343 //----- (00443FDC) --------------------------------------------------------
16344 void OnMapLoad()
16345 {
16346 signed __int64 v0; // qax@0
16347 int v1; // esi@1
16348 Event *v2; // ebx@2
16349 stru176 *v3; // esi@7
16350 __int16 v4; // cx@9
16351 __int16 v5; // di@9
16352 int v6; // eax@9
16353 int v7; // ecx@13
16354 signed __int64 v8; // qax@26
16355 unsigned int v9; // ecx@26
16356 signed __int64 v10; // qax@26
16357 signed __int64 v11; // qax@26
16358 int v12; // ST50_4@26
16359 signed __int64 v13; // qax@26
16360 signed __int64 v14; // qax@26
16361 int v15; // ST58_4@26
16362 signed __int64 v16; // qax@26
16363 int v17; // ebx@26
16364 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
16365 signed __int64 v19; // [sp+14h] [bp-3Ch]@26
16366 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
16367 Event *v21; // [sp+28h] [bp-28h]@2
16368 int v22; // [sp+2Ch] [bp-24h]@26
16369 signed int v23; // [sp+30h] [bp-20h]@1
16370 int v24; // [sp+34h] [bp-1Ch]@26
16371 int v25; // [sp+38h] [bp-18h]@26
16372 int v26; // [sp+3Ch] [bp-14h]@15
16373 int v27; // [sp+3Ch] [bp-14h]@26
16374 int v28; // [sp+40h] [bp-10h]@26
16375 __int16 v29; // [sp+46h] [bp-Ah]@9
16376 __int16 v30; // [sp+48h] [bp-8h]@9
16377 __int16 v31; // [sp+4Ah] [bp-6h]@9
16378 __int16 v32; // [sp+4Ch] [bp-4h]@9
16379 __int16 v33; // [sp+4Eh] [bp-2h]@9
16380
16381 v1 = 0;
16382 v23 = 0;
16383 if ( (signed int)uLevelEVT_NumEvents > 0 )
16384 {
16385 v2 = pLevelEVT_Events;
16386 v21 = pLevelEVT_Events;
16387 while ( 1 )
16388 {
16389 LODWORD(v0) = LOWORD(v2->uEventOffsetInEVT);
16390 if ( (unsigned __int8)pLevelEVT[(int)v0 + 4] == 3 )
16391 {
16392 pSoundList->_4A9A67(
16393 (unsigned __int8)pLevelEVT[(int)v0 + 5]
16394 + (((unsigned __int8)pLevelEVT[(int)v0 + 6]
16395 + (((unsigned __int8)pLevelEVT[(int)v0 + 7] + ((unsigned __int8)pLevelEVT[(int)v0 + 8] << 8)) << 8)) << 8),
16396 v1);
16397 goto LABEL_36;
16398 }
16399 if ( (unsigned __int8)pLevelEVT[(int)v0 + 4] == 31 )
16400 break;
16401 if ( (unsigned __int8)pLevelEVT[(int)v0 + 4] == 37 )
16402 {
16403 v7 = v2->uEventID;
16404 dword_597F18 = v2->field_4;
16405 EventProcessor(v7, 0, v1);
16406 dword_597F18 = v1;
16407 }
16408 else
16409 {
16410 if ( (unsigned __int8)pLevelEVT[(int)v0 + 4] == 38 )
16411 break;
16412 }
16413 LABEL_36:
16414 ++v23;
16415 ++v2;
16416 v21 = v2;
16417 if ( v23 >= (signed int)uLevelEVT_NumEvents )
16418 return;
16419 }
16420 v20 = pOutdoor->uLastVisitDay;
16421 v3 = &array_5B5928[dword_5B65C8];
16422 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
16423 v20 = pIndoor->uLastVisitDay;
16424 v4 = (unsigned __int8)pLevelEVT[(int)v0 + 4];
16425 WORD2(v0) = LOWORD(v2->uEventID);
16426 *(short *)&v3->field_18[4] = v4;
16427 v3->field_8 = WORD2(v0);
16428 v3->field_A = LOWORD(v2->field_4);
16429 v33 = (unsigned __int8)pLevelEVT[(int)v0 + 6];
16430 v3->field_12 = v33;
16431 v32 = (unsigned __int8)pLevelEVT[(int)v0 + 7];
16432 v3->field_14 = v32;
16433 v31 = (unsigned __int8)pLevelEVT[(int)v0 + 8];
16434 v3->field_16 = v31;
16435 v5 = (unsigned __int8)pLevelEVT[(int)v0 + 5];
16436 v30 = (unsigned __int8)pLevelEVT[(int)v0 + 9];
16437 *(short *)&v3->field_18[0] = v30;
16438 v29 = (unsigned __int8)pLevelEVT[(int)v0 + 10];
16439 *(short *)&v3->field_18[2] = v29;
16440 WORD2(v0) = (unsigned __int8)pLevelEVT[(int)v0 + 12];
16441 LOWORD(v0) = (unsigned __int8)pLevelEVT[(int)v0 + 11];
16442 v6 = (HIDWORD(v0) << 8) + v0;
16443 v3->field_10 = v5;
16444 v3->field_C = v6;
16445 v3->field_E = v6;
16446 if ( v4 == 38 && !(short)v6 )
16447 {
16448 if ( v20 )
16449 v18 = pParty->uTimePlayed - v20;
16450 else
16451 v18 = 0i64;
16452 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
16453 HIDWORD(v0) = v26 / 7 / 4 % 12;
16454 if ( v26 / 7 / 4 / 12 )
16455 {
16456 LODWORD(v0) = 0;
16457 if ( v5 )
16458 {
16459 LABEL_25:
16460 v3->field_4 = v0;
16461 LABEL_34:
16462 ++dword_5B65C8;
16463 v3->field_0 = v0;
16464 v1 = 0;
16465 goto LABEL_36;
16466 }
16467 }
16468 else
16469 {
16470 LODWORD(v0) = 0;
16471 }
16472 if ( v26 / 7 / 4 != (int)v0 && v33 != (short)v0
16473 || v26 / 7 != (int)v0 && v32 != (short)v0
16474 || v26 != (int)v0
16475 || !v20 )
16476 goto LABEL_25;
16477 }
16478 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
16479 v9 = v8;
16480 v10 = (signed int)v8 / 60;
16481 v22 = v10 % 60;
16482 v11 = (signed int)(v10 / 60);
16483 v12 = v11 % 24;
16484 v13 = (signed int)(v11 / 24);
16485 v27 = v13 % 7;
16486 v14 = (signed int)(v13 / 7);
16487 v15 = v14 % 4;
16488 v16 = (signed int)(v14 / 4);
16489 v24 = v16 / 12;
16490
16491 auto _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
16492 auto _2 = ((__int64)v9 << 32) | _1;
16493 v19 = _2 % 60;
16494 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
16495 // v9)
16496 // % 60;
16497 v17 = v12;
16498 v25 = v15;
16499 v28 = v16 % 12;
16500 if ( v5 )
16501 {
16502 ++v24;
16503 }
16504 else
16505 {
16506 if ( v33 )
16507 {
16508 ++v28;
16509 }
16510 else
16511 {
16512 if ( v32 )
16513 {
16514 ++v25;
16515 }
16516 else
16517 {
16518 ++v27;
16519 v22 = v30;
16520 v17 = v31;
16521 v19 = v29;
16522 }
16523 }
16524 }
16525 v0 = (signed __int64)((double)((v19
16526 + 0x3C * v22
16527 + 0xE10 * v17
16528 + 0x93A80 * v25
16529 + 0x15180 * v27
16530 + 0x24EA00 * (v28 + 12i64 * v24)) << 7)
16531 * 0.033333335);
16532 v2 = v21;
16533 v3->field_4 = HIDWORD(v0);
16534 goto LABEL_34;
16535 }
16536 }
16537 // 597F18: using guessed type int dword_597F18;
16538 // 5B65C8: using guessed type int dword_5B65C8;
16539
16540 //----- (00444360) --------------------------------------------------------
16541 void __thiscall Level_LoadEvtAndStr(const char *pLevelName)
16542 {
16543 const char *v1; // edi@1
16544 char pContainerName[120]; // [sp+8h] [bp-98h]@1
16545
16546 v1 = pLevelName;
16547 sprintfex(pContainerName, "%s.evt", pLevelName);
16548 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT, 0x2400u);
16549 sprintfex(pContainerName, "%s.str", v1);
16550 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr, 0x2400u);
16551 if ( uLevelStrFileSize )
16552 LoadLevel_InitializeLevelStr();
16553 }
16554
16555 //----- (004443D5) --------------------------------------------------------
16556 char *__cdecl _4443D5_GetMinimapRightClickText()
16557 {
16558 int v0; // ST20_4@1
16559 unsigned int v1; // esi@1
16560 signed int v2; // ebx@1
16561 double v3; // st7@1
16562 int v4; // esi@3
16563 int v5; // edi@4
16564 int v6; // eax@4
16565 int v7; // eax@4
16566 BSPModel *v8; // ecx@4
16567 unsigned __int8 v9; // zf@5
16568 char v10; // sf@5
16569 unsigned __int8 v11; // of@5
16570 ODMFace *v12; // eax@6
16571 __int16 v13; // cx@6
16572 const char *v14; // eax@8
16573 const char *v15; // edi@8
16574 char *result; // eax@12
16575 unsigned int v17; // eax@14
16576 unsigned int v18; // [sp+Ch] [bp-20h]@1
16577 int v19; // [sp+10h] [bp-1Ch]@1
16578 int v20; // [sp+14h] [bp-18h]@1
16579 char *v21; // [sp+18h] [bp-14h]@1
16580 unsigned int pY; // [sp+1Ch] [bp-10h]@1
16581 int v23; // [sp+20h] [bp-Ch]@1
16582 int v24; // [sp+24h] [bp-8h]@1
16583 int pX; // [sp+28h] [bp-4h]@1
16584
16585 v24 = pParty->vPosition.x;
16586 v0 = pParty->vPosition.z;
16587 v1 = pOutdoor->uNumBModels;
16588 *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789;
16589 v2 = 0;
16590 v18 = pOutdoor->uNumBModels;
16591 v21 = 0;
16592 pMouse->GetClickPos((unsigned int *)&pX, &pY);
16593 v3 = 1.0 / *(float *)&v23;
16594 v23 = pX - 557;
16595 v19 = (signed __int64)((double)(pX - 557) * v3 + (double)v24);
16596 v20 = (signed __int64)((double)v0 - (double)(signed int)(pY - 74) * v3);
16597 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || (*(float *)&v23 = 0.0, (signed int)v1 <= 0) )
16598 {
16599 LABEL_14:
16600 v17 = pMapStats->GetMapInfo(pCurrentMapName);
16601 if ( v17 == v2 )
16602 result = "No Maze Info for this maze on file!";
16603 else
16604 result = pMapStats->pInfos[v17].pName;
16605 }
16606 else
16607 {
16608 v4 = 0;
16609 while ( 1 )
16610 {
16611 pX = pOutdoor->pBModels[v4].vBoundingCenter.x - v19;
16612 pY = pOutdoor->pBModels[v4].vBoundingCenter.y - v20;
16613 v5 = abs((signed)pY);
16614 v6 = abs((signed)pX);
16615 v7 = sub_4621DA(v6, v5, v2);
16616 v8 = pOutdoor->pBModels;
16617 if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius )
16618 {
16619 v11 = __OFSUB__(pOutdoor->pBModels[v4].uNumFaces, v2);
16620 v9 = pOutdoor->pBModels[v4].uNumFaces == v2;
16621 v10 = ((pOutdoor->pBModels[v4].uNumFaces - v2) & 0x80000000u) != 0;
16622 v24 = v2;
16623 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
16624 {
16625 do
16626 {
16627 v12 = &v8[v4].pFaces[v2 / 0x134u];
16628 v13 = v12->sCogTriggeredID;
16629 if ( v13 )
16630 {
16631 if ( !(BYTE2(v12->uFaceAttributes) & 0x10) )
16632 {
16633 v14 = _444732_GetEventHintString(v13);
16634 v15 = v14;
16635 if ( v14 )
16636 {
16637 if ( _strcmpi(v14, nullstring) )
16638 v21 = (char *)v15;
16639 }
16640 }
16641 }
16642 ++v24;
16643 v8 = pOutdoor->pBModels;
16644 v2 += 308;
16645 }
16646 while ( v24 < (signed int)pOutdoor->pBModels[v4].uNumFaces );
16647 }
16648 result = v21;
16649 v2 = 0;
16650 if ( v21 )
16651 break;
16652 }
16653 ++v23;
16654 ++v4;
16655 if ( v23 >= (signed int)v18 )
16656 goto LABEL_14;
16657 }
16658 }
16659 return result;
16660 }
16661
16662 //----- (00444564) --------------------------------------------------------
16663 const char *__cdecl sub_444564()
16664 {
16665 double v0; // st7@3
16666 int v1; // ebx@3
16667 int v2; // edi@3
16668 int v3; // eax@3
16669 int v4; // esi@5
16670 int v5; // edi@6
16671 int v6; // eax@6
16672 int v7; // eax@6
16673 BSPModel *v8; // ecx@6
16674 unsigned __int8 v9; // zf@7
16675 unsigned __int8 v10; // sf@7
16676 ODMFace *v11; // eax@9
16677 __int16 v12; // cx@9
16678 const char *v13; // eax@11
16679 const char *v14; // edi@11
16680 const char *result; // eax@15
16681 unsigned int v16; // [sp+0h] [bp-20h]@3
16682 const char *v17; // [sp+4h] [bp-1Ch]@3
16683 unsigned int pY; // [sp+8h] [bp-18h]@3
16684 float v19; // [sp+Ch] [bp-14h]@1
16685 int v20; // [sp+10h] [bp-10h]@1
16686 int v21; // [sp+14h] [bp-Ch]@1
16687 unsigned int v22; // [sp+18h] [bp-8h]@8
16688 int pX; // [sp+1Ch] [bp-4h]@3
16689
16690 v20 = viewparams->sPartyPosX;
16691 v21 = viewparams->sPartyPosZ;
16692 v19 = (double)viewparams->field_2C * 0.000015258789;
16693 if ( viewparams->field_2C == 384 )
16694 {
16695 v20 = viewparams->field_38;
16696 v21 = viewparams->field_3A;
16697 }
16698 v17 = 0;
16699 v16 = pOutdoor->uNumBModels;
16700 pMouse->GetClickPos((unsigned int *)&pX, &pY);
16701 v0 = 1.0 / v19;
16702 v1 = (signed __int64)((double)(pX - 229) * v0 + (double)v20);
16703 LODWORD(v19) = (signed __int64)((double)v21 - (double)(signed int)(pY - 181) * v0);
16704 v2 = abs(v1 + 22528) / 512;
16705 v3 = abs((signed)LODWORD(v19) - 22528);
16706 if ( pOutdoor->_47F04C(v2, v3 / 512)
16707 && uCurrentlyLoadedLevelType == LEVEL_Outdoor
16708 && (v4 = 0, v20 = 0, (signed int)v16 > 0) )
16709 {
16710 while ( 1 )
16711 {
16712 pX = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.x + v4) - v1;
16713 pY = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.y + v4) - LODWORD(v19);
16714 v5 = abs((signed)pY);
16715 v6 = abs((signed)pX);
16716 v7 = sub_4621DA(v6, v5, 0);
16717 v8 = pOutdoor->pBModels;
16718 if ( v7 < *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v4) )
16719 {
16720 v9 = *(unsigned int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) == 0;
16721 v10 = *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) < 0;
16722 v21 = 0;
16723 if ( !(v10 | v9) )
16724 {
16725 v22 = 0;
16726 do
16727 {
16728 v11 = &(*(ODMFace **)((char *)&v8->pFaces + v4))[v22 / 0x134];
16729 v12 = v11->sCogTriggeredID;
16730 if ( v12 )
16731 {
16732 if ( !(BYTE2(v11->uFaceAttributes) & 0x10) )
16733 {
16734 v13 = _444732_GetEventHintString(v12);
16735 v14 = v13;
16736 if ( v13 )
16737 {
16738 if ( _strcmpi(v13, nullstring) )
16739 v17 = v14;
16740 }
16741 }
16742 }
16743 ++v21;
16744 v8 = pOutdoor->pBModels;
16745 v22 += 308;
16746 }
16747 while ( v21 < *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) );
16748 }
16749 result = v17;
16750 if ( v17 )
16751 break;
16752 }
16753 ++v20;
16754 v4 += 188;
16755 if ( v20 >= (signed int)v16 )
16756 goto LABEL_17;
16757 }
16758 }
16759 else
16760 {
16761 LABEL_17:
16762 result = 0;
16763 }
16764 return result;
16765 }
16766
16767
16768
16769
16770 //----- (00444A51) --------------------------------------------------------
16771 char *__cdecl TransitionUI_Draw()
16772 {
16773 MapInfo *v0; // esi@5
16774 char *v1; // eax@6
16775 char *result; // eax@12
16776 std::string v3; // [sp-18h] [bp-84h]@11
16777 unsigned int v4; // [sp-10h] [bp-7Ch]@12
16778 int v5; // [sp-Ch] [bp-78h]@12
16779 const char *v6; // [sp-8h] [bp-74h]@11
16780 signed int v7; // [sp-4h] [bp-70h]@11
16781 GUIWindow v8; // [sp+Ch] [bp-60h]@1
16782 unsigned int v9; // [sp+60h] [bp-Ch]@1
16783 unsigned int v10; // [sp+64h] [bp-8h]@1
16784 int a3; // [sp+6Bh] [bp-1h]@11
16785
16786 memcpy(&v8, pGUIWindow0, sizeof(v8));
16787 v10 = pMapStats->GetMapInfo(pCurrentMapName);
16788 v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
16789 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
16790 pRenderer->DrawTextureIndexed(
16791 _4E5E50_transui_x - 4,
16792 _4E5EE0_transui_y - 4,
16793 (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
16794 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pTexture_outside);
16795 uTextureID_507B04 = uTextureID_right_panel;
16796 pRenderer->DrawTextureTransparent(
16797 0x1D4u,
16798 0,
16799 (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
16800 pRenderer->DrawTextureIndexed(
16801 0x22Cu,
16802 0x1C3u,
16803 (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
16804 pRenderer->DrawTextureIndexed(
16805 0x1DCu,
16806 0x1C3u,
16807 (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0));
16808 if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != 48 )
16809 v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name);
16810 v0 = &pMapStats->pInfos[v10];
16811 v8.uFrameX = 493;
16812 v8.uFrameWidth = 126;
16813 v8.uFrameZ = 366;
16814 v8.DrawText2(pFontCreate, 0, 5u, 0, v0->pName, 3u);
16815 v8.uFrameX = 483;
16816 v8.uFrameWidth = 148;
16817 v8.uFrameZ = 334;
16818 if ( uCurrentHouse_Animation )
16819 {
16820 v1 = (&off_4EB080)[4 * uCurrentHouse_Animation];
16821 }
16822 else
16823 {
16824 if ( v10 )
16825 {
16826 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[409], v0->pName);// "Do you wish to leave %s?"
16827 v1 = pTmpBuf;
16828 goto LABEL_12;
16829 }
16830 v1 = nullstring;
16831 }
16832 if ( !v1 )
16833 {
16834 MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0);
16835 v1 = nullstring;
16836 }
16837 LABEL_12:
16838 v7 = 3;
16839 v6 = v1;
16840 v5 = 0;
16841 v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101;
16842 result = v8.DrawText2(pFontCreate, 0, v4, v5, v6, v7);
16843 dword_5B5924 = 1;
16844 return result;
16845 }
16846
16847
16848 //----- (00444C8F) --------------------------------------------------------
16849 GUIWindow *__cdecl UI_CreateTravelDialogue()
16850 {
16851 signed int v0; // eax@1
16852 unsigned int v1; // eax@6
16853 GUIWindow *result; // eax@9
16854 const char *v3; // [sp-4h] [bp-2Ch]@2
16855 char pContainer[32]; // [sp+0h] [bp-28h]@1
16856
16857 pEventTimer->Pause();
16858 v0 = const_2();
16859 sprintfex(pContainer, "evt%02d", v0);
16860 if ( pParty->uAlignment )
16861 {
16862 if ( pParty->uAlignment != 2 )
16863 goto LABEL_6;
16864 v3 = "-c";
16865 }
16866 else
16867 {
16868 v3 = "-b";
16869 }
16870 strcat(pContainer, v3);
16871 LABEL_6:
16872 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
16873 pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
16874 v1 = pMapStats->GetMapInfo(pCurrentMapName);
16875 if ( v1 )
16876 sprintfex(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
16877 else
16878 strcpy(byte_591098, pGlobalTXT_LocalizationStrings[79]);// "Exit"
16879 result = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, (enum WindowType)17, 0, (int)byte_591098);
16880 pDialogueWindow = result;
16881 return result;
16882 }
16883
16884 //----- (00444D80) --------------------------------------------------------
16885 signed int __cdecl GetTravelTime()
16886 {
16887 signed int v0; // esi@1
16888
16889 v0 = uDefaultTravelTime_ByFoot;
16890 if ( CheckHiredNPCSpeciality(5u) )
16891 --v0;
16892 if ( CheckHiredNPCSpeciality(6u) )
16893 v0 -= 2;
16894 if ( CheckHiredNPCSpeciality(7u) )
16895 v0 -= 3;
16896 if ( CheckHiredNPCSpeciality(0x2Cu) )
16897 --v0;
16898 if ( v0 < 1 )
16899 v0 = 1;
16900 return v0;
16901 }
16902 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
16903
16904 //----- (00444DCA) --------------------------------------------------------
16905 void __cdecl TravelUI_Draw()
16906 {
16907 unsigned int v0; // edi@1
16908 MapInfo *v1; // edi@2
16909 char *v2; // ST14_4@2
16910 signed int v3; // eax@2
16911 int v4; // eax@5
16912 const char *v5; // [sp-Ch] [bp-90h]@3
16913 signed int v6; // [sp-8h] [bp-8Ch]@3
16914 GUIWindow v7; // [sp+Ch] [bp-78h]@1
16915 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1
16916 unsigned int v9; // [sp+80h] [bp-4h]@1
16917
16918 memcpy(&v7, pGUIWindow0, sizeof(v7));
16919 v9 = pMapStats->GetMapInfo(pCurrentMapName);
16920 pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, pDestinationMapName, 20);
16921 v0 = pMapStats->GetMapInfo(pDestinationMapName);
16922 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
16923 pRenderer->DrawTextureTransparent(0x1D4u, 0,
16924 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
16925 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pTexture_outside);
16926 pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u,
16927 (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
16928 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u,
16929 (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0));
16930 if ( v0 )
16931 {
16932 v1 = &pMapStats->pInfos[v0];
16933 v7.uFrameX = 493;
16934 v7.uFrameWidth = 126;
16935 v2 = v1->pName;
16936 v7.uFrameZ = 366;
16937 v7.DrawText2(pFontCreate, 0, 4u, 0, v2, 3u);
16938 v7.uFrameX = 483;
16939 v7.uFrameWidth = 148;
16940 v7.uFrameZ = 334;
16941 v3 = GetTravelTime();
16942 if ( v3 == 1 )
16943 {
16944 v6 = 1;
16945 v5 = pGlobalTXT_LocalizationStrings[663]; // "It will take %d day to cross to %s."
16946 }
16947 else
16948 {
16949 v6 = v3;
16950 v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s."
16951 }
16952 sprintfex(pTmpBuf, v5, v6, v1->pName);
16953 strcat(pTmpBuf, "\n \n");
16954 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName);
16955 strcat(pTmpBuf, pTmpBuf2);
16956 v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0);
16957 v7.DrawText2(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u);
16958 dword_5B5924 = 1;
16959 }
16960 }
16961
16962
16963 //----- (00444FBE) --------------------------------------------------------
16964 void __cdecl DrawBranchlessDialogueUI()
16965 {
16966 GUIFont *v0; // esi@1
16967 int v1; // esi@4
16968 char *v2; // eax@6
16969 int v3; // edi@12
16970 char Str[200]; // [sp+Ch] [bp-120h]@12
16971 GUIWindow v5; // [sp+D4h] [bp-58h]@4
16972 GUIFont *pFont; // [sp+128h] [bp-4h]@1
16973
16974 v0 = pFontArrus;
16975 pFont = pFontArrus;
16976 if ( ptr_F8B1E8 && !byte_5B0938[0] )
16977 strcpy(byte_5B0938, ptr_F8B1E8);
16978 v5.uFrameWidth = 460;
16979 v5.uFrameZ = 452;
16980 v1 = pFontArrus->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7;
16981 if ( 352 - v1 < 8 )
16982 {
16983 pFont = pFontCreate;
16984 v1 = pFontCreate->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7;
16985 }
16986 pRenderer->_4A6A68(
16987 8u,
16988 352 - v1,
16989 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
16990 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v1);
16991 pRenderer->DrawTextureIndexed(8u, 347 - v1, pTexture_591428);
16992 v2 = FitTextInAWindow(byte_5B0938, pFont, &v5, 0xCu, 0);
16993 pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0);
16994 pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
16995 if ( pGUIWindow2->field_40 != 1 )
16996 {
16997 if ( pGUIWindow2->field_40 == 2 )
16998 {
16999 pGUIWindow2->field_40 = 0;
17000 strcpy(GameUI_StatusBar_TimedString, (const char *)pKeyActionMap->pPressedKeysBuffer);
17001 LABEL_16:
17002 sub_4452BB();
17003 return;
17004 }
17005 if ( pGUIWindow2->field_40 != 3 )
17006 return;
17007 pGUIWindow2->field_40 = 0;
17008 LABEL_15:
17009 memset(GameUI_StatusBar_TimedString, 0, 0xC8u);
17010 goto LABEL_16;
17011 }
17012 if ( pGUIWindow2->ptr_1C == (void *)26 )
17013 {
17014 sprintfex(Str, "%s %s", GameUI_StatusBar_TimedString, pKeyActionMap->pPressedKeysBuffer);
17015 v3 = pFontLucida->GetLineWidth(Str);
17016 pGUIWindow2->DrawText(pFontLucida, 13, 357, 0, Str, 0, 0, 0);
17017 pGUIWindow2->DrawFlashingInputCursor(v3 + 13, 357, pFontLucida);
17018 return;
17019 }
17020 if ( pKeyActionMap->pPressedKeysBuffer[0] )
17021 {
17022 pKeyActionMap->_459ED1(0);
17023 goto LABEL_15;
17024 }
17025 }
17026
17027 //----- (004451A8) --------------------------------------------------------
17028 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
17029 {
17030 int v3; // esi@1
17031 int v4; // edi@1
17032
17033 v3 = a2;
17034 v4 = a1;
17035 if ( !pGUIWindow2 )
17036 {
17037 if ( pParty->uFlags & 2 )
17038 pGame->Draw();
17039 if ( !dword_597F18 )
17040 pAudioPlayer->StopChannels(-1, -1);
17041 pMiscTimer->Pause();
17042 pEventTimer->Pause();
17043 dword_5C3418 = v4;
17044 dword_5C341C = v3;
17045 _591094_decoration = _5C3420_pDecoration;
17046 pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0);
17047 pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
17048 pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
17049 pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
17050 pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
17051 }
17052 }
17053
17054 //----- (004452BB) --------------------------------------------------------
17055 void __cdecl sub_4452BB()
17056 {
17057 pGUIWindow2->Release();
17058 pGUIWindow2 = 0;
17059 _5C3420_pDecoration = _591094_decoration;
17060 dword_597F18 = dword_5C341C;
17061 EventProcessor(dword_5C3418, 0, 1);
17062 dword_597F18 = 0;
17063 _5C3420_pDecoration = 0;
17064 pEventTimer->Resume();
17065 }
17066
17067
17068 //----- (00445308) --------------------------------------------------------
17069 int __fastcall sub_445308(int a1)
17070 {
17071 int result; // eax@12
17072
17073 if ( a1 == 10
17074 || a1 == 11
17075 || a1 == 12
17076 || a1 == 33
17077 || a1 == 34
17078 || a1 == 39
17079 || a1 == 40
17080 || a1 == 41
17081 || a1 == 42
17082 || a1 == 43
17083 || a1 == 52 )
17084 result = *(&pNPCStats->field_13A60 + 5 * a1);
17085 else
17086 result = dword_722320;
17087 return result;
17088 }
17089 // 722320: using guessed type int dword_722320;
17090
17091 //----- (00445350) --------------------------------------------------------
17092 void __cdecl DrawDialogueUI()
17093 {
17094 NPCData *v0; // ebx@2
17095 int v1; // eax@2
17096 unsigned __int16 v2; // di@2
17097 unsigned int v3; // eax@2
17098 char *v4; // esi@3
17099 int v5; // eax@11
17100 char *v6; // ecx@13
17101 char *v7; // eax@16
17102 unsigned int v8; // edi@19
17103 char *v9; // ecx@27
17104 char *v10; // eax@29
17105 int v11; // eax@30
17106 int v12; // esi@39
17107 char *v13; // eax@41
17108 GUIButton *v14; // eax@43
17109 GUIButton *v15; // edi@43
17110 signed int v16; // eax@44
17111 int v17; // eax@46
17112 int v18; // eax@47
17113 int v19; // eax@48
17114 int v20; // eax@49
17115 int v21; // eax@50
17116 int v22; // eax@51
17117 unsigned int v23; // eax@53
17118 const char *v24; // eax@59
17119 int v25; // eax@65
17120 int v26; // eax@66
17121 int v27; // eax@67
17122 int v28; // eax@68
17123 int v29; // eax@69
17124 unsigned __int16 v30; // cx@83
17125 int v31; // ecx@86
17126 int v32; // ebx@93
17127 unsigned int v33; // eax@93
17128 GUIWindow *v34; // ecx@93
17129 int v35; // esi@93
17130 int i; // eax@93
17131 GUIButton *v37; // eax@94
17132 int v38; // eax@95
17133 signed int v39; // esi@99
17134 signed int v40; // eax@102
17135 unsigned int v41; // ebx@102
17136 int v42; // edi@102
17137 GUIButton *v43; // esi@103
17138 int v44; // eax@104
17139 unsigned int v45; // ecx@104
17140 unsigned __int16 *v46; // edx@104
17141 unsigned __int16 v47; // ax@104
17142 char pFont; // [sp+4h] [bp-110h]@39
17143 int v49; // [sp+Ch] [bp-108h]@39
17144 int v50; // [sp+14h] [bp-100h]@39
17145 GUIWindow v51; // [sp+58h] [bp-BCh]@2
17146 GUIWindow v52; // [sp+ACh] [bp-68h]@42
17147 char *Str; // [sp+100h] [bp-14h]@104
17148 __int16 v54[2]; // [sp+104h] [bp-10h]@2
17149 unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82
17150 GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39
17151 char *pInString; // [sp+110h] [bp-4h]@32
17152
17153 if ( !pDialogueWindow )
17154 return;
17155 memcpy(&v51, pDialogueWindow, sizeof(v51));
17156 v0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
17157 v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID);
17158 v51.uFrameWidth -= 10;
17159 v51.uFrameZ -= 10;
17160 *(int *)v54 = v1;
17161 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
17162 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
17163 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
17164 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
17165 pRenderer->DrawTextureTransparent(
17166 0x1D4u,
17167 0,
17168 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
17169 pRenderer->DrawTextureIndexed(
17170 _4E5E50_transui_x - 4,
17171 _4E5EE0_transui_y - 4,
17172 (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
17173 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pDialogueNPCPortraits[0]);
17174 v3 = v0->uProfession;
17175 if ( v3 )
17176 {
17177 v4 = pTmpBuf;
17178 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v0->pName, aNPCProfessionNames[v3]);
17179 }
17180 else
17181 {
17182 strcpy(pTmpBuf, v0->pName);
17183 v4 = pTmpBuf;
17184 }
17185 v51.DrawText2(pFontArrus, 0x1E3u, 0x70u, v2, v4, 3u);
17186 pParty->GetPartyFame();
17187 if ( (signed int)uDialogueType > 89 )
17188 {
17189 if ( uDialogueType == 90 )
17190 {
17191 v7 = pGlobalTXT_LocalizationStrings[577]; // "Get back in there you wimps:"
17192 goto LABEL_37;
17193 }
17194 if ( uDialogueType == 91 )
17195 {
17196 sprintfex(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
17197 pInString = v4;
17198 v8 = 0;
17199 goto LABEL_39;
17200 }
17201 if ( uDialogueType == 92 )
17202 {
17203 v7 = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
17204 goto LABEL_37;
17205 }
17206 }
17207 else
17208 {
17209 if ( uDialogueType == 89 )
17210 {
17211 v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:"
17212 goto LABEL_37;
17213 }
17214 if ( uDialogueType == 13 )
17215 {
17216 v5 = 5 * v0->uProfession;
17217 goto LABEL_18;
17218 }
17219 if ( (signed int)uDialogueType > 18 )
17220 {
17221 if ( (signed int)uDialogueType > 24 )
17222 {
17223 if ( uDialogueType == 77 )
17224 {
17225 v5 = 5 * v0->uProfession;
17226 if ( byte_F8B1EC )
17227 {
17228 v6 = (char *)*(&pNPCStats->field_13A5C + 5 * v0->uProfession);
17229 goto LABEL_19;
17230 }
17231 if ( v0->uFlags & 0x80 )
17232 {
17233 v6 = (char *)*(&pNPCStats->field_13A68 + 5 * v0->uProfession);
17234 LABEL_19:
17235 v8 = 0;
17236 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
17237 LABEL_38:
17238 pInString = v7;
17239 goto LABEL_39;
17240 }
17241 LABEL_18:
17242 v6 = (char *)*(&pNPCStats->field_13A64 + v5);
17243 goto LABEL_19;
17244 }
17245 goto LABEL_24;
17246 }
17247 if ( byte_5B0938[0] )
17248 goto LABEL_24;
17249 v7 = ptr_F8B1E8;
17250 LABEL_37:
17251 v8 = 0;
17252 goto LABEL_38;
17253 }
17254 }
17255 LABEL_24:
17256 if ( *(int *)v54 == 1 )
17257 {
17258 v11 = v0->greet;
17259 v8 = 0;
17260 if ( v11 )
17261 {
17262 v10 = (char *)*(&pNPCStats->field_17884 + ((v0->uFlags & 3) == 2) + 2 * v11);
17263 goto LABEL_32;
17264 }
17265 }
17266 else
17267 {
17268 if ( *(int *)v54 == 2 )
17269 {
17270 v8 = 0;
17271 if ( v0->uFlags & 0x80 )
17272 v9 = (char *)*(&pNPCStats->field_13A68 + 5 * v0->uProfession);
17273 else
17274 v9 = (char *)*(&pNPCStats->field_13A64 + 5 * v0->uProfession);
17275 v10 = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
17276 LABEL_32:
17277 pInString = v10;
17278 if ( v10 == (char *)v8 )
17279 goto LABEL_42;
17280 LABEL_39:
17281 v49 = 460;
17282 v50 = 452;
17283 pOutString = pFontArrus;
17284 v12 = pFontArrus->CalcTextHeight(pInString, (GUIWindow *)&pFont, 13, v8) + 7;
17285 if ( 352 - v12 < 8 )
17286 {
17287 pOutString = pFontCreate;
17288 v12 = pFontCreate->CalcTextHeight(pInString, (GUIWindow *)&pFont, 13, v8) + 7;
17289 }
17290 pRenderer->_4A6A68(
17291 8u,
17292 352 - v12,
17293 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
17294 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
17295 pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
17296 v13 = FitTextInAWindow(pInString, pOutString, (GUIWindow *)&pFont, 0xDu, v8);
17297 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
17298 goto LABEL_42;
17299 }
17300 }
17301 LABEL_42:
17302 memcpy(&v52, pDialogueWindow, sizeof(v52));
17303 v52.uFrameX = 483;
17304 v52.uFrameWidth = 148;
17305 v52.uFrameZ = 334;
17306 for ( pOutString = (GUIFont *)v52.field_38;
17307 (signed int)pOutString < v52.field_38 + v52.field_28;
17308 pOutString = (GUIFont *)((char *)pOutString + 1) )
17309 {
17310 v14 = v52.GetControl((unsigned int)pOutString);
17311 v15 = v14;
17312 if ( !v14 )
17313 break;
17314 v16 = v14->uControlParam;
17315 if ( v16 > 24 )
17316 {
17317 v25 = v16 - 76;
17318 if ( v25 )
17319 {
17320 v26 = v25 - 1;
17321 if ( v26 )
17322 {
17323 v27 = v26 - 8;
17324 if ( v27 )
17325 {
17326 v28 = v27 - 1;
17327 if ( v28 )
17328 {
17329 v29 = v28 - 1;
17330 if ( v29 )
17331 {
17332 if ( v29 != 1 )
17333 goto LABEL_71;
17334 v24 = pGlobalTXT_LocalizationStrings[581];
17335 }
17336 else
17337 {
17338 v24 = pGlobalTXT_LocalizationStrings[580];
17339 }
17340 }
17341 else
17342 {
17343 v24 = pGlobalTXT_LocalizationStrings[579];
17344 }
17345 }
17346 else
17347 {
17348 v24 = pGlobalTXT_LocalizationStrings[578];
17349 }
17350 }
17351 else
17352 {
17353 v24 = pGlobalTXT_LocalizationStrings[407];
17354 }
17355 }
17356 else
17357 {
17358 if ( v0->uFlags & 0x80 )
17359 {
17360 LABEL_59:
17361 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v0->pName);
17362 v24 = pTmpBuf;
17363 goto LABEL_79;
17364 }
17365 v24 = pGlobalTXT_LocalizationStrings[406];
17366 }
17367 }
17368 else
17369 {
17370 if ( v16 == 24 )
17371 {
17372 v23 = v0->evtf;
17373 LABEL_63:
17374 v24 = (&dword_721660)[8 * v23];
17375 if ( !v24 )
17376 {
17377 v24 = nullstring;
17378 v15->uControlParam = 0;
17379 }
17380 goto LABEL_79;
17381 }
17382 v17 = v16 - 9;
17383 if ( !v17 )
17384 {
17385 v24 = (const char *)sub_445308(v0->uProfession);
17386 goto LABEL_79;
17387 }
17388 v18 = v17 - 4;
17389 if ( v18 )
17390 {
17391 v19 = v18 - 6;
17392 if ( !v19 )
17393 {
17394 v23 = v0->bDrawSomeAnim;
17395 goto LABEL_63;
17396 }
17397 v20 = v19 - 1;
17398 if ( !v20 )
17399 {
17400 v23 = v0->evtb;
17401 goto LABEL_63;
17402 }
17403 v21 = v20 - 1;
17404 if ( !v21 )
17405 {
17406 v23 = v0->evtc;
17407 goto LABEL_63;
17408 }
17409 v22 = v21 - 1;
17410 if ( !v22 )
17411 {
17412 v23 = v0->evtd;
17413 goto LABEL_63;
17414 }
17415 if ( v22 == 1 )
17416 {
17417 v23 = v0->evte;
17418 goto LABEL_63;
17419 }
17420 LABEL_71:
17421 v24 = nullstring;
17422 goto LABEL_79;
17423 }
17424 if ( v0->uFlags & 0x80 )
17425 goto LABEL_59;
17426 v24 = pGlobalTXT_LocalizationStrings[122];
17427 }
17428 LABEL_79:
17429 if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 )
17430 {
17431 pInString = 0;
17432 if ( (signed int)uNumActors > 0 )
17433 {
17434 v55 = &pActors[0].uAIState;
17435 *(int *)v54 = uNumActors;
17436 do
17437 {
17438 v30 = *v55;
17439 if ( *v55 == 5 || v30 == 11 || v30 == 19 || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == 4 )
17440 ++pInString;
17441 v55 += 418;
17442 --*(int *)v54;
17443 }
17444 while ( *(int *)v54 );
17445 }
17446 if ( pInString == (char *)uNumActors )
17447 v24 = pGlobalTXT_LocalizationStrings[658];
17448 }
17449 strcpy(v15->pButtonName, v24);
17450 }
17451 v32 = 0;
17452 pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
17453 v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
17454 v34 = pDialogueWindow;
17455 *(int *)v54 = v33;
17456 v35 = pDialogueWindow->field_38;
17457 for ( i = v35 + pDialogueWindow->field_28; v35 < i; i = pDialogueWindow->field_28 + pDialogueWindow->field_38 )
17458 {
17459 v37 = v34->GetControl(v35);
17460 if ( !v37 )
17461 {
17462 v34 = pDialogueWindow;
17463 break;
17464 }
17465 v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0);
17466 v34 = pDialogueWindow;
17467 v32 += v38;
17468 ++v35;
17469 }
17470 v39 = v34->field_28;
17471 if ( v39 )
17472 {
17473 pOutString = (GUIFont *)((174 - v32) / v39);
17474 if ( (174 - v32) / v39 > 32 )
17475 pOutString = (GUIFont *)32;
17476 v55 = (unsigned __int16 *)1;
17477 v40 = 174 - (int)pOutString * v39 - v32;
17478 v41 = v34->field_38;
17479 v42 = v40 / 2 - (signed int)pOutString / 2 + 138;
17480 if ( (signed int)v41 < (signed int)(v41 + v39) )
17481 {
17482 do
17483 {
17484 v43 = v34->GetControl(v41);
17485 if ( !v43 )
17486 break;
17487 v43->uY = (unsigned int)((char *)pOutString + v42);
17488 Str = v43->pButtonName;
17489 v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0);
17490 v45 = v43->uY;
17491 v46 = v55;
17492 v43->uHeight = v44;
17493 v42 = v45 + v44 - 1;
17494 v43->uW = v42;
17495 v47 = v54[0];
17496 if ( (unsigned __int16 *)pDialogueWindow->field_2C_focus_id != v46 )
17497 v47 = (unsigned __int16)pInString;
17498 v52.DrawText2(pFontArrus, 0, v45, v47, Str, 3u);
17499 v34 = pDialogueWindow;
17500 v55 = (unsigned __int16 *)((char *)v55 + 1);
17501 ++v41;
17502 }
17503 while ( (signed int)v41 < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
17504 }
17505 }
17506 pRenderer->DrawTextureIndexed(
17507 0x1D7u,
17508 0x1BDu,
17509 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
17510 }
17511
17512 //----- (004459F9) --------------------------------------------------------
17513 NPCData *__fastcall GetNPCData(unsigned int npcid)
17514 {
17515 unsigned int v1; // esi@1
17516 NPCData *result; // eax@5
17517 int v3; // esi@9
17518 int v4; // ecx@9
17519 int v5; // edx@9
17520 NPCData *v6; // eax@9
17521 char *v7; // ebx@14
17522 NPCData *v8; // edi@14
17523 char v9; // al@22
17524 std::string v10; // [sp-18h] [bp-2Ch]@4
17525 const char *v11; // [sp-8h] [bp-1Ch]@4
17526 int v12; // [sp-4h] [bp-18h]@4
17527 std::string *v13; // [sp+Ch] [bp-8h]@4
17528 int a3; // [sp+13h] [bp-1h]@4
17529
17530 v1 = npcid;
17531 if ( (npcid & 0x80000000u) == 0 )
17532 {
17533 if ( (signed int)npcid < 5000 )
17534 {
17535 if ( (signed int)npcid >= 501 )
17536 {
17537 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0);
17538 }
17539 return &pNPCStats->pNewNPCData[v1];
17540 }
17541 return &pNPCStats->array_13EF4[npcid - 5000];
17542 }
17543 if ( (signed int)npcid >= 5000 )
17544 return &pNPCStats->array_13EF4[npcid - 5000];
17545 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
17546 {
17547 result = 0;
17548 }
17549 else
17550 {
17551 v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
17552 v4 = 0;
17553 v5 = 0;
17554 v6 = pParty->pHirelings;
17555 do
17556 {
17557 if ( v6->pName )
17558 pTmpBuf[v4++] = v5;
17559 ++v6;
17560 ++v5;
17561 }
17562 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
17563 v13 = 0;
17564 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
17565 {
17566 v7 = &pTmpBuf[v4];
17567 v8 = pNPCStats->pNewNPCData;
17568 do
17569 {
17570 if ( v8->uFlags & 0x80
17571 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName))
17572 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) )
17573 *v7++ = (char)v13 + 2;
17574 v13 = (std::string *)((char *)v13 + 1);
17575 ++v8;
17576 }
17577 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs );
17578 }
17579 v9 = pTmpBuf[v3];
17580 if ( (unsigned __int8)v9 >= 2u )
17581 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499];
17582 else
17583 result = &pParty->pHirelings[(unsigned __int8)v9];
17584 }
17585 return result;
17586 }
17587
17588 //----- (00445B2C) --------------------------------------------------------
17589 NPCData *__fastcall GetNewNPCData(signed int npcid, int a2)
17590 {
17591 signed int v2; // esi@1
17592 int v3; // edi@1
17593 NPCData *result; // eax@5
17594 int v5; // esi@9
17595 int v6; // ecx@9
17596 int v7; // edx@9
17597 NPCData *v8; // eax@9
17598 NPCData *v9; // edi@14
17599 int v10; // ecx@20
17600 char v11; // al@23
17601 std::string v12; // [sp-18h] [bp-34h]@4
17602 const char *v13; // [sp-8h] [bp-24h]@4
17603 int v14; // [sp-4h] [bp-20h]@4
17604 std::string *v15; // [sp+Ch] [bp-10h]@1
17605 char *v16; // [sp+10h] [bp-Ch]@14
17606 int v17; // [sp+14h] [bp-8h]@13
17607 int a3; // [sp+1Bh] [bp-1h]@4
17608
17609 v2 = npcid;
17610 v3 = a2;
17611 v15 = (std::string *)a2;
17612 if ( npcid >= 0 )
17613 {
17614 if ( npcid < 5000 )
17615 {
17616 if ( npcid >= 501 )
17617 {
17618 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0);
17619 }
17620 *(int *)v3 = v2;
17621 return &pNPCStats->pNewNPCData[v2];
17622 }
17623 LABEL_7:
17624 *(int *)a2 = npcid - 5000;
17625 return &pNPCStats->array_13EF4[npcid - 5000];
17626 }
17627 if ( npcid >= 5000 )
17628 goto LABEL_7;
17629 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
17630 {
17631 *(int *)a2 = 0;
17632 result = 0;
17633 }
17634 else
17635 {
17636 v5 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
17637 v6 = 0;
17638 v7 = 0;
17639 v8 = pParty->pHirelings;
17640 do
17641 {
17642 if ( v8->pName )
17643 pTmpBuf[v6++] = v7;
17644 ++v8;
17645 ++v7;
17646 }
17647 while ( (signed int)v8 < (signed int)&pParty->pPickedItem );
17648 v17 = 0;
17649 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
17650 {
17651 v9 = pNPCStats->pNewNPCData;
17652 v16 = &pTmpBuf[v6];
17653 do
17654 {
17655 if ( v9->uFlags & 0x80
17656 && (!pParty->pHirelings[0].pName || strcmp(v9->pName, pParty->pHirelings[0].pName))
17657 && (!pParty->pHirelings[1].pName || strcmp(v9->pName, pParty->pHirelings[1].pName)) )
17658 {
17659 v10 = (int)v16++;
17660 *(char *)v10 = v17 + 2;
17661 }
17662 ++v17;
17663 ++v9;
17664 }
17665 while ( v17 < (signed int)pNPCStats->uNumNewNPCs );
17666 v3 = (int)v15;
17667 }
17668 v11 = pTmpBuf[v5];
17669 if ( (unsigned __int8)v11 >= 2u )
17670 {
17671 *(int *)v3 = (unsigned __int8)v11 - 2;
17672 result = &pNPCStats->pNPCData[(unsigned __int8)pTmpBuf[v5] + 499];
17673 }
17674 else
17675 {
17676 *(int *)v3 = (unsigned __int8)v11;
17677 result = &pParty->pHirelings[(unsigned __int8)pTmpBuf[v5]];
17678 }
17679 }
17680 return result;
17681 }
17682
17683 //----- (00445C8B) --------------------------------------------------------
17684 int __fastcall sub_445C8B(signed int a1)
17685 {
17686 signed int v1; // ebx@1
17687 int v3; // edi@6
17688 int v4; // ecx@6
17689 int v5; // edx@6
17690 NPCData *v6; // eax@6
17691 char *v7; // ebp@11
17692 NPCData *v8; // esi@11
17693
17694 v1 = 0;
17695 if ( a1 >= 0 )
17696 {
17697 if ( a1 < 5000 )
17698 return 1;
17699 return 2;
17700 }
17701 if ( a1 >= 5000 )
17702 return 2;
17703 v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
17704 v4 = 0;
17705 v5 = 0;
17706 v6 = pParty->pHirelings;
17707 do
17708 {
17709 if ( v6->pName )
17710 pTmpBuf[v4++] = v5;
17711 ++v6;
17712 ++v5;
17713 }
17714 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
17715 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
17716 {
17717 v7 = &pTmpBuf[v4];
17718 v8 = pNPCStats->pNewNPCData;
17719 do
17720 {
17721 if ( v8->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) )
17722 {
17723 if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) )
17724 *v7++ = v1 + 2;
17725 }
17726 ++v1;
17727 ++v8;
17728 }
17729 while ( v1 < (signed int)pNPCStats->uNumNewNPCs );
17730 }
17731 return ((unsigned __int8)pTmpBuf[v3] < 2u) + 1;
17732 }
17733
17734
17735 //----- (0044603D) --------------------------------------------------------
17736 void __cdecl sub_44603D()
17737 {
17738 uDialogue_SpeakingActorNPC_ID = 0;
17739 pDialogueWindow->Release();
17740 pDialogueWindow = 0;
17741 pMiscTimer->Resume();
17742 pEventTimer->Resume();
17743 }
17744
17745
17746 //----- (004465DF) --------------------------------------------------------
17747 signed int __thiscall sub_4465DF_check_season(void *_this)
17748 {
17749 unsigned int v1; // eax@1
17750 unsigned int v2; // edx@1
17751 char *v3; // ecx@2
17752 int v4; // ecx@3
17753 char v6; // zf@9
17754
17755 v1 = pParty->uCurrentMonth + 1;
17756 v2 = pParty->uDaysPlayed + 1;
17757 if ( _this )
17758 {
17759 v3 = (char *)_this - 1;
17760 if ( v3 )
17761 {
17762 v4 = (int)(v3 - 1);
17763 if ( v4 )
17764 {
17765 if ( v4 != 1 )
17766 return 0;
17767 if ( v1 != 12 )
17768 {
17769 if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 )
17770 return 1;
17771 v6 = v1 == 3;
17772 LABEL_24:
17773 if ( !v6 || (signed int)v2 >= 21 )
17774 return 0;
17775 return 1;
17776 }
17777 }
17778 else
17779 {
17780 if ( v1 != 9 )
17781 {
17782 if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 )
17783 return 1;
17784 v6 = v1 == 12;
17785 goto LABEL_24;
17786 }
17787 }
17788 }
17789 else
17790 {
17791 if ( v1 != 6 )
17792 {
17793 if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 )
17794 return 1;
17795 v6 = v1 == 9;
17796 goto LABEL_24;
17797 }
17798 }
17799 }
17800 else
17801 {
17802 if ( v1 != 3 )
17803 {
17804 if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 )
17805 return 1;
17806 v6 = v1 == 6;
17807 goto LABEL_24;
17808 }
17809 }
17810 if ( (signed int)v2 >= 21 )
17811 return 1;
17812 return 0;
17813 }
17814
17815 //----- (0044665D) --------------------------------------------------------
17816 // uType: 0 -> any monster
17817 // 1 -> uParam is GroupID
17818 // 2 -> uParam is MonsterID
17819 // 3 -> uParam is ActorID
17820 // uNumAlive: 0 -> all must be alive
17821 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive)
17822 {
17823 unsigned int uAliveActors; // eax@6
17824 int v5; // ecx@10
17825 unsigned int uTotalActors; // [sp+0h] [bp-4h]@1
17826
17827 uTotalActors = 0;
17828 if ( uType )
17829 {
17830 if ( uType == 1 )
17831 {
17832 uAliveActors = SearchActorByGroup(&uTotalActors, uParam);
17833 }
17834 else
17835 {
17836 if ( uType == 2 )
17837 {
17838 uAliveActors = SearchActorByMonsterID(&uTotalActors, uParam);
17839 }
17840 else
17841 {
17842 if ( uType != 3 )
17843 return 0;
17844 uAliveActors = SearchActorByID(&uTotalActors, uParam);
17845 }
17846 }
17847 }
17848 else
17849 {
17850 uAliveActors = SearchAliveActors(&uTotalActors);
17851 }
17852 v5 = 0;
17853 if ( uNumAlive )
17854 LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive;
17855 else
17856 LOBYTE(v5) = uTotalActors == uAliveActors;
17857 return v5;
17858 }
17859
17860 //----- (004466C4) --------------------------------------------------------
17861 bool __thiscall sub_4466C4(void *_this)
17862 {
17863 signed int v1; // ebp@1
17864 bool result; // eax@2
17865 int v3; // esi@3
17866 signed int v4; // edx@3
17867 signed int v5; // eax@4
17868 unsigned int v6; // ebx@6
17869 char *v7; // eax@6
17870 signed int v8; // edi@18
17871 int v9; // eax@19
17872 Player *v10; // [sp+8h] [bp-10h]@18
17873 signed int v11; // [sp+Ch] [bp-Ch]@3
17874 signed int v12; // [sp+10h] [bp-8h]@3
17875 void *v13; // [sp+14h] [bp-4h]@1
17876
17877 v1 = 0;
17878 v13 = _this;
17879 if ( !_this )
17880 return 0;
17881 v3 = dword_597F18;
17882 pSomeOtherEVT = pGlobalEVT;
17883 uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents;
17884 memcpy(pSomeOtherEVT_Events, pGlobalEVT_Events, 0xCE40u);
17885 v4 = 1;
17886 v12 = 1;
17887 v11 = 0;
17888 if ( (signed int)uSomeOtherEVT_NumEvents <= 0 )
17889 goto LABEL_16;
17890 do
17891 {
17892 v5 = v1;
17893 if ( (void *)pSomeOtherEVT_Events[v1].uEventID == v13 && pSomeOtherEVT_Events[v5].field_4 == v3 )
17894 {
17895 v6 = pSomeOtherEVT_Events[v5].uEventOffsetInEVT;
17896 v7 = &pSomeOtherEVT[v6];
17897 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 1 )
17898 break;
17899 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 44 )
17900 {
17901 v11 = v4;
17902 v10 = pParty->pPlayers;
17903 v8 = (unsigned __int8)v7[7]
17904 + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8);
17905 while ( 1 )
17906 {
17907 LOBYTE(v9) = v10->CompareVariable(
17908 (enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5]
17909 + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)),
17910 v8);
17911 if ( v9 )
17912 break;
17913 ++v10;
17914 if ( (signed int)v10 >= (signed int)pParty->pHirelings )
17915 goto LABEL_13;
17916 }
17917 }
17918 else
17919 {
17920 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 45 )
17921 break;
17922 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 46 )
17923 {
17924 v11 = v4;
17925 v12 = (unsigned __int8)v7[5];
17926 goto LABEL_13;
17927 }
17928 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] != 52
17929 || !IsActorAlive(
17930 (unsigned __int8)v7[5],
17931 (unsigned __int8)v7[6]
17932 + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8),
17933 (unsigned __int8)v7[10]) )
17934 goto LABEL_13;
17935 }
17936 v1 = -1;
17937 v3 = (unsigned __int8)pSomeOtherEVT[v6 + 11] - 1;
17938 LABEL_13:
17939 ++v3;
17940 v4 = 1;
17941 }
17942 ++v1;
17943 }
17944 while ( v1 < (signed int)uSomeOtherEVT_NumEvents );
17945 if ( v11 )
17946 result = v12 != 0;
17947 else
17948 LABEL_16:
17949 result = 2;
17950 return result;
17951 }
17952
17953
17954 //----- (0044684A) --------------------------------------------------------
17955 void __fastcall EventProcessor(int a1, int a2, int a3)
17956 {
17957 unsigned int v3; // eax@5
17958 signed int v4; // esi@7
17959 char *v5; // eax@8
17960 char *v6; // ecx@8
17961 char *v7; // ebp@8
17962 signed int v8; // edx@10
17963 int v9; // edi@12
17964 ByteArray *v10; // esi@12
17965 int v11; // eax@14
17966 char *v12; // eax@15
17967 char *v13; // edi@21
17968 int v14; // ebp@21
17969 int v15; // edi@21
17970 const char *v16; // esi@21
17971 bool v17; // edx@21
17972 int v18; // ecx@22
17973 int v19; // ebp@36
17974 signed int v20; // ecx@40
17975 int v21; // eax@40
17976 int v22; // edx@40
17977 int v23; // eax@40
17978 unsigned __int16 v24; // ax@45
17979 int v25; // eax@54
17980 LevelDecoration *v26; // eax@55
17981 int v27; // eax@57
17982 int v28; // ecx@57
17983 int v29; // edx@58
17984 int v30; // eax@58
17985 int v31; // ecx@58
17986 int v32; // esi@58
17987 NPCData *v33; // ecx@58
17988 int v34; // esi@59
17989 int v35; // esi@60
17990 int v36; // esi@61
17991 int v37; // esi@62
17992 int v38; // eax@78
17993 int v39; // ecx@78
17994 size_t v40; // edx@78
17995 char *v41; // esi@79
17996 int v42; // eax@84
17997 int v43; // ecx@84
17998 size_t v44; // edx@84
17999 char *v45; // esi@85
18000 void *v46; // eax@91
18001 GUIWindow *v47; // eax@93
18002 GUIButton *v48; // ecx@93
18003 GUIButton *v49; // esi@94
18004 char v50; // al@100
18005 Player *v51; // esi@103
18006 Player *v52; // ecx@106
18007 int v53; // ecx@107
18008 char v54; // al@111
18009 Player *v55; // esi@114
18010 Player *v56; // ecx@117
18011 int v57; // ecx@118
18012 signed int v58; // ebp@124
18013 Player *v59; // esi@125
18014 int v60; // eax@126
18015 int v61; // edx@133
18016 int v62; // eax@139
18017 void *v63; // ebp@145
18018 signed int v64; // edi@146
18019 unsigned int v65; // edx@148
18020 Player *v66; // ecx@148
18021 int v67; // esi@148
18022 signed int v68; // eax@151
18023 int v69; // esi@151
18024 Player *v70; // ecx@158
18025 unsigned int v71; // eax@159
18026 int v72; // esi@159
18027 signed int v73; // eax@162
18028 int v74; // esi@162
18029 int v75; // edx@172
18030 Player *v76; // esi@173
18031 signed int v77; // ebp@186
18032 int v78; // edx@186
18033 Player *v79; // esi@187
18034 signed int v80; // ebp@200
18035 int v81; // edx@200
18036 Player *v82; // esi@201
18037 int v83; // eax@212
18038 int v84; // ebp@220
18039 signed int v85; // ebp@224
18040 char v86; // al@224
18041 Player *v87; // esi@227
18042 Player *v88; // ecx@231
18043 int v89; // ecx@232
18044 int v90; // eax@243
18045 const char *v91; // ecx@247
18046 int v92; // eax@251
18047 char *v93; // eax@252
18048 int v94; // ecx@262
18049 int v95; // ebp@262
18050 int v96; // edx@262
18051 int v97; // eax@262
18052 unsigned int v98; // edx@265
18053 const char *v99; // esi@267
18054 int v100; // edx@267
18055 char *v101; // edi@281
18056 unsigned int v102; // esi@281
18057 int v103; // edi@284
18058 int v104; // eax@288
18059 int v105; // edx@294
18060 int v106; // [sp-20h] [bp-4C8h]@278
18061 signed int v107; // [sp-1Ch] [bp-4C4h]@278
18062 unsigned int v108; // [sp-18h] [bp-4C0h]@278
18063 signed int v109; // [sp-14h] [bp-4BCh]@278
18064 signed int v110; // [sp-10h] [bp-4B8h]@278
18065 int v111; // [sp-Ch] [bp-4B4h]@278
18066 Event *v112; // [sp-8h] [bp-4B0h]@5
18067 int v113; // [sp-8h] [bp-4B0h]@106
18068 int v114; // [sp-8h] [bp-4B0h]@117
18069 signed int v115; // [sp-8h] [bp-4B0h]@231
18070 unsigned int v116; // [sp-8h] [bp-4B0h]@278
18071 int v117; // [sp-4h] [bp-4ACh]@106
18072 int v118; // [sp-4h] [bp-4ACh]@117
18073 int v119; // [sp-4h] [bp-4ACh]@231
18074 int v120; // [sp-4h] [bp-4ACh]@278
18075 int v121; // [sp-4h] [bp-4ACh]@294
18076 int v122; // [sp+10h] [bp-498h]@4
18077 char *v123; // [sp+14h] [bp-494h]@0
18078 signed int v124; // [sp+18h] [bp-490h]@7
18079 signed int v125; // [sp+1Ch] [bp-48Ch]@155
18080 int v126; // [sp+1Ch] [bp-48Ch]@262
18081 int v127; // [sp+20h] [bp-488h]@4
18082 int v128; // [sp+24h] [bp-484h]@21
18083 int v129; // [sp+24h] [bp-484h]@262
18084 signed int v130; // [sp+28h] [bp-480h]@0
18085 int v131; // [sp+2Ch] [bp-47Ch]@1
18086 int v132; // [sp+30h] [bp-478h]@262
18087 signed int v133; // [sp+34h] [bp-474h]@1
18088 int v134; // [sp+38h] [bp-470h]@262
18089 int v135; // [sp+3Ch] [bp-46Ch]@262
18090 int v136; // [sp+40h] [bp-468h]@40
18091 int v137; // [sp+44h] [bp-464h]@40
18092 int v138; // [sp+48h] [bp-460h]@40
18093 int v139; // [sp+4Ch] [bp-45Ch]@40
18094 ItemGen item; // [sp+50h] [bp-458h]@15
18095 char Source[120]; // [sp+74h] [bp-434h]@15
18096 char Str[120]; // [sp+ECh] [bp-3BCh]@21
18097 Actor Dst; // [sp+164h] [bp-344h]@53
18098
18099 v131 = a1;
18100 v133 = 0;
18101 dword_5B5920 = a2;
18102 dword_5B65C4 = 0;
18103 if ( !a1 )
18104 {
18105 if ( !GameUI_StatusBar_TimedStringTimeLeft )
18106 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
18107 return;
18108 }
18109 v127 = 2 * (uActiveCharacter == 0) + 4;
18110 v122 = dword_597F18;
18111 if ( _5C3420_pDecoration )
18112 {
18113 v3 = uGlobalEVT_NumEvents;
18114 pSomeEVT = pGlobalEVT;
18115 v112 = pGlobalEVT_Events;
18116 }
18117 else
18118 {
18119 v3 = uLevelEVT_NumEvents;
18120 pSomeEVT = pLevelEVT;
18121 v112 = pLevelEVT_Events;
18122 }
18123 uSomeEVT_NumEvents = v3;
18124 memcpy(pSomeEVT_Events, v112, 0xCE40u);
18125 v4 = 0;
18126 v124 = 0;
18127 if ( (signed int)uSomeEVT_NumEvents > 0 )
18128 {
18129 v5 = pSomeEVT;
18130 v6 = v123;
18131 v7 = nullstring;
18132 while ( 1 )
18133 {
18134 if ( dword_5B65C4 )
18135 goto LABEL_301;
18136 v8 = v4;
18137 if ( pSomeEVT_Events[v4].uEventID == v131 && pSomeEVT_Events[v8].field_4 == v122 )
18138 {
18139 v9 = pSomeEVT_Events[v8].uEventOffsetInEVT;
18140 v10 = (ByteArray *)&v5[v9];
18141 switch ( v5[v9 + 4] )
18142 {
18143 case EVENT_CheckSeason:
18144 if ( !sub_4465DF_check_season((void *)v10->f[5]) )
18145 goto LABEL_291;
18146 v11 = v10->f[6];
18147 goto LABEL_130;
18148 case EVENT_ShowMovie:
18149 strcpy(Source, &v10->f[7]);
18150 v12 = (char *)&item.uExpireTime + strlen(Source) + 7;
18151 if ( *v12 == 32 )
18152 *v12 = 0;
18153 if ( pVideoPlayer->field_54 )
18154 pVideoPlayer->Unload();
18155 pVideoPlayer->bStopBeforeSchedule = 0;
18156 pVideoPlayer->field_40 = 0;
18157 if ( pAsyncMouse )
18158 pAsyncMouse->Suspend();
18159 v128 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
18160 v13 = &pSomeEVT[v9];
18161 v14 = (unsigned __int8)v13[5];
18162 v15 = (unsigned __int8)v13[6];
18163 strcpy(Str, Source);
18164 v16 = RemoveQuotes(Str);
18165 VideoPlayer::MovieLoop(v16, 0, v14, 1);
18166 if ( !_strcmpi(v16, "arbiter good") )
18167 {
18168 pParty->uAlignment = 0;
18169 v18 = 0;
18170 LABEL_23:
18171 LOBYTE(v17) = 1;
18172 SetUserInterface(v18, v17);
18173 goto LABEL_28;
18174 }
18175 if ( !_strcmpi(v16, "arbiter evil") )
18176 {
18177 v18 = 2;
18178 pParty->uAlignment = 2;
18179 goto LABEL_23;
18180 }
18181 if ( !_strcmpi(v16, "pcout01") ) // moving to harmondale from emerald isle
18182 {
18183 Rest(0x2760u);
18184 pParty->RestAndHeal();
18185 pParty->field_764 = 0;
18186 }
18187 LABEL_28:
18188 if ( !v15 || v128 == 3 )
18189 {
18190 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v128;
18191 if ( v128 == 3 )
18192 pGameLoadingUI_ProgressBar->uType = 1;
18193 if ( v128 == 13 )
18194 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
18195 }
18196 if ( pAsyncMouse )
18197 pAsyncMouse->Resume();
18198 goto LABEL_291;
18199 case EVENT_CheckSkill:
18200 v19 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18201 if ( v127 < 0 )
18202 goto LABEL_47;
18203 if ( v127 <= 3 )
18204 {
18205 v24 = pParty->pPlayers[0].pActiveSkills[3486 * v127 + v10->f[5]];
18206 }
18207 else
18208 {
18209 if ( v127 == 4 )
18210 {
18211 v24 = pPlayers[uActiveCharacter]->pActiveSkills[v10->f[5]];
18212 }
18213 else
18214 {
18215 if ( v127 == 5 )
18216 {
18217 v20 = 0;
18218 v21 = 3486 * v130 + v10->f[5];
18219 v136 = 1;
18220 LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21];
18221 v137 = v21 & 0x40;
18222 v138 = v21 & 0x80;
18223 v22 = v21 & 0x100;
18224 v23 = v21 & 0x3F;
18225 v139 = v22;
18226 while ( v23 < v19 || !*(&v136 + v10->f[6]) )
18227 {
18228 ++v20;
18229 if ( v20 >= 4 )
18230 goto LABEL_291;
18231 }
18232 LABEL_50:
18233 v11 = v10->f[11];
18234 goto LABEL_130;
18235 }
18236 LABEL_47:
18237 v10 = (ByteArray *)&v5[v9];
18238 v24 = pParty->pPlayers[0].pActiveSkills[(unsigned __int8)v5[v9 + 5] + 3486 * rand() % 4];
18239 }
18240 }
18241 v136 = 1;
18242 v137 = v24 & 0x40;
18243 v138 = v24 & 0x80;
18244 v139 = v24 & 0x100;
18245 if ( (v24 & 0x3F) >= v19 && *(&v136 + v10->f[6]) )
18246 goto LABEL_50;
18247 goto LABEL_291;
18248 case EVENT_SpeakNPC:
18249 if ( a3 )
18250 {
18251 //Actor::Actor(&Dst);
18252 memset(&Dst, 0, 0x344u);
18253 dword_5B65D0_dialogue_actor_npc_id = (unsigned __int8)pSomeEVT[v9 + 5]
18254 + (((unsigned __int8)pSomeEVT[v9 + 6]
18255 + (((unsigned __int8)pSomeEVT[v9 + 7]
18256 + ((unsigned __int8)pSomeEVT[v9 + 8] << 8)) << 8)) << 8);
18257 Dst.uNPC_ID = dword_5B65D0_dialogue_actor_npc_id;
18258 Dst.InitializeDialogue(0);
18259 }
18260 else
18261 {
18262 bDialogueUI_InitializeActor_NPC_ID = v10->f[5]
18263 + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18264 }
18265 goto LABEL_291;
18266 case EVENT_ChangeEvent:
18267 v25 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18268 if ( v25 )
18269 {
18270 stru_5E4C90.field_0[_5C3420_pDecoration->field_1C] = v10->f[5] - 124;
18271 }
18272 else
18273 {
18274 v26 = _5C3420_pDecoration;
18275 stru_5E4C90.field_0[_5C3420_pDecoration->field_1C] = 0;
18276 LOBYTE(v26->field_2) |= 0x20u;
18277 }
18278 goto LABEL_291;
18279 case EVENT_SetNPCGreeting:
18280 v27 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18281 v28 = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
18282 pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
18283 pNPCStats->pNewNPCData[v27].greet = v28;
18284 goto LABEL_291;
18285 case EVENT_SetNPCTopic:
18286 v29 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18287 v30 = v10->f[10] + ((v10->f[11] + ((v10->f[12] + (v10->f[13] << 8)) << 8)) << 8);
18288 v31 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18289 v32 = v10->f[9];
18290 v33 = &pNPCStats->pNewNPCData[v31];
18291 if ( v32 )
18292 {
18293 v34 = v32 - 1;
18294 if ( v34 )
18295 {
18296 v35 = v34 - 1;
18297 if ( v35 )
18298 {
18299 v36 = v35 - 1;
18300 if ( v36 )
18301 {
18302 v37 = v36 - 1;
18303 if ( v37 )
18304 {
18305 if ( v37 == 1 )
18306 v33->evtf = v30;
18307 }
18308 else
18309 {
18310 v33->evte = v30;
18311 }
18312 }
18313 else
18314 {
18315 v33->evtd = v30;
18316 }
18317 }
18318 else
18319 {
18320 v33->evtc = v30;
18321 }
18322 }
18323 else
18324 {
18325 v33->evtb = v30;
18326 }
18327 }
18328 else
18329 {
18330 v33->bDrawSomeAnim = v30;
18331 }
18332 if ( v29 == 8 )
18333 {
18334 if ( v30 == 78 )
18335 {
18336 sub_4BD8B5();
18337 ptr_507BC0->Release();
18338 pParty->uFlags &= 0xFFFFFFFDu;
18339 if ( EnterHouse((enum HOUSE_TYPE)170) )
18340 {
18341 pAudioPlayer->StopChannels(-1, -1);
18342 ptr_507BC0 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, 170, 0);
18343 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, v7, 0);
18344 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, v7, 0);
18345 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, v7, 0);
18346 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, v7, 0);
18347 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, v7, 0);
18348 ptr_F8B1E8 = (char *)dword_72193C;
18349 }
18350 }
18351 }
18352 goto LABEL_291;
18353 case EVENT_NPCSetItem:
18354 sub_448518_npc_set_item(
18355 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18356 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18357 v10->f[13]);
18358 goto LABEL_291;
18359 case EVENT_SetActorItem:
18360 Actor::GiveItem(
18361 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18362 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18363 v10->f[13]);
18364 goto LABEL_291;
18365 case EVENT_SetNPCGroupNews:
18366 pNPCStats->pGroups_copy[v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8)] = v10->f[9] + (v10->f[10] << 8);
18367 goto LABEL_291;
18368 case EVENT_SetActorGroup:
18369 *(&pActors[0].uGroup + 285212672 * v10->f[8] + 209 * (v10->f[5] + ((v10->f[6] + (v10->f[7] << 8)) << 8))) = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
18370 goto LABEL_291;
18371 case EVENT_ChangeGroup:
18372 v38 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18373 v39 = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
18374 v40 = uNumActors;
18375 if ( (signed int)uNumActors > 0 )
18376 {
18377 v41 = (char *)&pActors[0].uGroup;
18378 do
18379 {
18380 if ( *(int *)v41 == v38 )
18381 *(int *)v41 = v39;
18382 v41 += 836;
18383 --v40;
18384 }
18385 while ( v40 );
18386 }
18387 goto LABEL_291;
18388 case EVENT_ChangeGroupAlly:
18389 v42 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18390 v43 = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
18391 v44 = uNumActors;
18392 if ( (signed int)uNumActors > 0 )
18393 {
18394 v45 = (char *)&pActors[0].uAlly;
18395 do
18396 {
18397 if ( *((int *)v45 - 1) == v42 )
18398 *(int *)v45 = v43;
18399 v45 += 836;
18400 --v44;
18401 }
18402 while ( v44 );
18403 }
18404 goto LABEL_291;
18405 case EVENT_MoveNPC:
18406 pNPCStats->pNewNPCData[v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8)].house = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
18407 if ( ptr_507BC0 )
18408 {
18409 v46 = ptr_507BC0->ptr_1C;
18410 if ( v46 == (void *)165 )
18411 {
18412 sub_4BD8B5();
18413 pVideoPlayer->Unload();
18414 ptr_507BC0->Release();
18415 pParty->uFlags &= 0xFFFFFFFDu;
18416 _5C3420_pDecoration = (LevelDecoration *)1;
18417 if ( EnterHouse((enum HOUSE_TYPE)165) )
18418 {
18419 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
18420 v47 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, 165, 0);
18421 ptr_507BC0 = v47;
18422 v48 = v47->pControlsHead;
18423 if ( v48 )
18424 {
18425 do
18426 {
18427 v49 = v48->pNext;
18428 pAllocator->FreeChunk(v48);
18429 v48 = v49;
18430 }
18431 while ( v49 );
18432 v47 = ptr_507BC0;
18433 }
18434 v47->pControlsHead = 0;
18435 ptr_507BC0->pControlsTail = 0;
18436 ptr_507BC0->uNumControls = 0;
18437 }
18438 }
18439 else
18440 {
18441 if ( v46 == (void *)553 )
18442 pVideoPlayer->bLoopPlaying = 0;
18443 }
18444 }
18445 goto LABEL_291;
18446 case EVENT_Jmp:
18447 v124 = -1;
18448 v122 = v10->f[5] - 1;
18449 goto LABEL_291;
18450 case EVENT_ShowFace:
18451 v50 = v10->f[5];
18452 if ( (unsigned __int8)v50 <= 3u )
18453 {
18454 v117 = 0;
18455 v113 = v10->f[6];
18456 v53 = (unsigned __int8)v50;
18457 goto LABEL_108;
18458 }
18459 if ( v50 == 4 )
18460 {
18461 v117 = 0;
18462 v113 = v10->f[6];
18463 v52 = pPlayers[uActiveCharacter];
18464 goto LABEL_109;
18465 }
18466 if ( v50 != 5 )
18467 {
18468 v117 = 0;
18469 v113 = v10->f[6];
18470 v53 = rand() % 4;
18471 LABEL_108:
18472 v52 = &pParty->pPlayers[v53];
18473 LABEL_109:
18474 v52->PlayEmotion(v113, v117);
18475 goto LABEL_291;
18476 }
18477 v51 = pParty->pPlayers;
18478 do
18479 {
18480 v51->PlayEmotion((unsigned __int8)pSomeEVT[v9 + 6], 0);
18481 ++v51;
18482 }
18483 while ( (signed int)v51 < (signed int)pParty->pHirelings );
18484 LABEL_291:
18485 ++v122;
18486 v4 = v124;
18487 v5 = pSomeEVT;
18488 v6 = v123;
18489 v7 = nullstring;
18490 break;
18491 case EVENT_CharacterAnimation:
18492 v54 = v10->f[5];
18493 if ( (unsigned __int8)v54 <= 3u )
18494 {
18495 v118 = 0;
18496 v114 = v10->f[6];
18497 v57 = (unsigned __int8)v54;
18498 goto LABEL_119;
18499 }
18500 if ( v54 == 4 )
18501 {
18502 v118 = 0;
18503 v114 = v10->f[6];
18504 v56 = pPlayers[uActiveCharacter];
18505 goto LABEL_120;
18506 }
18507 if ( v54 != 5 )
18508 {
18509 v118 = 0;
18510 v114 = v10->f[6];
18511 v57 = rand() % 4;
18512 LABEL_119:
18513 v56 = &pParty->pPlayers[v57];
18514 LABEL_120:
18515 v56->PlaySound(v114, v118);
18516 goto LABEL_291;
18517 }
18518 v55 = pParty->pPlayers;
18519 do
18520 {
18521 v55->PlaySound((unsigned __int8)pSomeEVT[v9 + 6], 0);
18522 ++v55;
18523 }
18524 while ( (signed int)v55 < (signed int)pParty->pHirelings );
18525 goto LABEL_291;
18526 case EVENT_ForPartyMember:
18527 v127 = v10->f[5];
18528 goto LABEL_291;
18529 case EVENT_SummonItem:
18530 sub_42F7EB_DropItemAt(
18531 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18532 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18533 v10->f[13] + ((v10->f[14] + ((v10->f[15] + (v10->f[16] << 8)) << 8)) << 8),
18534 v10->f[17] + ((v10->f[18] + ((v10->f[19] + (v10->f[20] << 8)) << 8)) << 8),
18535 v10->f[21] + ((v10->f[22] + ((v10->f[23] + (v10->f[24] << 8)) << 8)) << 8),
18536 v10->f[25],
18537 v10->f[26],
18538 0,
18539 0);
18540 goto LABEL_291;
18541 case EVENT_Compare:
18542 v58 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18543 if ( v127 == 5 )
18544 {
18545 v130 = 0;
18546 v59 = pParty->pPlayers;
18547 while ( 1 )
18548 {
18549 LOBYTE(v60) = v59->CompareVariable(
18550 (enum VariableType)((unsigned __int8)pSomeEVT[v9 + 5]
18551 + ((unsigned __int8)pSomeEVT[v9 + 6] << 8)),
18552 v58);
18553 if ( v60 )
18554 break;
18555 ++v130;
18556 ++v59;
18557 if ( (signed int)v59 >= (signed int)pParty->pHirelings )
18558 goto LABEL_291;
18559 }
18560 LABEL_129:
18561 v11 = (unsigned __int8)pSomeEVT[v9 + 11];
18562 goto LABEL_130;
18563 }
18564 if ( v127 < 0 )
18565 goto LABEL_139;
18566 v61 = v127;
18567 if ( v127 <= 3 )
18568 goto LABEL_137;
18569 if ( v127 == 4 )
18570 {
18571 if ( uActiveCharacter )
18572 {
18573 v6 = (char *)pPlayers[uActiveCharacter];
18574 goto LABEL_138;
18575 }
18576 }
18577 else
18578 {
18579 if ( v127 != 6 )
18580 goto LABEL_139;
18581 }
18582 v61 = rand() % 4;
18583 v5 = pSomeEVT;
18584 LABEL_137:
18585 v6 = (char *)&pParty->pPlayers[v61];
18586 LABEL_138:
18587 v123 = v6;
18588 LABEL_139:
18589 LOBYTE(v62) = ((Player *)v6)->CompareVariable(
18590 (enum VariableType)((unsigned __int8)v5[v9 + 5] + ((unsigned __int8)v5[v9 + 6] << 8)),
18591 v58);
18592 LABEL_140:
18593 if ( v62 )
18594 goto LABEL_129;
18595 goto LABEL_291;
18596 case EVENT_IsActorAlive:
18597 v62 = IsActorAlive(
18598 v10->f[5],
18599 v10->f[6] + ((v10->f[7] + ((v10->f[8] + (v10->f[9] << 8)) << 8)) << 8),
18600 v10->f[10]);
18601 goto LABEL_140;
18602 case EVENT_Substract:
18603 v63 = (void *)(v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8));
18604 if ( v10->f[5] + (v10->f[6] << 8) == VAR_PlayerItemInHands )
18605 {
18606 v64 = 0;
18607 if ( (void *)pParty->pPickedItem.uItemID == v63 )
18608 {
18609 pMouse->RemoveHoldingItem();
18610 goto LABEL_291;
18611 }
18612 v65 = 0;
18613 v66 = pPlayers[uActiveCharacter];
18614 v67 = (int)v66->pInventoryIndices;
18615 do
18616 {
18617 if ( *(void **)&v66->pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 )
18618 {
18619 v66->RemoveItemAtInventoryIndex(v65);
18620 goto LABEL_291;
18621 }
18622 ++v65;
18623 v67 += 4;
18624 }
18625 while ( (signed int)v65 < 126 );
18626 v68 = 0;
18627 v69 = (int)&v66->pEquipment;
18628 do
18629 {
18630 if ( *(int *)v69 && *(void **)&v66->pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 )
18631 {
18632 *(&v66->pEquipment.uOffHand + v68) = 0;
18633 goto LABEL_291;
18634 }
18635 ++v68;
18636 v69 += 4;
18637 }
18638 while ( v68 < 16 );
18639 v125 = (signed int)&pPlayers[1];
18640 while ( 1 )
18641 {
18642 v70 = *(Player **)v125;
18643 if ( !v64 )
18644 {
18645 v71 = 0;
18646 v72 = (int)v70->pInventoryIndices;
18647 do
18648 {
18649 if ( *(void **)&v70->pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 )
18650 {
18651 v70->RemoveItemAtInventoryIndex(v71);
18652 goto LABEL_169;
18653 }
18654 ++v71;
18655 v72 += 4;
18656 }
18657 while ( (signed int)v71 < 126 );
18658 v73 = 0;
18659 v74 = (int)&v70->pEquipment;
18660 while ( !*(int *)v74
18661 || *(void **)&v70->pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 )
18662 {
18663 ++v73;
18664 v74 += 4;
18665 if ( v73 >= 16 )
18666 goto LABEL_170;
18667 }
18668 *(&v70->pEquipment.uOffHand + v73) = 0;
18669 LABEL_169:
18670 v64 = 1;
18671 }
18672 LABEL_170:
18673 v125 += 4;
18674 if ( v125 > (signed int)&pPlayers[4] )
18675 goto LABEL_291;
18676 }
18677 }
18678 v75 = v127;
18679 if ( v127 != 5 )
18680 {
18681 if ( v127 < 0 )
18682 goto LABEL_183;
18683 if ( v127 > 3 )
18684 {
18685 if ( v127 != 4 )
18686 {
18687 if ( v127 == 6 )
18688 goto LABEL_180;
18689 LABEL_183:
18690 ((Player *)v6)->SubtractVariable(
18691 (enum VariableType)((unsigned __int8)v5[v9 + 5] + ((unsigned __int8)v5[v9 + 6] << 8)),
18692 v63);
18693 goto LABEL_291;
18694 }
18695 if ( uActiveCharacter )
18696 {
18697 v6 = (char *)pPlayers[uActiveCharacter];
18698 goto LABEL_182;
18699 }
18700 LABEL_180:
18701 v75 = rand() % 4;
18702 v5 = pSomeEVT;
18703 }
18704 v6 = (char *)&pParty->pPlayers[v75];
18705 LABEL_182:
18706 v123 = v6;
18707 goto LABEL_183;
18708 }
18709 v76 = pParty->pPlayers;
18710 v130 = 4;
18711 do
18712 {
18713 v76->SubtractVariable(
18714 (enum VariableType)((unsigned __int8)pSomeEVT[v9 + 5] + ((unsigned __int8)pSomeEVT[v9 + 6] << 8)),
18715 v63);
18716 ++v76;
18717 }
18718 while ( (signed int)v76 < (signed int)pParty->pHirelings );
18719 goto LABEL_291;
18720 case EVENT_Set:
18721 v77 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18722 v78 = v127;
18723 if ( v127 != 5 )
18724 {
18725 if ( v127 < 0 )
18726 goto LABEL_197;
18727 if ( v127 > 3 )
18728 {
18729 if ( v127 != 4 )
18730 {
18731 if ( v127 == 6 )
18732 goto LABEL_194;
18733 LABEL_197:
18734 ((Player *)v6)->SetVariable(
18735 (enum VariableType)((unsigned __int8)v5[v9 + 5] + ((unsigned __int8)v5[v9 + 6] << 8)),
18736 v77);
18737 goto LABEL_291;
18738 }
18739 if ( uActiveCharacter )
18740 {
18741 v6 = (char *)pPlayers[uActiveCharacter];
18742 goto LABEL_196;
18743 }
18744 LABEL_194:
18745 v78 = rand() % 4;
18746 v5 = pSomeEVT;
18747 }
18748 v6 = (char *)&pParty->pPlayers[v78];
18749 LABEL_196:
18750 v123 = v6;
18751 goto LABEL_197;
18752 }
18753 v79 = pParty->pPlayers;
18754 v130 = 4;
18755 do
18756 {
18757 v79->SetVariable(
18758 (enum VariableType)((unsigned __int8)pSomeEVT[v9 + 5] + ((unsigned __int8)pSomeEVT[v9 + 6] << 8)),
18759 v77);
18760 ++v79;
18761 }
18762 while ( (signed int)v79 < (signed int)pParty->pHirelings );
18763 goto LABEL_291;
18764 case EVENT_Add:
18765 v80 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18766 v81 = v127;
18767 if ( v127 != 5 )
18768 {
18769 if ( v127 < 0 )
18770 goto LABEL_211;
18771 if ( v127 > 3 )
18772 {
18773 if ( v127 != 4 )
18774 {
18775 if ( v127 == 6 )
18776 goto LABEL_208;
18777 LABEL_211:
18778 ((Player *)v6)->AddVariable(
18779 (enum VariableType)((unsigned __int8)v5[v9 + 5] + ((unsigned __int8)v5[v9 + 6] << 8)),
18780 v80);
18781 goto LABEL_212;
18782 }
18783 if ( uActiveCharacter )
18784 {
18785 v6 = (char *)pPlayers[uActiveCharacter];
18786 goto LABEL_210;
18787 }
18788 LABEL_208:
18789 v81 = rand() % 4;
18790 v5 = pSomeEVT;
18791 }
18792 v6 = (char *)&pParty->pPlayers[v81];
18793 LABEL_210:
18794 v123 = v6;
18795 goto LABEL_211;
18796 }
18797 v82 = pParty->pPlayers;
18798 v130 = 4;
18799 do
18800 {
18801 v82->AddVariable(
18802 (enum VariableType)((unsigned __int8)pSomeEVT[v9 + 5] + ((unsigned __int8)pSomeEVT[v9 + 6] << 8)),
18803 v80);
18804 ++v82;
18805 }
18806 while ( (signed int)v82 < (signed int)pParty->pHirelings );
18807 LABEL_212:
18808 v83 = (unsigned __int8)pSomeEVT[v9 + 5] + ((unsigned __int8)pSomeEVT[v9 + 6] << 8);
18809 if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
18810 viewparams->bRedrawGameUI = 1;
18811 goto LABEL_291;
18812 case EVENT_InputString:
18813 if ( !dword_597F18 )
18814 {
18815 strcpy(
18816 GameUI_StatusBar_TimedString,
18817 &pLevelStr[pLevelStrOffsets[(unsigned __int8)v5[v9 + 5]
18818 + (((unsigned __int8)v5[v9 + 6]
18819 + (((unsigned __int8)v5[v9 + 7] + ((unsigned __int8)v5[v9 + 8] << 8)) << 8)) << 8)]]);
18820 v105 = v122;
18821 v121 = 26;
18822 LABEL_295:
18823 sub_4451A8_press_any_key(v131, v105, v121);
18824 LABEL_301:
18825 if ( v133 == 1 )
18826 LABEL_302:
18827 OnMapLeave();
18828 return;
18829 }
18830 v84 = v10->f[13] + ((v10->f[14] + ((v10->f[15] + (v10->f[16] << 8)) << 8)) << 8);
18831 if ( !_strcmpi(
18832 GameUI_StatusBar_TimedString,
18833 &pLevelStr[pLevelStrOffsets[v10->f[9]
18834 + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8)]])
18835 || !_strcmpi(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[v84]]) )
18836 {
18837 v11 = (unsigned __int8)pSomeEVT[v9 + 17];
18838 LABEL_130:
18839 v124 = -1;
18840 LABEL_131:
18841 v122 = v11 - 1;
18842 }
18843 goto LABEL_291;
18844 case EVENT_RandomGoTo:
18845 v124 = -1;
18846 v11 = (unsigned __int8)*(&pSomeEVT[v9 + 5]
18847 + rand()
18848 % ((v10->f[5] != 0)
18849 + (v10->f[6] != 0)
18850 + (v10->f[7] != 0)
18851 + (v10->f[8] != 0)
18852 + (v10->f[9] != 0)
18853 + (v10->f[10] != 0)));
18854 goto LABEL_131;
18855 case EVENT_ReceiveDamage:
18856 v85 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18857 v86 = v10->f[5];
18858 if ( (unsigned __int8)v86 <= 3u )
18859 {
18860 v119 = v10->f[6];
18861 v115 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18862 v89 = (unsigned __int8)v86;
18863 goto LABEL_233;
18864 }
18865 if ( v86 == 4 )
18866 {
18867 if ( !uActiveCharacter )
18868 goto LABEL_291;
18869 v119 = v10->f[6];
18870 v88 = pPlayers[uActiveCharacter];
18871 v115 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18872 goto LABEL_234;
18873 }
18874 if ( v86 != 5 )
18875 {
18876 v119 = v10->f[6];
18877 v115 = v10->f[7] + ((v10->f[8] + ((v10->f[9] + (v10->f[10] << 8)) << 8)) << 8);
18878 v89 = rand() % 4;
18879 LABEL_233:
18880 v88 = &pParty->pPlayers[v89];
18881 LABEL_234:
18882 v88->ReceiveDamage(v115, v119);
18883 goto LABEL_291;
18884 }
18885 v87 = pParty->pPlayers;
18886 do
18887 {
18888 v87->ReceiveDamage(v85, (unsigned __int8)pSomeEVT[v9 + 6]);
18889 ++v87;
18890 }
18891 while ( (signed int)v87 < (signed int)pParty->pHirelings );
18892 goto LABEL_291;
18893 case EVENT_ToggleIndoorLight:
18894 pIndoor->ToggleLight(v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8), v10->f[9]);
18895 goto LABEL_291;
18896 case EVENT_SetFacesBit:
18897 sub_44892E_set_faces_bit(
18898 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18899 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18900 v10->f[13]);
18901 goto LABEL_291;
18902 case EVENT_ToggleChestFlag:
18903 Chest::ToggleFlag(
18904 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18905 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18906 v10->f[13]);
18907 goto LABEL_291;
18908 case EVENT_ToggleActorFlag:
18909 Actor::ToggleFlag(
18910 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18911 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18912 v10->f[13]);
18913 goto LABEL_291;
18914 case EVENT_ToggleActorGroupFlag:
18915 ToggleActorGroupFlag(
18916 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18917 v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8),
18918 v10->f[13]);
18919 goto LABEL_291;
18920 case EVENT_SetSnow:
18921 if ( !v10->f[5] )
18922 pWeather->bRenderSnow = v10->f[6] != 0;
18923 goto LABEL_291;
18924 case EVENT_StatusText:
18925 v90 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18926 if ( _5C3420_pDecoration )
18927 {
18928 if ( _5C3420_pDecoration == (LevelDecoration *)1 )
18929 {
18930 ptr_F8B1E8 = (&dword_721664)[8 * v90];
18931 goto LABEL_291;
18932 }
18933 if ( a3 == 1 )
18934 {
18935 v91 = (&dword_721664)[8 * v90];
18936 LABEL_248:
18937 ShowStatusBarString(v91, 2u);
18938 goto LABEL_291;
18939 }
18940 }
18941 else
18942 {
18943 if ( a3 == 1 )
18944 {
18945 v91 = &pLevelStr[pLevelStrOffsets[v90]];
18946 goto LABEL_248;
18947 }
18948 }
18949 goto LABEL_291;
18950 case EVENT_ShowMessage:
18951 v92 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
18952 if ( _5C3420_pDecoration )
18953 {
18954 v93 = (&dword_721664)[8 * v92];
18955 byte_5B0938[0] = 0;
18956 ptr_F8B1E8 = v93;
18957 }
18958 else
18959 {
18960 strcpy(byte_5B0938, &pLevelStr[pLevelStrOffsets[v92]]);
18961 }
18962 goto LABEL_291;
18963 case EVENT_CastSpell:
18964 sub_448DF8_cast_spell(
18965 v10->f[5],
18966 v10->f[6],
18967 v10->f[7],
18968 v10->f[8] + ((v10->f[9] + ((v10->f[10] + (v10->f[11] << 8)) << 8)) << 8),
18969 v10->f[12] + ((v10->f[13] + ((v10->f[14] + (v10->f[15] << 8)) << 8)) << 8),
18970 v10->f[16] + ((v10->f[17] + ((v10->f[18] + (v10->f[19] << 8)) << 8)) << 8),
18971 v10->f[20] + ((v10->f[21] + ((v10->f[22] + (v10->f[23] << 8)) << 8)) << 8),
18972 v10->f[24] + ((v10->f[25] + ((v10->f[26] + (v10->f[27] << 8)) << 8)) << 8),
18973 v10->f[28] + ((v10->f[29] + ((v10->f[30] + (v10->f[31] << 8)) << 8)) << 8));
18974 goto LABEL_291;
18975 case EVENT_SetTexture:
18976 sub_44861E_set_texture(v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8), &v10->f[9]);
18977 goto LABEL_291;
18978 case EVENT_SetSprite:
18979 SetDecorationSprite(
18980 v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8),
18981 v10->f[9],
18982 &v10->f[10]);
18983 goto LABEL_291;
18984 case EVENT_SummonMonsters:
18985 sub_448CF4_spawn_monsters(
18986 v10->f[5],
18987 v10->f[6],
18988 v10->f[7],
18989 v10->f[8] + ((v10->f[9] + ((v10->f[10] + (v10->f[11] << 8)) << 8)) << 8),
18990 v10->f[12] + ((v10->f[13] + ((v10->f[14] + (v10->f[15] << 8)) << 8)) << 8),
18991 v10->f[16] + ((v10->f[17] + ((v10->f[18] + (v10->f[19] << 8)) << 8)) << 8),
18992 v10->f[20] + ((v10->f[21] + ((v10->f[22] + (v10->f[23] << 8)) << 8)) << 8),
18993 v10->f[24] + ((v10->f[25] + ((v10->f[26] + (v10->f[27] << 8)) << 8)) << 8));
18994 goto LABEL_291;
18995 case EVENT_MouseOver:
18996 case EVENT_LocationName:
18997 --v122;
18998 goto LABEL_291;
18999 case EVENT_ChangeDoorState:
19000 sub_449A49_door_switch_animation(v10->f[5], v10->f[6]);
19001 goto LABEL_291;
19002 case EVENT_OpenChest:
19003 if ( !Chest::Open(v10->f[5]) )
19004 goto LABEL_301;
19005 goto LABEL_291;
19006 case EVENT_MoveToMap:
19007 v94 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
19008 v135 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
19009 v132 = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
19010 v126 = v10->f[13] + ((v10->f[14] + ((v10->f[15] + (v10->f[16] << 8)) << 8)) << 8);
19011 v129 = v10->f[17] + ((v10->f[18] + ((v10->f[19] + (v10->f[20] << 8)) << 8)) << 8);
19012 v95 = v10->f[21] + ((v10->f[22] + ((v10->f[23] + (v10->f[24] << 8)) << 8)) << 8);
19013 v96 = v10->f[25];
19014 v97 = v96 + ((v10->f[26] + ((v10->f[27] + (v10->f[28] << 8)) << 8)) << 8);
19015 v134 = v96 + ((v10->f[26] + ((v10->f[27] + (v10->f[28] << 8)) << 8)) << 8);
19016 if ( v10->f[29] || v10->f[30] )
19017 {
19018 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
19019 pRenderer->_49FD3A(v9);
19020 sub_444839_move_map(
19021 (unsigned __int8)pSomeEVT[v9 + 29],
19022 (unsigned __int8)pSomeEVT[v9 + 30],
19023 v135,
19024 v132,
19025 v126,
19026 v129,
19027 v95,
19028 v134,
19029 &pSomeEVT[v9 + 31]);
19030 dword_5C3418 = v131;
19031 dword_5C341C = v122 + 1;
19032 goto LABEL_301;
19033 }
19034 _5B65AC_npcdata_fame_or_other = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
19035 _5B65A8_npcdata_uflags_or_other = v94;
19036 _5B65B0_npcdata_rep_or_other = v126;
19037 if ( v129 == -1 )
19038 {
19039 v98 = _5B65B4_npcdata_loword_house_or_other;
19040 }
19041 else
19042 {
19043 v98 = v129 & stru_5C6E00->uDoublePiMask;
19044 _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask;
19045 }
19046 v99 = &v10->f[31];
19047 _5B65B8_npcdata_hiword_house_or_other = v95;
19048 dword_5B65BC = v97;
19049 v100 = v94 | v132 | v126 | v95 | v97 | v98;
19050 dword_5B65C0 = v100;
19051 if ( *v99 == 48 )
19052 {
19053 if ( v100 )
19054 {
19055 pParty->vPosition.x = v135;
19056 pParty->vPosition.z = v132;
19057 pParty->vPosition.y = v126;
19058 pParty->uFallStartY = v126;
19059 if ( _5B65B4_npcdata_loword_house_or_other != -1 )
19060 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
19061 _5B65B4_npcdata_loword_house_or_other = -1;
19062 v120 = 0;
19063 v116 = 0;
19064 v111 = 0;
19065 v110 = 0;
19066 v109 = -1;
19067 v108 = 0;
19068 v107 = 0;
19069 pParty->sRotationX = v95;
19070 pParty->uFallSpeed = v134;
19071 dword_5B65C0 = 0;
19072 dword_5B65BC = 0;
19073 _5B65B8_npcdata_hiword_house_or_other = 0;
19074 _5B65B0_npcdata_rep_or_other = 0;
19075 _5B65AC_npcdata_fame_or_other = 0;
19076 _5B65A8_npcdata_uflags_or_other = 0;
19077 v106 = 232;
19078 LABEL_280:
19079 pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120);
19080 }
19081 }
19082 else
19083 {
19084 pGameLoadingUI_ProgressBar->uType = (_5C3420_pDecoration == 0) + 1;
19085 sub_44987B(v99, 0);
19086 v133 = 1;
19087 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 )
19088 {
19089 if ( uGameState == 2 )
19090 {
19091 pAudioPlayer->StopChannels(-1, -1);
19092 dword_F8B19C = 0;
19093 while ( sub_4BD8B5() )
19094 ;
19095 pVideoPlayer->Unload();
19096 ptr_507BC0->Release();
19097 ptr_507BC0 = 0;
19098 if ( pMessageQueue_50CBD0->uNumMessages )
19099 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
19100 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
19101 viewparams->bRedrawGameUI = 1;
19102 array_5913D8[6] = 0;
19103 pDialogueWindow->Release();
19104 dword_F8B19C = 0;
19105 pDialogueWindow = 0;
19106 pIcons_LOD->_40F9C5();
19107 }
19108 goto LABEL_302;
19109 }
19110 }
19111 goto LABEL_291;
19112 case EVENT_PlaySound:
19113 v120 = 0;
19114 v116 = 0;
19115 v111 = 0;
19116 v110 = v10->f[13] + ((v10->f[14] + ((v10->f[15] + (v10->f[16] << 8)) << 8)) << 8);
19117 v109 = v10->f[9] + ((v10->f[10] + ((v10->f[11] + (v10->f[12] << 8)) << 8)) << 8);
19118 v108 = 0;
19119 v107 = 0;
19120 v106 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
19121 goto LABEL_280;
19122 case EVENT_GiveItem:
19123 item.Reset();
19124 v101 = &pSomeEVT[v9];
19125 v102 = (unsigned __int8)v101[7]
19126 + (((unsigned __int8)v101[8] + (((unsigned __int8)v101[9] + ((unsigned __int8)v101[10] << 8)) << 8)) << 8);
19127 pItemsTable->GenerateItem((unsigned __int8)v101[5], (unsigned __int8)v101[6], &item);
19128 if ( v102 )
19129 item.uItemID = v102;
19130 pParty->SetHoldingItem(&item);
19131 goto LABEL_291;
19132 case EVENT_SpeakInHouse:
19133 v103 = v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8);
19134 if ( EnterHouse((enum HOUSE_TYPE)(v10->f[5] + ((v10->f[6] + ((v10->f[7] + (v10->f[8] << 8)) << 8)) << 8))) )
19135 {
19136 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
19137 pRenderer->_49FD3A(v103);
19138 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
19139 pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0);
19140 v104 = 187;
19141 if ( uCurrentHouse_Animation != 167 )
19142 v104 = v103;
19143 ptr_507BC0 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, v104, 0);
19144 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, v7, 0);
19145 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, v7, 0);
19146 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, v7, 0);
19147 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, v7, 0);
19148 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, v7, 0);
19149 }
19150 goto LABEL_291;
19151 default:
19152 goto LABEL_291;
19153 case EVENT_PressAnyKey:
19154 v121 = 33;
19155 v105 = v122 + 1;
19156 goto LABEL_295;
19157 case EVENT_Exit:
19158 goto LABEL_301;
19159 }
19160 }
19161 ++v4;
19162 v124 = v4;
19163 if ( v4 >= (signed int)uSomeEVT_NumEvents )
19164 goto LABEL_301;
19165 }
19166 }
19167 }
19168
19169
19170
19171 //----- (0044861E) --------------------------------------------------------
19172 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
19173 {
19174 unsigned int v2; // eax@2
19175 unsigned __int16 v3; // di@2
19176 signed int v4; // esi@5
19177 BLVFace *v5; // eax@7
19178 unsigned int *v6; // eax@8
19179 char *v7; // eax@9
19180 int v8; // edi@16
19181 char *v9; // esi@16
19182 ODMFace *v10; // eax@17
19183 unsigned int *v11; // eax@19
19184 unsigned __int16 v12; // [sp+Ch] [bp-18h]@2
19185 const char *Str2; // [sp+10h] [bp-14h]@1
19186 unsigned int v14; // [sp+14h] [bp-10h]@1
19187 signed int v15; // [sp+18h] [bp-Ch]@14
19188 int v16; // [sp+1Ch] [bp-8h]@15
19189 signed int v17; // [sp+20h] [bp-4h]@4
19190 signed int v18; // [sp+20h] [bp-4h]@16
19191
19192 Str2 = pFilename;
19193 v14 = uFaceCog;
19194 if ( uFaceCog )
19195 {
19196 v2 = pBitmaps_LOD->LoadTexture(pFilename);
19197 v3 = v2;
19198 v12 = v2;
19199 if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 )
19200 {
19201 HIWORD(pBitmaps_LOD->pTextures[v2].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette);
19202
19203 if ( uCurrentlyLoadedLevelType == 1 )
19204 {
19205 v17 = 1;
19206 if ( (signed int)pIndoor->uNumFaceExtras > 1 )
19207 {
19208 v4 = 1;
19209 do
19210 {
19211 if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 )
19212 {
19213 v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C];
19214 if ( BYTE1(v5->uAttributes) & 0x40 )
19215 {
19216 pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(
19217 Str2);
19218 v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID;
19219 if ( *(_WORD *)v6 )
19220 {
19221 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6);
19222 }
19223 else
19224 {
19225 *(_WORD *)v6 = v3;
19226 v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
19227 v7[1] &= 0xBFu;
19228 }
19229 }
19230 else
19231 {
19232 v5->uBitmapID = v3;
19233 }
19234 }
19235 ++v17;
19236 ++v4;
19237 }
19238 while ( v17 < (signed int)pIndoor->uNumFaceExtras );
19239 }
19240 pParty->uFlags |= 2u;
19241 }
19242 else
19243 {
19244 v15 = 0;
19245 if ( (signed int)pOutdoor->uNumBModels > 0 )
19246 {
19247 v16 = 0;
19248 do
19249 {
19250 v8 = 0;
19251 v9 = (char *)&pOutdoor->pBModels[v16].pVertices;
19252 v18 = 0;
19253 if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 )
19254 {
19255 do
19256 {
19257 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
19258 if ( v10->sCogNumber == v14 )
19259 {
19260 if ( BYTE1(v10->uFaceAttributes) & 0x40 )
19261 {
19262 *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
19263 Str2);
19264 v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272);
19265 if ( *(_WORD *)v11 )
19266 {
19267 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11);
19268 }
19269 else
19270 {
19271 *(_WORD *)v11 = v12;
19272 *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu;
19273 }
19274 }
19275 else
19276 {
19277 v10->uTextureID = v12;
19278 }
19279 }
19280 ++v18;
19281 v8 += 308;
19282 }
19283 while ( v18 < *((_DWORD *)v9 + 2) );
19284 }
19285 ++v15;
19286 ++v16;
19287 }
19288 while ( v15 < (signed int)pOutdoor->uNumBModels );
19289 }
19290 }
19291 pParty->uFlags |= 2u;
19292 }
19293 }
19294 }
19295
19296
19297
19298
19299 //----- (0044882F) --------------------------------------------------------
19300 void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName)
19301 {
19302 signed int v3; // ebp@1
19303 char *v4; // esi@2
19304 unsigned __int16 v5; // ax@6
19305 unsigned int v6; // [sp+4h] [bp-8h]@1
19306 int v7; // [sp+8h] [bp-4h]@1
19307
19308 v3 = 0;
19309 v7 = a2;
19310 v6 = uCog;
19311 if ( (signed int)uNumLevelDecorations > 0 )
19312 {
19313 v4 = (char *)&pLevelDecorations[0].field_2;
19314 do
19315 {
19316 if ( *((_WORD *)v4 + 9) == v6 )
19317 {
19318 if ( pFileName && _strcmpi(pFileName, "0") )
19319 {
19320 v5 = pDecorationList->GetDecorIdByName(pFileName);
19321 *((_WORD *)v4 - 1) = v5;
19322 pDecorationList->InitializeDecorationSprite((signed __int16)v5);
19323 }
19324 if ( v7 )
19325 *v4 &= 0xDFu;
19326 else
19327 *v4 |= 0x20u;
19328 pParty->uFlags |= 2u;
19329 }
19330 ++v3;
19331 v4 += 32;
19332 }
19333 while ( v3 < (signed int)uNumLevelDecorations );
19334 }
19335 }
19336
19337
19338 //----- (004488B6) --------------------------------------------------------
19339 unsigned __int16 DecorationList::GetDecorIdByName(const char *pName)
19340 {
19341 DecorationList *v2; // esi@1
19342 signed int uID; // edi@2
19343 signed int v4; // ebx@3
19344 unsigned __int16 result; // ax@6
19345
19346 v2 = this;
19347 if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) )
19348 {
19349 v4 = 1;
19350 while ( _strcmpi(pName, v2->pDecorations[v4].pName) )
19351 {
19352 ++uID;
19353 ++v4;
19354 if ( uID >= (signed int)v2->uNumDecorations )
19355 goto LABEL_6;
19356 }
19357 result = uID;
19358 }
19359 else
19360 {
19361 LABEL_6:
19362 result = 0;
19363 }
19364 return result;
19365 }
19366
19367
19368 //----- (0044892E) --------------------------------------------------------
19369 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
19370 {
19371 signed int v3; // esi@2
19372 signed int v4; // ecx@4
19373 char *v5; // eax@6
19374 int v6; // edi@13
19375 char *v7; // esi@13
19376 signed int v8; // ecx@13
19377 ODMFace *v9; // eax@14
19378 int v10; // [sp+0h] [bp-Ch]@1
19379 signed int v11; // [sp+4h] [bp-8h]@11
19380 int v12; // [sp+8h] [bp-4h]@12
19381
19382 v10 = sCogNumber;
19383 if ( sCogNumber )
19384 {
19385 v3 = 1;
19386 if ( uCurrentlyLoadedLevelType == 1 )
19387 {
19388 if ( (signed int)pIndoor->uNumFaceExtras > 1 )
19389 {
19390 v4 = 1;
19391 do
19392 {
19393 if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 )
19394 {
19395 v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
19396 if ( on )
19397 *(_DWORD *)v5 |= bit;
19398 else
19399 *(_DWORD *)v5 &= ~bit;
19400 }
19401 ++v3;
19402 ++v4;
19403 }
19404 while ( v3 < (signed int)pIndoor->uNumFaceExtras );
19405 }
19406 pParty->uFlags |= 2u;
19407 }
19408 else
19409 {
19410 v11 = 0;
19411 if ( (signed int)pOutdoor->uNumBModels > 0 )
19412 {
19413 v12 = 0;
19414 do
19415 {
19416 v6 = 0;
19417 v7 = (char *)&pOutdoor->pBModels[v12].pVertices;
19418 v8 = 0;
19419 if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 )
19420 {
19421 do
19422 {
19423 v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4));
19424 if ( v9->sCogNumber == v10 )
19425 {
19426 if ( on )
19427 v9->uFaceAttributes |= bit;
19428 else
19429 v9->uFaceAttributes &= ~bit;
19430 }
19431 ++v8;
19432 v6 += 308;
19433 }
19434 while ( v8 < *((_DWORD *)v7 + 2) );
19435 }
19436 ++v11;
19437 ++v12;
19438 }
19439 while ( v11 < (signed int)pOutdoor->uNumBModels );
19440 }
19441 }
19442 pParty->uFlags |= 2u;
19443 }
19444 }
19445
19446
19447 //----- (00448A17) --------------------------------------------------------
19448 void Chest::ToggleFlag(unsigned int uChestID, unsigned __int16 uFlag, unsigned int bToggle)
19449 {
19450 unsigned __int16 *pFlags; // eax@3
19451
19452 if ( (uChestID & 0x80000000u) == 0 && (signed int)uChestID <= 19 )
19453 {
19454 pFlags = &pChests[uChestID].uFlags;
19455 if ( bToggle )
19456 *pFlags |= uFlag;
19457 else
19458 *pFlags &= ~uFlag;
19459 }
19460 }
19461
19462 //----- (00448A40) --------------------------------------------------------
19463 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle)
19464 {
19465 unsigned __int16 *pState; // eax@6
19466
19467 if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) )
19468 {
19469 if ( bToggle )
19470 {
19471 pActors[uActorID].uAttributes |= uFlag;
19472 }
19473 else
19474 {
19475 if ( uFlag == 0x10000 )
19476 {
19477 pState = &pActors[uActorID].uAIState;
19478 if ( *pState == Disabled )
19479 *pState = Standing;
19480 }
19481 pActors[uActorID].uAttributes &= ~uFlag;
19482 }
19483 }
19484 }
19485
19486 //----- (00448A98) --------------------------------------------------------
19487 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
19488 {
19489 unsigned int v3; // ebx@1
19490 unsigned int v4; // ebp@1
19491 signed int v5; // edi@1
19492 char *v6; // esi@4
19493 size_t v7; // ecx@10
19494 char *v8; // eax@11
19495 unsigned __int16 v9; // dx@14
19496
19497 v4 = uGroupID;
19498 v5 = Standing;
19499 v3 = uFlag;
19500 if ( uGroupID )
19501 {
19502 if ( bToggle )
19503 {
19504 if ( (signed int)uNumActors > Standing )
19505 {
19506 v6 = (char *)&pActors[0].uAttributes;
19507 do
19508 {
19509 if ( *((_DWORD *)v6 + 168) == v4 )
19510 {
19511 *(_DWORD *)v6 |= v3;
19512 if ( v3 == 0x10000 )
19513 {
19514 *((_WORD *)v6 + 70) = Disabled;
19515 ((Actor *)(v6 - 36))->UpdateAnimation();
19516 }
19517 }
19518 ++v5;
19519 v6 += 836;
19520 }
19521 while ( v5 < (signed int)uNumActors );
19522 }
19523 }
19524 else
19525 {
19526 v7 = uNumActors;
19527 if ( (signed int)uNumActors > Standing )
19528 {
19529 v8 = (char *)&pActors[0].uAIState;
19530 do
19531 {
19532 if ( *((_DWORD *)v8 + 133) == v4 )
19533 {
19534 if ( v3 == 0x10000 )
19535 {
19536 v9 = *(_WORD *)v8;
19537 if ( *(_WORD *)v8 != Dead )
19538 {
19539 if ( v9 != 4 && v9 != 11 )
19540 *(_WORD *)v8 = Standing;
19541 }
19542 }
19543 *((_DWORD *)v8 - 35) &= ~v3;
19544 }
19545 v8 += 836;
19546 --v7;
19547 }
19548 while ( v7 );
19549 }
19550 }
19551 }
19552 }
19553
19554
19555 //----- (00448B45) --------------------------------------------------------
19556 void __thiscall GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
19557 {
19558 if ( bForceHide || GameUI_StatusBar_TimedStringTimeLeft && GetTickCount() >= GameUI_StatusBar_TimedStringTimeLeft )
19559 GameUI_StatusBar_TimedStringTimeLeft = 0;
19560 }
19561
19562 //----- (00448B67) --------------------------------------------------------
19563 void __thiscall OnTimer(int a1)
19564 {
19565 int v1; // ebp@1
19566 unsigned int v2; // ebx@4
19567 unsigned int v3; // edi@4
19568 char *v4; // esi@6
19569 __int16 v5; // ax@8
19570 int v6; // ecx@10
19571 unsigned int v7; // ebp@12
19572 int v8; // eax@16
19573 int v9; // eax@19
19574 unsigned __int64 v10; // qax@20
19575 int v11; // ecx@24
19576 int v12; // [sp+Ch] [bp-10h]@5
19577 unsigned int v13; // [sp+10h] [bp-Ch]@4
19578
19579 v1 = 0;
19580 if ( !pEventTimer->bPaused )
19581 {
19582 if ( a1 )
19583 dword_5773C0 = 0;
19584 v3 = HIDWORD(pParty->uTimePlayed);
19585 v2 = LODWORD(pParty->uTimePlayed);
19586 v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128;
19587 if ( v13 )
19588 {
19589 _5773B8_event_timer = pParty->uTimePlayed;
19590 v12 = 0;
19591 if ( dword_5B65C8 > 0 )
19592 {
19593 v4 = (char *)&array_5B5928[0].field_C;
19594 while ( 1 )
19595 {
19596 v5 = *(short *)v4;
19597 if ( *(short *)v4 != (short)v1 )
19598 break;
19599 v7 = *((int *)v4 - 2);
19600 if ( v7 <= v3 && (v7 < v3 || *((int *)v4 - 3) <= v2) )
19601 {
19602 if ( *((short *)v4 + 2) )
19603 {
19604 v8 = 29030400;
19605 }
19606 else
19607 {
19608 if ( *((short *)v4 + 3) )
19609 {
19610 v8 = 2419200;
19611 }
19612 else
19613 {
19614 v9 = -(*((short *)v4 + 4) != 0);
19615 v8 = (v9 & 0x7E900) + 86400;
19616 }
19617 }
19618 v10 = __PAIR__(v7, *((int *)v4 - 3)) + (signed __int64)((double)((signed __int64)v8 << 7) * 0.033333335);
19619 *((int *)v4 - 3) = v10;
19620 *((int *)v4 - 2) = HIDWORD(v10);
19621 if ( HIDWORD(v10) <= v3 && (HIDWORD(v10) < v3 || *((int *)v4 - 3) < v2) )
19622 {
19623 *((int *)v4 - 3) = v2;
19624 *((int *)v4 - 2) = v3;
19625 }
19626 v11 = *((short *)v4 - 2);
19627 dword_597F18 = *((short *)v4 - 1);
19628 EventProcessor(v11, 0, 1);
19629 dword_597F18 = 0;
19630 LABEL_25:
19631 v3 = HIDWORD(pParty->uTimePlayed);
19632 v2 = LODWORD(pParty->uTimePlayed);
19633 }
19634 LABEL_26:
19635 ++v12;
19636 v4 += 32;
19637 if ( v12 >= dword_5B65C8 )
19638 return;
19639 v1 = 0;
19640 }
19641 if ( v13 < v5 )
19642 {
19643 *(short *)v4 = v5 - v13;
19644 goto LABEL_26;
19645 }
19646 v6 = *((short *)v4 - 2);
19647 *(short *)v4 = *((short *)v4 + 1);
19648 dword_597F18 = *((short *)v4 - 1);
19649 EventProcessor(v6, 0, 1);
19650 dword_597F18 = v1;
19651 goto LABEL_25;
19652 }
19653 }
19654 }
19655 }
19656
19657 //----- (00481D77) --------------------------------------------------------
19658 void _outdoor_project(RenderVertexSoft *v)
19659 {
19660 double v1; // st7@1
19661 double v2; // st7@1
19662
19663 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001);
19664 v->flt_20 = v1;
19665 v2 = v1 * (double)pOutdoorCamera->int_fov_rad;
19666 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y;
19667 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z;
19668 }
19669
19670
19671 //----- (00448CF4) --------------------------------------------------------
19672 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName)
19673 {
19674 __int16 v8; // di@1
19675 __int16 v9; // si@1
19676 unsigned int v10; // eax@1
19677 size_t v11; // ebx@2
19678 signed int v12; // esi@2
19679 char *v13;//Actor_uYawAngle_cr *v13; // ebx@3
19680 AIDirection a3; // [sp+Ch] [bp-50h]@2
19681 AIDirection v15; // [sp+28h] [bp-34h]@2
19682 //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
19683
19684 v8 = typeindex;
19685 v9 = level;
19686
19687 SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
19688 //SpawnPointMM7::SpawnPointMM7(&v16);
19689
19690 v16.vPosition.x = x;
19691 v16.vPosition.y = y;
19692 v16.vPosition.z = z;
19693 v16.uGroup = group;
19694 v16.uRadius = 32;
19695 v16.uKind = 3;
19696 v16.uIndex = v8 + 2 * v9 + v9;
19697 v10 = pMapStats->GetMapInfo(pCurrentMapName);
19698 if ( v10 )
19699 {
19700 v11 = uNumActors;
19701 SpawnEncounter((MapInfo *)&pMapStats + v10, &v16, 0, count, 0);
19702 memcpy(&v15, Actor::GetDirectionInfo(8 * v11 | AI_OBJECT_ACTOR, 4u, &a3, 1), sizeof(v15));
19703 v12 = v11;
19704 if ( (signed int)v11 < (signed int)uNumActors )
19705 {
19706 v13 = (char *)&pActors[v11].uYawAngle;
19707 do
19708 {
19709 ((Actor *)((char *)v13 - 154))->PrepareSprites(0);
19710 ++v12;
19711 *(short *)v13/*->uYawAngle*/ = LOWORD(v15.uYawAngle);
19712 *(int *)(v13+666)/*->dword_000334_unique_name*/ = uUniqueName;
19713 ++v13;
19714 }
19715 while ( v12 < (signed int)uNumActors );
19716 }
19717 }
19718 }
19719
19720
19721 //----- (00448DF8) --------------------------------------------------------
19722 void __fastcall sub_448DF8_cast_spell(int spellnum, int rank, int level, int fromx, int fromy, int fromz, int tox, int toy, int toz)
19723 {
19724 int v9; // esi@1
19725 double v10; // st7@4
19726 double v11; // st6@4
19727 double v12; // st5@4
19728 double v13; // st7@6
19729 int v14; // ST44_4@7
19730 signed int v15; // ebx@9
19731 signed int v16; // edx@15
19732 char *v17; // ecx@16
19733 unsigned __int16 v18; // ax@20
19734 char *v19; // ecx@31
19735 int v20; // edx@35
19736 signed int v21; // edx@37
19737 char *v22; // ecx@38
19738 unsigned __int16 v23; // ax@41
19739 int i; // esi@42
19740 signed int v25; // edx@55
19741 char *v26; // ecx@56
19742 unsigned __int16 v27; // ax@59
19743 int j; // esi@60
19744 signed int v29; // edx@66
19745 char *v30; // ecx@67
19746 unsigned __int16 v31; // ax@70
19747 char *v32; // eax@80
19748 unsigned __int16 v33; // si@85
19749 int v34; // eax@96
19750 int v35; // eax@97
19751 unsigned __int64 v36; // qax@99
19752 SpellBuff *v37; // ecx@99
19753 int v38; // esi@103
19754 signed __int64 v39; // qax@105
19755 int v40; // ebx@108
19756 int v41; // ebx@109
19757 int v42; // esi@111
19758 int v43; // ebx@111
19759 int v44; // eax@117
19760 unsigned __int16 v45; // si@137
19761 unsigned __int16 v46; // [sp-8h] [bp-BCh]@99
19762 int v47; // [sp-4h] [bp-B8h]@35
19763 unsigned __int16 v48; // [sp-4h] [bp-B8h]@99
19764 int v49; // [sp+0h] [bp-B4h]@35
19765 int v50; // [sp+0h] [bp-B4h]@99
19766 int v51; // [sp+4h] [bp-B0h]@35
19767 unsigned __int8 v52; // [sp+4h] [bp-B0h]@99
19768 float v53; // [sp+14h] [bp-A0h]@4
19769 float v54; // [sp+18h] [bp-9Ch]@4
19770 int v55; // [sp+28h] [bp-8Ch]@7
19771 unsigned int yaw; // [sp+30h] [bp-84h]@7
19772 int pitch; // [sp+34h] [bp-80h]@7
19773 //LayingItem a1; // [sp+38h] [bp-7Ch]@12
19774 int v59; // [sp+A8h] [bp-Ch]@1
19775 int v60; // [sp+ACh] [bp-8h]@1
19776 int spellnum_; // [sp+B0h] [bp-4h]@1
19777 signed int levela; // [sp+BCh] [bp+8h]@80
19778 int a6_4; // [sp+C8h] [bp+14h]@117
19779 float a7a; // [sp+CCh] [bp+18h]@6
19780 signed int a7b; // [sp+CCh] [bp+18h]@12
19781 int a7c; // [sp+CCh] [bp+18h]@29
19782 int a7d; // [sp+CCh] [bp+18h]@55
19783 float a8a; // [sp+D0h] [bp+1Ch]@6
19784 int a8b; // [sp+D0h] [bp+1Ch]@37
19785 int a8c; // [sp+D0h] [bp+1Ch]@55
19786 float toza; // [sp+D4h] [bp+20h]@6
19787
19788 v9 = 0;
19789 v59 = rank + 1;
19790 spellnum_ = spellnum;
19791 v60 = 0;
19792 if ( tox || toy || toz )
19793 {
19794 v10 = (double)tox - (double)fromx;
19795 v53 = v10;
19796 v11 = (double)toy - (double)fromy;
19797 v54 = v11;
19798 v12 = (double)toz;
19799 }
19800 else
19801 {
19802 v10 = (double)pParty->vPosition.x - (double)fromx;
19803 v53 = v10;
19804 v11 = (double)pParty->vPosition.z - (double)fromy;
19805 v54 = v11;
19806 v12 = (double)(pParty->vPosition.y + pParty->sEyelevel);
19807 }
19808 a7a = v12 - (double)fromz;
19809 toza = v11 * v11;
19810 a8a = v10 * v10;
19811 v13 = sqrt(a7a * a7a + a8a + toza);
19812 if ( v13 <= 1.0 )
19813 {
19814 LOBYTE(v55) = 1;
19815 yaw = 0;
19816 pitch = 0;
19817 }
19818 else
19819 {
19820 v55 = (signed __int64)v13;
19821 v14 = (signed __int64)sqrt(a8a + toza);
19822 yaw = stru_5C6E00->Atan2((signed __int64)v53, (signed __int64)v54);
19823 pitch = stru_5C6E00->Atan2(v14, (signed __int64)a7a);
19824 }
19825 v15 = v59;
19826 if ( v59 <= 0 || v59 > 4 )
19827 v15 = 1;
19828 a7b = v15;
19829
19830 LayingItem a1; // [sp+38h] [bp-7Ch]@12
19831 //LayingItem::LayingItem(&a1);
19832
19833 a1.uItemType = stru_4E3ACC[spellnum_].uItemType;
19834 if ( spellnum_ > 58 )
19835 {
19836 if ( spellnum_ == 69 )
19837 goto LABEL_117;
19838 if ( spellnum_ != 83 )
19839 return;
19840 v40 = v15 - 2;
19841 if ( v40 )
19842 {
19843 v41 = v40 - 1;
19844 if ( !v41 )
19845 {
19846 v42 = 14400 * level;
19847 v43 = 4 * level + 10;
19848 goto LABEL_114;
19849 }
19850 if ( v41 == 1 )
19851 {
19852 v42 = 18000 * level;
19853 v43 = 5 * level + 10;
19854 goto LABEL_114;
19855 }
19856 }
19857 v42 = 10800 * level;
19858 v43 = 3 * level + 10;
19859 LABEL_114:
19860 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 0);
19861 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 1u);
19862 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 2u);
19863 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 3u);
19864 v52 = 0;
19865 v50 = 0;
19866 v48 = v43;
19867 v46 = a7b;
19868 v39 = (signed __int64)((double)(v42 << 7) * 0.033333335);
19869 v37 = &pParty->pPartyBuffs[2];
19870 LABEL_115:
19871 v36 = pParty->uTimePlayed + v39;
19872 LABEL_116:
19873 v37->Apply(v36, v46, v48, v50, v52);
19874 goto LABEL_139;
19875 }
19876 if ( spellnum_ != 58 )
19877 {
19878 switch ( spellnum_ )
19879 {
19880 case 2:
19881 case 6:
19882 case 18:
19883 case 26:
19884 case 29:
19885 case 32:
19886 case 39:
19887 case 41:
19888 a1.stru_24.Reset();
19889 v16 = 0;
19890 a1.field_48 = spellnum_;
19891 a1.field_4C = level;
19892 a1.field_50 = v15;
19893 if ( (signed int)pObjectList->uNumObjects <= 0 )
19894 goto LABEL_34;
19895 v17 = (char *)&pObjectList->pObjects->uObjectID;
19896 while ( (short)a1.uItemType != *(short *)v17 )
19897 {
19898 ++v16;
19899 v17 += 56;
19900 if ( v16 >= (signed int)pObjectList->uNumObjects )
19901 goto LABEL_34;
19902 }
19903 LABEL_20:
19904 v18 = v16;
19905 goto LABEL_35;
19906 case 24:
19907 switch ( v15 )
19908 {
19909 case 1:
19910 v60 = 1;
19911 break;
19912 case 2:
19913 v60 = 3;
19914 break;
19915 case 3:
19916 v60 = 5;
19917 break;
19918 case 4:
19919 v60 = 7;
19920 break;
19921 }
19922 a7c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
19923 if ( v60 != 1 )
19924 {
19925 a8b = a7c / (v60 - 1);
19926 a1.stru_24.Reset();
19927 v21 = 0;
19928 a1.field_48 = spellnum_;
19929 a1.field_4C = level;
19930 a1.field_50 = v15;
19931 if ( (signed int)pObjectList->uNumObjects <= 0 )
19932 {
19933 LABEL_41:
19934 v23 = 0;
19935 }
19936 else
19937 {
19938 v22 = (char *)&pObjectList->pObjects->uObjectID;
19939 while ( (short)a1.uItemType != *(short *)v22 )
19940 {
19941 ++v21;
19942 v22 += 56;
19943 if ( v21 >= (signed int)pObjectList->uNumObjects )
19944 goto LABEL_41;
19945 }
19946 v23 = v21;
19947 }
19948 a1.uObjectDescID = v23;
19949 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
19950 a1.vPosition.x = fromx;
19951 a1.uAttributes = 16;
19952 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
19953 a1.field_60_distance_related_prolly_lod = v55;
19954 a1.uSpriteFrameID = 0;
19955 a1.field_58 = 8002;
19956 a1.field_5C = 4;
19957 a1.uSoundID = 0;
19958 for ( i = a7c / -2; i <= a7c / 2; i += a8b )
19959 {
19960 a1.uFacing = i + yaw;
19961 a1.Create(
19962 (signed __int16)(i + (short)yaw),
19963 pitch,
19964 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
19965 0);
19966 }
19967 goto LABEL_139;
19968 }
19969 a1.stru_24.Reset();
19970 v16 = 0;
19971 a1.field_48 = spellnum_;
19972 a1.field_4C = level;
19973 a1.field_50 = v15;
19974 if ( (signed int)pObjectList->uNumObjects <= 0 )
19975 goto LABEL_34;
19976 v19 = (char *)&pObjectList->pObjects->uObjectID;
19977 do
19978 {
19979 if ( (short)a1.uItemType == *(short *)v19 )
19980 goto LABEL_20;
19981 ++v16;
19982 v19 += 56;
19983 }
19984 while ( v16 < (signed int)pObjectList->uNumObjects );
19985 LABEL_34:
19986 v18 = 0;
19987 LABEL_35:
19988 a1.uObjectDescID = v18;
19989 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
19990 a1.vPosition.x = fromx;
19991 a1.uAttributes = 16;
19992 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
19993 a1.field_60_distance_related_prolly_lod = v55;
19994 v20 = yaw;
19995 a1.uSpriteFrameID = 0;
19996 a1.field_58 = 8002;
19997 a1.field_5C = 0;
19998 a1.uFacing = yaw;
19999 a1.uSoundID = 0;
20000 v51 = 0;
20001 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
20002 v47 = pitch;
20003 goto LABEL_36;
20004 case 15:
20005 switch ( v15 )
20006 {
20007 case 1:
20008 v60 = 3;
20009 break;
20010 case 2:
20011 v60 = 5;
20012 break;
20013 case 3:
20014 v60 = 7;
20015 break;
20016 case 4:
20017 v60 = 9;
20018 break;
20019 }
20020 a7d = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
20021 a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1);
20022 a1.stru_24.Reset();
20023 v25 = 0;
20024 a1.field_48 = spellnum_;
20025 a1.field_4C = level;
20026 a1.field_50 = v15;
20027 if ( (signed int)pObjectList->uNumObjects <= 0 )
20028 goto LABEL_59;
20029 v26 = (char *)&pObjectList->pObjects->uObjectID;
20030 while ( (short)a1.uItemType != *(short *)v26 )
20031 {
20032 ++v25;
20033 v26 += 56;
20034 if ( v25 >= (signed int)pObjectList->uNumObjects )
20035 {
20036 LABEL_59:
20037 v27 = 0;
20038 goto LABEL_60;
20039 }
20040 }
20041 v27 = v25;
20042 LABEL_60:
20043 a1.uObjectDescID = v27;
20044 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
20045 a1.vPosition.x = fromx;
20046 a1.uAttributes = 16;
20047 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
20048 a1.field_60_distance_related_prolly_lod = v55;
20049 a1.uSpriteFrameID = 0;
20050 a1.field_58 = 8002;
20051 a1.field_5C = 4;
20052 a1.uSoundID = 0;
20053 for ( j = a7d / -2; j <= a7d / 2; j += a8c )
20054 {
20055 a1.uFacing = j + yaw;
20056 a1.Create(
20057 (signed __int16)(j + (short)yaw),
20058 pitch,
20059 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
20060 0);
20061 }
20062 goto LABEL_139;
20063 case 43:
20064 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
20065 return;
20066 a1.stru_24.Reset();
20067 v29 = 0;
20068 a1.field_48 = spellnum_;
20069 a1.field_4C = level;
20070 a1.field_50 = v15;
20071 if ( (signed int)pObjectList->uNumObjects <= 0 )
20072 goto LABEL_70;
20073 v30 = (char *)&pObjectList->pObjects->uObjectID;
20074 break;
20075 case 5:
20076 if ( v15 > 0 )
20077 {
20078 if ( v15 <= 2 )
20079 {
20080 v9 = 60 * (level + 60);
20081 }
20082 else
20083 {
20084 if ( v15 == 3 )
20085 {
20086 v9 = 180 * (level + 20);
20087 }
20088 else
20089 {
20090 if ( v15 == 4 )
20091 v9 = 240 * (level + 15);
20092 }
20093 }
20094 }
20095 levela = 1;
20096 v32 = (char *)&pParty->pPlayers[0].pConditions[1];
20097 do
20098 {
20099 if ( *(_QWORD *)v32 )
20100 levela = 0;
20101 v32 += 6972;
20102 }
20103 while ( (signed int)v32 < (signed int)&pParty->pHirelings[0].uFlags );
20104 if ( !levela )
20105 return;
20106 pParty->pPartyBuffs[8].Apply(
20107 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335),
20108 v15,
20109 0,
20110 0,
20111 0);
20112 v33 = spellnum_;
20113 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
20114 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 1u);
20115 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 2u);
20116 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 3u);
20117 goto LABEL_138;
20118 case 17:
20119 case 38:
20120 case 51:
20121 switch ( v15 )
20122 {
20123 case 1:
20124 case 2:
20125 v9 = 300 * (level + 12);
20126 break;
20127 case 3:
20128 v9 = 900 * (level + 4);
20129 break;
20130 case 4:
20131 v9 = 3600 * (level + 1);
20132 break;
20133 }
20134 switch ( spellnum_ )
20135 {
20136 case 17:
20137 v60 = 0;
20138 level = 14;
20139 break;
20140 case 38:
20141 v35 = level + 5;
20142 level = 15;
20143 v60 = v35;
20144 break;
20145 case 51:
20146 v34 = level + 5;
20147 level = 9;
20148 v60 = v34;
20149 break;
20150 }
20151 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
20152 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 1u);
20153 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 2u);
20154 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 3u);
20155 v52 = 0;
20156 v50 = 0;
20157 v48 = v60;
20158 v46 = v15;
20159 v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335);
20160 v37 = &pParty->pPartyBuffs[level];
20161 goto LABEL_116;
20162 case 8:
20163 if ( v15 == 2 || v15 == 3 || v15 != 4 )
20164 v38 = 60 * level;
20165 else
20166 v38 = 600 * level;
20167 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
20168 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 1u);
20169 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 2u);
20170 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 3u);
20171 v52 = 0;
20172 v50 = 0;
20173 v48 = level;
20174 v46 = v15;
20175 v39 = (signed __int64)((double)(v38 << 7) * 0.033333335);
20176 v37 = &pParty->pPartyBuffs[10];
20177 goto LABEL_115;
20178 case 3:
20179 case 14:
20180 case 25:
20181 case 36:
20182 goto LABEL_117;
20183 default:
20184 return;
20185 }
20186 while ( (short)a1.uItemType != *(short *)v30 )
20187 {
20188 ++v29;
20189 v30 += 56;
20190 if ( v29 >= (signed int)pObjectList->uNumObjects )
20191 {
20192 LABEL_70:
20193 v31 = 0;
20194 goto LABEL_71;
20195 }
20196 }
20197 v31 = v29;
20198 LABEL_71:
20199 a1.uObjectDescID = v31;
20200 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
20201 a1.vPosition.x = fromx;
20202 a1.uAttributes = 16;
20203 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
20204 a1.field_60_distance_related_prolly_lod = v55;
20205 a1.uSpriteFrameID = 0;
20206 a1.field_58 = 8002;
20207 a1.field_5C = 4;
20208 a1.uSoundID = 0;
20209 v51 = 0;
20210 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
20211 v20 = yaw;
20212 v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
20213 LABEL_36:
20214 a1.Create(v20, v47, v49, v51);
20215 goto LABEL_139;
20216 }
20217 LABEL_117:
20218 v44 = level;
20219 a6_4 = 3600 * level;
20220 if ( v15 == 1 )
20221 {
20222 LABEL_124:
20223 v60 = v44;
20224 goto LABEL_125;
20225 }
20226 if ( v15 == 2 )
20227 {
20228 v44 = 2 * level;
20229 goto LABEL_124;
20230 }
20231 if ( v15 == 3 )
20232 {
20233 v44 = 3 * level;
20234 goto LABEL_124;
20235 }
20236 if ( v15 == 4 )
20237 {
20238 v44 = 4 * level;
20239 goto LABEL_124;
20240 }
20241 LABEL_125:
20242 switch ( spellnum_ )
20243 {
20244 case 3:
20245 level = 6;
20246 break;
20247 case 14:
20248 level = 0;
20249 break;
20250 case 25:
20251 level = 17;
20252 break;
20253 case 36:
20254 level = 4;
20255 break;
20256 case 58:
20257 level = 12;
20258 break;
20259 case 69:
20260 level = 1;
20261 break;
20262 }
20263 v45 = spellnum_;
20264 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
20265 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 1u);
20266 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 2u);
20267 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 3u);
20268 pParty->pPartyBuffs[level].Apply(
20269 pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669),
20270 v15,
20271 v60,
20272 0,
20273 0);
20274 levela = 1;
20275 LABEL_138:
20276 if ( levela )
20277 LABEL_139:
20278 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[spellnum_], 0, 0, fromx, fromy, 0, 0, 0);
20279 }
20280 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
20281
20282 //----- (0044987B) --------------------------------------------------------
20283 char *__fastcall sub_44987B(const char *pMapName, unsigned int uStartingPointType)
20284 {
20285 const char *v2; // edi@1
20286 unsigned int v3; // ebx@1
20287 char *result; // eax@3
20288
20289 v2 = pMapName;
20290 v3 = uStartingPointType;
20291 pAudioPlayer->StopChannels(-1, -1);
20292 pGameLoadingUI_ProgressBar->_443484(0);
20293 if ( _strcmpi(pCurrentMapName, v2) )
20294 SaveGame(1, 0);
20295 uGameState = 2;
20296 result = strcpy(pCurrentMapName, v2);
20297 uLevel_StartingPointType = v3;
20298 return result;
20299 }
20300 // 6BE35C: using guessed type int uLevel_StartingPointType;
20301
20302 //----- (004498D5) --------------------------------------------------------
20303 void __thiscall TeleportToStartingPoint(unsigned int uPointType)
20304 {
20305 unsigned int v1; // ecx@2
20306 int v2; // ecx@3
20307 int v3; // ecx@4
20308 unsigned __int16 v4; // ax@11
20309 signed int v5; // ecx@12
20310 LevelDecoration *v6; // edx@13
20311 signed int v7; // ecx@17
20312 int v8; // eax@17
20313 int v9; // ecx@17
20314 const char *v10; // [sp-4h] [bp-84h]@6
20315 char pName[128]; // [sp+8h] [bp-78h]@11
20316
20317 if ( uPointType )
20318 {
20319 v1 = uPointType - 1;
20320 if ( v1 )
20321 {
20322 v2 = v1 - 1;
20323 if ( v2 )
20324 {
20325 v3 = v2 - 1;
20326 if ( v3 )
20327 {
20328 if ( v3 != 1 )
20329 return;
20330 v10 = "West Start";
20331 }
20332 else
20333 {
20334 v10 = "East Start";
20335 }
20336 }
20337 else
20338 {
20339 v10 = "South Start";
20340 }
20341 }
20342 else
20343 {
20344 v10 = "North Start";
20345 }
20346 }
20347 else
20348 {
20349 v10 = "Party Start";
20350 }
20351 strcpy(pName, v10);
20352 v4 = pDecorationList->GetDecorIdByName(pName);
20353 if ( v4 )
20354 {
20355 v5 = 0;
20356 if ( (signed int)uNumLevelDecorations > 0 )
20357 {
20358 v6 = pLevelDecorations;
20359 while ( v6->uDecorationDescID != (signed __int16)v4 )
20360 {
20361 ++v5;
20362 ++v6;
20363 if ( v5 >= (signed int)uNumLevelDecorations )
20364 goto LABEL_20;
20365 }
20366 v7 = v5;
20367 pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
20368 pParty->vPosition.z = pLevelDecorations[v7].vPosition.y;
20369 pParty->vPosition.y = pLevelDecorations[v7].vPosition.z;
20370 pParty->uFallStartY = pParty->vPosition.y;
20371 v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90;
20372 v9 = pLevelDecorations[v7].field_10_y_rot;
20373 pParty->sRotationY = v8;
20374 if ( v9 )
20375 pParty->sRotationY = v9;
20376 pParty->sRotationX = 0;
20377 pParty->uFallSpeed = 0;
20378 }
20379 LABEL_20:
20380 if ( dword_5B65C0 )
20381 {
20382 if ( _5B65A8_npcdata_uflags_or_other )
20383 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other;
20384 if ( _5B65AC_npcdata_fame_or_other )
20385 pParty->vPosition.z = _5B65AC_npcdata_fame_or_other;
20386 if ( _5B65B0_npcdata_rep_or_other )
20387 {
20388 pParty->vPosition.y = _5B65B0_npcdata_rep_or_other;
20389 pParty->uFallStartY = _5B65B0_npcdata_rep_or_other;
20390 }
20391 if ( _5B65B4_npcdata_loword_house_or_other )
20392 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
20393 if ( _5B65B8_npcdata_hiword_house_or_other )
20394 pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other;
20395 if ( dword_5B65BC )
20396 pParty->uFallSpeed = dword_5B65BC;
20397 }
20398 _5B65B4_npcdata_loword_house_or_other = -1;
20399 dword_5B65C0 = 0;
20400 dword_5B65BC = 0;
20401 _5B65B8_npcdata_hiword_house_or_other = 0;
20402 _5B65B0_npcdata_rep_or_other = 0;
20403 _5B65AC_npcdata_fame_or_other = 0;
20404 _5B65A8_npcdata_uflags_or_other = 0;
20405 }
20406 }
20407 // 5B65A8: using guessed type int _5B65A8_npcdata_uflags_or_other;
20408 // 5B65AC: using guessed type int _5B65AC_npcdata_fame_or_other;
20409 // 5B65B0: using guessed type int _5B65B0_npcdata_rep_or_other;
20410 // 5B65B4: using guessed type int _5B65B4_npcdata_loword_house_or_other;
20411 // 5B65B8: using guessed type int _5B65B8_npcdata_hiword_house_or_other;
20412 // 5B65BC: using guessed type int dword_5B65BC;
20413 // 5B65C0: using guessed type int dword_5B65C0;
20414
20415 //----- (00449A49) --------------------------------------------------------
20416 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2)
20417 {
20418 int v2; // eax@1
20419 int v3; // ebx@1
20420 signed int v4; // esi@2
20421 int v5; // edx@2
20422 BLVDoor *v6; // ecx@8
20423 unsigned int v7; // edx@18
20424 signed int v8; // esi@19
20425 int v9; // eax@19
20426 char Args; // [sp+Ch] [bp-78h]@6
20427
20428 LOWORD(v2) = LOWORD(pIndoor->pDoors);
20429 v3 = a2;
20430 if ( !pIndoor->pDoors )
20431 return v2;
20432 v4 = 0;
20433 v5 = (int)&pIndoor->pDoors->uDoorID;
20434 do
20435 {
20436 if ( *(int *)v5 == uDoorID )
20437 break;
20438 ++v4;
20439 v5 += 80;
20440 }
20441 while ( v4 < 200 );
20442 if ( v4 >= 200 )
20443 {
20444 sprintfex(&Args, "Unable to find Door ID: %i!", uDoorID);
20445 Abortf(&Args);
20446 }
20447 v6 = &pIndoor->pDoors[v4];
20448 if ( v3 == 2 )
20449 {
20450 LOWORD(v2) = v6->uState;
20451 if ( (short)v2 == 3 || (short)v2 == 1 )
20452 return v2;
20453 if ( (short)v2 )
20454 goto LABEL_14;
20455 }
20456 else
20457 {
20458 if ( !v3 )
20459 {
20460 LABEL_14:
20461 LOWORD(v2) = v6->uState;
20462 if ( (short)v2 && (short)v2 != 3 )
20463 {
20464 v6->uState = 3;
20465 if ( (short)v2 == 2 )
20466 {
20467 LABEL_17:
20468 v6->uTimeSinceTriggered = 0;
20469 return v2;
20470 }
20471 v7 = v6->uTimeSinceTriggered;
20472 v2 = 15360;
20473 if ( v7 != 15360 )
20474 {
20475 v8 = v6->uOpenSpeed;
20476 v9 = v6->uCloseSpeed;
20477 LABEL_26:
20478 v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8;
20479 goto LABEL_27;
20480 }
20481 goto LABEL_27;
20482 }
20483 return v2;
20484 }
20485 if ( v3 != 1 )
20486 return v2;
20487 }
20488 LOWORD(v2) = v6->uState;
20489 if ( (short)v2 != 2 && (short)v2 != 1 )
20490 {
20491 v6->uState = 1;
20492 if ( !(short)v2 )
20493 goto LABEL_17;
20494 v7 = v6->uTimeSinceTriggered;
20495 v2 = 15360;
20496 if ( v7 != 15360 )
20497 {
20498 v8 = v6->uCloseSpeed;
20499 v9 = v6->uOpenSpeed;
20500 goto LABEL_26;
20501 }
20502 LABEL_27:
20503 v6->uTimeSinceTriggered = v2;
20504 }
20505 return v2;
20506 }
20507
20508 //----- (00449B57) --------------------------------------------------------
20509 unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
20510 {
20511 return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8);
20512 }
20513
20514 //----- (00449B7E) --------------------------------------------------------
20515 char *__fastcall _449B7E_toggle_bit(char *pArray, __int16 a2, unsigned __int16 bToggle)
20516 {
20517 signed int v3; // esi@1
20518 char *result; // eax@1
20519 unsigned int v5; // edx@1
20520
20521 v3 = a2 - 1;
20522 result = &pArray[(signed __int16)(v3 >> 3)];
20523 v5 = 0x80u >> v3 % 8;
20524 if ( bToggle )
20525 *result |= v5;
20526 else
20527 *result &= ~(char)v5;
20528 return result;
20529 }
20530
20531
20532 //----- (0044A56A) --------------------------------------------------------
20533 void __cdecl sub_44A56A()
20534 {
20535 signed int v0; // edi@1
20536 NPCData *v1; // esi@2
20537
20538 pParty->field_70A = 0;
20539 v0 = 0;
20540 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
20541 {
20542 v1 = pNPCStats->pNewNPCData;
20543 do
20544 {
20545 if ( v1->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v1->pName, pParty->pHirelings[0].pName)) )
20546 {
20547 if ( !pParty->pHirelings[1].pName || strcmp(v1->pName, pParty->pHirelings[1].pName) )
20548 ++pParty->field_70A;
20549 }
20550 ++v0;
20551 ++v1;
20552 }
20553 while ( v0 < (signed int)pNPCStats->uNumNewNPCs );
20554 }
20555 }
20556
20557
20558 //----- (0044C175) --------------------------------------------------------
20559 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds)
20560 {
20561 unsigned int v2; // esi@1
20562 int i; // eax@1
20563
20564 v2 = uNumSeconds;
20565 strcpy(GameUI_StatusBar_TimedString, pString);
20566 GameUI_StatusBar_TimedStringTimeLeft = 1000 * v2 + GetTickCount();
20567 for ( i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString);
20568 i > 450;
20569 i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString) )
20570 byte_5C3427[strlen(GameUI_StatusBar_TimedString)] = 0;
20571 }
20572
20573 //----- (0044C1D0) --------------------------------------------------------
20574 void __cdecl ShowNothingHereStatus()
20575 {
20576 if ( !GameUI_StatusBar_TimedStringTimeLeft )
20577 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
20578 }
20579
20580
20581 //----- (0044C28B) --------------------------------------------------------
20582 signed int __cdecl const_2()
20583 {
20584 return 2;
20585 }
20586
20587 //----- (0044C28F) --------------------------------------------------------
20588 bool __cdecl sub_44C28F_open_nwc_dungeon()
20589 {
20590 bool result; // eax@1
20591
20592 result = _strcmpi("nwc.blv", pCurrentMapName);
20593 if ( result )
20594 {
20595 _5B65A8_npcdata_uflags_or_other = 0;
20596 _5B65AC_npcdata_fame_or_other = 0;
20597 _5B65B0_npcdata_rep_or_other = 0;
20598 _5B65B4_npcdata_loword_house_or_other = 0;
20599 _5B65B8_npcdata_hiword_house_or_other = 0;
20600 dword_5B65BC = 0;
20601 dword_5B65C0 = 0;
20602 pGameLoadingUI_ProgressBar->uType = 1;
20603 sub_44987B("nwc.blv", 0);
20604 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
20605 result = 1;
20606 }
20607 return result;
20608 }
20609 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
20610 // 5B65A8: using guessed type int _5B65A8_npcdata_uflags_or_other;
20611 // 5B65AC: using guessed type int _5B65AC_npcdata_fame_or_other;
20612 // 5B65B0: using guessed type int _5B65B0_npcdata_rep_or_other;
20613 // 5B65B4: using guessed type int _5B65B4_npcdata_loword_house_or_other;
20614 // 5B65B8: using guessed type int _5B65B8_npcdata_hiword_house_or_other;
20615 // 5B65BC: using guessed type int dword_5B65BC;
20616 // 5B65C0: using guessed type int dword_5B65C0;
20617
20618 //----- (0044C2F4) --------------------------------------------------------
20619 int LevelDecoration::IsInteractive()
20620 {
20621 signed int v1; // eax@1
20622
20623 v1 = this->uDecorationDescID;
20624 if ( v1 > 34 )
20625 {
20626 if ( v1 == 184 || v1 == 187 || v1 == 190 || v1 > 205 && v1 <= 221 )
20627 return 1;
20628 }
20629 else
20630 {
20631 if ( v1 == 34 || v1 >= 4 && (v1 <= 6 || v1 == 11 || v1 > 12 && (v1 <= 14 || v1 == 24)) )
20632 return 1;
20633 }
20634 return 0;
20635 }
20636
20637 //----- (0044C362) --------------------------------------------------------
20638 void Vec3_int_::Normalize_float()
20639 {
20640 Vec3_int_ *v1; // esi@1
20641 double v2; // st6@1
20642 float v3; // ST20_4@1
20643 double v4; // st5@1
20644 float v5; // ST18_4@1
20645 double v6; // st4@1
20646 float v7; // ST14_4@1
20647 float v8; // ST24_4@1
20648 float v9; // ST20_4@1
20649 double v10; // ST0C_8@1
20650 float v11; // ST18_4@1
20651 double v12; // ST0C_8@1
20652 float v13; // ST14_4@1
20653 double v14; // ST0C_8@1
20654
20655 v1 = this;
20656 v2 = (double)this->x * 0.000015258789;
20657 v3 = v2;
20658 v4 = (double)this->y * 0.000015258789;
20659 v5 = v4;
20660 v6 = (double)this->z * 0.000015258789;
20661 v7 = v6;
20662 v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2);
20663 v9 = v8 * v3 * 65536.0;
20664 v10 = v9 + 6.7553994e15;
20665 v1->x = LODWORD(v10);
20666 v11 = v8 * v5 * 65536.0;
20667 v12 = v11 + 6.7553994e15;
20668 v1->y = LODWORD(v12);
20669 v13 = v8 * v7 * 65536.0;
20670 v14 = v13 + 6.7553994e15;
20671 v1->z = LODWORD(v14);
20672 }
20673
20674 //----- (0044C448) --------------------------------------------------------
20675 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...)
20676 {
20677 GUIFont *result; // eax@1
20678 const char *v3; // edi@1
20679 const char **v4; // ebx@2
20680 unsigned int v5; // eax@3
20681 unsigned __int16 **v6; // ecx@6
20682 GUIFont *v7; // [sp+4h] [bp-Ch]@1
20683 int v8; // [sp+8h] [bp-8h]@1
20684 unsigned __int16 **v9; // [sp+Ch] [bp-4h]@2
20685
20686 result = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0);
20687 v3 = pFontPalette;
20688 v8 = 0;
20689 v7 = result;
20690 if ( pFontPalette )
20691 {
20692 v4 = &pFontPalette;
20693 v9 = result->pFontPalettes;
20694 do
20695 {
20696 v5 = pIcons_LOD->LoadTexture(v3, TEXTURE_16BIT_PALETTE);
20697 if ( v5 == -1 )
20698 {
20699 sprintfex(pTmpBuf, "Unable to open %s", v3);
20700 Abortf(pTmpBuf);
20701 }
20702 ++v4;
20703 v6 = v9;
20704 v3 = *v4;
20705 ++v8;
20706 ++v9;
20707 *v6 = (v5 != -1 ? pIcons_LOD->pTextures[v5].pPalette16 : 0);
20708 }
20709 while ( v3 );
20710 result = v7;
20711 }
20712 result->field_8 = v8;
20713 return result;
20714 }
20715
20716
20717
20718
20719 //----- (0044C768) --------------------------------------------------------
20720 char *__fastcall FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5)
20721 {
20722 const char *v5; // edi@1
20723 GUIFont *v6; // esi@1
20724 unsigned int v8; // eax@3
20725 int v9; // edi@3
20726 unsigned __int8 v10; // cl@4
20727 int v11; // edx@10
20728 GUICharMetric *v12; // ecx@10
20729 int v13; // edx@11
20730 int v14; // edx@12
20731 int v15; // edx@13
20732 unsigned int v16; // esi@15
20733 unsigned int v17; // edx@15
20734 unsigned int v18; // ecx@15
20735 int v19; // ebx@16
20736 unsigned __int8 v20; // zf@16
20737 char v21; // sf@16
20738 unsigned __int8 v22; // of@16
20739 int v23; // edi@16
20740 unsigned __int8 v24; // dl@17
20741 int v25; // edi@39
20742 int v26; // eax@42
20743 std::string v27; // [sp-18h] [bp-40h]@2
20744 const char *v28; // [sp-8h] [bp-30h]@2
20745 int v29; // [sp-4h] [bp-2Ch]@2
20746 const char *v30; // [sp+Ch] [bp-1Ch]@1
20747 char Str[3]; // [sp+10h] [bp-18h]@42
20748 char v32; // [sp+13h] [bp-15h]@42
20749 size_t v33; // [sp+14h] [bp-14h]@3
20750 unsigned int v34; // [sp+18h] [bp-10h]@3
20751 GUIFont *v35; // [sp+1Ch] [bp-Ch]@1
20752 int v36; // [sp+20h] [bp-8h]@3
20753 int v37; // [sp+24h] [bp-4h]@3
20754
20755 v5 = pInString;
20756 v6 = pFont;
20757 v30 = pInString;
20758 v35 = pFont;
20759 if ( !pInString )
20760 {
20761 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
20762 return 0;
20763 }
20764 v33 = strlen(pInString);
20765 strcpy(pTmpBuf3, v5);
20766 v8 = uX;
20767 v9 = 0;
20768 v36 = 0;
20769 v34 = uX;
20770 v37 = 0;
20771 if ( (signed int)v33 > 0 )
20772 {
20773 while ( 1 )
20774 {
20775 v10 = pTmpBuf3[v9];
20776 if ((v10 < v6->cFirstChar || v10 > v6->cLastChar)
20777 && v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' )
20778 goto LABEL_34;
20779 v11 = v10 - 9;
20780 v12 = &v6->pMetrics[v10];
20781 if ( !v11 )
20782 {
20783 strncpy(Str, &pTmpBuf3[v9 + 1], 3u);
20784 v32 = 0;
20785 v26 = atoi(Str);
20786 v8 = uX + v26;
20787 v25 = v9 + 3;
20788 v34 = v8;
20789 goto LABEL_43;
20790 }
20791 v13 = v11 - 1;
20792 if ( !v13 )
20793 break;
20794 v14 = v13 - 2;
20795 if ( !v14 )
20796 {
20797 v25 = v9 + 5;
20798 LABEL_43:
20799 v37 = v25;
20800 goto LABEL_34;
20801 }
20802 v15 = v14 - 1;
20803 if ( v15 )
20804 {
20805 if ( v15 != 19 )
20806 {
20807 v16 = v12->uRightSpacing;
20808 v17 = v12->uWidth;
20809 v18 = v12->uLeftSpacing;
20810 if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth )
20811 {
20812 if ( v37 > v36 )
20813 v8 += v18;
20814 v8 += v17;
20815 if ( v37 < (signed int)v33 )
20816 v8 += v16;
20817 v6 = v35;
20818 }
20819 else
20820 {
20821 v19 = v36;
20822 v8 = v34;
20823 v22 = __OFSUB__(v36, v37);
20824 v20 = v36 == v37;
20825 v21 = v36 - v37 < 0;
20826 v6 = v35;
20827 pTmpBuf3[v36] = 10;
20828 v23 = v19;
20829 if ( (unsigned __int8)(v21 ^ v22) | v20 )
20830 {
20831 do
20832 {
20833 v24 = pTmpBuf3[v23];
20834 if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 )
20835 {
20836 if ( v23 > v19 )
20837 v8 += v6->pMetrics[v24].uLeftSpacing;
20838 v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9);
20839 if ( v23 < v37 )
20840 v8 += v6->pMetrics[v24].uRightSpacing;
20841 }
20842 ++v23;
20843 }
20844 while ( v23 <= v37 );
20845 }
20846 }
20847 goto LABEL_34;
20848 }
20849 v8 += v12->uWidth;
20850 goto LABEL_41;
20851 }
20852 if ( !a5 )
20853 return (char *)v30;
20854 LABEL_34:
20855 v9 = v37++ + 1;
20856 if ( v37 >= (signed int)v33 )
20857 return pTmpBuf3;
20858 }
20859 v8 = v34;
20860 LABEL_41:
20861 v36 = v9;
20862 goto LABEL_34;
20863 }
20864 return pTmpBuf3;
20865 }
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877 //----- (00401000) --------------------------------------------------------
20878 void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int))
20879 {
20880 void *v4; // esi@2
20881 int v5; // edi@2
20882
20883 if ( numObjs - 1 >= 0 )
20884 {
20885 v4 = a1;
20886 v5 = numObjs;
20887 do
20888 {
20889 constructor((int)v4);
20890 v4 = (char *)v4 + objSize;
20891 --v5;
20892 }
20893 while ( v5 );
20894 }
20895 }
20896
20897
20898 //----- (004014E6) --------------------------------------------------------
20899 int __cdecl ODM_4014E6_AI()
20900 {
20901 int v0; // esi@2
20902 int v1; // eax@4
20903 int v2; // ebx@4
20904 unsigned int v3; // ecx@4
20905 int v4; // edx@5
20906 int v5; // edx@7
20907 unsigned int v6; // edx@9
20908 unsigned int v7; // ST20_4@10
20909 int v8; // eax@10
20910 int v9; // edi@10
20911 int v10; // ebx@14
20912 char v11; // zf@16
20913 int v12; // eax@22
20914 int result; // eax@24
20915 int v14; // edx@25
20916 int v15; // ecx@25
20917 int v16; // ebx@26
20918 unsigned int *v17; // ecx@27
20919 unsigned int v18; // esi@27
20920 int i; // edx@33
20921 char *v20; // ecx@34
20922 int v21; // [sp+Ch] [bp-14h]@4
20923 int v22; // [sp+10h] [bp-10h]@4
20924 int v23; // [sp+14h] [bp-Ch]@10
20925 int v24; // [sp+14h] [bp-Ch]@29
20926 signed int v25; // [sp+18h] [bp-8h]@1
20927 signed int v26; // [sp+18h] [bp-8h]@25
20928 int v27; // [sp+1Ch] [bp-4h]@1
20929
20930 pParty->uFlags &= 0xFFFFFFCFu;
20931 v27 = 0;
20932 v25 = 0;
20933 if ( (signed int)uNumActors > 0 )
20934 {
20935 v0 = (int)&pActors[0].uAttributes;
20936 do
20937 {
20938 *(char *)(v0 + 1) &= 0xFBu;
20939 if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
20940 goto LABEL_37;
20941 v22 = abs(pParty->vPosition.y - *(short *)(v0 + 110));
20942 v21 = abs(pParty->vPosition.z - *(short *)(v0 + 108));
20943 v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
20944 v2 = v21;
20945 v3 = v22;
20946 if ( v1 < v21 )
20947 {
20948 v4 = v1;
20949 v1 = v21;
20950 v2 = v4;
20951 }
20952 if ( v1 < v22 )
20953 {
20954 v5 = v1;
20955 v1 = v22;
20956 v3 = v5;
20957 }
20958 if ( v2 < (signed int)v3 )
20959 {
20960 v6 = v3;
20961 v3 = v2;
20962 v2 = v6;
20963 }
20964 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
20965 v8 = *(short *)(v0 + 100);
20966 v9 = v7 - v8;
20967 v23 = v7 - v8;
20968 if ( v23 < 0 )
20969 {
20970 v9 = 0;
20971 v23 = 0;
20972 }
20973 if ( v9 < 5632 )
20974 {
20975 v10 = *(int *)v0 & 0xFEFFFFFF;
20976 *(int *)v0 = v10;
20977 if ( v10 & 0x80000 || ((Actor *)(v0 - offsetof(Actor, uAttributes)))->GetActorsRelation(0) )
20978 {
20979 v11 = (pParty->uFlags & 0x10) == 0;
20980 *(int *)v0 = v10 | 0x1000000;
20981 if ( v11 && (double)v23 < 307.2 )
20982 pParty->uFlags |= 0x10u;
20983 if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
20984 pParty->uFlags |= 0x20u;
20985 }
20986 *(char *)(v0 + 1) |= 0x40u;
20987 v12 = v27++;
20988 ai_array_4F75E0[v12] = v9;
20989 ai_array_4F7DB0_actor_ids[v12] = v25;
20990 }
20991 else
20992 {
20993 LABEL_37:
20994 *(char *)(v0 + 1) &= 0xBFu;
20995 }
20996 ++v25;
20997 v0 += 836;
20998 }
20999 while ( v25 < (signed int)uNumActors );
21000 }
21001 result = v27;
21002 if ( v27 > 0 )
21003 {
21004 v14 = 0;
21005 v15 = 1;
21006 v26 = 1;
21007 do
21008 {
21009 while ( 1 )
21010 {
21011 v24 = v15;
21012 if ( v15 >= result )
21013 break;
21014 v16 = ai_array_4F75E0[v14];
21015 if ( v16 > ai_array_4F75E0[v15] )
21016 {
21017 v17 = &ai_array_4F7DB0_actor_ids[v15];
21018 v18 = ai_array_4F7DB0_actor_ids[v14];
21019 ai_array_4F7DB0_actor_ids[v14] = *v17;
21020 *v17 = v18;
21021 v15 = v24;
21022 ai_array_4F75E0[v14] = ai_array_4F75E0[v24];
21023 ai_array_4F75E0[v24] = v16;
21024 }
21025 result = v27;
21026 ++v15;
21027 }
21028 ++v14;
21029 v15 = v26 + 1;
21030 v26 = v15;
21031 }
21032 while ( v15 - 1 < result );
21033 }
21034 ai_arrays_size = result;
21035 if ( result > 30 )
21036 {
21037 result = 30;
21038 ai_arrays_size = 30;
21039 }
21040 for ( i = 0; i < result; ++i )
21041 {
21042 v20 = (char *)&pActors[ai_array_4F7DB0_actor_ids[i]].uAttributes;
21043 v20[1] |= 4u;
21044 }
21045 return result;
21046 }
21047 // 4F75D8: using guessed type int ai_arrays_size;
21048
21049 //----- (004016FA) --------------------------------------------------------
21050 int __cdecl BLV_4016FA_AI()
21051 {
21052 char *v0; // esi@2
21053 int v1; // eax@4
21054 int v2; // ebx@4
21055 unsigned int v3; // ecx@4
21056 int v4; // edx@5
21057 int v5; // edx@7
21058 unsigned int v6; // edx@9
21059 unsigned int v7; // ST24_4@10
21060 int v8; // eax@10
21061 int v9; // edi@10
21062 int v10; // ebx@14
21063 char v11; // zf@16
21064 int v12; // eax@22
21065 int v13; // edx@24
21066 int v14; // ecx@25
21067 int v15; // ebx@26
21068 unsigned int *v16; // ecx@27
21069 unsigned int v17; // esi@27
21070 int v18; // ecx@31
21071 signed int v19; // edi@31
21072 Actor *v20; // esi@32
21073 bool v21; // eax@33
21074 int v22; // eax@34
21075 signed int v23; // ebx@36
21076 char *v24; // esi@37
21077 signed int v25; // eax@40
21078 int v26; // eax@43
21079 int v27; // ebx@45
21080 int j; // edi@45
21081 unsigned int v29; // eax@46
21082 int v30; // eax@48
21083 int v31; // ecx@51
21084 int v32; // eax@51
21085 signed int v33; // eax@53
21086 __int64 v34; // qax@55
21087 char *v35; // ecx@56
21088 int v37; // [sp+Ch] [bp-18h]@1
21089 int v38; // [sp+10h] [bp-14h]@4
21090 int v39; // [sp+14h] [bp-10h]@4
21091 int v40; // [sp+18h] [bp-Ch]@10
21092 int v41; // [sp+18h] [bp-Ch]@29
21093 int i; // [sp+18h] [bp-Ch]@31
21094 signed int v43; // [sp+1Ch] [bp-8h]@1
21095 signed int v44; // [sp+1Ch] [bp-8h]@25
21096 int v45; // [sp+20h] [bp-4h]@1
21097
21098 pParty->uFlags &= 0xFFFFFFCFu;
21099 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
21100 v45 = 0;
21101 v43 = 0;
21102 if ( (signed int)uNumActors > 0 )
21103 {
21104 v0 = (char *)&pActors[0].uAttributes;
21105 do
21106 {
21107 v0[1] &= 0xFBu;
21108 if ( ! ((Actor *)(v0 - 36))->CanAct() )
21109 goto LABEL_60;
21110 v39 = abs(pParty->vPosition.y - *((short *)v0 + 55));
21111 v38 = abs(pParty->vPosition.z - *((short *)v0 + 54));
21112 v1 = abs(pParty->vPosition.x - *((short *)v0 + 53));
21113 v2 = v38;
21114 v3 = v39;
21115 if ( v1 < v38 )
21116 {
21117 v4 = v1;
21118 v1 = v38;
21119 v2 = v4;
21120 }
21121 if ( v1 < v39 )
21122 {
21123 v5 = v1;
21124 v1 = v39;
21125 v3 = v5;
21126 }
21127 if ( v2 < (signed int)v3 )
21128 {
21129 v6 = v3;
21130 v3 = v2;
21131 v2 = v6;
21132 }
21133 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
21134 v8 = *((short *)v0 + 50);
21135 v9 = v7 - v8;
21136 v40 = v7 - v8;
21137 if ( v40 < 0 )
21138 {
21139 v9 = 0;
21140 v40 = 0;
21141 }
21142 if ( v9 < 10240 )
21143 {
21144 v10 = *(int *)v0 & 0xFEFFFFFF;
21145 *(int *)v0 = v10;
21146 if ( v10 & 0x80000 || ((Actor *)(v0 - 36))->GetActorsRelation(0) )
21147 {
21148 v11 = (pParty->uFlags & 0x10) == 0;
21149 *(int *)v0 = v10 | 0x1000000;
21150 if ( v11 && (double)v40 < 307.2 )
21151 pParty->uFlags |= 0x10u;
21152 if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
21153 pParty->uFlags |= 0x20u;
21154 }
21155 v12 = v45++;
21156 ai_array_4F75E0[v12] = v9;
21157 ai_array_4F7DB0_actor_ids[v12] = v43;
21158 }
21159 else
21160 {
21161 LABEL_60:
21162 v0[1] &= 0xBFu;
21163 }
21164 ++v43;
21165 v0 += 836;
21166 }
21167 while ( v43 < (signed int)uNumActors );
21168 }
21169 v13 = 0;
21170 if ( v45 > 0 )
21171 {
21172 v14 = 1;
21173 v44 = 1;
21174 do
21175 {
21176 while ( 1 )
21177 {
21178 v41 = v14;
21179 if ( v14 >= v45 )
21180 break;
21181 v15 = ai_array_4F75E0[v13];
21182 if ( v15 > ai_array_4F75E0[v14] )
21183 {
21184 v16 = &ai_array_4F7DB0_actor_ids[v14];
21185 v17 = ai_array_4F7DB0_actor_ids[v13];
21186 ai_array_4F7DB0_actor_ids[v13] = *v16;
21187 *v16 = v17;
21188 v14 = v41;
21189 ai_array_4F75E0[v13] = ai_array_4F75E0[v41];
21190 ai_array_4F75E0[v41] = v15;
21191 }
21192 ++v14;
21193 }
21194 ++v13;
21195 v14 = v44 + 1;
21196 v44 = v14;
21197 }
21198 while ( v14 - 1 < v45 );
21199 }
21200 v18 = 0;
21201 v19 = 0;
21202 for ( i = 0; v18 < v45; i = v18 )
21203 {
21204 v20 = &pActors[ai_array_4F7DB0_actor_ids[v18]];
21205 if ( v20->uAttributes & 0x8000
21206 || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_array_4F7DB0_actor_ids[v18] | 3, 4u), v18 = i, v21) )
21207 {
21208 v22 = ai_array_4F7DB0_actor_ids[v18];
21209 v20->uAttributes |= 0x8000u;
21210 ai_array_4F6638_actor_ids[v19] = v22;
21211 ai_array_4F5E68[v19++] = ai_array_4F75E0[v18];
21212 if ( v19 >= 30 )
21213 break;
21214 }
21215 ++v18;
21216 }
21217 v23 = 0;
21218 ai_arrays_size = v19;
21219 if ( (signed int)uNumActors > 0 )
21220 {
21221 v24 = (char *)&pActors[0].uAttributes;
21222 do
21223 {
21224 if ( ((Actor *)(v24 - 36))->CanAct() && *((short *)v24 + 61) == v37 )
21225 {
21226 v25 = 0;
21227 if ( v19 <= 0 )
21228 {
21229 LABEL_43:
21230 v26 = ai_arrays_size;
21231 v24[1] |= 0x40u;
21232 ++ai_arrays_size;
21233 ai_array_4F6638_actor_ids[v26] = v23;
21234 }
21235 else
21236 {
21237 while ( ai_array_4F6638_actor_ids[v25] != v23 )
21238 {
21239 ++v25;
21240 if ( v25 >= v19 )
21241 goto LABEL_43;
21242 }
21243 }
21244 }
21245 ++v23;
21246 v24 += 836;
21247 }
21248 while ( v23 < (signed int)uNumActors );
21249 }
21250 v27 = ai_arrays_size;
21251 for ( j = 0; j < v45; ++j )
21252 {
21253 v29 = ai_array_4F7DB0_actor_ids[j];
21254 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() )
21255 {
21256 v30 = 0;
21257 if ( v27 <= 0 )
21258 {
21259 LABEL_51:
21260 v31 = ai_arrays_size;
21261 v32 = ai_array_4F7DB0_actor_ids[j];
21262 ++ai_arrays_size;
21263 ai_array_4F6638_actor_ids[v31] = v32;
21264 }
21265 else
21266 {
21267 while ( ai_array_4F6638_actor_ids[v30] != ai_array_4F7DB0_actor_ids[j] )
21268 {
21269 ++v30;
21270 if ( v30 >= v27 )
21271 goto LABEL_51;
21272 }
21273 }
21274 }
21275 }
21276 v33 = ai_arrays_size;
21277 if ( ai_arrays_size > 30 )
21278 {
21279 v33 = 30;
21280 ai_arrays_size = 30;
21281 }
21282 memcpy(ai_array_4F7DB0_actor_ids, ai_array_4F6638_actor_ids, 4 * v33);
21283 memcpy(ai_array_4F75E0, ai_array_4F5E68, 4 * ai_arrays_size);
21284 v34 = (unsigned int)ai_arrays_size;
21285 if ( ai_arrays_size > 0 )
21286 {
21287 do
21288 {
21289 v35 = (char *)&pActors[ai_array_4F7DB0_actor_ids[HIDWORD(v34)]].uAttributes;
21290 v35[1] |= 4u;
21291 ++HIDWORD(v34);
21292 }
21293 while ( SHIDWORD(v34) < (signed int)v34 );
21294 }
21295 return v34;
21296 }
21297 // 4F75D8: using guessed type int ai_arrays_size;
21298
21299 //----- (00401A91) --------------------------------------------------------
21300 void __cdecl sub_401A91_AI()
21301 {
21302 unsigned int v0; // esi@4
21303 int v1; // eax@7
21304 int v2; // ecx@7
21305 int v3; // eax@7
21306 signed int v4; // edi@10
21307 char *v5; // esi@12
21308 signed int v6; // eax@14
21309 __int16 v7; // cx@14
21310 Player **v8; // esi@20
21311 Player *pPlayer; // ecx@21
21312 Actor *pActor; // esi@34
21313 __int16 v11; // ax@34
21314 unsigned int v12; // eax@47
21315 signed int v13; // edi@47
21316 SpellBuff *v14; // ebx@47
21317 unsigned int v15; // edi@67
21318 char *v16; // eax@67
21319 unsigned int v17; // edx@67
21320 unsigned int v18; // ecx@67
21321 unsigned __int16 v19; // ax@72
21322 int *v20; // esi@80
21323 Actor *v21; // ebx@80
21324 unsigned __int16 v22; // ax@86
21325 signed int v23; // eax@94
21326 unsigned int v24; // eax@102
21327 signed int v25; // edi@102
21328 SpellBuff *v26; // esi@102
21329 unsigned int v27; // ecx@123
21330 unsigned int v28; // eax@123
21331 unsigned int v29; // eax@127
21332 AIDirection *v30; // eax@129
21333 unsigned __int16 v31; // ax@132
21334 unsigned int v32; // esi@142
21335 int v33; // eax@144
21336 int v34; // eax@147
21337 char v35; // al@150
21338 unsigned int v36; // edi@152
21339 signed int v37; // eax@154
21340 unsigned __int8 v38; // sf@158
21341 unsigned __int8 v39; // of@158
21342 signed int v40; // edx@166
21343 unsigned int v41; // ecx@166
21344 double v42; // st7@176
21345 double v43; // st6@176
21346 bool v44; // eax@189
21347 bool v45; // eax@192
21348 unsigned __int8 v46; // cl@197
21349 double v47; // st7@206
21350 double v48; // st7@207
21351 char v49; // zf@208
21352 char v50; // zf@214
21353 signed int v51; // edx@219
21354 unsigned int v52; // ecx@219
21355 __int16 v53; // fps@224
21356 unsigned __int8 v54; // c0@224
21357 unsigned __int8 v55; // c3@224
21358 double v56; // st7@226
21359 AIDirection *v57; // eax@246
21360 double v58; // st7@246
21361 signed int v59; // [sp-18h] [bp-C8h]@213
21362 int v60; // [sp-14h] [bp-C4h]@144
21363 int v61; // [sp-14h] [bp-C4h]@168
21364 AIDirection *v62; // [sp-14h] [bp-C4h]@213
21365 signed int v63; // [sp-14h] [bp-C4h]@216
21366 unsigned int v64; // [sp-14h] [bp-C4h]@219
21367 unsigned int v65; // [sp-10h] [bp-C0h]@144
21368 char v66; // [sp-10h] [bp-C0h]@147
21369 AIDirection *v67; // [sp-10h] [bp-C0h]@167
21370 int v68; // [sp-10h] [bp-C0h]@168
21371 AIDirection *v69; // [sp-10h] [bp-C0h]@206
21372 int v70; // [sp-10h] [bp-C0h]@213
21373 AIDirection *v71; // [sp-10h] [bp-C0h]@216
21374 AIDirection v72; // [sp+0h] [bp-B0h]@246
21375 AIDirection a3; // [sp+1Ch] [bp-94h]@129
21376 AIDirection v74; // [sp+38h] [bp-78h]@246
21377 AIDirection v75; // [sp+54h] [bp-5Ch]@129
21378 int v76; // [sp+70h] [bp-40h]@83
21379 signed int a1; // [sp+74h] [bp-3Ch]@129
21380 int v78; // [sp+78h] [bp-38h]@79
21381 AIDirection pDir; // [sp+7Ch] [bp-34h]@129
21382 float v80; // [sp+98h] [bp-18h]@33
21383 int v81; // [sp+9Ch] [bp-14h]@100
21384 int v82; // [sp+A0h] [bp-10h]@45
21385 unsigned int uActorID; // [sp+A4h] [bp-Ch]@32
21386 unsigned int v84; // [sp+A8h] [bp-8h]@11
21387 signed int a2; // [sp+ACh] [bp-4h]@83
21388
21389 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
21390 ODM_4014E6_AI();
21391 else
21392 BLV_4016FA_AI();
21393 v0 = 0;
21394 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->field_1613C > 0 )
21395 {
21396 if ( pParty->field_1613C > 417 )
21397 {
21398 pParty->field_1613C = 0;
21399 }
21400 else
21401 {
21402 pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8);
21403 v1 = rand();
21404 v2 = 128;
21405 v3 = pParty->sRotationX + v1 % 16 - 8;
21406 pParty->sRotationX = v3;
21407 if ( v3 > 128 || (v2 = -128, v3 < -128) )
21408 pParty->sRotationX = v2;
21409 pParty->uFlags |= 2u;
21410 pParty->field_1613C -= pMiscTimer->uTimeElapsed;
21411 v4 = pParty->field_16140 + 50;
21412 if ( pParty->field_1613C <= 0 )
21413 {
21414 pParty->field_1613C = 0;
21415 v84 = 0;
21416 if ( (signed int)uNumActors > 0 )
21417 {
21418 v5 = (char *)&pActors[0].sCurrentHP;
21419 do
21420 {
21421 if ( ((Actor *)(v5 - 40))->CanAct() )
21422 {
21423 v6 = stru_50C198.CalcMagicalDamageToActor((Actor *)(v5 - 40), 5, v4);
21424 v7 = *(short *)v5 - v6;
21425 *(short *)v5 = v7;
21426 if ( v6 )
21427 {
21428 if ( v7 >= 0 )
21429 {
21430 Actor::_4030AD(v84, 4, 0);
21431 }
21432 else
21433 {
21434 Actor::Die(v84);
21435 if ( *((int *)v5 + 19) )
21436 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[*((short *)v5 + 28)].uExp);
21437 }
21438 }
21439 }
21440 ++v84;
21441 v5 += 836;
21442 }
21443 while ( (signed int)v84 < (signed int)uNumActors );
21444 }
21445 v8 = &pPlayers[1];
21446 do
21447 {
21448 pPlayer = *v8;
21449 if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
21450 pPlayer->ReceiveDamage(v4, 5);
21451 ++v8;
21452 }
21453 while ( (signed int)v8 <= (signed int)&pPlayers[4] );
21454 v0 = 0;
21455 }
21456 if ( pTurnEngine->field_1C != v0 )
21457 --pTurnEngine->field_1C;
21458 }
21459 }
21460 if ( pParty->bTurnBasedModeOn == 1 )
21461 {
21462 pTurnEngine->_405E14();
21463 return;
21464 }
21465 uActorID = v0;
21466 if ( (signed int)uNumActors > (signed int)v0 )
21467 {
21468 LODWORD(v80) = (int)(char *)pActors + 176;
21469 do
21470 {
21471 pActor = (Actor *)(LODWORD(v80) - 176);
21472 v11 = *(unsigned int *)LODWORD(v80);
21473 v49 = *(unsigned int *)LODWORD(v80) == 5;
21474 dword_4F6E08[uActorID] = 4;
21475 if ( v49 || v11 == 11 || v11 == 19 || *(char *)(LODWORD(v80) - 139) & 4 )
21476 goto LABEL_78;
21477 if ( !*(short *)(LODWORD(v80) - 136) && v11 != 4 )
21478 Actor::Die(uActorID);
21479 v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
21480 v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1;
21481 v12 = 0;
21482 v13 = 0;
21483 v14 = (SpellBuff *)(LODWORD(v80) + 36);
21484 do
21485 {
21486 if ( v13 != 10 )
21487 {
21488 v14->_4585CA(pParty->uTimePlayed);
21489 v12 = 0;
21490 }
21491 ++v13;
21492 ++v14;
21493 }
21494 while ( v13 < 22 );
21495 if ( v84 != v12
21496 && SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12
21497 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12
21498 || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) )
21499 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
21500 if ( v82 != v12 )
21501 {
21502 pActor->pMonsterInfo.uHostilityType = 0;
21503 if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) <= (signed int)v12 )
21504 {
21505 if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) < (signed int)v12
21506 || LODWORD(pActor->pActorBuffs[1].uExpireTime) <= v12 )
21507 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
21508 }
21509 }
21510 if ( SHIDWORD(pActor->pActorBuffs[5].uExpireTime) > (signed int)v12
21511 || SHIDWORD(pActor->pActorBuffs[5].uExpireTime) >= (signed int)v12
21512 && LODWORD(pActor->pActorBuffs[5].uExpireTime)
21513 || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) > 0
21514 || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(pActor->pActorBuffs[6].uExpireTime) )
21515 goto LABEL_78;
21516 v15 = pMiscTimer->uTimeElapsed;
21517 v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
21518 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
21519 v17 = pActor->uCurrentActionTime;
21520 v18 = pActor->pMonsterInfo.uRecoveryTime;
21521 if ( (signed int)v18 > 0 )
21522 *(int *)v16 = v18 - v15;
21523 if ( *(int *)v16 < 0 )
21524 *(int *)v16 = 0;
21525 if ( (signed int)v17 < pActor->uCurrentActionLength )
21526 goto LABEL_78;
21527 v19 = pActor->uAIState;
21528 if ( v19 == Dying )
21529 {
21530 pActor->uAIState = Dead;
21531 }
21532 else
21533 {
21534 if ( v19 != 17 )
21535 {
21536 Actor::_403F58(uActorID, Dying, 256, 0);
21537 goto LABEL_78;
21538 }
21539 pActor->uAIState = 0;
21540 }
21541 pActor->uCurrentActionTime = 0;
21542 pActor->uCurrentActionLength = 0;
21543 pActor->UpdateAnimation();
21544 LABEL_78:
21545 ++uActorID;
21546 LODWORD(v80) += 836;
21547 }
21548 while ( (signed int)uActorID < (signed int)uNumActors );
21549 }
21550 v78 = 0;
21551 if ( ai_arrays_size > 0 )
21552 {
21553 while ( 1 )
21554 {
21555 uActorID = ai_array_4F7DB0_actor_ids[v78];
21556 v20 = &dword_4F6E08[uActorID];
21557 v21 = &pActors[uActorID];
21558 Actor::_401221(uActorID, &dword_4F6E08[uActorID], 1u);
21559 if ( v21->pMonsterInfo.uHostilityType && !*v20 )
21560 v21->pMonsterInfo.uHostilityType = 0;
21561 a2 = *v20;
21562 v76 = a2 & 7;
21563 if ( (a2 & 7) == 3 )
21564 v80 = 0.5;
21565 else
21566 v80 = 1.0;
21567 v22 = v21->uAIState;
21568 if ( v22 == 4 || v22 == 5 || v22 == 11 || v22 == 19 || v22 == 17 )
21569 goto LABEL_254;
21570 if ( !v21->sCurrentHP )
21571 Actor::Die(uActorID);
21572 if ( (signed __int64)v21->pActorBuffs[3].uExpireTime <= 0 )
21573 {
21574 v84 = 0;
21575 v23 = 1;
21576 }
21577 else
21578 {
21579 v23 = 1;
21580 v84 = 1;
21581 }
21582 if ( (signed __int64)v21->pActorBuffs[1].uExpireTime <= 0 )
21583 v82 = 0;
21584 else
21585 v82 = v23;
21586 if ( (signed __int64)v21->pActorBuffs[2].uExpireTime <= 0 )
21587 v81 = 0;
21588 else
21589 v81 = v23;
21590 v24 = 0;
21591 v25 = 0;
21592 v26 = v21->pActorBuffs;
21593 do
21594 {
21595 if ( v25 != 10 )
21596 {
21597 v26->_4585CA(pParty->uTimePlayed);
21598 v24 = 0;
21599 }
21600 ++v25;
21601 ++v26;
21602 }
21603 while ( v25 < 22 );
21604 if ( v84 != v24
21605 && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= (signed int)v24
21606 && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < (signed int)v24
21607 || LODWORD(v21->pActorBuffs[3].uExpireTime) <= v24) )
21608 v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
21609 if ( v82 != v24 )
21610 {
21611 v21->pMonsterInfo.uHostilityType = 0;
21612 if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= (signed int)v24 )
21613 {
21614 if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < (signed int)v24
21615 || LODWORD(v21->pActorBuffs[1].uExpireTime) <= v24 )
21616 v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
21617 }
21618 }
21619 if ( v81 != v24
21620 && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= (signed int)v24
21621 && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < (signed int)v24
21622 || LODWORD(v21->pActorBuffs[2].uExpireTime) <= v24) )
21623 {
21624 v21->uAIState = 11;
21625 goto LABEL_254;
21626 }
21627 if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )
21628 goto LABEL_254;
21629 v27 = pMiscTimer->uTimeElapsed;
21630 v28 = v21->pMonsterInfo.uRecoveryTime;
21631 v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
21632 if ( (signed int)v28 > 0 )
21633 v21->pMonsterInfo.uRecoveryTime = v28 - v27;
21634 if ( (v21->pMonsterInfo.uRecoveryTime & 0x80000000u) != 0 )
21635 v21->pMonsterInfo.uRecoveryTime = 0;
21636 v29 = v21->uAttributes;
21637 if ( !(v29 & 0x8000) )
21638 v21->uAttributes = v29 | 0x8000;
21639 a1 = 8 * uActorID | 3;
21640 v30 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0);
21641 v49 = v21->pMonsterInfo.uHostilityType == 0;
21642 memcpy(&v75, v30, sizeof(v75));
21643 memcpy(&pDir, &v75, sizeof(pDir));
21644 if ( !v49 && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
21645 {
21646 if ( v80 * 307.2 >= (double)(signed int)v75.uDistance
21647 && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9)
21648 || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 )
21649 {
21650 v32 = uActorID;
21651 goto LABEL_152;
21652 }
21653 }
21654 if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
21655 goto LABEL_254;
21656 if ( v21->uAIState == 2 )
21657 {
21658 v32 = uActorID;
21659 v35 = stru_50C198.special_ability_use_check(v21, uActorID);
21660 stru_50FE08.Add(
21661 a1,
21662 5120,
21663 v21->vPosition.x,
21664 v21->vPosition.y,
21665 v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
21666 v35,
21667 1);
21668 goto LABEL_152;
21669 }
21670 if ( v21->uAIState == 3 )
21671 {
21672 v34 = v21->pMonsterInfo.uMissleAttack1Type;
21673 v66 = 0;
21674 goto LABEL_149;
21675 }
21676 if ( v21->uAIState == 12 )
21677 {
21678 v34 = v21->pMonsterInfo.uMissleAttack2Type;
21679 v66 = 1;
21680 LABEL_149:
21681 v32 = uActorID;
21682 Actor::_404874(uActorID, &pDir, v34, v66);
21683 goto LABEL_152;
21684 }
21685 v32 = uActorID;
21686 if ( v21->uAIState == 13 )
21687 break;
21688 if ( v21->uAIState == 18 )
21689 {
21690 v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
21691 v60 = 3;
21692 v33 = v21->pMonsterInfo.uSpell2ID;
21693 LABEL_146:
21694 Actor::_404AC7(uActorID, &pDir, v33, v60, v65);
21695 }
21696 LABEL_152:
21697 v36 = v75.uDistance;
21698 if ( v21->pMonsterInfo.uHostilityType )
21699 goto LABEL_165;
21700 if ( v76 == 3 )
21701 {
21702 v36 = v75.uDistance;
21703 v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
21704 + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3);
21705 }
21706 else
21707 {
21708 v37 = 4;
21709 }
21710 if ( v37 == 1 )
21711 goto LABEL_257;
21712 if ( v37 == 2 )
21713 {
21714 v39 = __OFSUB__(v36, 1024);
21715 v38 = ((v36 - 1024) & 0x80000000u) != 0;
21716 }
21717 else
21718 {
21719 if ( v37 == 3 )
21720 {
21721 v39 = __OFSUB__(v36, 2560);
21722 v38 = ((v36 - 2560) & 0x80000000u) != 0;
21723 }
21724 else
21725 {
21726 if ( v37 != 4 )
21727 goto LABEL_165;
21728 v39 = __OFSUB__(v36, 5120);
21729 v38 = ((v36 - 5120) & 0x80000000u) != 0;
21730 }
21731 }
21732 if ( v38 ^ v39 )
21733 LABEL_257:
21734 v21->pMonsterInfo.uHostilityType = 4;
21735 LABEL_165:
21736 if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
21737 {
21738 v40 = a2;
21739 v41 = v32;
21740 if ( (signed int)v36 >= 10240 )
21741 {
21742 v68 = 0;
21743 v61 = 1024;
21744 goto LABEL_253;
21745 }
21746 v67 = &pDir;
21747 goto LABEL_182;
21748 }
21749 if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 )
21750 goto LABEL_241;
21751 if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 )
21752 {
21753 if ( v21->pMonsterInfo.uAIType == 1 )
21754 {
21755 v67 = &pDir;
21756 if ( v21->pMonsterInfo.uMovementType != 5 )
21757 goto LABEL_181;
21758 Actor::_403EB6(
21759 v32,
21760 a2,
21761 (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),
21762 &pDir);
21763 }
21764 else
21765 {
21766 if ( v21->pMonsterInfo.uAIType == 2 )
21767 {
21768 v84 = v21->sCurrentHP;
21769 v42 = (double)(signed int)v84;
21770 v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
21771 }
21772 else
21773 {
21774 if ( v21->pMonsterInfo.uAIType != 3 )
21775 goto LABEL_185;
21776 v84 = v21->sCurrentHP;
21777 v42 = (double)(signed int)v84;
21778 v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
21779 }
21780 if ( v43 > v42 && (signed int)v36 < 10240 )
21781 {
21782 v67 = &pDir;
21783 LABEL_181:
21784 v40 = a2;
21785 v41 = v32;
21786 LABEL_182:
21787 Actor::_402968(v41, v40, 0, v67);
21788 goto LABEL_254;
21789 }
21790 }
21791 }
21792 LABEL_185:
21793 v81 = v36 - v21->uActorRadius;
21794 if ( v76 == 3 )
21795 v81 -= pActors[a2 >> 3].uActorRadius;
21796 if ( v81 < 0 )
21797 v81 = 0;
21798 rand();
21799 v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0;
21800 v21->uAttributes &= 0xFBFFFF;
21801 v82 = 0;
21802 v49 = v21->pMonsterInfo.uMovementType == 5;
21803 v84 = v44;
21804 if ( v49 )
21805 v82 = 1;
21806 if ( v81 >= 5120 )
21807 goto LABEL_241;
21808 v45 = stru_50C198.special_ability_use_check(v21, v32);
21809 if ( !v45 )
21810 {
21811 if ( v21->pMonsterInfo.uMissleAttack1Type )
21812 {
21813 if ( v84 )
21814 {
21815 Actor::_403476(v32, a2, &pDir);
21816 goto LABEL_254;
21817 }
21818 LABEL_223:
21819 if ( v82 )
21820 goto LABEL_217;
21821 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
21822 //UNDEF(v53);
21823 v69 = &pDir;
21824 if ( !(v54 | v55) )
21825 goto LABEL_219;
21826 LABEL_225:
21827 Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
21828 goto LABEL_254;
21829 }
21830 v56 = v80 * 307.2;
21831 if ( (double)v81 >= v56 )
21832 {
21833 if ( v81 >= 1024 )
21834 {
21835 if ( v82 )
21836 goto LABEL_217;
21837 v71 = &pDir;
21838 v63 = 0;
21839 goto LABEL_240;
21840 }
21841 goto LABEL_235;
21842 }
21843 goto LABEL_227;
21844 }
21845 if ( v45 != 1 )
21846 {
21847 if ( v45 > 1 && v45 <= 3 )
21848 {
21849 if ( v45 == 2 )
21850 v46 = v21->pMonsterInfo.uSpell1ID;
21851 else
21852 v46 = v21->pMonsterInfo.uSpell2ID;
21853 if ( v46 )
21854 {
21855 if ( v84 )
21856 {
21857 if ( v45 == 2 )
21858 Actor::_403854(v32, a2, &pDir);
21859 else
21860 Actor::_403A60(v32, a2, &pDir);
21861 goto LABEL_254;
21862 }
21863 if ( v80 * 307.2 > (double)v81 || v82 )
21864 {
21865 LABEL_217:
21866 v69 = &pDir;
21867 LABEL_218:
21868 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
21869 LABEL_219:
21870 v51 = a2;
21871 v64 = (signed __int64)v47;
21872 v52 = v32;
21873 LABEL_247:
21874 Actor::_403EB6(v52, v51, v64, v69);
21875 goto LABEL_254;
21876 }
21877 v69 = &pDir;
21878 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
21879 goto LABEL_225;
21880 }
21881 v48 = v80 * 307.2;
21882 if ( (double)v81 >= v48 )
21883 {
21884 if ( v81 >= 1024 )
21885 {
21886 v50 = v82 == 0;
21887 LABEL_215:
21888 if ( !v50 )
21889 goto LABEL_217;
21890 v71 = &pDir;
21891 v63 = 256;
21892 LABEL_240:
21893 Actor::_402686(v32, a2, v63, v71);
21894 goto LABEL_254;
21895 }
21896 if ( v82 )
21897 goto LABEL_217;
21898 v70 = (signed __int64)v48;
21899 v62 = &pDir;
21900 v59 = 0;
21901 goto LABEL_237;
21902 }
21903 v49 = v84 == 0;
21904 goto LABEL_209;
21905 }
21906 LABEL_241:
21907 if ( !v21->pMonsterInfo.uMovementType )
21908 {
21909 v68 = 0;
21910 v61 = 1024;
21911 LABEL_252:
21912 v41 = v32;
21913 v40 = 4;
21914 LABEL_253:
21915 Actor::_4032B2(v41, v40, v61, v68);
21916 goto LABEL_254;
21917 }
21918 if ( v21->pMonsterInfo.uMovementType == 1 )
21919 {
21920 v68 = 0;
21921 v61 = 2560;
21922 goto LABEL_252;
21923 }
21924 if ( v21->pMonsterInfo.uMovementType == 2 )
21925 {
21926 v68 = 0;
21927 v61 = 5120;
21928 goto LABEL_252;
21929 }
21930 if ( v21->pMonsterInfo.uMovementType == 4 )
21931 {
21932 v68 = 0;
21933 v61 = 10240;
21934 goto LABEL_252;
21935 }
21936 if ( v21->pMonsterInfo.uMovementType == 5 )
21937 {
21938 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
21939 v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
21940 memcpy(&v74, v57, sizeof(v74));
21941 memcpy(&pDir, &v74, sizeof(pDir));
21942 v69 = &pDir;
21943 v52 = uActorID;
21944 v64 = (signed __int64)v58;
21945 v51 = 4;
21946 goto LABEL_247;
21947 }
21948 goto LABEL_254;
21949 }
21950 if ( !v21->pMonsterInfo.uMissleAttack2Type )
21951 {
21952 v56 = v80 * 307.2;
21953 if ( (double)v81 >= v56 )
21954 {
21955 if ( v81 >= 1024 )
21956 {
21957 v50 = v82 == 0;
21958 goto LABEL_215;
21959 }
21960 LABEL_235:
21961 if ( v82 )
21962 goto LABEL_217;
21963 v70 = (signed __int64)v56;
21964 v62 = &pDir;
21965 v59 = 0;
21966 LABEL_237:
21967 Actor::_40281C(v32, a2, v59, v62, v70);
21968 goto LABEL_254;
21969 }
21970 LABEL_227:
21971 v49 = v84 == 0;
21972 LABEL_209:
21973 v69 = &pDir;
21974 if ( v49 )
21975 goto LABEL_218;
21976 Actor::_403C6C(v32, a2, &pDir);
21977 goto LABEL_254;
21978 }
21979 if ( !v84 )
21980 goto LABEL_223;
21981 Actor::_40368B(v32, a2, &pDir);
21982 LABEL_254:
21983 ++v78;
21984 if ( v78 >= ai_arrays_size )
21985 return;
21986 }
21987 v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
21988 v60 = 2;
21989 v33 = v21->pMonsterInfo.uSpell1ID;
21990 goto LABEL_146;
21991 }
21992 }
21993
21994
21995
21996
21997 //----- (0040261D) --------------------------------------------------------
21998 int stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8)
21999 {
22000 int result; // eax@1
22001
22002 result = this->count;
22003 if ( this->count < 100 )
22004 {
22005 this->pIDs[result] = uID;
22006 this->pXs[this->count] = x;
22007 this->pYs[this->count] = y;
22008 this->pZs[this->count] = z;
22009 this->field_324[this->count] = a3;
22010 this->field_3EC[this->count] = a8;
22011 result = this->count;
22012 this->field_450[this->count++] = a7;
22013 }
22014 return result;
22015 }
22016
22017
22018
22019
22020
22021 //----- (00402CAE) --------------------------------------------------------
22022 int stru193_math::SinCos(int angle)
22023 {
22024 unsigned int v2; // edx@1
22025 unsigned int v3; // eax@1
22026 int result; // eax@4
22027
22028 v2 = this->uIntegerPi;
22029 v3 = this->uDoublePiMask & angle;
22030 if ( (signed int)v3 > (signed int)v2 )
22031 v3 = this->uIntegerDoublePi - v3;
22032 if ( (signed int)v3 >= (signed int)this->uIntegerHalfPi )
22033 result = -this->pCosTable[v2 - v3];
22034 else
22035 result = this->pCosTable[v3];
22036 return result;
22037 }
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052 //----- (00404544) --------------------------------------------------------
22053 signed int stru262_TurnBased::_404544()
22054 {
22055 stru262_TurnBased *v1; // ebx@1
22056 TurnBased_QueueElem *v2; // esi@2
22057 Actor *v3; // edi@4
22058 Actor *v4; // ecx@4
22059 Player *v5; // eax@7
22060 int v6; // ecx@15
22061 TurnBased_QueueElem *v7; // eax@16
22062 TurnBased_QueueElem *v8; // ecx@18
22063 int v9; // edx@19
22064 int v10; // esi@19
22065 int v11; // esi@21
22066 int v12; // ST0C_4@25
22067 int v13; // ST10_4@25
22068 int v14; // ST14_4@25
22069 int v15; // ST18_4@25
22070 signed int result; // eax@28
22071 TurnBased_QueueElem *v17; // edi@32
22072 int v18; // [sp+20h] [bp-Ch]@17
22073 int v19; // [sp+24h] [bp-8h]@1
22074 int v20; // [sp+28h] [bp-4h]@1
22075 signed int v21; // [sp+28h] [bp-4h]@16
22076 int v22; // [sp+28h] [bp-4h]@31
22077
22078 v20 = 0;
22079 v1 = this;
22080 v19 = this->uActorQueueSize;
22081 if ( this->uActorQueueSize > 0 )
22082 {
22083 v2 = this->pQueue;
22084 do
22085 {
22086 if ( (v2->uPackedID & 7) == 3 )
22087 {
22088 v3 = &pActors[v2->uPackedID >> 3];
22089 v4 = &pActors[v2->uPackedID >> 3];
22090 LOBYTE(v4->uAttributes) |= 0x80u;
22091 if ( !v4->CanAct() )
22092 {
22093 --v19;
22094 v2->field_4 = 1001;
22095 LOBYTE(v3->uAttributes) &= 0x7Fu;
22096 }
22097 }
22098 if ( (v2->uPackedID & 7) == 4 )
22099 {
22100 v5 = &pParty->pPlayers[v2->uPackedID >> 3];
22101 if ( v5->pConditions[14]
22102 || v5->pConditions[16]
22103 || v5->pConditions[15]
22104 || v5->pConditions[13]
22105 || v5->pConditions[12]
22106 || v5->pConditions[2] )
22107 {
22108 --v19;
22109 v2->field_4 = 1001;
22110 }
22111 }
22112 ++v20;
22113 ++v2;
22114 }
22115 while ( v20 < v1->uActorQueueSize );
22116 }
22117 v6 = v1->uActorQueueSize;
22118 if ( v6 > 0 )
22119 {
22120 v21 = 1;
22121 v7 = v1->pQueue;
22122 do
22123 {
22124 v18 = v21;
22125 if ( v21 < v6 )
22126 {
22127 v8 = v7 + 1;
22128 do
22129 {
22130 v9 = v8->field_4;
22131 v10 = v7->field_4;
22132 if ( v9 < v10
22133 || v9 == v10
22134 && ((v11 = v8->uPackedID & 7, v11 == 4) && (v7->uPackedID & 7) == 3
22135 || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) )
22136 {
22137 v12 = v7->uPackedID;
22138 v13 = v7->field_4;
22139 v14 = v7->uActionLength;
22140 v15 = v7->field_C;
22141 v7->uPackedID = v8->uPackedID;
22142 v7->field_4 = v8->field_4;
22143 v7->uActionLength = v8->uActionLength;
22144 v7->field_C = v8->field_C;
22145 v8->uPackedID = v12;
22146 v8->field_4 = v13;
22147 v8->uActionLength = v14;
22148 v8->field_C = v15;
22149 }
22150 ++v18;
22151 ++v8;
22152 }
22153 while ( v18 < v1->uActorQueueSize );
22154 }
22155 ++v21;
22156 v6 = v1->uActorQueueSize;
22157 ++v7;
22158 }
22159 while ( v21 - 1 < v6 );
22160 }
22161 v1->uActorQueueSize = v19;
22162 result = v1->pQueue[0].uPackedID;
22163 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
22164 {
22165 result = (result >> 3) + 1;
22166 uActiveCharacter = result;
22167 v1->field_18 |= 4u;
22168 }
22169 else
22170 {
22171 uActiveCharacter = 0;
22172 v1->field_18 &= 0xFFFFFFFBu;
22173 }
22174 v22 = 0;
22175 if ( v1->uActorQueueSize > 0 )
22176 {
22177 v17 = v1->pQueue;
22178 do
22179 {
22180 if ( (v17->uPackedID & 7) == 4 )
22181 pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875);
22182 ++v22;
22183 ++v17;
22184 result = v22;
22185 }
22186 while ( v22 < v1->uActorQueueSize );
22187 }
22188 return result;
22189 }
22190
22191 //----- (0040471C) --------------------------------------------------------
22192 int stru262_TurnBased::_40471C()
22193 {
22194 int result; // eax@3
22195
22196 if ( pParty->bTurnBasedModeOn == 1 )
22197 {
22198 if ( pTurnEngine->field_4 == 2 )
22199 result = _406457(0);
22200 }
22201 return result;
22202 }
22203
22204
22205 //----- (00404828) --------------------------------------------------------
22206 LayingItem::LayingItem()
22207 {
22208 LayingItem *v1; // esi@1
22209
22210 v1 = this;
22211 v1->field_22 = 1;
22212 v1->uSoundID = 0;
22213 v1->uFacing = 0;
22214 v1->vVelocity.z = 0;
22215 v1->vVelocity.y = 0;
22216 v1->vVelocity.x = 0;
22217 v1->uItemType = 0;
22218 v1->uObjectDescID = 0;
22219 v1->field_61 = 0;
22220 v1->field_60_distance_related_prolly_lod = 0;
22221 v1->field_20 = 0;
22222 v1->uSpriteFrameID = 0;
22223 v1->field_50 = 0;
22224 v1->field_4C = 0;
22225 v1->field_48 = 0;
22226 v1->field_54 = 0;
22227 }
22228
22229
22230
22231 //----- (004059DB) --------------------------------------------------------
22232 signed int stru262_TurnBased::Start()
22233 {
22234 stru262_TurnBased *v1; // ebx@1
22235 unsigned int v2; // edi@1
22236 int v3; // esi@1
22237 int v4; // eax@5
22238 unsigned int v5; // esi@7
22239 Actor *v6; // edi@7
22240 unsigned int v7; // eax@9
22241 unsigned int v8; // edx@10
22242 unsigned __int8 v9; // zf@14
22243 unsigned __int8 v10; // sf@14
22244 unsigned __int8 v11; // of@14
22245 char *v12; // esi@15
22246 int v13; // ecx@16
22247 unsigned __int16 v14; // ax@17
22248 int v15; // ecx@18
22249 signed __int64 v16; // qax@19
22250 int v17; // edx@22
22251 unsigned int v18; // esi@27
22252 char *v19; // esi@32
22253 int v20; // edx@33
22254 char *v21; // eax@33
22255 int v22; // ecx@33
22256 int v23; // eax@34
22257 char *v24; // eax@34
22258 char *v25; // ecx@34
22259 int v26; // edx@34
22260 int v27; // eax@38
22261 int v28; // ecx@38
22262 AIDirection v30; // [sp+Ch] [bp-68h]@10
22263 AIDirection v31; // [sp+28h] [bp-4Ch]@10
22264 AIDirection a3; // [sp+44h] [bp-30h]@10
22265 int v33; // [sp+60h] [bp-14h]@10
22266 int *v34; // [sp+64h] [bp-10h]@6
22267 int v35; // [sp+68h] [bp-Ch]@5
22268 int v40; // [sp+6Ch] [bp-8h]@1
22269 unsigned int v37; // [sp+70h] [bp-4h]@7
22270
22271 pTurnEngine->field_18 &= 0xFFFFFFFDu;
22272 v1 = this;
22273 pEventTimer->TrackGameTime();
22274 pAudioPlayer->StopChannels(-1, -1);
22275 v2 = 0;
22276 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
22277 v40 = (int)pParty->pPlayers;
22278 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
22279 dword_50C994 = 0;
22280 v1->field_10 = 100;
22281 v1->field_0 = 0;
22282 v1->field_8 = 64;
22283 v1->field_4 = 1;
22284 v1->uActorQueueSize = 0;
22285 v3 = 0;
22286 do
22287 {
22288 if ( ((Player *)v40)->CanAct() )
22289 {
22290 *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = 8 * v3 | OBJECT_Player;
22291 v1->pQueue[v1->uActorQueueSize].field_C = 2;
22292 v1->pQueue[v1->uActorQueueSize].uActionLength = 0;
22293 pParty->pTurnBasedPlayerRecoveryTimes[v1->uActorQueueSize++] = 0;
22294 }
22295 v40 += 6972;
22296 ++v3;
22297 }
22298 while ( v40 < (signed int)pParty->pHirelings );
22299 v35 = v1->uActorQueueSize;
22300 v4 = v35;
22301 v40 = v35;
22302 if ( v40 < v40 + ai_arrays_size )
22303 {
22304 v34 = (int *)ai_array_4F7DB0_actor_ids;
22305 do
22306 {
22307 v37 = *v34;
22308 v5 = v37;
22309 v6 = &pActors[v37];
22310 if ( v37 != 10 )
22311 {
22312 if ( pActors[v37].CanAct() )
22313 {
22314 v7 = v6->uAttributes;
22315 if ( v7 & 0x8000 < 0 )
22316 {
22317 v8 = dword_4F6E08[v5];
22318 LOBYTE(v7) = v7 | 0x80;
22319 v6->uAttributes = v7;
22320 v33 = 8 * v5 | OBJECT_Actor;
22321 memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31));
22322 memcpy(&v30, &v31, sizeof(v30));
22323 Actor::_403F58(v37, 4, 32, &v30);
22324 *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33;
22325 v1->pQueue[v1->uActorQueueSize].field_C = 2;
22326 v1->pQueue[v1->uActorQueueSize++].uActionLength = 0;
22327 }
22328 }
22329 v4 = v35;
22330 }
22331 ++v40;
22332 ++v34;
22333 }
22334 while ( v40 < v4 + ai_arrays_size );
22335 v2 = 0;
22336 }
22337 v11 = __OFSUB__(v1->uActorQueueSize, v2);
22338 v9 = v1->uActorQueueSize == v2;
22339 v10 = ((v1->uActorQueueSize - v2) & 0x80000000u) != 0;
22340 v37 = v2;
22341 v40 = v2;
22342 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
22343 {
22344 v12 = (char *)&v1->pQueue[0].field_4;
22345 while ( 1 )
22346 {
22347 v13 = *((int *)v12 - 1) & 7;
22348 if ( v13 != OBJECT_Player )
22349 break;
22350 v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery;
22351 if ( v14 != (short)v2 )
22352 {
22353 v33 = v14;
22354 v16 = (signed __int64)((double)v14 * 0.46875);
22355 LABEL_20:
22356 *(int *)v12 = v16;
22357 goto LABEL_26;
22358 }
22359 v15 = v37++;
22360 *(&a3.uDistance + v15) = v40;
22361 LABEL_26:
22362 ++v40;
22363 v12 += 16;
22364 if ( v40 >= v1->uActorQueueSize )
22365 goto LABEL_27;
22366 }
22367 if ( v13 != 3 )
22368 {
22369 *(int *)v12 = 666;
22370 goto LABEL_26;
22371 }
22372 v17 = rand() % 99;
22373 if ( v17 < 33 )
22374 {
22375 *(int *)v12 = 1;
22376 goto LABEL_26;
22377 }
22378 LODWORD(v16) = SHIDWORD(v16) < 66;
22379 LOBYTE(v16) = SHIDWORD(v16) >= 66;
22380 LODWORD(v16) = 2 * v16 + 3;
22381 goto LABEL_20;
22382 }
22383 LABEL_27:
22384 v18 = 0;
22385 if ( (signed int)v37 > (signed int)v2 )
22386 {
22387 do
22388 {
22389 *(&v31.uDistance + v18) = pParty->pPlayers[*(&v1->field_0 + 4 * (*(&a3.uDistance + v18) + 2)) >> 3].GetAttackRecoveryTime(
22390 v2);
22391 ++v18;
22392 }
22393 while ( (signed int)v18 < (signed int)v37 );
22394 if ( (signed int)v37 > (signed int)v2 )
22395 {
22396 v35 = v2;
22397 v34 = (int *)1;
22398 do
22399 {
22400 v40 = (int)v34;
22401 if ( (signed int)v34 < (signed int)v37 )
22402 {
22403 v19 = (char *)&v31.uDistance + v35;
22404 do
22405 {
22406 v20 = *(int *)v19;
22407 v33 = 4 * v40;
22408 v21 = (char *)(&v31.uDistance + v40);
22409 v22 = *(int *)v21;
22410 if ( *(int *)v21 < v20 )
22411 {
22412 *(int *)v21 = v20;
22413 v23 = v33;
22414 *(int *)v19 = v22;
22415 v24 = (char *)&a3.uDistance + v23;
22416 v25 = (char *)&a3.uDistance + v35;
22417 v26 = *(int *)v24;
22418 *(int *)v24 = *(unsigned int *)((char *)&a3.uDistance + v35);
22419 *(int *)v25 = v26;
22420 v2 = 0;
22421 }
22422 ++v40;
22423 }
22424 while ( v40 < (signed int)v37 );
22425 }
22426 v34 = (int *)((char *)v34 + 1);
22427 v35 += 4;
22428 }
22429 while ( (signed int)((char *)v34 - 1) < (signed int)v37 );
22430 if ( (signed int)v37 > (signed int)v2 )
22431 {
22432 do
22433 {
22434 v27 = v2 + 2;
22435 v28 = *(&a3.uDistance + v2++);
22436 v11 = __OFSUB__(v2, v37);
22437 v10 = ((v2 - v37) & 0x80000000u) != 0;
22438 v1->pQueue[v28].field_4 = v27;
22439 }
22440 while ( v10 ^ v11 );
22441 }
22442 }
22443 }
22444 return v1->_404544();
22445 }
22446