comparison mm7_3.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children a9e9c6989d04
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
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 #include "Log.h"
43
44 #include "mm7_data.h"
45
46
47
48
49
50
51
52
53 //----- (0046E44E) --------------------------------------------------------
54 int __thiscall _46E44E_collide_against_faces_and_portals(unsigned int b1)
55 {
56 BLVSector *v1; // edi@1
57 signed int v2; // ebx@1
58 BLVFace *v3; // esi@2
59 __int16 v4; // si@10
60 int v5; // ecx@12
61 unsigned __int8 v6; // sf@12
62 unsigned __int8 v7; // of@12
63 int result; // eax@14
64 BLVSector *v9; // ebx@15
65 int v10; // ecx@15
66 int v11; // eax@16
67 BLVFace *v12; // ebp@16
68 int v13; // eax@24
69 int v14; // esi@24
70 int v15; // eax@24
71 int v16; // edx@25
72 int v17; // eax@29
73 unsigned int v18; // eax@33
74 int v19; // eax@35
75 int v20; // edx@35
76 int v21; // eax@35
77 int v22; // ecx@36
78 int v23; // eax@40
79 unsigned int v24; // eax@44
80 int a3; // [sp+10h] [bp-48h]@28
81 int v26; // [sp+14h] [bp-44h]@15
82 int i; // [sp+18h] [bp-40h]@1
83 int a10; // [sp+1Ch] [bp-3Ch]@1
84 int v29; // [sp+20h] [bp-38h]@14
85 int v30; // [sp+24h] [bp-34h]@35
86 int v31; // [sp+28h] [bp-30h]@24
87 int v32; // [sp+2Ch] [bp-2Ch]@15
88 int v33[10]; // [sp+30h] [bp-28h]@1
89
90 v1 = &pIndoor->pSectors[stru_721530.uSectorID];
91 v2 = 0;
92 a10 = b1;
93 v33[0] = stru_721530.uSectorID;
94 for ( i = 1; v2 < v1->uNumPortals; ++v2 )
95 {
96 v3 = &pIndoor->pFaces[v1->pPortals[v2]];
97 if ( stru_721530.sMaxX <= v3->pBounding.x2
98 && stru_721530.sMinX >= v3->pBounding.x1
99 && stru_721530.sMaxY <= v3->pBounding.y2
100 && stru_721530.sMinY >= v3->pBounding.y1
101 && stru_721530.sMaxZ <= v3->pBounding.z2
102 && stru_721530.sMinZ >= v3->pBounding.z1
103 && abs((v3->pFacePlane_old.dist
104 + stru_721530.normal.x * v3->pFacePlane_old.vNormal.x
105 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
106 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 )
107 {
108 v4 = v3->uSectorID == stru_721530.uSectorID ? v3->uBackSectorID : v3->uSectorID;
109 v5 = i++;
110 v7 = __OFSUB__(i, 10);
111 v6 = i - 10 < 0;
112 v33[v5] = v4;
113 if ( !(v6 ^ v7) )
114 break;
115 }
116 }
117 result = 0;
118 v29 = 0;
119 if ( i > 0 )
120 {
121 while ( 1 )
122 {
123 v9 = &pIndoor->pSectors[v33[result]];
124 v10 = 0;
125 v32 = v9->uNumFloors + v9->field_C + v9->field_14;
126 v26 = 0;
127 if ( v32 > 0 )
128 break;
129 LABEL_46:
130 result = v29++ + 1;
131 if ( v29 >= i )
132 return result;
133 }
134 while ( 1 )
135 {
136 v11 = v9->pFloors[v10];
137 v12 = &pIndoor->pFaces[v11];
138 if ( v12->uAttributes & 1
139 || stru_721530.sMaxX > v12->pBounding.x2
140 || stru_721530.sMinX < v12->pBounding.x1
141 || stru_721530.sMaxY > v12->pBounding.y2
142 || stru_721530.sMinY < v12->pBounding.y1
143 || stru_721530.sMaxZ > v12->pBounding.z2
144 || stru_721530.sMinZ < v12->pBounding.z1
145 || v11 == stru_721530.field_84 )
146 goto LABEL_45;
147 v13 = v12->pFacePlane_old.vNormal.y;
148 v14 = v12->pFacePlane_old.dist;
149 v31 = v13;
150 v15 = (stru_721530.normal.x * v12->pFacePlane_old.vNormal.x
151 + v14
152 + stru_721530.normal.y * v13
153 + stru_721530.normal.z * v12->pFacePlane_old.vNormal.z) >> 16;
154 if ( v15 > 0 )
155 {
156 v16 = (stru_721530.normal2.y * v31
157 + v12->pFacePlane_old.dist
158 + stru_721530.normal2.z * v12->pFacePlane_old.vNormal.z
159 + stru_721530.normal2.x * v12->pFacePlane_old.vNormal.x) >> 16;
160 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
161 {
162 if ( v16 <= v15 )
163 {
164 a3 = stru_721530.field_6C;
165 if ( sub_47531C(
166 stru_721530.prolly_normal_d,
167 &a3,
168 stru_721530.normal.x,
169 stru_721530.normal.y,
170 stru_721530.normal.z,
171 stru_721530.field_58.x,
172 stru_721530.field_58.y,
173 stru_721530.field_58.z,
174 v12,
175 a10) )
176 {
177 v17 = a3;
178 }
179 else
180 {
181 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d;
182 if ( !sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v12) )
183 goto LABEL_34;
184 v17 = a3 - stru_721530.prolly_normal_d;
185 a3 -= stru_721530.prolly_normal_d;
186 }
187 if ( v17 < stru_721530.field_7C )
188 {
189 stru_721530.field_7C = v17;
190 v18 = 8 * v9->pFloors[v26];
191 LOBYTE(v18) = v18 | 6;
192 stru_721530.uFaceID = v18;
193 }
194 }
195 }
196 }
197 LABEL_34:
198 if ( !(stru_721530.field_0 & 1)
199 || (v19 = v12->pFacePlane_old.vNormal.x,
200 v20 = v12->pFacePlane_old.vNormal.y,
201 v30 = v19,
202 v21 = (stru_721530.field_34.x * v19
203 + v12->pFacePlane_old.dist
204 + stru_721530.field_34.y * v20
205 + stru_721530.field_34.z * v12->pFacePlane_old.vNormal.z) >> 16,
206 v21 <= 0)
207 || (v22 = (stru_721530.field_4C * v30
208 + v12->pFacePlane_old.dist
209 + stru_721530.field_50 * v20
210 + stru_721530.field_54 * v12->pFacePlane_old.vNormal.z) >> 16,
211 v21 > stru_721530.prolly_normal_d)
212 && v22 > stru_721530.prolly_normal_d
213 || v22 > v21 )
214 goto LABEL_45;
215 a3 = stru_721530.field_6C;
216 if ( sub_47531C(
217 stru_721530.field_8,
218 &a3,
219 stru_721530.field_34.x,
220 stru_721530.field_34.y,
221 stru_721530.field_34.z,
222 stru_721530.field_58.x,
223 stru_721530.field_58.y,
224 stru_721530.field_58.z,
225 v12,
226 a10) )
227 {
228 v23 = a3;
229 goto LABEL_43;
230 }
231 a3 = stru_721530.field_6C + stru_721530.field_8;
232 if ( sub_475D85(&stru_721530.field_34, &stru_721530.field_58, &a3, v12) )
233 {
234 v23 = a3 - stru_721530.prolly_normal_d;
235 a3 -= stru_721530.prolly_normal_d;
236 LABEL_43:
237 if ( v23 < stru_721530.field_7C )
238 {
239 stru_721530.field_7C = v23;
240 v24 = 8 * v9->pFloors[v26];
241 LOBYTE(v24) = v24 | 6;
242 stru_721530.uFaceID = v24;
243 }
244 }
245 LABEL_45:
246 v10 = v26++ + 1;
247 if ( v26 >= v32 )
248 goto LABEL_46;
249 }
250 }
251 return result;
252 }
253 // 46E44E: using guessed type int var_28[10];
254
255 //----- (0046E889) --------------------------------------------------------
256 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
257 {
258 int result; // eax@1
259 BSPModel *v2; // ecx@3
260 int v3; // ebx@9
261 ODMFace *v4; // eax@11
262 int v5; // edi@17
263 int v6; // esi@17
264 unsigned int v7; // ecx@17
265 int v8; // eax@19
266 int v9; // ecx@20
267 int v10; // eax@24
268 int v11; // ST18_4@25
269 int v12; // ST1C_4@25
270 int v13; // ST0C_4@25
271 unsigned int v14; // eax@28
272 int v15; // eax@30
273 int v16; // ecx@31
274 unsigned int v17; // eax@36
275 int v18; // ST18_4@41
276 int v19; // ST1C_4@41
277 int v20; // ST0C_4@41
278 int v21; // eax@42
279 unsigned int v22; // eax@43
280 //BLVFace f; // [sp+Ch] [bp-7Ch]@1
281 int v24; // [sp+6Ch] [bp-1Ch]@9
282 int a11; // [sp+70h] [bp-18h]@1
283 unsigned int v26; // [sp+74h] [bp-14h]@2
284 unsigned int v27; // [sp+78h] [bp-10h]@10
285 BSPModel *v28; // [sp+7Ch] [bp-Ch]@3
286 int a10; // [sp+80h] [bp-8h]@1
287 int a2; // [sp+84h] [bp-4h]@23
288
289 a11 = ecx0;
290
291 BLVFace f; // [sp+Ch] [bp-7Ch]@1
292 //BLVFace::BLVFace(&f);
293
294 result = 0;
295 a10 = 0;
296 if ( (signed int)pOutdoor->uNumBModels > 0 )
297 {
298 v26 = 0;
299 while ( 1 )
300 {
301 v2 = &pOutdoor->pBModels[v26 / 0xBC];
302 v28 = &pOutdoor->pBModels[v26 / 0xBC];
303 if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX )
304 {
305 if ( stru_721530.sMinX >= v2->sMinX )
306 {
307 if ( stru_721530.sMaxY <= v2->sMaxY )
308 {
309 if ( stru_721530.sMinY >= v2->sMinY )
310 {
311 if ( stru_721530.sMaxZ <= v2->sMaxZ )
312 {
313 if ( stru_721530.sMinZ >= v2->sMinZ )
314 {
315 v3 = 0;
316 v24 = v2->uNumFaces;
317 if ( v24 > 0 )
318 break;
319 }
320 }
321 }
322 }
323 }
324 }
325 LABEL_39:
326 ++a10;
327 v26 += 188;
328 result = a10;
329 if ( a10 >= (signed int)pOutdoor->uNumBModels )
330 return result;
331 }
332 v27 = 0;
333 while ( 1 )
334 {
335 v4 = &v2->pFaces[v27 / 0x134];
336 if ( stru_721530.sMaxX > v4->pBoundingBox.x2
337 || stru_721530.sMinX < v4->pBoundingBox.x1
338 || stru_721530.sMaxY > v4->pBoundingBox.y2
339 || stru_721530.sMinY < v4->pBoundingBox.y1
340 || stru_721530.sMaxZ > v4->pBoundingBox.z2
341 || stru_721530.sMinZ < v4->pBoundingBox.z1 )
342 goto LABEL_38;
343 f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x;
344 f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y;
345 v5 = v4->pFacePlane.vNormal.z;
346 f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
347 v6 = v4->pFacePlane.dist;
348 f.pFacePlane_old.dist = v4->pFacePlane.dist;
349 v7 = v4->uAttributes;
350 f.uAttributes = v7;
351 f.pBounding.x1 = v4->pBoundingBox.x1;
352 f.pBounding.y1 = v4->pBoundingBox.y1;
353 f.pBounding.z1 = v4->pBoundingBox.z1;
354 f.pBounding.x2 = v4->pBoundingBox.x2;
355 f.pBounding.y2 = v4->pBoundingBox.y2;
356 f.pBounding.z2 = v4->pBoundingBox.z2;
357 f.zCalc1 = v4->zCalc1;
358 f.zCalc2 = v4->zCalc2;
359 f.zCalc3 = v4->zCalc3;
360 f.pXInterceptDisplacements = v4->pXInterceptDisplacements;
361 f.pYInterceptDisplacements = v4->pYInterceptDisplacements;
362 f.pZInterceptDisplacements = v4->pZInterceptDisplacements;
363 f.uPolygonType = (PolygonType)v4->uPolygonType;
364 f.uNumVertices = v4->uNumVertices;
365 f.uBitmapID = v4->uTextureID;
366 f.pVertexIDs = v4->pVertexIDs;
367 if ( !(v7 & 0x20000000) )
368 {
369 if ( !(v7 & 1) )
370 break;
371 }
372 LABEL_37:
373 v2 = v28;
374 LABEL_38:
375 v27 += 308;
376 ++v3;
377 if ( v3 >= v24 )
378 goto LABEL_39;
379 }
380 v8 = (v5 * stru_721530.normal.z
381 + v6
382 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
383 + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16;
384 if ( v8 > 0 )
385 {
386 v9 = (v5 * stru_721530.normal2.z
387 + v6
388 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
389 + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16;
390 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
391 {
392 if ( v9 <= v8 )
393 {
394 a2 = stru_721530.field_6C;
395 if ( sub_4754BF(
396 stru_721530.prolly_normal_d,
397 &a2,
398 stru_721530.normal.x,
399 stru_721530.normal.y,
400 stru_721530.normal.z,
401 stru_721530.field_58.x,
402 stru_721530.field_58.y,
403 stru_721530.field_58.z,
404 &f,
405 a10,
406 a11) )
407 {
408 v10 = a2;
409 }
410 else
411 {
412 v11 = stru_721530.field_58.y;
413 v12 = stru_721530.field_58.z;
414 v13 = stru_721530.normal.y;
415 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
416 if ( !sub_475F30(
417 &a2,
418 &f,
419 stru_721530.normal.x,
420 v13,
421 stru_721530.normal.z,
422 stru_721530.field_58.x,
423 v11,
424 v12,
425 a10) )
426 goto LABEL_29;
427 v10 = a2 - stru_721530.prolly_normal_d;
428 a2 -= stru_721530.prolly_normal_d;
429 }
430 if ( v10 < stru_721530.field_7C )
431 {
432 stru_721530.field_7C = v10;
433 v14 = 8 * (v3 | (a10 << 6));
434 LOBYTE(v14) = v14 | 6;
435 stru_721530.uFaceID = v14;
436 }
437 }
438 }
439 }
440 LABEL_29:
441 if ( stru_721530.field_0 & 1 )
442 {
443 v15 = (f.pFacePlane_old.vNormal.z * stru_721530.field_34.z
444 + f.pFacePlane_old.dist
445 + f.pFacePlane_old.vNormal.y * stru_721530.field_34.y
446 + f.pFacePlane_old.vNormal.x * stru_721530.field_34.x) >> 16;
447 if ( v15 > 0 )
448 {
449 v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
450 + f.pFacePlane_old.dist
451 + f.pFacePlane_old.vNormal.y * stru_721530.field_50
452 + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16;
453 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
454 {
455 if ( v16 <= v15 )
456 {
457 a2 = stru_721530.field_6C;
458 if ( sub_4754BF(
459 stru_721530.field_8,
460 &a2,
461 stru_721530.field_34.x,
462 stru_721530.field_34.y,
463 stru_721530.field_34.z,
464 stru_721530.field_58.x,
465 stru_721530.field_58.y,
466 stru_721530.field_58.z,
467 &f,
468 a10,
469 a11) )
470 {
471 if ( a2 < stru_721530.field_7C )
472 {
473 stru_721530.field_7C = a2;
474 v17 = 8 * (v3 | (a10 << 6));
475 LOBYTE(v17) = v17 | 6;
476 stru_721530.uFaceID = v17;
477 }
478 }
479 else
480 {
481 v18 = stru_721530.field_58.y;
482 v19 = stru_721530.field_58.z;
483 v20 = stru_721530.field_34.y;
484 a2 = stru_721530.field_6C + stru_721530.field_8;
485 if ( sub_475F30(
486 &a2,
487 &f,
488 stru_721530.field_34.x,
489 v20,
490 stru_721530.field_34.z,
491 stru_721530.field_58.x,
492 v18,
493 v19,
494 a10) )
495 {
496 v2 = v28;
497 v21 = a2 - stru_721530.prolly_normal_d;
498 a2 -= stru_721530.prolly_normal_d;
499 if ( a2 < stru_721530.field_7C )
500 {
501 stru_721530.field_7C = v21;
502 v22 = 8 * (v3 | (a10 << 6));
503 LOBYTE(v22) = v22 | 6;
504 stru_721530.uFaceID = v22;
505 }
506 goto LABEL_38;
507 }
508 }
509 }
510 }
511 }
512 }
513 goto LABEL_37;
514 }
515 return result;
516 }
517
518
519
520 //----- (0046ED1B) --------------------------------------------------------
521 int _46ED1B_collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
522 {
523 uint uFaceID = -1;
524 int floor_level = _46CEC3_get_floor_level(x, y, z, *pSectorID, &uFaceID);
525
526 if (floor_level != -30000 && floor_level <= z + 50)
527 {
528 *pFaceID = uFaceID;
529 return floor_level;
530 }
531
532 uint uSectorID = pIndoor->GetSector(x, y, z);
533 *pSectorID = uSectorID;
534
535 floor_level = _46CEC3_get_floor_level(x, y, z, uSectorID, &uFaceID);
536 if (uSectorID && floor_level != -30000)
537 *pFaceID = uFaceID;
538 else return -30000;
539 return floor_level;
540 }
541
542 //----- (0046ED8A) --------------------------------------------------------
543 void __fastcall _46ED8A_collide_against_layingItems(unsigned int _this)
544 {
545 int v1; // ebx@2
546 ObjectDesc *v2; // edx@4
547 int v3; // esi@5
548 int v4; // ecx@5
549 int v5; // eax@7
550 int v6; // edi@9
551 int v7; // edx@9
552 int v8; // edi@11
553 int v9; // ebx@11
554 int v10; // ecx@12
555 int v11; // esi@13
556 signed int v12; // [sp+0h] [bp-14h]@1
557 int v13; // [sp+4h] [bp-10h]@9
558 char *v14; // [sp+8h] [bp-Ch]@2
559 unsigned int v15; // [sp+10h] [bp-4h]@1
560
561 v15 = 0;
562 v12 = _this;
563 if ( (signed int)uNumLayingItems > 0 )
564 {
565 v1 = (int)&pLayingItems[0].uObjectDescID;
566 v14 = (char *)&pLayingItems[0].uObjectDescID;
567 do
568 {
569 if ( *(short *)v1 )
570 {
571 v2 = &pObjectList->pObjects[*(short *)v1];
572 if ( !(v2->uFlags & 2) )
573 {
574 v3 = v2->uRadius;
575 v4 = *(int *)(v1 + 2);
576 if ( stru_721530.sMaxX <= v4 + v3 )
577 {
578 if ( stru_721530.sMinX >= v4 - v3 )
579 {
580 v5 = *(int *)(v1 + 6);
581 if ( stru_721530.sMaxY <= v5 + v3 )
582 {
583 if ( stru_721530.sMinY >= v5 - v3 )
584 {
585 v6 = v2->uHeight;
586 v7 = *(int *)(v1 + 10);
587 v13 = v6;
588 if ( stru_721530.sMaxZ <= v7 + v6 )
589 {
590 if ( stru_721530.sMinZ >= v7 )
591 {
592 v8 = v4 - stru_721530.normal.x;
593 v9 = v5 - stru_721530.normal.y;
594 if ( abs(((v4 - stru_721530.normal.x) * stru_721530.field_58.y
595 - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16) <= v3
596 + stru_721530.prolly_normal_d )
597 {
598 v10 = (v8 * stru_721530.field_58.x + v9 * stru_721530.field_58.y) >> 16;
599 if ( v10 > 0 )
600 {
601 v11 = stru_721530.normal.z
602 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v10) >> 16);
603 if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d )
604 {
605 if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
606 {
607 if ( v10 < stru_721530.field_7C )
608 sub_46DEF2(v12, v15);
609 }
610 }
611 }
612 }
613 }
614 }
615 }
616 }
617 }
618 }
619 }
620 }
621 ++v15;
622 v1 = (int)(v14 + 112);
623 v14 += 112;
624 }
625 while ( (signed int)v15 < (signed int)uNumLayingItems );
626 }
627 }
628
629 //----- (0046EF01) --------------------------------------------------------
630 int __thiscall _46EF01_collision_chech_player(int a1)
631 {
632 int v1; // edx@1
633 int result; // eax@1
634 int v3; // ebx@7
635 int v4; // esi@7
636 int v5; // edi@8
637 int v6; // ecx@9
638 int v7; // edi@12
639 int v8; // [sp+Ch] [bp-10h]@1
640 unsigned int v9; // [sp+10h] [bp-Ch]@1
641 int v10; // [sp+14h] [bp-8h]@7
642 int v11; // [sp+18h] [bp-4h]@7
643
644 v8 = a1;
645 v1 = 2 * pParty->field_14;
646 result = pParty->vPosition.x;
647 v9 = pParty->uPartyHeight;
648 if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14 )
649 {
650 if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
651 {
652 if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 )
653 {
654 if ( stru_721530.sMinY >= pParty->vPosition.y - v1 )
655 {
656 if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) )
657 {
658 if ( stru_721530.sMinZ >= pParty->vPosition.z )
659 {
660 v3 = stru_721530.prolly_normal_d + v1;
661 v11 = pParty->vPosition.x - stru_721530.normal.x;
662 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
663 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
664 v10 = pParty->vPosition.y - stru_721530.normal.y;
665 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
666 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
667 if ( result <= v3 )
668 {
669 result = v10 * stru_721530.field_58.y;
670 v5 = (v10 * stru_721530.field_58.y + v11 * stru_721530.field_58.x) >> 16;
671 if ( v5 > 0 )
672 {
673 v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
674 result = pParty->vPosition.z;
675 if ( v6 >= pParty->vPosition.z )
676 {
677 result = v9 + pParty->vPosition.z;
678 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
679 {
680 result = sub_452A9E(v3 * v3 - v4 * v4);
681 v7 = v5 - result;
682 if ( v7 < 0 )
683 v7 = 0;
684 if ( v7 < stru_721530.field_7C )
685 {
686 stru_721530.field_7C = v7;
687 stru_721530.uFaceID = 4;
688 }
689 }
690 }
691 }
692 }
693 }
694 }
695 }
696 }
697 }
698 }
699 return result;
700 }
701
702 //----- (0046F04E) --------------------------------------------------------
703 signed int __cdecl _46F04E_collide_against_portals()
704 {
705 BLVSector *v0; // ecx@1
706 unsigned int v1; // eax@1
707 int v2; // eax@2
708 BLVFace *v3; // eax@3
709 int v4; // ecx@9
710 int v5; // edx@9
711 signed int result; // eax@21
712 BLVFace *v7; // eax@22
713 signed int v8; // [sp+0h] [bp-14h]@1
714 BLVSector *v9; // [sp+4h] [bp-10h]@1
715 unsigned int v10; // [sp+8h] [bp-Ch]@1
716 int a3; // [sp+Ch] [bp-8h]@13
717 int v12; // [sp+10h] [bp-4h]@15
718
719 v8 = 0;
720 v0 = &pIndoor->pSectors[stru_721530.uSectorID];
721 v1 = 0xFFFFFFu;
722 v10 = 0xFFFFFFu;
723 v9 = v0;
724 if ( v0->uNumPortals > 0 )
725 {
726 do
727 {
728 v2 = v0->pPortals[v8];
729 if ( v2 != stru_721530.field_80 )
730 {
731 v3 = &pIndoor->pFaces[v2];
732 if ( stru_721530.sMaxX <= v3->pBounding.x2 )
733 {
734 if ( stru_721530.sMinX >= v3->pBounding.x1
735 && stru_721530.sMaxY <= v3->pBounding.y2
736 && stru_721530.sMinY >= v3->pBounding.y1
737 && stru_721530.sMaxZ <= v3->pBounding.z2
738 && stru_721530.sMinZ >= v3->pBounding.z1 )
739 {
740 v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x
741 + v3->pFacePlane_old.dist
742 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
743 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
744 v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z
745 + v3->pFacePlane_old.dist
746 + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
747 + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
748 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
749 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
750 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v3))
751 && a3 < (signed int)v10 )
752 {
753 v0 = v9;
754 v10 = a3;
755 v12 = v9->pPortals[v8];
756 }
757 else
758 {
759 v0 = v9;
760 }
761 }
762 }
763 }
764 ++v8;
765 }
766 while ( v8 < v0->uNumPortals );
767 v1 = v10;
768 }
769 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C )
770 {
771 stru_721530.field_80 = v12;
772 v7 = &pIndoor->pFaces[v12];
773 if ( v7->uSectorID == stru_721530.uSectorID )
774 stru_721530.uSectorID = v7->uBackSectorID;
775 else
776 stru_721530.uSectorID = v7->uSectorID;
777 stru_721530.field_7C = 268435455;
778 result = 0;
779 }
780 else
781 {
782 result = 1;
783 }
784 return result;
785 }
786
787
788 //----- (0047050A) --------------------------------------------------------
789 int stru141::_47050A(int a2)
790 {
791 stru141 *v2; // esi@1
792 signed int v3; // eax@1
793 int v4; // ecx@1
794 int v5; // edx@1
795 int v6; // edx@1
796 int v7; // eax@1
797 int v8; // eax@3
798 signed int result; // eax@4
799 int v10; // eax@5
800 int v11; // eax@5
801 int v12; // ebx@5
802 int v13; // edx@5
803 int v14; // edi@5
804 int v15; // ecx@5
805 int v16; // eax@5
806 int v17; // eax@5
807 int v18; // eax@7
808 int v19; // edx@9
809 int v20; // edi@9
810 int v21; // eax@9
811 int v22; // eax@11
812 int v23; // edx@13
813 int v24; // eax@13
814 int v25; // eax@14
815 int v26; // eax@16
816 int v27; // eax@17
817 int v28; // [sp+14h] [bp+8h]@5
818
819 v2 = this;
820 v3 = sub_452A9E(this->field_24 * this->field_24 + this->field_20 * this->field_20 + this->field_1C * this->field_1C);
821 v4 = v3 | 1;
822 v5 = v2->field_1C;
823 v2->field_64 = v3 | 1;
824 v2->field_58.x = 65536 / (v3 | 1) * v5;
825 v2->field_58.y = 65536 / (v3 | 1) * v2->field_20;
826 v6 = 65536 / (v3 | 1) * v2->field_24;
827 v2->field_68 = 65536 / (v3 | 1);
828 v7 = a2;
829 v2->field_58.z = v6;
830 if ( !a2 )
831 v7 = pEventTimer->dt_in_some_format;
832 v8 = ((unsigned __int64)(v7 * (signed __int64)v4) >> 16) - v2->field_70;
833 v2->field_6C = v8;
834 if ( v8 > 0 )
835 {
836 v10 = ((unsigned __int64)(v8 * (signed __int64)v2->field_58.x) >> 16) + v2->normal.x;
837 v2->field_4C = v10;
838 v2->normal2.x = v10;
839 v11 = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.y) >> 16) + v2->normal.y;
840 v2->field_50 = v11;
841 v2->normal2.y = v11;
842 v2->normal2.z = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16) + v2->normal.z;
843 v12 = v2->field_34.z;
844 v13 = v2->normal.x;
845 v14 = v2->normal2.x;
846 v15 = v2->prolly_normal_d;
847 v16 = v12 + ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16);
848 v28 = v16;
849 v2->field_54 = v16;
850 v17 = v13;
851 if ( v13 >= v14 )
852 v17 = v14;
853 v2->sMaxX = v17 - v15;
854 v18 = v15 + v13;
855 if ( v13 <= v14 )
856 v18 = v15 + v14;
857 v19 = v2->normal.y;
858 v20 = v2->normal2.y;
859 v2->sMinX = v18;
860 v21 = v19;
861 if ( v19 >= v20 )
862 v21 = v20;
863 v2->sMaxY = v21 - v15;
864 v22 = v15 + v19;
865 if ( v19 <= v20 )
866 v22 = v20 + v15;
867 v23 = v2->normal2.z;
868 v2->sMinY = v22;
869 v24 = v2->normal.z;
870 if ( v24 >= v23 )
871 v25 = v23 - v15;
872 else
873 v25 = v24 - v15;
874 v2->sMaxZ = v25;
875 v26 = v2->field_8;
876 if ( v12 <= v28 )
877 v27 = v28 + v26;
878 else
879 v27 = v12 + v26;
880 v2->uFaceID = 0;
881 v2->field_80 = -1;
882 v2->field_88 = -1;
883 v2->sMinZ = v27;
884 v2->field_7C = 0xFFFFFFu;
885 result = 0;
886 }
887 else
888 {
889 result = 1;
890 }
891 return result;
892 }
893
894 //----- (004706C6) --------------------------------------------------------
895 void __cdecl UpdateActors_ODM()
896 {
897 Actor *v0; // esi@2
898 unsigned __int16 v1; // ax@2
899 unsigned int v2; // ecx@6
900 int v3; // ebx@6
901 int v4; // eax@8
902 int v5; // eax@10
903 int v6; // ecx@10
904 signed int v7; // ebx@10
905 signed int v8; // ebx@17
906 unsigned __int8 v9; // zf@17
907 unsigned __int8 v10; // sf@17
908 unsigned __int16 v11; // ax@21
909 int v12; // eax@29
910 unsigned __int64 v13; // qax@29
911 int v14; // eax@30
912 unsigned __int64 v15; // qax@30
913 int v16; // eax@33
914 int v17; // edi@34
915 int v18; // edx@42
916 int v19; // ecx@42
917 __int16 v20; // ax@42
918 int v21; // ebx@42
919 int v22; // edi@42
920 int v23; // ecx@42
921 __int16 v24; // ax@42
922 int v25; // eax@45
923 signed int v26; // ecx@50
924 int v27; // eax@52
925 int v28; // eax@54
926 signed int v29; // ebx@57
927 signed int v30; // eax@57
928 int v31; // edi@57
929 signed int i; // ebx@57
930 unsigned int v33; // ecx@58
931 int v34; // ebx@64
932 int v35; // edi@64
933 int v36; // eax@64
934 unsigned __int16 v37; // cx@66
935 signed int v38; // edx@71
936 signed int v39; // edi@71
937 BSPModel *v40; // eax@75
938 ODMFace *v41; // edi@75
939 int v42; // ebx@76
940 int v43; // ecx@77
941 int v44; // edx@77
942 __int16 v45; // dx@82
943 int v46; // ecx@82
944 signed int v47; // ebx@85
945 int v48; // edi@85
946 int v49; // edi@85
947 int v50; // eax@85
948 unsigned __int64 v51; // qax@85
949 unsigned __int8 v52; // zf@87
950 unsigned __int8 v53; // sf@87
951 unsigned __int8 v54; // of@104
952 int v55; // eax@107
953 unsigned int v56; // edi@107
954 int v57; // ST10_4@107
955 unsigned int v58; // edi@107
956 unsigned int v59; // ebx@107
957 signed int v60; // eax@107
958 int v61; // eax@124
959 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
960 char v63; // [sp+18h] [bp-38h]@64
961 int v64; // [sp+1Ch] [bp-34h]@64
962 int v65; // [sp+20h] [bp-30h]@2
963 int v66; // [sp+24h] [bp-2Ch]@2
964 bool v67; // [sp+28h] [bp-28h]@10
965 unsigned int v68; // [sp+2Ch] [bp-24h]@10
966 unsigned int v69; // [sp+30h] [bp-20h]@6
967 unsigned int v70; // [sp+34h] [bp-1Ch]@10
968 int v71; // [sp+38h] [bp-18h]@62
969 int v72; // [sp+3Ch] [bp-14h]@10
970 int v73; // [sp+40h] [bp-10h]@17
971 int v74; // [sp+44h] [bp-Ch]@8
972 unsigned int v75; // [sp+48h] [bp-8h]@1
973 int v76; // [sp+4Ch] [bp-4h]@10
974
975 v75 = 0;
976 if ( (signed int)uNumActors <= 0 )
977 return;
978 do
979 {
980 v0 = &pActors[v75];
981 v66 = v0->vPosition.x;
982 v65 = v0->vPosition.y;
983 v1 = v0->uAIState;
984 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
985 goto LABEL_121;
986 v2 = v0->pMonsterInfo.uID;
987 v3 = 0;
988 v69 = 0;
989 if ( MonsterStats::BelongsToSupertype(v2, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
990 v3 = 1;
991 v4 = v0->pMonsterInfo.uFlying;
992 v0->uSectorID = 0;
993 v74 = v4;
994 if ( !v0->CanAct() )
995 v74 = 0;
996 v70 = GetTerrainHeightsAroundParty(v0->vPosition.x, v0->vPosition.y);
997 v5 = sub_46D49E_prolly_get_world_y_under_party(
998 v0->vPosition.x,
999 v0->vPosition.y,
1000 v0->vPosition.z,
1001 v0->uActorHeight,
1002 &v76,
1003 (int *)&v69,
1004 v3);
1005 v6 = v0->vPosition.z;
1006 v7 = v5;
1007 v68 = v5;
1008 v72 = 0;
1009 v67 = v69 == 0;
1010 if ( v6 > v5 + 1 )
1011 v72 = 1;
1012 if ( v0->uAIState == 5 && v76 && !v72 )
1013 {
1014 v0->uAIState = Removed;
1015 goto LABEL_121;
1016 }
1017 if ( v0->uCurrentActionAnimation == 1 )
1018 {
1019 v8 = v0->uMovementSpeed;
1020 v9 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0;
1021 v10 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0;
1022 v73 = v0->uMovementSpeed;
1023 if ( !v10 && (!(v10 | v9) || LODWORD(v0->pActorBuffs[7].uExpireTime) > 0) )
1024 {
1025 v8 = (signed __int64)((double)v73 * 0.5);
1026 v73 = (signed __int64)((double)v73 * 0.5);
1027 }
1028 v11 = v0->uAIState;
1029 if ( v11 == 7 || v11 == 6 )
1030 {
1031 v8 *= 2;
1032 v73 = v8;
1033 }
1034 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 1 )
1035 v8 = (signed __int64)((double)v73 * flt_6BE3AC_debug_recmod1_x_1_6);
1036 if ( v8 > 1000 )
1037 v8 = 1000;
1038 v12 = stru_5C6E00->SinCos(v0->uYawAngle);
1039 v69 = v12;
1040 v13 = v12 * (signed __int64)v8;
1041 v73 = v13 >> 16;
1042 v0->vVelocity.x = WORD1(v13);
1043 v69 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
1044 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16;
1045 v9 = v74 == 0;
1046 v0->vVelocity.y = v69 * v8 >> 16;
1047 if ( !v9 )
1048 {
1049 v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
1050 v69 = v14;
1051 v15 = v14 * (signed __int64)v8;
1052 v73 = v15 >> 16;
1053 v0->vVelocity.z = WORD1(v15);
1054 }
1055 v7 = v68;
1056 }
1057 else
1058 {
1059 v73 = v0->vVelocity.x;
1060 v69 = 55000;
1061 v73 = (unsigned __int64)(55000i64 * v73) >> 16;
1062 v0->vVelocity.x = v73;
1063 v73 = v0->vVelocity.y;
1064 v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16;
1065 v9 = v74 == 0;
1066 v0->vVelocity.y = v73;
1067 if ( !v9 )
1068 {
1069 v69 = 55000;
1070 v73 = v0->vVelocity.z;
1071 v73 = (unsigned __int64)(55000i64 * v73) >> 16;
1072 v0->vVelocity.z = v73;
1073 }
1074 }
1075 if ( v0->vPosition.z < v7 )
1076 {
1077 v16 = v74;
1078 v0->vPosition.z = v7;
1079 v0->vVelocity.z = v16 != 0 ? 0x14 : 0;
1080 }
1081 v17 = 0;
1082 if ( !v72 || v74 )
1083 {
1084 if ( v70 && !v72 && v67 )
1085 {
1086 v18 = v0->vPosition.y;
1087 v19 = v0->vPosition.x;
1088 v0->vPosition.z = v7;
1089 _46DCC8_get_gravity_direction_outdoor(v19, v18, &v62);
1090 v20 = GetGravityStrength();
1091 v21 = v62.y;
1092 v22 = v62.z;
1093 v23 = v62.y * v0->vVelocity.y;
1094 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
1095 v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16;
1096 v72 = v21;
1097 v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16;
1098 v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16;
1099 v24 = v72;
1100 v72 = v22;
1101 v0->vVelocity.y += v24;
1102 v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16;
1103 v0->vVelocity.z += v72;
1104 v17 = 0;
1105 }
1106 }
1107 else
1108 {
1109 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1110 }
1111 if ( pParty->field_1613C != v17 && v0->CanAct() )
1112 {
1113 v0->vVelocity.x += rand() % 100 - 50;
1114 v0->vVelocity.y += rand() % 100 - 50;
1115 v0->vVelocity.z += rand() % 100 - 20;
1116 v25 = rand();
1117 v0->uAIState = Stunned;
1118 v0->uYawAngle += v25 % 32 - 16;
1119 v0->UpdateAnimation();
1120 }
1121 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == v17 )
1122 {
1123 v0->vVelocity.y = v17;
1124 v0->vVelocity.x = v17;
1125 }
1126 v9 = v0->pMonsterInfo.uFlying == 0;
1127 stru_721530.field_0 = 1;
1128 if ( v9 )
1129 v26 = 40;
1130 else
1131 v26 = v0->uActorRadius;
1132 v27 = v0->uActorHeight;
1133 stru_721530.field_84 = -1;
1134 stru_721530.field_8 = v26;
1135 stru_721530.prolly_normal_d = v26;
1136 stru_721530.field_C = v27;
1137 stru_721530.field_70 = v17;
1138 v69 = v17;
1139 while ( 1 )
1140 {
1141 stru_721530.field_34.x = v0->vPosition.x;
1142 stru_721530.normal.x = stru_721530.field_34.x;
1143 stru_721530.field_34.y = v0->vPosition.y;
1144 stru_721530.normal.y = stru_721530.field_34.y;
1145 v28 = v0->vPosition.z;
1146 stru_721530.normal.z = v28 + v26 + 1;
1147 stru_721530.field_34.z = v28 - v26 + stru_721530.field_C - 1;
1148 if ( stru_721530.field_34.z < stru_721530.normal.z )
1149 stru_721530.field_34.z = v28 + v26 + 1;
1150 stru_721530.field_1C = v0->vVelocity.x;
1151 stru_721530.uSectorID = 0;
1152 stru_721530.field_20 = v0->vVelocity.y;
1153 stru_721530.field_24 = v0->vVelocity.z;
1154 if ( stru_721530._47050A(0) )
1155 break;
1156 _46E889_collide_against_bmodels(1u);
1157 v29 = WorldPosToGridCellZ(v0->vPosition.y);
1158 v30 = WorldPosToGridCellX(v0->vPosition.x);
1159 _46E26D_collide_against_sprites(v30, v29);
1160 _46EF01_collision_chech_player(0);
1161 _46ED8A_collide_against_layingItems(8 * v75 | 3);
1162 v31 = 0;
1163 for ( i = 0; v31 < ai_arrays_size; ++v31 )
1164 {
1165 v33 = ai_array_4F7DB0_actor_ids[v31];
1166 if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) )
1167 ++i;
1168 }
1169 v71 = i > 1;
1170 if ( stru_721530.field_7C < stru_721530.field_6C )
1171 v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1172 v34 = 0;
1173 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1174 v36 = sub_46D49E_prolly_get_world_y_under_party(
1175 stru_721530.normal2.x,
1176 stru_721530.normal2.y,
1177 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
1178 v0->uActorHeight,
1179 (int *)&v63,
1180 &v64,
1181 0);
1182 if ( v76 )
1183 {
1184 if ( v35 < v36 + 60 )
1185 {
1186 v37 = v0->uAIState;
1187 if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 )
1188 {
1189 if ( v64 )
1190 v61 = v36 + 30;
1191 else
1192 v61 = v68 + 60;
1193 sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
1194 v0->uAIState = Removed;
1195 return;
1196 }
1197 }
1198 }
1199 if ( stru_721530.field_7C >= stru_721530.field_6C )
1200 {
1201 v0->vPosition.x = LOWORD(stru_721530.normal2.x);
1202 v0->vPosition.y = LOWORD(stru_721530.normal2.y);
1203 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
1204 break;
1205 }
1206 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
1207 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
1208 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1209 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
1210 v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1211 v38 = stru_721530.uFaceID;
1212 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
1213 stru_721530.field_70 += stru_721530.field_7C;
1214 v39 = v38 >> 3;
1215 switch ( v38 & 7 )
1216 {
1217 case 3:
1218 if ( pParty->bTurnBasedModeOn != 1 )
1219 goto LABEL_97;
1220 if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 )
1221 {
1222 v34 = 0;
1223 LABEL_97:
1224 if ( v0->pMonsterInfo.uHostilityType )
1225 {
1226 if ( v71 == v34 )
1227 goto LABEL_99;
1228 LABEL_101:
1229 Actor::_403F58(v75, 4, v34, (AIDirection *)v34);
1230 break;
1231 }
1232 if ( v71 != v34 )
1233 goto LABEL_101;
1234 if ( pActors[v39].pMonsterInfo.uHostilityType )
1235 {
1236 LABEL_99:
1237 Actor::_402968(v75, v38, v34, (AIDirection *)v34);
1238 break;
1239 }
1240 LABEL_103:
1241 Actor::FaceObject(v75, v38, v34, (AIDirection *)v34);
1242 break;
1243 }
1244 break;
1245 case 4:
1246 if ( !v0->GetActorsRelation(0) )
1247 {
1248 v38 = stru_721530.uFaceID;
1249 goto LABEL_103;
1250 }
1251 v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
1252 v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0;
1253 v0->vVelocity.y = 0;
1254 v0->vVelocity.x = 0;
1255 if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) )
1256 pParty->pPartyBuffs[11].Reset();
1257 viewparams->bRedrawGameUI = 1;
1258 break;
1259 case 5:
1260 v47 = sub_452A9E(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
1261 v48 = stru_5C6E00->Atan2(
1262 v0->vPosition.x - pLevelDecorations[v39].vPosition.x,
1263 v0->vPosition.y - pLevelDecorations[v39].vPosition.y);
1264 v71 = stru_5C6E00->SinCos(v48);
1265 v70 = (unsigned __int64)(v71 * (signed __int64)v47) >> 16;
1266 v49 = v48 - stru_5C6E00->uIntegerHalfPi;
1267 v0->vVelocity.x = (unsigned int)(v71 * v47) >> 16;
1268 v50 = stru_5C6E00->SinCos(v49);
1269 v71 = v50;
1270 v51 = v50 * (signed __int64)v47;
1271 v70 = v51 >> 16;
1272 v0->vVelocity.y = WORD1(v51);
1273 break;
1274 case 6:
1275 v40 = &pOutdoor->pBModels[v38 >> 9];
1276 v41 = &v40->pFaces[v39 & 0x3F];
1277 if ( !(BYTE3(v41->uAttributes) & 0x20) )
1278 {
1279 v42 = v41->uPolygonType;
1280 if ( v42 == 3 )
1281 {
1282 v43 = v0->vVelocity.y;
1283 v44 = v0->vVelocity.x;
1284 v0->vVelocity.z = 0;
1285 v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1;
1286 if ( v44 * v44 + v43 * v43 < 400 )
1287 {
1288 v0->vVelocity.y = 0;
1289 v0->vVelocity.x = 0;
1290 }
1291 }
1292 else
1293 {
1294 v72 = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z
1295 + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16;
1296 if ( stru_721530.field_64 >> 3 > v72 )
1297 v72 = stru_721530.field_64 >> 3;
1298 v73 = v41->pFacePlane.vNormal.x;
1299 v73 = (unsigned __int64)(v72 * (signed __int64)v73) >> 16;
1300 v71 = v41->pFacePlane.vNormal.y;
1301 v71 = (unsigned __int64)(v72 * (signed __int64)v71) >> 16;
1302 v70 = v41->pFacePlane.vNormal.z;
1303 v70 = (unsigned __int64)(v72 * (signed __int64)(signed int)v70) >> 16;
1304 v0->vVelocity.x += v73;
1305 v0->vVelocity.y += v71;
1306 v0->vVelocity.z += v70;
1307 if ( v42 != 4 )
1308 {
1309 v45 = v0->vPosition.z;
1310 v46 = stru_721530.prolly_normal_d
1311 - ((v41->pFacePlane.dist
1312 + v41->pFacePlane.vNormal.x * v0->vPosition.x
1313 + v41->pFacePlane.vNormal.y * v0->vPosition.y
1314 + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16);
1315 if ( v46 > 0 )
1316 {
1317 v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16;
1318 v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16;
1319 v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16);
1320 }
1321 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
1322 }
1323 }
1324 }
1325 break;
1326 }
1327 v70 = v0->vVelocity.x;
1328 v71 = 58500;
1329 v70 = (unsigned __int64)(58500i64 * (signed int)v70) >> 16;
1330 v0->vVelocity.x = v70;
1331 v70 = v0->vVelocity.y;
1332 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
1333 v71 = 58500;
1334 v0->vVelocity.y = v70;
1335 v70 = v0->vVelocity.z;
1336 v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
1337 ++v69;
1338 v54 = __OFSUB__(v69, 100);
1339 v10 = ((v69 - 100) & 0x80000000u) != 0;
1340 v0->vVelocity.z = v70;
1341 if ( !(v10 ^ v54) )
1342 break;
1343 v26 = stru_721530.prolly_normal_d;
1344 }
1345 v69 = WorldPosToGridCellX(v66);
1346 v55 = WorldPosToGridCellZ(v65);
1347 v56 = v55 - 1;
1348 v57 = v0->vPosition.x;
1349 v71 = v55 - 1;
1350 v68 = WorldPosToGridCellX(v57);
1351 v70 = WorldPosToGridCellZ(v0->vPosition.y) - 1;
1352 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v69, v56) >> 1) & 1;
1353 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v68, v70) >> 1) & 1;
1354 v60 = 0;
1355 if ( v69 == v68 && v71 == v70 && v58 )
1356 v60 = 1;
1357 if ( !v67 )
1358 v60 = 1;
1359 if ( !v60 )
1360 {
1361 if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
1362 {
1363 v58 = v58 == 0;
1364 v59 = v59 == 0;
1365 }
1366 if ( !v74 && v58 && !v59 )
1367 {
1368 v0->vPosition.x = v66;
1369 v0->vPosition.y = v65;
1370 if ( v0->CanAct() )
1371 {
1372 v0->uYawAngle -= 32;
1373 v0->uCurrentActionTime = 0;
1374 v0->uCurrentActionLength = 128;
1375 v0->uAIState = Fleeing;
1376 }
1377 }
1378 }
1379 LABEL_121:
1380 ++v75;
1381 }
1382 while ( (signed int)v75 < (signed int)uNumActors );
1383 }
1384
1385
1386
1387 //----- (0047136C) --------------------------------------------------------
1388 void LayingItem::UpdateObject_fn0_BLV(unsigned int uLayingItemID)
1389 {
1390 LayingItem *v1; // esi@1
1391 ObjectDesc *v2; // edi@1
1392 int v3; // ST08_4@1
1393 __int16 v4; // ax@5
1394 __int16 v5; // ax@7
1395 BLVFace *v6; // ecx@11
1396 BLVFace *v7; // eax@11
1397 signed int v8; // ebx@12
1398 int v9; // ecx@16
1399 __int16 v10; // di@18
1400 char v11; // al@19
1401 int v12; // eax@25
1402 int v13; // eax@31
1403 int v14; // ebx@34
1404 signed int v15; // ebx@46
1405 BLVFace *v16; // edi@48
1406 int v17; // eax@50
1407 int v18; // eax@52
1408 int v19; // ecx@52
1409 Vec3_short_ *v20; // ecx@53
1410 int v21; // ecx@57
1411 __int16 v22; // ax@57
1412 int v23; // edi@62
1413 int v24; // edi@62
1414 int v25; // eax@62
1415 unsigned __int64 v26; // qax@62
1416 unsigned __int8 v27; // sf@64
1417 unsigned __int8 v28; // of@64
1418 __int16 v29; // di@67
1419 char v30; // al@68
1420 const char *v31; // [sp-8h] [bp-98h]@19
1421 const char *v32; // [sp-8h] [bp-98h]@68
1422 enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19
1423 enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68
1424 Particle_ Dst; // [sp+Ch] [bp-84h]@18
1425 unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
1426 ObjectDesc *v37; // [sp+78h] [bp-18h]@1
1427 unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
1428 int v39; // [sp+80h] [bp-10h]@33
1429 int v40; // [sp+84h] [bp-Ch]@28
1430 int v41; // [sp+88h] [bp-8h]@34
1431 int v42; // [sp+8Ch] [bp-4h]@4
1432
1433 uLayingItemID_ = uLayingItemID;
1434 v1 = &pLayingItems[uLayingItemID];
1435 v2 = &pObjectList->pObjects[v1->uObjectDescID];
1436 v3 = v1->vPosition.x;
1437 v37 = &pObjectList->pObjects[v1->uObjectDescID];
1438 if ( abs(v3) > 32767
1439 || abs(v1->vPosition.y) > 32767
1440 || abs(v1->vPosition.z) > 20000
1441 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &uFaceID),
1442 v42 <= -30000)
1443 && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z),
1444 (v1->uSectorID = v4) == 0)
1445 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) )
1446 {
1447 LayingItem::_42F933(uLayingItemID_);
1448 return;
1449 }
1450 v5 = v2->uFlags;
1451 if ( v5 & 0x20 )
1452 {
1453 LABEL_24:
1454 v8 = 0;
1455 LABEL_25:
1456 stru_721530.field_0 = v8;
1457 uFaceID = v8;
1458 stru_721530.prolly_normal_d = v2->uRadius;
1459 v12 = v2->uHeight;
1460 stru_721530.field_84 = -1;
1461 stru_721530.field_C = v12;
1462 stru_721530.field_8 = v8;
1463 stru_721530.field_70 = v8;
1464 while ( 1 )
1465 {
1466 stru_721530.field_34.x = v1->vPosition.x;
1467 stru_721530.normal.x = stru_721530.field_34.x;
1468 stru_721530.field_34.y = v1->vPosition.y;
1469 stru_721530.normal.y = stru_721530.field_34.y;
1470 stru_721530.field_34.z = stru_721530.prolly_normal_d + v1->vPosition.z + 1;
1471 stru_721530.normal.z = stru_721530.field_34.z;
1472 stru_721530.field_1C = v1->vVelocity.x;
1473 stru_721530.field_20 = v1->vVelocity.y;
1474 stru_721530.field_24 = v1->vVelocity.z;
1475 stru_721530.uSectorID = v1->uSectorID;
1476 if ( stru_721530._47050A(v8) )
1477 return;
1478 v40 = v8;
1479 do
1480 {
1481 _46E44E_collide_against_faces_and_portals(0);
1482 _46E0B2_collide_against_decorations();
1483 if ( (v1->field_58 & 7) != 4 )
1484 _46EF01_collision_chech_player(1);
1485 v13 = v1->field_58;
1486 v42 = v8;
1487 if ( (v13 & 7) == 3 )
1488 {
1489 if ( (signed int)uNumActors > v8 )
1490 {
1491 v39 = (int)&pActors[0].word_000086_some_monster_id;
1492 do
1493 {
1494 v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
1495 v14 = (signed __int64)((double)v41 * 0.3333333333333333);
1496 v41 = *(short *)(v39 - 38) - 1;
1497 if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
1498 _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
1499 ++v42;
1500 v39 += 836;
1501 }
1502 while ( v42 < (signed int)uNumActors );
1503 v8 = 0;
1504 }
1505 }
1506 else
1507 {
1508 if ( (signed int)uNumActors > v8 )
1509 {
1510 v39 = (int)&pActors[0].word_000086_some_monster_id;
1511 do
1512 {
1513 _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39] - 73));
1514 v39 += 836;
1515 }
1516 while ( v42 < (signed int)uNumActors );
1517 }
1518 }
1519 if ( _46F04E_collide_against_portals() )
1520 break;
1521 ++v40;
1522 }
1523 while ( v40 < 100 );
1524 if ( stru_721530.field_7C >= stru_721530.field_6C )
1525 {
1526 v1->vPosition.x = stru_721530.normal2.x;
1527 v1->vPosition.y = stru_721530.normal2.y;
1528 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
1529 v1->uSectorID = LOWORD(stru_721530.uSectorID);
1530 if ( !(HIBYTE(v2->uFlags) & 1) )
1531 return;
1532 memset(&Dst, v8, 0x68u);
1533 v29 = v2->uFlags;
1534 Dst.x = (double)v1->vPosition.x;
1535 Dst.y = (double)v1->vPosition.y;
1536 Dst.z = (double)v1->vPosition.z;
1537 Dst.flt_10 = 0.0;
1538 Dst.flt_14 = 0.0;
1539 Dst.flt_18 = 0.0;
1540 if ( v29 & 0x200 )
1541 {
1542 Dst.bFree = 1036;
1543 Dst.uDiffuse = 0xFF3C1Eu;
1544 v30 = rand();
1545 v34 = (TEXTURE_TYPE)v8;
1546 v32 = "effpar01";
1547 }
1548 else
1549 {
1550 if ( v29 & 0x400 )
1551 goto LABEL_70;
1552 Dst.bFree = 1032;
1553 Dst.uDiffuse = rand();
1554 v30 = rand();
1555 v34 = (TEXTURE_TYPE)v8;
1556 v32 = "effpar03";
1557 }
1558 Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128;
1559 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
1560 goto LABEL_71;
1561 }
1562 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
1563 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
1564 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1565 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
1566 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1567 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
1568 v1->uSectorID = LOWORD(stru_721530.uSectorID);
1569 stru_721530.field_70 += stru_721530.field_7C;
1570 if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
1571 return;
1572 v15 = (signed int)stru_721530.uFaceID >> 3;
1573 if ( (stru_721530.uFaceID & 7) == 5 )
1574 {
1575 v40 = sub_452A9E(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y);
1576 v23 = stru_5C6E00->Atan2(
1577 v1->vPosition.x - pLevelDecorations[v15].vPosition.x,
1578 v1->vPosition.y - pLevelDecorations[v15].vPosition.y);
1579 v42 = stru_5C6E00->SinCos(v23);
1580 v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
1581 v24 = v23 - stru_5C6E00->uIntegerHalfPi;
1582 v1->vVelocity.x = (unsigned int)(v42 * v40) >> 16;
1583 v25 = stru_5C6E00->SinCos(v24);
1584 v42 = v25;
1585 v26 = v25 * (signed __int64)v40;
1586 v41 = v26 >> 16;
1587 v1->vVelocity.y = WORD1(v26);
1588 }
1589 else
1590 {
1591 if ( (stru_721530.uFaceID & 7) != 6 )
1592 goto LABEL_64;
1593 stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3;
1594 v16 = &pIndoor->pFaces[v15];
1595 if ( v16->uPolygonType != 3 )
1596 {
1597 v42 = abs(v16->pFacePlane_old.vNormal.x * v1->vVelocity.x + v16->pFacePlane_old.vNormal.z * v1->vVelocity.z
1598 + v16->pFacePlane_old.vNormal.y * v1->vVelocity.y) >> 16;
1599 if ( stru_721530.field_64 >> 3 > v42 )
1600 v42 = stru_721530.field_64 >> 3;
1601 v40 = v16->pFacePlane_old.vNormal.x;
1602 v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
1603 v41 = v16->pFacePlane_old.vNormal.y;
1604 v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16;
1605 v39 = v16->pFacePlane_old.vNormal.z;
1606 v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16;
1607 v1->vVelocity.x += 2 * v40;
1608 v1->vVelocity.y += 2 * v41;
1609 if ( v16->pFacePlane_old.vNormal.z <= 32000 )
1610 {
1611 v22 = 2 * v39;
1612 }
1613 else
1614 {
1615 v21 = v39;
1616 v40 = 32000;
1617 v1->vVelocity.z += v39;
1618 v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16;
1619 v22 = (unsigned int)(v40 * v21) >> 16;
1620 }
1621 v1->vVelocity.z += v22;
1622 goto LABEL_60;
1623 }
1624 if ( v37->uFlags & 0x80 )
1625 {
1626 v17 = -v1->vVelocity.z >> 1;
1627 v1->vVelocity.z = v17;
1628 if ( (signed __int16)v17 < 10 )
1629 v1->vVelocity.z = 0;
1630 LABEL_60:
1631 if ( BYTE3(v16->uAttributes) & 0x10 )
1632 EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
1633 goto LABEL_63;
1634 }
1635 v18 = v1->vVelocity.y;
1636 v19 = v1->vVelocity.x;
1637 v1->vVelocity.z = 0;
1638 if ( v19 * v19 + v18 * v18 >= 400 )
1639 goto LABEL_60;
1640 v20 = pIndoor->pVertices;
1641 v1->vVelocity.z = 0;
1642 v1->vVelocity.y = 0;
1643 v1->vVelocity.x = 0;
1644 v1->vPosition.z = v20[*v16->pVertexIDs].z + 1;
1645 }
1646 LABEL_63:
1647 v2 = v37;
1648 LABEL_64:
1649 v41 = v1->vVelocity.x;
1650 v40 = 58500;
1651 v41 = (unsigned __int64)(58500i64 * v41) >> 16;
1652 v1->vVelocity.x = v41;
1653 v41 = v1->vVelocity.y;
1654 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
1655 v40 = 58500;
1656 v1->vVelocity.y = v41;
1657 v41 = v1->vVelocity.z;
1658 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
1659 ++uFaceID;
1660 v28 = __OFSUB__(uFaceID, 100);
1661 v27 = uFaceID - 100 < 0;
1662 v1->vVelocity.z = v41;
1663 if ( !(v27 ^ v28) )
1664 return;
1665 v8 = 0;
1666 }
1667 }
1668 if ( v42 <= v1->vPosition.z - 3 )
1669 {
1670 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1671 goto LABEL_24;
1672 }
1673 if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID_, 0) )
1674 {
1675 v6 = pIndoor->pFaces;
1676 v1->vPosition.z = v42 + 1;
1677 v7 = &v6[uFaceID];
1678 if ( v7->uPolygonType == 3 )
1679 {
1680 v8 = 0;
1681 v1->vVelocity.z = 0;
1682 }
1683 else
1684 {
1685 if ( v7->pFacePlane_old.vNormal.z < 45000 )
1686 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1687 v8 = 0;
1688 }
1689 v42 = v1->vVelocity.x;
1690 uFaceID = 58500;
1691 v42 = (unsigned __int64)(58500i64 * v42) >> 16;
1692 v1->vVelocity.x = v42;
1693 v42 = v1->vVelocity.y;
1694 v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
1695 uFaceID = 58500;
1696 v1->vVelocity.y = v42;
1697 v42 = v1->vVelocity.z;
1698 v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
1699 v9 = v1->vVelocity.x;
1700 v1->vVelocity.z = v42;
1701 if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 )
1702 {
1703 v1->vVelocity.z = v8;
1704 v1->vVelocity.y = v8;
1705 v1->vVelocity.x = v8;
1706 if ( !(HIBYTE(v2->uFlags) & 1) )
1707 return;
1708 memset(&Dst, v8, 0x68u);
1709 v10 = v2->uFlags;
1710 Dst.x = (double)v1->vPosition.x;
1711 Dst.y = (double)v1->vPosition.y;
1712 Dst.z = (double)v1->vPosition.z;
1713 Dst.flt_10 = 0.0;
1714 Dst.flt_14 = 0.0;
1715 Dst.flt_18 = 0.0;
1716 if ( v10 & 0x200 )
1717 {
1718 Dst.bFree = 1036;
1719 Dst.uDiffuse = 0xFF3C1Eu;
1720 Dst.flt_28 = 1.0;
1721 v11 = rand();
1722 v33 = (TEXTURE_TYPE)v8;
1723 v31 = "effpar01";
1724 }
1725 else
1726 {
1727 if ( v10 & 0x400 )
1728 {
1729 LABEL_70:
1730 Dst.bFree = 512;
1731 Dst.uDiffuse = rand();
1732 Dst.timeToLive = 64;
1733 Dst.uTextureID = v8;
1734 LABEL_71:
1735 Dst.flt_28 = 1.0;
1736 goto LABEL_72;
1737 }
1738 Dst.bFree = 1032;
1739 Dst.uDiffuse = rand();
1740 Dst.flt_28 = 1.0;
1741 v11 = rand();
1742 v33 = (TEXTURE_TYPE)v8;
1743 v31 = "effpar03";
1744 }
1745 Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128;
1746 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
1747 LABEL_72:
1748 pGame->pParticleEngine->AddParticle(&Dst);
1749 return;
1750 }
1751 goto LABEL_25;
1752 }
1753 }
1754 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
1755
1756 //----- (00471C03) --------------------------------------------------------
1757 void LayingItem::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
1758 {
1759 LayingItem *v1; // esi@1
1760 ObjectDesc *v2; // ebx@1
1761 signed int v3; // edx@1
1762 int v4; // ecx@1
1763 int v5; // ST04_4@1
1764 int v6; // eax@1
1765 int v7; // ecx@1
1766 int v8; // edi@1
1767 int v9; // eax@4
1768 __int16 v10; // ax@7
1769 int v11; // edx@11
1770 int v12; // ecx@11
1771 signed int v13; // edx@14
1772 signed int v14; // edx@16
1773 int v15; // eax@24
1774 int v16; // eax@25
1775 int v17; // ST10_4@25
1776 signed int v18; // eax@25
1777 signed int v19; // eax@28
1778 Actor *v20; // edi@31
1779 int v21; // eax@41
1780 int v22; // ecx@43
1781 __int16 v23; // bx@45
1782 char v24; // al@46
1783 signed int i; // edi@50
1784 int v26; // edi@52
1785 int v27; // eax@52
1786 __int16 v28; // cx@55
1787 int v29; // eax@55
1788 signed int v30; // edi@59
1789 BSPModel *v31; // ecx@61
1790 ODMFace *v32; // edi@61
1791 int v33; // eax@62
1792 int v34; // ecx@62
1793 int v35; // eax@63
1794 Actor *v36; // ecx@67
1795 __int16 v37; // ax@67
1796 int v38; // eax@72
1797 int v39; // eax@72
1798 unsigned __int64 v40; // qax@72
1799 int v41; // eax@72
1800 unsigned __int8 v42; // sf@74
1801 unsigned __int8 v43; // of@74
1802 int v44; // eax@77
1803 __int16 v45; // bx@81
1804 int v46; // eax@85
1805 const char *v47; // [sp-8h] [bp-B0h]@83
1806 enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46
1807 int v49; // [sp+Ch] [bp-9Ch]@52
1808 int v50; // [sp+10h] [bp-98h]@52
1809 Vec3_int_ v51; // [sp+14h] [bp-94h]@11
1810 Particle_ Dst; // [sp+20h] [bp-88h]@45
1811 unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1
1812 int v54; // [sp+8Ch] [bp-1Ch]@1
1813 int v55; // [sp+90h] [bp-18h]@1
1814 int v56; // [sp+94h] [bp-14h]@11
1815 int v57; // [sp+98h] [bp-10h]@1
1816 int v58; // [sp+9Ch] [bp-Ch]@1
1817 int v59; // [sp+A0h] [bp-8h]@1
1818 Actor *v60; // [sp+A4h] [bp-4h]@11
1819
1820 uLayingItemID_ = uLayingItemID;
1821 v1 = &pLayingItems[uLayingItemID];
1822 v58 = 0;
1823 v2 = &pObjectList->pObjects[v1->uObjectDescID];
1824 v57 = GetTerrainHeightsAroundParty(v1->vPosition.x, v1->vPosition.y);
1825 v3 = v1->vPosition.y;
1826 v4 = v1->vPosition.x;
1827 v5 = v2->uHeight;
1828 v55 = 0;
1829 v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0);
1830 v7 = v6;
1831 v54 = v6;
1832 v8 = v6 + 1;
1833 if ( v1->vPosition.z <= v6 + 1 )
1834 {
1835 if ( v59 )
1836 {
1837 v9 = v6 + 60;
1838 if ( v55 )
1839 v9 = v7 + 30;
1840 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9);
1841 LayingItem::_42F933(uLayingItemID_);
1842 v7 = v54;
1843 }
1844 }
1845 else
1846 {
1847 v58 = 1;
1848 }
1849 v10 = v2->uFlags;
1850 if ( !(v10 & 0x20) )
1851 {
1852 if ( v58 )
1853 {
1854 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1855 goto LABEL_13;
1856 }
1857 if ( v57 )
1858 {
1859 v11 = v1->vPosition.y;
1860 v12 = v1->vPosition.x;
1861 v1->vPosition.z = v8;
1862 _46DCC8_get_gravity_direction_outdoor(v12, v11, &v51);
1863 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
1864 v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16;
1865 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
1866 v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16;
1867 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
1868 v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16;
1869 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
1870 v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16;
1871 LABEL_12:
1872 v7 = v54;
1873 goto LABEL_13;
1874 }
1875 if ( v10 & 0x40 )
1876 {
1877 if ( v1->vPosition.z < v7 )
1878 v1->vPosition.z = v8;
1879 if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) )
1880 return;
1881 }
1882 v1->vPosition.z = v8;
1883 if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) )
1884 v1->vVelocity.z = 0;
1885 v60 = (Actor *)v1->vVelocity.x;
1886 v55 = 58500;
1887 v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16);
1888 v1->vVelocity.x = (signed __int16)v60;
1889 v60 = (Actor *)v1->vVelocity.y;
1890 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
1891 v55 = 58500;
1892 v1->vVelocity.y = (signed __int16)v60;
1893 v60 = (Actor *)v1->vVelocity.z;
1894 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
1895 v22 = v1->vVelocity.x;
1896 v1->vVelocity.z = (signed __int16)v60;
1897 if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 )
1898 goto LABEL_12;
1899 v1->vVelocity.y = 0;
1900 v1->vVelocity.x = 0;
1901 if ( !(HIBYTE(v2->uFlags) & 1) )
1902 return;
1903 memset(&Dst, 0, 0x68u);
1904 v23 = v2->uFlags;
1905 Dst.x = (double)v1->vPosition.x;
1906 Dst.y = (double)v1->vPosition.y;
1907 Dst.z = (double)v1->vPosition.z;
1908 Dst.flt_10 = 0.0;
1909 Dst.flt_14 = 0.0;
1910 Dst.flt_18 = 0.0;
1911 if ( HIBYTE(v23) & 2 )
1912 {
1913 Dst.bFree = 1036;
1914 Dst.uDiffuse = 16727070;
1915 v24 = rand();
1916 v48 = (TEXTURE_TYPE)0;
1917 LABEL_83:
1918 v47 = "effpar01";
1919 }
1920 else
1921 {
1922 if ( HIBYTE(v23) & 4 )
1923 {
1924 Dst.bFree = 512;
1925 Dst.uDiffuse = rand();
1926 Dst.timeToLive = 64;
1927 Dst.uTextureID = 0;
1928 LABEL_89:
1929 Dst.flt_28 = 1.0;
1930 pGame->pParticleEngine->AddParticle(&Dst);
1931 return;
1932 }
1933 Dst.bFree = 1032;
1934 Dst.uDiffuse = rand();
1935 v24 = rand();
1936 v48 = (TEXTURE_TYPE)0;
1937 LABEL_87:
1938 v47 = "effpar03";
1939 }
1940 Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128;
1941 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48);
1942 goto LABEL_89;
1943 }
1944 LABEL_13:
1945 if ( v1->vPosition.z > v7
1946 && (v13 = v1->vPosition.x, v13 >= -32768)
1947 && v13 <= 32768
1948 && (v14 = v1->vPosition.y, v14 >= -32768)
1949 && v14 <= 32768
1950 && v1->vPosition.z <= 13000
1951 || !(v2->uFlags & 0x40) )
1952 goto LABEL_92;
1953 if ( v1->vPosition.z < v7 )
1954 v1->vPosition.z = v8;
1955 if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) )
1956 {
1957 LABEL_92:
1958 stru_721530.field_0 = 0;
1959 v55 = 0;
1960 stru_721530.prolly_normal_d = v2->uRadius;
1961 stru_721530.field_C = v2->uHeight;
1962 stru_721530.field_8 = 0;
1963 stru_721530.field_70 = 0;
1964 while ( 1 )
1965 {
1966 stru_721530.field_34.x = v1->vPosition.x;
1967 stru_721530.normal.x = stru_721530.field_34.x;
1968 v15 = v1->vPosition.y;
1969 stru_721530.uSectorID = 0;
1970 stru_721530.field_34.y = v15;
1971 stru_721530.normal.y = v15;
1972 stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1;
1973 stru_721530.normal.z = stru_721530.field_34.z;
1974 stru_721530.field_1C = v1->vVelocity.x;
1975 stru_721530.field_20 = v1->vVelocity.y;
1976 stru_721530.field_24 = v1->vVelocity.z;
1977 if ( stru_721530._47050A(0) )
1978 return;
1979 _46E889_collide_against_bmodels(0);
1980 v16 = WorldPosToGridCellZ(v1->vPosition.y);
1981 v17 = v1->vPosition.x;
1982 v58 = v16;
1983 v18 = WorldPosToGridCellX(v17);
1984 _46E26D_collide_against_sprites(v18, v58);
1985 if ( (v1->field_58 & 7) != 4 )
1986 _46EF01_collision_chech_player(0);
1987 if ( (v1->field_58 & 7) == 3 )
1988 {
1989 v19 = v1->field_58 >> 3;
1990 if ( v19 >= 0 )
1991 {
1992 if ( v19 < (signed int)(uNumActors - 1) )
1993 {
1994 v56 = 0;
1995 if ( (signed int)uNumActors > 0 )
1996 {
1997 v60 = pActors;
1998 v20 = &pActors[v19];
1999 do
2000 {
2001 if ( v20->GetActorsRelation(v60) )
2002 _46DF1A_collide_against_actor(v56, 0);
2003 ++v56;
2004 ++v60;
2005 }
2006 while ( v56 < (signed int)uNumActors );
2007 }
2008 }
2009 }
2010 }
2011 else
2012 {
2013 for ( i = 0; i < (signed int)uNumActors; ++i )
2014 _46DF1A_collide_against_actor(i, 0);
2015 }
2016 v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2017 v27 = sub_46D49E_prolly_get_world_y_under_party(
2018 stru_721530.normal2.x,
2019 stru_721530.normal2.y,
2020 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
2021 v2->uHeight,
2022 &v49,
2023 &v50,
2024 0);
2025 if ( v59 && v26 < v27 + 60 )
2026 {
2027 if ( v50 )
2028 v44 = v27 + 30;
2029 else
2030 v44 = v54 + 60;
2031 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44);
2032 LayingItem::_42F933(uLayingItemID_);
2033 return;
2034 }
2035 if ( stru_721530.field_7C >= stru_721530.field_6C )
2036 {
2037 v1->vPosition.x = stru_721530.normal2.x;
2038 v1->vPosition.y = stru_721530.normal2.y;
2039 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2040 v1->uSectorID = LOWORD(stru_721530.uSectorID);
2041 if ( !(HIBYTE(v2->uFlags) & 1) )
2042 return;
2043 memset(&Dst, 0, 0x68u);
2044 v45 = v2->uFlags;
2045 Dst.x = (double)v1->vPosition.x;
2046 Dst.y = (double)v1->vPosition.y;
2047 Dst.z = (double)v1->vPosition.z;
2048 Dst.flt_10 = 0.0;
2049 Dst.flt_14 = 0.0;
2050 Dst.flt_18 = 0.0;
2051 if ( HIBYTE(v45) & 2 )
2052 {
2053 Dst.bFree = 1036;
2054 Dst.uDiffuse = 16727070;
2055 v24 = rand();
2056 v48 = (TEXTURE_TYPE)0;
2057 goto LABEL_83;
2058 }
2059 if ( HIBYTE(v45) & 4 )
2060 {
2061 Dst.bFree = 512;
2062 v46 = rand();
2063 Dst.uTextureID = 0;
2064 Dst.uDiffuse = v46;
2065 Dst.timeToLive = 64;
2066 goto LABEL_89;
2067 }
2068 Dst.bFree = 1032;
2069 Dst.uDiffuse = rand();
2070 v24 = rand();
2071 v48 = (TEXTURE_TYPE)0;
2072 goto LABEL_87;
2073 }
2074 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
2075 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2076 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
2077 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2078 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
2079 v28 = LOWORD(stru_721530.uSectorID);
2080 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
2081 v29 = v1->vPosition.z;
2082 v1->uSectorID = v28;
2083 stru_721530.field_70 += stru_721530.field_7C;
2084 if ( v2->uFlags & 0x40 )
2085 {
2086 if ( v29 < v54 )
2087 v1->vPosition.z = v54 + 1;
2088 if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
2089 return;
2090 }
2091 v30 = (signed int)stru_721530.uFaceID >> 3;
2092 if ( (stru_721530.uFaceID & 7) == 5 )
2093 break;
2094 if ( (stru_721530.uFaceID & 7) == 6 )
2095 {
2096 v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
2097 v32 = &v31->pFaces[v30 & 0x3F];
2098 if ( v32->uPolygonType != 3 )
2099 {
2100 v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y
2101 + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16;
2102 if ( stru_721530.field_64 >> 3 > v56 )
2103 v56 = stru_721530.field_64 >> 3;
2104 v57 = v32->pFacePlane.vNormal.x;
2105 v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
2106 v58 = v32->pFacePlane.vNormal.y;
2107 v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
2108 v60 = (Actor *)v32->pFacePlane.vNormal.z;
2109 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16);
2110 v1->vVelocity.x += 2 * v57;
2111 v1->vVelocity.y += 2 * v58;
2112 if ( v32->pFacePlane.vNormal.z <= 32000 )
2113 {
2114 v37 = 2 * (short)v60;
2115 }
2116 else
2117 {
2118 v36 = v60;
2119 v57 = 32000;
2120 v1->vVelocity.z += (signed __int16)v60;
2121 v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16;
2122 v37 = (unsigned int)(v57 * (int)v36) >> 16;
2123 }
2124 v1->vVelocity.z += v37;
2125 LABEL_70:
2126 if ( BYTE3(v32->uAttributes) & 0x10 )
2127 EventProcessor(v32->sCogTriggeredID, 0, 1);
2128 goto LABEL_74;
2129 }
2130 v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z;
2131 v34 = v1->vVelocity.x;
2132 v1->vPosition.z = v33 + 1;
2133 if ( v1->vVelocity.y * v1->vVelocity.y + v34 * v34 >= 400 )
2134 goto LABEL_70;
2135 LOWORD(v35) = 0;
2136 v1->vVelocity.z = 0;
2137 v1->vVelocity.x = 0;
2138 goto LABEL_73;
2139 }
2140 LABEL_74:
2141 v58 = v1->vVelocity.x;
2142 v57 = 58500;
2143 v58 = (unsigned __int64)(58500i64 * v58) >> 16;
2144 v1->vVelocity.x = v58;
2145 v58 = v1->vVelocity.y;
2146 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
2147 v57 = 58500;
2148 v1->vVelocity.y = v58;
2149 v58 = v1->vVelocity.z;
2150 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
2151 ++v55;
2152 v43 = __OFSUB__(v55, 100);
2153 v42 = v55 - 100 < 0;
2154 v1->vVelocity.z = v58;
2155 if ( !(v42 ^ v43) )
2156 return;
2157 }
2158 v57 = sub_452A9E(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x);
2159 v38 = stru_5C6E00->Atan2(
2160 v1->vPosition.x - pLevelDecorations[v30].vPosition.x,
2161 v1->vPosition.y - pLevelDecorations[v30].vPosition.y);
2162 v56 = v38;
2163 v39 = stru_5C6E00->SinCos(v38);
2164 v60 = (Actor *)v39;
2165 v40 = v39 * (signed __int64)v57;
2166 v58 = v40 >> 16;
2167 v1->vVelocity.x = WORD1(v40);
2168 v41 = stru_5C6E00->SinCos(v56 - stru_5C6E00->uIntegerHalfPi);
2169 v60 = (Actor *)v41;
2170 v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16;
2171 v58 = v35;
2172 LABEL_73:
2173 v1->vVelocity.y = v35;
2174 goto LABEL_74;
2175 }
2176 }
2177
2178
2179
2180 //----- (0047253E) --------------------------------------------------------
2181 void UpdateObjects()
2182 {
2183 unsigned int v0; // ebx@0
2184 //unsigned int v1; // edi@1
2185 char *v2; // esi@2
2186 //__int16 v3; // dx@5
2187 ObjectDesc *v4; // eax@5
2188 int v5; // ecx@6
2189 __int16 v6; // cx@7
2190 signed int v7; // eax@9
2191 __int16 v8; // cx@14
2192 __int16 v9; // dx@14
2193 unsigned int v10; // ecx@16
2194 signed int v11; // eax@17
2195 int v12; // edi@27
2196 int v13; // eax@27
2197 int v14; // ebx@27
2198 unsigned int v15; // ecx@27
2199 unsigned int v16; // edx@30
2200 unsigned int v17; // edx@32
2201 int v18; // [sp+4h] [bp-10h]@27
2202 int v19; // [sp+8h] [bp-Ch]@27
2203 //signed int v20; // [sp+10h] [bp-4h]@1
2204
2205 //v1 = 0;
2206 //v20 = 0;
2207 for (uint i = 0; i < uNumLayingItems; ++i)
2208 {
2209 auto item = pLayingItems + i;
2210 v2 = (char *)&item->uSpriteFrameID;
2211 //do
2212 //{
2213 //LOWORD(v0) = item->uAttributes;
2214 if (item->uAttributes & 0x40)
2215 item->uAttributes &= 0xFFBF;
2216 else
2217 {
2218 //v3 = item->uObjectDescID;
2219 v4 = &pObjectList->pObjects[item->uObjectDescID];
2220 if (item->uAttributes)
2221 {
2222 v5 = *(int *)(v2 + 62) >> 3;
2223 *(int *)(v2 - 26) = pActors[v5].vPosition.x;
2224 *(int *)(v2 - 22) = pActors[v5].vPosition.y;
2225 *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
2226 if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + *(short *)v2, *(short *)v2 = v6, !(v4->uFlags & 4)) )
2227 goto LABEL_36;
2228 if ( v6 >= 0 )
2229 {
2230 v7 = v4->uLifetime;
2231 if (item->uAttributes & 2)
2232 v7 = *((short *)v2 + 1);
2233 if ( v6 < v7 )
2234 goto LABEL_36;
2235 }
2236 goto LABEL_34;
2237 }
2238
2239 if ( item->uObjectDescID )
2240 {
2241 v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID;
2242 item->uSpriteFrameID = v8;
2243 v9 = v4->uFlags;
2244 if ( !(v9 & 4) )
2245 goto LABEL_22;
2246 if ( v8 < 0 )
2247 {
2248 v10 = i;
2249 LABEL_35:
2250 LayingItem::_42F933(v10);
2251 goto LABEL_36;
2252 }
2253 v11 = v4->uLifetime;
2254 if ( item->uAttributes & 2 )
2255 v11 = *((short *)v2 + 1);
2256 if ( v8 < v11 )
2257 {
2258 LABEL_22:
2259 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
2260 LayingItem::UpdateObject_fn0_BLV(i);
2261 else
2262 LayingItem::UpdateObject_fn0_ODM(i);
2263 if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
2264 goto LABEL_36;
2265 v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
2266 v18 = abs(pParty->vPosition.y - *(int *)(v2 - 22));
2267 v19 = abs(pParty->vPosition.z - *(int *)(v2 - 18));
2268 v13 = v12;
2269 v14 = v18;
2270 v15 = v19;
2271 if ( v12 < v18 )
2272 {
2273 v13 = v18;
2274 v14 = v12;
2275 }
2276 if ( v13 < v19 )
2277 {
2278 v16 = v13;
2279 v13 = v19;
2280 v15 = v16;
2281 }
2282 if ( v14 < (signed int)v15 )
2283 {
2284 v17 = v15;
2285 v15 = v14;
2286 v14 = v17;
2287 }
2288 v0 = (unsigned int)(11 * v14) >> 5;
2289 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
2290 goto LABEL_36;
2291 LABEL_34:
2292 v10 = i;
2293 goto LABEL_35;
2294 }
2295 v10 = i;
2296 if ( !(v9 & 0x40) )
2297 goto LABEL_35;
2298 _46BFFA_check_object_intercept(i, 8 * i | OBJECT_Item);
2299 }
2300 }
2301 LABEL_36:
2302 ;
2303 //v2 += 112;
2304 //v1 = v20++ + 1;
2305 //}
2306 //while ( v20 < (signed int)uNumLayingItems );
2307 }
2308 }
2309
2310 //----- (0047272C) --------------------------------------------------------
2311 int _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
2312 {
2313 signed int v5; // ebx@1
2314 int result; // eax@1
2315 int v7; // [sp+10h] [bp-8h]@1
2316 signed int v8; // [sp+14h] [bp-4h]@1
2317
2318 __debugbreak();
2319 v5 = x - 2;
2320 v7 = x;
2321 v8 = y;
2322 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
2323 result = _46ED1B_collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID);
2324 if ( result == -30000 || !*pSectorID )
2325 {
2326 *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40);
2327 result = _46ED1B_collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID);
2328 if ( result == -30000 || !*pSectorID )
2329 {
2330 *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40);
2331 result = _46ED1B_collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID);
2332 if ( result == -30000 || !*pSectorID )
2333 {
2334 *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40);
2335 result = _46ED1B_collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID);
2336 if ( result == -30000 || !*pSectorID )
2337 {
2338 *pSectorID = pIndoor->GetSector(v7, v8, z + 140);
2339 result = _46ED1B_collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID);
2340 }
2341 }
2342 }
2343 }
2344 return result;
2345 }
2346
2347 //----- (00472866) --------------------------------------------------------
2348 void BLV_ProcessPartyActions()
2349 {
2350 int v1; // ebx@1
2351 int v2; // edi@1
2352 int v6; // eax@18
2353 signed __int64 v8; // qax@27
2354 int v9; // eax@27
2355 double v10; // st7@27
2356 unsigned int v12; // eax@49
2357 double v13; // st7@50
2358 int v14; // eax@51
2359 signed __int64 v15; // qax@53
2360 double v16; // st7@54
2361 int v17; // eax@62
2362 double v18; // st7@62
2363 int v19; // ST40_4@62
2364 int v20; // eax@65
2365 double v21; // st7@65
2366 int v22; // ST40_4@65
2367 int v23; // eax@66
2368 double v24; // st7@66
2369 int v25; // ST40_4@66
2370 int v26; // eax@67
2371 double v27; // st7@67
2372 int v28; // ST40_4@67
2373 unsigned int v35; // eax@74
2374 int v36; // ecx@88
2375 int new_party_z; // esi@96
2376 int v38; // eax@96
2377 int v39; // ecx@106
2378 int v40; // eax@106
2379 Player **v41; // esi@113
2380 int v42; // eax@120
2381 signed int v43; // ecx@123
2382 BLVFace *v44; // esi@126
2383 PolygonType v45; // al@126
2384 int v46; // ecx@133
2385 char v47; // zf@133
2386 int v48; // eax@133
2387 int v49; // ST40_4@136
2388 int v50; // ST40_4@140
2389 int v51; // eax@140
2390 int v52; // eax@140
2391 signed int v53; // edi@146
2392 int v54; // ebx@146
2393 int v55; // ST30_4@146
2394 AudioPlayer *v56; // ecx@162
2395 SoundID v57; // [sp-20h] [bp-80h]@163
2396 signed int v58; // [sp-1Ch] [bp-7Ch]@161
2397 unsigned int v59; // [sp-18h] [bp-78h]@161
2398 signed int v60; // [sp-14h] [bp-74h]@161
2399 signed int v61; // [sp-10h] [bp-70h]@161
2400 int v62; // [sp-Ch] [bp-6Ch]@161
2401 int v63; // [sp-8h] [bp-68h]@75
2402 unsigned int v64; // [sp-8h] [bp-68h]@161
2403 int v65; // [sp-4h] [bp-64h]@75
2404 int v66; // [sp-4h] [bp-64h]@161
2405 int v68; // [sp+10h] [bp-50h]@45
2406 int v69; // [sp+10h] [bp-50h]@140
2407 unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
2408 signed int v71; // [sp+18h] [bp-48h]@1
2409 signed int v72; // [sp+1Ch] [bp-44h]@1
2410 signed int v73; // [sp+20h] [bp-40h]@100
2411 int v74; // [sp+20h] [bp-40h]@140
2412 bool bFeatherFall; // [sp+24h] [bp-3Ch]@15
2413 unsigned int uSectorID; // [sp+28h] [bp-38h]@1
2414 int v78; // [sp+2Ch] [bp-34h]@1
2415 unsigned int uFaceID; // [sp+30h] [bp-30h]@1
2416 int v80; // [sp+34h] [bp-2Ch]@1
2417 int v81; // [sp+38h] [bp-28h]@47
2418 int v82; // [sp+3Ch] [bp-24h]@47
2419 int _view_angle; // [sp+40h] [bp-20h]@47
2420 int bJumping; // [sp+44h] [bp-1Ch]@1
2421 int new_party_y; // [sp+48h] [bp-18h]@1
2422 int new_party_x; // [sp+4Ch] [bp-14h]@1
2423 int party_z; // [sp+50h] [bp-10h]@1
2424 int v89; // [sp+58h] [bp-8h]@1
2425 int angle; // [sp+5Ch] [bp-4h]@47
2426
2427 uFaceEvent = 0;
2428 v89 = pParty->uFallSpeed;
2429 v1 = 0;
2430 new_party_y = pParty->vPosition.y;
2431 v2 = 0;
2432 new_party_x = pParty->vPosition.x;
2433 party_z = pParty->vPosition.z;
2434 uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
2435 v72 = 0;
2436 v78 = 0;
2437 v71 = 0;
2438 bJumping = 0;
2439 v80 = _46ED1B_collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
2440 if ( pParty->bFlying )
2441 {
2442 pParty->bFlying = 0;
2443 __debugbreak();
2444 if (pParty->FlyActive())
2445 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing]
2446 }
2447 if ( v80 == -30000 )
2448 {
2449 v80 = _47272C_collide_agains_some_secotors_floors(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
2450 if ( v80 == -30000 )
2451 {
2452 pParty->vPosition.x = blv_prev_party_x;
2453 pParty->vPosition.y = blv_prev_party_z;
2454 pParty->vPosition.z = blv_prev_party_y;
2455 pParty->uFallStartY = blv_prev_party_y;
2456 return;
2457 }
2458 }
2459 blv_prev_party_x = pParty->vPosition.x;
2460 blv_prev_party_z = pParty->vPosition.y;
2461 blv_prev_party_y = pParty->vPosition.z;
2462 if (!pParty->bTurnBasedModeOn)
2463 {
2464 auto v67 = GetTickCount() / 500;
2465 if (dword_720CDC != v67 )
2466 {
2467 dword_4F8580[3 * dword_4F8580[0] + 1] = pParty->vPosition.x;
2468 dword_4F8580[3 * dword_4F8580[0] + 2] = pParty->vPosition.y;
2469 dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.z;
2470 if ( dword_4F8580[0] > 60 )
2471 dword_4F8580[0] = 1;
2472 }
2473 dword_720CDC = v67;
2474 }
2475 if (!pParty->FeatherFallActive())
2476 {
2477 bFeatherFall = false;
2478 if (!pParty->pPlayers[0].WearsItem(536, 16) &&
2479 !pParty->pPlayers[1].WearsItem(536, 16) &&
2480 !pParty->pPlayers[2].WearsItem(536, 16) &&
2481 !pParty->pPlayers[3].WearsItem(536, 16))
2482 {
2483 v6 = pParty->uFallStartY;
2484 }
2485 }
2486 else
2487 {
2488 v6 = v80;
2489 bFeatherFall = true;
2490 pParty->uFallStartY = v80;
2491 }
2492 LABEL_20:
2493 if ( v6 - party_z > 512 && !bFeatherFall && party_z <= v80 + 1 )
2494 {
2495 if ( BYTE1(pParty->uFlags) & 1 )
2496 {
2497 BYTE1(pParty->uFlags) &= 0xFEu;
2498 }
2499 else for (uint i = 0; i < 4; ++i)
2500 { // receive falling damage
2501 auto pPlayer = pParty->pPlayers + i;
2502
2503 if (!pPlayer->HasEnchantedItemEquipped(72) &&
2504 !pPlayer->WearsItem(529, 8))
2505 {
2506 v8 = (signed __int64)((double)pPlayer->GetMaxHealth() * 0.1);
2507 pPlayer->ReceiveDamage((pParty->uFallStartY - party_z) * (signed int)v8 / 256, 4);
2508 v9 = pPlayer->GetActualEndurance();
2509 v10 = (double)(20 - pPlayer->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
2510 pPlayer->SetRecoveryTime((signed __int64)v10);
2511 }
2512 }
2513 }
2514 if ( party_z > v80 + 1 )
2515 bJumping = 1;
2516 bFeatherFall = party_z - v80 <= 32;
2517 if ( party_z - v80 <= 32 )
2518 pParty->uFallStartY = party_z;
2519 if ( bWalkSound && pParty->field_6F8 > 0 )
2520 pParty->field_6F8 -= pEventTimer->uTimeElapsed;
2521 if ( party_z > v80 + 1 )
2522 {
2523 LABEL_43:
2524 if ( bJumping )
2525 goto LABEL_45;
2526 goto LABEL_44;
2527 }
2528 party_z = v80 + 1;
2529 pParty->uFallStartY = v80 + 1;
2530 if ( bJumping )
2531 goto LABEL_45;
2532 if (pParty->field_6F4_packedid != uFaceID)
2533 {
2534 auto pFace = &pIndoor->pFaces[uFaceID];
2535 if (pFace->uAttributes & 0x04000000 )
2536 {
2537 uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
2538 goto LABEL_43;
2539 }
2540 }
2541 LABEL_44:
2542 pParty->field_6F4_packedid = uFaceID;
2543 LABEL_45:
2544 v68 = uFaceID;
2545 if ( pIndoor->pFaces[uFaceID].uAttributes & 0x10 )
2546 v71 = 1;
2547 v81 = pParty->uWalkSpeed;
2548 angle = pParty->sRotationY;
2549 _view_angle = pParty->sRotationX;
2550 v82 = (unsigned __int64)(pEventTimer->dt_in_some_format
2551 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed * stru_5C6E00->uIntegerPi)
2552 / 180)) >> 16;
2553 LABEL_87:
2554 while ( pPartyActionQueue->uNumActions )
2555 {
2556 switch ( pPartyActionQueue->Next() )
2557 {
2558 case PARTY_TurnLeft:
2559 __debugbreak();
2560 v12 = uTurnSpeed;
2561 if ( uTurnSpeed )
2562 goto LABEL_58;
2563 v13 = (double)v82 * fTurnSpeedMultiplier;
2564 goto LABEL_51;
2565 case PARTY_TurnRight:
2566 __debugbreak();
2567 LODWORD(v15) = uTurnSpeed;
2568 if ( uTurnSpeed )
2569 goto LABEL_56;
2570 v16 = (double)v82 * fTurnSpeedMultiplier;
2571 goto LABEL_55;
2572 case PARTY_FastTurnLeft:
2573 v12 = uTurnSpeed;
2574 if ( uTurnSpeed )
2575 {
2576 LABEL_58:
2577 v14 = angle + v12;
2578 }
2579 else
2580 {
2581 v13 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82;
2582 LABEL_51:
2583 v14 = angle + (unsigned __int64)(signed __int64)v13;
2584 }
2585 angle = stru_5C6E00->uDoublePiMask & v14;
2586 goto LABEL_87;
2587 case PARTY_FastTurnRight:
2588 LODWORD(v15) = uTurnSpeed;
2589 if ( !uTurnSpeed )
2590 {
2591 v16 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82;
2592 LABEL_55:
2593 v15 = (signed __int64)v16;
2594 }
2595 LABEL_56:
2596 angle = stru_5C6E00->uDoublePiMask & (angle - v15);
2597 goto LABEL_87;
2598 case PARTY_StrafeLeft:
2599 __debugbreak();
2600 v17 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2601 v18 = (double)v81;
2602 //v88 = v18;
2603 v78 = (unsigned __int64)(v17 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16;
2604 v2 -= v78;
2605 v19 = stru_5C6E00->SinCos(angle);
2606 v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16;
2607 goto LABEL_63;
2608 case PARTY_StrafeRight:
2609 __debugbreak();
2610 v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2611 v21 = (double)v81;
2612 //v88 = v21;
2613 v78 = (unsigned __int64)(v20 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16;
2614 v2 += v78;
2615 v22 = stru_5C6E00->SinCos(angle);
2616 v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16;
2617 goto LABEL_68;
2618 case PARTY_WalkForward:
2619 __debugbreak();
2620 v23 = stru_5C6E00->SinCos(angle);
2621 v24 = (double)v81;
2622 //v88 = v24;
2623 v78 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
2624 v2 += v78;
2625 v25 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2626 v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
2627 LABEL_63:
2628 v1 += v78;
2629 goto LABEL_64;
2630 case PARTY_WalkBackward:
2631 __debugbreak();
2632 v26 = stru_5C6E00->SinCos(angle);
2633 v27 = (double)v81;
2634 //v88 = v27;
2635 v78 = (unsigned __int64)(v26
2636 * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16;
2637 v2 -= v78;
2638 v28 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2639 v78 = (unsigned __int64)(v28
2640 * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16;
2641 LABEL_68:
2642 v1 -= v78;
2643 LABEL_64:
2644 v78 = 1;
2645 goto LABEL_87;
2646 case PARTY_RunForward:
2647 //v29 = stru_5C6E00->SinCos(angle);
2648 //v30 = (double)v81;
2649 //v88 = (double)v81;
2650 v2 += (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
2651 //v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2652 v1 += (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
2653 v72 = 1;
2654 goto LABEL_87;
2655 case PARTY_RunBackward:
2656 //v32 = stru_5C6E00->SinCos(angle);
2657 //v33 = (double)v81;
2658 //v88 = (double)v81;
2659 v2 -= (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
2660 //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
2661 v1 -= (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
2662 //LABEL_70:
2663 v72 = 1;
2664 goto LABEL_87;
2665 case PARTY_LookUp:
2666 __debugbreak();
2667 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
2668 if ( _view_angle > 128 )
2669 _view_angle = 128;
2670 v35 = uActiveCharacter;
2671 if ( !uActiveCharacter )
2672 goto LABEL_87;
2673 v65 = 0;
2674 v63 = 63;
2675 goto LABEL_76;
2676 case PARTY_LookDown:
2677 __debugbreak();
2678 _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
2679 if ( _view_angle < -128 )
2680 _view_angle = -128;
2681 v35 = uActiveCharacter;
2682 if ( uActiveCharacter )
2683 {
2684 v65 = 0;
2685 v63 = 64;
2686 LABEL_76:
2687 pPlayers[v35]->PlaySound(v63, v65);
2688 }
2689 break;
2690 case PARTY_CenterView:
2691 __debugbreak();
2692 _view_angle = 0;
2693 break;
2694 case PARTY_Jump:
2695 __debugbreak();
2696 if ( (!bJumping || party_z <= v80 + 6 && v89 <= 0) && pParty->field_24 )
2697 {
2698 bJumping = 1;
2699 v89 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v89);
2700 }
2701 break;
2702 default:
2703 goto LABEL_87;
2704 }
2705 }
2706 v36 = 0;
2707 pParty->sRotationY = angle;
2708 pParty->sRotationX = _view_angle;
2709 if ( bJumping )
2710 {
2711 v89 += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
2712 }
2713 else
2714 {
2715 if ( pIndoor->pFaces[v68].pFacePlane_old.vNormal.z < 32768 )
2716 {
2717 v89 -= pEventTimer->uTimeElapsed * GetGravityStrength();
2718 goto LABEL_92;
2719 }
2720 if ( BYTE1(pParty->uFlags) & 1 )
2721 goto LABEL_92;
2722 v89 = 0;
2723 }
2724 if ( bJumping != v36 && v89 <= v36 )
2725 {
2726 if ( v89 < -500 && !pParty->bFlying )
2727 {
2728 v41 = &pPlayers[1];
2729 do
2730 {
2731 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) )
2732 (*v41)->PlayEmotion(46, 0);
2733 ++v41;
2734 }
2735 while ( (signed int)v41 <= (signed int)&pPlayers[4] );
2736 }
2737 goto LABEL_93;
2738 }
2739 LABEL_92:
2740 pParty->uFallStartY = party_z;
2741 LABEL_93:
2742 if ( v2 * v2 + v1 * v1 < 400 )
2743 {
2744 v1 = 0;
2745 v2 = 0;
2746 }
2747 stru_721530.field_84 = -1;
2748 stru_721530.field_70 = 0;
2749 stru_721530.prolly_normal_d = pParty->field_14;
2750 stru_721530.field_8 = pParty->field_14 >> 1;
2751 auto v83 = 0;
2752 stru_721530.field_0 = 1;
2753 stru_721530.field_C = pParty->uPartyHeight - 32;
2754 while ( 1 )
2755 {
2756 new_party_z = party_z;
2757 stru_721530.field_34.x = new_party_x;
2758 stru_721530.normal.x = new_party_x;
2759 stru_721530.field_1C = v2;
2760 stru_721530.field_34.y = new_party_y;
2761 stru_721530.normal.y = new_party_y;
2762 stru_721530.field_20 = v1;
2763 stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
2764 stru_721530.field_34.z = stru_721530.field_C + party_z + 1;
2765 stru_721530.field_24 = v89;
2766 stru_721530.uSectorID = uSectorID;
2767 v38 = 0;
2768 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
2769 v38 = 13312;
2770 if ( stru_721530._47050A(v38) )
2771 break;
2772 v73 = 0;
2773 do
2774 {
2775 _46E44E_collide_against_faces_and_portals(1u);
2776 _46E0B2_collide_against_decorations();
2777 for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
2778 _46DF1A_collide_against_actor(v80, 0);
2779 if ( _46F04E_collide_against_portals() )
2780 break;
2781 ++v73;
2782 }
2783 while ( v73 < 100 );
2784 if ( stru_721530.field_7C >= stru_721530.field_6C )
2785 {
2786 v39 = stru_721530.normal2.x;
2787 uSectorID = stru_721530.normal2.y;
2788 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2789 }
2790 else
2791 {
2792 v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + new_party_x;
2793 uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
2794 v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
2795 }
2796 v42 = _46ED1B_collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
2797 if ( v42 == -30000 || v42 - new_party_z > 128 )
2798 return;
2799 if ( stru_721530.field_7C >= stru_721530.field_6C )
2800 {
2801 new_party_x = stru_721530.normal2.x;
2802 new_party_y = stru_721530.normal2.y;
2803 new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
2804 break;
2805 }
2806 new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
2807 new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
2808 v43 = stru_721530.uFaceID;
2809 uSectorID = stru_721530.uSectorID;
2810 stru_721530.field_70 += stru_721530.field_7C;
2811 auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z;
2812 if ( (stru_721530.uFaceID & 7) == 3 )
2813 {
2814 if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
2815 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) )
2816 pParty->pPartyBuffs[11].Reset();
2817 viewparams->bRedrawGameUI = 1;
2818 goto LABEL_152;
2819 }
2820 if ( (stru_721530.uFaceID & 7) == 5 )
2821 {
2822 v53 = sub_452A9E(v2 * v2 + v1 * v1);
2823 v80 = v53;
2824 v54 = stru_5C6E00->Atan2(
2825 new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
2826 new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
2827 v2 = (unsigned __int64)(stru_5C6E00->SinCos(v54) * (signed __int64)v53) >> 16;
2828 v55 = stru_5C6E00->SinCos(v54 - stru_5C6E00->uIntegerHalfPi);
2829 v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16;
2830 }
2831 else
2832 {
2833 if ( (stru_721530.uFaceID & 7) == 6 )
2834 {
2835 v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
2836 v45 = v44->uPolygonType;
2837 if ( v45 == 3 )
2838 {
2839 if ( v89 < 0 )
2840 v89 = 0;
2841 v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1;
2842 if ( pParty->uFallStartY - v87 < 512 )
2843 pParty->uFallStartY = v87;
2844 if ( v2 * v2 + v1 * v1 < 400 )
2845 {
2846 v1 = 0;
2847 v2 = 0;
2848 }
2849 goto LABEL_143;
2850 }
2851 v46 = v89 * v44->pFacePlane_old.vNormal.z;
2852 v47 = v45 == 4;
2853 v48 = v44->pFacePlane_old.vNormal.x;
2854 if ( !v47 )
2855 {
2856 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
2857 if ( stru_721530.field_64 >> 3 > v80 )
2858 v80 = stru_721530.field_64 >> 3;
2859 v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
2860 v81 = v44->pFacePlane_old.vNormal.y;
2861 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
2862 v82 = v44->pFacePlane_old.vNormal.z;
2863 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
2864 v2 += v50;
2865 v89 += v82;
2866 v74 = v44->pFacePlane_old.vNormal.z;
2867 v51 = v44->pFacePlane_old.vNormal.y;
2868 v69 = v44->pFacePlane_old.vNormal.x;
2869 v80 = v51;
2870 v1 += v81;
2871 v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
2872 if ( v52 > 0 )
2873 {
2874 new_party_x += v52 * v69 >> 16;
2875 new_party_y += v52 * v80 >> 16;
2876 v87 += v52 * v74 >> 16;
2877 }
2878 LABEL_142:
2879 v43 = stru_721530.uFaceID;
2880 LABEL_143:
2881 if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 )
2882 uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
2883 goto LABEL_152;
2884 }
2885 v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
2886 if ( stru_721530.field_64 >> 3 > v80 )
2887 v80 = stru_721530.field_64 >> 3;
2888 v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
2889 v81 = v44->pFacePlane_old.vNormal.y;
2890 v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
2891 v82 = v44->pFacePlane_old.vNormal.z;
2892 v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
2893 v2 += v49;
2894 v1 += v81;
2895 v89 += v82;
2896 if ( v2 * v2 + v1 * v1 >= 400 )
2897 goto LABEL_142;
2898 v2 = 0;
2899 v1 = 0;
2900 v89 = 0;
2901 }
2902 }
2903 LABEL_152:
2904 v2 = (unsigned __int64)(58500i64 * v2) >> 16;
2905 v1 = (unsigned __int64)(58500i64 * v1) >> 16;
2906 ++v83;
2907 v89 = (unsigned __int64)(58500i64 * v89) >> 16;
2908 if ( v83 >= 100 )
2909 {
2910 new_party_z = v87;
2911 break;
2912 }
2913 }
2914 if ( bWalkSound && pParty->field_6F8 <= 0 )
2915 {
2916 if ( sub_452A9E((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
2917 * (pParty->vPosition.y - new_party_y)
2918 + (pParty->vPosition.z - new_party_z)
2919 * (pParty->vPosition.z - new_party_z)) <= 16 )
2920 goto LABEL_188;
2921 if ( v72 && (!bJumping || bFeatherFall) )
2922 {
2923 v66 = 0;
2924 v64 = 0;
2925 v62 = 0;
2926 v61 = 0;
2927 v60 = -1;
2928 v59 = 1;
2929 v58 = 804;
2930 if ( !v71 )
2931 {
2932 v56 = pAudioPlayer;
2933 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
2934 v57 = (SoundID)50;
2935 else
2936 v57 = (SoundID)64;
2937 goto LABEL_175;
2938 }
2939 v57 = (SoundID)63;
2940 LABEL_174:
2941 v56 = pAudioPlayer;
2942 goto LABEL_175;
2943 }
2944 if ( v78 && (!bJumping || bFeatherFall) )
2945 {
2946 v66 = 0;
2947 v64 = 0;
2948 v62 = 0;
2949 v61 = 0;
2950 v60 = -1;
2951 v59 = 1;
2952 v58 = 804;
2953 if ( v71 )
2954 {
2955 v57 = (SoundID)102;
2956 goto LABEL_174;
2957 }
2958 v56 = pAudioPlayer;
2959 if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
2960 v57 = (SoundID)89;
2961 else
2962 v57 = (SoundID)103;
2963 LABEL_175:
2964 pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
2965 }
2966 else
2967 {
2968 LABEL_188:
2969 pAudioPlayer->_4AA258(804);
2970 pParty->field_6F8 = 64;
2971 }
2972 }
2973 if ( !bJumping || bFeatherFall )
2974 pParty->uFlags &= 0xFFFFFFF7u;
2975 else
2976 pParty->uFlags |= 8u;
2977 BYTE1(pParty->uFlags) &= 0xFDu;
2978 pParty->vPosition.x = new_party_x;
2979 pParty->vPosition.z = new_party_z;
2980 pParty->vPosition.y = new_party_y;
2981 pParty->uFallSpeed = v89;
2982 if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 )
2983 BYTE1(pParty->uFlags) |= 2u;
2984 if (uFaceEvent)
2985 EventProcessor(uFaceEvent, 0, 1);
2986 }
2987
2988
2989 //----- (00473893) --------------------------------------------------------
2990 void __cdecl ODM_ProcessPartyActions()
2991 {
2992 int _zero; // esi@1
2993 int v1; // edi@1
2994 int v2; // ebx@1
2995 int v3; // eax@14
2996 Player **v4; // esi@21
2997 int v5; // eax@24
2998 int v6; // esi@45
2999 ODMFace *v7; // ecx@45
3000 unsigned int v8; // eax@71
3001 double v9; // st7@72
3002 signed __int64 v10; // qax@74
3003 double v11; // st7@75
3004 int v12; // ecx@77
3005 int v13; // eax@84
3006 double v14; // st7@84
3007 int v15; // eax@87
3008 double v16; // st7@87
3009 int v17; // eax@88
3010 double v18; // st7@88
3011 int v19; // eax@89
3012 double v20; // st7@89
3013 int v21; // eax@92
3014 double v22; // st7@92
3015 int v23; // eax@96
3016 double v24; // st7@96
3017 int v25; // eax@97
3018 double v26; // st7@97
3019 int v27; // eax@98
3020 double v28; // st7@98
3021 signed __int64 v29; // qax@98
3022 unsigned int v30; // eax@103
3023 int v31; // eax@130
3024 int v32; // ecx@141
3025 signed int v33; // eax@143
3026 int v34; // esi@143
3027 unsigned int v35; // esi@147
3028 int v36; // eax@155
3029 signed int v37; // esi@159
3030 signed int v38; // eax@159
3031 signed int i; // esi@159
3032 int v40; // esi@162
3033 Player **v41; // esi@172
3034 bool v42; // eax@180
3035 signed int v43; // ecx@184
3036 signed int v44; // edx@184
3037 int v45; // ecx@200
3038 BSPModel *v46; // eax@203
3039 ODMFace *v47; // esi@203
3040 int v48; // eax@203
3041 char v49; // zf@203
3042 char v50; // sf@203
3043 unsigned __int8 v51; // of@203
3044 int v52; // eax@203
3045 unsigned __int8 v53; // dl@205
3046 BSPModel *v54; // eax@215
3047 int v55; // eax@217
3048 signed int v56; // ebx@228
3049 int v57; // eax@228
3050 BSPModel *v58; // eax@228
3051 unsigned __int64 v59; // qax@228
3052 BSPModel *v60; // eax@228
3053 unsigned __int64 v61; // qax@228
3054 int v62; // eax@241
3055 signed int v63; // ST04_4@255
3056 signed int v64; // eax@255
3057 unsigned int v65; // ebx@263
3058 unsigned int v66; // esi@263
3059 int v67; // eax@263
3060 signed int v68; // ecx@263
3061 int v69; // eax@263
3062 int v70; // ebx@271
3063 int v71; // esi@271
3064 int v72; // edi@271
3065 int v73; // eax@271
3066 Player **v74; // esi@283
3067 int v75; // eax@284
3068 unsigned int v76; // edi@293
3069 bool v77; // edx@297
3070 bool v78; // ecx@303
3071 int v79; // ecx@314
3072 __int16 v80; // dx@317
3073 int v81; // ebx@318
3074 int v82; // ecx@318
3075 int v83; // eax@321
3076 Player **v84; // esi@333
3077 int v85; // eax@334
3078 int v86; // [sp-20h] [bp-B4h]@246
3079 int v87; // [sp-20h] [bp-B4h]@248
3080 signed int v88; // [sp-1Ch] [bp-B0h]@246
3081 unsigned int v89; // [sp-18h] [bp-ACh]@246
3082 signed int v90; // [sp-14h] [bp-A8h]@246
3083 signed int v91; // [sp-10h] [bp-A4h]@246
3084 int v92; // [sp-Ch] [bp-A0h]@246
3085 int v93; // [sp-8h] [bp-9Ch]@104
3086 unsigned int v94; // [sp-8h] [bp-9Ch]@246
3087 int v95; // [sp-4h] [bp-98h]@104
3088 int v96; // [sp-4h] [bp-98h]@246
3089 int v97; // [sp+Ch] [bp-88h]@180
3090 int v98; // [sp+10h] [bp-84h]@147
3091 int v99; // [sp+14h] [bp-80h]@147
3092 int v100; // [sp+18h] [bp-7Ch]@147
3093 bool v101; // [sp+1Ch] [bp-78h]@33
3094 int v102; // [sp+20h] [bp-74h]@1
3095 int v103; // [sp+24h] [bp-70h]@1
3096 int bFeatherFall; // [sp+28h] [bp-6Ch]@4
3097 int v105; // [sp+2Ch] [bp-68h]@24
3098 int bWaterWalk; // [sp+30h] [bp-64h]@1
3099 bool v107; // [sp+34h] [bp-60h]@30
3100 int v108; // [sp+38h] [bp-5Ch]@1
3101 int v109; // [sp+3Ch] [bp-58h]@28
3102 int v110; // [sp+40h] [bp-54h]@180
3103 int v111; // [sp+44h] [bp-50h]@14
3104 int bJumping; // [sp+48h] [bp-4Ch]@1
3105 int v113; // [sp+4Ch] [bp-48h]@1
3106 unsigned int v114; // [sp+50h] [bp-44h]@1
3107 int _walk_speed; // [sp+54h] [bp-40h]@48
3108 int v116; // [sp+58h] [bp-3Ch]@1
3109 int v117; // [sp+5Ch] [bp-38h]@1
3110 int v118; // [sp+60h] [bp-34h]@1
3111 Player **v119; // [sp+64h] [bp-30h]@4
3112 int _angle_x; // [sp+68h] [bp-2Ch]@48
3113 int v121; // [sp+6Ch] [bp-28h]@1
3114 unsigned int v122; // [sp+70h] [bp-24h]@180
3115 int v123; // [sp+74h] [bp-20h]@1
3116 int v124; // [sp+78h] [bp-1Ch]@1
3117 int _angle_y; // [sp+7Ch] [bp-18h]@48
3118 int v126; // [sp+80h] [bp-14h]@48
3119 BSPModel *v127; // [sp+84h] [bp-10h]@1
3120 int v128; // [sp+88h] [bp-Ch]@1
3121 int v129; // [sp+8Ch] [bp-8h]@92
3122 int v130; // [sp+90h] [bp-4h]@14
3123
3124 v121 = pParty->uFallSpeed;
3125 v123 = pParty->vPosition.z;
3126 _zero = 0;
3127 v1 = 0;
3128 v103 = 0;
3129 v2 = 0;
3130 *(float *)&v128 = 0.0;
3131 v116 = pParty->vPosition.x;
3132 v117 = pParty->vPosition.y;
3133 v113 = pParty->field_6F0;
3134 bJumping = 0;
3135 v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.y);
3136 v114 = 0;
3137 v124 = 0;
3138 v108 = 0;
3139 v102 = 0;
3140 v127 = 0;
3141 bWaterWalk = 0;
3142 if ( SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0
3143 || SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 )
3144 {
3145 bFeatherFall = 0;
3146 v119 = &pPlayers[1];
3147 while ( !(*v119)->WearsItem(536, 16) )
3148 {
3149 ++v119;
3150 if ( (signed int)v119 > (signed int)&pPlayers[4] )
3151 goto LABEL_9;
3152 }
3153 }
3154 bFeatherFall = 1;
3155 LABEL_9:
3156 if ( (signed __int64)pParty->pPartyBuffs[18].uExpireTime <= 0 )
3157 {
3158 LOBYTE(pParty->uFlags) &= 0x7Fu;
3159 }
3160 else
3161 {
3162 LOBYTE(pParty->uFlags) &= 0x7Fu;
3163 bWaterWalk = 1;
3164 *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
3165 if ( !(pParty->pPartyBuffs[18].uFlags & 1)
3166 && *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 )
3167 bWaterWalk = 0;
3168 }
3169 v3 = sub_46D49E_prolly_get_world_y_under_party(v116, v117, v123, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
3170 v111 = v3;
3171 if ( bFeatherFall )
3172 pParty->uFallStartY = v3;
3173 else
3174 v3 = pParty->uFallStartY;
3175 if ( v3 - v123 > 512 && !bFeatherFall && v123 <= v111 + 1 )
3176 {
3177 if ( BYTE1(pParty->uFlags) & 1 )
3178 {
3179 BYTE1(pParty->uFlags) &= 0xFEu;
3180 }
3181 else
3182 {
3183 v4 = &pPlayers[1]; // receive falling damage
3184 do
3185 {
3186 if ( !(*v4)->HasEnchantedItemEquipped(72) && !(*v4)->WearsItem(529, 8) )
3187 {
3188 v105 = (*v4)->GetMaxHealth();
3189 (*v4)->ReceiveDamage(
3190 (signed int)((pParty->uFallStartY - v123) * (unsigned __int64)(signed __int64)((double)v105 * 0.1)) / 256,
3191 4);
3192 v5 = (*v4)->GetActualEndurance();
3193 v105 = 20 - (*v4)->_48EA1B_get_static_effect(v5);
3194 (*v4)->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
3195 }
3196 ++v4;
3197 }
3198 while ( (signed int)v4 <= (signed int)&pPlayers[4] );
3199 _zero = 0;
3200 }
3201 }
3202 v109 = -1;
3203 if ( pParty->bFlying != _zero )
3204 v109 = sub_46D8E3(v116, v117, v123 + pParty->uPartyHeight, (int)&v102);
3205 v107 = v108 == _zero;
3206 v105 = v111 + 1;
3207 if ( v123 <= v111 + 1 )
3208 {
3209 v109 = -1;
3210 pParty->bFlying = _zero;
3211 }
3212 else
3213 {
3214 bJumping = 1;
3215 }
3216 v101 = v123 - v111 <= 32;
3217 if ( bWalkSound != _zero && pParty->field_6F8 > _zero )
3218 pParty->field_6F8 -= pEventTimer->uTimeElapsed;
3219 if ( !bUnderwater
3220 && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero
3221 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < _zero || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero) )
3222 pParty->bFlying = _zero;
3223 if ( bJumping == _zero )
3224 {
3225 if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) )
3226 {
3227 if ( v108 != _zero )
3228 {
3229 if ( v108 >> 6 < pOutdoor->uNumBModels )
3230 {
3231 v7 = (ODMFace *)&pOutdoor->pBModels[v108 >> 6].pFaces;
3232 v6 = v108 & 0x3F;
3233 if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 )
3234 {
3235 pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel;
3236 v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292);
3237 }
3238 }
3239 }
3240 }
3241 pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel;
3242 }
3243 _walk_speed = pParty->uWalkSpeed;
3244 _angle_y = pParty->sRotationY;
3245 _angle_x = pParty->sRotationX;
3246 v126 = pEventTimer->dt_in_some_format;
3247 v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format
3248 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed
3249 * stru_5C6E00->uIntegerPi)
3250 / 180)) >> 16);
3251 LABEL_118:
3252 while ( pPartyActionQueue->uNumActions )
3253 {
3254 switch ( pPartyActionQueue->Next() )
3255 {
3256 case PARTY_FlyUp:
3257 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 )
3258 {
3259 pParty->bFlying = 0;
3260 if ( bUnderwater
3261 || pParty->pPartyBuffs[7].uFlags & 1
3262 || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
3263 {
3264 if ( pParty->vPosition.z < 4000 || bJumping )
3265 {
3266 v123 += 30;
3267 v113 += 30;
3268 pParty->bFlying = 1;
3269 if ( v123 > 4000 )
3270 {
3271 v123 = 4000;
3272 v113 = 4000;
3273 }
3274 v1 = 0;
3275 v2 = 0;
3276 v121 = 0;
3277 *(float *)&v128 = 0.0;
3278 if ( v102 && v123 < v109 && (signed int)(pParty->uPartyHeight + v123) >= v109 )
3279 {
3280 pParty->field_6E0 = 0;
3281 pParty->field_6E4 = 0;
3282 pPartyActionQueue->uNumActions = 0;
3283 BYTE1(pParty->uFlags) |= 1u;
3284 pParty->vPosition.z = v109 - pParty->uPartyHeight - 31;
3285 pParty->field_6F0 = v123;
3286 pParty->bFlying = 0;
3287 v123 = v109 - pParty->uPartyHeight - 31;
3288 v113 = pParty->field_6F0;
3289 }
3290 pParty->uFallSpeed = 0;
3291 v127 = (BSPModel *)1;
3292 }
3293 }
3294 }
3295 goto LABEL_118;
3296 case PARTY_FlyDown:
3297 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 )
3298 {
3299 pParty->bFlying = 0;
3300 if ( bUnderwater
3301 || pParty->pPartyBuffs[7].uFlags & 1
3302 || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
3303 {
3304 v123 -= 30;
3305 v113 -= 30;
3306 pParty->uFallSpeed = 0;
3307 v121 = 0;
3308 pParty->bFlying = 1;
3309 v127 = (BSPModel *)1;
3310 if ( v123 <= v111 )
3311 {
3312 pParty->bFlying = 0;
3313 pPartyActionQueue->uNumActions = 0;
3314 }
3315 }
3316 }
3317 goto LABEL_118;
3318 case PARTY_TurnLeft:
3319 v8 = uTurnSpeed;
3320 if ( uTurnSpeed )
3321 goto LABEL_80;
3322 v9 = (double)(signed int)v119 * fTurnSpeedMultiplier;
3323 goto LABEL_73;
3324 case PARTY_TurnRight:
3325 LODWORD(v10) = uTurnSpeed;
3326 if ( uTurnSpeed )
3327 goto LABEL_77;
3328 v11 = (double)(signed int)v119 * fTurnSpeedMultiplier;
3329 goto LABEL_76;
3330 case PARTY_FastTurnLeft:
3331 v8 = uTurnSpeed;
3332 if ( uTurnSpeed )
3333 {
3334 LABEL_80:
3335 v12 = v8 + _angle_y;
3336 LABEL_78:
3337 _angle_y = stru_5C6E00->uDoublePiMask & v12;
3338 }
3339 else
3340 {
3341 v9 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)(signed int)v119;
3342 LABEL_73:
3343 _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9);
3344 }
3345 goto LABEL_118;
3346 case PARTY_FastTurnRight:
3347 LODWORD(v10) = uTurnSpeed;
3348 if ( !uTurnSpeed )
3349 {
3350 v11 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)(signed int)v119;
3351 LABEL_76:
3352 v10 = (signed __int64)v11;
3353 }
3354 LABEL_77:
3355 v12 = _angle_y - v10;
3356 goto LABEL_78;
3357 case PARTY_StrafeLeft:
3358 v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3359 v14 = (double)_walk_speed;
3360 v126 = v13;
3361 *(float *)&v128 = v14;
3362 v124 = (unsigned __int64)(v13 * (signed __int64)((signed int)(signed __int64)(v14 * fWalkSpeedMultiplier) >> 1)) >> 16;
3363 v2 -= v124;
3364 v126 = stru_5C6E00->SinCos(_angle_y);
3365 v124 = (unsigned __int64)(v126
3366 * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16;
3367 goto LABEL_85;
3368 case PARTY_StrafeRight:
3369 v15 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3370 v16 = (double)_walk_speed;
3371 v126 = v15;
3372 *(float *)&v128 = v16;
3373 v124 = (unsigned __int64)(v15 * (signed __int64)((signed int)(signed __int64)(v16 * fWalkSpeedMultiplier) >> 1)) >> 16;
3374 v2 += v124;
3375 v126 = stru_5C6E00->SinCos(_angle_y);
3376 v124 = (unsigned __int64)(v126
3377 * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16;
3378 goto LABEL_90;
3379 case PARTY_WalkForward:
3380 v17 = stru_5C6E00->SinCos(_angle_y);
3381 v18 = (double)_walk_speed;
3382 v126 = v17;
3383 *(float *)&v128 = v18;
3384 v124 = (unsigned __int64)(v17 * (signed __int64)(signed int)(signed __int64)(v18 * fWalkSpeedMultiplier)) >> 16;
3385 v2 += v124;
3386 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3387 v124 = (unsigned __int64)(v126
3388 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
3389 LABEL_85:
3390 v1 += v124;
3391 goto LABEL_86;
3392 case PARTY_WalkBackward:
3393 v19 = stru_5C6E00->SinCos(_angle_y);
3394 v20 = (double)_walk_speed;
3395 v126 = v19;
3396 *(float *)&v128 = v20;
3397 v124 = (unsigned __int64)(v19
3398 * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardWalkSpeedMultiplier)) >> 16;
3399 v2 -= v124;
3400 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3401 v124 = (unsigned __int64)(v126
3402 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
3403 * fBackwardWalkSpeedMultiplier)) >> 16;
3404 LABEL_90:
3405 v1 -= v124;
3406 goto LABEL_86;
3407 case PARTY_RunForward:
3408 if ( pParty->bFlying )
3409 {
3410 v21 = stru_5C6E00->SinCos(_angle_y);
3411 v22 = (double)_walk_speed;
3412 v126 = v21;
3413 *(float *)&v128 = v22;
3414 v129 = (unsigned __int64)(v21
3415 * (signed __int64)(signed int)(4
3416 * (unsigned __int64)(signed __int64)(v22
3417 * fWalkSpeedMultiplier))) >> 16;
3418 v2 += v129;
3419 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3420 v129 = (unsigned __int64)(v126
3421 * (signed __int64)(signed int)(4
3422 * (unsigned __int64)(signed __int64)(*(float *)&v128
3423 * fWalkSpeedMultiplier))) >> 16;
3424 v1 += v129;
3425 goto LABEL_93;
3426 }
3427 if ( v118 && !v108 )
3428 {
3429 v23 = stru_5C6E00->SinCos(_angle_y);
3430 v24 = (double)_walk_speed;
3431 v126 = v23;
3432 *(float *)&v128 = v24;
3433 v129 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
3434 v2 += v129;
3435 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3436 v129 = (unsigned __int64)(v126
3437 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
3438 v1 += v129;
3439 goto LABEL_86;
3440 }
3441 v25 = stru_5C6E00->SinCos(_angle_y);
3442 v26 = (double)_walk_speed;
3443 v114 = v25;
3444 *(float *)&v128 = v26;
3445 v129 = (unsigned __int64)(v25
3446 * (signed __int64)(signed int)(2
3447 * (unsigned __int64)(signed __int64)(v26
3448 * fWalkSpeedMultiplier))) >> 16;
3449 v2 += v129;
3450 v114 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3451 v129 = (unsigned __int64)((signed int)v114
3452 * (signed __int64)(signed int)(2
3453 * (unsigned __int64)(signed __int64)(*(float *)&v128
3454 * fWalkSpeedMultiplier))) >> 16;
3455 v1 += v129;
3456 v114 = 1;
3457 v128 = v1;
3458 break;
3459 case PARTY_RunBackward:
3460 v27 = stru_5C6E00->SinCos(_angle_y);
3461 v28 = (double)_walk_speed;
3462 v126 = v27;
3463 *(float *)&v128 = v28;
3464 v29 = (signed __int64)(v28 * fBackwardWalkSpeedMultiplier);
3465 if ( pParty->bFlying )
3466 {
3467 v129 = (unsigned __int64)(v126 * (signed __int64)(4 * (signed int)v29)) >> 16;
3468 v2 -= v129;
3469 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3470 v129 = (unsigned __int64)(v126
3471 * (signed __int64)(signed int)(4
3472 * (unsigned __int64)(signed __int64)(*(float *)&v128
3473 * fBackwardWalkSpeedMultiplier))) >> 16;
3474 v1 -= v129;
3475 LABEL_93:
3476 v128 = v1;
3477 }
3478 else
3479 {
3480 v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)v29) >> 16;
3481 v2 -= v129;
3482 v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
3483 v129 = (unsigned __int64)(v126
3484 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
3485 * fBackwardWalkSpeedMultiplier)) >> 16;
3486 v1 -= v129;
3487 LABEL_86:
3488 v128 = v1;
3489 v124 = 1;
3490 }
3491 break;
3492 case PARTY_LookUp:
3493 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
3494 if ( _angle_x > 128 )
3495 _angle_x = 128;
3496 v30 = uActiveCharacter;
3497 if ( !uActiveCharacter )
3498 goto LABEL_118;
3499 v95 = 0;
3500 v93 = 63;
3501 goto _play_player_sound;
3502 case PARTY_LookDown:
3503 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
3504 if ( _angle_x < -128 )
3505 _angle_x = -128;
3506 v30 = uActiveCharacter;
3507 if ( uActiveCharacter )
3508 {
3509 v95 = 0;
3510 v93 = 64;
3511 _play_player_sound:
3512 pPlayers[v30]->PlaySound(v93, v95);
3513 }
3514 goto LABEL_118;
3515 case PARTY_CenterView:
3516 _angle_x = 0;
3517 goto LABEL_118;
3518 case PARTY_Jump:
3519 if ( (!v118 || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
3520 {
3521 v126 = pParty->field_24 << 6;
3522 bJumping = 1;
3523 v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121);
3524 }
3525 goto LABEL_118;
3526 default:
3527 goto LABEL_118;
3528 case PARTY_Land:
3529 if ( pParty->bFlying )
3530 {
3531 BYTE1(pParty->uFlags) |= 1u;
3532 pParty->uFallSpeed = 0;
3533 }
3534 pParty->bFlying = 0;
3535 pPartyActionQueue->uNumActions = 0;
3536 goto LABEL_123;
3537 }
3538 }
3539 LABEL_123:
3540 pParty->sRotationY = _angle_y;
3541 pParty->sRotationX = _angle_x;
3542 if ( v123 < v111 )
3543 {
3544 if ( pParty->bFlying )
3545 {
3546 LABEL_130:
3547 v31 = GetTickCount();
3548 v126 = stru_5C6E00->SinCos(v31);
3549 v129 = (unsigned __int64)(4i64 * v126) >> 16;
3550 v123 = v113 + v129;
3551 if ( v127 )
3552 v123 = v113;
3553 if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0
3554 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) )
3555 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu;
3556 pParty->uFallStartY = v123;
3557 goto LABEL_141;
3558 }
3559 if ( v130 && v121 )
3560 sub_42F960_create_object(v116, v117, v111);
3561 v121 = 0;
3562 v123 = v111;
3563 pParty->uFallStartY = v111;
3564 }
3565 if ( pParty->bFlying )
3566 goto LABEL_130;
3567 v113 = v123;
3568 if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0
3569 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) )
3570 stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
3571 LABEL_141:
3572 v32 = 0;
3573 if ( bJumping && !pParty->bFlying )
3574 {
3575 v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
3576 v34 = v121 + 2 * v33;
3577 v121 += 2 * v33;
3578 goto LABEL_149;
3579 }
3580 if ( !v118 )
3581 {
3582 v34 = v121;
3583 LABEL_149:
3584 if ( bJumping == v32 )
3585 goto LABEL_150;
3586 goto LABEL_164;
3587 }
3588 if ( !bJumping )
3589 {
3590 if ( v108 )
3591 goto LABEL_150;
3592 v123 = v111;
3593 _46DCC8_get_gravity_direction_outdoor(v116, v117, (Vec3_int_ *)&v98);
3594 v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
3595 v129 = abs((signed __int64)v2 * (signed __int64)v98 + (signed __int64)v1 * (signed __int64)v99 + (signed __int64)v35 * (signed __int64)v100) >> 16;
3596 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98) >> 16);
3597 v2 += (int)v127;
3598 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v99) >> 16);
3599 v1 += (int)v127;
3600 v128 = v1;
3601 v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v100) >> 16);
3602 v34 = (int)((char *)v127 + v35);
3603 v32 = 0;
3604 v121 = v34;
3605 goto LABEL_149;
3606 }
3607 v34 = v121;
3608 LABEL_164:
3609 if ( !bUnderwater && v34 <= v32 )
3610 {
3611 if ( v34 < -500
3612 && !pParty->bFlying
3613 && pParty->vPosition.z - v111 > 1000
3614 && SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0
3615 && (SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 || !LODWORD(pParty->pPartyBuffs[5].uExpireTime)) )
3616 {
3617 v41 = &pPlayers[1];
3618 do
3619 {
3620 if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) && (*v41)->CanAct() )
3621 (*v41)->PlaySound(66, 0);
3622 ++v41;
3623 }
3624 while ( (signed int)v41 <= (signed int)&pPlayers[4] );
3625 }
3626 goto LABEL_151;
3627 }
3628 LABEL_150:
3629 pParty->uFallStartY = v123;
3630 LABEL_151:
3631 if ( v2 * v2 + v1 * v1 < 400 && !v118 )
3632 {
3633 *(float *)&v128 = 0.0;
3634 v2 = 0;
3635 }
3636 stru_721530.field_84 = -1;
3637 stru_721530.field_70 = 0;
3638 stru_721530.prolly_normal_d = pParty->field_14;
3639 stru_721530.field_8 = pParty->field_14 >> 1;
3640 v126 = 0;
3641 stru_721530.field_0 = 1;
3642 stru_721530.field_C = pParty->uPartyHeight - 32;
3643 do
3644 {
3645 stru_721530.field_34.x = v116;
3646 stru_721530.normal.x = v116;
3647 stru_721530.field_1C = v2;
3648 stru_721530.field_34.y = v117;
3649 stru_721530.normal.y = v117;
3650 stru_721530.normal.z = stru_721530.prolly_normal_d + v123 + 1;
3651 stru_721530.field_34.z = stru_721530.field_C + v123 + 1;
3652 stru_721530.field_20 = v128;
3653 stru_721530.field_24 = v121;
3654 v36 = 0;
3655 stru_721530.uSectorID = 0;
3656 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
3657 v36 = 13312;
3658 if ( stru_721530._47050A(v36) )
3659 break;
3660 _46E889_collide_against_bmodels(1u);
3661 v37 = WorldPosToGridCellZ(pParty->vPosition.y);
3662 v38 = WorldPosToGridCellX(pParty->vPosition.x);
3663 _46E26D_collide_against_sprites(v38, v37);
3664 _46ED8A_collide_against_layingItems(4u);
3665 for ( i = 0; i < (signed int)uNumActors; ++i )
3666 _46DF1A_collide_against_actor(i, 0);
3667 if ( stru_721530.field_7C >= stru_721530.field_6C )
3668 {
3669 _angle_x = stru_721530.normal2.x;
3670 _angle_y = stru_721530.normal2.y;
3671 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
3672 }
3673 else
3674 {
3675 _angle_x = v116 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
3676 _angle_y = v117 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
3677 v127 = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
3678 v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + v123;
3679 }
3680 v122 = v40;
3681 sub_46D49E_prolly_get_world_y_under_party(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
3682 v129 = sub_46D49E_prolly_get_world_y_under_party(_angle_x, v117, v40, pParty->uPartyHeight, &v130, &v97, 0);
3683 v119 = (Player **)sub_46D49E_prolly_get_world_y_under_party(
3684 v116,
3685 _angle_y,
3686 v40,
3687 pParty->uPartyHeight,
3688 &v130,
3689 &v110,
3690 0);
3691 v127 = (BSPModel *)GetTerrainHeightsAroundParty(_angle_x, v117);
3692 v42 = GetTerrainHeightsAroundParty(v116, _angle_y);
3693 v107 = 0;
3694 v118 = v42;
3695 if ( !v97 && !v110 && !v108 )
3696 v107 = 1;
3697 v43 = 1;
3698 v44 = 1;
3699 if ( bUnderwater || !v107 )
3700 goto LABEL_197;
3701 if ( v127 && v129 > v123 )
3702 v44 = 0;
3703 if ( v118 && (signed int)v119 > v123 )
3704 v43 = 0;
3705 if ( v44 )
3706 goto LABEL_197;
3707 if ( v43 )
3708 goto LABEL_198;
3709 v127 = (BSPModel *)sub_46D49E_prolly_get_world_y_under_party(
3710 _angle_x,
3711 _angle_y,
3712 v40,
3713 pParty->uPartyHeight,
3714 &v130,
3715 &v108,
3716 0);
3717 if ( GetTerrainHeightsAroundParty(_angle_x, _angle_y) && (signed int)v127 <= v123 )
3718 {
3719 v43 = 1;
3720 LABEL_197:
3721 v116 = _angle_x;
3722 if ( !v43 )
3723 goto LABEL_199;
3724 LABEL_198:
3725 v117 = _angle_y;
3726 }
3727 LABEL_199:
3728 if ( stru_721530.field_7C >= stru_721530.field_6C )
3729 {
3730 if ( !v107 )
3731 {
3732 v116 = stru_721530.normal2.x;
3733 v117 = stru_721530.normal2.y;
3734 }
3735 v123 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
3736 break;
3737 }
3738 stru_721530.field_70 += stru_721530.field_7C;
3739 v116 = _angle_x;
3740 v117 = _angle_y;
3741 v45 = stru_721530.uFaceID;
3742 v123 = v40;
3743 if ( (stru_721530.uFaceID & 7) == 3 )
3744 {
3745 if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
3746 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) )
3747 pParty->pPartyBuffs[11].Reset();
3748 viewparams->bRedrawGameUI = 1;
3749 goto LABEL_234;
3750 }
3751 if ( (stru_721530.uFaceID & 7) == 5 )
3752 {
3753 v56 = sub_452A9E(v2 * v2 + v128 * v128);
3754 v118 = v56;
3755 v57 = stru_5C6E00->Atan2(
3756 _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
3757 _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
3758 v129 = v57;
3759 v58 = (BSPModel *)stru_5C6E00->SinCos(v57);
3760 v127 = v58;
3761 v59 = (signed int)v58 * (signed __int64)v56;
3762 v122 = v59 >> 16;
3763 v2 = v59 >> 16;
3764 v60 = (BSPModel *)stru_5C6E00->SinCos(v129 - stru_5C6E00->uIntegerHalfPi);
3765 v127 = v60;
3766 v61 = (signed int)v60 * (signed __int64)v118;
3767 v122 = v61 >> 16;
3768 v128 = v61 >> 16;
3769 }
3770 else
3771 {
3772 if ( (stru_721530.uFaceID & 7) == 6 )
3773 {
3774 pParty->bFlying = 0;
3775 v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
3776 v127 = v46;
3777 v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
3778 v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1;
3779 v51 = __OFSUB__(v48, 32);
3780 v49 = v48 == 32;
3781 v50 = v48 - 32 < 0;
3782 v52 = v47->pFacePlane.vNormal.z;
3783 v129 = (unsigned __int8)(v50 ^ v51 | v49);
3784 v119 = (Player **)(v52 < 46378);
3785 if ( bUnderwater == 1 )
3786 v119 = 0;
3787 v53 = v47->uPolygonType;
3788 if ( v53 == 3 )
3789 {
3790 if ( v121 < 0 )
3791 v121 = 0;
3792 v123 = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
3793 if ( v2 * v2 + v128 * v128 < 400 )
3794 {
3795 v2 = 0;
3796 *(float *)&v128 = 0.0;
3797 }
3798 goto LABEL_221;
3799 }
3800 if ( !v129 && (v53 != 4 || v119) )
3801 {
3802 v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
3803 if ( stru_721530.field_64 >> 3 > v118 )
3804 v118 = stru_721530.field_64 >> 3;
3805 v129 = v47->pFacePlane.vNormal.x;
3806 v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
3807 _walk_speed = v47->pFacePlane.vNormal.y;
3808 _walk_speed = (unsigned __int64)(v118 * (signed __int64)_walk_speed) >> 16;
3809 v54 = 0;
3810 if ( !v119 )
3811 {
3812 v127 = (BSPModel *)v47->pFacePlane.vNormal.z;
3813 v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
3814 v54 = v127;
3815 }
3816 v121 += (int)v54;
3817 v128 += _walk_speed;
3818 v2 += v129;
3819 v55 = stru_721530.prolly_normal_d
3820 - ((signed int)(v47->pFacePlane.dist
3821 + v122 * v47->pFacePlane.vNormal.z
3822 + _angle_y * v47->pFacePlane.vNormal.y
3823 + _angle_x * v47->pFacePlane.vNormal.x) >> 16);
3824 if ( v55 > 0 )
3825 {
3826 v116 = _angle_x + (v47->pFacePlane.vNormal.x * v55 >> 16);
3827 v117 = _angle_y + (v47->pFacePlane.vNormal.y * v55 >> 16);
3828 if ( !v119 )
3829 v123 = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
3830 }
3831 LABEL_220:
3832 v45 = stru_721530.uFaceID;
3833 LABEL_221:
3834 if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uAttributes) & 4 )
3835 {
3836 pParty->field_6F4_packedid = v45;
3837 v103 = v47->sCogTriggeredID;
3838 }
3839 goto LABEL_234;
3840 }
3841 v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
3842 if ( stru_721530.field_64 >> 3 > v118 )
3843 v118 = stru_721530.field_64 >> 3;
3844 v122 = v47->pFacePlane.vNormal.x;
3845 v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
3846 v127 = (BSPModel *)v47->pFacePlane.vNormal.y;
3847 v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
3848 v129 = v47->pFacePlane.vNormal.z;
3849 v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
3850 v121 += v129;
3851 v2 += v122;
3852 v128 += (int)v127;
3853 if ( v2 * v2 + v128 * v128 >= 400 )
3854 goto LABEL_220;
3855 v2 = 0;
3856 v121 = 0;
3857 *(float *)&v128 = 0.0;
3858 }
3859 }
3860 LABEL_234:
3861 v2 = (unsigned __int64)(58500i64 * v2) >> 16;
3862 v127 = (BSPModel *)58500;
3863 v128 = (unsigned __int64)(58500i64 * v128) >> 16;
3864 v122 = (unsigned __int64)(58500i64 * v121) >> 16;
3865 ++v126;
3866 v121 = (unsigned __int64)(58500i64 * v121) >> 16;
3867 }
3868 while ( v126 < 100 );
3869 if ( bWalkSound && pParty->field_6F8 <= 0 )
3870 {
3871 v122 = abs(pParty->vPosition.x - v116);
3872 v126 = abs(pParty->vPosition.y - v117);
3873 v62 = abs(pParty->vPosition.z - v123);
3874 if ( sub_452A9E(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
3875 goto LABEL_344;
3876 if ( v114 && (!bJumping || v101) )
3877 {
3878 if ( !v107
3879 && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20) )
3880 {
3881 v96 = 0;
3882 v94 = 0;
3883 v92 = 0;
3884 v91 = 0;
3885 v90 = -1;
3886 v89 = 1;
3887 v88 = 804;
3888 v87 = 64;
3889 goto LABEL_257;
3890 }
3891 v96 = 0;
3892 v94 = 0;
3893 v92 = 0;
3894 v91 = 0;
3895 v90 = -1;
3896 v89 = 1;
3897 v88 = 804;
3898 v86 = 1;
3899 LABEL_255:
3900 v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
3901 v64 = WorldPosToGridCellX(pParty->vPosition.x);
3902 v87 = pOutdoor->_47EE49(v64, v63, v86);
3903 goto LABEL_257;
3904 }
3905 if ( v124 && (!bJumping || v101) )
3906 {
3907 if ( v107
3908 || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20 )
3909 {
3910 v96 = 0;
3911 v94 = 0;
3912 v92 = 0;
3913 v91 = 0;
3914 v90 = -1;
3915 v89 = 1;
3916 v88 = 804;
3917 v86 = 0;
3918 goto LABEL_255;
3919 }
3920 v96 = 0;
3921 v94 = 0;
3922 v92 = 0;
3923 v91 = 0;
3924 v90 = -1;
3925 v89 = 1;
3926 v88 = 804;
3927 v87 = 103;
3928 LABEL_257:
3929 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, v91, v92, v94, v96);
3930 }
3931 else
3932 {
3933 LABEL_344:
3934 pAudioPlayer->_4AA258(804);
3935 pParty->field_6F8 = 64;
3936 }
3937 }
3938 if ( !bJumping || v101 )
3939 pParty->uFlags &= 0xFFFFFFF7u;
3940 else
3941 pParty->uFlags |= 8u;
3942 v126 = WorldPosToGridCellX(pParty->vPosition.x);
3943 v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
3944 v114 = WorldPosToGridCellX(v116);
3945 v66 = WorldPosToGridCellZ(v117) - 1;
3946 v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
3947 v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
3948 v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
3949 v68 = 0;
3950 v69 = ((unsigned int)~v67 >> 1) & 1;
3951 if ( v114 == v126 && v66 == v65 && v122 && v69 )
3952 v68 = 1;
3953 if ( !v107 )
3954 v68 = 1;
3955 if ( v68 )
3956 {
3957 v70 = v123;
3958 v71 = v116;
3959 v72 = v117;
3960 pParty->uFallSpeed = v121;
3961 v73 = v123;
3962 pParty->vPosition.x = v116;
3963 pParty->vPosition.y = v117;
3964 pParty->vPosition.z = v123;
3965 pParty->field_6F0 = v113;
3966 if ( v123 > 8160 )
3967 {
3968 v73 = 8160;
3969 pParty->uFallStartY = 8160;
3970 pParty->vPosition.z = 8160;
3971 }
3972 if ( !v103
3973 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
3974 && pParty->vPosition.y == v72
3975 && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
3976 {
3977 if ( v73 < v111 )
3978 {
3979 pParty->uFallSpeed = 0;
3980 v73 = v105;
3981 pParty->vPosition.z = v105;
3982 if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
3983 {
3984 if ( pParty->uFlags & 0x100 )
3985 {
3986 BYTE1(pParty->uFlags) &= 0xFEu;
3987 }
3988 else
3989 {
3990 v74 = &pPlayers[1];
3991 do
3992 {
3993 v110 = (*v74)->GetMaxHealth();
3994 (*v74)->ReceiveDamage(
3995 (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
3996 4);
3997 v75 = (*v74)->GetActualEndurance();
3998 v110 = 20 - (*v74)->_48EA1B_get_static_effect(v75);
3999 (*v74)->SetRecoveryTime(
4000 (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
4001 ++v74;
4002 }
4003 while ( (signed int)v74 <= (signed int)&pPlayers[4] );
4004 v73 = pParty->vPosition.z;
4005 }
4006 }
4007 pParty->uFallStartY = v70;
4008 }
4009 if ( v102 && v73 < v109 )
4010 {
4011 if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
4012 {
4013 pParty->vPosition.z = v109 - pParty->uPartyHeight - 1;
4014 pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
4015 }
4016 }
4017 LOWORD(pParty->uFlags) &= 0xFDFBu;
4018 }
4019 return;
4020 }
4021 v76 = pParty->bFlying;
4022 if ( pParty->bFlying || v101 == 0 || bWaterWalk || !v127 )
4023 v77 = 1;
4024 else
4025 v77 = v122 != 0;
4026 v114 = 0;
4027 if ( !pParty->bFlying && v101 != 0 && !bWaterWalk )
4028 {
4029 if ( v127 )
4030 {
4031 v78 = v69 != 0;
4032 goto LABEL_306;
4033 }
4034 v114 = 1;
4035 }
4036 v78 = 1;
4037 LABEL_306:
4038 if ( v77 )
4039 {
4040 pParty->vPosition.x = v116;
4041 if ( !v78 )
4042 goto LABEL_313;
4043 goto LABEL_312;
4044 }
4045 if ( v78 )
4046 {
4047 LABEL_312:
4048 pParty->vPosition.y = v117;
4049 LABEL_313:
4050 if ( bWaterWalk )
4051 {
4052 LOBYTE(pParty->uFlags) &= 0x7Fu;
4053 v79 = 20 * pParty->pPartyBuffs[18].uOverlayID + 6180178;
4054 *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u;
4055 if ( !v122 || !v69 )
4056 {
4057 if ( !v76 )
4058 {
4059 v80 = *(short *)v79;
4060 LOBYTE(pParty->uFlags) |= 0x80u;
4061 *(short *)v79 = v80 & 0xFFFE;
4062 }
4063 }
4064 }
4065 goto LABEL_318;
4066 }
4067 if ( bWalkSound && pParty->field_6F8 <= 0 )
4068 {
4069 pAudioPlayer->_4AA258(804);
4070 pParty->field_6F8 = 64;
4071 }
4072 LABEL_318:
4073 v81 = v123;
4074 v82 = v123;
4075 pParty->vPosition.z = v123;
4076 if ( v123 > 8160 )
4077 {
4078 v82 = 8160;
4079 pParty->uFallStartY = 8160;
4080 pParty->vPosition.z = 8160;
4081 }
4082 LOWORD(pParty->uFlags) &= 0xFDFBu;
4083 pParty->uFallSpeed = v121;
4084 pParty->field_6F0 = v113;
4085 if ( v114 )
4086 {
4087 v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
4088 v82 = pParty->vPosition.z;
4089 if ( pParty->vPosition.z <= v83 )
4090 pParty->uFlags |= 4u;
4091 }
4092 if ( !v103
4093 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v116)
4094 && pParty->vPosition.y == v117
4095 && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) )
4096 {
4097 if ( v82 < v111 )
4098 {
4099 v82 = v105;
4100 pParty->uFallSpeed = 0;
4101 pParty->vPosition.z = v105;
4102 if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
4103 {
4104 if ( pParty->uFlags & 0x100 )
4105 {
4106 BYTE1(pParty->uFlags) &= 0xFEu;
4107 }
4108 else
4109 {
4110 v84 = &pPlayers[1];
4111 do
4112 {
4113 v110 = (*v84)->GetMaxHealth();
4114 (*v84)->ReceiveDamage(
4115 (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
4116 4);
4117 v85 = (*v84)->GetActualEndurance();
4118 v110 = 20 - (*v84)->_48EA1B_get_static_effect(v85);
4119 (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
4120 ++v84;
4121 }
4122 while ( (signed int)v84 <= (signed int)&pPlayers[4] );
4123 v82 = pParty->vPosition.z;
4124 }
4125 }
4126 pParty->uFallStartY = v81;
4127 }
4128 if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
4129 {
4130 pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1;
4131 pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
4132 }
4133 }
4134 }
4135
4136
4137
4138
4139
4140 //----- (0047531C) --------------------------------------------------------
4141 bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10)
4142 {
4143 BLVFace *v10; // ebx@1
4144 int v11; // ST1C_4@3
4145 int v12; // edi@3
4146 int v13; // esi@3
4147 int v14; // edi@4
4148 signed __int64 v15; // qtt@6
4149 __int16 v16; // si@7
4150 int *v18; // [sp+Ch] [bp-Ch]@1
4151 int v19; // [sp+10h] [bp-8h]@1
4152 int a7a; // [sp+30h] [bp+18h]@7
4153 int a9b; // [sp+38h] [bp+20h]@3
4154 int a9a; // [sp+38h] [bp+20h]@3
4155 int a10b; // [sp+3Ch] [bp+24h]@3
4156 signed int a10a; // [sp+3Ch] [bp+24h]@4
4157 int a10c; // [sp+3Ch] [bp+24h]@5
4158
4159 v10 = a9;
4160 v18 = a2;
4161 v19 = a1;
4162 if ( a10 && BYTE3(a9->uAttributes) & 0x20 )
4163 return 0;
4164 v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
4165 a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
4166 a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
4167 v12 = v11 + a9b + a10b;
4168 a9a = v11 + a9b + a10b;
4169 v13 = (a1 << 16)
4170 - a3 * v10->pFacePlane_old.vNormal.x
4171 - a4 * v10->pFacePlane_old.vNormal.y
4172 - a5 * v10->pFacePlane_old.vNormal.z
4173 - v10->pFacePlane_old.dist;
4174 if ( abs((a1 << 16)
4175 - a3 * v10->pFacePlane_old.vNormal.x
4176 - a4 * v10->pFacePlane_old.vNormal.y
4177 - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 )
4178 {
4179 a10c = abs(v13) >> 14;
4180 if ( a10c > abs(v12) )
4181 return 0;
4182 LODWORD(v15) = v13 << 16;
4183 HIDWORD(v15) = v13 >> 16;
4184 v14 = v19;
4185 a10a = v15 / a9a;
4186 }
4187 else
4188 {
4189 a10a = 0;
4190 v14 = abs(v13) >> 16;
4191 }
4192 v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16);
4193 LOWORD(a7a) = (short)a3
4194 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16)
4195 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16);
4196 HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16);
4197 if ( !sub_475665(
4198 v10,
4199 a7a,
4200 (short)a5
4201 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16)
4202 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) )
4203 return 0;
4204 *v18 = a10a >> 16;
4205 if ( a10a >> 16 < 0 )
4206 *v18 = 0;
4207 return 1;
4208 }
4209
4210 //----- (004754BF) --------------------------------------------------------
4211 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)
4212 {
4213 BLVFace *v11; // ebx@1
4214 int v12; // ST1C_4@3
4215 int v13; // edi@3
4216 int v14; // esi@3
4217 int v15; // edi@4
4218 signed __int64 v16; // qtt@6
4219 __int16 v17; // si@7
4220 int *v19; // [sp+Ch] [bp-Ch]@1
4221 int v20; // [sp+10h] [bp-8h]@1
4222 int a7a; // [sp+30h] [bp+18h]@7
4223 int a1b; // [sp+38h] [bp+20h]@3
4224 int a1a; // [sp+38h] [bp+20h]@3
4225 int a11b; // [sp+40h] [bp+28h]@3
4226 signed int a11a; // [sp+40h] [bp+28h]@4
4227 int a11c; // [sp+40h] [bp+28h]@5
4228
4229 v11 = a9;
4230 v19 = a2;
4231 v20 = a1;
4232 if ( a11 && BYTE3(a9->uAttributes) & 0x20 )
4233 return 0;
4234 v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
4235 a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
4236 a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
4237 v13 = v12 + a1b + a11b;
4238 a1a = v12 + a1b + a11b;
4239 v14 = (a1 << 16)
4240 - a3 * v11->pFacePlane_old.vNormal.x
4241 - a4 * v11->pFacePlane_old.vNormal.y
4242 - a5 * v11->pFacePlane_old.vNormal.z
4243 - v11->pFacePlane_old.dist;
4244 if ( abs((a1 << 16)
4245 - a3 * v11->pFacePlane_old.vNormal.x
4246 - a4 * v11->pFacePlane_old.vNormal.y
4247 - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 )
4248 {
4249 a11c = abs(v14) >> 14;
4250 if ( a11c > abs(v13) )
4251 return 0;
4252 LODWORD(v16) = v14 << 16;
4253 HIDWORD(v16) = v14 >> 16;
4254 v15 = v20;
4255 a11a = v16 / a1a;
4256 }
4257 else
4258 {
4259 a11a = 0;
4260 v15 = abs(v14) >> 16;
4261 }
4262 v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16);
4263 LOWORD(a7a) = (short)a3
4264 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16)
4265 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16);
4266 HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16);
4267 if ( !sub_4759C9(
4268 v11,
4269 a10,
4270 a7a,
4271 (short)a5
4272 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16)
4273 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) )
4274 return 0;
4275 *v19 = a11a >> 16;
4276 if ( a11a >> 16 < 0 )
4277 *v19 = 0;
4278 return 1;
4279 }
4280
4281
4282
4283 //----- (00475665) --------------------------------------------------------
4284 signed int __thiscall sub_475665(BLVFace *_this, int a2, __int16 a3)
4285 {
4286 unsigned int v3; // eax@1
4287 Vec3_short_ *v4; // edx@3
4288 signed int v5; // eax@4
4289 int v6; // esi@4
4290 signed int v7; // eax@7
4291 Vec3_short_ *v8; // edx@8
4292 signed int v9; // eax@9
4293 int v10; // esi@9
4294 signed int v11; // eax@11
4295 Vec3_short_ *v12; // edx@12
4296 signed int v13; // eax@13
4297 int v14; // esi@13
4298 int v15; // esi@14
4299 bool v16; // edi@14
4300 int v17; // ecx@16
4301 signed int v18; // edx@16
4302 int v19; // eax@17
4303 signed int v20; // ebx@18
4304 int v21; // edi@20
4305 signed int v22; // ST14_4@22
4306 signed __int64 v23; // qtt@22
4307 signed int result; // eax@25
4308 int v25; // [sp+14h] [bp-10h]@14
4309 int v26; // [sp+1Ch] [bp-8h]@2
4310 signed int v27; // [sp+20h] [bp-4h]@2
4311 signed int v28; // [sp+30h] [bp+Ch]@2
4312 signed int v29; // [sp+30h] [bp+Ch]@7
4313 signed int v30; // [sp+30h] [bp+Ch]@11
4314 signed int v31; // [sp+30h] [bp+Ch]@14
4315
4316 v3 = _this->uAttributes;
4317 if ( BYTE1(v3) & 1 )
4318 {
4319 v28 = 0;
4320 v26 = (signed __int16)a2;
4321 v27 = SHIWORD(a2);
4322 if ( _this->uNumVertices )
4323 {
4324 v4 = pIndoor->pVertices;
4325 do
4326 {
4327 v5 = v28;
4328 v6 = 2 * v28;
4329 word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x;
4330 word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y;
4331 word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1]
4332 + v4[_this->pVertexIDs[v5 + 1]].x;
4333 word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y;
4334 }
4335 while ( v28 < _this->uNumVertices );
4336 }
4337 }
4338 else
4339 {
4340 if ( BYTE1(v3) & 2 )
4341 {
4342 v26 = (signed __int16)a2;
4343 v7 = a3;
4344 v29 = 0;
4345 v27 = v7;
4346 if ( _this->uNumVertices )
4347 {
4348 v8 = pIndoor->pVertices;
4349 do
4350 {
4351 v9 = v29;
4352 v10 = 2 * v29;
4353 word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x;
4354 word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z;
4355 word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x;
4356 word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z;
4357 }
4358 while ( v29 < _this->uNumVertices );
4359 }
4360 }
4361 else
4362 {
4363 v26 = SHIWORD(a2);
4364 v11 = a3;
4365 v30 = 0;
4366 v27 = v11;
4367 if ( _this->uNumVertices )
4368 {
4369 v12 = pIndoor->pVertices;
4370 do
4371 {
4372 v13 = v30;
4373 v14 = 2 * v30;
4374 word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y;
4375 word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z;
4376 word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y;
4377 word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z;
4378 }
4379 while ( v30 < _this->uNumVertices );
4380 }
4381 }
4382 }
4383 v15 = 2 * _this->uNumVertices;
4384 v31 = 0;
4385 word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0];
4386 word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0];
4387 v25 = 0;
4388 v16 = word_720B40_intercepts_zs[0] >= v27;
4389 if ( v15 <= 0 )
4390 goto LABEL_29;
4391 do
4392 {
4393 if ( v31 >= 2 )
4394 break;
4395 v17 = v25;
4396 v18 = word_720B40_intercepts_zs[v25 + 1];
4397 if ( v16 ^ v18 >= v27 )
4398 {
4399 v19 = word_720C10_intercepts_xs[v17 + 1];
4400 if ( v19 >= v26 )
4401 v20 = 0;
4402 else
4403 v20 = 2;
4404 v21 = v20 | word_720C10_intercepts_xs[v17] < v26;
4405 if ( v21 != 3 )
4406 {
4407 if ( !v21
4408 || (v22 = v19 - word_720C10_intercepts_xs[v17],
4409 LODWORD(v23) = v22 << 16,
4410 HIDWORD(v23) = v22 >> 16,
4411 word_720C10_intercepts_xs[v17]
4412 + ((signed int)(((unsigned __int64)(v23
4413 / (v18 - word_720B40_intercepts_zs[v17])
4414 * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16)
4415 + 32768) >> 16) >= v26) )
4416 ++v31;
4417 }
4418 }
4419 ++v25;
4420 v16 = v18 >= v27;
4421 }
4422 while ( v25 < v15 );
4423 result = 1;
4424 if ( v31 != 1 )
4425 LABEL_29:
4426 result = 0;
4427 return result;
4428 }
4429
4430 //----- (004759C9) --------------------------------------------------------
4431 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
4432 {
4433 unsigned int v4; // eax@1
4434 int v5; // edx@4
4435 __int16 v6; // si@4
4436 int v7; // edx@9
4437 __int16 v8; // si@9
4438 int v9; // edx@13
4439 __int16 v10; // si@13
4440 int v11; // esi@14
4441 bool v12; // edi@14
4442 int v13; // ecx@16
4443 signed int v14; // edx@16
4444 int v15; // eax@17
4445 signed int v16; // ebx@18
4446 int v17; // edi@20
4447 signed int v18; // ST14_4@22
4448 signed __int64 v19; // qtt@22
4449 bool result; // eax@25
4450 int v21; // [sp+14h] [bp-10h]@14
4451 signed int v22; // [sp+18h] [bp-Ch]@1
4452 int v23; // [sp+1Ch] [bp-8h]@2
4453 signed int v24; // [sp+20h] [bp-4h]@2
4454 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
4455 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
4456 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
4457 signed int a4d; // [sp+30h] [bp+Ch]@14
4458
4459 v4 = a1->uAttributes;
4460 v22 = 0;
4461 if ( BYTE1(v4) & 1 )
4462 {
4463 v23 = (signed __int16)a3;
4464 v24 = SHIWORD(a3);
4465 if ( a1->uNumVertices )
4466 {
4467 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
4468 do
4469 {
4470 v5 = 2 * v22;
4471 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x);
4472 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y);
4473 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x);
4474 word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
4475 ++v22;
4476 }
4477 while ( v22 < a1->uNumVertices );
4478 }
4479 }
4480 else
4481 {
4482 if ( BYTE1(v4) & 2 )
4483 {
4484 v23 = (signed __int16)a3;
4485 v24 = a4;
4486 if ( a1->uNumVertices )
4487 {
4488 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
4489 do
4490 {
4491 v7 = 2 * v22;
4492 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x);
4493 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z);
4494 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x);
4495 word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
4496 ++v22;
4497 }
4498 while ( v22 < a1->uNumVertices );
4499 }
4500 }
4501 else
4502 {
4503 v23 = SHIWORD(a3);
4504 v24 = a4;
4505 if ( a1->uNumVertices )
4506 {
4507 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
4508 do
4509 {
4510 v9 = 2 * v22;
4511 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y);
4512 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z);
4513 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y);
4514 word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
4515 ++v22;
4516 }
4517 while ( v22 < a1->uNumVertices );
4518 }
4519 }
4520 }
4521 v11 = 2 * a1->uNumVertices;
4522 a4d = 0;
4523 word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
4524 word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0];
4525 v21 = 0;
4526 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
4527 if ( v11 <= 0 )
4528 goto LABEL_29;
4529 do
4530 {
4531 if ( a4d >= 2 )
4532 break;
4533 v13 = v21;
4534 v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1];
4535 if ( v12 ^ v14 >= v24 )
4536 {
4537 v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
4538 if ( v15 >= v23 )
4539 v16 = 0;
4540 else
4541 v16 = 2;
4542 v17 = v16 | word_720A70_intercepts_xs_plus_xs[v13] < v23;
4543 if ( v17 != 3 )
4544 {
4545 if ( !v17
4546 || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13],
4547 LODWORD(v19) = v18 << 16,
4548 HIDWORD(v19) = v18 >> 16,
4549 word_720A70_intercepts_xs_plus_xs[v13]
4550 + ((signed int)(((unsigned __int64)(v19
4551 / (v14 - word_7209A0_intercepts_ys_plus_ys[v13])
4552 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16)
4553 + 32768) >> 16) >= v23) )
4554 ++a4d;
4555 }
4556 }
4557 ++v21;
4558 v12 = v14 >= v24;
4559 }
4560 while ( v21 < v11 );
4561 result = 1;
4562 if ( a4d != 1 )
4563 LABEL_29:
4564 result = 0;
4565 return result;
4566 }
4567
4568 //----- (00475D85) --------------------------------------------------------
4569 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4)
4570 {
4571 BLVFace *v4; // ebx@1
4572 int v5; // ST24_4@2
4573 int v6; // ST28_4@2
4574 int v7; // edi@2
4575 int v8; // eax@5
4576 signed int v9; // esi@5
4577 signed __int64 v10; // qtt@10
4578 Vec3_int_ *v11; // esi@11
4579 int v12; // ST14_4@11
4580 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1
4581 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1
4582 int v16; // [sp+18h] [bp-Ch]@2
4583 int v17; // [sp+20h] [bp-4h]@10
4584 int a4b; // [sp+30h] [bp+Ch]@2
4585 int a4c; // [sp+30h] [bp+Ch]@9
4586 signed int a4a; // [sp+30h] [bp+Ch]@10
4587
4588 v4 = a4;
4589 v15 = a2;
4590 v14 = a1;
4591 if ( BYTE3(a4->uAttributes) & 0x20
4592 || (v5 = (unsigned __int64)(a2->x * (signed __int64)a4->pFacePlane_old.vNormal.x) >> 16,
4593 a4b = (unsigned __int64)(a2->y * (signed __int64)a4->pFacePlane_old.vNormal.y) >> 16,
4594 v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16,
4595 v7 = v5 + v6 + a4b,
4596 (v16 = v5 + v6 + a4b) == 0)
4597 || v7 > 0 && !(v4->uAttributes & 1) )
4598 return 0;
4599 v8 = v4->pFacePlane_old.vNormal.z * a1->z;
4600 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x);
4601 if ( v7 <= 0 )
4602 {
4603 if ( v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0 )
4604 return 0;
4605 }
4606 else
4607 {
4608 if ( v9 < 0 )
4609 return 0;
4610 }
4611 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14;
4612 if ( a4c > abs(v7)
4613 || (LODWORD(v10) = v9 << 16, HIDWORD(v10) = v9 >> 16, a4a = v10 / v16, v17 = v10 / v16, v17 > *a3 << 16)
4614 || (v11 = v14,
4615 LOWORD(v12) = LOWORD(v14->x)
4616 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->x) >> 16) + 32768) >> 16),
4617 HIWORD(v12) = LOWORD(v11->y)
4618 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->y) >> 16) + 32768) >> 16),
4619 !sub_475665(
4620 v4,
4621 v12,
4622 LOWORD(v11->z) + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->z) >> 16) + 32768) >> 16))) )
4623 return 0;
4624 *a3 = a4a >> 16;
4625 return 1;
4626 }
4627
4628 //----- (00475F30) --------------------------------------------------------
4629 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
4630 {
4631 BLVFace *v9; // ebx@1
4632 int v10; // ST20_4@2
4633 int v11; // ST28_4@2
4634 int v12; // ST24_4@2
4635 char v13; // zf@2
4636 int v14; // edi@2
4637 int v15; // eax@5
4638 signed int v16; // esi@5
4639 int v17; // ST20_4@9
4640 signed __int64 v18; // qtt@10
4641 int v19; // ST14_4@11
4642 int *v21; // [sp+14h] [bp-10h]@1
4643 int v22; // [sp+1Ch] [bp-8h]@2
4644 int v23; // [sp+1Ch] [bp-8h]@10
4645 signed int v24; // [sp+20h] [bp-4h]@10
4646
4647 v9 = a2;
4648 v21 = a1;
4649 if ( BYTE3(a2->uAttributes) & 0x20
4650 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
4651 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
4652 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
4653 v13 = v10 + v12 + v11 == 0,
4654 v14 = v10 + v12 + v11,
4655 v22 = v10 + v12 + v11,
4656 v13)
4657 || v14 > 0 && !(a2->uAttributes & 1) )
4658 return 0;
4659 v15 = a4 * a2->pFacePlane_old.vNormal.y;
4660 v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
4661 if ( v14 <= 0 )
4662 {
4663 if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
4664 return 0;
4665 }
4666 else
4667 {
4668 if ( v16 < 0 )
4669 return 0;
4670 }
4671 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
4672 if ( v17 > abs(v14)
4673 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16)
4674 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
4675 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
4676 !sub_4759C9(
4677 v9,
4678 a9,
4679 v19,
4680 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) )
4681 return 0;
4682 *v21 = v24 >> 16;
4683 return 1;
4684 }
4685
4686
4687
4688
4689
4690 //----- (004760D5) --------------------------------------------------------
4691 PartyAction ActionQueue::Next()
4692 {
4693 if (!uNumActions)
4694 return PARTY_INVALID;
4695
4696 auto result = pActions[0];
4697 for (unsigned int i = 0; i < uNumActions - 1; ++i)
4698 pActions[i] = pActions[i + 1];
4699 --uNumActions;
4700
4701 return result;
4702 }
4703
4704 //----- (00476387) --------------------------------------------------------
4705 bool __cdecl sub_476387()
4706 {
4707 return (pNPCStats->pNewNPCData[57].uFlags & 0x80) != 0;
4708 }
4709
4710 //----- (00476395) --------------------------------------------------------
4711 //0x26 Wizard eye at skill level 2
4712 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
4713 {
4714 bool result; // eax@2
4715 signed int v2; // esi@3
4716 char *v3; // eax@4
4717
4718 if ( bNoNPCHiring == 1 )
4719 return 0;
4720 v2 = 0;
4721 if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
4722 {
4723 LABEL_8:
4724 result = 0;
4725 if ( pParty->pHirelings[0].uProfession != uProfession )
4726 {
4727 LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
4728 return result;
4729 }
4730 }
4731 else
4732 {
4733 v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
4734 while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
4735 {
4736 ++v2;
4737 v3 += 76;
4738 if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
4739 goto LABEL_8;
4740 }
4741 result = 0;
4742 }
4743 ++result;
4744 return result;
4745 }
4746 // 6BE3C5: using guessed type char bNoNPCHiring;
4747
4748 //----- (004763E0) --------------------------------------------------------
4749 void __cdecl InitializeAwards()
4750 {
4751 char *v0; // ebx@1
4752 char *v1; // eax@4
4753 char v2; // dl@5
4754 char *v3; // ecx@5
4755 int v4; // esi@9
4756 signed int v5; // [sp+Ch] [bp-Ch]@4
4757 char *v6; // [sp+10h] [bp-8h]@4
4758 Award *v7; // [sp+14h] [bp-4h]@3
4759
4760 v0 = 0;
4761 if ( pAwardsTXT_Raw )
4762 pAllocator->FreeChunk(pAwardsTXT_Raw);
4763 pAwardsTXT_Raw = 0;
4764 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
4765 strtok(pAwardsTXT_Raw, "\r");
4766 v7 = pAwards;
4767 for (uint i = 0; i < 104; ++i)
4768 {
4769 v1 = strtok(v0, "\r") + 1;
4770 v6 = v0;
4771 v5 = (signed int)v0;
4772 do
4773 {
4774 v2 = *v1;
4775 v3 = 0;
4776 if ( *v1 != 9 )
4777 {
4778 v0 = 0;
4779 do
4780 {
4781 if ( !v2 )
4782 break;
4783 ++v3;
4784 v2 = v1[(int)v3];
4785 }
4786 while ( v2 != 9 );
4787 }
4788 v4 = (int)&v1[(int)v3];
4789 if ( v1[(int)v3] == (char)v0 )
4790 v5 = 1;
4791 *(char *)v4 = (char)v0;
4792 if ( v3 == v0 )
4793 {
4794 v5 = 1;
4795 }
4796 else
4797 {
4798 if ( v6 == (char *)1 )
4799 {
4800 v7->pText = RemoveQuotes(v1);
4801 }
4802 else
4803 {
4804 if ( v6 == (char *)2 )
4805 v7->uSort = atoi(v1);
4806 }
4807 }
4808 ++v6;
4809 v1 = (char *)(v4 + 1);
4810 }
4811 while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 );
4812 ++v7;
4813 }
4814 //while ( (signed int)v7 < (signed int)&dword_7241C8 );
4815 }
4816 // 7241C8: using guessed type int dword_7241C8;
4817
4818 //----- (004764C2) --------------------------------------------------------
4819 void __cdecl InitializeScrolls()
4820 {
4821 char *v0; // ebx@1
4822 char *v1; // eax@4
4823 int v2; // edi@4
4824 char v3; // dl@5
4825 char *v4; // ecx@5
4826 int v5; // esi@9
4827 const char **v6; // [sp+10h] [bp-8h]@3
4828 signed int v7; // [sp+14h] [bp-4h]@4
4829
4830 v0 = 0;
4831 if ( pScrollsTXT_Raw )
4832 pAllocator->FreeChunk(pScrollsTXT_Raw);
4833 pScrollsTXT_Raw = 0;
4834 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
4835 strtok(pScrollsTXT_Raw, "\r");
4836 v6 = pScrolls;
4837 for (uint i = 0; i < 82; ++i)
4838 {
4839 v1 = strtok(v0, "\r") + 1;
4840 v2 = 0;
4841 v7 = (signed int)v0;
4842 do
4843 {
4844 v3 = *v1;
4845 v4 = 0;
4846 if ( *v1 != 9 )
4847 {
4848 v0 = 0;
4849 do
4850 {
4851 if ( !v3 )
4852 break;
4853 ++v4;
4854 v3 = v1[(int)v4];
4855 }
4856 while ( v3 != 9 );
4857 }
4858 v5 = (int)&v1[(int)v4];
4859 if ( v1[(int)v4] == (char)v0 )
4860 v7 = 1;
4861 *(char *)v5 = (char)v0;
4862 if ( v4 == v0 )
4863 {
4864 v7 = 1;
4865 }
4866 else
4867 {
4868 if ( v2 == 1 )
4869 *v6 = RemoveQuotes(v1);
4870 }
4871 ++v2;
4872 v1 = (char *)(v5 + 1);
4873 }
4874 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
4875 ++v6;
4876 }
4877 //while ( (signed int)v6 < (signed int)dword_723E80_award_related );
4878 }
4879
4880
4881 //----- (00476590) --------------------------------------------------------
4882 void __cdecl InitializeMerchants()
4883 {
4884 char *v0; // ebx@1
4885 //char **v1; // edi@3
4886 char *v2; // ecx@4
4887 char v3; // dl@5
4888 char *v4; // eax@5
4889 int v5; // esi@9
4890 signed int v6; // [sp+Ch] [bp-8h]@4
4891 char *v7; // [sp+10h] [bp-4h]@4
4892
4893 v0 = 0;
4894 if ( pMerchantsTXT_Raw )
4895 pAllocator->FreeChunk(pMerchantsTXT_Raw);
4896 pMerchantsTXT_Raw = 0;
4897 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
4898 strtok(pMerchantsTXT_Raw, "\r");
4899 //v1 = (char **)pMerchantsRepairPhrases;
4900 for (uint i = 0; i < 7; ++i)
4901 {
4902 v7 = v0;
4903 v6 = (signed int)v0;
4904 v2 = strtok(v0, "\r") + 1;
4905 do
4906 {
4907 v3 = *v2;
4908 v4 = 0;
4909 if ( *v2 != 9 )
4910 {
4911 v0 = 0;
4912 do
4913 {
4914 if ( !v3 )
4915 break;
4916 ++v4;
4917 v3 = v2[(int)v4];
4918 }
4919 while ( v3 != 9 );
4920 }
4921 v5 = (int)&v2[(int)v4];
4922 if ( v2[(int)v4] == (char)v0 )
4923 v6 = 1;
4924 *(char *)v5 = (char)v0;
4925 if ( v4 == v0 )
4926 {
4927 v6 = 1;
4928 }
4929 else
4930 {
4931 if ( v7 == (char *)1 )
4932 {
4933 pMerchantsBuyPhrases[i] = RemoveQuotes(v2);
4934 }
4935 else
4936 {
4937 if ( v7 == (char *)2 )
4938 {
4939 pMerchantsSellPhrases[i] = RemoveQuotes(v2);
4940 }
4941 else
4942 {
4943 if ( v7 == (char *)3 )
4944 {
4945 pMerchantsRepairPhrases[i] = RemoveQuotes(v2);
4946 }
4947 else
4948 {
4949 if ( v7 - 3 == (char *)1 )
4950 pMerchantsIdentifyPhrases[i] = RemoveQuotes(v2);
4951 }
4952 }
4953 }
4954 }
4955 ++v7;
4956 v2 = (char *)(v5 + 1);
4957 }
4958 while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 );
4959 //++v1;
4960 }
4961 //while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases );
4962 }
4963
4964 //----- (00476682) --------------------------------------------------------
4965 void __cdecl InitializeTransitions()
4966 {
4967 char *v0; // ebx@1
4968 char *v1; // eax@4
4969 int v2; // edi@4
4970 char v3; // dl@5
4971 char *v4; // ecx@5
4972 int v5; // esi@9
4973 char **v6; // [sp+10h] [bp-8h]@3
4974 signed int v7; // [sp+14h] [bp-4h]@4
4975
4976 v0 = 0;
4977 if ( pTransitionsTXT_Raw )
4978 pAllocator->FreeChunk(pTransitionsTXT_Raw);
4979 pTransitionsTXT_Raw = 0;
4980 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
4981 strtok(pTransitionsTXT_Raw, "\r");
4982 v6 = pTransitionStrings;
4983 for (uint i = 0; i < 464; ++i)
4984 {
4985 v1 = strtok(v0, "\r") + 1;
4986 v2 = 0;
4987 v7 = (signed int)v0;
4988 do
4989 {
4990 v3 = *v1;
4991 v4 = 0;
4992 if ( *v1 != 9 )
4993 {
4994 v0 = 0;
4995 do
4996 {
4997 if ( !v3 )
4998 break;
4999 ++v4;
5000 v3 = v1[(int)v4];
5001 }
5002 while ( v3 != 9 );
5003 }
5004 v5 = (int)&v1[(int)v4];
5005 if ( v1[(int)v4] == (char)v0 )
5006 v7 = 1;
5007 *(char *)v5 = (char)v0;
5008 if ( v4 == v0 )
5009 {
5010 v7 = 1;
5011 }
5012 else
5013 {
5014 if ( v2 == 1 )
5015 *v6 = (char *)RemoveQuotes(v1);
5016 }
5017 ++v2;
5018 v1 = (char *)(v5 + 1);
5019 }
5020 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
5021 ++v6;
5022 }
5023 //while ( (signed int)v6 < (signed int)"awards.txt" );
5024 }
5025
5026 //----- (00476750) --------------------------------------------------------
5027 void __cdecl InitializeAutonotes()
5028 {
5029 char *v0; // ebp@3
5030 int v1; // ebx@4
5031 char *v2; // esi@4
5032 char v3; // cl@5
5033 int v4; // eax@5
5034 int v5; // edi@9
5035 signed int v6; // [sp+0h] [bp-4h]@4
5036
5037 if ( pAutonoteTXT_Raw )
5038 pAllocator->FreeChunk(pAutonoteTXT_Raw);
5039 pAutonoteTXT_Raw = 0;
5040 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
5041 strtok(pAutonoteTXT_Raw, "\r");
5042 v0 = (char *)&stru_723720[0].eType;
5043 for (uint i = 0; i < 195; ++i)
5044 {
5045 v1 = 0;
5046 v2 = strtok(0, "\r") + 1;
5047 v6 = 0;
5048 do
5049 {
5050 v3 = *v2;
5051 v4 = 0;
5052 while ( v3 != 9 && v3 )
5053 {
5054 ++v4;
5055 v3 = v2[v4];
5056 }
5057 v5 = (int)&v2[v4];
5058 if ( !v2[v4] )
5059 v6 = 1;
5060 *(char *)v5 = 0;
5061 if ( v4 )
5062 {
5063 if ( v1 == 1 )
5064 {
5065 *((int *)v0 - 1) = (int)RemoveQuotes(v2);
5066 }
5067 else
5068 {
5069 if ( v1 == 2 )
5070 {
5071 if ( _strcmpi(v2, "potion") )
5072 {
5073 if ( _strcmpi(v2, "stat") )
5074 {
5075 if ( _strcmpi(v2, "seer") )
5076 {
5077 if ( _strcmpi(v2, "obelisk") )
5078 *(int *)v0 = 5 - (_strcmpi(v2, "teacher") != 0);
5079 else
5080 *(int *)v0 = 2;
5081 }
5082 else
5083 {
5084 *(int *)v0 = 3;
5085 }
5086 }
5087 else
5088 {
5089 *(int *)v0 = 1;
5090 }
5091 }
5092 else
5093 {
5094 *(int *)v0 = 0;
5095 }
5096 }
5097 }
5098 }
5099 else
5100 {
5101 v6 = 1;
5102 }
5103 ++v1;
5104 v2 = (char *)(v5 + 1);
5105 }
5106 while ( v1 - 1 <= 2 && !v6 );
5107 v0 += 8;
5108 }
5109 //while ( (signed int)v0 < (signed int)&pScrolls[1] );
5110 }
5111
5112
5113 //----- (004768A9) --------------------------------------------------------
5114 void __cdecl InitializeQuests()
5115 {
5116 char *v0; // ebx@1
5117 char *v1; // eax@4
5118 int v2; // edi@4
5119 char v3; // dl@5
5120 char *v4; // ecx@5
5121 int v5; // esi@9
5122 //const char **v6; // [sp+10h] [bp-8h]@3
5123 signed int v7; // [sp+14h] [bp-4h]@4
5124
5125 v0 = 0;
5126 if ( pQuestsTXT_Raw )
5127 pAllocator->FreeChunk(pQuestsTXT_Raw);
5128 pQuestsTXT_Raw = 0;
5129 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
5130 strtok(pQuestsTXT_Raw, "\r");
5131
5132 //v6 = pQuestTable;
5133 for (uint i = 0; i < 512; ++i)
5134 //do
5135 {
5136 v1 = strtok(v0, "\r") + 1;
5137 v2 = 0;
5138 v7 = (signed int)v0;
5139 do
5140 {
5141 v3 = *v1;
5142 v4 = 0;
5143 if ( *v1 != '\t' )
5144 {
5145 v0 = 0;
5146 do
5147 {
5148 if ( !v3 )
5149 break;
5150 ++v4;
5151 v3 = v1[(int)v4];
5152 }
5153 while ( v3 != '\t' );
5154 }
5155 v5 = (int)&v1[(int)v4];
5156 if ( v1[(int)v4] == (char)v0 )
5157 v7 = 1;
5158 *(char *)v5 = (char)v0;
5159 if ( v4 == v0 )
5160 {
5161 v7 = 1;
5162 }
5163 else
5164 {
5165 if ( v2 == 1 )
5166 pQuestTable[i] = RemoveQuotes(v1);
5167 }
5168 ++v2;
5169 v1 = (char *)(v5 + 1);
5170 }
5171 while ( v2 - 1 <= 1 && (char *)v7 == v0 );
5172 //++v6;
5173 }
5174 //while ( (signed int)v6 < (signed int)&unk_723714 );
5175 }
5176
5177
5178
5179 //----- (00476977) --------------------------------------------------------
5180 void NPCStats::Initialize2()
5181 {
5182 char *v4; // eax@4
5183 char v5; // dl@5
5184 char *v6; // ecx@5
5185 int v7; // edi@9
5186 char *v9; // eax@21
5187 char v10; // dl@22
5188 char *v11; // ecx@22
5189 int v12; // edi@26
5190 char *v14; // eax@39
5191 char v15; // dl@40
5192 int v16; // ecx@40
5193 int v17; // edi@44
5194 char v18; // zf@47
5195 NPCStats_stru0 *v19; // eax@57
5196 signed int v20; // edx@57
5197 signed int v21; // ecx@58
5198 char *v22; // [sp+10h] [bp-10h]@4
5199 char *v23; // [sp+10h] [bp-10h]@21
5200 char *v25; // [sp+14h] [bp-Ch]@4
5201 char *v26; // [sp+14h] [bp-Ch]@21
5202 signed int v27; // [sp+14h] [bp-Ch]@39
5203 //signed int v28; // [sp+18h] [bp-8h]@3
5204 //signed int v29; // [sp+18h] [bp-8h]@20
5205 signed int v30; // [sp+18h] [bp-8h]@37
5206 char *v31; // [sp+1Ch] [bp-4h]@37
5207
5208 //v1 = this;
5209 //v2 = 0;
5210 if (pNPCTextTXT_Raw)
5211 pAllocator->FreeChunk(pNPCTextTXT_Raw);
5212
5213 //v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
5214 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
5215 strtok(pNPCTextTXT_Raw, "\r");
5216
5217 for (uint i = 0; i < 789; ++i)
5218 {
5219 v4 = strtok(nullptr, "\r") + 1;
5220 v22 = nullptr;
5221 v25 = nullptr;
5222 do
5223 {
5224 v5 = *v4;
5225 v6 = 0;
5226 if ( *v4 != 9 )
5227 {
5228 do
5229 {
5230 if ( !v5 )
5231 break;
5232 ++v6;
5233 v5 = v4[(int)v6];
5234 }
5235 while ( v5 != 9 );
5236 //v2 = 0;
5237 }
5238 v7 = (int)&v4[(int)v6];
5239 if ( !v4[(int)v6] )
5240 v25 = (char *)1;
5241 *(char *)v7 = 0;
5242 if ( v6 == nullptr )
5243 {
5244 v25 = (char *)1;
5245 }
5246 else
5247 {
5248 if ( v22 == (char *)1 )
5249 pNPCTopics[i].pText = RemoveQuotes(v4);
5250 }
5251 ++v22;
5252 v4 = (char *)(v7 + 1);
5253 }
5254 while ( (signed int)(v22 - 1) <= 1 && v25 == nullptr );
5255 }
5256
5257 if (pNPCTopicTXT_Raw)
5258 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
5259
5260 //v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2);
5261 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
5262 strtok(pNPCTopicTXT_Raw, "\r");
5263
5264 for (uint i = 0; i < 579; ++i)
5265 {
5266 v9 = strtok(nullptr, "\r") + 1;
5267 v23 = nullptr;
5268 v26 = nullptr;
5269 do
5270 {
5271 v10 = *v9;
5272 v11 = 0;
5273 if ( *v9 != 9 )
5274 {
5275 do
5276 {
5277 if ( !v10 )
5278 break;
5279 ++v11;
5280 v10 = v9[(int)v11];
5281 }
5282 while ( v10 != 9 );
5283 //v2 = 0;
5284 }
5285 v12 = (int)&v9[(int)v11];
5286 if ( !v9[(int)v11] )
5287 v26 = (char *)1;
5288 *(char *)v12 = 0;
5289 if ( v11 == nullptr )
5290 {
5291 v26 = (char *)1;
5292 }
5293 else
5294 {
5295 if ( v23 == (char *)1 )
5296 pNPCTopics[i].pTopic = RemoveQuotes(v9);
5297 }
5298 ++v23;
5299 v9 = (char *)(v12 + 1);
5300 }
5301 while ( (signed int)(v23 - 1) <= 1 && v26 == nullptr );
5302 }
5303
5304 if (pNPCDistTXT_Raw)
5305 pAllocator->FreeChunk(pNPCDistTXT_Raw);
5306
5307 //v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2);
5308 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
5309 strtok(pNPCDistTXT_Raw, "\r");
5310 strtok(nullptr, "\r");
5311 v30 = 1;
5312 v31 = &array_16544[0].field_4[1];
5313
5314 char *v2 = 0;
5315 while ( 2 )
5316 {
5317 v14 = strtok(nullptr, "\r") + 1;
5318 v27 = 0;
5319 char *v24 = nullptr;
5320 do
5321 {
5322 v15 = *v14;
5323 v16 = 0;
5324 if ( *v14 != 9 )
5325 {
5326 do
5327 {
5328 if ( !v15 )
5329 break;
5330 ++v16;
5331 v15 = v14[v16];
5332 }
5333 while ( v15 != 9 );
5334 v2 = v24;
5335 }
5336 v17 = (int)&v14[v16];
5337 if ( !v14[v16] )
5338 v27 = 1;
5339 *(char *)v17 = 0;
5340 if ( !v16 )
5341 {
5342 v27 = 1;
5343 goto LABEL_54;
5344 }
5345 v18 = v2 == 0;
5346 if ( (signed int)v2 > 0 )
5347 {
5348 if ( (signed int)v2 < 77 )
5349 {
5350 array_16544[(int)v2].field_4[v30] = atoi(v14);
5351 goto LABEL_54;
5352 }
5353 v18 = v2 == 0;
5354 }
5355 if ( v18 )
5356 *v31 = 10;
5357 LABEL_54:
5358 ++v2;
5359 v14 = (char *)(v17 + 1);
5360 v24 = v2;
5361 }
5362 while ( (signed int)(v2 - 1) <= 77 && !v27 );
5363 ++v30;
5364 ++v31;
5365 if ( v30 < 59 )
5366 {
5367 v2 = 0;
5368 continue;
5369 }
5370 break;
5371 }
5372 v19 = array_16544;
5373 v20 = 77;
5374 do
5375 {
5376 v19->field_0 = 0;
5377 v21 = 1;
5378 do
5379 v19->field_0 += v19->field_4[v21++];
5380 while ( v21 < 59 );
5381 ++v19;
5382 --v20;
5383 }
5384 while ( v20 );
5385
5386 if (pNPCDistTXT_Raw)
5387 {
5388 pAllocator->FreeChunk(pNPCDistTXT_Raw);
5389 pNPCDistTXT_Raw = nullptr;
5390 }
5391 }
5392
5393 //----- (00476C60) --------------------------------------------------------
5394 void NPCStats::_476C60()
5395 {
5396 for (uint i = 1; i < uNumNewNPCs; ++i)
5397 pNewNPCData[i].pName = pNPCNames2[i - 1];
5398
5399 if (pParty->pHirelings[0].pName)
5400 pParty->pHirelings[0].pName = pParty->pHireling1Name;
5401 if (pParty->pHirelings[1].pName)
5402 pParty->pHirelings[1].pName = pParty->pHireling2Name;
5403 }
5404
5405 //----- (00476CB5) --------------------------------------------------------
5406 void NPCStats::Initialize1()
5407 {
5408 NPCStats *pNPCStats; // esi@1
5409 char *pRaw; // eax@1
5410 char *pHouse; // edi@1
5411 char *v4; // eax@2
5412 char v5; // dl@3
5413 int v6; // ecx@3
5414 char *v7; // eax@11
5415 char *v8; // eax@26
5416 char *v9; // ecx@27
5417 char v10; // dl@28
5418 int v11; // eax@28
5419 int v12; // edi@32
5420 char *v13; // eax@42
5421 char *v14; // eax@43
5422 char v15; // dl@44
5423 int v16; // ecx@44
5424 int v17; // edi@48
5425 char *v18; // eax@56
5426 char *v19; // eax@57
5427 char v20; // cl@58
5428 int v21; // edi@58
5429 int v22; // esi@62
5430 int v23; // [sp+Ch] [bp-14h]@7
5431 signed int v24; // [sp+10h] [bp-10h]@1
5432 signed int v25; // [sp+10h] [bp-10h]@26
5433 signed int v26; // [sp+10h] [bp-10h]@42
5434 signed int v27; // [sp+10h] [bp-10h]@56
5435 char *Str; // [sp+14h] [bp-Ch]@1
5436 NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26
5437 unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42
5438 char **pCatchPhrase; // [sp+14h] [bp-Ch]@56
5439 signed int v32; // [sp+18h] [bp-8h]@2
5440 signed int v33; // [sp+18h] [bp-8h]@27
5441 signed int v34; // [sp+18h] [bp-8h]@43
5442 signed int v35; // [sp+18h] [bp-8h]@57
5443 signed int v36; // [sp+1Ch] [bp-4h]@2
5444 signed int v37; // [sp+1Ch] [bp-4h]@27
5445 signed int v38; // [sp+1Ch] [bp-4h]@43
5446 signed int v39; // [sp+1Ch] [bp-4h]@57
5447
5448 pNPCStats = this;
5449 pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
5450 pNPCStats->pNPCDataTXT_Raw = pRaw;
5451 strtok(pRaw, "\r");
5452 strtok(0, "\r");
5453 pHouse = (char *)&pNPCStats->pNPCData[1].house;
5454 Str = (char *)pNPCStats->pNPCNames2;
5455 v24 = 500;
5456 do
5457 {
5458 v32 = 0;
5459 v4 = strtok(0, "\r") + 1;
5460 v36 = -1;
5461 do
5462 {
5463 v5 = *v4;
5464 v6 = 0;
5465 while ( v5 != 9 && v5 )
5466 {
5467 ++v6;
5468 v5 = v4[v6];
5469 }
5470 v23 = (int)&v4[v6];
5471 if ( !v4[v6] )
5472 v32 = 1;
5473 v4[v6] = 0;
5474 if ( v6 )
5475 {
5476 switch ( v36 )
5477 {
5478 case 0:
5479 v7 = RemoveQuotes(v4);
5480 *((int *)pHouse - 5) = (int)v7;
5481 *(int *)Str = (int)v7;
5482 break;
5483 case 1:
5484 *((int *)pHouse - 4) = atoi(v4);
5485 break;
5486 case 5:
5487 *(int *)pHouse = atoi(v4);
5488 break;
5489 case 6:
5490 *((int *)pHouse + 1) = atoi(v4);
5491 break;
5492 case 7:
5493 *((int *)pHouse + 2) = atoi(v4);
5494 break;
5495 case 8:
5496 *((int *)pHouse + 3) = *v4 == 121;
5497 break;
5498 case 9:
5499 *((int *)pHouse + 5) = atoi(v4);
5500 break;
5501 case 10:
5502 *((int *)pHouse + 6) = atoi(v4);
5503 break;
5504 case 11:
5505 *((int *)pHouse + 7) = atoi(v4);
5506 break;
5507 case 12:
5508 *((int *)pHouse + 8) = atoi(v4);
5509 break;
5510 case 13:
5511 *((int *)pHouse + 9) = atoi(v4);
5512 break;
5513 case 14:
5514 *((int *)pHouse + 10) = atoi(v4);
5515 break;
5516 default:
5517 break;
5518 }
5519 }
5520 ++v36;
5521 v4 = (char *)(v23 + 1);
5522 }
5523 while ( v36 + 1 <= 15 && !v32 );
5524 Str += 4;
5525 pHouse += 76;
5526 --v24;
5527 }
5528 while ( v24 );
5529 pNPCStats->uNumNewNPCs = 501;
5530 v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
5531 pNPCStats->pNPCGreetTXT_Raw = v8;
5532 strtok(v8, "\r");
5533 pGreetings = pNPCStats->pNPCGreetings;
5534 v25 = 205;
5535 do
5536 {
5537 v37 = 0;
5538 v33 = 0;
5539 v9 = strtok(0, "\r") + 1;
5540 do
5541 {
5542 v10 = *v9;
5543 v11 = 0;
5544 while ( v10 != 9 && v10 )
5545 {
5546 ++v11;
5547 v10 = v9[v11];
5548 }
5549 v12 = (int)&v9[v11];
5550 if ( !v9[v11] )
5551 v33 = 1;
5552 *(char *)v12 = 0;
5553 if ( v11 )
5554 {
5555 if ( v37 == 1 )
5556 {
5557 pGreetings->pGreeting1 = (char *)RemoveQuotes(v9);
5558 }
5559 else
5560 {
5561 if ( v37 == 2 )
5562 pGreetings->pGreeting2 = (char *)RemoveQuotes(v9);
5563 }
5564 }
5565 ++v37;
5566 v9 = (char *)(v12 + 1);
5567 }
5568 while ( v37 <= 2 && !v33 );
5569 ++pGreetings;
5570 --v25;
5571 }
5572 while ( v25 );
5573 v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
5574 pNPCStats->pNCPGroupTXT_Raw = v13;
5575 strtok(v13, "\r");
5576 pGroups = pNPCStats->pGroups;
5577 v26 = 51;
5578 do
5579 {
5580 v14 = strtok(0, "\r") + 1;
5581 v38 = 0;
5582 v34 = 0;
5583 do
5584 {
5585 v15 = *v14;
5586 v16 = 0;
5587 while ( v15 != 9 && v15 )
5588 {
5589 ++v16;
5590 v15 = v14[v16];
5591 }
5592 v17 = (int)&v14[v16];
5593 if ( !v14[v16] )
5594 v34 = 1;
5595 *(char *)v17 = 0;
5596 if ( v16 && v38 == 1 )
5597 *pGroups = atoi(v14);
5598 ++v38;
5599 v14 = (char *)(v17 + 1);
5600 }
5601 while ( v38 <= 1 && !v34 );
5602 ++pGroups;
5603 --v26;
5604 }
5605 while ( v26 );
5606 v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0);
5607 pNPCStats->pNPCNewsTXT_Raw = v18;
5608 strtok(v18, "\r");
5609 pCatchPhrase = pNPCStats->pCatchPhrases;
5610 v27 = 51;
5611 do
5612 {
5613 v19 = strtok(0, "\r") + 1;
5614 v39 = 0;
5615 v35 = 0;
5616 do
5617 {
5618 v20 = *v19;
5619 v21 = 0;
5620 while ( v20 != 9 && v20 )
5621 {
5622 ++v21;
5623 v20 = v19[v21];
5624 }
5625 v22 = (int)&v19[v21];
5626 if ( !v19[v21] )
5627 v35 = 1;
5628 *(char *)v22 = 0;
5629 if ( v21 && v39 == 1 )
5630 *pCatchPhrase = (char *)RemoveQuotes(v19);
5631 ++v39;
5632 v19 = (char *)(v22 + 1);
5633 }
5634 while ( v39 <= 1 && !v35 );
5635 ++pCatchPhrase;
5636 --v27;
5637 }
5638 while ( v27 );
5639 }
5640
5641 //----- (0047702F) --------------------------------------------------------
5642 void NPCStats::Initialize()
5643 {
5644 //NPCStats *v1; // edi@1
5645 char *v2; // ebx@1
5646 //char *v3; // eax@1
5647 char *v4; // ebx@3
5648 char v5; // al@4
5649 int v6; // ecx@4
5650 //char *v7; // eax@18
5651 char *v8; // ebx@18
5652 char *v9; // ecx@19
5653 char v10; // dl@20
5654 int v11; // eax@20
5655 char v12; // zf@41
5656 signed int v13; // [sp+Ch] [bp-14h]@18
5657 int v14; // [sp+10h] [bp-10h]@4
5658 int v15; // [sp+10h] [bp-10h]@24
5659 char *v16; // [sp+14h] [bp-Ch]@1
5660 signed int v17; // [sp+14h] [bp-Ch]@19
5661 unsigned int v18; // [sp+18h] [bp-8h]@1
5662 char *v19; // [sp+18h] [bp-8h]@18
5663 signed int v20; // [sp+1Ch] [bp-4h]@3
5664 signed int v21; // [sp+1Ch] [bp-4h]@19
5665 //v1 = this;
5666
5667 Initialize1();
5668 Initialize2();
5669
5670 InitializeQuests();
5671 InitializeAutonotes();
5672 InitializeAwards();
5673 InitializeTransitions();
5674 InitializeMerchants();
5675 InitializeScrolls();
5676 v2 = 0;
5677 field_17FC0 = 0;
5678 pNPCNamesTXT_Raw = 0;
5679 //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
5680 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
5681 strtok(pNPCNamesTXT_Raw, "\r");
5682 v18 = 0;
5683 v16 = (char *)pNPCNames;
5684 while ( 1 )
5685 {
5686 v4 = strtok(v2, "\r") + 1;
5687 v20 = 0;
5688 do
5689 {
5690 v5 = *v4;
5691 v6 = 0;
5692 v14 = 0;
5693 if ( *v4 == 9 )
5694 goto LABEL_45;
5695 do
5696 {
5697 if ( !v5 )
5698 break;
5699 if ( v5 == 10 )
5700 break;
5701 ++v6;
5702 v14 = v6;
5703 v5 = v4[v6];
5704 }
5705 while ( v5 != 9 );
5706 if ( v6 )
5707 {
5708 v4[v6] = 0;
5709 if ( v20 )
5710 {
5711 if ( v20 == 1 )
5712 *((int *)v16 + 1) = (int)RemoveQuotes(v4);
5713 }
5714 else
5715 {
5716 *(int *)v16 = (int)RemoveQuotes(v4);
5717 }
5718 }
5719 else
5720 {
5721 LABEL_45:
5722 if ( v20 == 1 && !uNumNPCNames[1] )
5723 uNumNPCNames[1] = v18;
5724 }
5725 ++v20;
5726 v4 += v14 + 1;
5727 }
5728 while ( v20 <= 1 );
5729 ++v18;
5730 v16 += 8;
5731 if ( (signed int)v18 >= 540 )
5732 break;
5733 v2 = 0;
5734 }
5735 pNPCProfTXT_Raw = 0;
5736 uNumNPCNames[0] = v18;
5737 //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
5738 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
5739 strtok(pNPCProfTXT_Raw, "\r");
5740 strtok(0, "\r");
5741 strtok(0, "\r");
5742 strtok(0, "\r");
5743 v8 = (char *)&pProfessions[0].pJoinText;
5744 v19 = (char *)&pProfessions[0].pJoinText;
5745 v13 = 58;
5746 do
5747 {
5748 v21 = 0;
5749 v9 = strtok(0, "\r") + 1;
5750 v17 = 0;
5751 do
5752 {
5753 v10 = *v9;
5754 v11 = 0;
5755 if ( *v9 != 9 )
5756 {
5757 do
5758 {
5759 if ( !v10 )
5760 break;
5761 ++v11;
5762 v10 = v9[v11];
5763 }
5764 while ( v10 != 9 );
5765 v8 = v19;
5766 }
5767 v15 = (int)&v9[v11];
5768 if ( !v9[v11] )
5769 v17 = 1;
5770 *(char *)v15 = 0;
5771 if ( v11 )
5772 {
5773 switch ( v21 )
5774 {
5775 case 2:
5776 *((int *)v8 - 3) = atoi(v9);
5777 break;
5778 case 3:
5779 *((int *)v8 - 1) = (int)RemoveQuotes(v9);
5780 break;
5781 case 4:
5782 *((int *)v8 - 2) = (int)RemoveQuotes(v9);
5783 break;
5784 case 5:
5785 *(int *)v8 = (int)RemoveQuotes(v9);
5786 break;
5787 case 6:
5788 *((int *)v8 + 1) = (int)RemoveQuotes(v9);
5789 break;
5790 }
5791 }
5792 else
5793 {
5794 if ( !v21 )
5795 v17 = 1;
5796 }
5797 ++v21;
5798 v9 = (char *)(v15 + 1);
5799 }
5800 while ( v21 <= 6 && !v17 );
5801 v8 += 20;
5802 v12 = v13-- == 1;
5803 v19 = v8;
5804 }
5805 while ( !v12 );
5806 uNumNPCProfessions = 59;
5807 }
5808
5809 //----- (00477266) --------------------------------------------------------
5810 void NPCStats::Release()
5811 {
5812 NPCStats *v1; // esi@1
5813 void *v2; // ST00_4@1
5814 int v3; // ebx@1
5815
5816 v1 = this;
5817 pAllocator->FreeChunk(this->pNPCTopicTXT_Raw);
5818 v2 = v1->pNPCTextTXT_Raw;
5819 v1->pNPCNewsTXT_Raw = 0;
5820 pAllocator->FreeChunk(v2);
5821 v1->pNPCNewsTXT_Raw = 0;
5822 pAllocator->FreeChunk(0);
5823 v1->pNPCNewsTXT_Raw = 0;
5824 pAllocator->FreeChunk(v1->pNPCProfTXT_Raw);
5825 v1->pNPCProfTXT_Raw = 0;
5826 pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw);
5827 v1->pNPCNamesTXT_Raw = 0;
5828 pAllocator->FreeChunk(v1->pNPCDataTXT_Raw);
5829 v1->pNPCDataTXT_Raw = 0;
5830 pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
5831 v1->pNPCDistTXT_Raw = 0;
5832 v3 = (int)&v1->pNPCGreetTXT_Raw;
5833 pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw);
5834 v1 = (NPCStats *)((char *)v1 + 98296);
5835 *(int *)v3 = 0;
5836 pAllocator->FreeChunk(v1->pNPCData[0].pName);
5837 v1->pNPCData[0].pName = 0;
5838 }
5839
5840 //----- (0047730C) --------------------------------------------------------
5841 int __fastcall const_1(int a1, int)
5842 {
5843 return 1;
5844 }
5845 // 47730C: using guessed type int __stdcall const_1(int);
5846
5847 //----- (0047732C) --------------------------------------------------------
5848 bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5)
5849 {
5850 //NPCStats *v5; // ebx@1
5851 signed __int64 v6; // qax@1
5852 int v7; // esi@1
5853 int v8; // edx@1
5854 NPCData *v9; // edi@1
5855 int v10; // eax@1
5856 //int v11; // eax@23
5857 int v12; // ecx@23
5858 int v13; // edx@28
5859 int v14; // esi@37
5860 int v15; // edx@37
5861 int v16; // ecx@37
5862 int v17; // eax@37
5863 int v18; // edx@37
5864 signed int result; // eax@39
5865 int v20; // [sp+Ch] [bp-Ch]@1
5866 signed int v21; // [sp+10h] [bp-8h]@1
5867 signed int v22; // [sp+14h] [bp-4h]@1
5868 int v23; // [sp+24h] [bp+Ch]@1
5869
5870
5871 v23 = a3 - 1;
5872 //v5 = this;
5873 v6 = (signed __int64)((double)v23 * -0.33333334);
5874 v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28];
5875 v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116];
5876 v8 = rand() % uNumNPCNames[v7];
5877 v9 = a2;
5878 a2->uSex = v7;
5879 a2->pName = pNPCNames[v8][v7];
5880 v10 = 0;
5881 v22 = 0;
5882 v21 = 0;
5883
5884 while ( 1 )
5885 {
5886 if ( v20 == v10 )
5887 {
5888 if ( v7 == v10 )
5889 {
5890 v23 = 2;
5891 a2 = (NPCData *)100;
5892 }
5893 else
5894 {
5895 if ( v7 - v10 == 1 )
5896 {
5897 v23 = 201;
5898 a2 = (NPCData *)250;
5899 }
5900 }
5901 }
5902 else
5903 {
5904 switch ( v20 - v10 )
5905 {
5906 case 1:
5907 if ( v7 == v10 )
5908 {
5909 v23 = 400;
5910 a2 = (NPCData *)430;
5911 }
5912 else
5913 {
5914 if ( v7 - v10 == 1 )
5915 {
5916 v23 = 460;
5917 a2 = (NPCData *)490;
5918 }
5919 }
5920 break;
5921 case 2:
5922 if ( v7 == v10 )
5923 {
5924 v23 = 500;
5925 a2 = (NPCData *)520;
5926 }
5927 else
5928 {
5929 if ( v7 - v10 == 1 )
5930 {
5931 v23 = 530;
5932 a2 = (NPCData *)550;
5933 }
5934 }
5935 break;
5936 case 3:
5937 if ( v7 == v10 )
5938 {
5939 v23 = 300;
5940 a2 = (NPCData *)330;
5941 }
5942 else
5943 {
5944 if ( v7 - v10 == 1 )
5945 {
5946 v23 = 360;
5947 a2 = (NPCData *)387;
5948 }
5949 }
5950 break;
5951 }
5952 }
5953 v12 = v23 + rand() % ((int)a2 - v23 + 1);
5954 if ( const_1(v12, v7) == 1 )
5955 v21 = 1;
5956 ++v22;
5957 if ( v22 >= 4 )
5958 {
5959 v12 = v23;
5960 v21 = 1;
5961 }
5962 if ( v21 )
5963 break;
5964 v10 = 0;
5965 }
5966
5967 v9->uPortraitID = v12;
5968 v9->uFlags = 0;
5969 v9->fame = 0;
5970 v13 = rand() % 100 + 1;
5971
5972 if ( v13 >= 60 )
5973 {
5974 if ( v13 >= 90 )
5975 {
5976 if ( v13 >= 95 )
5977 {
5978 if ( v13 >= 98 )
5979 v9->rep = -600;
5980 else
5981 v9->rep = 400;
5982 }
5983 else
5984 {
5985 v9->rep = -300;
5986 }
5987 }
5988 else
5989 {
5990 v9->rep = 200;
5991 }
5992 }
5993 else
5994 {
5995 v9->rep = 0;
5996 }
5997
5998 //v14 = (int)((char *)v5 + 64 * a5);
5999 //v15 = rand() % *(_DWORD *)(v14 + 91460);
6000 v15 = rand() % array_16544[a5].field_0;
6001 v16 = 0;
6002 v17 = 0;
6003 v18 = v15 + 1;
6004
6005 if ( v18 > 0 )
6006 {
6007 do
6008 //v14 += *(char *)(v14 + v17++ + 0x16548);
6009 v16 += array_16544[a5].field_4[v17++];
6010 while ( v16 < v18 );
6011 }
6012 v9->uProfession = v17 - 1;
6013 v9->house = a4;
6014 v9->field_24 = 1;
6015 v9->joins = 1;
6016 return true;
6017 }
6018 // 47730C: using guessed type int __stdcall const_1(int);
6019
6020 //----- (0047752B) --------------------------------------------------------
6021 int __cdecl GetPartyReputation()
6022 {
6023 DDM_DLV_Header *v0; // ebx@1
6024 signed int v1; // esi@3
6025
6026 v0 = &pOutdoor->ddm;
6027 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
6028 v0 = &pIndoor->dlv;
6029 v1 = 0;
6030 if ( CheckHiredNPCSpeciality(0x2Du) )
6031 v1 = 5;
6032 if ( CheckHiredNPCSpeciality(0x33u) )
6033 v1 += 5;
6034 if ( CheckHiredNPCSpeciality(0x30u) )
6035 v1 += 5;
6036 if ( CheckHiredNPCSpeciality(0x32u) )
6037 v1 += 5;
6038 if ( CheckHiredNPCSpeciality(0x34u) )
6039 v1 += 5;
6040 return v1 + v0->uReputation;
6041 }
6042
6043
6044
6045
6046
6047 //----- (004775ED) --------------------------------------------------------
6048 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2)
6049 {
6050 char *v2; // edi@1
6051 int v3; // eax@1
6052 char *v4; // edx@2
6053 char *v5; // esi@3
6054 double v6; // st7@6
6055 signed __int64 v7; // ST84_8@6
6056 double v8; // ST0C_8@6
6057 int v9; // esi@6
6058 double v10; // ST44_8@6
6059 int v11; // ecx@6
6060 double v12; // ST34_8@6
6061 int v13; // ecx@6
6062 double v14; // ST14_8@6
6063 double v15; // st7@8
6064 unsigned int v16; // ecx@8
6065 signed __int64 v17; // ST64_8@8
6066 double v18; // ST24_8@8
6067 int v19; // edi@8
6068 double v20; // ST3C_8@8
6069 int v21; // ecx@8
6070 double v22; // ST2C_8@8
6071 int v23; // ST9C_4@8
6072 double v24; // ST1C_8@8
6073 int *v25; // edi@8
6074 int v26; // esi@8
6075 int *v27; // edi@10
6076 int v28; // esi@10
6077 int result; // eax@12
6078 __int64 v30; // [sp+A8h] [bp-30h]@8
6079 float v31; // [sp+B0h] [bp-28h]@6
6080 float v32; // [sp+B4h] [bp-24h]@6
6081 int v33; // [sp+B8h] [bp-20h]@6
6082 int v34; // [sp+BCh] [bp-1Ch]@2
6083 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1
6084 float v36; // [sp+C4h] [bp-14h]@6
6085 int v37; // [sp+C8h] [bp-10h]@6
6086 int v38; // [sp+CCh] [bp-Ch]@1
6087 float v39; // [sp+D0h] [bp-8h]@6
6088 int *v40; // [sp+D4h] [bp-4h]@2
6089
6090 v2 = (char *)&this->field_14[4 * this->field_10 + 20];
6091 v38 = 0;
6092 *(int *)v2 = this->field_14[20];
6093 v2 += 4;
6094 *(int *)v2 = this->field_14[21];
6095 v2 += 4;
6096 *(int *)v2 = this->field_14[22];
6097 *((int *)v2 + 1) = this->field_14[23];
6098 v3 = this->field_10;
6099 v35 = this;
6100 if ( v3 > 0 )
6101 {
6102 v40 = &this->field_14[40];
6103 v4 = (char *)&this->field_14[23] + 3;
6104 v34 = v3;
6105 while ( 1 )
6106 {
6107 v5 = v4 - 15;
6108 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
6109 goto LABEL_11;
6110 if ( *(float *)v5 <= (double)a2 )
6111 break;
6112 if ( *(float *)(v4 + 1) <= (double)a2 )
6113 {
6114 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
6115 v16 = (unsigned __int8)*v4;
6116 HIDWORD(v30) = LODWORD(a2);
6117 v17 = (unsigned __int8)v4[16] - v16;
6118 v36 = v15;
6119 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11);
6120 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7);
6121 v39 = (double)v17 * v15;
6122 v18 = v39 + 6.7553994e15;
6123 v19 = (unsigned __int8)*v4;
6124 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
6125 v20 = v39 + 6.7553994e15;
6126 v21 = (unsigned __int8)*(v4 - 2);
6127 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1);
6128 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36;
6129 v22 = v39 + 6.7553994e15;
6130 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2);
6131 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
6132 v24 = v39 + 6.7553994e15;
6133 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8);
6134 v25 = v40;
6135 *v40 = *(int *)v5;
6136 v26 = (int)(v5 + 4);
6137 ++v25;
6138 *v25 = *(int *)v26;
6139 v26 += 4;
6140 ++v25;
6141 ++v38;
6142 v40 += 4;
6143 *v25 = *(int *)v26;
6144 v25[1] = *(int *)(v26 + 4);
6145 goto LABEL_9;
6146 }
6147 LABEL_10:
6148 v27 = v40;
6149 ++v38;
6150 *v40 = *(int *)v5;
6151 v28 = (int)(v5 + 4);
6152 ++v27;
6153 *v27 = *(int *)v28;
6154 v28 += 4;
6155 ++v27;
6156 v40 += 4;
6157 *v27 = *(int *)v28;
6158 v27[1] = *(int *)(v28 + 4);
6159 LABEL_11:
6160 v4 += 16;
6161 --v34;
6162 if ( !v34 )
6163 goto LABEL_12;
6164 }
6165 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
6166 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
6167 v36 = v6;
6168 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
6169 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
6170 *(float *)&v37 = (double)v7 * v6;
6171 v8 = *(float *)&v37 + 6.7553994e15;
6172 v9 = (unsigned __int8)*v4;
6173 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
6174 v10 = *(float *)&v37 + 6.7553994e15;
6175 v11 = (unsigned __int8)*(v4 - 2);
6176 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
6177 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
6178 v12 = v39 + 6.7553994e15;
6179 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
6180 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
6181 v14 = v39 + 6.7553994e15;
6182 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
6183 LABEL_9:
6184 //this = v35;
6185 v5 = (char *)&v30 + 4;
6186 goto LABEL_10;
6187 }
6188 LABEL_12:
6189 result = v38;
6190 this->field_10 = v38;
6191 return result;
6192 }
6193
6194 //----- (00477927) --------------------------------------------------------
6195 int stru6_stru1_indoor_sw_billboard::_477927(float a2)
6196 {
6197 char *v2; // edi@1
6198 int v3; // eax@1
6199 char *v4; // edx@2
6200 char *v5; // esi@3
6201 double v6; // st7@6
6202 signed __int64 v7; // ST84_8@6
6203 double v8; // ST0C_8@6
6204 int v9; // esi@6
6205 double v10; // ST44_8@6
6206 int v11; // ecx@6
6207 double v12; // ST34_8@6
6208 int v13; // ecx@6
6209 double v14; // ST14_8@6
6210 double v15; // st7@8
6211 unsigned int v16; // ecx@8
6212 signed __int64 v17; // ST64_8@8
6213 double v18; // ST24_8@8
6214 int v19; // edi@8
6215 double v20; // ST3C_8@8
6216 int v21; // ecx@8
6217 double v22; // ST2C_8@8
6218 int v23; // ST9C_4@8
6219 double v24; // ST1C_8@8
6220 int *v25; // edi@8
6221 int v26; // esi@8
6222 int *v27; // edi@10
6223 int v28; // esi@10
6224 int result; // eax@12
6225 __int64 v30; // [sp+A8h] [bp-30h]@8
6226 float v31; // [sp+B0h] [bp-28h]@6
6227 float v32; // [sp+B4h] [bp-24h]@6
6228 int v33; // [sp+B8h] [bp-20h]@6
6229 int v34; // [sp+BCh] [bp-1Ch]@2
6230 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1
6231 float v36; // [sp+C4h] [bp-14h]@6
6232 int v37; // [sp+C8h] [bp-10h]@6
6233 int v38; // [sp+CCh] [bp-Ch]@1
6234 float v39; // [sp+D0h] [bp-8h]@6
6235 int *v40; // [sp+D4h] [bp-4h]@2
6236
6237 v2 = (char *)&this->field_14[4 * this->field_10 + 20];
6238 v38 = 0;
6239 *(int *)v2 = this->field_14[20];
6240 v2 += 4;
6241 *(int *)v2 = this->field_14[21];
6242 v2 += 4;
6243 *(int *)v2 = this->field_14[22];
6244 *((int *)v2 + 1) = this->field_14[23];
6245 v3 = this->field_10;
6246 v35 = this;
6247 if ( v3 > 0 )
6248 {
6249 v40 = &this->field_14[40];
6250 v4 = (char *)&this->field_14[23] + 3;
6251 v34 = v3;
6252 while ( 1 )
6253 {
6254 v5 = v4 - 15;
6255 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 )
6256 goto LABEL_11;
6257 if ( *(float *)v5 >= (double)a2 )
6258 break;
6259 if ( *(float *)(v4 + 1) >= (double)a2 )
6260 {
6261 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
6262 v16 = (unsigned __int8)*v4;
6263 HIDWORD(v30) = LODWORD(a2);
6264 v17 = (unsigned __int8)v4[16] - v16;
6265 v36 = v15;
6266 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11);
6267 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7);
6268 v39 = (double)v17 * v15;
6269 v18 = v39 + 6.7553994e15;
6270 v19 = (unsigned __int8)*v4;
6271 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
6272 v20 = v39 + 6.7553994e15;
6273 v21 = (unsigned __int8)*(v4 - 2);
6274 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1);
6275 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36;
6276 v22 = v39 + 6.7553994e15;
6277 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2);
6278 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
6279 v24 = v39 + 6.7553994e15;
6280 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8);
6281 v25 = v40;
6282 *v40 = *(int *)v5;
6283 v26 = (int)(v5 + 4);
6284 ++v25;
6285 *v25 = *(int *)v26;
6286 v26 += 4;
6287 ++v25;
6288 ++v38;
6289 v40 += 4;
6290 *v25 = *(int *)v26;
6291 v25[1] = *(int *)(v26 + 4);
6292 goto LABEL_9;
6293 }
6294 LABEL_10:
6295 v27 = v40;
6296 ++v38;
6297 *v40 = *(int *)v5;
6298 v28 = (int)(v5 + 4);
6299 ++v27;
6300 *v27 = *(int *)v28;
6301 v28 += 4;
6302 ++v27;
6303 v40 += 4;
6304 *v27 = *(int *)v28;
6305 v27[1] = *(int *)(v28 + 4);
6306 LABEL_11:
6307 v4 += 16;
6308 --v34;
6309 if ( !v34 )
6310 goto LABEL_12;
6311 }
6312 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
6313 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
6314 v36 = v6;
6315 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
6316 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
6317 *(float *)&v37 = (double)v7 * v6;
6318 v8 = *(float *)&v37 + 6.7553994e15;
6319 v9 = (unsigned __int8)*v4;
6320 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
6321 v10 = *(float *)&v37 + 6.7553994e15;
6322 v11 = (unsigned __int8)*(v4 - 2);
6323 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
6324 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
6325 v12 = v39 + 6.7553994e15;
6326 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
6327 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
6328 v14 = v39 + 6.7553994e15;
6329 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
6330 LABEL_9:
6331 //this = v35;
6332 v5 = (char *)&v30 + 4;
6333 goto LABEL_10;
6334 }
6335 LABEL_12:
6336 result = v38;
6337 this->field_10 = v38;
6338 return result;
6339 }
6340
6341 //----- (00477C61) --------------------------------------------------------
6342 int stru6_stru1_indoor_sw_billboard::sub_477C61()
6343 {
6344 stru6_stru1_indoor_sw_billboard *v1; // ebx@1
6345 int v2; // ecx@2
6346 int v3; // eax@3
6347 double v4; // st7@4
6348 double v5; // st7@5
6349 double v6; // st6@5
6350 double v7; // st5@6
6351 float v8; // ST30_4@8
6352 float v9; // ST24_4@8
6353 double v10; // st7@8
6354 double v11; // st6@8
6355 double v12; // st5@8
6356 float v13; // ST24_4@13
6357 int v14; // esi@13
6358 char *v15; // esi@15
6359 signed int v16; // eax@16
6360 __int16 v17; // fps@16
6361 unsigned __int8 v18; // c2@16
6362 unsigned __int8 v19; // c3@16
6363 double v20; // st6@16
6364 float v21; // ST18_4@17
6365 float v22; // ST2C_4@17
6366 float v23; // ST34_4@17
6367 float v24; // ST24_4@17
6368 double v25; // st7@17
6369 double v26; // st6@17
6370 float v27; // ST34_4@18
6371 float v28; // ST30_4@18
6372 int v29; // eax@19
6373 signed int v31; // [sp+8h] [bp-28h]@15
6374 float v32; // [sp+Ch] [bp-24h]@16
6375 float v33; // [sp+14h] [bp-1Ch]@16
6376 float v34; // [sp+18h] [bp-18h]@16
6377 float v35; // [sp+1Ch] [bp-14h]@17
6378 float v36; // [sp+20h] [bp-10h]@4
6379 float v37; // [sp+24h] [bp-Ch]@4
6380 float v38; // [sp+24h] [bp-Ch]@16
6381 float v39; // [sp+28h] [bp-8h]@9
6382 float v40; // [sp+28h] [bp-8h]@16
6383 float v41; // [sp+2Ch] [bp-4h]@6
6384 float v42; // [sp+2Ch] [bp-4h]@9
6385
6386 v1 = this;
6387 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
6388 {
6389 v2 = 0;
6390 if ( v1->field_10 > 0 )
6391 {
6392 v3 = (int)&v1->field_14[1];
6393 do
6394 {
6395 v4 = *(float *)(v3 - 4);
6396 LODWORD(v37) = *(int *)v3;
6397 LODWORD(v36) = *(int *)(v3 + 4);
6398 if ( pBLVRenderParams->sPartyRotX )
6399 {
6400 v5 = v4 - (double)pBLVRenderParams->vPartyPos.x;
6401 v6 = v37 - (double)pBLVRenderParams->vPartyPos.y;
6402 if ( pRenderer->pRenderD3D )
6403 {
6404 v41 = pBLVRenderParams->fSineY * v6 + pBLVRenderParams->fCosineY * v5;
6405 v7 = pBLVRenderParams->fSineY * v5 - pBLVRenderParams->fCosineY * v6;
6406 }
6407 else
6408 {
6409 v41 = pBLVRenderParams->fCosineY * v5 - pBLVRenderParams->fSineY * v6;
6410 v7 = pBLVRenderParams->fSineY * v5 + pBLVRenderParams->fCosineY * v6;
6411 }
6412 v8 = v7;
6413 v9 = v36 - (double)pBLVRenderParams->vPartyPos.z;
6414 v10 = pBLVRenderParams->fCosineNegX * v41 - pBLVRenderParams->fSineNegX * v9;
6415 v11 = v8;
6416 v12 = pBLVRenderParams->fCosineNegX * v9 + pBLVRenderParams->fSineNegX * v41;
6417 }
6418 else
6419 {
6420 v42 = v4 - (double)pBLVRenderParams->vPartyPos.x;
6421 v39 = v37 - (double)pBLVRenderParams->vPartyPos.y;
6422 if ( pRenderer->pRenderD3D )
6423 {
6424 v10 = pBLVRenderParams->fSineY * v39 + pBLVRenderParams->fCosineY * v42;
6425 v11 = pBLVRenderParams->fSineY * v42 - pBLVRenderParams->fCosineY * v39;
6426 }
6427 else
6428 {
6429 v10 = pBLVRenderParams->fCosineY * v42 - pBLVRenderParams->fSineY * v39;
6430 v11 = pBLVRenderParams->fSineY * v42 + pBLVRenderParams->fCosineY * v39;
6431 }
6432 v12 = v36 - (double)pBLVRenderParams->vPartyPos.z;
6433 }
6434 v13 = v12;
6435 ++v2;
6436 *(int *)(v3 + 84) = LODWORD(v13);
6437 v14 = *(int *)(v3 + 8);
6438 *(float *)(v3 + 76) = v10;
6439 *(int *)(v3 + 88) = v14;
6440 *(float *)(v3 + 80) = v11;
6441 v3 += 16;
6442 }
6443 while ( v2 < v1->field_10 );
6444 }
6445 }
6446 else
6447 {
6448 v15 = (char *)&this->field_14[1];
6449 v31 = 3;
6450 do
6451 {
6452 v40 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationX) * 0.0000152587890625;
6453 v32 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi)
6454 * 0.0000152587890625;
6455 v34 = (double)stru_5C6E00->SinCos(pIndoorCamera->sRotationY) * 0.0000152587890625;
6456 v16 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
6457 LODWORD(v38) = *(int *)v15;
6458 v33 = (double)v16 * 0.0000152587890625;
6459 //UNDEF(v17);
6460 v20 = *((float *)v15 - 1) - (double)pIndoorCamera->pos.x;
6461 if ( v19 | v18 )
6462 {
6463 v27 = v20;
6464 LODWORD(v35) = *((int *)v15 + 1);
6465 v28 = v38 - (double)pIndoorCamera->pos.y;
6466 v25 = v33 * v28 + v34 * v27;
6467 v26 = v34 * v28 - v33 * v27;
6468 }
6469 else
6470 {
6471 v21 = v20;
6472 v22 = v38 - (double)pIndoorCamera->pos.y;
6473 v23 = v33 * v22 + v34 * v21;
6474 v24 = *((float *)v15 + 1) - (double)pIndoorCamera->pos.z;
6475 v25 = v32 * v24 + v40 * v23;
6476 v26 = v34 * v22 - v33 * v21;
6477 v35 = v40 * v24 - v32 * v23;
6478 }
6479 *((int *)v15 + 21) = LODWORD(v35);
6480 v29 = *((int *)v15 + 2);
6481 *((float *)v15 + 19) = v25;
6482 *((int *)v15 + 22) = v29;
6483 *((float *)v15 + 20) = v26;
6484 v15 += 16;
6485 --v31;
6486 }
6487 while ( v31 );
6488 }
6489 v1->field_10 = 3;
6490 return 1;
6491 }
6492
6493 //----- (00477F63) --------------------------------------------------------
6494 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
6495 {
6496 signed int v1; // ebx@1
6497 stru6_stru1_indoor_sw_billboard *v2; // esi@1
6498 double v3; // st7@2
6499 int v4; // edx@4
6500 char *v5; // ecx@5
6501 int v6; // edi@5
6502 float v7; // ST08_4@13
6503 signed int v9; // [sp+Ch] [bp-8h]@1
6504 float v10; // [sp+10h] [bp-4h]@2
6505
6506 auto a1 = this;
6507
6508 v1 = 0;
6509 v2 = a1;
6510 v9 = 0;
6511 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
6512 {
6513 v10 = 16192.0;
6514 v3 = (double)pBLVRenderParams->field_40 * 0.000015258789;
6515 }
6516 else
6517 {
6518 v10 = (double)pOutdoorCamera->shading_dist_mist;
6519 v3 = 8.0;
6520 }
6521 v4 = a1->field_10;
6522 if ( v4 <= 0 )
6523 goto LABEL_16;
6524 v5 = (char *)&a1->field_14[20];
6525 v6 = v4;
6526 do
6527 {
6528 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 )
6529 {
6530 if ( v3 < *(float *)v5 )
6531 v9 = 1;
6532 else
6533 v1 = 1;
6534 }
6535 v5 += 16;
6536 --v6;
6537 }
6538 while ( v6 );
6539 if ( !v1 )
6540 {
6541 if ( v9 )
6542 {
6543 v2->_477927(v10);
6544 return v2->field_10 != 0;
6545 }
6546 LABEL_16:
6547 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
6548 return v2->field_10 != 0;
6549 }
6550 v7 = v3;
6551 _4775ED(v7);
6552 return v2->field_10 != 0;
6553 }
6554
6555 //----- (0047802A) --------------------------------------------------------
6556 int stru6_stru1_indoor_sw_billboard::sub_47802A()
6557 {
6558 int v1; // edx@1
6559 stru6_stru1_indoor_sw_billboard *v2; // edi@1
6560 int v3; // ebx@2
6561 char *v4; // esi@3
6562 float v5; // eax@4
6563 double v6; // st7@4
6564 double v7; // ST30_8@5
6565 double v8; // st6@6
6566 double v9; // st5@6
6567 char *v10; // ecx@15
6568 float v11; // eax@16
6569 double v12; // st7@16
6570 double v13; // st6@16
6571 double v14; // st5@16
6572 signed int v16; // [sp+38h] [bp-Ch]@1
6573 int a6; // [sp+3Ch] [bp-8h]@5
6574 int a5; // [sp+40h] [bp-4h]@5
6575
6576 auto a1 = this;
6577
6578 v1 = 0;
6579 v2 = a1;
6580 v16 = 0;
6581 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
6582 {
6583 v3 = 0;
6584 if ( a1->field_10 > 0 )
6585 {
6586 v4 = (char *)&a1->field_14[42];
6587 do
6588 {
6589 LODWORD(v5) = *((int *)v4 - 2);
6590 v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / *((float *)v4 - 2);
6591 if ( pRenderer->pRenderD3D )
6592 {
6593 v7 = v5 + 6.7553994e15;
6594 pGame->pIndoorCameraD3D->Project(
6595 COERCE_UNSIGNED_INT64(v5 + 6.7553994e15),
6596 COERCE_UNSIGNED_INT64(*((float *)v4 - 1) + 6.7553994e15),
6597 COERCE_UNSIGNED_INT64(*(float *)v4 + 6.7553994e15),
6598 &a5,
6599 &a6);
6600 *((float *)v4 + 18) = (double)a5;
6601 *((float *)v4 + 19) = (double)a6;
6602 *((float *)v4 + 20) = (double)SLODWORD(v7);
6603 }
6604 else
6605 {
6606 *((float *)v4 + 18) = (double)pBLVRenderParams->uViewportCenterX - v6 * *((float *)v4 - 1);
6607 v8 = (double)pBLVRenderParams->uViewportCenterY;
6608 v9 = v6 * *(float *)v4;
6609 *((int *)v4 + 20) = LODWORD(v5);
6610 *((float *)v4 + 19) = v8 - v9;
6611 }
6612 *((int *)v4 + 21) = *((int *)v4 + 1);
6613 if ( (double)(signed int)pViewport->uViewportX <= *((float *)v4 + 18)
6614 && (double)(signed int)pViewport->uViewportZ > *((float *)v4 + 18)
6615 && (double)(signed int)pViewport->uViewportY <= *((float *)v4 + 19)
6616 && (double)(signed int)pViewport->uViewportW > *((float *)v4 + 19) )
6617 v16 = 1;
6618 ++v3;
6619 v4 += 16;
6620 }
6621 while ( v3 < v2->field_10 );
6622 }
6623 }
6624 else
6625 {
6626 if ( a1->field_10 > 0 )
6627 {
6628 v10 = (char *)&a1->field_14[40];
6629 do
6630 {
6631 LODWORD(v11) = *(int *)v10;
6632 v12 = (double)pOutdoorCamera->int_fov_rad / *(float *)v10;
6633 *((float *)v10 + 20) = (double)pViewport->uScreenCenterX - v12 * *((float *)v10 + 1);
6634 v13 = (double)pViewport->uScreenCenterY;
6635 v14 = v12 * *((float *)v10 + 2);
6636 *((int *)v10 + 22) = LODWORD(v11);
6637 *((int *)v10 + 23) = *((int *)v10 + 3);
6638 *((float *)v10 + 21) = v13 - v14;
6639 if ( (double)(signed int)pViewport->uViewportX <= *((float *)v10 + 20)
6640 && (double)(signed int)pViewport->uViewportZ > *((float *)v10 + 20)
6641 && (double)(signed int)pViewport->uViewportY <= *((float *)v10 + 21)
6642 && (double)(signed int)pViewport->uViewportW > *((float *)v10 + 21) )
6643 v16 = 1;
6644 ++v1;
6645 v10 += 16;
6646 }
6647 while ( v1 < v2->field_10 );
6648 }
6649 }
6650 return v16;
6651 }
6652
6653
6654
6655 //----- (004783FA) --------------------------------------------------------
6656 void __cdecl sub_4783FA_construct_global_73D150()
6657 {
6658 char *v0; // eax@1
6659 signed int v1; // ecx@1
6660
6661 v0 = (char *)&array_73D150[0].flt_2C;
6662 v1 = 20;
6663 do
6664 {
6665 *(float *)v0 = 0.0;
6666 v0 += 48;
6667 --v1;
6668 }
6669 while ( v1 );
6670 }
6671
6672
6673
6674 //----- (0047840D) --------------------------------------------------------
6675 char Render::DrawBuildingsD3D()
6676 {
6677 IndoorCameraD3D *v0; // eax@3
6678 char result; // al@3
6679 Vec3_int_ **v2; // ebx@4
6680 Vec3_int_ *v3; // eax@6
6681 ODMFace *pFace; // esi@6
6682 int v5; // ecx@8
6683 int v6; // eax@8
6684 stru148 *v7; // ebx@8
6685 LightmapBuilder *v8; // eax@8
6686 int v9; // ecx@8
6687 char v10; // zf@8
6688 Texture *pFaceTexture; // eax@10
6689 signed int v12; // ecx@10
6690 unsigned int v13; // eax@14
6691 unsigned int v14; // eax@18
6692 unsigned int v15; // eax@22
6693 unsigned int v16; // edi@22
6694 int v17; // eax@24
6695 int v18; // edi@34
6696 char *v19; // eax@35
6697 char *v20; // ecx@35
6698 Vec3_int_ *v21; // edx@36
6699 int v22; // edx@36
6700 char *v23; // edi@37
6701 int v24; // eax@50
6702 int v25; // ecx@55
6703 int v26; // eax@57
6704 int v27; // eax@57
6705 int v28; // eax@58
6706 int v29; // edx@58
6707 double v30; // st7@59
6708 LightmapBuilder *v31; // edi@63
6709 signed int v32; // eax@73
6710 int v33; // eax@78
6711 unsigned int v34; // eax@80
6712 std::string v35; // [sp-18h] [bp-70h]@2
6713 int v36; // [sp-14h] [bp-6Ch]@69
6714 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69
6715 int v38; // [sp-Ch] [bp-64h]@69
6716 LightmapBuilder *v39; // [sp-8h] [bp-60h]@2
6717 int v40; // [sp-4h] [bp-5Ch]@2
6718 std::string *v41; // [sp+Ch] [bp-4Ch]@2
6719 Vec3_int_ *v42; // [sp+10h] [bp-48h]@6
6720 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8
6721 float v44; // [sp+18h] [bp-40h]@10
6722 float v45; // [sp+1Ch] [bp-3Ch]@10
6723 ODMFace *v46; // [sp+20h] [bp-38h]@6
6724 IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
6725 unsigned int v48; // [sp+28h] [bp-30h]@8
6726 int v49; // [sp+2Ch] [bp-2Ch]@10
6727 int v50; // [sp+30h] [bp-28h]@34
6728 int v51; // [sp+34h] [bp-24h]@35
6729 int v52; // [sp+38h] [bp-20h]@36
6730 int v53; // [sp+3Ch] [bp-1Ch]@8
6731 Vec3_int_ *v54; // [sp+40h] [bp-18h]@6
6732 int a1; // [sp+44h] [bp-14h]@3
6733 Vec3_int_ **v56; // [sp+48h] [bp-10h]@4
6734 int uNumVertices; // [sp+4Ch] [bp-Ch]@34
6735 int unused; // [sp+50h] [bp-8h]@3
6736 int a3; // [sp+57h] [bp-1h]@2
6737
6738 if ( !pRenderer->pRenderD3D )
6739 {
6740 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
6741 }
6742 unused = 0;
6743 v0 = pGame->pIndoorCameraD3D;
6744 a1 = 0;
6745 v47 = v0;
6746 result = LOBYTE(pOutdoor->pBModels);
6747 v41 = (std::string *)pOutdoor->uNumBModels;
6748 if ( (signed int)pOutdoor->uNumBModels > 0 )
6749 {
6750 v2 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces;
6751 v56 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces;
6752 while ( 1 )
6753 {
6754 if ( IsBModelVisible(a1, &unused) )
6755 {
6756 *(v2 - 3) = (Vec3_int_ *)((unsigned int)*(v2 - 3) | 1);
6757 v3 = *v2;
6758 pFace = (ODMFace *)v2[2];
6759 v54 = 0;
6760 v46 = pFace;
6761 v42 = v3;
6762 if ( (signed int)v3 > 0 )
6763 break;
6764 }
6765 LABEL_86:
6766 ++a1;
6767 v2 += 47;
6768 result = a1;
6769 v56 = v2;
6770 if ( a1 >= (signed int)v41 )
6771 return result;
6772 }
6773 while ( 1 )
6774 {
6775 if (pFace->Invisible())
6776 goto LABEL_85;
6777 v5 = (int)*(v2 - 1);
6778 v6 = pFace->pVertexIDs[0];
6779 v53 = 0;
6780 v7 = &array_77EC08[pOutdoorCamera->numStru148s];
6781 v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8);
6782 *(int *)&v7->flags = 0;
6783 pLightmapBuilder = v8;
6784 v9 = pFace->uTextureID;
6785 v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
6786 v48 = pFace->uTextureID;
6787 if ( !v10 )
6788 {
6789 v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
6790 v9 = v48;
6791 }
6792 pFaceTexture = (Texture *)(v9 != -1 ? (int)&pBitmaps_LOD->pTextures[v9] : 0);
6793 v7->pTexture = pFaceTexture;
6794 v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
6795 v49 = v12;
6796 v49 = pFaceTexture->uTextureHeight;
6797 v10 = (pFace->uAttributes & 0x10) == 0;
6798 v45 = 1.0 / (double)v12;
6799 v44 = 1.0 / (double)v49;
6800 if ( !v10 )
6801 *(int *)&v7->flags |= 2u;
6802 if ( BYTE2(pFace->uAttributes) & 0x40 )
6803 HIBYTE(v7->flags) |= 4u;
6804 v13 = pFace->uAttributes;
6805 if ( v13 & 4 )
6806 {
6807 HIBYTE(v7->flags) |= 4u;
6808 }
6809 else
6810 {
6811 if ( v13 & 0x20 )
6812 HIBYTE(v7->flags) |= 8u;
6813 }
6814 v14 = pFace->uAttributes;
6815 if ( BYTE1(v14) & 8 )
6816 {
6817 *(int *)&v7->flags |= 0x2000u;
6818 }
6819 else
6820 {
6821 if ( v14 & 0x40 )
6822 HIBYTE(v7->flags) |= 0x10u;
6823 }
6824 v15 = GetTickCount();
6825 v7->sTextureDeltaU = pFace->sTextureDeltaU;
6826 v7->sTextureDeltaV = pFace->sTextureDeltaV;
6827 v16 = v15 >> 4;
6828 if ( pFace->pFacePlane.vNormal.z && (v40 = pFace->pFacePlane.vNormal.z, abs(v40) >= 59082) )
6829 {
6830 v17 = *(int *)&v7->flags;
6831 if ( BYTE1(v17) & 4 )
6832 goto LABEL_29;
6833 if ( BYTE1(v17) & 8 )
6834 {
6835 LABEL_26:
6836 v7->sTextureDeltaV -= v16 & v7->pTexture->uHeightMinus1;
6837 goto LABEL_30;
6838 }
6839 }
6840 else
6841 {
6842 v17 = *(int *)&v7->flags;
6843 if ( BYTE1(v17) & 4 )
6844 goto LABEL_26;
6845 if ( BYTE1(v17) & 8 )
6846 {
6847 LABEL_29:
6848 v7->sTextureDeltaV += v16 & v7->pTexture->uHeightMinus1;
6849 goto LABEL_30;
6850 }
6851 }
6852 LABEL_30:
6853 if ( BYTE1(v17) & 0x10 )
6854 {
6855 v7->sTextureDeltaU -= v16 & v7->pTexture->uWidthMinus1;
6856 }
6857 else
6858 {
6859 if ( BYTE1(v17) & 0x20 )
6860 v7->sTextureDeltaU += v16 & v7->pTexture->uWidthMinus1;
6861 }
6862 v18 = pFace->uNumVertices;
6863 v50 = 0;
6864 v49 = 0;
6865 uNumVertices = v18;
6866 if ( v18 > 0 )
6867 {
6868 v19 = (char *)&array_73D150[0].vWorldPosition.z;
6869 v20 = (char *)pFace->pTextureUIDs;
6870 v51 = v18;
6871 do
6872 {
6873 v21 = &(*(v56 - 1))[*((short *)v20 - 20)];
6874 *((float *)v19 - 2) = (double)v21->x;
6875 *((float *)v19 - 1) = (double)v21->y;
6876 *(float *)v19 = (double)v21->z;
6877 v19 += 48;
6878 v52 = v7->sTextureDeltaU + *(short *)v20;
6879 *((float *)v19 - 5) = (double)v52 * v45;
6880 v22 = v7->sTextureDeltaV + *((short *)v20 + 20);
6881 v20 += 2;
6882 v10 = v51-- == 1;
6883 v52 = v22;
6884 *((float *)v19 - 4) = (double)v22 * v44;
6885 }
6886 while ( !v10 );
6887 v23 = (char *)&array_73D150[0].vWorldViewPosition;
6888 v51 = uNumVertices;
6889 *(float *)&pLightmapBuilder = (double)(signed int)pLightmapBuilder;
6890 do
6891 {
6892 if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) )
6893 ++v53;
6894 v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u);
6895 if ( *(float *)v23 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v23 )
6896 {
6897 if ( *(float *)v23 >= 8.0 )
6898 v49 = 1;
6899 else
6900 v50 = 1;
6901 }
6902 else
6903 {
6904 v47->Project((RenderVertexSoft *)(v23 - 12), 1u, 0);
6905 }
6906 v23 += 48;
6907 --v51;
6908 }
6909 while ( v51 );
6910 v18 = uNumVertices;
6911 }
6912 if ( v53 == v18 )
6913 LOBYTE(v7->field_32) |= 1u;
6914 v24 = pOutdoor->vSunlight.x;
6915 v7->pODMFace = pFace;
6916 v7->uNumVertices = v18;
6917 v7->field_59 = 5;
6918 pLightmapBuilder = (LightmapBuilder *)-v24;
6919 v51 = pFace->pFacePlane.vNormal.x;
6920 v51 = (unsigned __int64)(-v24 * (signed __int64)v51) >> 16;
6921 v53 = pFace->pFacePlane.vNormal.y;
6922 pLightmapBuilder = (LightmapBuilder *)-pOutdoor->vSunlight.y;
6923 v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)v53) >> 16;
6924 v52 = pFace->pFacePlane.vNormal.z;
6925 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16;
6926 pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52);
6927 v51 = 20 * (int)pLightmapBuilder;
6928 result = 20 - (20 * (signed int)pLightmapBuilder >> 16);
6929 v7->field_58 = result;
6930 if ( result < 0 )
6931 v7->field_58 = 0;
6932 if ( v7->field_58 > 31 )
6933 v7->field_58 = 31;
6934 if ( pOutdoorCamera->numStru148s >= 1999 )
6935 return result;
6936 ++pOutdoorCamera->numStru148s;
6937 ++pOutdoorCamera->field_44;
6938 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) )
6939 {
6940 LOBYTE(v25) = (char)v54;
6941 v26 = a1;
6942 pFace->bVisible = 1;
6943 v7->uBModelFaceID = v25;
6944 LOWORD(v25) = (unsigned __int8)v25;
6945 v7->uBModelID = v26;
6946 v27 = 8 * (v25 | (v26 << 6));
6947 LOBYTE(v27) = v27 | 6;
6948 v7->field_50 = v27;
6949 if ( v18 > 0 )
6950 {
6951 v28 = 0;
6952 v29 = v18;
6953 do
6954 {
6955 v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
6956 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28]));
6957 ++v28;
6958 --v29;
6959 array_50A2B0[v28 + 49].flt_20 = v30;
6960 }
6961 while ( v29 );
6962 pFace = v46;
6963 }
6964
6965 static stru154 static_RenderBuildingsD3D_stru_73C834;
6966 /*static bool __init_flag = false;
6967 if (!__init_flag)
6968 {
6969 __init_flag = true;
6970
6971 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u;
6972 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834);
6973 atexit(loc_4789D4);
6974 }*/
6975
6976 v40 = (int)pFace;
6977 pLightmapBuilder = pGame->pLightmapBuilder;
6978 v31 = pLightmapBuilder;
6979 pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
6980 pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
6981 v31->std__vector_000004_size = 0;
6982 LOBYTE(v31) = 0;
6983 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
6984 {
6985 v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0);
6986 static_RenderBuildingsD3D_stru_73C834._49B04D(pFace, (BSPVertexBuffer *)v56 - 1);
6987 if ( pDecalBuilder->uNumDecals > 0 )
6988 {
6989 v40 = -1;
6990 v39 = v31;
6991 v38 = 0;
6992 v37 = array_50AC10;
6993 v36 = uNumVertices;
6994 pDecalBuilder->ApplyDecals(
6995 31 - v7->field_58,
6996 2,
6997 &static_RenderBuildingsD3D_stru_73C834,
6998 uNumVertices,
6999 array_50AC10,
7000 0,
7001 (char)v31,
7002 -1);
7003 }
7004 }
7005 if ( stru_F8AD28.uNumLightsApplied > 0 )
7006 pLightmapBuilder->ApplyLights(
7007 &stru_F8AD28,
7008 &static_RenderBuildingsD3D_stru_73C834,
7009 uNumVertices,
7010 array_50AC10,
7011 0,
7012 (char)v31);
7013 if ( v50 )
7014 {
7015 v32 = sr_424CD7(uNumVertices);
7016 goto LABEL_76;
7017 }
7018 if ( v49 )
7019 {
7020 v32 = sr_424EE0_MakeFanFromTriangle(uNumVertices);
7021 LABEL_76:
7022 v7->uNumVertices = v32;
7023 uNumVertices = v32;
7024 OutdoorCamera::Project(v32);
7025 }
7026 if ( uNumVertices )
7027 {
7028 v33 = *(int *)&v7->flags;
7029 if ( v33 & 2 )
7030 {
7031 if ( BYTE1(v33) & 0x3C )
7032 v34 = pRenderer->pHDWaterBitmapIDs[0];
7033 else
7034 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
7035 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34];
7036 }
7037 else
7038 {
7039 v40 = (int)pBitmaps_LOD->pHardwareTextures[v48];
7040 }
7041 pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40);
7042 }
7043 goto LABEL_85;
7044 }
7045 --pOutdoorCamera->numStru148s;
7046 --pOutdoorCamera->field_44;
7047 LABEL_85:
7048 v54 = (Vec3_int_ *)((char *)v54 + 1);
7049 v2 = v56;
7050 ++pFace;
7051 v46 = pFace;
7052 if ( (signed int)v54 >= (signed int)v42 )
7053 goto LABEL_86;
7054 }
7055 }
7056 return result;
7057 }
7058 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag;
7059
7060 //----- (004789DE) --------------------------------------------------------
7061 BSPModel *Render::DrawBuildingsSW()
7062 {
7063 BSPModel *result; // eax@1
7064 unsigned int *v1; // ebx@2
7065 int v2; // eax@4
7066 int v3; // edi@4
7067 int v4; // ecx@6
7068 int v5; // eax@6
7069 int v6; // ecx@6
7070 int v7; // ecx@6
7071 double v8; // st7@7
7072 char *v9; // ebx@7
7073 int v10; // eax@9
7074 double v11; // st7@9
7075 stru148 *v12; // ebx@19
7076 double v13; // st7@21
7077 double v14; // ST4C_8@23
7078 int v15; // eax@23
7079 int v16; // eax@27
7080 int v17; // ecx@29
7081 unsigned __int8 v18; // sf@29
7082 unsigned __int8 v19; // of@29
7083 int v20; // ecx@30
7084 int v21; // eax@31
7085 int v22; // eax@31
7086 int v23; // eax@35
7087 int v24; // eax@39
7088 Texture *v25; // eax@43
7089 int v26; // esi@43
7090 signed int v27; // ecx@43
7091 double v28; // st6@43
7092 double v29; // st5@43
7093 int v30; // edx@44
7094 int v31; // eax@44
7095 double v32; // st4@45
7096 int v33; // ecx@45
7097 char v34; // zf@45
7098 BSPVertexBuffer *v35; // eax@50
7099 unsigned int v36; // eax@53
7100 signed int v37; // esi@53
7101 int v38; // eax@54
7102 signed int v39; // edx@55
7103 char *v40; // ecx@56
7104 double v41; // ST1C_8@57
7105 double v42; // ST24_8@57
7106 signed int v43; // eax@60
7107 signed int v44; // esi@60
7108 int v45; // eax@61
7109 signed int v46; // edx@62
7110 char *v47; // ecx@63
7111 double v48; // ST34_8@64
7112 double v49; // ST44_8@64
7113 int v50; // eax@66
7114 signed int v51; // ecx@67
7115 char *v52; // edx@68
7116 double v53; // ST3C_8@69
7117 double v54; // ST2C_8@69
7118 float v55; // [sp+44h] [bp-7Ch]@50
7119 float v56; // [sp+48h] [bp-78h]@50
7120 float v57; // [sp+4Ch] [bp-74h]@50
7121 float v58; // [sp+50h] [bp-70h]@64
7122 int v59; // [sp+54h] [bp-6Ch]@64
7123 int v60; // [sp+58h] [bp-68h]@69
7124 float v61; // [sp+5Ch] [bp-64h]@64
7125 float v62; // [sp+60h] [bp-60h]@69
7126 float v63; // [sp+64h] [bp-5Ch]@57
7127 float v64; // [sp+68h] [bp-58h]@57
7128 int v65; // [sp+6Ch] [bp-54h]@64
7129 int v66; // [sp+70h] [bp-50h]@1
7130 int v67; // [sp+74h] [bp-4Ch]@6
7131 int v68; // [sp+78h] [bp-48h]@4
7132 int v69; // [sp+7Ch] [bp-44h]@57
7133 int v70; // [sp+80h] [bp-40h]@69
7134 int v71; // [sp+84h] [bp-3Ch]@23
7135 float v72; // [sp+88h] [bp-38h]@69
7136 int v73; // [sp+8Ch] [bp-34h]@57
7137 int v74; // [sp+90h] [bp-30h]@6
7138 int v75; // [sp+94h] [bp-2Ch]@6
7139 int v76; // [sp+98h] [bp-28h]@4
7140 int v77; // [sp+9Ch] [bp-24h]@6
7141 unsigned int *v78; // [sp+A0h] [bp-20h]@2
7142 int v79; // [sp+A4h] [bp-1Ch]@4
7143 int a1; // [sp+A8h] [bp-18h]@1
7144 int v81; // [sp+ACh] [bp-14h]@7
7145 int v82; // [sp+B0h] [bp-10h]@6
7146 int v83; // [sp+B4h] [bp-Ch]@6
7147 signed int v84; // [sp+B8h] [bp-8h]@7
7148 int a2; // [sp+BCh] [bp-4h]@1
7149
7150 a2 = 0;
7151 a1 = 0;
7152 result = pOutdoor->pBModels;
7153 v66 = pOutdoor->uNumBModels;
7154 if ( (signed int)pOutdoor->uNumBModels > 0 )
7155 {
7156 v1 = &pOutdoor->pBModels->uNumFaces;
7157 v78 = &pOutdoor->pBModels->uNumFaces;
7158 while ( 1 )
7159 {
7160 if ( IsBModelVisible(a1, &a2) )
7161 {
7162 *(v1 - 3) |= 1u;
7163 v2 = *v1;
7164 v3 = v1[2];
7165 v79 = 0;
7166 v76 = v3;
7167 v68 = v2;
7168 if ( v2 > 0 )
7169 break;
7170 }
7171 LABEL_73:
7172 ++a1;
7173 v1 += 47;
7174 result = (BSPModel *)a1;
7175 v78 = v1;
7176 if ( a1 >= v66 )
7177 return result;
7178 }
7179 while ( 1 )
7180 {
7181 if ( !(*(char *)(v3 + 29) & 0x20) )
7182 {
7183 v4 = 3 * *(short *)(v3 + 32);
7184 v5 = (int)(v1 - 2);
7185 v67 = (int)(v1 - 2);
7186 v6 = *(int *)(*(v1 - 1) + 4 * v4 + 8) + 4;
7187 v82 = 0;
7188 v83 = v6;
7189 v74 = 0;
7190 v7 = *(char *)(v3 + 302);
7191 v75 = 0;
7192 v77 = v7;
7193 if ( v7 > 0 )
7194 {
7195 v8 = (double)v83;
7196 v9 = (char *)&array_73D150[0].vWorldViewPosition;
7197 v81 = v3 + 32;
7198 v83 = v7;
7199 *(float *)&v84 = v8;
7200 while ( 1 )
7201 {
7202 v10 = *(int *)(v5 + 4) + 12 * *(short *)v81;
7203 *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0;
7204 *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0;
7205 v11 = (double)*(signed int *)(v10 + 8) + 4.0;
7206 *((float *)v9 - 1) = v11;
7207 if ( *(float *)&v84 == v11 )
7208 ++v82;
7209 pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u);
7210 if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 )
7211 {
7212 if ( *(float *)v9 >= 8.0 )
7213 v75 = 1;
7214 else
7215 v74 = 1;
7216 }
7217 else
7218 {
7219 pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0);
7220 }
7221 v81 += 2;
7222 v9 += 48;
7223 --v83;
7224 if ( !v83 )
7225 break;
7226 v5 = v67;
7227 }
7228 v7 = v77;
7229 }
7230 v12 = &array_77EC08[pOutdoorCamera->numStru148s];
7231 *(int *)&v12->flags = 0;
7232 if ( v82 == v7 )
7233 *(int *)&v12->flags = 65536;
7234 v12->pODMFace = (ODMFace *)v3;
7235 v12->uNumVertices = v7;
7236 v12->field_59 = 5;
7237 v84 = *(int *)v3;
7238 v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
7239 v82 = -pOutdoor->vSunlight.y;
7240 v84 = *(int *)(v3 + 4);
7241 v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
7242 v81 = -pOutdoor->vSunlight.z;
7243 v84 = *(int *)(v3 + 8);
7244 v81 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16;
7245 v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
7246 v13 = (double)v84 * 0.000015258789;
7247 if ( v13 < 0.0 )
7248 v13 = 0.0;
7249 *(float *)&v84 = v13 * 31.0;
7250 v14 = *(float *)&v84 + 6.7553994e15;
7251 v71 = LODWORD(v14);
7252 v15 = (int)&v12->field_58;
7253 v12->field_58 = 31 - LOBYTE(v14);
7254 if ( (char)(31 - LOBYTE(v14)) < 0 )
7255 *(char *)v15 = 0;
7256 if ( *(char *)v15 > 31 )
7257 *(char *)v15 = 31;
7258 v16 = *(short *)(v3 + 272);
7259 if ( *(char *)(v3 + 29) & 0x40 )
7260 v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
7261 v17 = v16;
7262 result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
7263 v19 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
7264 v18 = pOutdoorCamera->numStru148s - 1999 < 0;
7265 v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0);
7266 if ( !(v18 ^ v19) )
7267 return result;
7268 ++pOutdoorCamera->numStru148s;
7269 ++pOutdoorCamera->field_44;
7270 if ( !ODMFace::IsBackfaceCulled((ODMFace *)v3, array_73D150, v12) )
7271 {
7272 LABEL_71:
7273 --pOutdoorCamera->numStru148s;
7274 --pOutdoorCamera->field_44;
7275 goto LABEL_72;
7276 }
7277 LOBYTE(v20) = v79;
7278 v21 = a1;
7279 *(char *)(v3 + 305) = 1;
7280 v12->uBModelFaceID = v20;
7281 LOWORD(v20) = (unsigned __int8)v20;
7282 v12->uBModelID = v21;
7283 v22 = 8 * (v20 | (v21 << 6));
7284 LOBYTE(v22) = v22 | 6;
7285 v12->field_50 = v22;
7286 if ( *(char *)(v3 + 28) & 0x10 )
7287 *(int *)&v12->flags |= 2u;
7288 if ( *(char *)(v3 + 30) & 0x40 )
7289 HIBYTE(v12->flags) |= 4u;
7290 v23 = *(int *)(v3 + 28);
7291 if ( v23 & 4 )
7292 {
7293 HIBYTE(v12->flags) |= 4u;
7294 }
7295 else
7296 {
7297 if ( v23 & 0x20 )
7298 HIBYTE(v12->flags) |= 8u;
7299 }
7300 v24 = *(int *)(v3 + 28);
7301 if ( BYTE1(v24) & 8 )
7302 {
7303 HIBYTE(v12->flags) |= 0x20u;
7304 }
7305 else
7306 {
7307 if ( v24 & 0x40 )
7308 HIBYTE(v12->flags) |= 0x10u;
7309 }
7310 v25 = v12->pTexture;
7311 v26 = v77;
7312 v27 = v25->uTextureWidth;
7313 v84 = v25->uTextureHeight;
7314 v28 = 1.0 / (double)v27;
7315 v29 = 1.0 / (double)v84;
7316 if ( v77 > 0 )
7317 {
7318 v30 = v3 + 112;
7319 v31 = 0;
7320 v83 = v77;
7321 do
7322 {
7323 v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001);
7324 memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31]));
7325 ++v31;
7326 array_50A2B0[v31 + 49].flt_20 = v32;
7327 v84 = v12->sTextureDeltaU + *(short *)(v30 - 40);
7328 array_50A2B0[v31 + 49].u = (double)v84 * v28;
7329 v33 = v12->sTextureDeltaV + *(short *)v30;
7330 v30 += 2;
7331 v34 = v83-- == 1;
7332 v84 = v33;
7333 array_50A2B0[v31 + 49].v = (double)v33 * v29;
7334 }
7335 while ( !v34 );
7336 v3 = v76;
7337 v26 = v77;
7338 }
7339
7340 static stru154 static_sub_004789DE_stru_73C818; // idb
7341 /*static bool __init_flag = false;
7342 if (!__init_flag)
7343 {
7344 __init_flag = true;
7345
7346 static_sub_004789DE_byte_73C830__init_flag |= 1u;
7347 stru154::stru154(&static_sub_004789DE_stru_73C818);
7348 }*/
7349
7350 pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
7351 if ( stru_F8AD28.uNumLightsApplied <= 0 )
7352 {
7353 v12->field_108 = 0;
7354 }
7355 else
7356 {
7357 v35 = (BSPVertexBuffer *)(v78 - 2);
7358 v12->field_108 = 1;
7359
7360 static_sub_004789DE_stru_73C818._49B04D((ODMFace *)v3, v35);
7361 v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x;
7362 v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y;
7363 v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z;
7364 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
7365 }
7366 if ( v74 )
7367 {
7368 v36 = sr_4250FE(v26);
7369 v37 = v36;
7370 if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) )
7371 goto LABEL_71;
7372 v12->_48276F_sr();
7373 v39 = 0;
7374 if ( (signed int)v12->uNumVertices > 0 )
7375 {
7376 v40 = (char *)&array_508690[0].vWorldViewProjY;
7377 do
7378 {
7379 LODWORD(v64) = *((int *)v40 - 1);
7380 v41 = v64 + 6.7553994e15;
7381 v69 = LODWORD(v41);
7382 dword_50B638[v39] = LODWORD(v41);
7383 LODWORD(v63) = *(int *)v40;
7384 v42 = v63 + 6.7553994e15;
7385 v73 = LODWORD(v42);
7386 v40 += 48;
7387 dword_50B570[v39++] = LODWORD(v42);
7388 }
7389 while ( v39 < (signed int)v12->uNumVertices );
7390 }
7391 }
7392 else
7393 {
7394 if ( v75 )
7395 {
7396 v43 = sr_4252E8(v26);
7397 v44 = v43;
7398 if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) )
7399 goto LABEL_71;
7400 v12->_48276F_sr();
7401 v46 = 0;
7402 if ( (signed int)v12->uNumVertices > 0 )
7403 {
7404 v47 = (char *)&array_508690[0].vWorldViewProjY;
7405 do
7406 {
7407 LODWORD(v61) = *((int *)v47 - 1);
7408 v48 = v61 + 6.7553994e15;
7409 v65 = LODWORD(v48);
7410 dword_50B638[v46] = LODWORD(v48);
7411 LODWORD(v58) = *(int *)v47;
7412 v49 = v58 + 6.7553994e15;
7413 v59 = LODWORD(v49);
7414 v47 += 48;
7415 dword_50B570[v46++] = LODWORD(v49);
7416 }
7417 while ( v46 < (signed int)v12->uNumVertices );
7418 }
7419 }
7420 else
7421 {
7422 v50 = sr_4254D2(v26);
7423 v12->uNumVertices = v50;
7424 if ( !v50 )
7425 goto LABEL_71;
7426 sr_sub_4829B9(
7427 &array_73D150[*(char *)(v3 + 298)],
7428 &array_73D150[*(char *)(v3 + 299)],
7429 &array_73D150[*(char *)(v3 + 300)],
7430 v12,
7431 0);
7432 v51 = 0;
7433 if ( (signed int)v12->uNumVertices > 0 )
7434 {
7435 v52 = (char *)&array_508690[0].vWorldViewProjY;
7436 do
7437 {
7438 LODWORD(v62) = *((int *)v52 - 1);
7439 v53 = v62 + 6.7553994e15;
7440 v60 = LODWORD(v53);
7441 dword_50B638[v51] = LODWORD(v53);
7442 LODWORD(v72) = *(int *)v52;
7443 v54 = v72 + 6.7553994e15;
7444 v70 = LODWORD(v54);
7445 v52 += 48;
7446 dword_50B570[v51++] = LODWORD(v54);
7447 }
7448 while ( v51 < (signed int)v12->uNumVertices );
7449 }
7450 }
7451 }
7452 sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638, dword_50B570, v12);
7453 }
7454 LABEL_72:
7455 ++v79;
7456 v1 = v78;
7457 v3 += 308;
7458 v76 = v3;
7459 if ( v79 >= v68 )
7460 goto LABEL_73;
7461 }
7462 }
7463 return result;
7464 }
7465 // 50B570: using guessed type int dword_50B570[];
7466 // 50B638: using guessed type int dword_50B638[];
7467 // 73C830: using guessed type char static_sub_004789DE_byte_73C830__init_flag;
7468
7469 //----- (00479089) --------------------------------------------------------
7470 bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused)
7471 {
7472 BSPModel *v2; // eax@1
7473 int v3; // edi@1
7474 int v4; // ebx@1
7475 int v5; // ST28_4@1
7476 int v6; // ecx@1
7477 int v7; // ebx@3
7478 int v8; // eax@3
7479 int v9; // eax@3
7480 int v10; // ebx@3
7481 signed int v11; // esi@6
7482 int v12; // esi@8
7483 bool result; // eax@9
7484 unsigned int v14; // [sp+Ch] [bp-20h]@1
7485 int v15; // [sp+Ch] [bp-20h]@5
7486 int *v16; // [sp+10h] [bp-1Ch]@1
7487 int v17; // [sp+1Ch] [bp-10h]@1
7488 int v18; // [sp+20h] [bp-Ch]@1
7489 int v19; // [sp+20h] [bp-Ch]@3
7490 int angle; // [sp+24h] [bp-8h]@1
7491 int v21; // [sp+28h] [bp-4h]@1
7492 int v22; // [sp+28h] [bp-4h]@3
7493
7494 v16 = unused;
7495 angle = (signed int)(pOutdoorCamera->uCameraFovInDegrees << 11) / 360 >> 1;
7496 v14 = uModelID;
7497 v2 = &pOutdoor->pBModels[uModelID];
7498 v3 = v2->vBoundingCenter.x - pIndoorCamera->pos.x;
7499 v4 = v2->vBoundingCenter.y - pIndoorCamera->pos.y;
7500 v5 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
7501 v21 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
7502 v18 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX);
7503 stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi);
7504 v6 = v5;
7505 v17 = v3 * v5 + v4 * v21;
7506 if ( pIndoorCamera->sRotationX )
7507 v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16;
7508 v19 = v4 * v6 - v3 * v21;
7509 v7 = abs(v4);
7510 v8 = abs(v3);
7511 v9 = sub_4621DA(v8, v7, 0);
7512 v10 = v14 * 188;
7513 v22 = v9;
7514 *v16 = 0;
7515 if ( v9 < pOutdoor->pBModels[v14].sBoundingRadius + 256 )
7516 *v16 = 1;
7517 v15 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
7518 if ( v19 >= 0 )
7519 v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16)
7520 - ((unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)v19) >> 16);
7521 else
7522 v11 = ((unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)v19) >> 16)
7523 + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16);
7524 v12 = v11 >> 16;
7525 if ( v22 <= pOutdoorCamera->shading_dist_mist + 2048 )
7526 {
7527 if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 )
7528 {
7529 result = v12 < 0;
7530 LOBYTE(result) = v12 >= 0;
7531 }
7532 else
7533 {
7534 result = 1;
7535 }
7536 }
7537 else
7538 {
7539 result = 0;
7540 }
7541 return result;
7542 }
7543
7544
7545
7546
7547 //----- (00479295) --------------------------------------------------------
7548 int stru148::_479295()
7549 {
7550 stru148 *v1; // edi@1
7551 ODMFace *v2; // esi@1
7552 int v3; // ecx@4
7553 int v4; // eax@4
7554 int v5; // edx@4
7555 int v6; // ST14_4@5
7556 int v7; // ST04_4@5
7557 stru149 *v8; // ecx@5
7558 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
7559 int v11; // [sp+18h] [bp-4h]@4
7560
7561 v1 = this;
7562 v2 = this->pODMFace;
7563 if ( !v2->pFacePlane.vNormal.z )
7564 {
7565 v3 = v2->pFacePlane.vNormal.x;
7566 v4 = -v2->pFacePlane.vNormal.y;
7567 LABEL_9:
7568 v5 = 0;
7569 v11 = 65536;
7570 goto LABEL_5;
7571 }
7572 if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
7573 {
7574 thisa.x = -v2->pFacePlane.vNormal.y;
7575 thisa.y = v2->pFacePlane.vNormal.x;
7576 thisa.z = 0;
7577 thisa.Normalize_float();
7578 v4 = thisa.x;
7579 v3 = thisa.y;
7580 goto LABEL_9;
7581 }
7582 v3 = 0;
7583 v4 = 65536;
7584 v11 = 0;
7585 v5 = -65536;
7586 LABEL_5:
7587 v6 = v11;
7588 v1->sTextureDeltaU = v2->sTextureDeltaU;
7589 v7 = v3;
7590 v8 = v1->ptr_38;
7591 v1->sTextureDeltaV = v2->sTextureDeltaV;
7592 v8->_48616B(v4, v7, 0, 0, v5, v6);
7593 return 1;
7594 }
7595
7596 //----- (00479332) --------------------------------------------------------
7597 int Render::OnOutdoorRedrawSW()
7598 {
7599 signed int result; // eax@1
7600 unsigned int v1; // edi@1
7601 char *v2; // esi@2
7602 char v3; // cl@3
7603 double v4; // st7@4
7604 float v5; // ST34_4@6
7605 double v6; // ST24_8@6
7606 int v7; // eax@6
7607 unsigned int v8; // eax@11
7608 signed int v9; // eax@13
7609 Vec3_float_ *v10; // eax@14
7610 double v11; // st7@17
7611 float v12; // ST34_4@19
7612 double v13; // ST1C_8@19
7613 float v14; // [sp+4h] [bp-34h]@1
7614 float v15; // [sp+8h] [bp-30h]@1
7615 float v16; // [sp+Ch] [bp-2Ch]@1
7616
7617 v14 = (double)pOutdoor->vSunlight.x * 0.000015258789;
7618 result = 0;
7619 v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s];
7620 v15 = (double)pOutdoor->vSunlight.y * 0.000015258789;
7621 v16 = (double)pOutdoor->vSunlight.z * 0.000015258789;
7622 if ( v1 > (unsigned int)array_77EC08 )
7623 {
7624 v2 = (char *)&array_77EC08[0].pODMFace;
7625 while ( 1 )
7626 {
7627 v3 = v2[5];
7628 if ( v3 == 5 )
7629 break;
7630 if ( v3 == 1 )
7631 {
7632 v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1)
7633 + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))];
7634 if ( v9 > (signed int)(uNumTerrainNormals - 1) )
7635 v10 = 0;
7636 else
7637 v10 = &pTerrainNormals[v9];
7638 if ( v10 )
7639 {
7640 v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x);
7641 if ( v11 < 0.0 )
7642 v11 = 0.0;
7643 v12 = v11 * 31.0;
7644 v13 = v12 + 6.7553994e15;
7645 v2[4] = 31 - LOBYTE(v13);
7646 }
7647 else
7648 {
7649 v2[4] = 0;
7650 }
7651 if ( v2[4] < 0 )
7652 v2[4] = 0;
7653 goto LABEL_23;
7654 }
7655 LABEL_24:
7656 v2 += 268;
7657 if ( (unsigned int)(v2 - 84) >= v1 )
7658 return result;
7659 }
7660 v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16)
7661 + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16)
7662 + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16))
7663 * 0.000015258789;
7664 if ( v4 < 0.0 )
7665 v4 = 0.0;
7666 v5 = v4 * 31.0;
7667 v6 = v5 + 6.7553994e15;
7668 v7 = (int)(v2 + 4);
7669 v2[4] = 31 - LOBYTE(v6);
7670 if ( (char)(31 - LOBYTE(v6)) < 0 )
7671 *(char *)v7 = 0;
7672 if ( *(char *)v7 > 31 )
7673 *(char *)v7 = 31;
7674 if ( *(char *)(*(int *)v2 + 29) & 0x40 )
7675 {
7676 v8 = pTextureFrameTable->GetFrameTexture(
7677 *((short *)v2 - 4),
7678 pEventTimer->uTotalGameTimeElapsed);
7679 *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0;
7680 }
7681 LABEL_23:
7682 result = 1;
7683 goto LABEL_24;
7684 }
7685 return result;
7686 }
7687
7688 //----- (00479543) --------------------------------------------------------
7689 void Render::DrawSkyD3D()
7690 {
7691 int v0; // esi@2
7692 int v1; // eax@2
7693 double v2; // st7@2
7694 double v3; // st6@2
7695 double v4; // st5@2
7696 double v5; // st4@2
7697 double v6; // st7@2
7698 char *v7; // esi@3
7699 int v8; // eax@4
7700 int v9; // eax@4
7701 int v10; // ebx@4
7702 signed __int64 v11; // qax@6
7703 double v12; // st7@6
7704 int v13; // edi@6
7705 int v14; // ecx@6
7706 int v15; // eax@8
7707 int v16; // eax@12
7708 signed __int64 v17; // qtt@13
7709 signed int v18; // ecx@13
7710 Texture *v19; // eax@15
7711 double v20; // st6@15
7712 double v21; // st7@15
7713 double v22; // st6@15
7714 unsigned __int8 v23; // sf@15
7715 unsigned __int8 v24; // of@15
7716 stru148 _this; // [sp+14h] [bp-150h]@1
7717 double v26; // [sp+120h] [bp-44h]@4
7718 float v27; // [sp+128h] [bp-3Ch]@4
7719 float v28; // [sp+12Ch] [bp-38h]@2
7720 int v29; // [sp+130h] [bp-34h]@4
7721 int v30; // [sp+134h] [bp-30h]@1
7722 int v31; // [sp+138h] [bp-2Ch]@2
7723 int v32; // [sp+13Ch] [bp-28h]@6
7724 int v33; // [sp+140h] [bp-24h]@2
7725 float v34; // [sp+144h] [bp-20h]@1
7726 int v35; // [sp+148h] [bp-1Ch]@4
7727 double v36; // [sp+14Ch] [bp-18h]@2
7728 int v37; // [sp+154h] [bp-10h]@8
7729 int v38; // [sp+158h] [bp-Ch]@1
7730 int v39; // [sp+15Ch] [bp-8h]@4
7731 int v40; // [sp+160h] [bp-4h]@7
7732
7733 v30 = (signed __int64)((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
7734 / ((double)pOutdoorCamera->int_fov_rad + 8192.0)
7735 + (double)pViewport->uScreenCenterY);
7736 v34 = cos((double)pIndoorCamera->sRotationX * 0.0030664064) * (double)pOutdoorCamera->shading_dist_mist;
7737 v38 = (signed __int64)((double)pViewport->uScreenCenterY
7738 - (double)pOutdoorCamera->int_fov_rad
7739 / (v34 + 0.0000001)
7740 * (sin((double)pIndoorCamera->sRotationX * 0.0030664064)
7741 * (double)-pOutdoorCamera->shading_dist_mist
7742 - (double)pIndoorCamera->pos.z));
7743 _this._48607B(&stru_8019C8);
7744 _this.ptr_38->_48694B();
7745 _this.uTileBitmapID = LOWORD(pOutdoor->uSky_TextureID);
7746 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
7747 if ( _this.pTexture )
7748 {
7749 v0 = pIndoorCamera->sRotationX;
7750 _this.field_58 = 0;
7751 _this.uNumVertices = 4;
7752 _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16);
7753 _this.v_18.y = 0;
7754 v1 = stru_5C6E00->SinCos(v0 + 16);
7755 v2 = (double)(signed int)pViewport->uViewportX;
7756 _this.v_18.z = -v1;
7757 array_50AC10[0].vWorldViewProjX = v2;
7758 v3 = (double)(signed int)pViewport->uViewportY;
7759 array_50AC10[0].vWorldViewProjY = v3;
7760 array_50AC10[1].vWorldViewProjX = v2;
7761 v4 = (double)v38;
7762 _this.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
7763 _this.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
7764 v28 = v4;
7765 array_50AC10[1].vWorldViewProjY = v4;
7766 v5 = (double)(signed int)pViewport->uViewportZ;
7767 array_50AC10[2].vWorldViewProjX = v5;
7768 v38 = pViewport->uViewportZ - pViewport->uViewportX;
7769 _this.field_24 = 0x2000000u;
7770 array_50AC10[2].vWorldViewProjY = v4;
7771 array_50AC10[3].vWorldViewProjX = v5;
7772 array_50AC10[3].vWorldViewProjY = v3;
7773 v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
7774 v6 = tan(0.6457717418670654);
7775 v31 = 0;
7776 v33 = 65536 / (signed int)(signed __int64)(v36 / v6 + 0.5);
7777 if ( (signed int)_this.uNumVertices <= 0 )
7778 goto LABEL_16;
7779 v7 = (char *)&array_50AC10[0].vWorldViewProjY;
7780 while ( 1 )
7781 {
7782 LODWORD(v27) = *(int *)v7;
7783 v26 = v27 + 6.7553994e15;
7784 v29 = LODWORD(v26);
7785 v38 = _this.ptr_38->field_14;
7786 v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
7787 v8 = v39 + _this.ptr_38->field_C;
7788 v39 = v33 * (v30 - LODWORD(v26));
7789 v35 = v8;
7790 v38 = _this.ptr_38->field_20;
7791 v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
7792 HIDWORD(v36) = v39 + _this.ptr_38->field_18;
7793 v38 = _this.v_18.z;
7794 v9 = (unsigned __int64)(_this.v_18.z * (signed __int64)(v33 * (v30 - LODWORD(v26)))) >> 16;
7795 v10 = _this.v_18.x + v9;
7796 v39 = _this.v_18.x + v9;
7797 if ( _this.v_18.x + v9 > 0 )
7798 {
7799 v10 = 0;
7800 v39 = 0;
7801 }
7802 v11 = (signed __int64)*((float *)v7 - 1);
7803 v38 = v10;
7804 v12 = *(float *)v7 - 1.0;
7805 v13 = v33 * (pViewport->uScreenCenterX - v11);
7806 LODWORD(v34) = -_this.field_24;
7807 v32 = (signed __int64)v12;
7808 v14 = v33 * (v30 - v32);
7809 while ( 1 )
7810 {
7811 v40 = v14;
7812 if ( !v10 )
7813 goto LABEL_12;
7814 v37 = abs(SLODWORD(v34) >> 14);
7815 v15 = abs(v10);
7816 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportY )
7817 {
7818 if ( v39 <= 0 )
7819 break;
7820 }
7821 v14 = v40;
7822 LABEL_12:
7823 v37 = _this.v_18.z;
7824 v16 = (unsigned __int64)(_this.v_18.z * (signed __int64)v14) >> 16;
7825 --v32;
7826 v14 += v33;
7827 v10 = _this.v_18.x + v16;
7828 v39 = _this.v_18.x + v16;
7829 v38 = _this.v_18.x + v16;
7830 }
7831 LODWORD(v17) = LODWORD(v34) << 16;
7832 HIDWORD(v17) = SLODWORD(v34) >> 16;
7833 v40 = v17 / v38;
7834 v18 = v17 / v38;
7835 if ( v18 < 0 )
7836 v18 = pOutdoorCamera->shading_dist_mist;
7837 v40 = v13;
7838 v37 = _this.ptr_38->field_10;
7839 v40 = v13;
7840 v37 = v35 + ((unsigned __int64)(v37 * (signed __int64)v13) >> 16);
7841 v35 = _this.ptr_38->field_1C;
7842 HIDWORD(v36) += (unsigned __int64)(v35 * (signed __int64)v13) >> 16;
7843 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed
7844 + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3);
7845 v40 = (unsigned __int64)(SHIDWORD(v36) * (signed __int64)v18) >> 16;
7846 v19 = _this.pTexture;
7847 HIDWORD(v36) = _this.pTexture->uTextureWidth;
7848 v7 += 48;
7849 v20 = (double)SHIDWORD(v36) * 65536.0;
7850 HIDWORD(v36) = 224 * pMiscTimer->uTotalGameTimeElapsed + (v40 >> 3);
7851 ++v31;
7852 *((float *)v7 - 10) = (double)v35 / v20;
7853 v21 = (double)SHIDWORD(v36);
7854 HIDWORD(v36) = v19->uTextureHeight;
7855 v22 = (double)SHIDWORD(v36);
7856 HIDWORD(v36) = v18 >> 16;
7857 v24 = _this.uNumVertices > v31;
7858 v23 = ((v31 - _this.uNumVertices) & 0x80000000u) != 0;
7859 *((float *)v7 - 9) = v21 / (v22 * 65536.0);
7860 *((float *)v7 - 16) = (double)pOutdoorCamera->shading_dist_mist;
7861 *((float *)v7 - 11) = 1.0 / (double)SHIDWORD(v36);
7862 if ( !(v23 ^ v24) )
7863 {
7864 LABEL_16:
7865 pRenderer->DrawFan(
7866 _this.uNumVertices,
7867 &_this,
7868 pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
7869 array_50AC10[0].vWorldViewProjY = v28;
7870 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
7871 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
7872 array_50AC10[3].vWorldViewProjY = v28;
7873 pRenderer->DrawFan(
7874 _this.uNumVertices,
7875 &_this,
7876 pBitmaps_LOD->pHardwareTextures[(signed __int16)_this.uTileBitmapID]);
7877 return;
7878 }
7879 }
7880 }
7881 }
7882
7883
7884 //----- (00479A53) --------------------------------------------------------
7885 void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID)
7886 {
7887 BLVFace *pFace; // esi@1
7888 unsigned int v3; // edi@1
7889 PolygonType v4; // al@1
7890 double v5; // st7@3
7891 signed __int64 v6; // qax@3
7892 PolygonType v7; // cl@3
7893 int v8; // esi@7
7894 int v9; // eax@7
7895 unsigned int v10; // eax@7
7896 double v11; // st6@7
7897 int v12; // edx@7
7898 int v13; // eax@7
7899 char *v14; // esi@8
7900 void *v15; // ecx@9
7901 int v16; // eax@9
7902 int v17; // edi@9
7903 double v18; // st7@9
7904 signed int v19; // ebx@9
7905 void *v20; // ecx@9
7906 int v21; // ebx@11
7907 int v22; // eax@14
7908 signed __int64 v23; // qtt@16
7909 double v24; // st7@16
7910 unsigned __int8 v25; // sf@16
7911 unsigned __int8 v26; // of@16
7912 Render *v27; // ecx@17
7913 double v28; // st7@20
7914 char *v29; // ebx@20
7915 char *v30; // edx@20
7916 unsigned __int8 v31; // c0@21
7917 unsigned __int8 v32; // c3@21
7918 double v33; // st6@23
7919 char *v34; // esi@30
7920 const void *v35; // ecx@31
7921 int v36; // eax@31
7922 const void *v37; // edi@31
7923 signed __int64 v38; // qax@31
7924 int v39; // ecx@31
7925 int v40; // ebx@33
7926 int v41; // eax@36
7927 signed __int64 v42; // qtt@39
7928 int v43; // eax@39
7929 char v44; // zf@39
7930 double v45; // st7@39
7931 double v46; // st7@39
7932 unsigned int v47; // edx@40
7933 double v48; // st7@41
7934 RenderVertexSoft *v49; // ebx@41
7935 void *v50; // edi@43
7936 double v51; // st7@46
7937 RenderVertexSoft *v52; // edx@46
7938 void *v53; // edi@48
7939 char *v54; // ebx@52
7940 unsigned int v55; // eax@53
7941 unsigned int v56; // eax@55
7942 int v57; // ST10_4@55
7943 Texture *v58; // eax@55
7944 signed int v59; // [sp-4h] [bp-178h]@17
7945 stru148 *v60; // [sp+0h] [bp-174h]@17
7946 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
7947 stru148 v62; // [sp+14h] [bp-160h]@6
7948 unsigned int v63; // [sp+120h] [bp-54h]@7
7949 double v64; // [sp+124h] [bp-50h]@7
7950 unsigned int v65; // [sp+128h] [bp-4Ch]@1
7951 unsigned int v66; // [sp+12Ch] [bp-48h]@7
7952 float v67; // [sp+130h] [bp-44h]@7
7953 __int64 v68; // [sp+134h] [bp-40h]@3
7954 __int64 v69; // [sp+13Ch] [bp-38h]@3
7955 int v70; // [sp+144h] [bp-30h]@3
7956 int X; // [sp+148h] [bp-2Ch]@9
7957 int v72; // [sp+14Ch] [bp-28h]@7
7958 float v73; // [sp+150h] [bp-24h]@16
7959 unsigned int v74; // [sp+154h] [bp-20h]@3
7960 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
7961 float v76; // [sp+15Ch] [bp-18h]@9
7962 int v77; // [sp+160h] [bp-14h]@9
7963 int v78; // [sp+164h] [bp-10h]@7
7964 void *v79; // [sp+168h] [bp-Ch]@9
7965 float v80; // [sp+16Ch] [bp-8h]@3
7966 const void *v81; // [sp+170h] [bp-4h]@7
7967
7968 __debugbreak();
7969
7970 pFace = &pIndoor->pFaces[uFaceID];
7971 v65 = uFaceID;
7972 v3 = uNumVertices;
7973 v4 = pFace->uPolygonType;
7974 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
7975 {
7976 if ( (signed int)uNumVertices > 0 )
7977 {
7978 v54 = (char *)&array_507D30[0].u;
7979 LODWORD(v80) = uNumVertices;
7980 do
7981 {
7982 v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x;
7983 *(float *)v54 = (double)v69 + *(float *)v54;
7984 *(float *)v54 = *(float *)v54 * 0.25;
7985 v55 = GetTickCount();
7986 v54 += 48;
7987 v44 = LODWORD(v80)-- == 1;
7988 v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5);
7989 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
7990 }
7991 while ( !v44 );
7992 uFaceID = v65;
7993 }
7994 v56 = 8 * uFaceID;
7995 LOBYTE(v56) = 8 * uFaceID | 6;
7996 v57 = v56;
7997 v58 = pFace->GetTexture();
7998 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
7999 return;
8000 }
8001 HIDWORD(v69) = pIndoorCamera->sRotationX;
8002 HIDWORD(v68) = pIndoorCamera->pos.z;
8003 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
8004 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z)
8005 / (((double)pBLVRenderParams->field_40 + 16192.0)
8006 * 65536.0)
8007 + *(float *)&v74);
8008 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064;
8009 *(float *)&v75 = v5;
8010 v80 = cos(v5) * 16192.0;
8011 v6 = (signed __int64)(*(float *)&v74
8012 - (double)pBLVRenderParams->field_40
8013 / ((v80 + 0.0000001)
8014 * 65535.0)
8015 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
8016 v7 = pFace->uPolygonType;
8017 if ( v7 == 4 || v7 == 3 )
8018 v70 = v6;
8019 stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
8020 v62._48607B(&stru_8019C8);
8021 v62.uTileBitmapID = pFace->uBitmapID;
8022 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
8023 if ( !v62.pTexture )
8024 return;
8025 v8 = pBLVRenderParams->sPartyRotX;
8026 v62.field_58 = 0;
8027 v62.uNumVertices = v3;
8028 v9 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX - stru_5C6E00->uIntegerHalfPi + 16);
8029 v62.v_18.y = 0;
8030 v62.v_18.x = -v9;
8031 v62.v_18.z = -stru_5C6E00->SinCos(v8 + 16);
8032 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
8033 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
8034 LODWORD(v80) = v10;
8035 v62.field_24 = 33554432;
8036 v64 = (double)(signed int)v10 * 0.5;
8037 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
8038 LODWORD(v80) = v62.pTexture->uTextureWidth;
8039 v11 = 1.0 / (double)SLODWORD(v80);
8040 LODWORD(v80) = v62.pTexture->uTextureHeight;
8041 v12 = v62.pTexture->uWidthMinus1;
8042 v13 = v62.pTexture->uHeightMinus1;
8043 v67 = v11;
8044 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
8045 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
8046 v78 = 0;
8047 v81 = 0;
8048 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
8049 if ( (signed int)v62.uNumVertices <= 0 )
8050 {
8051 LABEL_17:
8052 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
8053 v27 = pRenderer;
8054 v60 = &v62;
8055 v59 = v62.uNumVertices;
8056 goto LABEL_18;
8057 }
8058 v14 = (char *)&array_507D30[0].vWorldViewProjY;
8059 while ( 2 )
8060 {
8061 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
8062 LODWORD(v80) = v62.ptr_38->field_14;
8063 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
8064 v16 = v77 + v62.ptr_38->field_C;
8065 v77 = (int)v15;
8066 v74 = v16;
8067 LODWORD(v80) = v62.ptr_38->field_20;
8068 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
8069 v79 = v15;
8070 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
8071 LODWORD(v80) = v62.v_18.z;
8072 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
8073 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
8074 v18 = *(float *)v14 - 1.0;
8075 v19 = -v62.field_24;
8076 v77 = -v62.field_24;
8077 X = (int)((char *)v79 + v62.v_18.x);
8078 LODWORD(v76) = (signed __int64)v18;
8079 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
8080 while ( 1 )
8081 {
8082 v79 = v20;
8083 if ( !X )
8084 goto LABEL_14;
8085 v21 = abs(v19 >> 14);
8086 if ( v21 <= abs(X) )
8087 break;
8088 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
8089 break;
8090 v19 = v77;
8091 v20 = v79;
8092 LABEL_14:
8093 LODWORD(v80) = v62.v_18.z;
8094 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
8095 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
8096 --LODWORD(v76);
8097 v20 = (char *)v20 + v72;
8098 X = v22 + v62.v_18.x;
8099 v78 = 1;
8100 }
8101 if ( !v78 )
8102 {
8103 LODWORD(v23) = v77 << 16;
8104 HIDWORD(v23) = v77 >> 16;
8105 v79 = (void *)(v23 / X);
8106 v77 = v17;
8107 LODWORD(v80) = v62.ptr_38->field_10;
8108 v77 = v17;
8109 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
8110 LODWORD(v80) = v62.ptr_38->field_1C;
8111 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
8112 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
8113 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
8114 v14 += 48;
8115 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
8116 v81 = (char *)v81 + 1;
8117 v24 = (double)SLODWORD(v80) * 0.000015259022;
8118 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
8119 v26 = __OFSUB__((int)v81, v62.uNumVertices);
8120 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
8121 *((float *)v14 - 10) = v24 * v67;
8122 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
8123 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
8124 if ( !(v25 ^ v26) )
8125 goto LABEL_17;
8126 continue;
8127 }
8128 break;
8129 }
8130 LODWORD(v73) = 0;
8131 v80 = v76;
8132 if ( (signed int)v62.uNumVertices > 0 )
8133 {
8134 v28 = (double)SLODWORD(v76);
8135 LODWORD(v76) = (int)(char *)array_50AC10 + 28;
8136 v29 = (char *)&array_50AC10[0].vWorldViewProjX;
8137 v30 = (char *)&array_507D30[1].vWorldViewProjY;
8138 v79 = array_50AC10;
8139 v81 = array_507D30;
8140 v78 = v62.uNumVertices;
8141 do
8142 {
8143 v31 = v28 < *((float *)v30 - 12);
8144 v32 = v28 == *((float *)v30 - 12);
8145 ++LODWORD(v73);
8146 memcpy(v79, v81, 0x30u);
8147 v79 = (char *)v79 + 48;
8148 LODWORD(v76) += 48;
8149 v29 += 48;
8150 if ( v31 | v32 || v28 >= *(float *)v30 )
8151 {
8152 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 )
8153 goto LABEL_28;
8154 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12))
8155 + *((float *)v30 - 1);
8156 }
8157 else
8158 {
8159 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30)
8160 + *((float *)v30 - 13);
8161 }
8162 *(float *)v29 = v33;
8163 v79 = (char *)v79 + 48;
8164 v29 += 48;
8165 ++LODWORD(v73);
8166 *(unsigned int *)LODWORD(v76) = v28;
8167 LODWORD(v76) += 48;
8168 LABEL_28:
8169 v81 = (char *)v81 + 48;
8170 v30 += 48;
8171 --v78;
8172 }
8173 while ( v78 );
8174 }
8175 if ( SLODWORD(v73) <= 0 )
8176 goto LABEL_40;
8177 v34 = (char *)&array_50AC10[0].vWorldViewProjY;
8178 v65 = v77 >> 14;
8179 HIDWORD(v69) = LODWORD(v73);
8180 do
8181 {
8182 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
8183 v78 = v62.ptr_38->field_14;
8184 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
8185 v36 = (int)((char *)v81 + v62.ptr_38->field_C);
8186 v81 = v35;
8187 v74 = v36;
8188 v78 = v62.ptr_38->field_20;
8189 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
8190 v78 = (int)v35;
8191 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18);
8192 v81 = (const void *)v62.v_18.z;
8193 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16;
8194 v37 = (const void *)(v72
8195 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1)));
8196 v38 = (signed __int64)(*(float *)v34 - 1.0);
8197 v81 = 0;
8198 LODWORD(v76) = v38;
8199 v39 = v72 * (v70 - v38);
8200 while ( 1 )
8201 {
8202 v78 = v39;
8203 if ( !X )
8204 goto LABEL_36;
8205 v40 = abs(X);
8206 if ( abs((signed __int64)v65) <= v40 )
8207 break;
8208 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
8209 break;
8210 v39 = v78;
8211 LABEL_36:
8212 v78 = v62.v_18.z;
8213 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16;
8214 --LODWORD(v76);
8215 v39 += v72;
8216 X = v41 + v62.v_18.x;
8217 v81 = (const void *)1;
8218 }
8219 if ( v81 )
8220 {
8221 v79 = (void *)v62.v_18.z;
8222 v78 = 2 * LODWORD(v76);
8223 v81 = (const void *)((unsigned __int64)(v62.v_18.z
8224 * (signed __int64)(signed int)(signed __int64)(((double)v70
8225 - ((double)(2 * LODWORD(v76))
8226 - *(float *)v34))
8227 * (double)v72)) >> 16);
8228 X = (int)((char *)v81 + v62.v_18.x);
8229 }
8230 LODWORD(v42) = v77 << 16;
8231 HIDWORD(v42) = v77 >> 16;
8232 v79 = (void *)(v42 / X);
8233 v81 = v37;
8234 v78 = v62.ptr_38->field_10;
8235 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
8236 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
8237 v74 = (unsigned int)v37;
8238 LODWORD(v76) = v43;
8239 v78 = v62.ptr_38->field_1C;
8240 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
8241 v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
8242 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
8243 v34 += 48;
8244 v78 = v66 + ((signed int)v74 >> 4);
8245 v44 = HIDWORD(v69)-- == 1;
8246 v45 = (double)v78 * 0.000015259022;
8247 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
8248 *((float *)v34 - 10) = v45 * v67;
8249 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
8250 v46 = (double)(signed int)v79;
8251 *((float *)v34 - 16) = 0.000015258789 * v46;
8252 *((float *)v34 - 11) = 65536.0 / v46;
8253 }
8254 while ( !v44 );
8255 LABEL_40:
8256 v47 = 0;
8257 if ( SLODWORD(v73) > 0 )
8258 {
8259 v48 = (double)SLODWORD(v80);
8260 v75 = array_507D30;
8261 v49 = array_50AC10;
8262 HIDWORD(v69) = LODWORD(v73);
8263 do
8264 {
8265 if ( v48 >= v49->vWorldViewProjY )
8266 {
8267 v50 = v75;
8268 ++v47;
8269 ++v75;
8270 memcpy(v50, v49, 0x30u);
8271 }
8272 ++v49;
8273 --HIDWORD(v69);
8274 }
8275 while ( HIDWORD(v69) );
8276 }
8277 v62.uNumVertices = v47;
8278 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]);
8279 *(float *)&v74 = 0.0;
8280 if ( SLODWORD(v73) > 0 )
8281 {
8282 v51 = (double)SLODWORD(v80);
8283 v75 = array_507D30;
8284 v52 = array_50AC10;
8285 v80 = v73;
8286 do
8287 {
8288 if ( v51 <= v52->vWorldViewProjY )
8289 {
8290 v53 = v75;
8291 ++v74;
8292 ++v75;
8293 memcpy(v53, v52, 0x30u);
8294 }
8295 ++v52;
8296 --LODWORD(v80);
8297 }
8298 while ( v80 != 0.0 );
8299 }
8300 v62.uNumVertices = v74;
8301 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
8302 v60 = &v62;
8303 v59 = v74;
8304 v27 = pRenderer;
8305 LABEL_18:
8306 v27->_4A2ED5(v59, v60, v61);
8307 }
8308
8309 //----- (0047A384) --------------------------------------------------------
8310 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa)
8311 {
8312 int v2; // ebx@3
8313 unsigned int v3; // eax@3
8314 MapInfo *v4; // edi@4
8315 //int v5; // eax@8
8316 //SpawnPointMM7 *v6; // edx@14
8317 size_t v7; // eax@19
8318 char *v8; // eax@19
8319 char *v9; // eax@21
8320 char Source[120]; // [sp+Ch] [bp-84h]@19
8321 const char *pFilename; // [sp+84h] [bp-Ch]@1
8322 //unsigned int v12; // [sp+88h] [bp-8h]@12
8323 //int v13; // [sp+8Ch] [bp-4h]@11
8324
8325 pFilename = pLevelFilename;
8326 thisa->AllocSoftwareDrawBuffers();
8327 pOutdoorCamera->_485F64();
8328 pWeather->bRenderSnow = 0;
8329 pRenderer->ClearZBuffer(0, 479);
8330 thisa = (OutdoorCamera *)1;
8331 GetAlertStatus();
8332 if ( qword_A750D8 )
8333 qword_A750D8 = 0i64;
8334 v2 = pMapStats->GetMapInfo(pCurrentMapName);
8335 v3 = 0;
8336 if ( v2 )
8337 {
8338 v4 = &pMapStats->pInfos[v2];
8339 v3 = v4->uRespawnIntervalDays;
8340 }
8341 else
8342 {
8343 v4 = (MapInfo *)thisa;
8344 }
8345 day_attrib &= 0xFFFFFFFEu;
8346 dword_6BE13C_uCurrentlyLoadedLocationID = v2;
8347 pOutdoor->Initialize(
8348 pFilename,
8349 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1,
8350 v3,
8351 (int)&thisa);
8352 if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x20) )
8353 {
8354 InitializeActors();
8355 InitializeLayingItems();
8356 }
8357 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu;
8358 //v5 = 0;
8359 if ( !v2 )
8360 thisa = 0;
8361 if ( thisa == (OutdoorCamera *)1 )
8362 {
8363 //v13 = 0;
8364 for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i)
8365 {
8366 //v12 = 0;
8367 //while ( 1 )
8368 //{
8369 auto spawn = pOutdoor->pSpawnPoints + i;
8370 //v6 = &pOutdoor->pSpawnPoints[v12 / 0x18];
8371 if (spawn->uKind == 3 )
8372 SpawnEncounter(v4, spawn, 0, 0, 0);
8373 else
8374 v4->SpawnRandomTreasure(spawn);
8375 //++v13;
8376 //v12 += 24;
8377 //if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints )
8378 // break;
8379 //v5 = 0;
8380 //}
8381 }
8382 RespawnGlobalDecorations();
8383 }
8384 pOutdoor->PrepareDecorations();
8385 pOutdoor->_47F223_LooksLikeGenerateMonsterLoot();
8386 pOutdoor->InitalizeActors(v2);
8387 pOutdoor->MessWithLUN();
8388 v7 = strlen("levels\\");
8389 strcpy(Source, &pFilename[v7]);
8390 strcpy(pOutdoor->pLevelFilename, Source);
8391 pWeather->Initialize();
8392 pIndoorCamera->sRotationY = pParty->sRotationY;
8393 pIndoorCamera->sRotationX = pParty->sRotationX;
8394 pOutdoorCamera->RotationToInts();
8395 pOutdoor->UpdateSunlightVectors();
8396 pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov;
8397 pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C;
8398 v8 = (char *)&array_77EC08[0].ptr_38;
8399 do
8400 {
8401 *(int *)v8 = (int)&stru_8019C8;
8402 v8 += 268;
8403 }
8404 while ( (signed int)v8 < (signed int)&unk_801A00 );
8405 v9 = (char *)&array_77EC08[0].prolly_tail;
8406 do
8407 {
8408 *((int *)v9 - 1) = 0;
8409 *(int *)v9 = 0;
8410 *((int *)v9 - 5) = 0;
8411 v9 += 268;
8412 }
8413 while ( (signed int)v9 < (signed int)&unk_801A0C );
8414 MM7Initialization();
8415 }
8416
8417
8418
8419 //----- (0047A825) --------------------------------------------------------
8420 bool LevelDecoration::_47A825()
8421 {
8422 bool v1; // ebx@1
8423 LevelDecoration *v2; // edi@1
8424
8425 v1 = 0;
8426 v2 = this;
8427 if ( pParty->uCurrentHour >= 1 || (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 178) )
8428 {
8429 v1 = 0;
8430 }
8431 else
8432 {
8433 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 164)
8434 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 165)
8435 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 166)
8436 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 167)
8437 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 168)
8438 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 169)
8439 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 170)
8440 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 171)
8441 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 172)
8442 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 173)
8443 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 174)
8444 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 175)
8445 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 176)
8446 && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 177) )
8447 {
8448 v1 = 1;
8449 LOBYTE(v2->field_2) &= 0xDFu;
8450 return v1;
8451 }
8452 }
8453 LOBYTE(v2->field_2) |= 0x20u;
8454 return v1;
8455 }
8456
8457
8458
8459 //----- (0047BC6F) --------------------------------------------------------
8460 unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4)
8461 {
8462 int v4; // ebx@1
8463 int v6; // edx@4
8464 int v7; // ecx@5
8465 signed int v8; // eax@6
8466 signed __int64 v9; // qtt@11
8467 signed int v10; // eax@12
8468 int v11; // esi@17
8469 signed __int64 v12; // qtt@19
8470 double v13; // ST10_8@19
8471 int v14; // edi@25
8472 signed int v15; // edx@26
8473 signed __int64 v16; // qtt@29
8474 signed int v17; // eax@30
8475 int v18; // [sp+10h] [bp-8h]@1
8476 float a3a; // [sp+20h] [bp+8h]@19
8477
8478 v4 = a2;
8479 v18 = a2;
8480 if ( pParty->field_1613C )
8481 return PaletteManager::Get(a2);
8482 if ( !pWeather->field_FA0 )
8483 {
8484 if ( day_attrib & 1 )
8485 {
8486 v14 = day_fogrange_1 << 16;
8487 if ( a3 >= day_fogrange_1 << 16 )
8488 {
8489 if ( a3 <= day_fogrange_2 << 16 )
8490 {
8491 LODWORD(v16) = (a3 - v14) << 16;
8492 HIDWORD(v16) = (a3 - v14) >> 16;
8493 v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
8494 }
8495 else
8496 {
8497 v15 = 27;
8498 }
8499 }
8500 else
8501 {
8502 v15 = 0;
8503 }
8504 v17 = _43F55F_get_billboard_light_level(a1, v15);
8505 if ( v17 > 27 )
8506 v17 = 27;
8507 if ( !a3 )
8508 v17 = 27;
8509 v7 = v18;
8510 v6 = v17;
8511 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
8512 }
8513 v11 = a4;
8514 if ( a4 < 0 )
8515 v11 = 0;
8516 LODWORD(v12) = a3 << 16;
8517 HIDWORD(v12) = a3 >> 16;
8518 a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20)
8519 * pOutdoor->fFogDensity;
8520 v13 = a3a + 6.7553994e15;
8521 v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11);
8522 if ( v10 > 27 )
8523 v10 = 27;
8524 if ( v10 < a4 )
8525 v10 = a4;
8526 if ( v10 > pOutdoor->field_CBC_terrain_triangles_shade_type )
8527 v10 = pOutdoor->field_CBC_terrain_triangles_shade_type;
8528 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
8529 }
8530 v6 = 0;
8531 if ( pWeather->field_FA0 == 1 )
8532 {
8533 v8 = 67108864;
8534 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
8535 v8 = pParty->pPartyBuffs[16].uPower << 26;
8536 if ( a3 <= v8 )
8537 {
8538 if ( a3 > 0 )
8539 {
8540 LODWORD(v9) = a3 << 16;
8541 HIDWORD(v9) = a3 >> 16;
8542 v6 = (unsigned __int64)(27 * v9 / v8) >> 16;
8543 }
8544 }
8545 else
8546 {
8547 v6 = 27;
8548 }
8549 v10 = _43F55F_get_billboard_light_level(a1, v6);
8550 if ( v10 > 27 || !a3 )
8551 v10 = 27;
8552 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
8553 }
8554 v7 = 0;
8555 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
8556 }
8557 // 6BE030: using guessed type int day_attrib;
8558 // 6BE040: using guessed type int day_fogrange_1;
8559 // 6BE044: using guessed type int day_fogrange_2;
8560
8561
8562
8563
8564
8565
8566
8567
8568 //----- (0047BEB1) --------------------------------------------------------
8569 int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8)
8570 {
8571 stru148 *v8; // ebx@1
8572 signed int v9; // edx@1
8573 int v10; // eax@5
8574 signed int v11; // eax@9
8575 signed int v12; // eax@15
8576 signed __int64 v13; // qtt@21
8577 int *v14; // ecx@30
8578 int *v15; // edi@30
8579 int v16; // ebx@32
8580 signed __int64 v17; // qtt@37
8581 double v18; // ST10_8@37
8582 double v19; // ST10_8@38
8583 int v20; // edi@39
8584 int result; // eax@46
8585 int *v22; // eax@48
8586 signed int v23; // edx@51
8587 signed __int64 v24; // qtt@51
8588 int v25; // ecx@51
8589 signed int v26; // [sp+14h] [bp-4h]@1
8590 float v27; // [sp+28h] [bp+10h]@37
8591 float v28; // [sp+28h] [bp+10h]@38
8592 int v29; // [sp+2Ch] [bp+14h]@37
8593
8594 v8 = a2;
8595 v9 = a1;
8596 v26 = a1;
8597 if ( pParty->field_1613C )
8598 {
8599 *a5 = -1;
8600 *a6 = -1;
8601 *(char *)a7 = 1;
8602 LABEL_46:
8603 result = a8;
8604 *(char *)a8 = 0;
8605 return result;
8606 }
8607 if ( a1 < 0 )
8608 {
8609 v26 = v8->field_34 << 16;
8610 v9 = v8->field_34 << 16;
8611 }
8612 v10 = pWeather->field_FA0;
8613 if ( bUnderwater == 1 )
8614 v10 = 0;
8615 if ( !v10 )
8616 {
8617 if ( !(day_attrib & 1) && !bUnderwater )
8618 {
8619 v14 = a5;
8620 v15 = a6;
8621 if ( !v9 )
8622 {
8623 *a5 = 31;
8624 *a6 = -1;
8625 }
8626 v16 = v8->field_58 - terrain_gamma;
8627 if ( v16 >= 0 )
8628 {
8629 if ( v16 > 27 )
8630 v16 = 27;
8631 }
8632 else
8633 {
8634 v16 = 0;
8635 }
8636 *a6 = 27;
8637 if ( a4 )
8638 {
8639 v28 = pOutdoor->fFogDensity * 27.0;
8640 v19 = v28 + 6.7553994e15;
8641 v29 = LODWORD(v19);
8642 }
8643 else
8644 {
8645 LODWORD(v17) = v9 << 16;
8646 HIDWORD(v17) = v9 >> 16;
8647 v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16)
8648 + *a6)
8649 * pOutdoor->fFogDensity;
8650 v18 = v27 + 6.7553994e15;
8651 v29 = LODWORD(v18);
8652 }
8653 *v14 = v16 + v29;
8654 v20 = *v15;
8655 if ( v16 + v29 > v20 )
8656 *v14 = v20;
8657 if ( *v14 < v16 )
8658 *v14 = v16;
8659 if ( *v14 > pOutdoor->field_CBC_terrain_triangles_shade_type )
8660 *v14 = pOutdoor->field_CBC_terrain_triangles_shade_type;
8661 goto LABEL_45;
8662 }
8663 if ( v9 >= day_fogrange_1 << 16 )
8664 {
8665 if ( v9 <= day_fogrange_2 << 16 )
8666 {
8667 v23 = v9 - (day_fogrange_1 << 16);
8668 LODWORD(v24) = v23 << 16;
8669 HIDWORD(v24) = v23 >> 16;
8670 v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
8671 v22 = a5;
8672 *a5 = v25;
8673 if ( v25 > 27 )
8674 goto LABEL_54;
8675 v9 = v26;
8676 }
8677 else
8678 {
8679 v22 = a5;
8680 *a5 = 27;
8681 }
8682 }
8683 else
8684 {
8685 v22 = a5;
8686 *a5 = 0;
8687 }
8688 if ( v9 )
8689 {
8690 LABEL_55:
8691 if ( a4 )
8692 *v22 = 31;
8693 *a6 = 31;
8694 *(char *)a7 = 0;
8695 goto LABEL_59;
8696 }
8697 LABEL_54:
8698 *v22 = 27;
8699 goto LABEL_55;
8700 }
8701 if ( v10 == 1 )
8702 {
8703 v11 = 1;
8704 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 )
8705 {
8706 v12 = 0;
8707 }
8708 else
8709 {
8710 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
8711 {
8712 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime <= 0 )
8713 v11 = 0;
8714 else
8715 v11 = pParty->pPartyBuffs[16].uPower;
8716 }
8717 v12 = v11 << 26;
8718 }
8719 if ( a4 )
8720 goto LABEL_24;
8721 if ( v9 <= v12 )
8722 {
8723 if ( v9 > 0 )
8724 {
8725 LODWORD(v13) = v9 << 16;
8726 HIDWORD(v13) = v9 >> 16;
8727 v9 = v26;
8728 *a5 = (unsigned __int64)(27 * v13 / v12) >> 16;
8729 }
8730 if ( *a5 > 27 )
8731 goto LABEL_24;
8732 }
8733 else
8734 {
8735 *a5 = 27;
8736 }
8737 if ( v9 )
8738 {
8739 LABEL_25:
8740 if ( v8->field_32 & 4 )
8741 *a5 = 27;
8742 *a6 = 27;
8743 LABEL_45:
8744 *(char *)a7 = 0;
8745 goto LABEL_46;
8746 }
8747 LABEL_24:
8748 *a5 = 27;
8749 goto LABEL_25;
8750 }
8751 *a5 = -1;
8752 *a6 = -1;
8753 *(char *)a7 = 1;
8754 LABEL_59:
8755 result = a8;
8756 *(char *)a8 = 1;
8757 return result;
8758 }
8759 // 4D864C: using guessed type char byte_4D864C;
8760 // 6BE030: using guessed type int day_attrib;
8761 // 6BE040: using guessed type int day_fogrange_1;
8762 // 6BE044: using guessed type int day_fogrange_2;
8763 // 6BE3C4: using guessed type char bUnderwater;
8764
8765 //----- (0047C178) --------------------------------------------------------
8766 void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4)
8767 {
8768 stru148 *v4; // esi@1
8769 void *result; // eax@2
8770 int v6; // [sp+4h] [bp-8h]@3
8771 int v7; // [sp+8h] [bp-4h]@3
8772
8773 v4 = a2;
8774 if ( pParty->field_1613C )
8775 {
8776 result = PaletteManager::Get(a2->pTexture->palette_id2);
8777 }
8778 else
8779 {
8780 sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3));
8781 result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7);
8782 }
8783 return result;
8784 }
8785
8786 //----- (0047C1CA) --------------------------------------------------------
8787 void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4)
8788 {
8789 stru148 *v4; // esi@1
8790 void *result; // eax@2
8791 int v6; // edx@3
8792 int v7; // ecx@8
8793 int a3a; // [sp+4h] [bp-8h]@1
8794 char v9; // [sp+8h] [bp-4h]@1
8795
8796 v9 = a2;
8797 v4 = a1;
8798 a3a = 1;
8799 if ( pParty->field_1613C )
8800 {
8801 result = PaletteManager::Get(a1->pTexture->palette_id2);
8802 }
8803 else
8804 {
8805 v6 = pGame->_44EC23(a1, &a3a, a4);
8806 if ( v6 == -1 )
8807 v6 = a3;
8808 if ( v9 == 1 )
8809 {
8810 if ( v6 != -1 || a4 != -1 )
8811 {
8812 v7 = v4->pTexture->palette_id2;
8813 }
8814 else
8815 {
8816 v6 = 0;
8817 v7 = 0;
8818 }
8819 result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a);
8820 }
8821 else
8822 {
8823 result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a);
8824 }
8825 }
8826 return result;
8827 }
8828
8829 //----- (0047C24C) --------------------------------------------------------
8830 unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4)
8831 {
8832 int v4; // esi@1
8833 int v5; // eax@2
8834 int a3a; // [sp+4h] [bp-4h]@1
8835
8836 v4 = a2;
8837 a3a = 1;
8838 if ( a4 )
8839 {
8840 v5 = pGame->_44ED0A(a1, &a3a, 31);
8841 if ( v5 != -1 )
8842 a3 = v5;
8843 }
8844 return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a);
8845 }
8846
8847 //----- (0047C28C) --------------------------------------------------------
8848 char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4)
8849 {
8850 stru148 *v4; // esi@1
8851 char *result; // eax@2
8852 signed int v6; // eax@3
8853 int v7; // ecx@8
8854 int a2a; // [sp+4h] [bp-8h]@1
8855 char v9; // [sp+8h] [bp-4h]@1
8856
8857 v9 = a2;
8858 v4 = a1;
8859 a2a = 1;
8860 if ( pParty->field_1613C )
8861 {
8862 result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2];
8863 }
8864 else
8865 {
8866 v6 = pGame->_44EC23(a1, &a2a, a4);
8867 if ( v6 != -1 )
8868 a3 = v6;
8869 if ( v9 == 1 )
8870 {
8871 if ( a3 != -1 || a4 != -1 )
8872 v7 = v4->pTexture->palette_id2;
8873 else
8874 v7 = 0;
8875 result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a);
8876 }
8877 else
8878 {
8879 result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a);
8880 }
8881 }
8882 return result;
8883 }
8884
8885 // 4D864C: using guessed type char byte_4D864C;
8886
8887
8888 //----- (0047C370) --------------------------------------------------------
8889 unsigned int __cdecl GetLevelFogColor()
8890 {
8891 unsigned int result; // eax@2
8892 signed __int64 v1; // qax@5
8893 int v2; // eax@6
8894
8895 if ( bUnderwater )
8896 {
8897 result = 0xFF258F5Cu;
8898 }
8899 else
8900 {
8901 if ( day_attrib & 1 )
8902 {
8903 if ( pWeather->field_FA0 )
8904 {
8905 v2 = -(pWeather->field_FA0 != 1);
8906 result = (v2 & 0xE0E0E1) - 0xE0E0E1;
8907 }
8908 else
8909 {
8910 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0);
8911 result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8);
8912 }
8913 }
8914 else
8915 {
8916 result = 0;
8917 }
8918 }
8919 return result;
8920 }
8921 // 6BE030: using guessed type int day_attrib;
8922 // 6BE3C4: using guessed type char bUnderwater;
8923
8924 //----- (0047C3D7) --------------------------------------------------------
8925 int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3)
8926 {
8927 int v3; // ecx@1
8928 double v5; // st7@10
8929 signed int v6; // esi@10
8930 signed int v7; // ecx@11
8931 double v8; // st6@12
8932 double v9; // st7@15
8933 double v10; // st6@16
8934 float v11; // ST14_4@17
8935 double v12; // ST08_8@17
8936
8937 v3 = pWeather->field_FA0;
8938 if ( bUnderwater == 1 )
8939 v3 = 0;
8940 if ( pParty->field_1613C || !(day_attrib & 1) && !bUnderwater )
8941 return 0xFF000000u;
8942 if ( v3 )
8943 {
8944 if ( v3 != 1 )
8945 return 0;
8946 v5 = (double)day_fogrange_1;
8947 v6 = 216;
8948 if ( a3 < v5 )
8949 goto LABEL_11;
8950 v8 = (double)day_fogrange_2;
8951 if ( a3 > v8 )
8952 {
8953 LABEL_13:
8954 v7 = v6;
8955 goto LABEL_19;
8956 }
8957 v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
8958 }
8959 else
8960 {
8961 v9 = (double)day_fogrange_1;
8962 v6 = 216;
8963 if ( a3 < v9 )
8964 {
8965 LABEL_11:
8966 v7 = 0;
8967 goto LABEL_19;
8968 }
8969 v10 = (double)day_fogrange_2;
8970 if ( a3 > v10 )
8971 goto LABEL_13;
8972 v11 = (a3 - v9) * 216.0 / (v10 - v9);
8973 v12 = v11 + 6.7553994e15;
8974 v7 = LODWORD(v12);
8975 }
8976 if ( v7 > v6 )
8977 {
8978 LABEL_20:
8979 v7 = v6;
8980 goto LABEL_21;
8981 }
8982 LABEL_19:
8983 if ( a3 == 0.0 )
8984 goto LABEL_20;
8985 LABEL_21:
8986 if ( a2 )
8987 v7 = 248;
8988 return (-1 - v7) << 24;
8989 }
8990 // 6BE030: using guessed type int day_attrib;
8991 // 6BE040: using guessed type int day_fogrange_1;
8992 // 6BE044: using guessed type int day_fogrange_2;
8993 // 6BE3C4: using guessed type char bUnderwater;
8994
8995 //----- (0047C4FC) --------------------------------------------------------
8996 signed int __fastcall GetActorTintColor(int a1, int a2, float a3, int a4, RenderBillboard *a5)
8997 {
8998 int v5; // esi@1
8999 signed int v6; // edx@1
9000 signed int result; // eax@2
9001 int v8; // eax@3
9002 double v9; // st7@12
9003 double v10; // ST0C_8@18
9004 int v11; // ecx@28
9005 signed int v12; // edi@28
9006 double v13; // ST0C_8@33
9007 double v14; // ST0C_8@34
9008 double v15; // st7@44
9009 double v16; // ST0C_8@44
9010 double v17; // ST0C_8@44
9011 int v18; // ST14_4@44
9012 double v19; // ST0C_8@44
9013 signed int v20; // [sp+10h] [bp-4h]@10
9014 float a3a; // [sp+1Ch] [bp+8h]@33
9015 float a3b; // [sp+1Ch] [bp+8h]@34
9016 float a3c; // [sp+1Ch] [bp+8h]@44
9017 float a3d; // [sp+1Ch] [bp+8h]@44
9018 float a4b; // [sp+20h] [bp+Ch]@18
9019 int a4a; // [sp+20h] [bp+Ch]@33
9020 float a4c; // [sp+20h] [bp+Ch]@44
9021 float a4d; // [sp+20h] [bp+Ch]@44
9022 int a5a; // [sp+24h] [bp+10h]@44
9023
9024 v5 = a2;
9025 v6 = 0;
9026 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
9027 return 8 * (31 - a1) | ((8 * (31 - a1) | ((31 - a1) << 11)) << 8);
9028 v8 = pWeather->field_FA0;
9029 if ( bUnderwater == 1 )
9030 v8 = 0;
9031 if ( pParty->field_1613C )
9032 return 16711680;
9033 if ( v8 )
9034 {
9035 if ( v8 != 1 )
9036 return 0;
9037 v20 = 1;
9038 if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
9039 v20 = pParty->pPartyBuffs[16].uPower;
9040 v9 = (double)v20 * 1024.0;
9041 if ( a4 )
9042 goto LABEL_19;
9043 if ( a3 <= v9 )
9044 {
9045 if ( a3 > 0.0 )
9046 {
9047 a4b = a3 * 216.0 / v9;
9048 v10 = a4b + 6.7553994e15;
9049 v6 = LODWORD(v10);
9050 if ( SLODWORD(v10) > 216 )
9051 goto LABEL_19;
9052 }
9053 }
9054 else
9055 {
9056 v6 = 216;
9057 }
9058 if ( a3 != 0.0 )
9059 {
9060 LABEL_20:
9061 if ( a5 )
9062 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
9063 if ( v6 > 216 )
9064 v6 = 216;
9065 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
9066 }
9067 LABEL_19:
9068 v6 = 216;
9069 goto LABEL_20;
9070 }
9071 if ( a3 == 0.0 )
9072 {
9073 result = (signed int)0xF8F8F8;
9074 }
9075 else
9076 {
9077 v11 = 8 * (a1 - v5);
9078 v12 = v11;
9079 if ( v11 >= 0 )
9080 {
9081 if ( v11 > 216 )
9082 v12 = 216;
9083 }
9084 else
9085 {
9086 v12 = 0;
9087 }
9088 if ( a4 )
9089 {
9090 a3b = pOutdoor->fFogDensity * 216.0;
9091 v14 = a3b + 6.7553994e15;
9092 a4a = LODWORD(v14);
9093 }
9094 else
9095 {
9096 a3a = (a3 / (double)pOutdoorCamera->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity;
9097 v13 = a3a + 6.7553994e15;
9098 a4a = LODWORD(v13);
9099 }
9100 v6 = a4a + v12;
9101 if ( a5 )
9102 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
9103 if ( v6 > 216 )
9104 v6 = 216;
9105 if ( v6 < v12 )
9106 v6 = v12;
9107 if ( v6 > 8 * pOutdoor->field_CBC_terrain_triangles_shade_type )
9108 v6 = 8 * pOutdoor->field_CBC_terrain_triangles_shade_type;
9109 if ( !bUnderwater )
9110 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
9111 v15 = (double)(255 - v6) * 0.0039215689;
9112 a3c = v15;
9113 a4c = v15 * 16.0;
9114 v16 = a4c + 6.7553994e15;
9115 a5a = LODWORD(v16);
9116 a4d = a3c * 194.0;
9117 v17 = a4d + 6.7553994e15;
9118 v18 = LODWORD(v17);
9119 a3d = a3c * 153.0;
9120 v19 = a3d + 6.7553994e15;
9121 result = LODWORD(v19) | ((v18 | (a5a << 8)) << 8);
9122 }
9123 return result;
9124 }
9125 // 6BE3C4: using guessed type char bUnderwater;
9126
9127
9128
9129
9130 //----- (0047F44B) --------------------------------------------------------
9131 int __stdcall WorldPosToGridCellX(signed int a1)
9132 {
9133 return (a1 >> 9) + 64;
9134 }
9135 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
9136
9137 //----- (0047F458) --------------------------------------------------------
9138 int __stdcall WorldPosToGridCellZ(signed int a1)
9139 {
9140 return 64 - (a1 >> 9);
9141 }
9142
9143 //----- (0047F469) --------------------------------------------------------
9144 int __stdcall GridCellToWorldPosX(int a1)
9145 {
9146 return (a1 - 64) << 9;
9147 }
9148
9149 //----- (0047F476) --------------------------------------------------------
9150 int __stdcall GridCellToWorldPosZ(int a1)
9151 {
9152 return (64 - a1) << 9;
9153 }
9154
9155 //----- (0047F4D3) --------------------------------------------------------
9156 void __fastcall sub_47F4D3(int band1, int band2, int band3)
9157 {
9158 int v3; // edi@1
9159 //stru220 *v4; // esi@1
9160 double v5; // ST2C_8@3
9161 double v6; // st7@3
9162 //double v7; // [sp+18h] [bp-28h]@3
9163 //double v8; // [sp+20h] [bp-20h]@2
9164 int v9; // [sp+34h] [bp-Ch]@1
9165 int v10; // [sp+38h] [bp-8h]@1
9166 //signed int band3a; // [sp+48h] [bp+8h]@2
9167
9168 v9 = band2 * 512;
9169 pOutdoorCamera->outdoor_grid_band_3 = band3;
9170 v10 = band1 * 512;
9171 v3 = band3 * 512;
9172 pOutdoorCamera->uPickDepth = band3 * 512;
9173 //v4 = stru_76E5C8; // v4: 0 -> 65536
9174 for (uint i = 0; i < 16384; ++i)
9175 //do
9176 {
9177 auto v4 = stru_76E5C8 + i;
9178 //band3a = 256;
9179 //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8);
9180 for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128
9181 {
9182 v5 = pow(j * 512 + 256, 2.0);
9183 v6 = pow(i * 4 + 256, 2.0);
9184 //*((float *)&v5 + 1) = sqrt(v6 + v5);
9185 int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15;
9186 if (v7 >= v10)
9187 {
9188 if (v7 >= v9)
9189 v4->field_0 = ((v7 >= v3) - 1) & 2;
9190 else
9191 v4->field_0 = 2;
9192 }
9193 else
9194 {
9195 v4->field_0 = 1;
9196 }
9197 //band3a += 512;
9198 v4->distance = v7;
9199 ++v4;
9200 }
9201 //while ( band3a < 65792 );
9202 }
9203 //while ( (signed int)v4 < (signed int)arary_77E5C8 );
9204 }
9205
9206
9207
9208
9209 //----- (004811A3) --------------------------------------------------------
9210 void stru148::_4811A3()
9211 {
9212 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
9213 pRenderer->DrawTerrainPolygon(uNumVertices, this,
9214 pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]],
9215 0, 0);
9216
9217 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
9218 pRenderer->DrawTerrainPolygon(uNumVertices, this,
9219 pBitmaps_LOD->pHardwareTextures[uTileBitmapID],
9220 1, 1);
9221 }
9222
9223
9224
9225 //----- (00481DB2) --------------------------------------------------------
9226 char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3)
9227 {
9228 int v3; // eax@2
9229 int v4; // esi@2
9230 signed int v5; // esi@2
9231 char *v6; // edi@3
9232 double v7; // ST14_8@4
9233 double v8; // ST0C_8@4
9234 char result; // al@5
9235
9236 if ( a2 >= 3 )
9237 {
9238 v3 = a3->uTileBitmapID;
9239 v4 = a3->uTileBitmapID;
9240 a3->ptr_38 = &stru_8019C8;
9241 a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0);
9242 v5 = 0;
9243 if ( (signed int)a3->uNumVertices > 0 )
9244 {
9245 v6 = (char *)&array_508690[0].vWorldViewProjY;
9246 do
9247 {
9248 v7 = *((float *)v6 - 1) + 6.7553994e15;
9249 dword_50B638[v5] = LODWORD(v7);
9250 v8 = *(float *)v6 + 6.7553994e15;
9251 v6 += 48;
9252 dword_50B570[v5++] = LODWORD(v8);
9253 }
9254 while ( v5 < (signed int)a3->uNumVertices );
9255 }
9256 result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638, dword_50B570, a3);
9257 }
9258 return result;
9259 }
9260 // 50B570: using guessed type int dword_50B570[];
9261 // 50B638: using guessed type int dword_50B638[];
9262
9263
9264
9265 //----- (00481E55) --------------------------------------------------------
9266 void OutdoorCamera::Project(unsigned int uNumVertices)
9267 {
9268 double v1; // st7@2
9269 double v2; // st6@2
9270 double v3; // st5@2
9271 int v4; // eax@2
9272 unsigned int v5; // edx@2
9273 double v6; // st4@3
9274 double v7; // st3@3
9275
9276 if ( (signed int)uNumVertices > 0 )
9277 {
9278 v1 = (double)pOutdoorCamera->int_fov_rad;
9279 v2 = (double)pViewport->uScreenCenterX;
9280 v3 = (double)pViewport->uScreenCenterY;
9281 v4 = 0;
9282 v5 = uNumVertices;
9283 do
9284 {
9285 v6 = v1 * array_507D30[v4].flt_20;
9286 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
9287 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
9288 array_50AC10[v4].vWorldViewProjX = v2 - v7;
9289 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
9290 ++v4;
9291 --v5;
9292 }
9293 while ( v5 );
9294 }
9295 }
9296
9297 //----- (00481EB7) --------------------------------------------------------
9298 void __cdecl ResetStru148s()
9299 {
9300 int v0; // ecx@1
9301 char *v1; // eax@2
9302
9303 v0 = pOutdoorCamera->numStru148s;
9304 if ( pOutdoorCamera->numStru148s > 0 )
9305 {
9306 v1 = (char *)&array_77EC08[0].prolly_tail;
9307 do
9308 {
9309 *((int *)v1 - 1) = 0;
9310 *(int *)v1 = 0;
9311 *((int *)v1 - 5) = 0;
9312 v1 += 268;
9313 --v0;
9314 }
9315 while ( v0 );
9316 }
9317 }
9318
9319 //----- (00481ED9) --------------------------------------------------------
9320 void __cdecl sub_481ED9_MessWithOutdoorCamera()
9321 {
9322 stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0);
9323 pOutdoorCamera->numStru148s = 0;
9324 pOutdoorCamera->uNumEdges = 0;
9325 pOutdoorCamera->uNumSpans = 0;
9326 pOutdoorCamera->uNumSurfs = 0;
9327 pOutdoorCamera->uNumBillboards = 0;
9328 pOutdoorCamera->field_44 = 0;
9329 }
9330
9331 //----- (00481EFA) --------------------------------------------------------
9332 bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5)
9333 {
9334 RenderVertexSoft *v5; // esi@1
9335 RenderVertexSoft *v6; // edx@1
9336 bool v7; // edi@2
9337 bool v8; // ecx@5
9338 bool v9; // esi@8
9339 bool v10; // eax@11
9340 double v11; // st7@14
9341 signed int v12; // esi@15
9342 signed int v13; // edx@18
9343 signed int v14; // ecx@21
9344 signed int v15; // eax@24
9345 RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1
9346
9347 v5 = a2;
9348 v6 = a1;
9349 v17 = v5;
9350 v7 = a1->vWorldViewPosition.x < 8.0;
9351 v8 = v5->vWorldViewPosition.x < 8.0;
9352 v9 = a3->vWorldViewPosition.x < 8.0;
9353 v10 = a4->vWorldViewPosition.x < 8.0;
9354 return !(v8 & v9 & v10 & v7)
9355 && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1),
9356 v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1),
9357 v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1),
9358 v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1),
9359 !(v13 & v14 & v15 & v12));
9360 }
9361
9362 //----- (00481FC9) --------------------------------------------------------
9363 int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)
9364 {
9365 __debugbreak();
9366 return 0;
9367 /*signed int result; // eax@5
9368 __int64 v11; // ST08_8@6
9369 __int64 v12; // ST08_8@6
9370 __int64 v13; // ST08_8@6
9371 __int64 v14; // ST08_8@6
9372
9373 __asm { fld dword ptr [ecx+8] }
9374 _ESI = a2;
9375 _EDX = a3;
9376 __asm { fcomp dword ptr [esi+8] }
9377 _EDI = a4;
9378 __asm { fnstsw ax }
9379 if ( !__SETP__(HIBYTE(_AX) & 0x44, 0) )
9380 {
9381 __asm
9382 {
9383 fld dword ptr [esi+8]
9384 fcomp dword ptr [edx+8]
9385 fnstsw ax
9386 }
9387 if ( !__SETP__(HIBYTE(_AX) & 0x44, 0) )
9388 *(int *)&a4->flags |= 0x10u;
9389 }
9390 __asm
9391 {
9392 fld dword ptr [ecx+0Ch]
9393 fsub dword ptr [esi+0Ch]
9394 fstp [ebp+var_C]
9395 fld dword ptr [ecx+10h]
9396 fsub dword ptr [esi+10h]
9397 fstp [ebp+var_14]
9398 fld dword ptr [ecx+14h]
9399 fsub dword ptr [esi+14h]
9400 fstp [ebp+arg_0]
9401 fld dword ptr [edx+0Ch]
9402 fsub dword ptr [esi+0Ch]
9403 fstp [ebp+var_10]
9404 fld dword ptr [edx+10h]
9405 fsub dword ptr [esi+10h]
9406 fstp [ebp+var_8]
9407 fld dword ptr [edx+14h]
9408 fsub dword ptr [esi+14h]
9409 fstp [ebp+var_4]
9410 fld dword ptr [ecx]
9411 fsub dword ptr [esi]
9412 fld dword ptr [ecx+4]
9413 fsub dword ptr [esi+4]
9414 fld dword ptr [ecx+8]
9415 fsub dword ptr [esi+8]
9416 fld dword ptr [edx]
9417 fsub dword ptr [esi]
9418 fld dword ptr [edx+4]
9419 fsub dword ptr [esi+4]
9420 fld dword ptr [edx+8]
9421 fsub dword ptr [esi+8]
9422 fstp [ebp+arg_4]
9423 fld st
9424 fmul st, st(3)
9425 fld [ebp+arg_4]
9426 fmul st, st(5)
9427 fsubp st(1), st
9428 fild pIndoorCamera->pos.x
9429 fsub dword ptr [esi]
9430 fmulp st(1), st
9431 fld [ebp+arg_4]
9432 fmul st, st(6)
9433 fld st(3)
9434 fmul st, st(5)
9435 fsubp st(1), st
9436 fild pIndoorCamera->pos.y
9437 fsub dword ptr [esi+4]
9438 fmulp st(1), st
9439 faddp st(1), st
9440 fld st(2)
9441 fmul st, st(5)
9442 fld st(2)
9443 fmul st, st(7)
9444 fsubp st(1), st
9445 fild pIndoorCamera->pos.z
9446 fsub dword ptr [esi+8]
9447 fmulp st(1), st
9448 faddp st(1), st
9449 fcomp ds:flt_4D84E8
9450 fstp st
9451 fstp st
9452 fstp st
9453 fnstsw ax
9454 fstp st
9455 fstp st
9456 }
9457 if ( __SETP__(HIBYTE(_AX) & 0x41, 0) )
9458 {
9459 __asm
9460 {
9461 fld [ebp+var_4]
9462 fmul [ebp+var_14]
9463 fld [ebp+var_8]
9464 fmul [ebp+arg_0]
9465 fsubp st(1), st
9466 fstp [ebp+arg_4]
9467 fld [ebp+arg_4]
9468 fadd ds:flt_4D87D0
9469 fstp [ebp+var_20]
9470 fld [ebp+var_10]
9471 fmul [ebp+arg_0]
9472 fld [ebp+var_4]
9473 fmul [ebp+var_C]
9474 }
9475 _EDI->v_18.x = v11;
9476 __asm
9477 {
9478 fsubp st(1), st
9479 fstp [ebp+arg_4]
9480 fld [ebp+arg_4]
9481 fadd ds:flt_4D87D0
9482 fstp [ebp+var_20]
9483 fld [ebp+var_8]
9484 fmul [ebp+var_C]
9485 fld [ebp+var_10]
9486 fmul [ebp+var_14]
9487 }
9488 _EDI->v_18.y = v12;
9489 __asm
9490 {
9491 fsubp st(1), st
9492 fstp [ebp+arg_4]
9493 fld [ebp+arg_4]
9494 fadd ds:flt_4D87D0
9495 fstp [ebp+var_20]
9496 }
9497 _EDI->v_18.z = v13;
9498 stru148::_486089_normalize_v_18(_EDI);
9499 __asm
9500 {
9501 fild dword ptr [edi+18h]
9502 fmul dword ptr [esi+0Ch]
9503 fchs
9504 fild dword ptr [edi+1Ch]
9505 fmul dword ptr [esi+10h]
9506 fsubp st(1), st
9507 fild dword ptr [edi+20h]
9508 fmul dword ptr [esi+14h]
9509 fsubp st(1), st
9510 fstp [ebp+arg_4]
9511 fld [ebp+arg_4]
9512 fadd ds:flt_4D87D0
9513 fstp [ebp+var_20]
9514 }
9515 _EDI->field_24 = v14;
9516 result = 1;
9517 }
9518 else
9519 {
9520 result = 0;
9521 }
9522 return result;*/
9523 }
9524
9525
9526
9527 //----- (004823F4) --------------------------------------------------------
9528 bool __fastcall GetTerrainHeightsAroundParty(int a1, int a2)
9529 {
9530 unsigned int v2; // ebx@1
9531 unsigned int v3; // edi@1
9532 int v4; // eax@1
9533 int v6; // esi@5
9534 int v7; // ecx@6
9535 int v8; // edx@6
9536 int v9; // eax@6
9537 int v10; // esi@10
9538 int v11; // [sp+14h] [bp-8h]@1
9539 int v12; // [sp+18h] [bp-4h]@1
9540
9541 v12 = a1;
9542 v11 = a2;
9543 v2 = WorldPosToGridCellX(a1);
9544 v3 = WorldPosToGridCellZ(v11) - 1;
9545 dword_76D568_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2);
9546 dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1);
9547 dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1);
9548 dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2);
9549 dword_76D558_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3);
9550 dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3);
9551 dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1);
9552 dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1);
9553 dword_76D548_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2, v3);
9554 dword_76D54C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3);
9555 dword_76D550_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3 + 1);
9556 v4 = pOutdoor->DoGetHeightOnTerrain(v2, v3 + 1);
9557 dword_76D554_terrain_cell_world_pos_around_party_y = v4;
9558 if ( dword_76D548_terrain_cell_world_pos_around_party_y == dword_76D54C_terrain_cell_world_pos_around_party_y
9559 && dword_76D54C_terrain_cell_world_pos_around_party_y == dword_76D550_terrain_cell_world_pos_around_party_y
9560 && dword_76D550_terrain_cell_world_pos_around_party_y == v4 )
9561 return 0;
9562 v6 = abs(v12 - dword_76D568_terrain_cell_world_pos_around_party_x);
9563 if ( abs(dword_76D558_terrain_cell_world_pos_around_party_z - v11) >= v6 )
9564 {
9565 v7 = dword_76D554_terrain_cell_world_pos_around_party_y;
9566 v8 = dword_76D550_terrain_cell_world_pos_around_party_y;
9567 v9 = dword_76D548_terrain_cell_world_pos_around_party_y;
9568 }
9569 else
9570 {
9571 v7 = dword_76D54C_terrain_cell_world_pos_around_party_y;
9572 v8 = dword_76D548_terrain_cell_world_pos_around_party_y;
9573 v9 = dword_76D550_terrain_cell_world_pos_around_party_y;
9574 }
9575 if ( v7 >= v8 )
9576 {
9577 v10 = v8;
9578 if ( v8 < v9 )
9579 goto LABEL_13;
9580 LABEL_12:
9581 v10 = v9;
9582 goto LABEL_13;
9583 }
9584 if ( v7 >= v9 )
9585 goto LABEL_12;
9586 v10 = v7;
9587 LABEL_13:
9588 if ( v7 <= v8 )
9589 {
9590 if ( v8 > v9 )
9591 v9 = v8;
9592 }
9593 else
9594 {
9595 if ( v7 > v9 )
9596 v9 = v7;
9597 }
9598 return v9 - v10 > 512;
9599 }
9600
9601
9602 //----- (0048257A) --------------------------------------------------------
9603 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4)
9604 {
9605 unsigned int v4; // ebx@1
9606 unsigned int v5; // edi@1
9607 int result; // eax@9
9608 int v7; // ebx@10
9609 int v8; // ebx@11
9610 int v9; // eax@11
9611 int v10; // ecx@11
9612 int v11; // [sp+Ch] [bp-Ch]@1
9613 int v12; // [sp+10h] [bp-8h]@1
9614 int v13; // [sp+10h] [bp-8h]@11
9615 signed int v14; // [sp+14h] [bp-4h]@3
9616 int v15; // [sp+24h] [bp+Ch]@11
9617
9618 v11 = a1;
9619 v12 = a2;
9620 v4 = WorldPosToGridCellX(a1);
9621 v5 = WorldPosToGridCellZ(v12) - 1;
9622 dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
9623 dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
9624 dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
9625 dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
9626 dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
9627 dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
9628 dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
9629 dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
9630 dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
9631 dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
9632 dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
9633 dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
9634 *a3 = 0;
9635 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(v4, v5) & 2 )
9636 *a3 = 1;
9637 v14 = 0;
9638 if ( !a4 && *a3 )
9639 v14 = -60;
9640 if ( dword_76D518_terrain_cell_world_pos_around_party_y != dword_76D51C_terrain_cell_world_pos_around_party_y
9641 || dword_76D51C_terrain_cell_world_pos_around_party_y != dword_76D520_terrain_cell_world_pos_around_party_y
9642 || dword_76D520_terrain_cell_world_pos_around_party_y != dword_76D524_terrain_cell_world_pos_around_party_y )
9643 {
9644 v7 = abs(v11 - dword_76D538_terrain_cell_world_pos_around_party_x);
9645 if ( abs(dword_76D528_terrain_cell_world_pos_around_party_z - v12) >= v7 )
9646 {
9647 v8 = dword_76D524_terrain_cell_world_pos_around_party_y;
9648 v9 = dword_76D520_terrain_cell_world_pos_around_party_y;
9649 v10 = dword_76D518_terrain_cell_world_pos_around_party_y;
9650 v15 = v11 - dword_76D544_terrain_cell_world_pos_around_party_x;
9651 v13 = v12 - dword_76D534_terrain_cell_world_pos_around_party_z;
9652 }
9653 else
9654 {
9655 v8 = dword_76D51C_terrain_cell_world_pos_around_party_y;
9656 v9 = dword_76D518_terrain_cell_world_pos_around_party_y;
9657 v10 = dword_76D520_terrain_cell_world_pos_around_party_y;
9658 v15 = dword_76D53C_terrain_cell_world_pos_around_party_x - v11;
9659 v13 = dword_76D52C_terrain_cell_world_pos_around_party_z - v12;
9660 }
9661 result = v14
9662 + v8
9663 + ((unsigned __int64)(v13 * (signed __int64)((v10 - v8) << 7)) >> 16)
9664 + ((unsigned __int64)(v15 * (signed __int64)((v9 - v8) << 7)) >> 16);
9665 }
9666 else
9667 {
9668 result = v14 + dword_76D518_terrain_cell_world_pos_around_party_y;
9669 }
9670 return result;
9671 }
9672
9673
9674 //----- (0048276F) --------------------------------------------------------
9675 void stru148::_48276F_sr()
9676 {
9677 unsigned int v1; // ebx@1
9678 float v2; // edx@2
9679 double v3; // st7@2
9680 char *v4; // ecx@3
9681 float v5; // eax@5
9682 float v6; // eax@7
9683 float v7; // eax@9
9684 float v8; // ecx@13
9685 int i; // eax@16
9686 int v10; // edx@20
9687 RenderVertexSoft *v11; // ecx@22
9688 RenderVertexSoft *v12; // edx@22
9689 RenderVertexSoft *v13; // esi@22
9690 int v14; // ebx@26
9691 RenderVertexSoft *v15; // ebx@27
9692 double v16; // st6@28
9693 double v17; // st5@28
9694 double v18; // st4@28
9695 int v19; // [sp+4h] [bp-2Ch]@20
9696 int v20; // [sp+8h] [bp-28h]@22
9697 int v21; // [sp+Ch] [bp-24h]@22
9698 stru148 *v22; // [sp+10h] [bp-20h]@1
9699 float v23; // [sp+14h] [bp-1Ch]@11
9700 float v24; // [sp+18h] [bp-18h]@7
9701 float v25; // [sp+1Ch] [bp-14h]@5
9702 float v26; // [sp+20h] [bp-10h]@2
9703 float v27; // [sp+24h] [bp-Ch]@2
9704 float v28; // [sp+28h] [bp-8h]@2
9705 float v29; // [sp+2Ch] [bp-4h]@9
9706
9707 v1 = this->uNumVertices;
9708 v22 = this;
9709 if ( (signed int)v1 >= 3 )
9710 {
9711 LODWORD(v2) = 0;
9712 v26 = 10000.0;
9713 v28 = 10000.0;
9714 v3 = -10000.0;
9715 v27 = -10000.0;
9716 if ( (signed int)v1 > 0 )
9717 {
9718 v4 = (char *)&array_508690[0].vWorldViewProjY;
9719 do
9720 {
9721 if ( *((float *)v4 - 1) < (double)v26 )
9722 {
9723 LODWORD(v5) = *((int *)v4 - 1);
9724 v25 = v2;
9725 v26 = v5;
9726 }
9727 if ( *((float *)v4 - 1) > (double)v27 )
9728 {
9729 LODWORD(v6) = *((int *)v4 - 1);
9730 v24 = v2;
9731 v27 = v6;
9732 }
9733 if ( *(float *)v4 < (double)v28 )
9734 {
9735 LODWORD(v7) = *(int *)v4;
9736 v29 = v2;
9737 v28 = v7;
9738 }
9739 if ( v3 < *(float *)v4 )
9740 {
9741 v3 = *(float *)v4;
9742 v23 = v2;
9743 }
9744 ++LODWORD(v2);
9745 v4 += 48;
9746 }
9747 while ( SLODWORD(v2) < (signed int)v1 );
9748 }
9749 v8 = v29;
9750 if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) )
9751 v8 = v23;
9752 v29 = 0.0;
9753 for ( i = 0; i < (signed int)v1; ++i )
9754 {
9755 if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) )
9756 {
9757 v10 = LODWORD(v29)++;
9758 *(&v19 + v10) = i;
9759 }
9760 }
9761 v11 = &array_508690[v19];
9762 v12 = &array_508690[v20];
9763 v13 = &array_508690[v21];
9764 if ( LODWORD(v29) != 3 )
9765 {
9766 v11 = array_508690;
9767 v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3));
9768 v12 = &array_508690[1];
9769 v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x;
9770 v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y;
9771 v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z;
9772 v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x;
9773 v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y;
9774 v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z;
9775 if ( v24 * v27 - v25 * v29 == 0.0 )
9776 {
9777 if ( v26 * v29 - v24 * v28 == 0.0 )
9778 {
9779 if ( v25 * v28 - v26 * v27 == 0.0 )
9780 {
9781 v14 = v1 - 2;
9782 LODWORD(v26) = v14;
9783 if ( v14 >= 2 )
9784 {
9785 v15 = &array_508690[v14];
9786 do
9787 {
9788 v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x;
9789 v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y;
9790 v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z;
9791 v13 = v15;
9792 if ( v27 * v18 - v17 * v29 != 0.0 )
9793 break;
9794 if ( v16 * v29 - v18 * v28 != 0.0 )
9795 break;
9796 if ( v28 * v17 - v16 * v27 != 0.0 )
9797 break;
9798 --LODWORD(v26);
9799 --v15;
9800 }
9801 while ( SLODWORD(v26) >= 2 );
9802 }
9803 }
9804 }
9805 }
9806 }
9807 sr_sub_4829B9(v11, v12, v13, v22, 1);
9808 }
9809 }
9810
9811 //----- (004829B9) --------------------------------------------------------
9812 stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5)
9813 {
9814 double v5; // st7@1
9815 RenderVertexSoft *v6; // esi@1
9816 double v7; // st6@1
9817 stru148 *result; // eax@3
9818 double v9; // st6@3
9819 double v10; // st5@3
9820 float v11; // ST0C_4@3
9821 float v12; // ST04_4@3
9822 double v13; // st4@3
9823 float v14; // [sp+8h] [bp-Ch]@1
9824 float v15; // [sp+10h] [bp-4h]@1
9825 float v16; // [sp+1Ch] [bp+8h]@1
9826 float v17; // [sp+1Ch] [bp+8h]@3
9827
9828 v5 = a2->vWorldViewProjX - a1->vWorldViewProjX;
9829 v6 = a3;
9830 v16 = a3->vWorldViewProjY - a1->vWorldViewProjY;
9831 v15 = a2->vWorldViewProjY - a1->vWorldViewProjY;
9832 v14 = v6->vWorldViewProjX - a1->vWorldViewProjX;
9833 v7 = v16 * v5 - v14 * v15;
9834 if ( v7 == 0.0 )
9835 v7 = 0.0000001;
9836 result = a4;
9837 v9 = 1.0 / v7;
9838 v10 = 1.0 / a1->vWorldViewPosition.x;
9839 v11 = 1.0 / a2->vWorldViewPosition.x - v10;
9840 v12 = 1.0 / v6->vWorldViewPosition.x - v10;
9841 v13 = (v11 * v16 - v12 * v15) * v9;
9842 v17 = (v11 * v14 - v12 * v5) * -v9;
9843 a4->field_C = a1->vWorldViewProjX;
9844 a4->field_10 = a1->vWorldViewProjY;
9845 a4->field_0 = v10;
9846 a4->field_8 = v17;
9847 a4->field_4 = v13;
9848 return result;
9849 }
9850
9851 //----- (00482A90) --------------------------------------------------------
9852 signed int __cdecl const_1_0()
9853 {
9854 return 1;
9855 }
9856
9857
9858 //----- (00482A94) --------------------------------------------------------
9859 int sr_sub_482A94(Span *_this)
9860 {
9861 stru315 *v1; // ebp@0
9862 Span *v2; // edi@1
9863 stru148 *v3; // esi@1
9864 int v4; // ecx@1
9865 stru149 *v5; // eax@1
9866 stru149 *v6; // eax@1
9867 int v7; // edx@1
9868 int v8; // eax@1
9869 int v9; // ecx@1
9870 int v10; // edx@1
9871 int v11; // ebx@1
9872 int v12; // eax@1
9873 signed int v13; // ebx@1
9874 int v14; // ebx@2
9875 signed __int64 v15; // qtt@3
9876 stru149 *v16; // eax@3
9877 signed int v17; // ebx@3
9878 Texture *v18; // eax@14
9879 unsigned __int16 *v19; // eax@15
9880 stru149 *v20; // eax@21
9881 signed int v21; // eax@21
9882 int v22; // eax@21
9883 int v23; // ecx@21
9884 Texture *v24; // edx@21
9885 signed int v25; // eax@21
9886 signed int v27; // [sp-4h] [bp-A4h]@8
9887 int v28; // [sp+Ch] [bp-94h]@1
9888 int v29; // [sp+10h] [bp-90h]@1
9889 stru316 a2; // [sp+14h] [bp-8Ch]@21
9890 stru315 a1; // [sp+3Ch] [bp-64h]@1
9891 int v32; // [sp+80h] [bp-20h]@1
9892 int v33; // [sp+84h] [bp-1Ch]@1
9893 int v34; // [sp+88h] [bp-18h]@1
9894 int v35; // [sp+8Ch] [bp-14h]@1
9895 int v36; // [sp+90h] [bp-10h]@1
9896 int v37; // [sp+94h] [bp-Ch]@1
9897 int v38; // [sp+98h] [bp-8h]@1
9898 int X; // [sp+9Ch] [bp-4h]@1
9899
9900 v2 = _this;
9901 v3 = _this->pParent;
9902 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
9903 v5 = v3->ptr_38;
9904 v38 = v4;
9905 v37 = v5->field_14;
9906 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
9907 v6 = v3->ptr_38;
9908 v7 = v38 + v6->field_C;
9909 v37 = v6->field_20;
9910 v33 = v7;
9911 v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
9912 v38 = v4;
9913 v34 = v8;
9914 v37 = v3->v_18.z;
9915 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
9916 v9 = v3->v_18.x;
9917 v28 = v3->sTextureDeltaU << 16;
9918 v35 = v3->sTextureDeltaV << 16;
9919 v10 = v2->field_8;
9920 v29 = pOutdoorCamera->camera_rotation_y_int_sine;
9921 v32 = pOutdoorCamera->camera_rotation_y_int_cosine;
9922 a1.field_28 = v2->field_C;
9923 v11 = v3->field_24;
9924 v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10);
9925 v12 = v3->v_18.y;
9926 v13 = -v11;
9927 v36 = v13;
9928 X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9;
9929 if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) )
9930 return 0;
9931 LODWORD(v15) = v36 << 16;
9932 HIDWORD(v15) = v36 >> 16;
9933 v38 = v15 / X;
9934 v16 = v3->ptr_38;
9935 X = v37;
9936 v36 = v16->field_10;
9937 X = v37;
9938 v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16);
9939 v33 = v3->ptr_38->field_1C;
9940 X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
9941 v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
9942 v17 = 2;
9943 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
9944 if ( v38 >= mipmapping_building_mm1 << 16 )
9945 {
9946 if ( v38 >= mipmapping_building_mm2 << 16 )
9947 {
9948 if ( v38 >= mipmapping_building_mm3 << 16 )
9949 {
9950 if ( bUseLoResSprites )
9951 goto LABEL_12;
9952 v27 = 3;
9953 }
9954 else
9955 {
9956 v27 = 2;
9957 }
9958 v17 = v27;
9959 goto LABEL_12;
9960 }
9961 v17 = 1;
9962 }
9963 else
9964 {
9965 v17 = 0;
9966 }
9967 LABEL_12:
9968 if ( v17 < (signed int)v3->ptr_48 )
9969 v17 = (signed int)v3->ptr_48;
9970 v18 = v3->pTexture;
9971 if ( v17 )
9972 {
9973 if ( v17 == 1 )
9974 {
9975 v19 = (unsigned __int16 *)v18->pLevelOfDetail1;
9976 }
9977 else
9978 {
9979 if ( v17 == 2 )
9980 v19 = (unsigned __int16 *)v18->pLevelOfDetail2;
9981 else
9982 v19 = (unsigned __int16 *)v18->pLevelOfDetail3;
9983 }
9984 }
9985 else
9986 {
9987 v19 = (unsigned __int16 *)v18->pLevelOfDetail0;
9988 }
9989 a1.pTextureLOD = v19;
9990 X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16;
9991 v20 = v3->ptr_38;
9992 X = v38;
9993 a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24;
9994 X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16;
9995 v21 = X - v3->ptr_38->field_28 - v35;
9996 a1.field_30 >>= v17 + bUseLoResSprites;
9997 a1.field_2C = v21 >> (v17 + bUseLoResSprites);
9998 v35 = pOutdoorCamera->int_fov_rad_inv;
9999 v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites);
10000 a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16;
10001 X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16;
10002 a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16);
10003 v22 = v2->field_A;
10004 a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A];
10005 HIWORD(v23) = HIWORD(v38);
10006 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22];
10007 LOWORD(v23) = 0;
10008 a1.field_24 = v23 | v3->field_50;
10009 v24 = v3->pTexture;
10010 v32 = (signed int)v24->uTextureWidth >> v17;
10011 v25 = (signed int)v24->uTextureHeight >> v17;
10012 a1.field_10 = v17 - v24->uWidthLn2 + 16;
10013 a1.field_C = v32 - 1;
10014 a1.field_8 = (v25 << 16) - 65536;
10015 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1);
10016 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10017 sr_sub_485975(&a1, (stru315 *)&a2);
10018 else
10019 sr_sub_4D6FB0(v1);
10020 return 1;
10021 }
10022
10023 //----- (00482E07) --------------------------------------------------------
10024 signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget)
10025 {
10026 stru315 *v2; // ebp@0
10027 stru148 *v3; // esi@1
10028 int v4; // edi@1
10029 int v5; // edi@1
10030 stru149 *v6; // eax@1
10031 stru149 *v7; // eax@1
10032 int v8; // edx@1
10033 int v9; // eax@1
10034 int v10; // edi@1
10035 int v11; // eax@1
10036 unsigned __int64 v12; // qax@1
10037 int v13; // eax@1
10038 signed __int64 v14; // qtt@3
10039 int v15; // ebx@4
10040 signed __int64 v16; // qtt@5
10041 int v17; // eax@5
10042 unsigned __int16 *v18; // eax@7
10043 Texture *v19; // eax@8
10044 Texture *v20; // eax@10
10045 Texture *v21; // eax@12
10046 Texture *v22; // eax@14
10047 int v23; // ecx@17
10048 Texture *v24; // ebx@17
10049 signed int v25; // edx@17
10050 signed int v26; // eax@17
10051 char v27; // bl@17
10052 stru149 *v28; // eax@18
10053 stru149 *v29; // eax@18
10054 int v30; // eax@18
10055 int v31; // eax@18
10056 unsigned int v32; // edx@18
10057 int v33; // edi@21
10058 signed __int64 v34; // qtt@22
10059 signed int v35; // ecx@22
10060 int v36; // eax@24
10061 stru149 *v37; // eax@24
10062 int v38; // edi@24
10063 int v39; // eax@24
10064 int v40; // edi@35
10065 signed __int64 v41; // qtt@36
10066 int v42; // edx@36
10067 stru149 *v43; // eax@36
10068 int v44; // edi@36
10069 int v45; // eax@36
10070 Span *v46; // edi@44
10071 stru149 *v47; // eax@44
10072 stru149 *v48; // eax@44
10073 int v49; // eax@44
10074 int v50; // ecx@44
10075 unsigned int v51; // edx@44
10076 int v52; // edi@46
10077 signed __int64 v53; // qtt@47
10078 unsigned int v54; // ecx@47
10079 int v55; // eax@49
10080 stru149 *v56; // eax@49
10081 int v57; // edi@49
10082 int v58; // eax@49
10083 int v59; // edi@60
10084 signed __int64 v60; // qtt@61
10085 int v61; // edx@61
10086 stru149 *v62; // eax@61
10087 int v63; // edi@61
10088 int v64; // eax@61
10089 int v66; // [sp+Ch] [bp-B8h]@1
10090 int v67; // [sp+10h] [bp-B4h]@1
10091 int v68; // [sp+14h] [bp-B0h]@1
10092 int v69; // [sp+18h] [bp-ACh]@1
10093 int v70; // [sp+1Ch] [bp-A8h]@5
10094 int v71; // [sp+20h] [bp-A4h]@1
10095 signed int v72; // [sp+24h] [bp-A0h]@1
10096 stru316 a2; // [sp+28h] [bp-9Ch]@18
10097 int v74; // [sp+50h] [bp-74h]@17
10098 stru315 a1; // [sp+54h] [bp-70h]@5
10099 Span *v76; // [sp+98h] [bp-2Ch]@1
10100 unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1
10101 int v78; // [sp+A0h] [bp-24h]@17
10102 int v79; // [sp+A4h] [bp-20h]@3
10103 int v80; // [sp+A8h] [bp-1Ch]@3
10104 int v81; // [sp+ACh] [bp-18h]@1
10105 int X; // [sp+B0h] [bp-14h]@2
10106 int v83; // [sp+B4h] [bp-10h]@1
10107 int v84; // [sp+B8h] [bp-Ch]@1
10108 int v85; // [sp+BCh] [bp-8h]@1
10109 int v86; // [sp+C0h] [bp-4h]@18
10110
10111 v85 = ecx0->field_C;
10112 v3 = ecx0->pParent;
10113 v4 = pViewport->uScreenCenterY - ecx0->field_A;
10114 v77 = pRenderTarget;
10115 v5 = pOutdoorCamera->int_fov_rad_inv * v4;
10116 v6 = v3->ptr_38;
10117 v76 = ecx0;
10118 v81 = v5;
10119 v83 = v6->field_14;
10120 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
10121 v7 = v3->ptr_38;
10122 v8 = v81 + v7->field_C;
10123 v83 = v7->field_20;
10124 v67 = v8;
10125 v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18;
10126 v81 = v5;
10127 v71 = v9;
10128 v83 = v3->v_18.z;
10129 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
10130 v68 = v3->sTextureDeltaU << 16;
10131 v69 = v3->sTextureDeltaV << 16;
10132 v72 = -v3->field_24;
10133 v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8);
10134 v11 = v3->v_18.y;
10135 v66 = v81 + v3->v_18.x;
10136 v83 = v10;
10137 v12 = v10 * (signed __int64)v11;
10138 v81 = v12 >> 16;
10139 v13 = v66 + (v12 >> 16);
10140 v84 = v13;
10141 if ( !v13
10142 || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83)
10143 || (LODWORD(v14) = v72 << 16,
10144 HIDWORD(v14) = v72 >> 16,
10145 v79 = v14 / v84,
10146 v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv,
10147 v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16,
10148 (v84 = v66 + v81) == 0)
10149 || (v15 = abs(v66 + v81), abs(X) >= v15) )
10150 return 0;
10151 LODWORD(v16) = v72 << 16;
10152 HIDWORD(v16) = v72 >> 16;
10153 v70 = v16 / v84;
10154 v17 = v16 / v84;
10155 a1.field_24 = v79;
10156 if ( v79 >= v17 )
10157 a1.field_24 = v17;
10158 v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
10159 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
10160 v84 = 2;
10161 if ( a1.field_24 >= mipmapping_building_mm1 << 16 )
10162 {
10163 if ( a1.field_24 >= mipmapping_building_mm2 << 16 )
10164 {
10165 if ( a1.field_24 >= mipmapping_building_mm3 << 16 )
10166 {
10167 if ( bUseLoResSprites )
10168 goto LABEL_16;
10169 v22 = v3->pTexture;
10170 v84 = 3;
10171 v18 = (unsigned __int16 *)v22->pLevelOfDetail3;
10172 }
10173 else
10174 {
10175 v21 = v3->pTexture;
10176 v84 = 2;
10177 v18 = (unsigned __int16 *)v21->pLevelOfDetail2;
10178 }
10179 }
10180 else
10181 {
10182 v20 = v3->pTexture;
10183 v84 = 1;
10184 v18 = (unsigned __int16 *)v20->pLevelOfDetail1;
10185 }
10186 }
10187 else
10188 {
10189 v19 = v3->pTexture;
10190 v84 = 0;
10191 v18 = (unsigned __int16 *)v19->pLevelOfDetail0;
10192 }
10193 a1.pTextureLOD = v18;
10194 LABEL_16:
10195 if ( v18 )
10196 {
10197 v23 = v3->field_5A;
10198 v83 = v3->field_52;
10199 v24 = v3->pTexture;
10200 v74 = v23;
10201 v78 = v85 >> v23;
10202 v25 = v24->uTextureWidth;
10203 v81 = v85 - (v85 >> v23 << v23);
10204 v26 = (signed int)v24->uTextureHeight >> v84;
10205 a1.field_10 = v84 - v24->uWidthLn2 + 16;
10206 v27 = v84 + bUseLoResSprites;
10207 a1.field_8 = (v26 << 16) - 65536;
10208 a1.field_C = (v25 >> v84) - 1;
10209 if ( v79 >= v70 )
10210 {
10211 v46 = v76;
10212 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1);
10213 v47 = v3->ptr_38;
10214 v79 = v80;
10215 v86 = v47->field_10;
10216 v79 = v80;
10217 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
10218 v86 = v3->ptr_38->field_1C;
10219 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
10220 v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16;
10221 v48 = v3->ptr_38;
10222 v79 = v70;
10223 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24;
10224 v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16;
10225 v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28;
10226 a1.field_30 >>= v27;
10227 a1.field_2C = (v69 + v49) >> v27;
10228 a1.field_14 = dword_80AA20 >> v27;
10229 a1.field_18 = dword_80AA1C >> v27;
10230 a1.field_1C = dword_80AA18 >> v27;
10231 v50 = v46->field_8;
10232 a1.field_20 = dword_80AA14 >> v27;
10233 v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A;
10234 a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50);
10235 a1.pColorBuffer = &v77[v85 - 1] + v51;
10236 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
10237 if ( v78 > 0 )
10238 {
10239 do
10240 {
10241 v77 = (unsigned __int16 *)v3->v_18.y;
10242 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16;
10243 v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16);
10244 if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)
10245 && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) )
10246 {
10247 LODWORD(v53) = v72 << 16;
10248 HIDWORD(v53) = v72 >> 16;
10249 v86 = v53 / v84;
10250 v54 = v53 / v84;
10251 v84 = v53 / v84;
10252 }
10253 else
10254 {
10255 v84 = 0x40000000u;
10256 v54 = 0x40000000u;
10257 }
10258 HIWORD(v55) = HIWORD(v54);
10259 LOWORD(v55) = 0;
10260 a1.field_24 = v3->field_50 | v55;
10261 v77 = (unsigned __int16 *)v3->ptr_38->field_10;
10262 v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
10263 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
10264 v56 = v3->ptr_38;
10265 v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24;
10266 v77 = (unsigned __int16 *)v56->field_1C;
10267 v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
10268 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
10269 v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
10270 a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74;
10271 a1.field_0 = v58;
10272 a1.field_28 = v83;
10273 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10274 {
10275 if ( v3->pODMFace->uPolygonType == 1 )
10276 sr_sub_485BAE(&a1, &a2);
10277 else
10278 sr_sub_485AFF(&a1, &a2);
10279 }
10280 else
10281 {
10282 if ( v3->pODMFace->uPolygonType == 1 )
10283 sr_sub_4D71F8(&a1);
10284 else
10285 sr_sub_4D714C(&a1);
10286 }
10287 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
10288 &a2,
10289 v76,
10290 v84,
10291 v3,
10292 pOutdoorCamera->building_gamme,
10293 0,
10294 0);
10295 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
10296 --v78;
10297 }
10298 while ( v78 );
10299 }
10300 if ( !v81 )
10301 return 1;
10302 v83 = v3->v_18.y;
10303 v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16;
10304 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10305 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
10306 {
10307 v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
10308 if ( abs(X) < v59 )
10309 {
10310 LODWORD(v60) = v72 << 16;
10311 HIDWORD(v60) = v72 >> 16;
10312 v86 = v60 / v84;
10313 HIWORD(v61) = (unsigned int)(v60 / v84) >> 16;
10314 LOWORD(v61) = 0;
10315 a1.field_24 = v61 | v3->field_50;
10316 v83 = v3->ptr_38->field_10;
10317 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10318 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
10319 v62 = v3->ptr_38;
10320 v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24;
10321 v83 = v62->field_1C;
10322 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10323 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
10324 v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
10325 - a1.field_2C) >> v74;
10326 a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74;
10327 a1.field_0 = v64;
10328 a1.field_28 = v81;
10329 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10330 {
10331 if ( v3->pODMFace->uPolygonType == 1 )
10332 sr_sub_485BAE(&a1, &a2);
10333 else
10334 sr_sub_485AFF(&a1, &a2);
10335 }
10336 else
10337 {
10338 if ( v3->pODMFace->uPolygonType == 1 )
10339 sr_sub_4D71F8(&a1);
10340 else
10341 sr_sub_4D714C(&a1);
10342 }
10343 return 1;
10344 }
10345 }
10346 }
10347 else
10348 {
10349 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1);
10350 v28 = v3->ptr_38;
10351 v85 = v10;
10352 v86 = v28->field_10;
10353 v85 = v10;
10354 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
10355 v86 = v3->ptr_38->field_1C;
10356 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
10357 v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16;
10358 v29 = v3->ptr_38;
10359 v85 = v79;
10360 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24;
10361 v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16;
10362 v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28;
10363 a1.field_30 >>= v27;
10364 a1.field_2C = (v69 + v30) >> v27;
10365 a1.field_14 = dword_80AA20 >> v27;
10366 a1.field_18 = dword_80AA1C >> v27;
10367 a1.field_1C = dword_80AA18 >> v27;
10368 a1.field_20 = dword_80AA14 >> v27;
10369 v31 = v76->field_A;
10370 v32 = pRenderer->uTargetSurfacePitch * v76->field_A;
10371 v86 = v76->field_8;
10372 a1.pColorBuffer = &v77[v86 + v32];
10373 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31];
10374 v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74);
10375 if ( v78 > 0 )
10376 {
10377 v86 = v78;
10378 do
10379 {
10380 v78 = v3->v_18.y;
10381 v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16;
10382 v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
10383 if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16)
10384 && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) )
10385 {
10386 LODWORD(v34) = v72 << 16;
10387 HIDWORD(v34) = v72 >> 16;
10388 v85 = v34 / v84;
10389 v35 = v34 / v84;
10390 v84 = v34 / v84;
10391 }
10392 else
10393 {
10394 v84 = 1073741824;
10395 v35 = 1073741824;
10396 }
10397 HIWORD(v36) = HIWORD(v35);
10398 LOWORD(v36) = 0;
10399 a1.field_24 = v3->field_50 | v36;
10400 v78 = v3->ptr_38->field_10;
10401 v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
10402 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
10403 v37 = v3->ptr_38;
10404 v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24;
10405 v78 = v37->field_1C;
10406 v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
10407 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
10408 v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
10409 a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74;
10410 a1.field_0 = v39;
10411 a1.field_28 = v83;
10412 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10413 {
10414 if ( v3->pODMFace->uPolygonType == 1 )
10415 sr_sub_485A24(&a1, (stru315 *)&a2);
10416 else
10417 sr_sub_485975(&a1, (stru315 *)&a2);
10418 }
10419 else
10420 {
10421 if ( v3->pODMFace->uPolygonType == 1 )
10422 sr_sub_4D705A(v2);
10423 else
10424 sr_sub_4D6FB0(v2);
10425 }
10426 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
10427 &a2,
10428 v76,
10429 v84,
10430 v3,
10431 pOutdoorCamera->building_gamme,
10432 1u,
10433 0);
10434 v80 -= pOutdoorCamera->int_fov_rad_inv << v74;
10435 --v86;
10436 }
10437 while ( v86 );
10438 }
10439 if ( !v81 )
10440 return 1;
10441 v83 = v3->v_18.y;
10442 v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10443 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10444 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
10445 {
10446 v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
10447 if ( abs(X) < v40 )
10448 {
10449 LODWORD(v41) = v72 << 16;
10450 HIDWORD(v41) = v72 >> 16;
10451 X = v41 / v84;
10452 HIWORD(v42) = (unsigned int)(v41 / v84) >> 16;
10453 LOWORD(v42) = 0;
10454 a1.field_24 = v42 | v3->field_50;
10455 v83 = v3->ptr_38->field_10;
10456 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10457 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
10458 v43 = v3->ptr_38;
10459 v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24;
10460 v83 = v43->field_1C;
10461 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
10462 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
10463 v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
10464 - a1.field_2C) >> v74;
10465 a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74;
10466 a1.field_0 = v45;
10467 a1.field_28 = v81;
10468 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10469 {
10470 if ( v3->pODMFace->uPolygonType == 1 )
10471 sr_sub_485A24(&a1, (stru315 *)&a2);
10472 else
10473 sr_sub_485975(&a1, (stru315 *)&a2);
10474 }
10475 else
10476 {
10477 if ( v3->pODMFace->uPolygonType == 1 )
10478 sr_sub_4D705A(v2);
10479 else
10480 sr_sub_4D6FB0(v2);
10481 }
10482 return 1;
10483 }
10484 }
10485 }
10486 }
10487 return 0;
10488 }
10489 // 4D864C: using guessed type char byte_4D864C;
10490 // 6BE0E4: using guessed type int mipmapping_building_mm1;
10491 // 6BE0E8: using guessed type int mipmapping_building_mm2;
10492 // 6BE0EC: using guessed type int mipmapping_building_mm3;
10493 // 80AA14: using guessed type int dword_80AA14;
10494 // 80AA18: using guessed type int dword_80AA18;
10495 // 80AA1C: using guessed type int dword_80AA1C;
10496 // 80AA20: using guessed type int dword_80AA20;
10497
10498 //----- (004839BD) --------------------------------------------------------
10499 signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface)
10500 {
10501 stru315 *v2; // ebp@0
10502 int v3; // eax@1
10503 int v4; // edi@1
10504 stru148 *v5; // esi@1
10505 unsigned int v6; // ebx@1
10506 int v7; // ecx@1
10507 int v8; // ebx@1
10508 int v9; // ecx@1
10509 int v10; // eax@1
10510 stru149 *v11; // eax@1
10511 int v12; // edx@1
10512 int v13; // eax@1
10513 int v14; // edi@1
10514 int v15; // ecx@1
10515 int v16; // eax@1
10516 signed int v17; // edi@1
10517 int v18; // edi@2
10518 signed __int64 v19; // qtt@3
10519 int v20; // edi@3
10520 unsigned __int16 *v21; // eax@3
10521 Texture *v22; // eax@4
10522 Texture *v23; // eax@6
10523 Texture *v24; // eax@8
10524 Texture *v25; // eax@10
10525 stru149 *v26; // eax@13
10526 int v27; // edi@13
10527 signed int v28; // edx@13
10528 Texture *v29; // ebx@13
10529 int v30; // edi@13
10530 signed int v31; // edx@13
10531 signed int v32; // eax@13
10532 signed int v33; // eax@13
10533 int v34; // ebx@13
10534 int v35; // eax@15
10535 int v36; // ebx@15
10536 int v37; // eax@16
10537 signed __int64 v38; // qtt@17
10538 int v39; // ecx@17
10539 int v40; // eax@19
10540 stru149 *v41; // eax@21
10541 int v42; // ebx@21
10542 int v43; // ebx@21
10543 int v44; // eax@21
10544 char v45; // zf@25
10545 int v46; // eax@28
10546 int v47; // eax@28
10547 int v48; // ebx@28
10548 int v49; // eax@29
10549 signed __int64 v50; // qtt@30
10550 int v51; // ecx@30
10551 int v52; // eax@30
10552 int v53; // edx@31
10553 stru149 *v54; // eax@33
10554 int v55; // ebx@33
10555 signed int v56; // ebx@33
10556 int v57; // eax@33
10557 unsigned __int64 v58; // qax@33
10558 int v60; // [sp+Ch] [bp-BCh]@1
10559 Span *v61; // [sp+10h] [bp-B8h]@1
10560 int v62; // [sp+14h] [bp-B4h]@2
10561 int v63; // [sp+18h] [bp-B0h]@1
10562 stru315 a1; // [sp+1Ch] [bp-ACh]@1
10563 stru316 a2; // [sp+60h] [bp-68h]@13
10564 int v66; // [sp+88h] [bp-40h]@13
10565 int v67; // [sp+8Ch] [bp-3Ch]@1
10566 int v68; // [sp+90h] [bp-38h]@13
10567 int v69; // [sp+94h] [bp-34h]@3
10568 int v70; // [sp+98h] [bp-30h]@1
10569 int v71; // [sp+9Ch] [bp-2Ch]@1
10570 int v72; // [sp+A0h] [bp-28h]@1
10571 int v73; // [sp+A4h] [bp-24h]@13
10572 int v74; // [sp+A8h] [bp-20h]@1
10573 int v75; // [sp+ACh] [bp-1Ch]@3
10574 int v76; // [sp+B0h] [bp-18h]@1
10575 int v77; // [sp+B4h] [bp-14h]@1
10576 int X; // [sp+B8h] [bp-10h]@1
10577 int v79; // [sp+BCh] [bp-Ch]@21
10578 int v80; // [sp+C0h] [bp-8h]@13
10579 unsigned int v81; // [sp+C4h] [bp-4h]@1
10580
10581 v3 = ecx0->field_A;
10582 v4 = ecx0->field_8;
10583 v5 = ecx0->pParent;
10584 v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A;
10585 v61 = ecx0;
10586 v7 = ecx0->field_C;
10587 a1.pColorBuffer = &pTargetSurface[v6];
10588 v74 = v7;
10589 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3];
10590 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
10591 v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3);
10592 v10 = v5->ptr_38->field_14;
10593 v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
10594 v72 = v10;
10595 v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16;
10596 v11 = v5->ptr_38;
10597 v12 = v81 + v11->field_C;
10598 v72 = v11->field_20;
10599 v67 = v12;
10600 v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18;
10601 v81 = v9;
10602 v70 = v13;
10603 v72 = v5->v_18.z;
10604 v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16;
10605 v14 = v5->field_24;
10606 v15 = v81 + v5->v_18.x;
10607 v71 = v5->sTextureDeltaU << 16;
10608 v63 = v5->sTextureDeltaV << 16;
10609 v16 = v5->v_18.y;
10610 v17 = -v14;
10611 v60 = v15;
10612 v77 = v17;
10613 v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16;
10614 X = v81 + v15;
10615 if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) )
10616 return 0;
10617 LODWORD(v19) = v77 << 16;
10618 HIDWORD(v19) = v77 >> 16;
10619 v69 = v19 / X;
10620 v20 = v19 / X;
10621 v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
10622 a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
10623 v75 = 2;
10624 if ( v20 >= mipmapping_building_mm1 << 16 )
10625 {
10626 if ( v20 >= mipmapping_building_mm2 << 16 )
10627 {
10628 if ( v20 >= mipmapping_building_mm3 << 16 )
10629 {
10630 if ( bUseLoResSprites )
10631 goto LABEL_12;
10632 v25 = v5->pTexture;
10633 v75 = 3;
10634 v21 = (unsigned __int16 *)v25->pLevelOfDetail3;
10635 }
10636 else
10637 {
10638 v24 = v5->pTexture;
10639 v75 = 2;
10640 v21 = (unsigned __int16 *)v24->pLevelOfDetail2;
10641 }
10642 }
10643 else
10644 {
10645 v23 = v5->pTexture;
10646 v75 = 1;
10647 v21 = (unsigned __int16 *)v23->pLevelOfDetail1;
10648 }
10649 }
10650 else
10651 {
10652 v22 = v5->pTexture;
10653 v75 = 0;
10654 v21 = (unsigned __int16 *)v22->pLevelOfDetail0;
10655 }
10656 a1.pTextureLOD = v21;
10657 LABEL_12:
10658 if ( v21 )
10659 {
10660 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1);
10661 a1.field_28 = 16;
10662 v66 = v74 >> 4;
10663 v81 = v8;
10664 v26 = v5->ptr_38;
10665 v72 = v74 - 16 * (v74 >> 4);
10666 v76 = v26->field_10;
10667 v81 = v8;
10668 v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
10669 v76 = v5->ptr_38->field_1C;
10670 v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
10671 v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16;
10672 v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24;
10673 v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16;
10674 v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28;
10675 v76 = v75 + bUseLoResSprites;
10676 v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv;
10677 v29 = v5->pTexture;
10678 v30 = (v71 + v27) >> v76;
10679 v31 = v28 >> v76;
10680 v32 = (signed int)v29->uTextureWidth >> v75;
10681 v74 = (signed __int16)v75;
10682 v68 = v31;
10683 v80 = v32;
10684 v33 = (signed int)v29->uTextureHeight >> v75;
10685 v34 = v75 - v29->uWidthLn2;
10686 a1.field_8 = (v33 << 16) - 65536;
10687 v81 = 2 * pMiscTimer->uTotalGameTimeElapsed;
10688 a1.field_10 = v34 + 16;
10689 a1.field_C = v80 - 1;
10690 if ( v66 > 0 )
10691 {
10692 v74 = v66;
10693 v66 = 12 - v75;
10694 do
10695 {
10696 v80 = v5->v_18.y;
10697 v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16;
10698 v36 = v35 + v60;
10699 X = v35 + v60;
10700 if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) )
10701 {
10702 LODWORD(v38) = v77 << 16;
10703 HIDWORD(v38) = v77 >> 16;
10704 v80 = v38 / X;
10705 v39 = v38 / X;
10706 X = v38 / X;
10707 }
10708 else
10709 {
10710 X = 0x40000000u;
10711 v39 = 0x40000000u;
10712 }
10713 HIWORD(v40) = HIWORD(v39);
10714 if ( v39 <= v69 )
10715 HIWORD(v40) = HIWORD(v69);
10716 LOWORD(v40) = 0;
10717 a1.field_24 = v5->field_50 | v40;
10718 v79 = v5->ptr_38->field_10;
10719 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
10720 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
10721 v41 = v5->ptr_38;
10722 v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24;
10723 v79 = v41->field_1C;
10724 v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
10725 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
10726 v43 = (v71 + v42) >> v76;
10727 v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76;
10728 a1.field_4 = (v43 - v30) >> 4;
10729 a1.field_0 = (v79 - v68) >> 4;
10730 a1.field_30 = v30 + 4 * stru_5C6E00->SinCos(v81 + (v68 >> v66));
10731 v44 = stru_5C6E00->SinCos(v81 + (v30 >> v66) - stru_5C6E00->uIntegerHalfPi);
10732 a1.field_2C = v68 + 4 * v44;
10733 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10734 sr_sub_485975(&a1, (stru315 *)&a2);
10735 else
10736 sr_sub_4D6FB0(v2);
10737 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0);
10738 v73 -= 16 * pOutdoorCamera->int_fov_rad_inv;
10739 v45 = v74-- == 1;
10740 a1.field_28 = 16;
10741 v30 = v43;
10742 v68 = v79;
10743 }
10744 while ( !v45 );
10745 v31 = v79;
10746 }
10747 if ( !v72 )
10748 return 1;
10749 v66 = 12 - v75;
10750 a1.field_30 = v30 + 4 * stru_5C6E00->SinCos(v81 + (v31 >> (12 - v75)));
10751 v46 = stru_5C6E00->SinCos(v81 + (v30 >> v66) - stru_5C6E00->uIntegerHalfPi);
10752 a1.field_2C = v68 + 4 * v46;
10753 v79 = v5->v_18.y;
10754 v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
10755 v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
10756 v48 = v47 + v60;
10757 X = v47 + v60;
10758 if ( v47 + v60 )
10759 {
10760 v79 = abs(v62);
10761 v49 = abs(v48);
10762 if ( v79 <= v49 )
10763 {
10764 LODWORD(v50) = v77 << 16;
10765 HIDWORD(v50) = v77 >> 16;
10766 v77 = v50 / X;
10767 v51 = v50 / X;
10768 HIWORD(v52) = HIWORD(v69);
10769 if ( v51 <= v69 )
10770 {
10771 LOWORD(v52) = 0;
10772 a1.field_24 = v52 | v5->field_50;
10773 }
10774 else
10775 {
10776 HIWORD(v53) = HIWORD(v51);
10777 LOWORD(v53) = 0;
10778 a1.field_24 = v53 | v5->field_50;
10779 }
10780 v79 = v5->ptr_38->field_10;
10781 v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
10782 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
10783 v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16;
10784 v54 = v5->ptr_38;
10785 v55 = v67 - v54->field_24;
10786 v79 = v54->field_1C;
10787 v56 = v71 + v55;
10788 v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
10789 v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
10790 v79 = v57;
10791 v58 = v57 * (signed __int64)v51;
10792 v70 = v58 >> 16;
10793 LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76;
10794 a1.field_4 = ((v56 >> v76) - v30) >> 4;
10795 a1.field_0 = ((signed int)v58 - v68) >> 4;
10796 a1.field_28 = v72;
10797 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10798 sr_sub_485975(&a1, (stru315 *)&a2);
10799 else
10800 sr_sub_4D6FB0(v2);
10801 return 1;
10802 }
10803 }
10804 }
10805 return 0;
10806 }
10807 // 4D864C: using guessed type char byte_4D864C;
10808 // 6BE0E4: using guessed type int mipmapping_building_mm1;
10809 // 6BE0E8: using guessed type int mipmapping_building_mm2;
10810 // 6BE0EC: using guessed type int mipmapping_building_mm3;
10811
10812
10813
10814 //----- (0048408A) --------------------------------------------------------
10815 signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this)
10816 {
10817 stru315 *v1; // ebp@0
10818 Span *v2; // edi@1
10819 stru148 *v3; // esi@1
10820 int v4; // ecx@1
10821 stru149 *v5; // eax@1
10822 stru149 *v6; // eax@1
10823 int v7; // edx@1
10824 int v8; // eax@1
10825 int v9; // ebx@1
10826 int v10; // eax@1
10827 int v11; // ecx@1
10828 int v12; // eax@1
10829 int v13; // ecx@1
10830 int v14; // eax@1
10831 signed int v15; // ecx@1
10832 int v16; // ebx@1
10833 signed __int64 v17; // qtt@3
10834 stru149 *v18; // eax@3
10835 int v19; // ebx@3
10836 Texture *v20; // eax@4
10837 unsigned __int16 *v21; // eax@4
10838 Texture *v22; // eax@6
10839 Texture *v23; // ecx@8
10840 Texture *v24; // eax@10
10841 stru149 *v25; // eax@12
10842 signed int v26; // eax@12
10843 int v27; // ecx@12
10844 int v28; // eax@14
10845 int v29; // edx@14
10846 int v30; // ecx@14
10847 Texture *v31; // esi@14
10848 int v32; // edx@14
10849 int v33; // eax@14
10850 int v35; // [sp+Ch] [bp-8Ch]@1
10851 int v36; // [sp+10h] [bp-88h]@1
10852 stru316 a2; // [sp+14h] [bp-84h]@14
10853 stru315 a1; // [sp+3Ch] [bp-5Ch]@1
10854 int v39; // [sp+80h] [bp-18h]@1
10855 int v40; // [sp+84h] [bp-14h]@1
10856 int v41; // [sp+88h] [bp-10h]@1
10857 int v42; // [sp+8Ch] [bp-Ch]@1
10858 int v43; // [sp+90h] [bp-8h]@2
10859 int v44; // [sp+94h] [bp-4h]@1
10860
10861 v2 = _this;
10862 v3 = _this->pParent;
10863 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
10864 v5 = v3->ptr_38;
10865 v44 = v4;
10866 v42 = v5->field_14;
10867 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
10868 v6 = v3->ptr_38;
10869 v7 = v44 + v6->field_C;
10870 v42 = v6->field_20;
10871 v39 = v7;
10872 v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
10873 v44 = v4;
10874 v41 = v8;
10875 v42 = v3->v_18.z;
10876 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
10877 v9 = v44 + v3->v_18.x;
10878 v35 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
10879 v10 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
10880 v11 = v2->field_8;
10881 v36 = v10;
10882 a1.field_28 = v2->field_C;
10883 v12 = pViewport->uScreenCenterX - v11;
10884 v13 = v3->field_24;
10885 v42 = pOutdoorCamera->int_fov_rad_inv * v12;
10886 v14 = v3->v_18.y;
10887 v15 = -v13;
10888 v40 = v15;
10889 v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9;
10890 v44 = v16;
10891 if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) )
10892 return 0;
10893 LODWORD(v17) = v40 << 16;
10894 HIDWORD(v17) = v40 >> 16;
10895 v43 = v17 / v44;
10896 v18 = v3->ptr_38;
10897 v44 = v42;
10898 v40 = v18->field_10;
10899 v44 = v42;
10900 v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16);
10901 v39 = v3->ptr_38->field_1C;
10902 v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
10903 v19 = v43;
10904 v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
10905 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
10906 v44 = 2;
10907 if ( v43 < mipmapping_terrain_mm1 << 16 )
10908 {
10909 v20 = v3->pTexture;
10910 v44 = 0;
10911 v21 = (unsigned __int16 *)v20->pLevelOfDetail0;
10912 LABEL_11:
10913 a1.pTextureLOD = v21;
10914 goto LABEL_12;
10915 }
10916 if ( v43 < mipmapping_terrain_mm2 << 16 )
10917 {
10918 v22 = v3->pTexture;
10919 v44 = 1;
10920 v21 = (unsigned __int16 *)v22->pLevelOfDetail1;
10921 goto LABEL_11;
10922 }
10923 if ( v43 >= mipmapping_terrain_mm3 << 16 )
10924 {
10925 if ( !bUseLoResSprites )
10926 {
10927 v24 = v3->pTexture;
10928 v44 = 3;
10929 v21 = (unsigned __int16 *)v24->pLevelOfDetail3;
10930 goto LABEL_11;
10931 }
10932 }
10933 else
10934 {
10935 v23 = v3->pTexture;
10936 v44 = 2;
10937 a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2;
10938 }
10939 LABEL_12:
10940 v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16;
10941 v25 = v3->ptr_38;
10942 v43 = v19;
10943 a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24;
10944 v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16;
10945 v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28;
10946 v27 = bUseLoResSprites + v44 + 2;
10947 a1.field_30 >>= v27;
10948 v41 = bUseLoResSprites + v44 + 2;
10949 a1.field_2C = v26 >> v27;
10950 if ( byte_80AA10 )
10951 {
10952 a1.field_14 = dword_80AA20 >> v27;
10953 a1.field_18 = dword_80AA1C >> v27;
10954 a1.field_1C = dword_80AA18 >> v27;
10955 a1.field_20 = dword_80AA14 >> v27;
10956 }
10957 v41 = pOutdoorCamera->int_fov_rad_inv;
10958 v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27;
10959 a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16;
10960 v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
10961 a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
10962 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
10963 LOWORD(v19) = 0;
10964 v28 = v2->field_A;
10965 v29 = v2->field_A;
10966 a1.field_24 = v19;
10967 v30 = v2->field_8;
10968 a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29];
10969 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28];
10970 v31 = v3->pTexture;
10971 v32 = ((signed int)v31->uTextureWidth >> v44) - 1;
10972 v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536;
10973 a1.field_10 = v44 - v31->uWidthLn2 + 16;
10974 a1.field_C = v32;
10975 a1.field_8 = v33;
10976 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
10977 {
10978 if ( byte_80AA10 )
10979 sr_sub_485A24(&a1, (stru315 *)&a2);
10980 else
10981 sr_sub_485975(&a1, (stru315 *)&a2);
10982 }
10983 else
10984 {
10985 if ( byte_80AA10 )
10986 sr_sub_4D705A(v1);
10987 else
10988 sr_sub_4D6FB0(v1);
10989 }
10990 return 1;
10991 }
10992
10993
10994
10995 //----- (00484442) --------------------------------------------------------
10996 signed int sr_sub_484442(Span *_this)
10997 {
10998 int v1; // ebp@0
10999 Span *v2; // edi@1
11000 stru148 *v3; // esi@1
11001 int v4; // ecx@1
11002 stru149 *v5; // eax@1
11003 stru149 *v6; // eax@1
11004 int v7; // edx@1
11005 int v8; // eax@1
11006 int v9; // ebx@1
11007 int v10; // eax@1
11008 int v11; // ecx@1
11009 int v12; // eax@1
11010 int v13; // ecx@1
11011 signed int v14; // ecx@1
11012 int v15; // ebx@1
11013 signed __int64 v16; // qtt@3
11014 int v17; // ecx@3
11015 int v18; // ebx@3
11016 int v19; // eax@3
11017 signed int v20; // ebx@3
11018 unsigned __int16 *v21; // eax@4
11019 stru149 *v22; // eax@12
11020 signed int v23; // eax@12
11021 int v24; // ecx@12
11022 int v25; // ecx@14
11023 unsigned int *v26; // eax@14
11024 Texture *v27; // esi@14
11025 signed int v28; // edi@14
11026 signed int v29; // eax@14
11027 signed int v31; // [sp+Ch] [bp-90h]@1
11028 int v32; // [sp+10h] [bp-8Ch]@1
11029 int v33; // [sp+14h] [bp-88h]@1
11030 stru316 v34; // [sp+18h] [bp-84h]@14
11031 stru315 v35; // [sp+40h] [bp-5Ch]@1
11032 int v36; // [sp+84h] [bp-18h]@1
11033 int v37; // [sp+88h] [bp-14h]@1
11034 int v38; // [sp+8Ch] [bp-10h]@1
11035 int v39; // [sp+90h] [bp-Ch]@1
11036 int v40; // [sp+94h] [bp-8h]@1
11037 int v41; // [sp+98h] [bp-4h]@1
11038
11039 v2 = _this;
11040 v3 = _this->pParent;
11041 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
11042 v5 = v3->ptr_38;
11043 v40 = v4;
11044 v39 = v5->field_14;
11045 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
11046 v6 = v3->ptr_38;
11047 v7 = v40 + v6->field_C;
11048 v39 = v6->field_20;
11049 v36 = v7;
11050 v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
11051 v40 = v4;
11052 v38 = v8;
11053 v39 = v3->v_18.z;
11054 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
11055 v9 = v40 + v3->v_18.x;
11056 v32 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
11057 v10 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
11058 v11 = v2->field_8;
11059 v33 = v10;
11060 v35.field_28 = v2->field_C;
11061 v12 = pViewport->uScreenCenterX - v11;
11062 v13 = v3->field_24;
11063 v41 = pOutdoorCamera->int_fov_rad_inv * v12;
11064 v14 = -v13;
11065 v31 = v14;
11066 v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9;
11067 v37 = v15;
11068 if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) )
11069 return 0;
11070 LODWORD(v16) = v31 << 16;
11071 HIDWORD(v16) = v31 >> 16;
11072 v40 = v16 / v37;
11073 v17 = v16 / v37;
11074 v18 = v41;
11075 HIWORD(v19) = (unsigned int)(v16 / v37) >> 16;
11076 LOWORD(v19) = 0;
11077 v35.field_24 = v19;
11078 v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16);
11079 v36 = v3->ptr_38->field_1C;
11080 v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16;
11081 v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16;
11082 v20 = 2;
11083 v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11084 if ( v17 < mipmapping_terrain_mm1 << 16 )
11085 {
11086 v20 = 0;
11087 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0;
11088 LABEL_11:
11089 v35.pTextureLOD = v21;
11090 goto LABEL_12;
11091 }
11092 if ( v17 < mipmapping_terrain_mm2 << 16 )
11093 {
11094 v20 = 1;
11095 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1;
11096 goto LABEL_11;
11097 }
11098 if ( v17 < mipmapping_terrain_mm3 << 16 )
11099 {
11100 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
11101 goto LABEL_11;
11102 }
11103 if ( !bUseLoResSprites )
11104 {
11105 v20 = 3;
11106 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3;
11107 goto LABEL_11;
11108 }
11109 LABEL_12:
11110 v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16;
11111 v22 = v3->ptr_38;
11112 v41 = v17;
11113 v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24;
11114 v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28;
11115 v24 = bUseLoResSprites + v20 + 2;
11116 v35.field_30 >>= v24;
11117 v38 = bUseLoResSprites + v20 + 2;
11118 v35.field_2C = v23 >> v24;
11119 if ( byte_80AA10 )
11120 {
11121 v35.field_14 = dword_80AA20 >> v24;
11122 v35.field_18 = dword_80AA1C >> v24;
11123 v35.field_1C = dword_80AA18 >> v24;
11124 v35.field_20 = dword_80AA14 >> v24;
11125 }
11126 v38 = pOutdoorCamera->int_fov_rad_inv;
11127 v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24;
11128 v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16;
11129 v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
11130 v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
11131 v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
11132 v25 = v2->field_8;
11133 v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A];
11134 v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A];
11135 v35.pDepthBuffer = v26;
11136 v27 = v3->pTexture;
11137 v28 = (signed int)v27->uTextureWidth >> v20;
11138 v29 = (signed int)v27->uTextureHeight >> v20;
11139 v35.field_10 = v20 - v27->uWidthLn2 + 16;
11140 v35.field_C = v28 - 1;
11141 v35.field_8 = (v29 << 16) - 65536;
11142 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11143 {
11144 if ( byte_80AA10 )
11145 sr_sub_485D3E(&v35, &v34);
11146 else
11147 sr_sub_485C89(&v35, &v34);
11148 }
11149 else
11150 {
11151 if ( byte_80AA10 )
11152 sr_sub_4D72EC(v1);
11153 else
11154 sr_sub_4D73DF(v1);
11155 }
11156 return 1;
11157 }
11158
11159
11160 //----- (004847EB) --------------------------------------------------------
11161 int sr_sub_4847EB(Span *_this)
11162 {
11163 stru315 *v1; // ebp@0
11164 int v2; // ebx@1
11165 int v3; // edx@1
11166 stru148 *v4; // esi@1
11167 int v5; // eax@1
11168 signed int v6; // eax@3
11169 int v7; // edi@3
11170 stru149 *v8; // eax@3
11171 stru149 *v9; // eax@3
11172 int v10; // edx@3
11173 int v11; // eax@3
11174 signed int v12; // ebx@3
11175 int v13; // ebx@4
11176 signed __int64 v14; // qtt@5
11177 int v15; // eax@5
11178 signed int v16; // ebx@5
11179 unsigned __int16 *v17; // ecx@6
11180 stru149 *v18; // eax@14
11181 stru149 *v19; // eax@14
11182 signed int v20; // eax@14
11183 int v21; // ecx@14
11184 Texture *v22; // edx@16
11185 signed int v23; // eax@16
11186 int v24; // ebx@16
11187 int v25; // edi@17
11188 int v26; // ebx@17
11189 int v27; // eax@17
11190 int v28; // edi@17
11191 int v29; // eax@18
11192 signed __int64 v30; // qtt@19
11193 int v31; // ecx@19
11194 int v32; // eax@19
11195 stru149 *v33; // eax@21
11196 signed int v34; // edi@21
11197 int v35; // ebx@21
11198 signed int v36; // edi@21
11199 signed __int64 v37; // qtt@21
11200 signed int v38; // ebx@21
11201 int v39; // ebx@29
11202 int v40; // eax@32
11203 unsigned __int64 v41; // qax@32
11204 int v42; // edi@32
11205 int v43; // eax@33
11206 signed __int64 v44; // qtt@34
11207 int v45; // ecx@34
11208 int v46; // eax@34
11209 stru149 *v47; // eax@36
11210 signed int v48; // edi@36
11211 int v49; // eax@36
11212 int v50; // eax@47
11213 unsigned __int64 v51; // qax@47
11214 int v52; // edi@47
11215 int v53; // eax@48
11216 signed __int64 v54; // qtt@49
11217 int v55; // ecx@49
11218 int v56; // eax@49
11219 stru149 *v57; // eax@51
11220 signed int v58; // edi@51
11221 int v59; // eax@51
11222 Span *v61; // [sp+Ch] [bp-B0h]@1
11223 int v62; // [sp+10h] [bp-ACh]@3
11224 int v63; // [sp+14h] [bp-A8h]@3
11225 int v64; // [sp+18h] [bp-A4h]@3
11226 int v65; // [sp+1Ch] [bp-A0h]@3
11227 signed int v66; // [sp+20h] [bp-9Ch]@3
11228 signed int v67; // [sp+24h] [bp-98h]@3
11229 int v68; // [sp+28h] [bp-94h]@1
11230 char v69; // [sp+2Ch] [bp-90h]@1
11231 stru315 sr; // [sp+30h] [bp-8Ch]@1
11232 stru316 sr2; // [sp+74h] [bp-48h]@14
11233 int v72; // [sp+9Ch] [bp-20h]@5
11234 int v73; // [sp+A0h] [bp-1Ch]@1
11235 int v74; // [sp+A4h] [bp-18h]@3
11236 int v75; // [sp+A8h] [bp-14h]@21
11237 int v76; // [sp+ACh] [bp-10h]@1
11238 int v77; // [sp+B0h] [bp-Ch]@14
11239 int v78; // [sp+B4h] [bp-8h]@3
11240 int v79; // [sp+B8h] [bp-4h]@3
11241
11242 v2 = _this->field_A;
11243 v3 = _this->field_8;
11244 v4 = _this->pParent;
11245 v73 = 0;
11246 v61 = _this;
11247 sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
11248 v76 = v3;
11249 v5 = _this->field_C;
11250 sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2];
11251 v68 = texmapping_terrain_subdivsize;
11252 v69 = texmapping_terrain_subdivpow2;
11253 if ( v5 >= texmapping_terrain_subdivsize )
11254 v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1));
11255 v6 = v5 - v73;
11256 v67 = v6 >> texmapping_terrain_subdivpow2;
11257 v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2);
11258 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
11259 v8 = v4->ptr_38;
11260 v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
11261 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
11262 v76 = v8->field_14;
11263 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
11264 v9 = v4->ptr_38;
11265 v10 = v78 + v9->field_C;
11266 v76 = v9->field_20;
11267 v65 = v10;
11268 v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16)
11269 + v4->ptr_38->field_18;
11270 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
11271 v64 = v11;
11272 v76 = v4->v_18.z;
11273 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
11274 v12 = -v4->field_24;
11275 v63 = v78 + v4->v_18.x;
11276 v66 = -v4->field_24;
11277 v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16;
11278 v74 = v78 + v63;
11279 if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) )
11280 return 0;
11281 LODWORD(v14) = v66 << 16;
11282 HIDWORD(v14) = v66 >> 16;
11283 v72 = v14 / v74;
11284 sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
11285 v15 = v14 / v74;
11286 v16 = 2;
11287 if ( v15 >= mipmapping_terrain_mm1 << 16 )
11288 {
11289 if ( v15 >= mipmapping_terrain_mm2 << 16 )
11290 {
11291 if ( v15 >= mipmapping_terrain_mm3 << 16 )
11292 {
11293 if ( bUseLoResSprites )
11294 goto LABEL_14;
11295 v16 = 3;
11296 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3;
11297 }
11298 else
11299 {
11300 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
11301 }
11302 }
11303 else
11304 {
11305 v16 = 1;
11306 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1;
11307 }
11308 }
11309 else
11310 {
11311 v16 = 0;
11312 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0;
11313 }
11314 sr.pTextureLOD = v17;
11315 LABEL_14:
11316 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1);
11317 v18 = v4->ptr_38;
11318 v78 = v7;
11319 v79 = v18->field_10;
11320 v78 = v7;
11321 v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
11322 v79 = v4->ptr_38->field_1C;
11323 v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
11324 v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16;
11325 v19 = v4->ptr_38;
11326 v78 = v72;
11327 sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24;
11328 v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
11329 v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28;
11330 v21 = bUseLoResSprites + v16 + 2;
11331 sr.field_30 >>= v21;
11332 v78 = bUseLoResSprites + v16 + 2;
11333 sr.field_2C = v20 >> v21;
11334 if ( byte_80AA10 )
11335 {
11336 sr.field_14 = dword_80AA20 >> v21;
11337 sr.field_18 = dword_80AA1C >> v21;
11338 sr.field_1C = dword_80AA18 >> v21;
11339 sr.field_20 = dword_80AA14 >> v21;
11340 }
11341 v22 = v4->pTexture;
11342 v79 = (signed int)v22->uTextureWidth >> v16;
11343 v23 = (signed int)v22->uTextureHeight >> v16;
11344 v24 = v16 - v22->uWidthLn2 + 16;
11345 sr.field_8 = (v23 << 16) - 65536;
11346 sr.field_10 = v24;
11347 sr.field_C = v79 - 1;
11348 if ( v73 )
11349 {
11350 v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv;
11351 v26 = v25;
11352 v77 = v4->v_18.y;
11353 v79 = v25;
11354 v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16;
11355 v28 = v27 + v63;
11356 v74 = v27 + v63;
11357 if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) )
11358 return 0;
11359 LODWORD(v30) = v66 << 16;
11360 HIDWORD(v30) = v66 >> 16;
11361 v77 = v30 / v74;
11362 v31 = v30 / v74;
11363 HIWORD(v32) = HIWORD(v72);
11364 if ( v72 <= v31 )
11365 HIWORD(v32) = HIWORD(v31);
11366 LOWORD(v32) = 0;
11367 v77 = v26;
11368 sr.field_24 = v32;
11369 v74 = v4->ptr_38->field_10;
11370 v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
11371 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
11372 v33 = v4->ptr_38;
11373 v77 = v26;
11374 v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24;
11375 v74 = v33->field_1C;
11376 v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
11377 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
11378 v35 = (v77 - v4->ptr_38->field_28) >> v78;
11379 v74 = v73 << 16;
11380 v36 = (v34 >> v78) - sr.field_30;
11381 LODWORD(v37) = v36 << 16;
11382 HIDWORD(v37) = v36 >> 16;
11383 v38 = v35 - sr.field_2C;
11384 sr.field_4 = v37 / (v73 << 16);
11385 v75 = v73 << 16;
11386 LODWORD(v37) = v38 << 16;
11387 HIDWORD(v37) = v38 >> 16;
11388 v77 = v37 / (v73 << 16);
11389 sr.field_0 = v37 / (v73 << 16);
11390 sr.field_28 = v73;
11391 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11392 {
11393 if ( byte_80AA10 )
11394 sr_sub_485A24(&sr, (stru315 *)&sr2);
11395 else
11396 sr_sub_485975(&sr, (stru315 *)&sr2);
11397 }
11398 else
11399 {
11400 if ( byte_80AA10 )
11401 sr_sub_4D705A(v1);
11402 else
11403 sr_sub_4D6FB0(v1);
11404 }
11405 v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69);
11406 }
11407 else
11408 {
11409 v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
11410 v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
11411 }
11412 sr.field_28 = v68;
11413 while ( v67 > 0 )
11414 {
11415 v40 = v4->v_18.y;
11416 --v67;
11417 v75 = v40;
11418 v41 = v40 * (signed __int64)v39;
11419 v79 = v41 >> 16;
11420 LODWORD(v41) = v41 >> 16;
11421 v42 = v41 + v63;
11422 v74 = v41 + v63;
11423 if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) )
11424 return 0;
11425 LODWORD(v44) = v66 << 16;
11426 HIDWORD(v44) = v66 >> 16;
11427 v73 = v44 / v74;
11428 v45 = v44 / v74;
11429 HIWORD(v46) = HIWORD(v72);
11430 if ( v72 <= v45 )
11431 HIWORD(v46) = HIWORD(v45);
11432 LOWORD(v46) = 0;
11433 v79 = v39;
11434 sr.field_24 = v46;
11435 v75 = v4->ptr_38->field_10;
11436 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
11437 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
11438 v47 = v4->ptr_38;
11439 v79 = v39;
11440 v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24;
11441 v75 = v47->field_1C;
11442 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
11443 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
11444 v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
11445 sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69;
11446 sr.field_0 = v49;
11447 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11448 {
11449 if ( byte_80AA10 )
11450 sr_sub_485A24(&sr, (stru315 *)&sr2);
11451 else
11452 sr_sub_485975(&sr, (stru315 *)&sr2);
11453 }
11454 else
11455 {
11456 if ( byte_80AA10 )
11457 sr_sub_4D705A(v1);
11458 else
11459 sr_sub_4D6FB0(v1);
11460 }
11461 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0);
11462 sr.field_28 = v68;
11463 v39 -= pOutdoorCamera->int_fov_rad_inv << v69;
11464 }
11465 if ( !v62 )
11466 return 1;
11467 v50 = v4->v_18.y;
11468 v75 = v50;
11469 v51 = v50 * (signed __int64)v39;
11470 v79 = v51 >> 16;
11471 LODWORD(v51) = v51 >> 16;
11472 v52 = v51 + v63;
11473 v74 = v51 + v63;
11474 if ( (int)v51 + v63 )
11475 {
11476 v75 = abs(v76);
11477 v53 = abs(v52);
11478 if ( v75 <= v53 )
11479 {
11480 LODWORD(v54) = v66 << 16;
11481 HIDWORD(v54) = v66 >> 16;
11482 v76 = v54 / v74;
11483 v55 = v54 / v74;
11484 HIWORD(v56) = HIWORD(v72);
11485 if ( v72 <= v55 )
11486 HIWORD(v56) = HIWORD(v55);
11487 LOWORD(v56) = 0;
11488 v76 = v39;
11489 sr.field_24 = v56;
11490 v75 = v4->ptr_38->field_10;
11491 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
11492 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
11493 v57 = v4->ptr_38;
11494 v76 = v39;
11495 v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24;
11496 v75 = v57->field_1C;
11497 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
11498 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
11499 v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
11500 sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69;
11501 sr.field_0 = v59;
11502 sr.field_28 = v62;
11503 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11504 {
11505 if ( byte_80AA10 )
11506 sr_sub_485A24(&sr, (stru315 *)&sr2);
11507 else
11508 sr_sub_485975(&sr, (stru315 *)&sr2);
11509 }
11510 else
11511 {
11512 if ( byte_80AA10 )
11513 sr_sub_4D705A(v1);
11514 else
11515 sr_sub_4D6FB0(v1);
11516 }
11517 return 1;
11518 }
11519 }
11520 return 0;
11521 }
11522 // 4D864C: using guessed type char byte_4D864C;
11523 // 6BE050: using guessed type int texmapping_terrain_subdivsize;
11524 // 6BE054: using guessed type int texmapping_terrain_subdivpow2;
11525 // 6BE0F0: using guessed type int mipmapping_terrain_mm1;
11526 // 6BE0F4: using guessed type int mipmapping_terrain_mm2;
11527 // 6BE0F8: using guessed type int mipmapping_terrain_mm3;
11528 // 80AA10: using guessed type char byte_80AA10;
11529 // 80AA14: using guessed type int dword_80AA14;
11530 // 80AA18: using guessed type int dword_80AA18;
11531 // 80AA1C: using guessed type int dword_80AA1C;
11532 // 80AA20: using guessed type int dword_80AA20;
11533
11534
11535
11536 //----- (00485407) --------------------------------------------------------
11537 signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1)
11538 {
11539 stru315 *v1; // ebp@0
11540 int v2; // eax@1
11541 int v3; // edx@1
11542 unsigned int v4; // edi@1
11543 stru148 *v5; // esi@1
11544 int v6; // ecx@1
11545 int v7; // ebx@1
11546 int v8; // ecx@1
11547 stru149 *v9; // eax@1
11548 stru149 *v10; // eax@1
11549 int v11; // edx@1
11550 int v12; // eax@1
11551 int v13; // eax@1
11552 int v14; // ecx@1
11553 signed int v15; // edi@1
11554 int v16; // edi@2
11555 signed __int64 v17; // qtt@3
11556 int v18; // edi@3
11557 int v19; // eax@3
11558 unsigned __int8 *pLOD; // eax@3
11559 Texture *v21; // eax@4
11560 Texture *v22; // eax@6
11561 Texture *v23; // eax@8
11562 Texture *v24; // eax@10
11563 stru149 *v25; // eax@13
11564 stru149 *v26; // eax@13
11565 signed int v27; // ebx@13
11566 stru149 *v28; // eax@13
11567 Texture *v29; // esi@13
11568 signed int v30; // ebx@13
11569 signed int v31; // edi@13
11570 signed int v32; // edx@13
11571 signed int v33; // eax@13
11572 int v34; // esi@13
11573 int v35; // eax@13
11574 unsigned __int64 v36; // qax@13
11575 int v37; // eax@13
11576 unsigned __int64 v38; // qax@13
11577 char v39; // cl@14
11578 stru316 a2; // [sp+Ch] [bp-90h]@13
11579 stru315 a1a; // [sp+34h] [bp-68h]@1
11580 Span *v43; // [sp+78h] [bp-24h]@1
11581 int v44; // [sp+7Ch] [bp-20h]@1
11582 int v45; // [sp+80h] [bp-1Ch]@1
11583 int v46; // [sp+84h] [bp-18h]@1
11584 Span *v47; // [sp+88h] [bp-14h]@1
11585 int v48; // [sp+8Ch] [bp-10h]@1
11586 int v49; // [sp+90h] [bp-Ch]@3
11587 int i; // [sp+94h] [bp-8h]@3
11588 int X; // [sp+98h] [bp-4h]@1
11589
11590 v2 = a1->field_A;
11591 v3 = a1->field_8;
11592 v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A;
11593 v5 = a1->pParent;
11594 v43 = a1;
11595 v6 = a1->field_C;
11596 a1a.pColorBuffer = &pRenderer->pTargetSurface[v4];
11597 v46 = v6;
11598 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3);
11599 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
11600 a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
11601 v9 = v5->ptr_38;
11602 v47 = (Span *)v7;
11603 X = v8;
11604 v48 = v9->field_14;
11605 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
11606 v10 = v5->ptr_38;
11607 v11 = X + v10->field_C;
11608 v48 = v10->field_20;
11609 v44 = v11;
11610 v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18;
11611 X = v8;
11612 v45 = v12;
11613 v48 = v5->v_18.z;
11614 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
11615 v13 = v5->v_18.y;
11616 v14 = X + v5->v_18.x;
11617 v15 = -v5->field_24;
11618 v48 = -v5->field_24;
11619 X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14;
11620 if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) )
11621 return 0;
11622 LODWORD(v17) = v48 << 16;
11623 HIDWORD(v17) = v48 >> 16;
11624 i = v17 / X;
11625 v18 = v17 / X;
11626 HIWORD(v19) = (unsigned int)(v17 / X) >> 16;
11627 LOWORD(v19) = 0;
11628 a1a.field_24 = v19;
11629 pLOD = v5->pTexture->pLevelOfDetail2;
11630 a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
11631 v49 = 2;
11632 if ( v18 >= mipmapping_terrain_mm1 << 16 )
11633 {
11634 if ( v18 >= mipmapping_terrain_mm2 << 16 )
11635 {
11636 if ( v18 >= mipmapping_terrain_mm3 << 16 )
11637 {
11638 if ( bUseLoResSprites )
11639 goto LABEL_12;
11640 v24 = v5->pTexture;
11641 v49 = 3;
11642 pLOD = v24->pLevelOfDetail3;
11643 }
11644 else
11645 {
11646 v23 = v5->pTexture;
11647 v49 = 2;
11648 pLOD = v23->pLevelOfDetail2;
11649 }
11650 }
11651 else
11652 {
11653 v22 = v5->pTexture;
11654 v49 = 1;
11655 pLOD = v22->pLevelOfDetail1;
11656 }
11657 }
11658 else
11659 {
11660 v21 = v5->pTexture;
11661 v49 = 0;
11662 pLOD = v21->pLevelOfDetail0;
11663 }
11664 a1a.pTextureLOD = (unsigned __int16 *)pLOD;
11665 LABEL_12:
11666 if ( !pLOD )
11667 return 0;
11668 a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1);
11669 a1a.field_28 = 16;
11670 v43 = (Span *)(v46 >> 4);
11671 X = v7;
11672 v25 = v5->ptr_38;
11673 v48 = v46 - 16 * (v46 >> 4);
11674 v46 = v25->field_10;
11675 X = v7;
11676 v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16);
11677 v44 = v5->ptr_38->field_1C;
11678 v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16;
11679 X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16;
11680 v26 = v5->ptr_38;
11681 X = v18;
11682 v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24;
11683 X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16;
11684 v28 = v5->ptr_38;
11685 v29 = v5->pTexture;
11686 v44 = bUseLoResSprites + v49 + 2;
11687 v30 = v27 >> v44;
11688 v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44;
11689 v32 = (signed int)v29->uTextureWidth >> v49;
11690 v33 = (signed int)v29->uTextureHeight >> v49;
11691 v34 = v49 - v29->uWidthLn2;
11692 a1a.field_8 = (v33 << 16) - 65536;
11693 X = 2 * pMiscTimer->uTotalGameTimeElapsed;
11694 v45 = pOutdoorCamera->int_fov_rad_inv;
11695 a1a.field_10 = v34 + 16;
11696 a1a.field_C = v32 - 1;
11697 i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16;
11698 v47 = (Span *)(i >> v44);
11699 v35 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
11700 v36 = (signed int)v47 * (signed __int64)v35;
11701 i = v36 >> 16;
11702 a1a.field_4 = v36 >> 16;
11703 v37 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
11704 v38 = (signed int)v47 * (signed __int64)v37;
11705 i = v38 >> 16;
11706 a1a.field_0 = v38 >> 16;
11707 if ( (signed int)v43 > 0 )
11708 {
11709 v47 = v43;
11710 v39 = 12 - v49;
11711 for ( i = 12 - v49; ; v39 = i )
11712 {
11713 a1a.field_30 = v30 + 4 * stru_5C6E00->SinCos(X + (v31 >> v39));
11714 a1a.field_2C = v31 + 4 * stru_5C6E00->SinCos(X + (v30 >> i) - stru_5C6E00->uIntegerHalfPi);
11715 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11716 sr_sub_485975(&a1a, (stru315 *)&a2);
11717 else
11718 sr_sub_4D6FB0(v1);
11719 a1a.field_28 = 16;
11720 v30 += 16 * a1a.field_4;
11721 v31 += 16 * a1a.field_0;
11722 v47 = (Span *)((char *)v47 - 1);
11723 if ( !v47 )
11724 break;
11725 }
11726 }
11727 if ( v48 )
11728 {
11729 i = 12 - v49;
11730 a1a.field_30 = v30 + 4 * stru_5C6E00->SinCos(X + (v31 >> (12 - v49)));
11731 a1a.field_2C = v31 + 4 * stru_5C6E00->SinCos(X + (v30 >> i) - stru_5C6E00->uIntegerHalfPi);
11732 a1a.field_28 = v48;
11733 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
11734 sr_sub_485975(&a1a, (stru315 *)&a2);
11735 else
11736 sr_sub_4D6FB0(v1);
11737 }
11738 return 1;
11739 }
11740
11741
11742 //----- (0048585C) --------------------------------------------------------
11743 signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4)
11744 {
11745 Span *v3; // esi@1
11746 stru148 *v4; // edi@1
11747 int v5; // ebx@2
11748 signed __int64 v6; // qtt@3
11749 int v7; // ebx@3
11750 signed int v8; // ecx@3
11751 void *v9; // eax@5
11752 int v10; // ecx@5
11753 unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1
11754 signed int v13; // [sp+10h] [bp-10h]@1
11755 int X; // [sp+18h] [bp-8h]@1
11756
11757 v3 = a1;
11758 pPixels = pRenderTarget;
11759 v4 = a1->pParent;
11760 v13 = -v4->field_24;
11761 X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv
11762 * (pViewport->uScreenCenterX - (signed int)a1->field_8)
11763 * (signed __int64)v4->v_18.y) >> 16)
11764 + ((unsigned __int64)(v4->v_18.z
11765 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv
11766 * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16)
11767 + v4->v_18.x;
11768 if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) )
11769 {
11770 LODWORD(v6) = v13 << 16;
11771 HIDWORD(v6) = v13 >> 16;
11772 v7 = v6 / X;
11773 v8 = v6 / X;
11774 }
11775 else
11776 {
11777 v7 = pOutdoorCamera->shading_dist_mist << 16;
11778 v8 = pOutdoorCamera->shading_dist_mist << 16;
11779 }
11780 v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4);
11781 fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C);
11782 HIWORD(v10) = HIWORD(v7);
11783 LOWORD(v10) = 0;
11784 j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C);
11785 return 1;
11786 }
11787
11788 //----- (00485975) --------------------------------------------------------
11789 stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2)
11790 {
11791 stru315 *result; // eax@1
11792 int i; // ecx@1
11793 int v4; // esi@2
11794 int v5; // esi@2
11795 int v6; // ecx@2
11796 int v7; // esi@3
11797 int v8; // edi@3
11798 int v9; // ebx@3
11799 int v10; // ecx@8
11800 unsigned __int16 *v11; // esi@10
11801 unsigned int *v12; // ecx@12
11802 int v13; // esi@12
11803 int v14; // [sp+0h] [bp-4h]@2
11804
11805 result = a1;
11806 for ( i = a1->field_28; i; i = result->field_28 )
11807 {
11808 v4 = result->field_8 & result->field_2C;
11809 result->field_28 = i - 1;
11810 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
11811 v6 = *((char *)result->pTextureLOD + v5);
11812 v14 = *((char *)result->pTextureLOD + v5);
11813 if ( a2->field_20 )
11814 {
11815 v7 = HIWORD(a2->field_10);
11816 v8 = a2->field_C;
11817 v9 = v7;
11818 if ( v7 >= v8 )
11819 v9 = a2->field_C;
11820 if ( a2->field_8 - v9 <= 0 )
11821 {
11822 v10 = 0;
11823 }
11824 else
11825 {
11826 if ( v7 >= v8 )
11827 v7 = a2->field_C;
11828 v10 = a2->field_8 - v7;
11829 }
11830 v11 = (unsigned __int16 *)a2->field_24;
11831 v6 = v14 + (v10 << 8);
11832 }
11833 else
11834 {
11835 v11 = result->field_34_palette;
11836 }
11837 *result->pColorBuffer = v11[v6];
11838 v12 = result->pDepthBuffer;
11839 v13 = result->field_24;
11840 ++result->pColorBuffer;
11841 *v12 = v13;
11842 ++result->pDepthBuffer;
11843 a2->field_10 += a2->field_18;
11844 result->field_30 += result->field_4;
11845 result->field_2C += result->field_0;
11846 }
11847 --result->field_28;
11848 return result;
11849 }
11850
11851 //----- (00485A24) --------------------------------------------------------
11852 stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2)
11853 {
11854 stru315 *result; // eax@1
11855 int i; // ecx@1
11856 int v4; // ecx@2
11857 int v5; // ecx@4
11858 int v6; // ecx@6
11859 int v7; // ecx@8
11860 int v8; // esi@10
11861 int v9; // ecx@10
11862 int v10; // esi@11
11863 int v11; // edi@11
11864 int v12; // ebx@11
11865 int v13; // ecx@16
11866 unsigned __int16 *v14; // esi@18
11867 unsigned int *v15; // ecx@20
11868 int v16; // esi@20
11869 int v17; // [sp+0h] [bp-4h]@10
11870
11871 result = a1;
11872 for ( i = a1->field_28; i; i = result->field_28 )
11873 {
11874 result->field_28 = i - 1;
11875 v4 = result->field_18;
11876 if ( result->field_30 > v4 )
11877 result->field_30 = v4;
11878 v5 = result->field_20;
11879 if ( result->field_2C > v5 )
11880 result->field_2C = v5;
11881 v6 = result->field_14;
11882 if ( result->field_30 < v6 )
11883 result->field_30 = v6;
11884 v7 = result->field_1C;
11885 if ( result->field_2C < v7 )
11886 result->field_2C = v7;
11887 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
11888 v9 = *((char *)result->pTextureLOD + v8);
11889 v17 = *((char *)result->pTextureLOD + v8);
11890 if ( a2->field_20 )
11891 {
11892 v10 = HIWORD(a2->field_10);
11893 v11 = a2->field_C;
11894 v12 = v10;
11895 if ( v10 >= v11 )
11896 v12 = a2->field_C;
11897 if ( a2->field_8 - v12 <= 0 )
11898 {
11899 v13 = 0;
11900 }
11901 else
11902 {
11903 if ( v10 >= v11 )
11904 v10 = a2->field_C;
11905 v13 = a2->field_8 - v10;
11906 }
11907 v14 = (unsigned __int16 *)a2->field_24;
11908 v9 = v17 + (v13 << 8);
11909 }
11910 else
11911 {
11912 v14 = result->field_34_palette;
11913 }
11914 *result->pColorBuffer = v14[v9];
11915 v15 = result->pDepthBuffer;
11916 v16 = result->field_24;
11917 ++result->pColorBuffer;
11918 *v15 = v16;
11919 ++result->pDepthBuffer;
11920 a2->field_10 += a2->field_18;
11921 result->field_30 += result->field_4;
11922 result->field_2C += result->field_0;
11923 }
11924 --result->field_28;
11925 return result;
11926 }
11927
11928 //----- (00485AFF) --------------------------------------------------------
11929 stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2)
11930 {
11931 stru315 *result; // eax@1
11932 int i; // ecx@1
11933 int v4; // esi@2
11934 int v5; // esi@2
11935 int v6; // ecx@2
11936 int v7; // esi@3
11937 int v8; // edi@3
11938 int v9; // ebx@3
11939 int v10; // ecx@8
11940 unsigned __int16 *v11; // esi@10
11941 unsigned int *v12; // ecx@12
11942 int v13; // esi@12
11943 int v14; // [sp+0h] [bp-4h]@2
11944
11945 result = a1;
11946 for ( i = a1->field_28; i; i = result->field_28 )
11947 {
11948 v4 = result->field_8 & result->field_2C;
11949 result->field_28 = i - 1;
11950 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
11951 v6 = *((char *)result->pTextureLOD + v5);
11952 v14 = *((char *)result->pTextureLOD + v5);
11953 if ( a2->field_20 )
11954 {
11955 v7 = HIWORD(a2->field_14);
11956 v8 = a2->field_C;
11957 v9 = v7;
11958 if ( v7 >= v8 )
11959 v9 = a2->field_C;
11960 if ( a2->field_8 - v9 <= 0 )
11961 {
11962 v10 = 0;
11963 }
11964 else
11965 {
11966 if ( v7 >= v8 )
11967 v7 = a2->field_C;
11968 v10 = a2->field_8 - v7;
11969 }
11970 v11 = a2->field_24_palette;
11971 v6 = v14 + (v10 << 8);
11972 }
11973 else
11974 {
11975 v11 = result->field_34_palette;
11976 }
11977 *result->pColorBuffer = v11[v6];
11978 v12 = result->pDepthBuffer;
11979 v13 = result->field_24;
11980 --result->pColorBuffer;
11981 *v12 = v13;
11982 --result->pDepthBuffer;
11983 a2->field_14 -= a2->field_18;
11984 result->field_30 += result->field_4;
11985 result->field_2C += result->field_0;
11986 }
11987 --result->field_28;
11988 return result;
11989 }
11990
11991 //----- (00485BAE) --------------------------------------------------------
11992 stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2)
11993 {
11994 stru315 *result; // eax@1
11995 int i; // ecx@1
11996 int v4; // ecx@2
11997 int v5; // ecx@4
11998 int v6; // ecx@6
11999 int v7; // ecx@8
12000 int v8; // esi@10
12001 int v9; // ecx@10
12002 int v10; // esi@11
12003 int v11; // edi@11
12004 int v12; // ebx@11
12005 int v13; // ecx@16
12006 unsigned __int16 *v14; // esi@18
12007 unsigned int *v15; // ecx@20
12008 int v16; // esi@20
12009 int v17; // [sp+0h] [bp-4h]@10
12010
12011 result = a1;
12012 for ( i = a1->field_28; i; i = result->field_28 )
12013 {
12014 result->field_28 = i - 1;
12015 v4 = result->field_18;
12016 if ( result->field_30 > v4 )
12017 result->field_30 = v4;
12018 v5 = result->field_20;
12019 if ( result->field_2C > v5 )
12020 result->field_2C = v5;
12021 v6 = result->field_14;
12022 if ( result->field_30 < v6 )
12023 result->field_30 = v6;
12024 v7 = result->field_1C;
12025 if ( result->field_2C < v7 )
12026 result->field_2C = v7;
12027 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
12028 v9 = *((char *)result->pTextureLOD + v8);
12029 v17 = *((char *)result->pTextureLOD + v8);
12030 if ( a2->field_20 )
12031 {
12032 v10 = HIWORD(a2->field_14);
12033 v11 = a2->field_C;
12034 v12 = v10;
12035 if ( v10 >= v11 )
12036 v12 = a2->field_C;
12037 if ( a2->field_8 - v12 <= 0 )
12038 {
12039 v13 = 0;
12040 }
12041 else
12042 {
12043 if ( v10 >= v11 )
12044 v10 = a2->field_C;
12045 v13 = a2->field_8 - v10;
12046 }
12047 v14 = a2->field_24_palette;
12048 v9 = v17 + (v13 << 8);
12049 }
12050 else
12051 {
12052 v14 = result->field_34_palette;
12053 }
12054 *result->pColorBuffer = v14[v9];
12055 v15 = result->pDepthBuffer;
12056 v16 = result->field_24;
12057 --result->pColorBuffer;
12058 *v15 = v16;
12059 --result->pDepthBuffer;
12060 a2->field_14 -= a2->field_18;
12061 result->field_30 += result->field_4;
12062 result->field_2C += result->field_0;
12063 }
12064 --result->field_28;
12065 return result;
12066 }
12067
12068 //----- (00485C89) --------------------------------------------------------
12069 stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2)
12070 {
12071 stru315 *result; // eax@1
12072 int i; // ecx@1
12073 int v4; // esi@2
12074 int v5; // esi@2
12075 int v6; // ecx@2
12076 int v7; // esi@4
12077 int v8; // edi@4
12078 int v9; // ecx@9
12079 unsigned __int16 *v10; // esi@11
12080 unsigned int *v11; // ecx@14
12081 int v12; // esi@14
12082 int v13; // [sp+0h] [bp-4h]@2
12083
12084 result = a1;
12085 for ( i = a1->field_28; i; i = result->field_28 )
12086 {
12087 v4 = result->field_8 & result->field_2C;
12088 result->field_28 = i - 1;
12089 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
12090 v6 = *((char *)result->pTextureLOD + v5);
12091 v13 = *((char *)result->pTextureLOD + v5);
12092 if ( *((char *)result->pTextureLOD + v5) )
12093 {
12094 if ( a2->field_20 )
12095 {
12096 v7 = HIWORD(a2->field_10);
12097 v8 = v7;
12098 if ( v7 >= a2->field_C )
12099 v8 = a2->field_C;
12100 if ( a2->field_8 - v8 <= 0 )
12101 {
12102 v9 = 0;
12103 }
12104 else
12105 {
12106 if ( v7 >= a2->field_C )
12107 v7 = a2->field_C;
12108 v9 = a2->field_8 - v7;
12109 }
12110 v10 = a2->field_24_palette;
12111 v6 = v13 + (v9 << 8);
12112 }
12113 else
12114 {
12115 v10 = result->field_34_palette;
12116 }
12117 *result->pColorBuffer = v10[v6];
12118 }
12119 v11 = result->pDepthBuffer;
12120 v12 = result->field_24;
12121 ++result->pColorBuffer;
12122 *v11 = v12;
12123 ++result->pDepthBuffer;
12124 a2->field_10 += a2->field_18;
12125 result->field_30 += result->field_4;
12126 result->field_2C += result->field_0;
12127 }
12128 --result->field_28;
12129 return result;
12130 }
12131
12132 //----- (00485D3E) --------------------------------------------------------
12133 stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2)
12134 {
12135 stru315 *result; // eax@1
12136 int i; // ecx@1
12137 int v4; // ecx@2
12138 int v5; // ecx@4
12139 int v6; // ecx@6
12140 int v7; // ecx@8
12141 int v8; // esi@10
12142 int v9; // ecx@10
12143 int v10; // esi@12
12144 int v11; // edi@12
12145 int v12; // ecx@17
12146 unsigned __int16 *v13; // esi@19
12147 unsigned int *v14; // ecx@22
12148 int v15; // esi@22
12149 int v16; // [sp+0h] [bp-4h]@10
12150
12151 result = a1;
12152 for ( i = a1->field_28; i; i = result->field_28 )
12153 {
12154 result->field_28 = i - 1;
12155 v4 = result->field_18;
12156 if ( result->field_30 > v4 )
12157 result->field_30 = v4;
12158 v5 = result->field_20;
12159 if ( result->field_2C > v5 )
12160 result->field_2C = v5;
12161 v6 = result->field_14;
12162 if ( result->field_30 < v6 )
12163 result->field_30 = v6;
12164 v7 = result->field_1C;
12165 if ( result->field_2C < v7 )
12166 result->field_2C = v7;
12167 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
12168 v9 = *((char *)result->pTextureLOD + v8);
12169 v16 = *((char *)result->pTextureLOD + v8);
12170 if ( *((char *)result->pTextureLOD + v8) )
12171 {
12172 if ( a2->field_20 )
12173 {
12174 v10 = HIWORD(a2->field_10);
12175 v11 = v10;
12176 if ( v10 >= a2->field_C )
12177 v11 = a2->field_C;
12178 if ( a2->field_8 - v11 <= 0 )
12179 {
12180 v12 = 0;
12181 }
12182 else
12183 {
12184 if ( v10 >= a2->field_C )
12185 v10 = a2->field_C;
12186 v12 = a2->field_8 - v10;
12187 }
12188 v13 = a2->field_24_palette;
12189 v9 = v16 + (v12 << 8);
12190 }
12191 else
12192 {
12193 v13 = result->field_34_palette;
12194 }
12195 *result->pColorBuffer = v13[v9];
12196 }
12197 v14 = result->pDepthBuffer;
12198 v15 = result->field_24;
12199 ++result->pColorBuffer;
12200 *v14 = v15;
12201 ++result->pDepthBuffer;
12202 a2->field_10 += a2->field_18;
12203 result->field_30 += result->field_4;
12204 result->field_2C += result->field_0;
12205 }
12206 --result->field_28;
12207 return result;
12208 }
12209
12210 //----- (00485E1F) --------------------------------------------------------
12211 void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, stru148 *a4, int a5, unsigned __int8 a6, char a7)
12212 {
12213 stru316 *v7; // esi@1
12214 signed int *v8; // edi@1
12215 signed int *v9; // ebx@1
12216 char v10; // zf@1
12217 int v11; // eax@1
12218 Span *v12; // ecx@3
12219 double v13; // ST24_8@3
12220 double v14; // ST24_8@3
12221 int v15; // eax@3
12222 signed int v16; // ST14_4@4
12223 char v17; // dl@4
12224 signed int v18; // ST10_4@4
12225 void *v19; // eax@4
12226 signed int v20; // ST14_4@5
12227 char v21; // dl@5
12228 int v22; // ST10_4@5
12229 signed int v23; // ST14_4@6
12230 char v24; // dl@6
12231 Span *v26; // [sp+10h] [bp-8h]@1
12232 char v27; // [sp+16h] [bp-2h]@1
12233 char v28; // [sp+17h] [bp-1h]@1
12234 float v29; // [sp+30h] [bp+18h]@3
12235 float v30; // [sp+30h] [bp+18h]@3
12236
12237 v7 = a1;
12238 v26 = a2;
12239 v8 = &a1->field_C;
12240 v9 = &a1->field_8;
12241 v10 = a1->field_0 == 0;
12242 v27 = a1->field_4 != 0;
12243 v28 = !v10;
12244 sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28);
12245 v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8);
12246 v11 = a4->field_108;
12247 v7->field_20 = v11;
12248 if ( v11 )
12249 {
12250 if ( a7 )
12251 {
12252 v12 = v26;
12253 v29 = v26->field_10 * 31.0;
12254 v13 = v29 + 6.7553994e15;
12255 v7->field_10 = LODWORD(v13) << 16;
12256 v30 = v12->field_14 * 31.0;
12257 v14 = v30 + 6.7553994e15;
12258 v15 = v7->field_10;
12259 v7->field_14 = LODWORD(v14) << 16;
12260 v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C);
12261 }
12262 v16 = *v8;
12263 v17 = v28;
12264 v18 = *v9;
12265 v7->field_1C = a6;
12266 v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16);
12267 }
12268 else
12269 {
12270 v20 = *v8;
12271 v21 = v28;
12272 v7->field_10 = 0;
12273 v7->field_14 = 0;
12274 v22 = *v9;
12275 v7->field_18 = 0;
12276 v7->field_1C = 0;
12277 v19 = sr_sub_47C1CA(a4, v21, v22, v20);
12278 }
12279 v23 = *v8;
12280 v24 = v28;
12281 v7->field_24_palette = (unsigned __int16 *)v19;
12282 return sr_sub_47C1CA(a4, v24, *v9, v23);
12283 }
12284
12285 //----- (00485F53) --------------------------------------------------------
12286 void __thiscall sub_485F53(Vec2_int_ *v)
12287 {
12288 ++v->y;
12289 if ( v->y > 1000 )
12290 v->y = 0;
12291 }
12292
12293
12294
12295 //----- (00485F64) --------------------------------------------------------
12296 void OutdoorCamera::_485F64()
12297 {
12298 int v1; // eax@1
12299 int v2; // eax@2
12300 signed __int64 v3; // qtt@4
12301 int v4; // eax@4
12302
12303 this->uCameraFovInDegrees = 75;
12304 v1 = stru_5C6E00->uPiMask & 0xD5;
12305 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
12306 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
12307 else
12308 v2 = stru_5C6E00->pTanTable[v1];
12309 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
12310 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
12311 v4 = (signed int)(v3 / v2) >> 16;
12312 this->int_fov_rad = v4;
12313 this->field_4C = 360000;
12314 this->int_fov_rad_inv = 65536 / v4;
12315 this->field_50 = 115;
12316 unnamed_6BE060[1] = 1;
12317 RotationToInts();
12318 }
12319
12320 //----- (0048600E) --------------------------------------------------------
12321 void OutdoorCamera::RotationToInts()
12322 {
12323 camera_rotation_y_int_sine = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
12324 camera_rotation_y_int_cosine = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
12325 camera_rotation_x_int_sine = stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi);
12326 camera_rotation_x_int_cosine = stru_5C6E00->SinCos(pIndoorCamera->sRotationX);
12327 }
12328
12329
12330 //----- (0048607B) --------------------------------------------------------
12331 void stru148::_48607B(stru149 *a2)
12332 {
12333 this->pTexture = 0;
12334 this->ptr_38 = a2;
12335 }
12336
12337 //----- (00486089) --------------------------------------------------------
12338 void stru148::_486089_normalize_v_18()
12339 {
12340 stru148 *v1; // esi@1
12341 double v2; // st7@1
12342 double v3; // st6@1
12343 float v4; // ST18_4@2
12344 double v5; // st5@1
12345 float v6; // ST14_4@2
12346 double v7; // st7@1
12347 float v8; // ST24_4@2
12348 float v9; // ST20_4@2
12349 double v10; // ST0C_8@2
12350 float v11; // ST18_4@2
12351 double v12; // ST0C_8@2
12352 float v13; // ST14_4@2
12353 double v14; // ST0C_8@2
12354 float v15; // [sp+20h] [bp-8h]@1
12355
12356 v1 = this;
12357 v2 = (double)this->v_18.x;
12358 v15 = v2;
12359 v3 = (double)this->v_18.y;
12360 v5 = (double)this->v_18.z;
12361 v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2);
12362 if ( v7 == 0.0 )
12363 {
12364 v1->v_18.x = 0;
12365 v1->v_18.y = 0;
12366 v1->v_18.z = 65536;
12367 }
12368 else
12369 {
12370 v8 = 1.0 / v7;
12371 v9 = v8 * v15 * 65536.0;
12372 v10 = v9 + 6.7553994e15;
12373 v1->v_18.x = LODWORD(v10);
12374 v4 = v3;
12375 v11 = v8 * v4 * 65536.0;
12376 v12 = v11 + 6.7553994e15;
12377 v1->v_18.y = LODWORD(v12);
12378 v6 = v5;
12379 v13 = v8 * v6 * 65536.0;
12380 v14 = v13 + 6.7553994e15;
12381 v1->v_18.z = LODWORD(v14);
12382 }
12383 }
12384
12385 //----- (0048616B) --------------------------------------------------------
12386 int stru149::_48616B(int a2, int a3, int a4, int a5, int a6, int a7)
12387 {
12388 int v7; // ebx@1
12389 int v8; // esi@1
12390 int v9; // edi@1
12391 int v10; // eax@1
12392 int v11; // edx@1
12393 int v12; // esi@2
12394 int v13; // eax@2
12395 int v14; // ST10_4@3
12396 int v15; // esi@3
12397 int v16; // eax@5
12398 int v17; // ST0C_4@6
12399 int v18; // eax@8
12400 int v19; // ST0C_4@9
12401 int v20; // eax@10
12402 int v21; // edx@10
12403 int v22; // eax@10
12404 int result; // eax@10
12405 int v24; // [sp+14h] [bp-14h]@1
12406 int v25; // [sp+18h] [bp-10h]@1
12407 int v26; // [sp+1Ch] [bp-Ch]@1
12408 int v27; // [sp+24h] [bp-4h]@1
12409 int v28; // [sp+30h] [bp+8h]@10
12410 int v29; // [sp+3Ch] [bp+14h]@10
12411
12412 v25 = pOutdoorCamera->camera_rotation_x_int_cosine;
12413 v7 = pOutdoorCamera->camera_rotation_y_int_sine;
12414 v27 = pOutdoorCamera->camera_rotation_x_int_sine;
12415 v8 = -pIndoorCamera->pos.y;
12416 v9 = pOutdoorCamera->camera_rotation_y_int_cosine;
12417 v26 = -pIndoorCamera->pos.z;
12418 v24 = -pIndoorCamera->pos.x;
12419 v10 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.x;
12420 v11 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
12421 if ( pIndoorCamera->sRotationX )
12422 {
12423 v14 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
12424 v15 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
12425 this->field_0 = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
12426 + ((unsigned __int64)(-65536
12427 * pIndoorCamera->pos.z
12428 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16);
12429 this->field_4 = v15;
12430 v12 = v25;
12431 v13 = ((unsigned __int64)((v26 << 16) * (signed __int64)v25) >> 16)
12432 - ((unsigned __int64)(v14 * (signed __int64)v27) >> 16);
12433 }
12434 else
12435 {
12436 this->field_4 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
12437 v12 = v25;
12438 this->field_0 = v11;
12439 v13 = v26 << 16;
12440 }
12441 this->field_8 = v13;
12442 if ( pIndoorCamera->sRotationX )
12443 {
12444 v17 = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
12445 this->field_C = ((unsigned __int64)(v17 * (signed __int64)v12) >> 16)
12446 + ((unsigned __int64)(a4 * (signed __int64)v27) >> 16);
12447 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
12448 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
12449 v16 = ((unsigned __int64)(a4 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v17 * (signed __int64)v27) >> 16);
12450 }
12451 else
12452 {
12453 this->field_C = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16)
12454 + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
12455 this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
12456 - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
12457 v16 = a4;
12458 }
12459 this->field_14 = v16;
12460 if ( pIndoorCamera->sRotationX )
12461 {
12462 v19 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
12463 this->field_18 = ((unsigned __int64)(v19 * (signed __int64)v12) >> 16)
12464 + ((unsigned __int64)(a7 * (signed __int64)v27) >> 16);
12465 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
12466 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
12467 v18 = ((unsigned __int64)(a7 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v27) >> 16);
12468 }
12469 else
12470 {
12471 this->field_18 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16)
12472 + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
12473 this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
12474 - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
12475 v18 = a7;
12476 }
12477 this->field_18 = -this->field_18;
12478 this->field_1C = -this->field_1C;
12479 this->field_20 = v18;
12480 v20 = this->field_C;
12481 this->field_20 = -this->field_20;
12482 v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0) >> 16)
12483 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
12484 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
12485 v28 = this->field_18;
12486 v22 = this->field_0;
12487 this->field_24 = v21;
12488 v29 = (unsigned __int64)(v28 * (signed __int64)v22) >> 16;
12489 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
12490 this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
12491 return result;
12492 }
12493
12494 //----- (0048653D) --------------------------------------------------------
12495 int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)
12496 {
12497 stru149 *v7; // esi@1
12498 int v8; // edi@1
12499 int v9; // eax@1
12500 int v10; // edx@1
12501 int v11; // ecx@1
12502 int v12; // eax@1
12503 int v13; // ebx@2
12504 int v14; // ecx@2
12505 int v15; // eax@2
12506 int v16; // ST14_4@3
12507 int v17; // ST10_4@3
12508 int v18; // eax@5
12509 int v19; // ST10_4@6
12510 int v20; // eax@8
12511 int v21; // ST10_4@9
12512 int v22; // eax@10
12513 int v23; // ecx@10
12514 int v24; // eax@10
12515 int result; // eax@10
12516 int v26; // [sp+14h] [bp-14h]@1
12517 int v27; // [sp+18h] [bp-10h]@1
12518 int v28; // [sp+1Ch] [bp-Ch]@1
12519 int v29; // [sp+24h] [bp-4h]@1
12520 int v30; // [sp+30h] [bp+8h]@10
12521 int v31; // [sp+3Ch] [bp+14h]@10
12522
12523 v7 = this;
12524 v8 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotY);
12525 v29 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotY - stru_5C6E00->uIntegerHalfPi);
12526 v28 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX);
12527 v9 = stru_5C6E00->SinCos(pBLVRenderParams->sPartyRotX - stru_5C6E00->uIntegerHalfPi);
12528 v11 = -pBLVRenderParams->vPartyPos.y;
12529 v26 = -pBLVRenderParams->vPartyPos.x;
12530 v27 = v9;
12531 v12 = -pBLVRenderParams->vPartyPos.z;
12532 if ( pBLVRenderParams->sPartyRotX )
12533 {
12534 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
12535 v13 = v28;
12536 v17 = -65536 * pBLVRenderParams->vPartyPos.z;
12537 v7->field_0 = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
12538 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16);
12539 v7->field_4 = v8 * v11 - v29 * v26;
12540 v14 = v27;
12541 v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16);
12542 }
12543 else
12544 {
12545 v7->field_0 = v10 + v29 * -pBLVRenderParams->vPartyPos.y;
12546 v13 = v28;
12547 v7->field_4 = v8 * v11 - v29 * v26;
12548 v14 = v27;
12549 v15 = v12 << 16;
12550 }
12551 v7->field_8 = v15;
12552 if ( pBLVRenderParams->sPartyRotX )
12553 {
12554 v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
12555 v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16)
12556 + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16);
12557 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
12558 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
12559 v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16);
12560 }
12561 else
12562 {
12563 v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16)
12564 + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
12565 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
12566 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
12567 v18 = a4;
12568 }
12569 v7->field_14 = v18;
12570 if ( pBLVRenderParams->sPartyRotX )
12571 {
12572 v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
12573 v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16)
12574 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16);
12575 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
12576 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
12577 v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16);
12578 }
12579 else
12580 {
12581 v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16)
12582 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
12583 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
12584 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
12585 v20 = a7;
12586 }
12587 v7->field_18 = -v7->field_18;
12588 v7->field_1C = -v7->field_1C;
12589 v7->field_20 = v20;
12590 v22 = v7->field_C;
12591 v7->field_20 = -v7->field_20;
12592 v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0) >> 16)
12593 + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4) >> 16)
12594 + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16);
12595 v30 = v7->field_18;
12596 v24 = v7->field_0;
12597 v7->field_24 = v23;
12598 v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16;
12599 result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4) >> 16;
12600 v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16);
12601 return result;
12602 }
12603
12604 //----- (0048694B) --------------------------------------------------------
12605 int stru149::_48694B()
12606 {
12607 int v1; // eax@1
12608 int v2; // ST04_4@1
12609 int v3; // ST00_4@1
12610 int v4; // eax@1
12611 int v5; // ST0C_4@1
12612 int result; // eax@1
12613
12614 v1 = this->field_C;
12615 this->field_18 = -this->field_18;
12616 this->field_1C = -this->field_1C;
12617 this->field_20 = -this->field_20;
12618 v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0) >> 16;
12619 v3 = this->field_18;
12620 v4 = this->field_0;
12621 this->field_24 = v2
12622 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
12623 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
12624 v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
12625 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
12626 this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
12627 return result;
12628 }
12629
12630
12631 //----- (00486A28) --------------------------------------------------------
12632 void OutdoorCamera::AllocSoftwareDrawBuffers()
12633 {
12634 if ( !this || !pSpans )
12635 {
12636 ReleaseSoftwareDrawBuffers();
12637 pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
12638 pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
12639 pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
12640 pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
12641 memset(pSpans, 0, 0x493E0u);
12642 memset(pEdges, 0, 0x4C2C0u);
12643 memset(pSurfs, 0, 0x11940u);
12644 memset(pNewEdges, 0, 0x6180u);
12645 }
12646 }
12647
12648 //----- (00486AFC) --------------------------------------------------------
12649 void OutdoorCamera::ReleaseSoftwareDrawBuffers()
12650 {
12651 pAllocator->FreeChunk(pSpans);
12652 pAllocator->FreeChunk(pEdges);
12653 pAllocator->FreeChunk(pSurfs);
12654 pAllocator->FreeChunk(pNewEdges);
12655 pSpans = 0;
12656 pEdges = 0;
12657 pSurfs = 0;
12658 pNewEdges = 0;
12659 }
12660
12661 //----- (00486B4E) --------------------------------------------------------
12662 char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)
12663 {
12664 stru148 *v4; // esi@1
12665 RenderVertexSoft *v5; // edi@1
12666 char v6; // zf@1
12667 unsigned int v7; // eax@3
12668 int v8; // ebx@3
12669 int *v9; // ecx@7
12670 int v10; // ebx@8
12671 int v11; // eax@10
12672 double v12; // st7@14
12673 int *v13; // edx@14
12674 double v14; // st6@14
12675 double v15; // st7@16
12676 int v16; // edi@16
12677 double v17; // st7@16
12678 double v18; // st7@16
12679 int v19; // edi@18
12680 double v20; // st7@18
12681 double v21; // st7@18
12682 Edge *i; // edx@20
12683 double v23; // st7@28
12684 Edge *v24; // eax@28
12685 std::string v26; // [sp-18h] [bp-98h]@2
12686 const char *v27; // [sp-8h] [bp-88h]@2
12687 int v28; // [sp-4h] [bp-84h]@2
12688 double v29; // [sp+Ch] [bp-74h]@28
12689 double v30; // [sp+14h] [bp-6Ch]@28
12690 double v31; // [sp+1Ch] [bp-64h]@20
12691 double v32; // [sp+24h] [bp-5Ch]@16
12692 double v33; // [sp+2Ch] [bp-54h]@14
12693 unsigned int v34; // [sp+34h] [bp-4Ch]@2
12694 unsigned __int64 v35; // [sp+38h] [bp-48h]@28
12695 int v36; // [sp+40h] [bp-40h]@28
12696 int v37; // [sp+44h] [bp-3Ch]@20
12697 float v38; // [sp+48h] [bp-38h]@18
12698 int v39; // [sp+4Ch] [bp-34h]@16
12699 int v40; // [sp+50h] [bp-30h]@14
12700 int v41; // [sp+54h] [bp-2Ch]@3
12701 RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1
12702 int v43; // [sp+5Ch] [bp-24h]@14
12703 int v44; // [sp+60h] [bp-20h]@6
12704 int v45; // [sp+64h] [bp-1Ch]@6
12705 unsigned int v46; // [sp+68h] [bp-18h]@7
12706 int *v47; // [sp+6Ch] [bp-14h]@1
12707 int v48; // [sp+70h] [bp-10h]@7
12708 float *v49; // [sp+74h] [bp-Ch]@7
12709 float v50; // [sp+78h] [bp-8h]@10
12710 float v51; // [sp+7Ch] [bp-4h]@14
12711
12712 v4 = a4;
12713 v5 = a1;
12714 v47 = a2;
12715 v6 = (HIBYTE(a4->flags) & 0x40) == 0;
12716 v42 = a1;
12717 if ( !v6 )
12718 {
12719 MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0);
12720 }
12721 LOBYTE(v7) = v4->field_108;
12722 v8 = v4->uNumVertices;
12723 v4->field_108 = 0;
12724 BYTE3(a4) = v7;
12725 v41 = v8;
12726 if ( v8 > 0 )
12727 {
12728 if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 )
12729 {
12730 v7 = pOutdoorCamera->uNumEdges;
12731 if ( (signed int)pOutdoorCamera->uNumEdges < 5979 )
12732 {
12733 v4->uEdgeList1Size = 0;
12734 v4->uEdgeList2Size = 0;
12735 v45 = -1;
12736 v34 = v7;
12737 v28 = v8;
12738 v27 = (const char *)v5;
12739 v44 = 10000;
12740 pGame->pLightmapBuilder->_45CB89(v5, v8);
12741 if ( v8 > 0 )
12742 {
12743 v9 = a3;
12744 v48 = 1;
12745 v49 = &v5->flt_2C;
12746 v46 = (char *)v47 - (char *)a3;
12747 do
12748 {
12749 v10 = v48;
12750 ++pOutdoorCamera->uNumEdges;
12751 if ( v48 >= v41 )
12752 v10 = 0;
12753 v11 = *v9;
12754 LODWORD(v50) = *v9;
12755 if ( SLODWORD(v50) > v45 )
12756 v45 = v11;
12757 if ( v11 < v44 )
12758 v44 = v11;
12759 v12 = (double)SLODWORD(v50);
12760 v13 = &a3[v10];
12761 v51 = v12;
12762 v14 = (double)*v13;
12763 v50 = v14;
12764 *(float *)&v40 = v14 - v12;
12765 v33 = *(float *)&v40 + 6.7553994e15;
12766 v43 = LODWORD(v33);
12767 if ( LODWORD(v33) )
12768 {
12769 if ( SLODWORD(v33) >= 0 )
12770 {
12771 v19 = (int)((char *)v9 + v46);
12772 ptr_80C978_Edges->field_8 = 1;
12773 LODWORD(v38) = (int)&v47[v10];
12774 v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19;
12775 v6 = BYTE3(a4) == 0;
12776 v20 = (double)v40;
12777 v40 = *v13 - *v9;
12778 v21 = v20 / (double)v40;
12779 ptr_80C978_Edges->field_4 = v21;
12780 ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19;
12781 if ( !v6 )
12782 {
12783 ptr_80C978_Edges->field_1C = *v49;
12784 ptr_80C978_Edges->field_20 = v42[v10].flt_2C;
12785 ptr_80C978_Edges->field_24 = (double)*(signed int *)v19;
12786 ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38);
12787 ptr_80C978_Edges->field_2C = (double)*v9;
12788 ptr_80C978_Edges->field_30 = (double)*v13;
12789 v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges;
12790 }
12791 }
12792 else
12793 {
12794 v32 = v51 + 6.7553994e15;
12795 v39 = LODWORD(v32);
12796 v51 = v50;
12797 v15 = (double)SLODWORD(v32);
12798 ptr_80C978_Edges->field_8 = 0;
12799 v16 = (int)&v47[v10];
12800 v50 = v15;
12801 v40 = *(int *)((char *)v9 + v46) - *(int *)v16;
12802 v6 = BYTE3(a4) == 0;
12803 v17 = (double)v40;
12804 v40 = *v9 - *v13;
12805 v18 = v17 / (double)v40;
12806 ptr_80C978_Edges->field_4 = v18;
12807 ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16;
12808 if ( !v6 )
12809 {
12810 ptr_80C978_Edges->field_1C = v42[v10].flt_2C;
12811 ptr_80C978_Edges->field_20 = *v49;
12812 ptr_80C978_Edges->field_24 = (double)*(signed int *)v16;
12813 ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46);
12814 ptr_80C978_Edges->field_2C = (double)*v13;
12815 ptr_80C978_Edges->field_30 = (double)*v9;
12816 v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges;
12817 }
12818 }
12819 v31 = v51 + 6.7553994e15;
12820 v37 = LODWORD(v31);
12821 for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext )
12822 ;
12823 if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 )
12824 {
12825 ptr_80C978_Edges->pNext = i->pNext;
12826 i->pNext = ptr_80C978_Edges;
12827 }
12828 else
12829 {
12830 ptr_80C978_Edges->pNext = i;
12831 i->pPrev->pNext = ptr_80C978_Edges;
12832 }
12833 v23 = v50 - 1.0;
12834 *(float *)&v40 = v23;
12835 v38 = v23;
12836 v30 = v38 + 6.7553994e15;
12837 v36 = LODWORD(v30);
12838 ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)];
12839 v29 = *(float *)&v40 + 6.7553994e15;
12840 v35 = __PAIR__(v40, LODWORD(v29));
12841 v24 = ptr_80C978_Edges;
12842 ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges;
12843 v24->pSurf = ptr_80C97C_Surfs;
12844 if ( ptr_80C978_Edges < &pEdges[5999] )
12845 ++ptr_80C978_Edges;
12846 }
12847 ++v48;
12848 v49 += 12;
12849 ++v9;
12850 }
12851 while ( v48 - 1 < v41 );
12852 }
12853 LOBYTE(v7) = v34;
12854 if ( pOutdoorCamera->uNumEdges != v34 )
12855 {
12856 v4->ptr_48 = 0;
12857 ptr_80C97C_Surfs->field_22 = 0;
12858 ptr_80C97C_Surfs->pParent = v4;
12859 ptr_80C97C_Surfs->field_4 = v4->field_4;
12860 ptr_80C97C_Surfs->field_8 = v4->field_8;
12861 ptr_80C97C_Surfs->field_0 = v4->field_0;
12862 ptr_80C97C_Surfs->field_C = v4->field_C;
12863 ptr_80C97C_Surfs->field_10 = v4->field_10;
12864 LOBYTE(v7) = (char)pSurfs + 28;
12865 if ( ptr_80C97C_Surfs < &pSurfs[1999] )
12866 {
12867 ++ptr_80C97C_Surfs;
12868 ++pOutdoorCamera->uNumSurfs;
12869 }
12870 if ( BYTE3(a4) )
12871 v4->field_108 = 1;
12872 }
12873 }
12874 }
12875 }
12876 return v7;
12877 }
12878
12879
12880
12881 //----- (0043F953) --------------------------------------------------------
12882 void PrepareBspRenderList_BLV()
12883 {
12884 pBspRenderer->uNumFaceIDs = 0;
12885
12886 if (pBLVRenderParams->uPartySectorID)
12887 {
12888 pBspRenderer->field_FA8[0].uSectorID = pBLVRenderParams->uPartySectorID;
12889 pBspRenderer->field_FA8[0].uViewportW = pBLVRenderParams->uViewportW;
12890 pBspRenderer->field_FA8[0].uViewportZ = pBLVRenderParams->uViewportZ;
12891 pBspRenderer->field_FA8[0].uViewportY = pBLVRenderParams->uViewportY;
12892 pBspRenderer->field_FA8[0].uViewportX = pBLVRenderParams->uViewportX;
12893 pBspRenderer->field_FA8[0].field_C._43F9E1(
12894 pBLVRenderParams->uViewportX,
12895 pBLVRenderParams->uViewportY,
12896 pBLVRenderParams->uViewportZ,
12897 pBLVRenderParams->uViewportW);
12898 pBspRenderer->field_FA8[0].uFaceID = -1;
12899 pBspRenderer->field_FA8[0].std__vector_0007A8 = -1;
12900 pBspRenderer->std__vector_000FA8 = 1;
12901 sub_440639(0);
12902 }
12903
12904 pBspRenderer->MakeVisibleSectorList();
12905 }
12906
12907 //----- (0043F9E1) --------------------------------------------------------
12908 void BspRenderer_stru2::_43F9E1(__int16 x, int y, __int16 z, int w)
12909 {
12910 _viewport_space_y = y;
12911 _viewport_space_w = w;
12912
12913 for (uint i = 0; i < 480; ++i)
12914 {
12915 if ( i < y || i > w )
12916 {
12917 array_3D8[i] = -1;
12918 array_18[i] = 640;
12919 }
12920 else
12921 {
12922 array_18[i] = x;
12923 array_3D8[i] = z;
12924 }
12925 }
12926 }
12927
12928 //----- (0043FA33) --------------------------------------------------------
12929 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID)
12930 {
12931 LevelDecoration *v2; // esi@1
12932 DecorationDesc *v3; // ebx@2
12933 __int16 v4; // ax@2
12934 double v5; // st7@3
12935 int v6; // eax@5
12936 int v7; // edx@5
12937 unsigned int v8; // edi@5
12938 int v9; // edi@5
12939 int v10; // eax@7
12940 SpriteFrame *v11; // eax@7
12941 SpriteFrame *v12; // esi@7
12942 int v13; // eax@7
12943 int v14; // ebx@16
12944 RenderBillboard *v15; // ecx@17
12945 char v16; // zf@18
12946 IndoorCameraD3D **v17; // eax@19
12947 double v18; // st7@19
12948 float v19; // eax@19
12949 signed __int64 v20; // qtt@19
12950 signed __int64 v21; // qtt@20
12951 int v22; // edx@21
12952 int v23; // eax@21
12953 Particle_ local_0; // [sp+Ch] [bp-A0h]@3
12954 double v25; // [sp+74h] [bp-38h]@19
12955 unsigned int v26; // [sp+7Ch] [bp-30h]@1
12956 int a2; // [sp+80h] [bp-2Ch]@5
12957 int a3; // [sp+84h] [bp-28h]@5
12958 int a1; // [sp+88h] [bp-24h]@5
12959 int v30; // [sp+8Ch] [bp-20h]@7
12960 float v31; // [sp+90h] [bp-1Ch]@1
12961 int a5; // [sp+94h] [bp-18h]@17
12962 int z; // [sp+98h] [bp-14h]@15
12963 int a6; // [sp+9Ch] [bp-10h]@17
12964 int y; // [sp+A0h] [bp-Ch]@15
12965 int x; // [sp+A4h] [bp-8h]@15
12966 int v37; // [sp+A8h] [bp-4h]@5
12967
12968 v26 = uDecorationID;
12969 LODWORD(v31) = uSectorID;
12970 v2 = &pLevelDecorations[uDecorationID];
12971 if ( !(v2->field_2 & 0x20) )
12972 {
12973 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID];
12974 v4 = v3->uFlags;
12975 if ( (char)v4 >= 0 )
12976 {
12977 if ( !(v4 & DECORATION_DONT_DRAW) )
12978 {
12979 v6 = v2->vPosition.x;
12980 v7 = v2->vPosition.z;
12981 a2 = v2->vPosition.y;
12982 a1 = v6;
12983 a3 = v7;
12984 v8 = v2->field_10_y_rot
12985 + ((signed int)stru_5C6E00->uIntegerPi >> 3)
12986 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
12987 v37 = pBLVRenderParams->field_0_timer_;
12988 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7;
12989 if ( pParty->bTurnBasedModeOn == 1 )
12990 v37 = pMiscTimer->uTotalGameTimeElapsed;
12991 v10 = abs(v2->vPosition.x + v2->vPosition.y);
12992 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10);
12993 v30 = 0;
12994 v12 = v11;
12995 v13 = v11->uFlags;
12996 if ( v13 & 2 )
12997 v30 = 2;
12998 if ( v13 & 0x40000 )
12999 v30 |= 0x40u;
13000 if ( v13 & 0x20000 )
13001 LOBYTE(v30) = v30 | 0x80;
13002 if ( (256 << v9) & v13 )
13003 v30 |= 4u;
13004 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) )
13005 {
13006 v14 = abs(x);
13007 if ( v14 >= abs(y) )
13008 {
13009 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6);
13010 v15 = &pBillboardRenderList[uNumBillboardsToDraw];
13011 if ( (signed int)uNumBillboardsToDraw < 500 )
13012 {
13013 ++uNumBillboardsToDraw;
13014 ++uNumDecorationsDrawnThisFrame;
13015 v16 = pRenderer->pRenderD3D == 0;
13016 v15->uHwSpriteID = v12->pHwSpriteIDs[v9];
13017 v15->uPalette = v12->uPaletteIndex;
13018 v15->uIndoorSectorID = LOWORD(v31);
13019 if ( v16 )
13020 {
13021 LODWORD(v21) = pBLVRenderParams->field_40 << 16;
13022 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16;
13023 v37 = v21 / x;
13024 LODWORD(v31) = v12->scale;
13025 v37 = v21 / x;
13026 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16;
13027 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16;
13028 }
13029 else
13030 {
13031 v17 = &pGame->pIndoorCameraD3D;
13032 v15->fov_x = pGame->pIndoorCameraD3D->fov_x;
13033 v18 = (*v17)->fov_y;
13034 v19 = v15->fov_x;
13035 v15->fov_y = v18;
13036 v31 = v19;
13037 v25 = v19 + 6.7553994e15;
13038 LODWORD(v20) = 0;
13039 HIDWORD(v20) = SLOWORD(v25);
13040 v37 = v20 / x;
13041 LODWORD(v31) = v12->scale;
13042 v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
13043 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
13044 v31 = v15->fov_y;
13045 v25 = v31 + 6.7553994e15;
13046 LODWORD(v20) = 0;
13047 HIDWORD(v20) = SLOWORD(v25);
13048 v37 = v20 / x;
13049 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16;
13050 }
13051 HIWORD(v22) = HIWORD(x);
13052 v15->field_4 = v37;
13053 v15->field_1E = v30;
13054 v15->some_x = a1;
13055 v15->some_y = a2;
13056 v15->some_z = a3;
13057 v15->uScreenSpaceX = a5;
13058 v15->uScreenSpaceY = a6;
13059 v23 = 8 * v26;
13060 LOBYTE(v23) = 8 * v26 | 5;
13061 LOWORD(v22) = 0;
13062 v15->uTintColor = 0;
13063 v15->sZValue = v22 + v23;
13064 v15->pSpriteFrame = v12;
13065 }
13066 }
13067 }
13068 }
13069 }
13070 else
13071 {
13072 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern
13073 v5 = (double)v2->vPosition.x;
13074 local_0.bFree = 1036;
13075 local_0.uDiffuse = 0xFF3C1Eu;
13076 local_0.x = v5;
13077 local_0.y = (double)v2->vPosition.y;
13078 local_0.z = (double)v2->vPosition.z;
13079 local_0.flt_10 = 0.0;
13080 local_0.flt_14 = 0.0;
13081 local_0.flt_18 = 0.0;
13082 local_0.flt_28 = 1.0;
13083 local_0.timeToLive = (rand() & 0x80) + 128;
13084 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
13085 pGame->pParticleEngine->AddParticle(&local_0);
13086 }
13087 }
13088 }
13089
13090
13091 //----- (0044028F) --------------------------------------------------------
13092 void PrepareItemsRenderList_BLV()
13093 {
13094 ObjectDesc *v1; // ebx@4
13095 __int16 v2; // ax@5
13096 RenderBillboard *v3; // esi@12
13097 SpriteFrame *v4; // eax@12
13098 SpriteFrame *v5; // ebx@12
13099 unsigned int v6; // eax@12
13100 int v7; // ecx@12
13101 int v8; // edx@12
13102 int v9; // ecx@12
13103 unsigned __int16 v10; // ax@12
13104 int *v11; // eax@20
13105 char v12; // zf@26
13106 int v18; // ST5C_4@27
13107 signed __int64 v19; // qtt@28
13108 int v20; // ST5C_4@28
13109 int v21; // edx@29
13110 __int16 v22; // ax@29
13111 int v23; // eax@29
13112 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12
13113 __int16 a5; // [sp+28h] [bp-34h]@12
13114 int a6; // [sp+2Ch] [bp-30h]@12
13115 int a2; // [sp+30h] [bp-2Ch]@12
13116 int a1; // [sp+34h] [bp-28h]@12
13117 int v30; // [sp+38h] [bp-24h]@12
13118 int v31; // [sp+38h] [bp-24h]@27
13119 int a3; // [sp+40h] [bp-1Ch]@12
13120 signed __int16 v34; // [sp+44h] [bp-18h]@14
13121 int v35; // [sp+48h] [bp-14h]@25
13122 int v36; // [sp+4Ch] [bp-10h]@25
13123 signed int z; // [sp+50h] [bp-Ch]@24
13124 signed int y; // [sp+54h] [bp-8h]@24
13125 signed int x; // [sp+58h] [bp-4h]@24
13126
13127 for (uint i = 0; i < uNumLayingItems; ++i)
13128 {
13129 auto p = pLayingItems + i;
13130 if (p->uObjectDescID)
13131 {
13132 v1 = &pObjectList->pObjects[p->uObjectDescID];
13133 if ( !(v1->uFlags & 1) )
13134 {
13135 if ( ((v2 = p->uItemType, v2 < 1000) || v2 >= 10000)
13136 && (v2 < 500 || v2 >= 600)
13137 && (v2 < 811 || v2 >= 815)
13138 || pGame->pStru6Instance->_4A81CA(p))
13139 {
13140 a5 = p->uSectorID;
13141 a1 = p->vPosition.x;
13142 a2 = p->vPosition.y;
13143 a3 = p->vPosition.z;
13144 v3 = &pBillboardRenderList[uNumBillboardsToDraw];
13145 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID);
13146 v5 = v4;
13147 v24 = v4;
13148 v30 = v4->uFlags;
13149 a6 = v4->uGlowRadius * p->field_22;
13150 v6 = stru_5C6E00->Atan2(
13151 p->vPosition.x - pBLVRenderParams->vPartyPos.x,
13152 p->vPosition.y - pBLVRenderParams->vPartyPos.y);
13153 LOWORD(v7) = p->uFacing;
13154 v8 = v30;
13155 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
13156 v10 = v5->pHwSpriteIDs[v9];
13157 v3->uHwSpriteID = v10;
13158 if ( v30 & 0x20 )
13159 {
13160 v8 = v30;
13161 a3 -= (signed int)((unsigned __int64)(v5->scale
13162 * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1;
13163 }
13164 v34 = 0;
13165 if ( v8 & 2 )
13166 v34 = 2;
13167 if ( v8 & 0x40000 )
13168 v34 |= 0x40u;
13169 if ( v8 & 0x20000 )
13170 LOBYTE(v34) = v34 | 0x80;
13171 v11 = (int *)(256 << v9);
13172 if ( (256 << v9) & v8 )
13173 v34 |= 4u;
13174 if ( a6 )
13175 {
13176 LOBYTE(v11) = byte_4E94D3;
13177 pMobileLightsStack->AddLight(
13178 a1,
13179 a2,
13180 a3,
13181 a5,
13182 a6,
13183 v1->uParticleTrailColorR,
13184 v1->uParticleTrailColorG,
13185 v1->uParticleTrailColorB,
13186 byte_4E94D3);
13187 }
13188 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
13189 a1,
13190 a2,
13191 a3,
13192 &x,
13193 &y,
13194 &z,
13195 1) )
13196 {
13197 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35);
13198 if ( (signed int)uNumBillboardsToDraw >= 500 )
13199 return;
13200 ++uNumBillboardsToDraw;
13201 ++uNumSpritesDrawnThisFrame;
13202 p->uAttributes |= 1u;
13203 v12 = pRenderer->pRenderD3D == 0;
13204 v3->uPalette = v24->uPaletteIndex;
13205 v3->uIndoorSectorID = a5;
13206 if ( v12 )
13207 {
13208 LODWORD(v19) = pBLVRenderParams->field_40 << 16;
13209 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16;
13210 v20 = v19 / x;
13211 v3->field_0 = (unsigned __int64)(v24->scale * v19 / x) >> 16;
13212 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;
13213 }
13214 else
13215 {
13216 v3->fov_x = pGame->pIndoorCameraD3D->fov_x;
13217 v3->fov_y = pGame->pIndoorCameraD3D->fov_y;
13218 v18 = (int)floorf(v3->fov_x + 0.5f) / x;
13219 v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
13220 v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
13221 }
13222 HIWORD(v21) = HIWORD(x);
13223 v3->field_4 = v31;
13224 v3->field_1E = v34;
13225 v3->some_x = a1;
13226 v3->some_y = a2;
13227 v3->some_z = a3;
13228 v3->uScreenSpaceX = v36;
13229 v22 = v35;
13230 v3->uTintColor = 0;
13231 v3->uScreenSpaceY = v22;
13232 LOWORD(v21) = 0;
13233 v23 = 8 * i;
13234 LOBYTE(v23) = 8 * i | 2;
13235 v3->pSpriteFrame = v24;
13236 v12 = (p->uAttributes & 0x20) == 0;
13237 v3->sZValue = v21 + v23;
13238 if ( !v12 )
13239 {
13240 if ( !pRenderer->pRenderD3D )
13241 v3->sZValue = 0;
13242 }
13243 }
13244 }
13245 }
13246 }
13247 }
13248 }
13249
13250
13251
13252 //----- (00440639) --------------------------------------------------------
13253 void __fastcall sub_440639(int a1)
13254 {
13255 int v1; // ebx@1
13256 signed int v2; // edi@1
13257 BLVSector *v3; // esi@1
13258
13259 v1 = a1;
13260 v2 = 0;
13261 v3 = &pIndoor->pSectors[pBspRenderer->field_FA8[a1].uSectorID];
13262 if ( pRenderer->pRenderD3D )
13263 {
13264 if ( v3->uNumNonBSPFaces > 0 )
13265 {
13266 do
13267 {
13268 Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
13269 pBspRenderer->PrepareFaceRenderList_d3d(v1, v3->pFaceIDs[v2++]);
13270 }
13271 while ( v2 < v3->uNumNonBSPFaces );
13272 }
13273 }
13274 else
13275 {
13276 if ( v3->uNumNonBSPFaces > 0 )
13277 {
13278 do
13279 pBspRenderer->PrepareFaceRenderList_sw(v1, v3->pFaceIDs[v2++]);
13280 while ( v2 < v3->uNumNonBSPFaces );
13281 }
13282 }
13283 if ( v3->field_0 & 0x10 )
13284 sub_4406BC(v1, v3->uFirstBSPNode);
13285 }
13286
13287 //----- (004406BC) --------------------------------------------------------
13288 void __fastcall sub_4406BC(int a1, unsigned int uFirstNode)
13289 {
13290 BLVSector *v2; // esi@2
13291 BSPNode *v3; // edi@2
13292 BLVFace *v4; // eax@2
13293 int v5; // ecx@2
13294 __int16 v6; // ax@6
13295 int v7; // ebp@10
13296 int v8; // ebx@10
13297 __int16 v9; // di@18
13298 int v10; // [sp+10h] [bp-Ch]@1
13299 bool v11; // [sp+14h] [bp-8h]@5
13300 BspRenderer_stru0 *v12; // [sp+18h] [bp-4h]@1
13301
13302 Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
13303
13304 v10 = a1;
13305 v12 = &pBspRenderer->field_FA8[a1];
13306 while ( 1 )
13307 {
13308 v2 = &pIndoor->pSectors[v12->uSectorID];
13309 v3 = &pIndoor->pNodes[uFirstNode];
13310 v4 = &pIndoor->pFaces[v2->pFaceIDs[v3->uCoplanarOffset]];
13311 v5 = v4->pFacePlane_old.dist
13312 + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x
13313 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y
13314 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z;
13315 if ( v4->uAttributes & 1 && v4->uSectorID != v12->uSectorID )
13316 v5 = -v5;
13317 v11 = v5 > 0;
13318 if ( v5 <= 0 )
13319 v6 = v3->uFront;
13320 else
13321 v6 = v3->uBack;
13322 if ( v6 != -1 )
13323 sub_4406BC(v10, v6);
13324 v7 = v3->uCoplanarOffset;
13325 v8 = v7 + v3->uCoplanarSize;
13326
13327 Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]);
13328
13329 if ( pRenderer->pRenderD3D )
13330 {
13331 while ( v7 < v8 )
13332 pBspRenderer->PrepareFaceRenderList_d3d(v10, v2->pFaceIDs[v7++]);
13333 }
13334 else
13335 {
13336 while ( v7 < v8 )
13337 pBspRenderer->PrepareFaceRenderList_sw(v10, v2->pFaceIDs[v7++]);
13338 }
13339 v9 = v11 ? v3->uFront : v3->uBack;
13340 if ( v9 == -1 )
13341 break;
13342 uFirstNode = v9;
13343 }
13344 }
13345
13346 //----- (00440DF5) --------------------------------------------------------
13347 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)
13348 {
13349 int result; // eax@1
13350
13351 pElements[uNumElements].field_6_rnd_value = a2;
13352 pElements[uNumElements].field_8_rnd_value = a3;
13353 pElements[uNumElements].field_A_rnd_value = a4;
13354 pElements[uNumElements].field_C_time_left = rand() % 64 + 256;
13355 pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left;
13356 result = 3 * uNumElements;
13357 pElements[uNumElements++].bgr16 = bgr;
13358 if (uNumElements >= 100 )
13359 uNumElements = 0;
13360 return result;
13361 }
13362
13363 //----- (00440E91) --------------------------------------------------------
13364 void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr)
13365 {
13366 stru167_wrap *v6; // edi@1
13367 int i; // esi@1
13368 int v8; // ST08_4@2
13369 int v9; // ST04_4@2
13370 int v10; // eax@2
13371
13372 v6 = this;
13373 for ( i = 0; i < rand() % 6 + 5; ++i )
13374 {
13375 v8 = z + rand() % 33;
13376 v9 = rand() % 33 + y - 16;
13377 v10 = rand();
13378 Push(v10 % 33 + x - 16, v9, v8, a5, bgr);
13379 }
13380 }
13381
13382 //----- (00440F07) --------------------------------------------------------
13383 void stru167_wrap::_440F07()
13384 {
13385 for (uint i = 0; i < 100; ++i)
13386 {
13387 if (pElements[i].field_C_time_left > 0)
13388 {
13389 pElements[i].field_A_rnd_value += rand() % 5 + 4;
13390 pElements[i].field_6_rnd_value += rand() % 5 - 2;
13391 pElements[i].field_8_rnd_value += rand() % 5 - 2;
13392 pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed;
13393 }
13394 }
13395 }
13396
13397 //----- (0044100D) --------------------------------------------------------
13398 bool __cdecl sub_44100D()
13399 {
13400 return pCurrentScreen == 4
13401 || pCurrentScreen == 7
13402 || pCurrentScreen > 12
13403 && (pCurrentScreen <= 14
13404 || pCurrentScreen > 16
13405 && (pCurrentScreen <= 18
13406 || pCurrentScreen == 23));
13407 }
13408 // 4E28F8: using guessed type int pCurrentScreen;
13409
13410 //----- (00441498) --------------------------------------------------------
13411 void __cdecl GameUI_DrawTorchlightAndWizardEye()
13412 {
13413 unsigned int v0; // eax@15
13414 IconFrame *v1; // eax@15
13415 unsigned int v2; // eax@19
13416 IconFrame *v3; // eax@19
13417
13418 if ( !pCurrentScreen
13419 || pCurrentScreen == 1
13420 || pCurrentScreen == 2
13421 || pCurrentScreen == 5
13422 || pCurrentScreen == 8
13423 || pCurrentScreen == 10
13424 || pCurrentScreen == 11
13425 || pCurrentScreen == 12
13426 || pCurrentScreen == 15
13427 || pCurrentScreen == 3
13428 || pCurrentScreen == 19 )
13429 {
13430 if ( SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) >= 0
13431 && (SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[16].uExpireTime)) )
13432 {
13433 v0 = pEventTimer->Time();
13434 v1 = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, v0);
13435 pRenderer->DrawTextureTransparent(
13436 pUIAnum_Torchlight->x,
13437 pUIAnum_Torchlight->y,
13438 &pIcons_LOD->pTextures[v1->uTextureID]);
13439 }
13440 if ( SHIDWORD(pParty->pPartyBuffs[19].uExpireTime) >= 0
13441 && (SHIDWORD(pParty->pPartyBuffs[19].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[19].uExpireTime)) )
13442 {
13443 v2 = pEventTimer->Time();
13444 v3 = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, v2);
13445 pRenderer->DrawTextureTransparent(
13446 pUIAnim_WizardEye->x,
13447 pUIAnim_WizardEye->y,
13448 &pIcons_LOD->pTextures[v3->uTextureID]);
13449 }
13450 }
13451 }
13452 // 4E28F8: using guessed type int pCurrentScreen;
13453
13454 //----- (0044158F) --------------------------------------------------------
13455 void __cdecl GameUI_DrawCharacterSelectionFrame()
13456 {
13457 if ( uActiveCharacter )
13458 pRenderer->DrawTextureTransparent(
13459 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9,
13460 0x17Cu,
13461 &pIcons_LOD->pTextures[dword_50C98C]);
13462 }
13463
13464
13465 //----- (004415C5) --------------------------------------------------------
13466 void __cdecl Load_isn_spells_21_27()
13467 {
13468 signed int v0; // esi@1
13469 char pContainer[120]; // [sp+8h] [bp-20h]@2
13470
13471 v0 = 0;
13472 do
13473 {
13474 sprintf(pContainer, "isn-%02d", v0 + 1);
13475 pTextureIDs_isns[v0++] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
13476 }
13477 while ( v0 < 14 );
13478 uIconIdx_Spell21 = pIconsFrameTable->FindIcon("spell21");
13479 uIconIdx_Spell27 = pIconsFrameTable->FindIcon("spell27");
13480 }
13481
13482 //----- (0044162D) --------------------------------------------------------
13483 void __cdecl GameUI_DrawPartySpells()
13484 {
13485 unsigned int v0; // ebp@1
13486 signed int v1; // edi@1
13487 int v2; // eax@2
13488 int v3; // ecx@5
13489 __int16 *v4; // ebx@25
13490 Player *v5; // edi@26
13491 unsigned int v6; // [sp-4h] [bp-1Ch]@11
13492 Texture *v7; // [sp-4h] [bp-1Ch]@12
13493 unsigned int v8; // [sp-4h] [bp-1Ch]@20
13494 Texture *v9; // [sp-4h] [bp-1Ch]@21
13495 Player **v10; // [sp+10h] [bp-8h]@25
13496
13497 v0 = (signed __int64)((double)GetTickCount() * 0.050000001);
13498 v1 = 0;
13499 do
13500 {
13501 v2 = (unsigned __int8)byte_4E5DD8[v1];
13502 if ( SHIDWORD(pParty->pPartyBuffs[v2].uExpireTime) >= 0
13503 && (SHIDWORD(pParty->pPartyBuffs[v2].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[v2].uExpireTime) > 0) )
13504 {
13505 v3 = pTextureIDs_isns[v1];
13506 pRenderer->_4A65CC(
13507 pPartySpellbuffsUI_XYs[v1][0],
13508 pPartySpellbuffsUI_XYs[v1][1],
13509 (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
13510 (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
13511 v0 + 20 * pPartySpellbuffsUI_smthns[v1],
13512 0,
13513 63);
13514 }
13515 ++v1;
13516 }
13517 while ( v1 < 14 );
13518 if ( !pCurrentScreen
13519 || pCurrentScreen == 4 )
13520 {
13521 if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
13522 {
13523 if ( pParty->bFlying )
13524 v6 = v0;
13525 else
13526 v6 = 0;
13527 v7 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_Spell21, v6)->uTextureID];
13528 if ( pRenderer->pRenderD3D )
13529 pRenderer->DrawTextureIndexed(8u, 8u, v7);
13530 else
13531 pRenderer->DrawTextureTransparent(8u, 8u, v7);
13532 }
13533 if ( SHIDWORD(pParty->pPartyBuffs[18].uExpireTime) >= 0
13534 && (SHIDWORD(pParty->pPartyBuffs[18].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[18].uExpireTime)) )
13535 {
13536 if ( pParty->uFlags & 0x80 )
13537 v8 = v0;
13538 else
13539 v8 = 0;
13540 v9 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_Spell27, v8)->uTextureID];
13541 if ( pRenderer->pRenderD3D )
13542 pRenderer->DrawTextureIndexed(396u, 8u, v9);
13543 else
13544 pRenderer->DrawTextureTransparent(396u, 8u, v9);
13545 }
13546 }
13547
13548 uint _it = 0;
13549 v10 = &pPlayers[1];
13550 v4 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
13551 do
13552 {
13553 v5 = *v10;
13554 if ( (signed __int64)(*v10)->pPlayerBuffs[6].uExpireTime > 0 )
13555 pRenderer->DrawTextureIndexed(
13556 *v4 + 72,
13557 0x1ABu,
13558 (Texture *)(dword_507964 != -1 ? &pIcons_LOD->pTextures[dword_507964] : 0));
13559 if ( (signed __int64)v5->pPlayerBuffs[1].uExpireTime > 0 )
13560 pRenderer->DrawTextureIndexed(
13561 *v4 + 72,
13562 0x189u,
13563 (Texture *)(dword_50796C != -1 ? &pIcons_LOD->pTextures[dword_50796C] : 0));
13564 if ( (signed __int64)v5->pPlayerBuffs[11].uExpireTime > 0 )
13565 pRenderer->DrawTextureIndexed(
13566 *v4 + 72,
13567 0x19Au,
13568 (Texture *)(dword_507968 != -1 ? &pIcons_LOD->pTextures[dword_507968] : 0));
13569 if ( (signed __int64)v5->pPlayerBuffs[10].uExpireTime > 0 )
13570 pRenderer->DrawTextureIndexed(
13571 *v4 + 72,
13572 0x1BCu,
13573 (Texture *)(dword_507960 != -1 ? &pIcons_LOD->pTextures[dword_507960] : 0));
13574 ++v10;
13575 ++v4;
13576 }
13577 //while ( (signed int)v4 < (signed int)pBaseHealthByClass );
13578 while (++_it != 4);
13579 }
13580
13581
13582 //----- (00441A4E) --------------------------------------------------------
13583 __int16 __fastcall sub_441A4E(int a1)
13584 {
13585 __int16 result; // ax@1
13586 int v2; // ebx@1
13587 char *v3; // esi@1
13588 int v4; // edi@4
13589 int v5; // ecx@4
13590 SpriteFrame *v6; // eax@6
13591 SpriteFrame *v7; // edi@6
13592 int v8; // eax@6
13593 unsigned __int16 v9; // ax@6
13594 RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1
13595 int v11; // [sp+5Ch] [bp-Ch]@6
13596 int v12; // [sp+60h] [bp-8h]@1
13597 int v13; // [sp+64h] [bp-4h]@6
13598
13599 v10.uParentBillboardID = -1;
13600 v10.pTarget = pRenderer->pTargetSurface;
13601 v10.pTargetZ = pRenderer->pActiveZBuffer;
13602 v10.uTargetPitch = pRenderer->field_10;
13603 result = 0;
13604 v2 = a1;
13605 v10.uViewportX = 0;
13606 v10.uViewportY = 0;
13607 v10.uViewportZ = 639;
13608 v10.uViewportW = 479;
13609 v12 = 0;
13610 v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C;
13611 do
13612 {
13613 if ( *((short *)v3 - 3) > 0 )
13614 {
13615 result = *((short *)v3 - 6);
13616 if ( result >= 300 )
13617 {
13618 v4 = result;
13619 v5 = result == v2 + 320 | result == v2 + 330 | result == v2 + 340 | result == v2 + 350;
13620 result = v2 + 310;
13621 if ( v4 == v2 + 310 | v5 )
13622 {
13623 if ( !*(short *)v3 )
13624 {
13625 v6 = pSpriteFrameTable->GetFrame(
13626 pOverlayList->pOverlays[*((short *)v3 - 5)].uSpriteFramesetID,
13627 *((short *)v3 - 4));
13628 v7 = v6;
13629 v11 = *((int *)v3 + 1);
13630 v13 = v6->scale;
13631 v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16;
13632 v10.uScreenSpaceX = *((short *)v3 - 2);
13633 v10.uScreenSpaceY = *((short *)v3 - 1);
13634 v10.field_10 = v13;
13635 v10.field_14 = v13;
13636 v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1);
13637 v8 = *((short *)v3 - 5);
13638 v10.sZValue = 0;
13639 v10.uFlags = 0;
13640 v9 = pOverlayList->pOverlays[v8].uOverlayType;
13641 if ( !v9 || v9 == 2 )
13642 v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
13643 result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0);
13644 ++v12;
13645 if ( v12 == 5 )
13646 break;
13647 }
13648 }
13649 }
13650 }
13651 v3 += 20;
13652 }
13653 while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays );
13654 return result;
13655 }
13656
13657
13658
13659 //----- (00441D38) --------------------------------------------------------
13660 void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags)
13661 {
13662 int uHeight; // ebx@6
13663 //unsigned int v9; // edx@9
13664 //unsigned int v10; // ebx@10
13665 __int16 v11; // cx@11
13666 //BLVFace *v12; // ecx@17
13667 //unsigned int v13; // ecx@21
13668 unsigned int v14; // ebx@23
13669 int v15; // eax@23
13670 //unsigned int *v16; // ecx@28
13671 __int16 v17; // di@30
13672 double v18; // st7@30
13673 float v19; // ST38_4@30
13674 double v20; // st7@30
13675 double v21; // st6@30
13676 double v22; // st5@33
13677 unsigned __int16 *v26; // edx@37
13678 signed int v27; // eax@37
13679 unsigned __int16 *v28; // ecx@37
13680 signed int v29; // edi@40
13681 int v30; // eax@42
13682 unsigned __int16 *v31; // ebx@43
13683 signed int v32; // edi@46
13684 signed int v33; // ebx@50
13685 unsigned int v34; // eax@50
13686 signed int v35; // ecx@50
13687 unsigned __int16 v36; // di@66
13688 int v37; // edi@72
13689 int v38; // ebx@72
13690 __int16 v39; // ax@87
13691 int v40; // edi@91
13692 int v41; // ebx@91
13693 unsigned int v42; // eax@101
13694 unsigned int v43; // ebx@101
13695 unsigned int v44; // ST30_4@101
13696 char *v45; // ebx@106
13697 int v46; // edi@108
13698 int v47; // eax@108
13699 unsigned int v48; // ebx@114
13700 unsigned int v49; // ST64_4@114
13701 double v50; // ST20_8@117
13702 unsigned int v51; // [sp-10h] [bp-64h]@79
13703 unsigned int v52; // [sp-10h] [bp-64h]@100
13704 unsigned int v53; // [sp-Ch] [bp-60h]@79
13705 unsigned int v54; // [sp-Ch] [bp-60h]@100
13706 unsigned int v55; // [sp-8h] [bp-5Ch]@77
13707 unsigned int v56; // [sp-8h] [bp-5Ch]@100
13708 signed int v57; // [sp-4h] [bp-58h]@54
13709 unsigned __int16 v58; // [sp-4h] [bp-58h]@77
13710 unsigned __int16 v59; // [sp-4h] [bp-58h]@100
13711 unsigned __int16 v60; // [sp+10h] [bp-44h]@66
13712 unsigned int v61; // [sp+10h] [bp-44h]@85
13713 unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
13714 unsigned int v63; // [sp+14h] [bp-40h]@85
13715 int v64; // [sp+18h] [bp-3Ch]@39
13716 unsigned int v65; // [sp+18h] [bp-3Ch]@85
13717 unsigned int lPitch; // [sp+20h] [bp-34h]@1
13718 unsigned int lPitcha; // [sp+20h] [bp-34h]@23
13719 char *lPitchb; // [sp+20h] [bp-34h]@106
13720 unsigned int v69; // [sp+24h] [bp-30h]@23
13721 signed int v70; // [sp+24h] [bp-30h]@37
13722 unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
13723 signed int uBluea; // [sp+28h] [bp-2Ch]@37
13724 int v73; // [sp+2Ch] [bp-28h]@30
13725 unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
13726 int v76; // [sp+34h] [bp-20h]@91
13727 int v77; // [sp+34h] [bp-20h]@108
13728 signed int v78; // [sp+38h] [bp-1Ch]@37
13729 int v79; // [sp+38h] [bp-1Ch]@72
13730 signed int a2b; // [sp+40h] [bp-14h]@41
13731 char *a2c; // [sp+40h] [bp-14h]@68
13732 int a3a; // [sp+44h] [bp-10h]@40
13733 signed int uCenterY; // [sp+48h] [bp-Ch]@1
13734 signed int uCenterX; // [sp+4Ch] [bp-8h]@1
13735 //signed int uZb; // [sp+5Ch] [bp+8h]@27
13736 signed int uWidth; // [sp+5Ch] [bp+8h]@30
13737 signed int uZd; // [sp+5Ch] [bp+8h]@45
13738 signed int uZe; // [sp+5Ch] [bp+8h]@67
13739 signed int uZf; // [sp+5Ch] [bp+8h]@85
13740 signed int uZg; // [sp+5Ch] [bp+8h]@105
13741 unsigned int uWa; // [sp+60h] [bp+Ch]@23
13742 float uWb; // [sp+60h] [bp+Ch]@30
13743 unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
13744 unsigned int uWd; // [sp+60h] [bp+Ch]@95
13745 float uZooma; // [sp+64h] [bp+10h]@117
13746 signed int flagsa; // [sp+68h] [bp+14h]@42
13747 unsigned int flagsb; // [sp+68h] [bp+14h]@66
13748 char *flagsc; // [sp+68h] [bp+14h]@86
13749 unsigned int flagsd; // [sp+68h] [bp+14h]@105
13750
13751 //a3 = uY;
13752 //a2 = uX;
13753 uCenterX = (uX + uZ) / 2;
13754 uCenterY = (uY + uW) / 2;
13755 lPitch = pRenderer->uTargetSurfacePitch;
13756 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
13757 uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
13758 auto bWizardEyeActive = pParty->WizardEyeActive();
13759 auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel();
13760 if (CheckHiredNPCSpeciality(0x26u))
13761 {
13762 bWizardEyeActive = true;
13763 uWizardEyeSkillLevel = 2;
13764 }
13765 pRenderer->Clip_v2(uX, uY, uZ - 1, uW - 1);
13766 uHeight = uW - uY;
13767 uWidth = uZ - uX;
13768
13769 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
13770 {
13771 v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
13772 v74 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
13773 v62 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
13774 v73 = (1 << (v17 + 16)) / (signed int)uZoom;
13775 v18 = (double)(1 << (16 - v17));
13776 v19 = v18;
13777 v20 = (double)(pParty->vPosition.x + 32768) / v18;
13778 v21 = (double)(32768 - pParty->vPosition.y) / v19;
13779 uWb = v21;
13780 if ( uZoom == 512 )
13781 {
13782 v20 = v20 - (double)(uWidth / 2);
13783 v22 = (double)(uHeight / 2);
13784 }
13785 else
13786 {
13787 if ( uZoom == 1024 )
13788 {
13789 v20 = v20 - (double)(uWidth / 4);
13790 v22 = (double)(uHeight / 4);
13791 }
13792 else
13793 {
13794 if ( uZoom != 2048 )
13795 goto LABEL_37;
13796 v20 = v20 - (double)(uWidth / 8);
13797 v22 = (double)(uHeight / 8);
13798 }
13799 }
13800 uWb = v21 - v22;
13801 LABEL_37:
13802 //v23 = v20 * 65536.0;
13803 //v24 = v23 + 6.7553994e15;
13804 v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
13805 //uWe = uWb * 65536.0;
13806 //v25 = uWe + 6.7553994e15;
13807 v78 = v70;
13808 uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
13809 v26 = (unsigned __int16 *)_56EFD8_minimap;
13810 v27 = uBluea >> 16;
13811 uWc = (unsigned __int16 *)_56EFD8_minimap;
13812 v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
13813 if ( flags )
13814 {
13815 if ( v74 )
13816 {
13817 v64 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
13818 if ( uHeight > 0 )
13819 {
13820 a3a = uHeight;
13821 v29 = v70 >> 16;
13822 do
13823 {
13824 a2b = 0;
13825 if ( uWidth > 0 )
13826 {
13827 v30 = (int)&v74[v27 * v64];
13828 flagsa = uWidth;
13829 a2b = uWidth;
13830 do
13831 {
13832 v31 = uWc;
13833 ++uWc;
13834 *v31 = v62[*(char *)(v30 + v29)];
13835 v78 += v73;
13836 v29 = v78 >> 16;
13837 --flagsa;
13838 }
13839 while ( flagsa );
13840 }
13841 v78 = v70;
13842 v29 = v70 >> 16;
13843 v28 += 137 - a2b;
13844 uBluea += v73;
13845 v27 = uBluea >> 16;
13846 --a3a;
13847 }
13848 while ( a3a );
13849 }
13850 }
13851 }
13852 uZd = 117;
13853 do
13854 {
13855 v32 = 137;
13856 do
13857 {
13858 *v28 = *v26;
13859 ++v28;
13860 ++v26;
13861 --v32;
13862 }
13863 while ( v32 );
13864 v28 += lPitch - 137;
13865 --uZd;
13866 }
13867 while ( uZd );
13868 uNumBlueFacesInBLVMinimap = 0;
13869 }
13870 else
13871 {
13872 pRenderer->FillRectFast(uX, uY, uZ - uX, uHeight, 0xF);
13873 uNumBlueFacesInBLVMinimap = 0;
13874
13875 for (uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i)
13876 {
13877 auto pOutline = &pIndoor->pMapOutlines->pOutlines[i];
13878
13879 auto pFace1 = pIndoor->pFaces + pOutline->uFace1ID;
13880 auto pFace2 = pIndoor->pFaces + pOutline->uFace2ID;
13881 //v9 = pIndoor->pFaces[pMapVertex->uFace1ID].uAttributes;
13882 //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes;
13883 if (pFace1->Visible() && pFace2->Visible())
13884 {
13885 v11 = pOutline->uFlags;
13886 if ( v11 & 1 )
13887 goto LABEL_15;
13888 if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
13889 goto LABEL_ABC;
13890
13891 }
13892 continue;
13893
13894 LABEL_ABC:
13895 pOutline->uFlags = v11 | 1;
13896 pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
13897
13898 LABEL_15:
13899 //v12 = &pIndoor->pFaces[pOutline->uFace1ID];
13900 if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 &&
13901 (pFace1->uAttributes & 0x2000000 || pFace2->uAttributes & 0x2000000) &&
13902 (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID))
13903 {
13904 if (uNumBlueFacesInBLVMinimap < 49)
13905 pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i;
13906 }
13907 else
13908 {
13909 auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x);
13910 auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16);
13911 auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16);
13912 v69 = uCenterX + _c;
13913 v69 = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
13914 lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
13915 uWa = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
13916 v14 = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
13917 v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
13918 if ( v15 > 100 )
13919 v15 = 100;
13920 pRenderer->Line2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
13921 }
13922 }
13923
13924
13925 for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i)
13926 {
13927 //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
13928 auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]];
13929 pRenderer->Line2D(
13930 uCenterX
13931 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
13932 * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16)
13933 - uZoom * pParty->vPosition.x) >> 16),
13934 uCenterY
13935 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
13936 * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
13937 - uZoom * pParty->vPosition.y) >> 16),
13938 uCenterX
13939 + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
13940 * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
13941 - uZoom * pParty->vPosition.x) >> 16),
13942 uCenterY
13943 - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
13944 * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
13945 - uZoom * pParty->vPosition.y) >> 16),
13946 uBlue);
13947 }
13948 }
13949
13950
13951 //_draw_party_arrow:
13952 v33 = 0;
13953 v34 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
13954 v35 = 0;
13955 if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) < 128 )
13956 goto LABEL_66;
13957 if ( (signed int)v34 <= 384 )
13958 {
13959 v35 = 1;
13960 goto LABEL_66;
13961 }
13962 if ( (signed int)v34 >= 640 )
13963 {
13964 if ( (signed int)v34 > 896 )
13965 {
13966 if ( (signed int)v34 >= 1152 )
13967 {
13968 if ( (signed int)v34 > 1408 )
13969 {
13970 if ( (signed int)v34 >= 1664 )
13971 {
13972 if ( (signed int)v34 > 1920 )
13973 goto LABEL_66;
13974 v57 = 7;
13975 }
13976 else
13977 {
13978 v57 = 6;
13979 }
13980 }
13981 else
13982 {
13983 v57 = 5;
13984 }
13985 }
13986 else
13987 {
13988 v57 = 4;
13989 }
13990 }
13991 else
13992 {
13993 v57 = 3;
13994 }
13995 }
13996 else
13997 {
13998 v57 = 2;
13999 }
14000 v35 = v57;
14001 LABEL_66:
14002 pRenderer->DrawTextureTransparent(
14003 uCenterX - 3,
14004 uCenterY - 3,
14005 (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
14006 v36 = 255;
14007 flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
14008 v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
14009 if ( bWizardEyeActive )
14010 {
14011 uZe = 0;
14012 //for (uint i = 0; i < uNumLayingItems; ++i)
14013 if (uNumLayingItems > 0)
14014 {
14015 a2c = (char *)&pLayingItems[0].uObjectDescID;
14016 while ( 1 )
14017 {
14018 if ( !*((short *)a2c - 1)
14019 || !*(short *)a2c
14020 || uWizardEyeSkillLevel == 1
14021 || (v37 = ((unsigned __int64)((*(int *)(a2c + 2) - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
14022 + uCenterX,
14023 v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16,
14024 v38 = uCenterY - v79,
14025 v37 < pRenderer->field_1C_clipx)
14026 || v37 > pRenderer->field_24_clipz
14027 || v38 < pRenderer->field_20_clipy
14028 || v38 > pRenderer->field_28_clipw )
14029 goto LABEL_83;
14030 if ( pObjectList->pObjects[*(short *)a2c].uFlags & 0x10 )
14031 break;
14032 if ( (signed int)uZoom > 512 )
14033 {
14034 pRenderer->Line2D(v37 - 1, v38 - 1, v37 - 1, v38 + 1, flagsb);
14035 pRenderer->Line2D(v37, v38 - 2, v37, v38 + 1, flagsb);
14036 pRenderer->Line2D(v37 + 1, v38 - 1, v37 + 1, v38 + 1, flagsb);
14037 pRenderer->Line2D(v37 - 2, v38, v37 - 2, v38 + 1, flagsb);
14038 v37 += 2;
14039 v58 = flagsb;
14040 v55 = v38 + 1;
14041 goto LABEL_81;
14042 }
14043 pRenderer->Line2D(v37 - 1, v38 - 1, v37 - 1, uCenterY - v79, flagsb);
14044 v58 = flagsb;
14045 v55 = uCenterY - v79;
14046 v53 = v37;
14047 v51 = v38 - 1;
14048 LABEL_82:
14049 pRenderer->Line2D(v37, v51, v53, v55, v58);
14050 LABEL_83:
14051 ++uZe;
14052 a2c += 112;
14053 if ( uZe >= (signed int)uNumLayingItems )
14054 {
14055 v36 = 255;
14056 v33 = 0;
14057 goto LABEL_85;
14058 }
14059 }
14060 v58 = v60;
14061 v55 = uCenterY - v79;
14062 LABEL_81:
14063 v53 = v37;
14064 v51 = uCenterY - v79;
14065 goto LABEL_82;
14066 }
14067 LABEL_85:
14068 v63 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, 0, v33);
14069 v61 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, v36, v33);
14070 v65 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, v36, v33);
14071 uZf = v33;
14072 if ( (signed int)uNumActors > v33 )
14073 {
14074 flagsc = (char *)&pActors[0].uAIState;
14075 do
14076 {
14077 v39 = *(short *)flagsc;
14078 if ( *(short *)flagsc != 11 && v39 != 19 && (v39 == 5 || *(flagsc - 139) & 0x80) )
14079 {
14080 v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
14081 * (signed __int64)(signed int)uZoom) >> 16)
14082 + uCenterX;
14083 v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.y)
14084 * (signed __int64)(signed int)uZoom) >> 16;
14085 v41 = uCenterY - v76;
14086 if ( v40 >= pRenderer->field_1C_clipx )
14087 {
14088 if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
14089 {
14090 uWd = v61;
14091 if ( *(flagsc - 137) & 1 )
14092 uWd = v63;
14093 if ( *(short *)flagsc == 5 )
14094 uWd = v65;
14095 if ( (signed int)uZoom > 1024 )
14096 {
14097 pRenderer->Line2D(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd);
14098 pRenderer->Line2D(v40, v41 - 2, v40, v41 + 2, uWd);
14099 pRenderer->Line2D(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd);
14100 v42 = v41 + 1;
14101 v43 = v41 - 1;
14102 v44 = v42;
14103 pRenderer->Line2D(v40 - 2, v43, v40 - 2, v42, uWd);
14104 v40 += 2;
14105 v59 = uWd;
14106 v56 = v44;
14107 v54 = v40;
14108 v52 = v43;
14109 }
14110 else
14111 {
14112 pRenderer->Line2D(v40 - 1, v41 - 1, v40 - 1, uCenterY - v76, uWd);
14113 v59 = uWd;
14114 v56 = uCenterY - v76;
14115 v54 = v40;
14116 v52 = v41 - 1;
14117 }
14118 pRenderer->Line2D(v40, v52, v54, v56, v59);
14119 }
14120 }
14121 }
14122 ++uZf;
14123 flagsc += 836;
14124 }
14125 while ( uZf < (signed int)uNumActors );
14126 v36 = 255;
14127 v33 = 0;
14128 }
14129 }
14130 flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v36, v36, v36);
14131 uZg = v33;
14132 if ( (signed int)uNumLevelDecorations > v33 )
14133 {
14134 v45 = (char *)&pLevelDecorations[0].vPosition;
14135 lPitchb = (char *)&pLevelDecorations[0].vPosition;
14136 do
14137 {
14138 if ( *(v45 - 2) & 8 )
14139 {
14140 v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
14141 + uCenterX;
14142 v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16;
14143 v47 = uCenterY - v77;
14144 if ( v46 >= pRenderer->field_1C_clipx )
14145 {
14146 if ( v46 <= pRenderer->field_24_clipz && v47 >= pRenderer->field_20_clipy && v47 <= pRenderer->field_28_clipw )
14147 {
14148 if ( (signed int)uZoom > 512 )
14149 {
14150 v48 = v47 + 1;
14151 v49 = v47 - 1;
14152 pRenderer->Line2D(v46 - 1, v47 - 1, v46 - 1, v47 + 1, flagsd);
14153 pRenderer->Line2D(v46, v49, v46, v48, flagsd);
14154 pRenderer->Line2D(v46 + 1, v49, v46 + 1, v48, flagsd);
14155 v45 = lPitchb;
14156 }
14157 else
14158 {
14159 pRenderer->Line2D(v46, uCenterY - v77, v46, uCenterY - v77, flagsd);
14160 }
14161 }
14162 }
14163 }
14164 ++uZg;
14165 v45 += 32;
14166 lPitchb = v45;
14167 }
14168 while ( uZg < (signed int)uNumLevelDecorations );
14169 v33 = 0;
14170 }
14171 pRenderer->DrawTextureTransparent(
14172 0x1D4u,
14173 v33,
14174 (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
14175 uZooma = (double)pParty->sRotationY * 0.1171875;
14176 v50 = uZooma + 6.7553994e15;
14177 pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
14178 pRenderer->DrawTextureIndexed(
14179 LODWORD(v50) + 285,
14180 0x88u,
14181 (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
14182 pRenderer->ResetClip();
14183 }
14184
14185
14186 //----- (00442955) --------------------------------------------------------
14187 int __fastcall DrawSpellbook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074)
14188 {
14189 int v5; // ebx@1
14190 int v6; // edi@1
14191 unsigned int *v7; // eax@8
14192 unsigned __int8 v8; // zf@8
14193 unsigned __int8 v9; // sf@8
14194 int v10; // esi@10
14195 unsigned int v11; // edx@11
14196 __int16 v12; // cx@12
14197 signed int v13; // eax@15
14198 int v14; // eax@16
14199 Vec3_short_ *v15; // ecx@16
14200 int v16; // edx@16
14201 int v17; // ecx@16
14202 Vec3_short_ *v18; // eax@16
14203 int v19; // ecx@16
14204 int v20; // eax@16
14205 signed int v21; // esi@18
14206 int v22; // ecx@21
14207 int v23; // ecx@21
14208 Vec3_short_ *v24; // edx@21
14209 Vec3_short_ *v25; // eax@21
14210 int v26; // ecx@21
14211 unsigned __int16 *v27; // edi@21
14212 int v28; // edx@21
14213 int v29; // eax@21
14214 double v30; // st7@23
14215 signed __int64 v31; // qax@23
14216 char *v32; // edx@23
14217 int v33; // esi@23
14218 signed int v34; // eax@23
14219 signed int v35; // ecx@23
14220 int v36; // esi@27
14221 int v37; // ecx@27
14222 int v38; // edx@31
14223 unsigned int v39; // eax@33
14224 const void *v40; // esi@33
14225 unsigned __int16 *v41; // edi@33
14226 unsigned __int8 v42; // cf@33
14227 unsigned int v43; // ecx@33
14228 int v44; // edi@33
14229 int v45; // esi@33
14230 int v46; // ecx@33
14231 signed int v47; // esi@38
14232 signed int v48; // ecx@38
14233 int v49; // eax@38
14234 signed int v50; // edx@55
14235 unsigned int v51; // ecx@55
14236 int result; // eax@72
14237 int v53; // eax@75
14238 int v54; // esi@75
14239 int v55; // eax@75
14240 __int16 v56; // si@85
14241 double v57; // st7@85
14242 int v58; // ebx@85
14243 signed __int64 v59; // qax@85
14244 signed int v60; // edi@85
14245 signed __int64 v61; // qax@85
14246 signed int v62; // ebx@85
14247 signed int v63; // esi@85
14248 int v64; // eax@87
14249 unsigned int v65; // ebx@95
14250 char *v66; // edx@95
14251 unsigned __int16 *v67; // esi@96
14252 int v68; // edi@98
14253 unsigned __int16 v69; // cx@99
14254 unsigned int v70; // [sp-10h] [bp-48074h]@80
14255 unsigned int v71; // [sp-Ch] [bp-48070h]@80
14256 unsigned int v72; // [sp-8h] [bp-4806Ch]@80
14257 signed int v73; // [sp-4h] [bp-48068h]@59
14258 unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
14259 char v75; // [sp+Ch] [bp-48058h]@23
14260 int v76; // [sp+4800Ch] [bp-58h]@23
14261 unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
14262 unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23
14263 unsigned int v79; // [sp+48018h] [bp-4Ch]@1
14264 unsigned int y_; // [sp+4801Ch] [bp-48h]@1
14265 int v81; // [sp+48020h] [bp-44h]@23
14266 unsigned int x_; // [sp+48024h] [bp-40h]@1
14267 unsigned int teal; // [sp+48028h] [bp-3Ch]@8
14268 int v84; // [sp+4802Ch] [bp-38h]@1
14269 int v85; // [sp+48030h] [bp-34h]@1
14270 int v86; // [sp+48034h] [bp-30h]@1
14271 int v87; // [sp+48038h] [bp-2Ch]@16
14272 unsigned int v88; // [sp+4803Ch] [bp-28h]@16
14273 int black; // [sp+48040h] [bp-24h]@8
14274 int v90; // [sp+48044h] [bp-20h]@1
14275 unsigned int i; // [sp+48048h] [bp-1Ch]@9
14276 unsigned int v92; // [sp+4804Ch] [bp-18h]@16
14277 unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
14278 unsigned int v94; // [sp+48054h] [bp-10h]@8
14279 unsigned int v95; // [sp+48058h] [bp-Ch]@16
14280 int v96; // [sp+4805Ch] [bp-8h]@10
14281 const void *v97; // [sp+48060h] [bp-4h]@16
14282 char *a4a; // [sp+4806Ch] [bp+8h]@85
14283 int a5a; // [sp+48070h] [bp+Ch]@86
14284
14285 x_ = x;
14286 y_ = y;
14287 v85 = (signed int)(x + a4) >> 1;
14288 v90 = (signed int)(y + a5) >> 1;
14289 v79 = pRenderer->uTargetSurfacePitch;
14290 pRenderer->Clip_v2(x, y, a4, a5);
14291 v5 = viewparams->field_2C;
14292 v6 = viewparams->sPartyPosX;
14293 v86 = viewparams->sPartyPosX;
14294 v84 = viewparams->sPartyPosZ;
14295 if ( viewparams->field_2C != 384 )
14296 {
14297 if ( viewparams->field_2C == 768 )
14298 {
14299 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
14300 goto LABEL_23;
14301 v5 = 680;
14302 }
14303 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
14304 goto LABEL_8;
14305 LABEL_23:
14306 v94 = a4 - x_ + 1;
14307 v92 = a5 - y_ + 1;
14308 v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
14309 v95 = (unsigned int)pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
14310 v78 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
14311 v87 = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
14312 v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
14313 black = 22528 / (v5 / 384);
14314 teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
14315 v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
14316 v96 = 32768 - black - v84;
14317 v31 = (signed __int64)((double)v96 / v30);
14318 v32 = &v75;
14319 v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
14320 v34 = (int)v31 << 16;
14321 v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
14322 black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
14323 v76 = v33;
14324 v35 = v34 >> 16;
14325 if ( v95 && (signed int)v92 > 0 )
14326 {
14327 v96 = v92;
14328 do
14329 {
14330 v88 = 0;
14331 if ( (signed int)v94 > 0 )
14332 {
14333 v36 = v95 + v35 * v76;
14334 i = v94;
14335 v88 = v94;
14336 v37 = black;
14337 v77 = (unsigned __int16 *)v36;
14338 do
14339 {
14340 *(short *)v32 = v78[*((char *)v77 + v37)];
14341 v32 += 2;
14342 v97 = (char *)v97 + v87;
14343 v37 = (signed int)v97 >> 16;
14344 --i;
14345 }
14346 while ( i );
14347 }
14348 v34 += v87;
14349 v97 = (const void *)teal;
14350 black = v81;
14351 v32 += 2 * (v94 - v88);
14352 v35 = v34 >> 16;
14353 --v96;
14354 }
14355 while ( v96 );
14356 }
14357 v97 = &v75;
14358 if ( (signed int)v92 > 0 )
14359 {
14360 v96 = v92;
14361 v38 = 2 * (v79 - v94);
14362 do
14363 {
14364 if ( (signed int)v94 > 0 )
14365 {
14366 v39 = v94;
14367 v40 = v97;
14368 v41 = v93;
14369 v42 = v94 & 1;
14370 v43 = v94 >> 1;
14371 memcpy(v93, v97, 4 * (v94 >> 1));
14372 v45 = (int)((char *)v40 + 4 * v43);
14373 v44 = (int)&v41[2 * v43];
14374 v46 = v42;
14375 v39 *= 2;
14376 v93 = (unsigned __int16 *)((char *)v93 + v39);
14377 v97 = (char *)v97 + v39;
14378 while ( v46 )
14379 {
14380 *(short *)v44 = *(short *)v45;
14381 v45 += 2;
14382 v44 += 2;
14383 --v46;
14384 }
14385 v6 = v86;
14386 }
14387 v93 = (unsigned __int16 *)((char *)v93 + v38);
14388 --v96;
14389 }
14390 while ( v96 );
14391 }
14392 goto LABEL_38;
14393 }
14394 v6 = viewparams->field_38;
14395 v86 = viewparams->field_38;
14396 v84 = viewparams->field_3A;
14397 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
14398 goto LABEL_23;
14399 v5 = viewparams->field_2C - 34;
14400 LABEL_8:
14401 black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
14402 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
14403 v7 = (uint *)pIndoor->pMapOutlines;
14404 uNumBlueFacesInBLVMinimap = 0;
14405 v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
14406 v9 = (pIndoor->pMapOutlines->uNumOutlines & 0x80000000u) != 0;
14407 v94 = 0;
14408 if ( !(v9 | v8) )
14409 {
14410 i = 0;
14411 do
14412 {
14413 v10 = (int)((char *)v7 + i + 4);
14414 v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
14415 if ( BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )
14416 goto LABEL_17;
14417 v12 = *(short *)((char *)v7 + i + 14);
14418 if ( !(v12 & 1) )
14419 {
14420 if ( !(v96 & 0x80) && (v11 & 0x80u) == 0 )
14421 goto LABEL_17;
14422 v96 = (signed int)v94 >> 3;
14423 v13 = v94;
14424 *(short *)(v10 + 10) = v12 | 1;
14425 pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
14426 }
14427 v14 = *(short *)v10;
14428 v88 = v5;
14429 v15 = &pIndoor->pVertices[v14];
14430 v16 = v15->x;
14431 v17 = v15->y - v84;
14432 v93 = (unsigned __int16 *)(v16 - v6);
14433 v92 = v17;
14434 v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
14435 v19 = v18->x;
14436 v20 = v18->y - v84;
14437 v95 = v19 - v6;
14438 v97 = (const void *)v20;
14439 v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
14440 v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
14441 v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
14442 v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
14443 pRenderer->Line2D(
14444 v85 + v88,
14445 v90 - v87,
14446 v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
14447 v90 - v92,
14448 black);
14449 v7 = (uint *)pIndoor->pMapOutlines;
14450 LABEL_17:
14451 ++v94;
14452 i += 12;
14453 }
14454 while ( (signed int)v94 < (signed int)*v7 );
14455 }
14456 v21 = 0;
14457 if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
14458 {
14459 while ( 1 )
14460 {
14461 v22 = pBlueFacesInBLVMinimapIDs[v21];
14462 v87 = v5;
14463 v23 = (int)&v7[3 * v22 + 1];
14464 v24 = &pIndoor->pVertices[*(short *)v23];
14465 v25 = &pIndoor->pVertices[*(short *)(v23 + 2)];
14466 v26 = v25->x;
14467 v27 = (unsigned __int16 *)(v24->x - v86);
14468 v28 = v24->y - v84;
14469 v29 = v25->y - v84;
14470 v93 = v27;
14471 v92 = v28;
14472 v97 = (const void *)v29;
14473 v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
14474 v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
14475 i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
14476 v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
14477 pRenderer->Line2D(
14478 v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
14479 v90 - v88,
14480 v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
14481 v90 - v95,
14482 teal);
14483 ++v21;
14484 if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
14485 break;
14486 v7 = (uint *)pIndoor->pMapOutlines;
14487 }
14488 v6 = v86;
14489 }
14490 LABEL_38:
14491 v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
14492 v81 = pParty->vPosition.y - v84;
14493 v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
14494 v48 = 1;
14495 v49 = v90 - (int)v97 - 3;
14496 if ( v47 >= (signed int)x_ )
14497 {
14498 if ( v47 > (signed int)a4 )
14499 {
14500 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 6) > (signed int)a4 )
14501 v48 = 0;
14502 v47 = a4;
14503 }
14504 }
14505 else
14506 {
14507 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85) < (signed int)x_ )
14508 v48 = 0;
14509 v47 = x_;
14510 }
14511 if ( v49 >= (signed int)y_ )
14512 {
14513 if ( v49 > a5 )
14514 {
14515 if ( v90 - (signed int)v97 - 6 > a5 )
14516 v48 = 0;
14517 v49 = a5;
14518 }
14519 }
14520 else
14521 {
14522 if ( v90 - (signed int)v97 < (signed int)y_ )
14523 v48 = 0;
14524 v49 = y_;
14525 }
14526 if ( v48 == 1 )
14527 {
14528 v50 = 0;
14529 v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
14530 if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 )
14531 {
14532 if ( (signed int)v51 > 384 )
14533 {
14534 if ( (signed int)v51 >= 640 )
14535 {
14536 if ( (signed int)v51 > 896 )
14537 {
14538 if ( (signed int)v51 >= 1152 )
14539 {
14540 if ( (signed int)v51 > 1408 )
14541 {
14542 if ( (signed int)v51 >= 1664 )
14543 {
14544 if ( (signed int)v51 > 1920 )
14545 goto LABEL_71;
14546 v73 = 7;
14547 }
14548 else
14549 {
14550 v73 = 6;
14551 }
14552 }
14553 else
14554 {
14555 v73 = 5;
14556 }
14557 }
14558 else
14559 {
14560 v73 = 4;
14561 }
14562 }
14563 else
14564 {
14565 v73 = 3;
14566 }
14567 }
14568 else
14569 {
14570 v73 = 2;
14571 }
14572 v50 = v73;
14573 goto LABEL_71;
14574 }
14575 v50 = 1;
14576 }
14577 LABEL_71:
14578 pRenderer->_4A6776(
14579 v47,
14580 v49,
14581 (Texture *)(pTextureIDs_pMapDirs[v50] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v50]] : 0));
14582 }
14583 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14584 v95 = 0;
14585 v86 = result;
14586 if ( (signed int)uNumLevelDecorations > 0 )
14587 {
14588 v94 = (unsigned int)&pLevelDecorations[0].vPosition;
14589 do
14590 {
14591 if ( *(char *)(v94 - 2) & 8 )
14592 {
14593 v53 = *(int *)(v94 + 4) - v84;
14594 v93 = (unsigned __int16 *)(*(int *)v94 - v6);
14595 v92 = v53;
14596 v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
14597 v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
14598 v55 = v90 - (int)v97;
14599 if ( v54 >= pRenderer->field_1C_clipx )
14600 {
14601 if ( v54 <= pRenderer->field_24_clipz && v55 >= pRenderer->field_20_clipy && v55 <= pRenderer->field_28_clipw )
14602 {
14603 v74 = v86;
14604 if ( v5 > 512 )
14605 {
14606 v96 = v55 + 1;
14607 black = v55 - 1;
14608 pRenderer->Line2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
14609 pRenderer->Line2D(v54, black, v54, v96, v86);
14610 ++v54;
14611 v74 = v86;
14612 v72 = v96;
14613 v71 = v54;
14614 v70 = black;
14615 }
14616 else
14617 {
14618 v72 = v90 - (int)v97;
14619 v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
14620 v70 = v90 - (int)v97;
14621 }
14622 pRenderer->Line2D(v54, v70, v71, v72, v74);
14623 }
14624 }
14625 }
14626 ++v95;
14627 result = v95;
14628 v94 += 32;
14629 }
14630 while ( (signed int)v95 < (signed int)uNumLevelDecorations );
14631 }
14632 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
14633 {
14634 v90 = a4 - x_ + 1;
14635 v95 = a5 - y_ + 1;
14636 v77 = &pRenderer->pTargetSurface[x_ + y_ * v79];
14637 v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
14638 black = (1 << (v56 + 16)) / v5;
14639 v57 = (double)(1 << (16 - v56));
14640 v58 = 22528 / (v5 / 384);
14641 v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57);
14642 v60 = (int)v59 << 16;
14643 v97 = (const void *)((int)v59 << 16);
14644 v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
14645 v78 = (unsigned __int16 *)(v60 >> 16);
14646 v62 = (int)v61 << 16;
14647 teal = v60 >> 16;
14648 v63 = (signed __int16)v61;
14649 a4a = &v75;
14650 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
14651 v85 = 0;
14652 for ( i = result; v85 < (signed int)v95; result = v85 )
14653 {
14654 a5a = 0;
14655 if ( v90 > 0 )
14656 {
14657 v96 = (v63 - 80) / 4;
14658 v64 = teal;
14659 do
14660 {
14661 v81 = (v64 - 80) / 4;
14662 if ( !pOutdoor->_47F04C(v81, v96) )
14663 {
14664 if ( pOutdoor->_47F097(v81, v96) )
14665 {
14666 if ( !((a5a + v85) % 2) )
14667 *(short *)a4a = i;
14668 }
14669 else
14670 {
14671 *(short *)a4a = 0;
14672 }
14673 }
14674 a4a += 2;
14675 v97 = (char *)v97 + black;
14676 v64 = (signed int)v97 >> 16;
14677 ++a5a;
14678 }
14679 while ( a5a < v90 );
14680 }
14681 v62 += black;
14682 v97 = (const void *)v60;
14683 a4a += 2 * (v90 - a5a);
14684 v63 = v62 >> 16;
14685 ++v85;
14686 teal = (unsigned int)v78;
14687 }
14688 v65 = v95;
14689 v66 = &v75;
14690 if ( (signed int)v95 > 0 )
14691 {
14692 v67 = v77;
14693 result = 2 * (v79 - v90);
14694 do
14695 {
14696 if ( v90 > 0 )
14697 {
14698 v68 = v90;
14699 do
14700 {
14701 v69 = *(short *)v66;
14702 if ( !*(short *)v66 || v69 == (short)i )
14703 *v67 = v69;
14704 v66 += 2;
14705 ++v67;
14706 --v68;
14707 }
14708 while ( v68 );
14709 }
14710 v67 = (unsigned __int16 *)((char *)v67 + result);
14711 --v65;
14712 }
14713 while ( v65 );
14714 }
14715 }
14716 return result;
14717 }
14718
14719 //----- (00443219) --------------------------------------------------------
14720 int ViewingParams::_443219()
14721 {
14722 this->sPartyPosZ += 512;
14723 return _4432E7();
14724 }
14725
14726 //----- (00443225) --------------------------------------------------------
14727 int ViewingParams::_443225()
14728 {
14729 this->sPartyPosX -= 512;
14730 return _4432E7();
14731 }
14732
14733 //----- (00443231) --------------------------------------------------------
14734 int ViewingParams::_443231()
14735 {
14736 this->sPartyPosZ -= 512;
14737 return _4432E7();
14738 }
14739
14740 //----- (0044323D) --------------------------------------------------------
14741 int ViewingParams::_44323D()
14742 {
14743 this->sPartyPosX += 512;
14744 return _4432E7();
14745 }
14746
14747 //----- (00443249) --------------------------------------------------------
14748 int ViewingParams::_443249()
14749 {
14750 int v1; // edx@1
14751
14752 v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
14753 this->field_2C = v1;
14754 if ( v1 < 384 )
14755 this->field_2C = 384;
14756 this->sPartyPosX = pParty->vPosition.x;
14757 this->sPartyPosZ = pParty->vPosition.y;
14758 return _4432E7();
14759 }
14760
14761 //----- (00443291) --------------------------------------------------------
14762 int ViewingParams::_443291()
14763 {
14764 int v1; // edx@1
14765 int v2; // eax@1
14766
14767 v1 = 2 * this->field_2C;
14768 v2 = 1536;
14769 this->field_2C = v1;
14770 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
14771 v2 = 3072;
14772 if ( v1 > v2 )
14773 this->field_2C = v2;
14774 this->sPartyPosX = pParty->vPosition.x;
14775 this->sPartyPosZ = pParty->vPosition.y;
14776 return _4432E7();
14777 }
14778
14779 //----- (004432E7) --------------------------------------------------------
14780 int ViewingParams::_4432E7()
14781 {
14782 ViewingParams *v1; // esi@1
14783 int v2; // ebx@1
14784 signed int v3; // edx@1
14785 int v4; // ecx@1
14786 int v5; // edi@3
14787 int v6; // eax@3
14788 int v7; // eax@5
14789 int result; // eax@7
14790
14791 v1 = this;
14792 v2 = this->field_3A;
14793 v3 = 88 >> this->field_2C / 384;
14794 v4 = (44 - v3) << 9;
14795 if ( v1->sPartyPosZ > v2 + v4 )
14796 v1->sPartyPosZ = v2 + v4;
14797 v5 = v1->field_38;
14798 v6 = (v3 - 44) << 9;
14799 if ( v1->sPartyPosX < v5 + v6 )
14800 v1->sPartyPosX = v5 + v6;
14801 v7 = v2 + v6;
14802 if ( v1->sPartyPosZ < v7 )
14803 v1->sPartyPosZ = v7;
14804 result = v5 + v4;
14805 if ( v1->sPartyPosX > v5 + v4 )
14806 v1->sPartyPosX = result;
14807 return result;
14808 }
14809
14810 //----- (00443343) --------------------------------------------------------
14811 unsigned int ViewingParams::_443343()
14812 {
14813 signed int v1; // esi@1
14814 unsigned __int16 *v2; // edi@1
14815 unsigned int result; // eax@2
14816
14817 v1 = 0;
14818 v2 = this->pPalette;
14819 do
14820 {
14821 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, v1);
14822 *v2 = result;
14823 ++v1;
14824 ++v2;
14825 }
14826 while ( v1 < 256 );
14827 return result;
14828 }
14829
14830 //----- (00443365) --------------------------------------------------------
14831 int ViewingParams::_443365()
14832 {
14833 ViewingParams *v1; // esi@1
14834 __int16 *v2; // edi@3
14835 Vec3_short_ *v3; // eax@4
14836 unsigned int v4; // edx@4
14837 signed int v5; // eax@8
14838 Vec3_short_ *v6; // eax@12
14839 signed int v7; // edi@12
14840 signed int v8; // eax@16
14841 char v9; // zf@20
14842 int result; // eax@21
14843 unsigned int v11; // [sp+4h] [bp-1Ch]@3
14844 unsigned int *v12; // [sp+8h] [bp-18h]@3
14845 unsigned int v13; // [sp+Ch] [bp-14h]@8
14846 unsigned int v14; // [sp+10h] [bp-10h]@2
14847 unsigned int v15; // [sp+14h] [bp-Ch]@2
14848 unsigned int v16; // [sp+18h] [bp-8h]@2
14849 unsigned int v17; // [sp+1Ch] [bp-4h]@2
14850
14851 v1 = this;
14852 _443343();
14853 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
14854 {
14855 v16 = 0x40000000u;
14856 v14 = 0x40000000u;
14857 v17 = 0xC0000000u;
14858 v15 = 0xC0000000u;
14859 if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
14860 {
14861 v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
14862 v11 = pIndoor->pMapOutlines->uNumOutlines;
14863 v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
14864 do
14865 {
14866 v3 = &pIndoor->pVertices[*v2];
14867 v4 = v3->x;
14868 if ( (signed int)v4 < (signed int)v16 )
14869 v16 = v3->x;
14870 if ( (signed int)v4 > (signed int)v17 )
14871 v17 = v3->x;
14872 v5 = v3->y;
14873 v13 = v5;
14874 if ( v5 < (signed int)v14 )
14875 v14 = v4;
14876 if ( v5 > (signed int)v15 )
14877 v15 = v4;
14878 v6 = &pIndoor->pVertices[v2[1]];
14879 v7 = v6->x;
14880 if ( v7 < (signed int)v16 )
14881 v16 = v4;
14882 if ( v7 > (signed int)v17 )
14883 v17 = v4;
14884 v8 = v6->y;
14885 if ( v8 < (signed int)v14 )
14886 v14 = v13;
14887 if ( v8 > (signed int)v15 )
14888 v15 = v13;
14889 v2 = (__int16 *)(v12 + 3);
14890 v9 = v11-- == 1;
14891 v12 += 3;
14892 }
14893 while ( !v9 );
14894 }
14895 v1->uMinimapZoom = 1024;
14896 v1->field_38 = (signed int)(v16 + v17) / 2;
14897 v1->field_28 = 10;
14898 result = (signed int)(v14 + v15) / 2;
14899 v1->field_3A = result;
14900 }
14901 else
14902 {
14903 v1->field_38 = 0;
14904 v1->field_3A = 0;
14905 v1->uMinimapZoom = dword_576E2C;
14906 result = dword_576E28;
14907 v1->field_28 = dword_576E28;
14908 }
14909 v1->field_2C = 384;
14910 return result;
14911 }
14912
14913
14914 //----- (00443801) --------------------------------------------------------
14915 int __cdecl Initialize2DA()
14916 {
14917 const char *v0; // esi@3
14918 _2devent *v1; // edi@3
14919 char *v2; // esi@5
14920 int v3; // edx@5
14921 char v4; // cl@6
14922 int v5; // eax@6
14923 int v6; // ebx@10
14924 int v7; // eax@60
14925 int result; // eax@78
14926 signed int v9; // [sp+10h] [bp-8h]@5
14927 signed int v10; // [sp+14h] [bp-4h]@5
14928
14929 int it = 0;
14930
14931 if ( p2DEventsTXT_Raw )
14932 pAllocator->FreeChunk(p2DEventsTXT_Raw);
14933 p2DEventsTXT_Raw = 0;
14934 v0 = "\r";
14935 p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
14936 strtok(p2DEventsTXT_Raw, "\r");
14937 strtok(0, "\r");
14938 v1 = p2DEvents;
14939 while ( 1 )
14940 {
14941 v2 = strtok(0, v0) + 1;
14942 v10 = 0;
14943 v3 = -2;
14944 v9 = -2;
14945 do
14946 {
14947 v4 = *v2;
14948 v5 = 0;
14949 while ( v4 != 9 && v4 )
14950 {
14951 ++v5;
14952 v4 = v2[v5];
14953 }
14954 v6 = (int)&v2[v5];
14955 if ( !v2[v5] )
14956 v10 = 1;
14957 *(char *)v6 = 0;
14958 if ( v5 )
14959 {
14960 switch ( v3 )
14961 {
14962 case 0:
14963 if ( _strnicmp(v2, "wea", 3u) )
14964 {
14965 if ( _strnicmp(v2, "arm", 3u) )
14966 {
14967 if ( _strnicmp(v2, "mag", 3u) )
14968 {
14969 if ( _strnicmp(v2, "alc", 3u) )
14970 {
14971 if ( _strnicmp(v2, "sta", 3u) )
14972 {
14973 if ( _strnicmp(v2, "boa", 3u) )
14974 {
14975 if ( _strnicmp(v2, "tem", 3u) )
14976 {
14977 if ( _strnicmp(v2, "tra", 3u) )
14978 {
14979 if ( _strnicmp(v2, "tow", 3u) )
14980 {
14981 if ( _strnicmp(v2, "tav", 3u) )
14982 {
14983 if ( _strnicmp(v2, "ban", 3u) )
14984 {
14985 if ( _strnicmp(v2, "fir", 3u) )
14986 {
14987 if ( _strnicmp(v2, "air", 3u) )
14988 {
14989 if ( _strnicmp(v2, "wat", 3u) )
14990 {
14991 if ( _strnicmp(v2, "ear", 3u) )
14992 {
14993 if ( _strnicmp(v2, "spi", 3u) )
14994 {
14995 if ( _strnicmp(v2, "min", 3u) )
14996 {
14997 if ( _strnicmp(v2, "bod", 3u) )
14998 {
14999 if ( _strnicmp(v2, "lig", 3u) )
15000 {
15001 if ( _strnicmp(v2, "dar", 3u) )
15002 {
15003 if ( _strnicmp(v2, "ele", 3u) )
15004 {
15005 if ( _strnicmp(v2, "sel", 3u) )
15006 {
15007 if ( _strnicmp(v2, "mir", 3u) )
15008 {
15009 v7 = -(_strnicmp(v2, "mer", 3u) != 0);
15010 LOBYTE(v7) = v7 & 0xEE;
15011 v1->uType = v7 + 18;
15012 }
15013 else
15014 {
15015 v1->uType = 16;
15016 }
15017 }
15018 else
15019 {
15020 v1->uType = 15;
15021 }
15022 }
15023 else
15024 {
15025 v1->uType = 14;
15026 }
15027 }
15028 else
15029 {
15030 v1->uType = 13;
15031 }
15032 }
15033 else
15034 {
15035 v1->uType = 12;
15036 }
15037 }
15038 else
15039 {
15040 v1->uType = 11;
15041 }
15042 }
15043 else
15044 {
15045 v1->uType = 10;
15046 }
15047 }
15048 else
15049 {
15050 v1->uType = 9;
15051 }
15052 }
15053 else
15054 {
15055 v1->uType = 8;
15056 }
15057 }
15058 else
15059 {
15060 v1->uType = 7;
15061 }
15062 }
15063 else
15064 {
15065 v1->uType = 6;
15066 }
15067 }
15068 else
15069 {
15070 v1->uType = 5;
15071 }
15072 }
15073 else
15074 {
15075 v1->uType = 22;
15076 }
15077 }
15078 else
15079 {
15080 v1->uType = 21;
15081 }
15082 }
15083 else
15084 {
15085 v1->uType = 17;
15086 }
15087 }
15088 else
15089 {
15090 v1->uType = 30;
15091 }
15092 }
15093 else
15094 {
15095 v1->uType = 23;
15096 }
15097 }
15098 else
15099 {
15100 v1->uType = 28;
15101 }
15102 }
15103 else
15104 {
15105 v1->uType = 27;
15106 }
15107 }
15108 else
15109 {
15110 v1->uType = 4;
15111 }
15112 }
15113 else
15114 {
15115 v1->uType = 3;
15116 }
15117 }
15118 else
15119 {
15120 v1->uType = 2;
15121 }
15122 }
15123 else
15124 {
15125 v1->uType = 1;
15126 }
15127 break;
15128 case 2:
15129 v1->uAnimationID = atoi(v2);
15130 break;
15131 case 3:
15132 v1->pName = (char *)RemoveQuotes(v2);
15133 break;
15134 case 4:
15135 v1->pProprieterName = RemoveQuotes(v2);
15136 break;
15137 case 5:
15138 v1->pProprieterTitle = RemoveQuotes(v2);
15139 break;
15140 case 6:
15141 v1->field_14 = atoi(v2);
15142 break;
15143 case 7:
15144 v1->_state = atoi(v2);
15145 break;
15146 case 8:
15147 v1->_rep = atoi(v2);
15148 break;
15149 case 9:
15150 v1->_per = atoi(v2);
15151 break;
15152 case 10:
15153 v1->fPriceMultiplier = atof(v2);
15154 break;
15155 case 11:
15156 v1->flt_24 = atof(v2);
15157 break;
15158 case 13:
15159 v1->field_1C = atoi(v2);
15160 break;
15161 case 16:
15162 v1->uOpenTime = atoi(v2);
15163 break;
15164 case 17:
15165 v1->uCloseTime = atoi(v2);
15166 break;
15167 case 18:
15168 v1->uExitPicID = atoi(v2);
15169 break;
15170 case 19:
15171 v1->uExitMapID = atoi(v2);
15172 break;
15173 case 20:
15174 v1->_quest_related = atoi(v2);
15175 break;
15176 case 21:
15177 v1->pEnterText = RemoveQuotes(v2);
15178 break;
15179 default:
15180 break;
15181 }
15182 }
15183 v2 = (char *)(v6 + 1);
15184 v3 = v9 + 1;
15185 v9 = v3;
15186 result = v3 + 1;
15187 }
15188 while ( v3 + 1 <= 23 && !v10 );
15189 ++v1;
15190 //if ( (signed int)v1 >= (signed int)&unk_597F10 )
15191 if (++it >= 525)
15192 return result;
15193 v0 = "\r";
15194 }
15195 }
15196
15197 //----- (00443CE1) --------------------------------------------------------
15198 unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize)
15199 {
15200 const char *v3; // edi@1
15201 FILE *v4; // eax@1
15202 unsigned int v5; // esi@3
15203 char Args; // [sp+8h] [bp-B4h]@6
15204 //Texture DstBuf; // [sp+6Ch] [bp-50h]@1
15205 void *Dst; // [sp+B4h] [bp-8h]@1
15206 void *ptr; // [sp+B8h] [bp-4h]@1
15207
15208 v3 = pContainerName;
15209 Dst = a2;
15210 ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
15211
15212 Texture DstBuf; // [sp+6Ch] [bp-50h]@1
15213 //Texture::Texture(&DstBuf);
15214
15215 v4 = pEvents_LOD->FindContainer(v3, 0);
15216 if ( !v4 )
15217 Abortf("Unable to load %s", v3);
15218 fread(&DstBuf, 1u, 0x30u, v4);
15219 v5 = DstBuf.uDecompressedSize;
15220 if ( !DstBuf.uDecompressedSize )
15221 v5 = DstBuf.uTextureSize;
15222 memset(&DstBuf, 0, 0x48u);
15223 if ( (signed int)v5 >= (signed int)uBufferSize )
15224 {
15225 sprintf(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
15226 Abortf(&Args);
15227 }
15228 memcpy(Dst, ptr, v5);
15229 pAllocator->FreeChunk(ptr);
15230 return v5;
15231 }
15232
15233 //----- (00443DA1) --------------------------------------------------------
15234 void __cdecl Initialize_GlobalEVT()
15235 {
15236 signed int v0; // esi@1
15237 unsigned int v1; // ecx@2
15238 char *v2; // eax@2
15239
15240 v0 = 0;
15241 uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT, 0xB400u);
15242 if ( uGlobalEVT_Size )
15243 {
15244 uGlobalEVT_NumEvents = 0;
15245 memset(pGlobalEVT_Events, 128, 0xCE40u);
15246 v1 = uGlobalEVT_NumEvents;
15247 v2 = (char *)&pGlobalEVT_Events[uGlobalEVT_NumEvents].field_4;
15248 do
15249 {
15250 ++v1;
15251 *((int *)v2 - 1) = (unsigned __int8)pGlobalEVT[v0 + 1] + ((unsigned __int8)pGlobalEVT[v0 + 2] << 8);
15252 *(int *)v2 = (unsigned __int8)pGlobalEVT[v0 + 3];
15253 *((int *)v2 + 1) = v0;
15254 v2 += 12;
15255 v0 += (unsigned __int8)pGlobalEVT[v0] + 1;
15256 }
15257 while ( v0 < (signed int)uGlobalEVT_Size );
15258 uGlobalEVT_NumEvents = v1;
15259 }
15260 }
15261
15262 //----- (00443E31) --------------------------------------------------------
15263 void __cdecl LoadLevel_InitializeLevelStr()
15264 {
15265 signed __int16 v0; // si@1
15266 //unsigned int v1; // ecx@1
15267 signed int v2; // edi@1
15268 int v3; // edx@1
15269 //int v4; // eax@2
15270 int v5; // ebx@4
15271 int v6; // ebx@11
15272 int v7; // eax@12
15273 unsigned int *v8; // edi@13
15274 char Args[100]; // [sp+Ch] [bp-68h]@9
15275 int v10; // [sp+70h] [bp-4h]@1
15276
15277 if (sizeof(pLevelStrOffsets) != 0x7D0)
15278 Log::Warning(L"pLevelStrOffsets: deserialization warning");
15279 memset(pLevelStrOffsets, 0, 0x7D0u);
15280
15281 v0 = 0;
15282 //v1 = uLevelStrFileSize;
15283 v2 = 1;
15284 v3 = 0;
15285 v10 = 0;
15286 //v4 = 0;
15287 for (uint i = 0; i < uLevelStrFileSize; ++i)
15288 {
15289 if ( !pLevelStr[i] )
15290 {
15291 v5 = (signed __int16)v2++;
15292 pLevelStrOffsets[v5] = i + 1;
15293 if ( (signed __int16)(i - (short)v10) > v0 )
15294 v0 = i - v10;
15295 v10 = i;
15296 }
15297 }
15298
15299 uLevelStrNumStrings = (signed __int16)v2 - 1;
15300 if ( v0 > 800 )
15301 {
15302 sprintf(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", v0 + 1);
15303 Abortf(Args);
15304 }
15305 v6 = 0;
15306 if ( (signed __int16)v2 - 1 > 0 )
15307 {
15308 v7 = 0;
15309 do
15310 {
15311 v8 = &pLevelStrOffsets[v7];
15312 if ( RemoveQuotes(&pLevelStr[*v8]) != &pLevelStr[*v8] )
15313 ++*v8;
15314 ++v6;
15315 v7 = (signed __int16)v6;
15316 }
15317 while ( (signed __int16)v6 < (signed int)uLevelStrNumStrings );
15318 }
15319 }
15320
15321 //----- (00443EF8) --------------------------------------------------------
15322 void __cdecl LoadLevel_InitializeLevelEvt()
15323 {
15324 if (!uLevelEVT_Size)
15325 return;
15326
15327 memset(array_5B5928, 0, 0xC80u);
15328 memset(pLevelEVT_Events, 128, 0xCE40u);
15329
15330 uLevelEVT_NumEvents = 0;
15331 dword_5B65C8 = 0;
15332
15333 for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i)
15334 {
15335 pLevelEVT_Events[i].uEventID = pLevelEVT[j + 1] + ((unsigned short)pLevelEVT[j + 2] << 8);
15336 pLevelEVT_Events[i].field_4 = pLevelEVT[j + 3];
15337 pLevelEVT_Events[i].uEventOffsetInEVT = j;
15338 j += pLevelEVT[j] + 1;
15339
15340 uLevelEVT_NumEvents++;
15341 }
15342 }
15343
15344 //----- (00443F95) --------------------------------------------------------
15345 void __cdecl OnMapLeave()
15346 {
15347 signed int v0; // edi@1
15348 char *v1; // esi@2
15349 int v2; // ecx@4
15350
15351 v0 = 0;
15352 if ( (signed int)uLevelEVT_NumEvents > 0 )
15353 {
15354 v1 = (char *)&pLevelEVT_Events[0].field_4;
15355 do
15356 {
15357 if ( pLevelEVT[*((short *)v1 + 2) + 4] == 53 )
15358 {
15359 v2 = *((int *)v1 - 1);
15360 dword_597F18 = *(int *)v1;
15361 EventProcessor(v2, 0, 1);
15362 dword_597F18 = 0;
15363 }
15364 ++v0;
15365 v1 += 12;
15366 }
15367 while ( v0 < (signed int)uLevelEVT_NumEvents );
15368 }
15369 }
15370
15371
15372 //----- (00443FDC) --------------------------------------------------------
15373 void OnMapLoad()
15374 {
15375 stru176 *v3; // esi@7
15376 __int16 v4; // cx@9
15377 __int16 v5; // di@9
15378 int v6; // eax@9
15379 signed __int64 v8; // qax@26
15380 unsigned int v9; // ecx@26
15381 signed __int64 v10; // qax@26
15382 signed __int64 v11; // qax@26
15383 int v12; // ST50_4@26
15384 signed __int64 v13; // qax@26
15385 signed __int64 v14; // qax@26
15386 int v15; // ST58_4@26
15387 signed __int64 v16; // qax@26
15388 int v17; // ebx@26
15389 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
15390 signed __int64 v19; // [sp+14h] [bp-3Ch]@26
15391 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
15392 int v22; // [sp+2Ch] [bp-24h]@26
15393 int v24; // [sp+34h] [bp-1Ch]@26
15394 int v25; // [sp+38h] [bp-18h]@26
15395 int v26; // [sp+3Ch] [bp-14h]@15
15396 int v27; // [sp+3Ch] [bp-14h]@26
15397 int v28; // [sp+40h] [bp-10h]@26
15398 __int16 v29; // [sp+46h] [bp-Ah]@9
15399 __int16 v30; // [sp+48h] [bp-8h]@9
15400 __int16 v31; // [sp+4Ah] [bp-6h]@9
15401 __int16 v32; // [sp+4Ch] [bp-4h]@9
15402 __int16 v33; // [sp+4Eh] [bp-2h]@9
15403
15404 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
15405 {
15406 auto pEvent = pLevelEVT_Events + i;
15407
15408 auto _evt = (_evt_raw *)(pLevelEVT + pEvent->uEventOffsetInEVT);
15409
15410 if (_evt->v4 == 3)
15411 {
15412 pSoundList->LoadSound(
15413 _evt->v5 +
15414 ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8),
15415 0);
15416 }
15417 else if (_evt->v4 == 37)
15418 {
15419 dword_597F18 = pEvent->field_4;
15420 EventProcessor(pEvent->uEventID, 0, 0);
15421 dword_597F18 = 0;
15422 }
15423 else if (_evt->v4 == 31 || _evt->v4 == 38)
15424 {
15425 v3 = &array_5B5928[dword_5B65C8];
15426 v20 = pOutdoor->uLastVisitDay;
15427 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
15428 v20 = pIndoor->stru1.uLastVisitDay;
15429
15430 v4 = _evt->v4;
15431 v3->field_1C = v4;
15432 v3->field_8 = pEvent->uEventID;
15433 v3->field_A = pEvent->field_4;
15434 v33 = _evt->v6;
15435 v3->field_12 = v33;
15436 v32 = _evt->v7;
15437 v3->field_14 = v32;
15438 v31 = _evt->v8;
15439 v3->field_16 = v31;
15440 v5 = _evt->v5;
15441 v30 = _evt->v9;
15442 v3->field_18 = v30;
15443 v29 = _evt->v10;
15444 v3->field_1A = v29;
15445
15446 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
15447 v3->field_10 = v5;
15448 v3->field_C = v6;
15449 v3->field_E = v6;
15450 if ( v4 == 38 && !(short)v6 )
15451 {
15452 if ( v20 )
15453 v18 = pParty->uTimePlayed - v20;
15454 else
15455 v18 = 0i64;
15456 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
15457
15458 if ( v26 / 7 / 4 / 12 )
15459 {
15460 if ( v5 )
15461 {
15462 v3->field_4 = 0;
15463 ++dword_5B65C8;
15464 v3->field_0 = 0;
15465 continue;
15466 }
15467 }
15468 if (v26 / 7 / 4 != 0 && v33 != 0 ||
15469 v26 / 7 != 0 && v32 != 0 ||
15470 v26 != 0 || !v20)
15471 {
15472 v3->field_4 = 0;
15473 ++dword_5B65C8;
15474 v3->field_0 = 0;
15475 continue;
15476 }
15477 }
15478
15479 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
15480 v9 = v8;
15481 v10 = (signed int)v8 / 60;
15482 v22 = v10 % 60;
15483 v11 = (signed int)(v10 / 60);
15484 v12 = v11 % 24;
15485 v13 = (signed int)(v11 / 24);
15486 v27 = v13 % 7;
15487 v14 = (signed int)(v13 / 7);
15488 v15 = v14 % 4;
15489 v16 = (signed int)(v14 / 4);
15490 v24 = v16 / 12;
15491
15492 auto _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
15493 auto _2 = ((__int64)v9 << 32) | _1;
15494
15495 v19 = _2 % 60;
15496 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
15497 // v9)
15498 // % 60;
15499
15500 v17 = v12;
15501 v25 = v15;
15502 v28 = v16 % 12;
15503 if ( v5 )
15504 {
15505 ++v24;
15506 }
15507 else
15508 {
15509 if ( v33 )
15510 {
15511 ++v28;
15512 }
15513 else
15514 {
15515 if ( v32 )
15516 {
15517 ++v25;
15518 }
15519 else
15520 {
15521 ++v27;
15522 v22 = v30;
15523 v17 = v31;
15524 v19 = v29;
15525 }
15526 }
15527 }
15528 auto v0 = (signed __int64)((double)((v19
15529 + 0x3C * v22
15530 + 0xE10 * v17
15531 + 0x93A80 * v25
15532 + 0x15180 * v27
15533 + 0x24EA00 * (v28 + 12i64 * v24)) << 7)
15534 * 0.033333335);
15535 v3->field_4 = HIDWORD(v0);
15536
15537 ++dword_5B65C8;
15538 v3->field_0 = v0;
15539 }
15540 }
15541 }
15542
15543 //----- (00444360) --------------------------------------------------------
15544 void __thiscall Level_LoadEvtAndStr(const char *pLevelName)
15545 {
15546 char pContainerName[120]; // [sp+8h] [bp-98h]@1
15547
15548 sprintf(pContainerName, "%s.evt", pLevelName);
15549 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT, 0x2400u);
15550
15551 sprintf(pContainerName, "%s.str", pLevelName);
15552 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr, 0x2400u);
15553 if (uLevelStrFileSize)
15554 LoadLevel_InitializeLevelStr();
15555 }
15556
15557 //----- (004443D5) --------------------------------------------------------
15558 char *__cdecl _4443D5_GetMinimapRightClickText()
15559 {
15560 int v0; // ST20_4@1
15561 unsigned int v1; // esi@1
15562 signed int v2; // ebx@1
15563 double v3; // st7@1
15564 int v4; // esi@3
15565 int v5; // edi@4
15566 int v6; // eax@4
15567 int v7; // eax@4
15568 BSPModel *v8; // ecx@4
15569 unsigned __int8 v9; // zf@5
15570 char v10; // sf@5
15571 unsigned __int8 v11; // of@5
15572 ODMFace *v12; // eax@6
15573 __int16 v13; // cx@6
15574 const char *v14; // eax@8
15575 const char *v15; // edi@8
15576 char *result; // eax@12
15577 unsigned int v17; // eax@14
15578 unsigned int v18; // [sp+Ch] [bp-20h]@1
15579 int v19; // [sp+10h] [bp-1Ch]@1
15580 int v20; // [sp+14h] [bp-18h]@1
15581 char *v21; // [sp+18h] [bp-14h]@1
15582 unsigned int pY; // [sp+1Ch] [bp-10h]@1
15583 int v23; // [sp+20h] [bp-Ch]@1
15584 int v24; // [sp+24h] [bp-8h]@1
15585 int pX; // [sp+28h] [bp-4h]@1
15586
15587 v24 = pParty->vPosition.x;
15588 v0 = pParty->vPosition.y;
15589 v1 = pOutdoor->uNumBModels;
15590 *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789;
15591 v2 = 0;
15592 v18 = pOutdoor->uNumBModels;
15593 v21 = 0;
15594 pMouse->GetClickPos((unsigned int *)&pX, &pY);
15595 v3 = 1.0 / *(float *)&v23;
15596 v23 = pX - 557;
15597 v19 = (signed __int64)((double)(pX - 557) * v3 + (double)v24);
15598 v20 = (signed __int64)((double)v0 - (double)(signed int)(pY - 74) * v3);
15599 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || (*(float *)&v23 = 0.0, (signed int)v1 <= 0) )
15600 {
15601 LABEL_14:
15602 v17 = pMapStats->GetMapInfo(pCurrentMapName);
15603 if ( v17 == v2 )
15604 result = "No Maze Info for this maze on file!";
15605 else
15606 result = pMapStats->pInfos[v17].pName;
15607 }
15608 else
15609 {
15610 v4 = 0;
15611 while ( 1 )
15612 {
15613 pX = pOutdoor->pBModels[v4].vBoundingCenter.x - v19;
15614 pY = pOutdoor->pBModels[v4].vBoundingCenter.y - v20;
15615 v5 = abs((signed)pY);
15616 v6 = abs((signed)pX);
15617 v7 = sub_4621DA(v6, v5, v2);
15618 v8 = pOutdoor->pBModels;
15619 if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius )
15620 {
15621 v11 = __OFSUB__(pOutdoor->pBModels[v4].uNumFaces, v2);
15622 v9 = pOutdoor->pBModels[v4].uNumFaces == v2;
15623 v10 = ((pOutdoor->pBModels[v4].uNumFaces - v2) & 0x80000000u) != 0;
15624 v24 = v2;
15625 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
15626 {
15627 do
15628 {
15629 v12 = &v8[v4].pFaces[v2 / 0x134u];
15630 v13 = v12->sCogTriggeredID;
15631 if ( v13 )
15632 {
15633 if ( !(BYTE2(v12->uAttributes) & 0x10) )
15634 {
15635 v14 = _444732_GetEventHintString(v13);
15636 v15 = v14;
15637 if ( v14 )
15638 {
15639 if ( _strcmpi(v14, "") )
15640 v21 = (char *)v15;
15641 }
15642 }
15643 }
15644 ++v24;
15645 v8 = pOutdoor->pBModels;
15646 v2 += 308;
15647 }
15648 while ( v24 < (signed int)pOutdoor->pBModels[v4].uNumFaces );
15649 }
15650 result = v21;
15651 v2 = 0;
15652 if ( v21 )
15653 break;
15654 }
15655 ++v23;
15656 ++v4;
15657 if ( v23 >= (signed int)v18 )
15658 goto LABEL_14;
15659 }
15660 }
15661 return result;
15662 }
15663
15664 //----- (00444564) --------------------------------------------------------
15665 const char *__cdecl sub_444564()
15666 {
15667 double v0; // st7@3
15668 int v1; // ebx@3
15669 int v2; // edi@3
15670 int v3; // eax@3
15671 int v4; // esi@5
15672 int v5; // edi@6
15673 int v6; // eax@6
15674 int v7; // eax@6
15675 BSPModel *v8; // ecx@6
15676 unsigned __int8 v9; // zf@7
15677 unsigned __int8 v10; // sf@7
15678 ODMFace *v11; // eax@9
15679 __int16 v12; // cx@9
15680 const char *v13; // eax@11
15681 const char *v14; // edi@11
15682 const char *result; // eax@15
15683 unsigned int v16; // [sp+0h] [bp-20h]@3
15684 const char *v17; // [sp+4h] [bp-1Ch]@3
15685 unsigned int pY; // [sp+8h] [bp-18h]@3
15686 float v19; // [sp+Ch] [bp-14h]@1
15687 int v20; // [sp+10h] [bp-10h]@1
15688 int v21; // [sp+14h] [bp-Ch]@1
15689 unsigned int v22; // [sp+18h] [bp-8h]@8
15690 int pX; // [sp+1Ch] [bp-4h]@3
15691
15692 v20 = viewparams->sPartyPosX;
15693 v21 = viewparams->sPartyPosZ;
15694 v19 = (double)viewparams->field_2C * 0.000015258789;
15695 if ( viewparams->field_2C == 384 )
15696 {
15697 v20 = viewparams->field_38;
15698 v21 = viewparams->field_3A;
15699 }
15700 v17 = 0;
15701 v16 = pOutdoor->uNumBModels;
15702 pMouse->GetClickPos((unsigned int *)&pX, &pY);
15703 v0 = 1.0 / v19;
15704 v1 = (signed __int64)((double)(pX - 229) * v0 + (double)v20);
15705 LODWORD(v19) = (signed __int64)((double)v21 - (double)(signed int)(pY - 181) * v0);
15706 v2 = abs(v1 + 22528) / 512;
15707 v3 = abs((signed)LODWORD(v19) - 22528);
15708 if ( pOutdoor->_47F04C(v2, v3 / 512)
15709 && uCurrentlyLoadedLevelType == LEVEL_Outdoor
15710 && (v4 = 0, v20 = 0, (signed int)v16 > 0) )
15711 {
15712 while ( 1 )
15713 {
15714 pX = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.x + v4) - v1;
15715 pY = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.y + v4) - LODWORD(v19);
15716 v5 = abs((signed)pY);
15717 v6 = abs((signed)pX);
15718 v7 = sub_4621DA(v6, v5, 0);
15719 v8 = pOutdoor->pBModels;
15720 if ( v7 < *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v4) )
15721 {
15722 v9 = *(unsigned int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) == 0;
15723 v10 = *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) < 0;
15724 v21 = 0;
15725 if ( !(v10 | v9) )
15726 {
15727 v22 = 0;
15728 do
15729 {
15730 v11 = &(*(ODMFace **)((char *)&v8->pFaces + v4))[v22 / 0x134];
15731 v12 = v11->sCogTriggeredID;
15732 if ( v12 )
15733 {
15734 if ( !(BYTE2(v11->uAttributes) & 0x10) )
15735 {
15736 v13 = _444732_GetEventHintString(v12);
15737 v14 = v13;
15738 if ( v13 )
15739 {
15740 if ( _strcmpi(v13, "") )
15741 v17 = v14;
15742 }
15743 }
15744 }
15745 ++v21;
15746 v8 = pOutdoor->pBModels;
15747 v22 += 308;
15748 }
15749 while ( v21 < *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) );
15750 }
15751 result = v17;
15752 if ( v17 )
15753 break;
15754 }
15755 ++v20;
15756 v4 += 188;
15757 if ( v20 >= (signed int)v16 )
15758 goto LABEL_17;
15759 }
15760 }
15761 else
15762 {
15763 LABEL_17:
15764 result = 0;
15765 }
15766 return result;
15767 }
15768
15769
15770
15771
15772 //----- (00444A51) --------------------------------------------------------
15773 char *__cdecl TransitionUI_Draw()
15774 {
15775 MapInfo *v0; // esi@5
15776 char *v1; // eax@6
15777 char *result; // eax@12
15778 std::string v3; // [sp-18h] [bp-84h]@11
15779 unsigned int v4; // [sp-10h] [bp-7Ch]@12
15780 int v5; // [sp-Ch] [bp-78h]@12
15781 const char *v6; // [sp-8h] [bp-74h]@11
15782 signed int v7; // [sp-4h] [bp-70h]@11
15783 GUIWindow v8; // [sp+Ch] [bp-60h]@1
15784 unsigned int v9; // [sp+60h] [bp-Ch]@1
15785 unsigned int v10; // [sp+64h] [bp-8h]@1
15786 int a3; // [sp+6Bh] [bp-1h]@11
15787
15788 memcpy(&v8, pPrimaryWindow, sizeof(v8));
15789 v10 = pMapStats->GetMapInfo(pCurrentMapName);
15790 v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
15791 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
15792 pRenderer->DrawTextureIndexed(
15793 _4E5E50_transui_x - 4,
15794 _4E5EE0_transui_y - 4,
15795 (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
15796 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pTexture_outside);
15797 uTextureID_507B04 = uTextureID_right_panel;
15798 pRenderer->DrawTextureTransparent(
15799 0x1D4u,
15800 0,
15801 (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
15802 pRenderer->DrawTextureIndexed(
15803 0x22Cu,
15804 0x1C3u,
15805 (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
15806 pRenderer->DrawTextureIndexed(
15807 0x1DCu,
15808 0x1C3u,
15809 (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0));
15810 if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != 48 )
15811 v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name);
15812 v0 = &pMapStats->pInfos[v10];
15813 v8.uFrameX = 493;
15814 v8.uFrameWidth = 126;
15815 v8.uFrameZ = 366;
15816 v8.DrawTitleText(pFontCreate, 0, 5u, 0, v0->pName, 3u);
15817 v8.uFrameX = 483;
15818 v8.uFrameWidth = 148;
15819 v8.uFrameZ = 334;
15820 if ( uCurrentHouse_Animation )
15821 {
15822 v1 = (&off_4EB080)[4 * uCurrentHouse_Animation];
15823 }
15824 else
15825 {
15826 if ( v10 )
15827 {
15828 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], v0->pName);// "Do you wish to leave %s?"
15829 v1 = pTmpBuf;
15830 goto LABEL_12;
15831 }
15832 v1 = "";
15833 }
15834 if ( !v1 )
15835 {
15836 MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0);
15837 v1 = "";
15838 }
15839 LABEL_12:
15840 v7 = 3;
15841 v6 = v1;
15842 v5 = 0;
15843 v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101;
15844 result = v8.DrawTitleText(pFontCreate, 0, v4, v5, v6, v7);
15845 dword_5B5924 = 1;
15846 return result;
15847 }
15848
15849
15850 //----- (00444C8F) --------------------------------------------------------
15851 GUIWindow *__cdecl UI_CreateTravelDialogue()
15852 {
15853 signed int v0; // eax@1
15854 unsigned int v1; // eax@6
15855 GUIWindow *result; // eax@9
15856 const char *v3; // [sp-4h] [bp-2Ch]@2
15857 char pContainer[32]; // [sp+0h] [bp-28h]@1
15858
15859 pEventTimer->Pause();
15860 v0 = const_2();
15861 sprintf(pContainer, "evt%02d", v0);
15862 if ( pParty->uAlignment )
15863 {
15864 if ( pParty->uAlignment != 2 )
15865 goto LABEL_6;
15866 v3 = "-c";
15867 }
15868 else
15869 {
15870 v3 = "-b";
15871 }
15872 strcat(pContainer, v3);
15873 LABEL_6:
15874 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
15875 pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
15876 v1 = pMapStats->GetMapInfo(pCurrentMapName);
15877 if ( v1 )
15878 sprintf(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
15879 else
15880 strcpy(byte_591098, pGlobalTXT_LocalizationStrings[79]);// "Exit"
15881 result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)byte_591098);
15882 pDialogueWindow = result;
15883 return result;
15884 }
15885
15886 //----- (00444D80) --------------------------------------------------------
15887 signed int __cdecl GetTravelTime()
15888 {
15889 signed int v0; // esi@1
15890
15891 v0 = uDefaultTravelTime_ByFoot;
15892 if ( CheckHiredNPCSpeciality(5u) )
15893 --v0;
15894 if ( CheckHiredNPCSpeciality(6u) )
15895 v0 -= 2;
15896 if ( CheckHiredNPCSpeciality(7u) )
15897 v0 -= 3;
15898 if ( CheckHiredNPCSpeciality(0x2Cu) )
15899 --v0;
15900 if ( v0 < 1 )
15901 v0 = 1;
15902 return v0;
15903 }
15904 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
15905
15906 //----- (00444DCA) --------------------------------------------------------
15907 void __cdecl TravelUI_Draw()
15908 {
15909 unsigned int v0; // edi@1
15910 MapInfo *v1; // edi@2
15911 char *v2; // ST14_4@2
15912 signed int v3; // eax@2
15913 int v4; // eax@5
15914 const char *v5; // [sp-Ch] [bp-90h]@3
15915 signed int v6; // [sp-8h] [bp-8Ch]@3
15916 GUIWindow v7; // [sp+Ch] [bp-78h]@1
15917 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1
15918 unsigned int v9; // [sp+80h] [bp-4h]@1
15919
15920 memcpy(&v7, pPrimaryWindow, sizeof(v7));
15921 v9 = pMapStats->GetMapInfo(pCurrentMapName);
15922 pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
15923 v0 = pMapStats->GetMapInfo(pDestinationMapName);
15924 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
15925 pRenderer->DrawTextureTransparent(0x1D4u, 0,
15926 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
15927 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pTexture_outside);
15928 pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u,
15929 (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
15930 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u,
15931 (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0));
15932 if ( v0 )
15933 {
15934 v1 = &pMapStats->pInfos[v0];
15935 v7.uFrameX = 493;
15936 v7.uFrameWidth = 126;
15937 v2 = v1->pName;
15938 v7.uFrameZ = 366;
15939 v7.DrawTitleText(pFontCreate, 0, 4u, 0, v2, 3u);
15940 v7.uFrameX = 483;
15941 v7.uFrameWidth = 148;
15942 v7.uFrameZ = 334;
15943 v3 = GetTravelTime();
15944 if ( v3 == 1 )
15945 {
15946 v6 = 1;
15947 v5 = pGlobalTXT_LocalizationStrings[663]; // "It will take %d day to cross to %s."
15948 }
15949 else
15950 {
15951 v6 = v3;
15952 v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s."
15953 }
15954 sprintf(pTmpBuf, v5, v6, v1->pName);
15955 strcat(pTmpBuf, "\n \n");
15956 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName);
15957 strcat(pTmpBuf, pTmpBuf2);
15958 v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0);
15959 v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u);
15960 dword_5B5924 = 1;
15961 }
15962 }
15963
15964
15965 //----- (00444FBE) --------------------------------------------------------
15966 void __cdecl DrawBranchlessDialogueUI()
15967 {
15968 GUIFont *v0; // esi@1
15969 int v1; // esi@4
15970 char *v2; // eax@6
15971 int v3; // edi@12
15972 char Str[200]; // [sp+Ch] [bp-120h]@12
15973 GUIWindow v5; // [sp+D4h] [bp-58h]@4
15974 GUIFont *pFont; // [sp+128h] [bp-4h]@1
15975
15976 v0 = pFontArrus;
15977 pFont = pFontArrus;
15978 if ( ptr_F8B1E8 && !byte_5B0938[0] )
15979 strcpy(byte_5B0938, ptr_F8B1E8);
15980 v5.uFrameWidth = 460;
15981 v5.uFrameZ = 452;
15982 v1 = pFontArrus->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7;
15983 if ( 352 - v1 < 8 )
15984 {
15985 pFont = pFontCreate;
15986 v1 = pFontCreate->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7;
15987 }
15988 pRenderer->_4A6A68(
15989 8u,
15990 352 - v1,
15991 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
15992 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v1);
15993 pRenderer->DrawTextureIndexed(8u, 347 - v1, pTexture_591428);
15994 v2 = FitTextInAWindow(byte_5B0938, pFont, &v5, 0xCu, 0);
15995 pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0);
15996 pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
15997 if ( pGUIWindow2->field_40 != 1 )
15998 {
15999 if ( pGUIWindow2->field_40 == 2 )
16000 {
16001 pGUIWindow2->field_40 = 0;
16002 strcpy(GameUI_StatusBar_TimedString, (const char *)pKeyActionMap->pPressedKeysBuffer);
16003 LABEL_16:
16004 sub_4452BB();
16005 return;
16006 }
16007 if ( pGUIWindow2->field_40 != 3 )
16008 return;
16009 pGUIWindow2->field_40 = 0;
16010 LABEL_15:
16011 memset(GameUI_StatusBar_TimedString, 0, 0xC8u);
16012 goto LABEL_16;
16013 }
16014 if ( pGUIWindow2->ptr_1C == (void *)26 )
16015 {
16016 sprintf(Str, "%s %s", GameUI_StatusBar_TimedString, pKeyActionMap->pPressedKeysBuffer);
16017 v3 = pFontLucida->GetLineWidth(Str);
16018 pGUIWindow2->DrawText(pFontLucida, 13, 357, 0, Str, 0, 0, 0);
16019 pGUIWindow2->DrawFlashingInputCursor(v3 + 13, 357, pFontLucida);
16020 return;
16021 }
16022 if ( pKeyActionMap->pPressedKeysBuffer[0] )
16023 {
16024 pKeyActionMap->_459ED1(0);
16025 goto LABEL_15;
16026 }
16027 }
16028
16029 //----- (004451A8) --------------------------------------------------------
16030 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
16031 {
16032 int v3; // esi@1
16033 int v4; // edi@1
16034
16035 v3 = a2;
16036 v4 = a1;
16037 if ( !pGUIWindow2 )
16038 {
16039 if ( pParty->uFlags & 2 )
16040 pGame->Draw();
16041 if ( !dword_597F18 )
16042 pAudioPlayer->StopChannels(-1, -1);
16043 pMiscTimer->Pause();
16044 pEventTimer->Pause();
16045 dword_5C3418 = v4;
16046 dword_5C341C = v3;
16047 _591094_decoration = _5C3420_pDecoration;
16048 pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0);
16049 pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
16050 pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
16051 pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
16052 pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
16053 }
16054 }
16055
16056 //----- (004452BB) --------------------------------------------------------
16057 void __cdecl sub_4452BB()
16058 {
16059 pGUIWindow2->Release();
16060 pGUIWindow2 = 0;
16061 _5C3420_pDecoration = _591094_decoration;
16062 dword_597F18 = dword_5C341C;
16063 EventProcessor(dword_5C3418, 0, 1);
16064 dword_597F18 = 0;
16065 _5C3420_pDecoration = 0;
16066 pEventTimer->Resume();
16067 }
16068
16069
16070 //----- (00445308) --------------------------------------------------------
16071 const char *__fastcall sub_445308(int a1)
16072 {
16073 if ( a1 == 10
16074 || a1 == 11
16075 || a1 == 12
16076 || a1 == 33
16077 || a1 == 34
16078 || a1 == 39
16079 || a1 == 40
16080 || a1 == 41
16081 || a1 == 42
16082 || a1 == 43
16083 || a1 == 52 )
16084 return (const char *)*(&pNPCStats->field_13A60 + 5 * a1);
16085 else
16086 return pNPCTopics[407].pTopic;
16087 }
16088
16089
16090 //----- (00445350) --------------------------------------------------------
16091 void __cdecl DrawDialogueUI()
16092 {
16093 NPCData *v0; // ebx@2
16094 int v1; // eax@2
16095 unsigned __int16 v2; // di@2
16096 unsigned int v3; // eax@2
16097 char *v4; // esi@3
16098 int v5; // eax@11
16099 char *v6; // ecx@13
16100 char *v7; // eax@16
16101 unsigned int v8; // edi@19
16102 char *v9; // ecx@27
16103 char *v10; // eax@29
16104 int v11; // eax@30
16105 int v12; // esi@39
16106 char *v13; // eax@41
16107 GUIButton *v14; // eax@43
16108 GUIButton *v15; // edi@43
16109 signed int v16; // eax@44
16110 int v17; // eax@46
16111 int v18; // eax@47
16112 int v19; // eax@48
16113 int v20; // eax@49
16114 int v21; // eax@50
16115 int v22; // eax@51
16116 unsigned int v23; // eax@53
16117 const char *v24; // eax@59
16118 int v25; // eax@65
16119 int v26; // eax@66
16120 int v27; // eax@67
16121 int v28; // eax@68
16122 int v29; // eax@69
16123 unsigned __int16 v30; // cx@83
16124 int v31; // ecx@86
16125 int v32; // ebx@93
16126 unsigned int v33; // eax@93
16127 GUIWindow *v34; // ecx@93
16128 int v35; // esi@93
16129 int i; // eax@93
16130 GUIButton *v37; // eax@94
16131 int v38; // eax@95
16132 signed int v39; // esi@99
16133 signed int v40; // eax@102
16134 unsigned int v41; // ebx@102
16135 int v42; // edi@102
16136 GUIButton *v43; // esi@103
16137 int v44; // eax@104
16138 unsigned int v45; // ecx@104
16139 unsigned __int16 *v46; // edx@104
16140 unsigned __int16 v47; // ax@104
16141 char pFont; // [sp+4h] [bp-110h]@39
16142 int v49; // [sp+Ch] [bp-108h]@39
16143 int v50; // [sp+14h] [bp-100h]@39
16144 GUIWindow v51; // [sp+58h] [bp-BCh]@2
16145 GUIWindow v52; // [sp+ACh] [bp-68h]@42
16146 char *Str; // [sp+100h] [bp-14h]@104
16147 __int16 v54[2]; // [sp+104h] [bp-10h]@2
16148 unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82
16149 GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39
16150 char *pInString; // [sp+110h] [bp-4h]@32
16151
16152 if ( !pDialogueWindow )
16153 return;
16154 memcpy(&v51, pDialogueWindow, sizeof(v51));
16155 v0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
16156 v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID);
16157 v51.uFrameWidth -= 10;
16158 v51.uFrameZ -= 10;
16159 *(int *)v54 = v1;
16160 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16161 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
16162 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
16163 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
16164 pRenderer->DrawTextureTransparent(
16165 0x1D4u,
16166 0,
16167 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
16168 pRenderer->DrawTextureIndexed(
16169 _4E5E50_transui_x - 4,
16170 _4E5EE0_transui_y - 4,
16171 (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
16172 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pDialogueNPCPortraits[0]);
16173 v3 = v0->uProfession;
16174 if ( v3 )
16175 {
16176 v4 = pTmpBuf;
16177 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v0->pName, aNPCProfessionNames[v3]);
16178 }
16179 else
16180 {
16181 strcpy(pTmpBuf, v0->pName);
16182 v4 = pTmpBuf;
16183 }
16184 v51.DrawTitleText(pFontArrus, 0x1E3u, 0x70u, v2, v4, 3u);
16185 pParty->GetPartyFame();
16186 if ( (signed int)uDialogueType > 89 )
16187 {
16188 if ( uDialogueType == 90 )
16189 {
16190 v7 = pGlobalTXT_LocalizationStrings[577]; // "Get back in there you wimps:"
16191 goto LABEL_37;
16192 }
16193 if ( uDialogueType == 91 )
16194 {
16195 sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
16196 pInString = v4;
16197 v8 = 0;
16198 goto LABEL_39;
16199 }
16200 if ( uDialogueType == 92 )
16201 {
16202 v7 = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
16203 goto LABEL_37;
16204 }
16205 }
16206 else
16207 {
16208 if ( uDialogueType == 89 )
16209 {
16210 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:"
16211 goto LABEL_37;
16212 }
16213 if ( uDialogueType == 13 )
16214 {
16215 v5 = 5 * v0->uProfession;
16216 goto LABEL_18;
16217 }
16218 if ( (signed int)uDialogueType > 18 )
16219 {
16220 if ( (signed int)uDialogueType > 24 )
16221 {
16222 if ( uDialogueType == 77 )
16223 {
16224 v5 = 5 * v0->uProfession;
16225 if ( byte_F8B1EC )
16226 {
16227 v6 = (char *)*(&pNPCStats->field_13A5C + 5 * v0->uProfession);
16228 goto LABEL_19;
16229 }
16230 if ( v0->uFlags & 0x80 )
16231 {
16232 v6 = (char *)*(&pNPCStats->field_13A68 + 5 * v0->uProfession);
16233 LABEL_19:
16234 v8 = 0;
16235 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
16236 LABEL_38:
16237 pInString = v7;
16238 goto LABEL_39;
16239 }
16240 LABEL_18:
16241 v6 = (char *)*(&pNPCStats->field_13A64 + v5);
16242 goto LABEL_19;
16243 }
16244 goto LABEL_24;
16245 }
16246 if ( byte_5B0938[0] )
16247 goto LABEL_24;
16248 v7 = (char *)ptr_F8B1E8;
16249 LABEL_37:
16250 v8 = 0;
16251 goto LABEL_38;
16252 }
16253 }
16254 LABEL_24:
16255 if ( *(int *)v54 == 1 )
16256 {
16257 v11 = v0->greet;
16258 v8 = 0;
16259 if ( v11 )
16260 {
16261 v10 = (char *)*(&pNPCStats->field_17884 + ((v0->uFlags & 3) == 2) + 2 * v11);
16262 goto LABEL_32;
16263 }
16264 }
16265 else
16266 {
16267 if ( *(int *)v54 == 2 )
16268 {
16269 v8 = 0;
16270 if ( v0->uFlags & 0x80 )
16271 v9 = (char *)*(&pNPCStats->field_13A68 + 5 * v0->uProfession);
16272 else
16273 v9 = (char *)*(&pNPCStats->field_13A64 + 5 * v0->uProfession);
16274 v10 = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
16275 LABEL_32:
16276 pInString = v10;
16277 if ( v10 == (char *)v8 )
16278 goto LABEL_42;
16279 LABEL_39:
16280 v49 = 460;
16281 v50 = 452;
16282 pOutString = pFontArrus;
16283 v12 = pFontArrus->CalcTextHeight(pInString, (GUIWindow *)&pFont, 13, v8) + 7;
16284 if ( 352 - v12 < 8 )
16285 {
16286 pOutString = pFontCreate;
16287 v12 = pFontCreate->CalcTextHeight(pInString, (GUIWindow *)&pFont, 13, v8) + 7;
16288 }
16289 pRenderer->_4A6A68(
16290 8u,
16291 352 - v12,
16292 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
16293 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
16294 pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
16295 v13 = FitTextInAWindow(pInString, pOutString, (GUIWindow *)&pFont, 0xDu, v8);
16296 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
16297 goto LABEL_42;
16298 }
16299 }
16300 LABEL_42:
16301 memcpy(&v52, pDialogueWindow, sizeof(v52));
16302 v52.uFrameX = 483;
16303 v52.uFrameWidth = 148;
16304 v52.uFrameZ = 334;
16305 for ( pOutString = (GUIFont *)v52.pStartingPosActiveItem;
16306 (signed int)pOutString < v52.pStartingPosActiveItem + v52.pNumPresenceButton;
16307 pOutString = (GUIFont *)((char *)pOutString + 1) )
16308 {
16309 v14 = v52.GetControl((unsigned int)pOutString);
16310 v15 = v14;
16311 if ( !v14 )
16312 break;
16313 v16 = v14->uControlParam;
16314 if ( v16 > 24 )
16315 {
16316 v25 = v16 - 76;
16317 if ( v25 )
16318 {
16319 v26 = v25 - 1;
16320 if ( v26 )
16321 {
16322 v27 = v26 - 8;
16323 if ( v27 )
16324 {
16325 v28 = v27 - 1;
16326 if ( v28 )
16327 {
16328 v29 = v28 - 1;
16329 if ( v29 )
16330 {
16331 if ( v29 != 1 )
16332 goto LABEL_71;
16333 v24 = pGlobalTXT_LocalizationStrings[581];
16334 }
16335 else
16336 {
16337 v24 = pGlobalTXT_LocalizationStrings[580];
16338 }
16339 }
16340 else
16341 {
16342 v24 = pGlobalTXT_LocalizationStrings[579];
16343 }
16344 }
16345 else
16346 {
16347 v24 = pGlobalTXT_LocalizationStrings[578];
16348 }
16349 }
16350 else
16351 {
16352 v24 = pGlobalTXT_LocalizationStrings[407];
16353 }
16354 }
16355 else
16356 {
16357 if ( v0->uFlags & 0x80 )
16358 {
16359 LABEL_59:
16360 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v0->pName);
16361 v24 = pTmpBuf;
16362 goto LABEL_79;
16363 }
16364 v24 = pGlobalTXT_LocalizationStrings[406];
16365 }
16366 }
16367 else
16368 {
16369 if ( v16 == 24 )
16370 {
16371 v23 = v0->evtf;
16372 LABEL_63:
16373 v24 = (&dword_721660)[8 * v23];
16374 if ( !v24 )
16375 {
16376 v24 = "";
16377 v15->uControlParam = 0;
16378 }
16379 goto LABEL_79;
16380 }
16381 v17 = v16 - 9;
16382 if ( !v17 )
16383 {
16384 v24 = (const char *)sub_445308(v0->uProfession);
16385 goto LABEL_79;
16386 }
16387 v18 = v17 - 4;
16388 if ( v18 )
16389 {
16390 v19 = v18 - 6;
16391 if ( !v19 )
16392 {
16393 v23 = v0->bDrawSomeAnim;
16394 goto LABEL_63;
16395 }
16396 v20 = v19 - 1;
16397 if ( !v20 )
16398 {
16399 v23 = v0->evtb;
16400 goto LABEL_63;
16401 }
16402 v21 = v20 - 1;
16403 if ( !v21 )
16404 {
16405 v23 = v0->evtc;
16406 goto LABEL_63;
16407 }
16408 v22 = v21 - 1;
16409 if ( !v22 )
16410 {
16411 v23 = v0->evtd;
16412 goto LABEL_63;
16413 }
16414 if ( v22 == 1 )
16415 {
16416 v23 = v0->evte;
16417 goto LABEL_63;
16418 }
16419 LABEL_71:
16420 v24 = "";
16421 goto LABEL_79;
16422 }
16423 if ( v0->uFlags & 0x80 )
16424 goto LABEL_59;
16425 v24 = pGlobalTXT_LocalizationStrings[122];
16426 }
16427 LABEL_79:
16428 if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 )
16429 {
16430 pInString = 0;
16431 if ( (signed int)uNumActors > 0 )
16432 {
16433 v55 = (unsigned short *)&pActors[0].uAIState;
16434 *(int *)v54 = uNumActors;
16435 do
16436 {
16437 v30 = *v55;
16438 if ( *v55 == 5 || v30 == 11 || v30 == 19 || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == 4 )
16439 ++pInString;
16440 v55 += 418;
16441 --*(int *)v54;
16442 }
16443 while ( *(int *)v54 );
16444 }
16445 if ( pInString == (char *)uNumActors )
16446 v24 = pGlobalTXT_LocalizationStrings[658];
16447 }
16448 strcpy(v15->pButtonName, v24);
16449 }
16450 v32 = 0;
16451 pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16452 v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
16453 v34 = pDialogueWindow;
16454 *(int *)v54 = v33;
16455 v35 = pDialogueWindow->pStartingPosActiveItem;
16456 for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
16457 {
16458 v37 = v34->GetControl(v35);
16459 if ( !v37 )
16460 {
16461 v34 = pDialogueWindow;
16462 break;
16463 }
16464 v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0);
16465 v34 = pDialogueWindow;
16466 v32 += v38;
16467 ++v35;
16468 }
16469 v39 = v34->pNumPresenceButton;
16470 if ( v39 )
16471 {
16472 pOutString = (GUIFont *)((174 - v32) / v39);
16473 if ( (174 - v32) / v39 > 32 )
16474 pOutString = (GUIFont *)32;
16475 v55 = (unsigned __int16 *)1;
16476 v40 = 174 - (int)pOutString * v39 - v32;
16477 v41 = v34->pStartingPosActiveItem;
16478 v42 = v40 / 2 - (signed int)pOutString / 2 + 138;
16479 if ( (signed int)v41 < (signed int)(v41 + v39) )
16480 {
16481 do
16482 {
16483 v43 = v34->GetControl(v41);
16484 if ( !v43 )
16485 break;
16486 v43->uY = (unsigned int)((char *)pOutString + v42);
16487 Str = v43->pButtonName;
16488 v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0);
16489 v45 = v43->uY;
16490 v46 = v55;
16491 v43->uHeight = v44;
16492 v42 = v45 + v44 - 1;
16493 v43->uW = v42;
16494 v47 = v54[0];
16495 if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 )
16496 v47 = (unsigned __int16)pInString;
16497 v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u);
16498 v34 = pDialogueWindow;
16499 v55 = (unsigned __int16 *)((char *)v55 + 1);
16500 ++v41;
16501 }
16502 while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
16503 }
16504 }
16505 pRenderer->DrawTextureIndexed(
16506 0x1D7u,
16507 0x1BDu,
16508 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
16509 }
16510
16511 //----- (004459F9) --------------------------------------------------------
16512 NPCData *__fastcall GetNPCData(unsigned int npcid)
16513 {
16514 unsigned int v1; // esi@1
16515 NPCData *result; // eax@5
16516 int v3; // esi@9
16517 int v4; // ecx@9
16518 int v5; // edx@9
16519 NPCData *v6; // eax@9
16520 char *v7; // ebx@14
16521 NPCData *v8; // edi@14
16522 char v9; // al@22
16523 std::string v10; // [sp-18h] [bp-2Ch]@4
16524 const char *v11; // [sp-8h] [bp-1Ch]@4
16525 int v12; // [sp-4h] [bp-18h]@4
16526 std::string *v13; // [sp+Ch] [bp-8h]@4
16527 int a3; // [sp+13h] [bp-1h]@4
16528
16529 v1 = npcid;
16530 if ( (npcid & 0x80000000u) == 0 )
16531 {
16532 if ( (signed int)npcid < 5000 )
16533 {
16534 if ( (signed int)npcid >= 501 )
16535 {
16536 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0);
16537 }
16538 return &pNPCStats->pNewNPCData[v1];
16539 }
16540 return &pNPCStats->array_13EF4[npcid - 5000];
16541 }
16542 if ( (signed int)npcid >= 5000 )
16543 return &pNPCStats->array_13EF4[npcid - 5000];
16544 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
16545 {
16546 result = 0;
16547 }
16548 else
16549 {
16550 v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
16551 v4 = 0;
16552 v5 = 0;
16553 v6 = pParty->pHirelings;
16554 do
16555 {
16556 if ( v6->pName )
16557 pTmpBuf[v4++] = v5;
16558 ++v6;
16559 ++v5;
16560 }
16561 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
16562 v13 = 0;
16563 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
16564 {
16565 v7 = &pTmpBuf[v4];
16566 v8 = pNPCStats->pNewNPCData;
16567 do
16568 {
16569 if ( v8->uFlags & 0x80
16570 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName))
16571 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) )
16572 *v7++ = (char)v13 + 2;
16573 v13 = (std::string *)((char *)v13 + 1);
16574 ++v8;
16575 }
16576 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs );
16577 }
16578 v9 = pTmpBuf[v3];
16579 if ( (unsigned __int8)v9 >= 2u )
16580 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499];
16581 else
16582 result = &pParty->pHirelings[(unsigned __int8)v9];
16583 }
16584 return result;
16585 }
16586
16587 //----- (00445B2C) --------------------------------------------------------
16588 NPCData *__fastcall GetNewNPCData(signed int npcid, int a2)
16589 {
16590 signed int v2; // esi@1
16591 int v3; // edi@1
16592 NPCData *result; // eax@5
16593 int v5; // esi@9
16594 int v6; // ecx@9
16595 int v7; // edx@9
16596 NPCData *v8; // eax@9
16597 NPCData *v9; // edi@14
16598 int v10; // ecx@20
16599 char v11; // al@23
16600 std::string v12; // [sp-18h] [bp-34h]@4
16601 const char *v13; // [sp-8h] [bp-24h]@4
16602 int v14; // [sp-4h] [bp-20h]@4
16603 std::string *v15; // [sp+Ch] [bp-10h]@1
16604 char *v16; // [sp+10h] [bp-Ch]@14
16605 int v17; // [sp+14h] [bp-8h]@13
16606 int a3; // [sp+1Bh] [bp-1h]@4
16607
16608 v2 = npcid;
16609 v3 = a2;
16610 v15 = (std::string *)a2;
16611 if ( npcid >= 0 )
16612 {
16613 if ( npcid < 5000 )
16614 {
16615 if ( npcid >= 501 )
16616 {
16617 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0);
16618 }
16619 *(int *)v3 = v2;
16620 return &pNPCStats->pNewNPCData[v2];
16621 }
16622 LABEL_7:
16623 *(int *)a2 = npcid - 5000;
16624 return &pNPCStats->array_13EF4[npcid - 5000];
16625 }
16626 if ( npcid >= 5000 )
16627 goto LABEL_7;
16628 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
16629 {
16630 *(int *)a2 = 0;
16631 result = 0;
16632 }
16633 else
16634 {
16635 v5 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
16636 v6 = 0;
16637 v7 = 0;
16638 v8 = pParty->pHirelings;
16639 do
16640 {
16641 if ( v8->pName )
16642 pTmpBuf[v6++] = v7;
16643 ++v8;
16644 ++v7;
16645 }
16646 while ( (signed int)v8 < (signed int)&pParty->pPickedItem );
16647 v17 = 0;
16648 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
16649 {
16650 v9 = pNPCStats->pNewNPCData;
16651 v16 = &pTmpBuf[v6];
16652 do
16653 {
16654 if ( v9->uFlags & 0x80
16655 && (!pParty->pHirelings[0].pName || strcmp(v9->pName, pParty->pHirelings[0].pName))
16656 && (!pParty->pHirelings[1].pName || strcmp(v9->pName, pParty->pHirelings[1].pName)) )
16657 {
16658 v10 = (int)v16++;
16659 *(char *)v10 = v17 + 2;
16660 }
16661 ++v17;
16662 ++v9;
16663 }
16664 while ( v17 < (signed int)pNPCStats->uNumNewNPCs );
16665 v3 = (int)v15;
16666 }
16667 v11 = pTmpBuf[v5];
16668 if ( (unsigned __int8)v11 >= 2u )
16669 {
16670 *(int *)v3 = (unsigned __int8)v11 - 2;
16671 result = &pNPCStats->pNPCData[(unsigned __int8)pTmpBuf[v5] + 499];
16672 }
16673 else
16674 {
16675 *(int *)v3 = (unsigned __int8)v11;
16676 result = &pParty->pHirelings[(unsigned __int8)pTmpBuf[v5]];
16677 }
16678 }
16679 return result;
16680 }
16681
16682 //----- (00445C8B) --------------------------------------------------------
16683 int __fastcall sub_445C8B(signed int a1)
16684 {
16685 signed int v1; // ebx@1
16686 int v3; // edi@6
16687 int v4; // ecx@6
16688 int v5; // edx@6
16689 NPCData *v6; // eax@6
16690 char *v7; // ebp@11
16691 NPCData *v8; // esi@11
16692
16693 v1 = 0;
16694 if ( a1 >= 0 )
16695 {
16696 if ( a1 < 5000 )
16697 return 1;
16698 return 2;
16699 }
16700 if ( a1 >= 5000 )
16701 return 2;
16702 v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
16703 v4 = 0;
16704 v5 = 0;
16705 v6 = pParty->pHirelings;
16706 do
16707 {
16708 if ( v6->pName )
16709 pTmpBuf[v4++] = v5;
16710 ++v6;
16711 ++v5;
16712 }
16713 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
16714 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
16715 {
16716 v7 = &pTmpBuf[v4];
16717 v8 = pNPCStats->pNewNPCData;
16718 do
16719 {
16720 if ( v8->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) )
16721 {
16722 if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) )
16723 *v7++ = v1 + 2;
16724 }
16725 ++v1;
16726 ++v8;
16727 }
16728 while ( v1 < (signed int)pNPCStats->uNumNewNPCs );
16729 }
16730 return ((unsigned __int8)pTmpBuf[v3] < 2u) + 1;
16731 }
16732
16733
16734 //----- (0044603D) --------------------------------------------------------
16735 void __cdecl sub_44603D()
16736 {
16737 uDialogue_SpeakingActorNPC_ID = 0;
16738 pDialogueWindow->Release();
16739 pDialogueWindow = 0;
16740 pMiscTimer->Resume();
16741 pEventTimer->Resume();
16742 }
16743
16744
16745 //----- (004465DF) --------------------------------------------------------
16746 int sub_4465DF_check_season(int a1)
16747 {
16748 unsigned int v1; // eax@1
16749 unsigned int v2; // edx@1
16750 int v3; // ecx@2
16751 int v4; // ecx@3
16752 char v6; // zf@9
16753
16754 v1 = pParty->uCurrentMonth + 1;
16755 v2 = pParty->uDaysPlayed + 1;
16756 if ( a1 )
16757 {
16758 v3 = a1 - 1;
16759 if ( v3 )
16760 {
16761 v4 = v3 - 1;
16762 if ( v4 )
16763 {
16764 if ( v4 != 1 )
16765 return 0;
16766 if ( v1 != 12 )
16767 {
16768 if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 )
16769 return 1;
16770 v6 = v1 == 3;
16771 LABEL_24:
16772 if ( !v6 || (signed int)v2 >= 21 )
16773 return 0;
16774 return 1;
16775 }
16776 }
16777 else
16778 {
16779 if ( v1 != 9 )
16780 {
16781 if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 )
16782 return 1;
16783 v6 = v1 == 12;
16784 goto LABEL_24;
16785 }
16786 }
16787 }
16788 else
16789 {
16790 if ( v1 != 6 )
16791 {
16792 if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 )
16793 return 1;
16794 v6 = v1 == 9;
16795 goto LABEL_24;
16796 }
16797 }
16798 }
16799 else
16800 {
16801 if ( v1 != 3 )
16802 {
16803 if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 )
16804 return 1;
16805 v6 = v1 == 6;
16806 goto LABEL_24;
16807 }
16808 }
16809 if ( (signed int)v2 >= 21 )
16810 return 1;
16811 return 0;
16812 }
16813
16814 //----- (0044665D) --------------------------------------------------------
16815 // uType: 0 -> any monster
16816 // 1 -> uParam is GroupID
16817 // 2 -> uParam is MonsterID
16818 // 3 -> uParam is ActorID
16819 // uNumAlive: 0 -> all must be alive
16820 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive)
16821 {
16822 unsigned int uAliveActors; // eax@6
16823 int v5; // ecx@10
16824 unsigned int uTotalActors; // [sp+0h] [bp-4h]@1
16825
16826 uTotalActors = 0;
16827 if ( uType )
16828 {
16829 if ( uType == 1 )
16830 {
16831 uAliveActors = SearchActorByGroup(&uTotalActors, uParam);
16832 }
16833 else
16834 {
16835 if ( uType == 2 )
16836 {
16837 uAliveActors = SearchActorByMonsterID(&uTotalActors, uParam);
16838 }
16839 else
16840 {
16841 if ( uType != 3 )
16842 return 0;
16843 uAliveActors = SearchActorByID(&uTotalActors, uParam);
16844 }
16845 }
16846 }
16847 else
16848 {
16849 uAliveActors = SearchAliveActors(&uTotalActors);
16850 }
16851 v5 = 0;
16852 if ( uNumAlive )
16853 LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive;
16854 else
16855 LOBYTE(v5) = uTotalActors == uAliveActors;
16856 return v5;
16857 }
16858
16859 //----- (004466C4) --------------------------------------------------------
16860 bool __thiscall sub_4466C4(void *_this)
16861 {
16862 signed int v1; // ebp@1
16863 bool result; // eax@2
16864 int v3; // esi@3
16865 signed int v4; // edx@3
16866 signed int v5; // eax@4
16867 unsigned int v6; // ebx@6
16868 char *v7; // eax@6
16869 signed int v8; // edi@18
16870 int v9; // eax@19
16871 Player *v10; // [sp+8h] [bp-10h]@18
16872 signed int v11; // [sp+Ch] [bp-Ch]@3
16873 signed int v12; // [sp+10h] [bp-8h]@3
16874 void *v13; // [sp+14h] [bp-4h]@1
16875
16876 v1 = 0;
16877 v13 = _this;
16878 if ( !_this )
16879 return 0;
16880 v3 = dword_597F18;
16881 pSomeOtherEVT = pGlobalEVT;
16882 uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents;
16883 memcpy(pSomeOtherEVT_Events, pGlobalEVT_Events, 0xCE40u);
16884 v4 = 1;
16885 v12 = 1;
16886 v11 = 0;
16887 if ( (signed int)uSomeOtherEVT_NumEvents <= 0 )
16888 goto LABEL_16;
16889 do
16890 {
16891 v5 = v1;
16892 if ( (void *)pSomeOtherEVT_Events[v1].uEventID == v13 && pSomeOtherEVT_Events[v5].field_4 == v3 )
16893 {
16894 v6 = pSomeOtherEVT_Events[v5].uEventOffsetInEVT;
16895 v7 = &pSomeOtherEVT[v6];
16896 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 1 )
16897 break;
16898 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 44 )
16899 {
16900 v11 = v4;
16901 v10 = pParty->pPlayers;
16902 v8 = (unsigned __int8)v7[7]
16903 + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8);
16904 while ( 1 )
16905 {
16906 LOBYTE(v9) = v10->CompareVariable(
16907 (enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5]
16908 + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)),
16909 v8);
16910 if ( v9 )
16911 break;
16912 ++v10;
16913 if ( (signed int)v10 >= (signed int)pParty->pHirelings )
16914 goto LABEL_13;
16915 }
16916 }
16917 else
16918 {
16919 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 45 )
16920 break;
16921 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 46 )
16922 {
16923 v11 = v4;
16924 v12 = (unsigned __int8)v7[5];
16925 goto LABEL_13;
16926 }
16927 if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] != 52
16928 || !IsActorAlive(
16929 (unsigned __int8)v7[5],
16930 (unsigned __int8)v7[6]
16931 + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8),
16932 (unsigned __int8)v7[10]) )
16933 goto LABEL_13;
16934 }
16935 v1 = -1;
16936 v3 = (unsigned __int8)pSomeOtherEVT[v6 + 11] - 1;
16937 LABEL_13:
16938 ++v3;
16939 v4 = 1;
16940 }
16941 ++v1;
16942 }
16943 while ( v1 < (signed int)uSomeOtherEVT_NumEvents );
16944 if ( v11 )
16945 result = v12 != 0;
16946 else
16947 LABEL_16:
16948 result = 2;
16949 return result;
16950 }
16951
16952
16953 //----- (0044684A) --------------------------------------------------------
16954 void __fastcall EventProcessor(int uEventID, int a2, int a3)
16955 {
16956 unsigned int v3; // eax@5
16957 //signed int v4; // esi@7
16958 //char *v5; // eax@8
16959 Player *v6; // ecx@8
16960 //char *v7; // ebp@8
16961 //signed int v8; // edx@10
16962 //int v9; // edi@12
16963 //ByteArray *v10; // esi@12
16964 int v11; // eax@14
16965 char *v12; // eax@15
16966 //char *v13; // edi@21
16967 int v14; // ebp@21
16968 int v15; // edi@21
16969 const char *v16; // esi@21
16970 bool v17; // edx@21
16971 int v18; // ecx@22
16972 int v19; // ebp@36
16973 signed int v20; // ecx@40
16974 int v21; // eax@40
16975 int v22; // edx@40
16976 int v23; // eax@40
16977 unsigned __int16 v24; // ax@45
16978 int v25; // eax@54
16979 LevelDecoration *v26; // eax@55
16980 int v27; // eax@57
16981 int v28; // ecx@57
16982 int v29; // edx@58
16983 int v30; // eax@58
16984 int v31; // ecx@58
16985 int v32; // esi@58
16986 NPCData *v33; // ecx@58
16987 int v34; // esi@59
16988 int v35; // esi@60
16989 int v36; // esi@61
16990 int v37; // esi@62
16991 int v38; // eax@78
16992 int v39; // ecx@78
16993 size_t v40; // edx@78
16994 char *v41; // esi@79
16995 int v42; // eax@84
16996 int v43; // ecx@84
16997 size_t v44; // edx@84
16998 char *v45; // esi@85
16999 void *v46; // eax@91
17000 GUIWindow *v47; // eax@93
17001 GUIButton *v48; // ecx@93
17002 GUIButton *v49; // esi@94
17003 char v50; // al@100
17004 Player *v51; // esi@103
17005 Player *v52; // ecx@106
17006 int v53; // ecx@107
17007 char v54; // al@111
17008 Player *v55; // esi@114
17009 Player *v56; // ecx@117
17010 int v57; // ecx@118
17011 signed int v58; // ebp@124
17012 Player *v59; // esi@125
17013 int v60; // eax@126
17014 int v61; // edx@133
17015 int v62; // eax@139
17016 void *v63; // ebp@145
17017 signed int v64; // edi@146
17018 unsigned int v65; // edx@148
17019 Player *v66; // ecx@148
17020 int v67; // esi@148
17021 signed int v68; // eax@151
17022 int v69; // esi@151
17023 Player *v70; // ecx@158
17024 unsigned int v71; // eax@159
17025 int v72; // esi@159
17026 signed int v73; // eax@162
17027 int v74; // esi@162
17028 int v75; // edx@172
17029 Player *v76; // esi@173
17030 signed int v77; // ebp@186
17031 int v78; // edx@186
17032 Player *v79; // esi@187
17033 signed int v80; // ebp@200
17034 int v81; // edx@200
17035 Player *v82; // esi@201
17036 int v83; // eax@212
17037 int v84; // ebp@220
17038 signed int v85; // ebp@224
17039 char v86; // al@224
17040 Player *v87; // esi@227
17041 Player *v88; // ecx@231
17042 int v89; // ecx@232
17043 int v90; // eax@243
17044 const char *v91; // ecx@247
17045 int v92; // eax@251
17046 char *v93; // eax@252
17047 int v94; // ecx@262
17048 int v95; // ebp@262
17049 int v96; // edx@262
17050 int v97; // eax@262
17051 unsigned int v98; // edx@265
17052 const char *v99; // esi@267
17053 int v100; // edx@267
17054 //char *v101; // edi@281
17055 unsigned int v102; // esi@281
17056 int v103; // edi@284
17057 int v104; // eax@288
17058 int v105; // edx@294
17059 int v106; // [sp-20h] [bp-4C8h]@278
17060 signed int v107; // [sp-1Ch] [bp-4C4h]@278
17061 unsigned int v108; // [sp-18h] [bp-4C0h]@278
17062 signed int v109; // [sp-14h] [bp-4BCh]@278
17063 signed int v110; // [sp-10h] [bp-4B8h]@278
17064 int v111; // [sp-Ch] [bp-4B4h]@278
17065 Event *v112; // [sp-8h] [bp-4B0h]@5
17066 int v113; // [sp-8h] [bp-4B0h]@106
17067 int v114; // [sp-8h] [bp-4B0h]@117
17068 signed int v115; // [sp-8h] [bp-4B0h]@231
17069 unsigned int v116; // [sp-8h] [bp-4B0h]@278
17070 int v117; // [sp-4h] [bp-4ACh]@106
17071 int v118; // [sp-4h] [bp-4ACh]@117
17072 int v119; // [sp-4h] [bp-4ACh]@231
17073 int v120; // [sp-4h] [bp-4ACh]@278
17074 int v121; // [sp-4h] [bp-4ACh]@294
17075 int v122; // [sp+10h] [bp-498h]@4
17076 //char *v123; // [sp+14h] [bp-494h]@0
17077 //signed int v124; // [sp+18h] [bp-490h]@7
17078 signed int v125; // [sp+1Ch] [bp-48Ch]@155
17079 int v126; // [sp+1Ch] [bp-48Ch]@262
17080 int v127; // [sp+20h] [bp-488h]@4
17081 int v128; // [sp+24h] [bp-484h]@21
17082 int v129; // [sp+24h] [bp-484h]@262
17083 signed int v130; // [sp+28h] [bp-480h]@0
17084 //int v131; // [sp+2Ch] [bp-47Ch]@1
17085 int v132; // [sp+30h] [bp-478h]@262
17086 signed int v133; // [sp+34h] [bp-474h]@1
17087 int v134; // [sp+38h] [bp-470h]@262
17088 int v135; // [sp+3Ch] [bp-46Ch]@262
17089 int v136; // [sp+40h] [bp-468h]@40
17090 int v137; // [sp+44h] [bp-464h]@40
17091 int v138; // [sp+48h] [bp-460h]@40
17092 int v139; // [sp+4Ch] [bp-45Ch]@40
17093 ItemGen item; // [sp+50h] [bp-458h]@15
17094 char Source[120]; // [sp+74h] [bp-434h]@15
17095 char Str[120]; // [sp+ECh] [bp-3BCh]@21
17096 Actor Dst; // [sp+164h] [bp-344h]@53
17097
17098 //v131 = uEventID;
17099 v133 = 0;
17100 dword_5B5920 = a2;
17101 dword_5B65C4 = 0;
17102 if ( !a1 )
17103 {
17104 if ( !GameUI_StatusBar_TimedStringTimeLeft )
17105 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
17106 return;
17107 }
17108 v127 = 2 * (uActiveCharacter == 0) + 4;
17109 v122 = dword_597F18;
17110 if ( _5C3420_pDecoration )
17111 {
17112 v3 = uGlobalEVT_NumEvents;
17113 pSomeEVT = pGlobalEVT;
17114 v112 = pGlobalEVT_Events;
17115 }
17116 else
17117 {
17118 v3 = uLevelEVT_NumEvents;
17119 pSomeEVT = pLevelEVT;
17120 v112 = pLevelEVT_Events;
17121 }
17122 uSomeEVT_NumEvents = v3;
17123 memcpy(pSomeEVT_Events, v112, 0xCE40u);
17124 //v4 = 0;
17125 //v124 = 0;
17126 for (uint i = 0; i < uSomeEVT_NumEvents; ++i)
17127 {
17128 //v5 = pSomeEVT;
17129 //v6 = v123;
17130 //v7 = "";
17131 //while ( 1 )
17132 //{
17133 if ( dword_5B65C4 )
17134 goto LABEL_301;
17135 //v8 = v4;
17136 if ( pSomeEVT_Events[i/*v4*/].uEventID == uEventID && pSomeEVT_Events[i/*v4*/].field_4 == v122 )
17137 {
17138 //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT;
17139 //v10 = (ByteArray *)&v5[v9];
17140 auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[i/*v4*/].uEventOffsetInEVT);
17141
17142 switch (_evt->v4)
17143 {
17144 case EVENT_CheckSeason:
17145 if ( !sub_4465DF_check_season(_evt->v5) )
17146 goto LABEL_291;
17147 v11 = _evt->v6;
17148 goto LABEL_130;
17149 case EVENT_ShowMovie:
17150 strcpy(Source, (char *)&_evt->v7);
17151 v12 = (char *)&item.uExpireTime + strlen(Source) + 7;
17152 if ( *v12 == 32 )
17153 *v12 = 0;
17154 if ( pVideoPlayer->field_54 )
17155 pVideoPlayer->Unload();
17156 pVideoPlayer->bStopBeforeSchedule = 0;
17157 pVideoPlayer->field_40 = 0;
17158 if (pAsyncMouse)
17159 pAsyncMouse->Suspend();
17160 v128 = pCurrentScreen;
17161 //v13 = &pSomeEVT[v9];
17162 //v14 = (unsigned __int8)v13[5];
17163 //v15 = (unsigned __int8)v13[6];
17164 v14 = _evt->v5;
17165 v15 = _evt->v6;
17166 strcpy(Str, Source);
17167 v16 = RemoveQuotes(Str);
17168 VideoPlayer::MovieLoop(v16, 0, v14, 1);
17169 if ( !_strcmpi(v16, "arbiter good") )
17170 {
17171 pParty->uAlignment = 0;
17172 v18 = 0;
17173 LABEL_23:
17174 LOBYTE(v17) = 1;
17175 SetUserInterface(v18, v17);
17176 goto LABEL_28;
17177 }
17178 if ( !_strcmpi(v16, "arbiter evil") )
17179 {
17180 v18 = 2;
17181 pParty->uAlignment = 2;
17182 goto LABEL_23;
17183 }
17184 if ( !_strcmpi(v16, "pcout01") ) // moving to harmondale from emerald isle
17185 {
17186 Rest(0x2760u);
17187 pParty->RestAndHeal();
17188 pParty->field_764 = 0;
17189 }
17190 LABEL_28:
17191 if ( !v15 || v128 == 3 )
17192 {
17193 pCurrentScreen = v128;
17194 if ( v128 == 3 )
17195 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
17196 if ( v128 == 13 )
17197 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
17198 }
17199 if (pAsyncMouse)
17200 pAsyncMouse->Resume();
17201 goto LABEL_291;
17202 case EVENT_CheckSkill:
17203 v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8);
17204 if ( v127 < 0 )
17205 goto LABEL_47;
17206 if ( v127 <= 3 )
17207 {
17208 v24 = pParty->pPlayers[0].pActiveSkills[3486 * v127 + _evt->v5];
17209 }
17210 else
17211 {
17212 if ( v127 == 4 )
17213 {
17214 v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5];
17215 }
17216 else
17217 {
17218 if ( v127 == 5 )
17219 {
17220 v20 = 0;
17221 v21 = 3486 * v130 + _evt->v5;
17222 v136 = 1;
17223 LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21];
17224 v137 = v21 & 0x40;
17225 v138 = v21 & 0x80;
17226 v22 = v21 & 0x100;
17227 v23 = v21 & 0x3F;
17228 v139 = v22;
17229 while ( v23 < v19 || !*(&v136 + _evt->v6) )
17230 {
17231 ++v20;
17232 if ( v20 >= 4 )
17233 goto LABEL_291;
17234 }
17235 LABEL_50:
17236 v11 = _evt->v11;
17237 goto LABEL_130;
17238 }
17239 LABEL_47:
17240 //v10 = (ByteArray *)&v5[v9];
17241 v24 = pParty->pPlayers[0].pActiveSkills[_evt->v5 + 3486 * rand() % 4];
17242 }
17243 }
17244 v136 = 1;
17245 v137 = v24 & 0x40;
17246 v138 = v24 & 0x80;
17247 v139 = v24 & 0x100;
17248 if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) )
17249 goto LABEL_50;
17250 goto LABEL_291;
17251 case EVENT_SpeakNPC:
17252 if ( a3 )
17253 {
17254 //Actor::Actor(&Dst);
17255 memset(&Dst, 0, 0x344u);
17256 dword_5B65D0_dialogue_actor_npc_id = _evt->v5
17257 + ((_evt->v6
17258 + ((_evt->v7
17259 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
17260 Dst.uNPC_ID = dword_5B65D0_dialogue_actor_npc_id;
17261 Dst.InitializeDialogue(0);
17262 }
17263 else
17264 {
17265 bDialogueUI_InitializeActor_NPC_ID = _evt->v5
17266 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
17267 }
17268 goto LABEL_291;
17269 case EVENT_ChangeEvent:
17270 v25 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
17271 if ( v25 )
17272 {
17273 stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = _evt->v5 - 124;
17274 }
17275 else
17276 {
17277 v26 = _5C3420_pDecoration;
17278 stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = 0;
17279 LOBYTE(v26->field_2) |= 0x20u;
17280 }
17281 goto LABEL_291;
17282 case EVENT_SetNPCGreeting:
17283 v27 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17284 v28 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
17285 pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
17286 pNPCStats->pNewNPCData[v27].greet = v28;
17287 goto LABEL_291;
17288 case EVENT_SetNPCTopic:
17289 v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17290 v30 = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8);
17291 v31 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17292 v32 = _evt->v9;
17293 v33 = &pNPCStats->pNewNPCData[v31];
17294 if ( v32 )
17295 {
17296 v34 = v32 - 1;
17297 if ( v34 )
17298 {
17299 v35 = v34 - 1;
17300 if ( v35 )
17301 {
17302 v36 = v35 - 1;
17303 if ( v36 )
17304 {
17305 v37 = v36 - 1;
17306 if ( v37 )
17307 {
17308 if ( v37 == 1 )
17309 v33->evtf = v30;
17310 }
17311 else
17312 {
17313 v33->evte = v30;
17314 }
17315 }
17316 else
17317 {
17318 v33->evtd = v30;
17319 }
17320 }
17321 else
17322 {
17323 v33->evtc = v30;
17324 }
17325 }
17326 else
17327 {
17328 v33->evtb = v30;
17329 }
17330 }
17331 else
17332 {
17333 v33->bDrawSomeAnim = v30;
17334 }
17335 if ( v29 == 8 )
17336 {
17337 if ( v30 == 78 )
17338 {
17339 sub_4BD8B5();
17340 ptr_507BC0->Release();
17341 pParty->uFlags &= 0xFFFFFFFDu;
17342 if ( EnterHouse((enum HOUSE_TYPE)170) )
17343 {
17344 pAudioPlayer->StopChannels(-1, -1);
17345 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
17346 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
17347 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
17348 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
17349 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
17350 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
17351 ptr_F8B1E8 = pNPCTopics[90].pText;
17352 }
17353 }
17354 }
17355 goto LABEL_291;
17356 case EVENT_NPCSetItem:
17357 sub_448518_npc_set_item(
17358 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17359 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17360 _evt->v13);
17361 goto LABEL_291;
17362 case EVENT_SetActorItem:
17363 Actor::GiveItem(
17364 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17365 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17366 _evt->v13);
17367 goto LABEL_291;
17368 case EVENT_SetNPCGroupNews:
17369 pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8);
17370 goto LABEL_291;
17371 case EVENT_SetActorGroup:
17372 __debugbreak();
17373 *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
17374 goto LABEL_291;
17375 case EVENT_ChangeGroup:
17376 v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17377 v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
17378 v40 = uNumActors;
17379 __debugbreak();
17380 if ( (signed int)uNumActors > 0 )
17381 {
17382 v41 = (char *)&pActors[0].uGroup;
17383 do
17384 {
17385 if ( *(int *)v41 == v38 )
17386 *(int *)v41 = v39;
17387 v41 += 836;
17388 --v40;
17389 }
17390 while ( v40 );
17391 }
17392 goto LABEL_291;
17393 case EVENT_ChangeGroupAlly:
17394 v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17395 v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
17396 v44 = uNumActors;
17397 __debugbreak();
17398 if ( (signed int)uNumActors > 0 )
17399 {
17400 v45 = (char *)&pActors[0].uAlly;
17401 do
17402 {
17403 if ( *((int *)v45 - 1) == v42 )
17404 *(int *)v45 = v43;
17405 v45 += 836;
17406 --v44;
17407 }
17408 while ( v44 );
17409 }
17410 goto LABEL_291;
17411 case EVENT_MoveNPC:
17412 pNPCStats->pNewNPCData[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)].house = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
17413 if ( ptr_507BC0 )
17414 {
17415 v46 = ptr_507BC0->ptr_1C;
17416 if ( v46 == (void *)165 )
17417 {
17418 sub_4BD8B5();
17419 pVideoPlayer->Unload();
17420 ptr_507BC0->Release();
17421 pParty->uFlags &= 0xFFFFFFFDu;
17422 _5C3420_pDecoration = (LevelDecoration *)1;
17423 if ( EnterHouse((enum HOUSE_TYPE)165) )
17424 {
17425 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
17426 v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
17427 ptr_507BC0 = v47;
17428 v48 = v47->pControlsHead;
17429 if ( v48 )
17430 {
17431 do
17432 {
17433 v49 = v48->pNext;
17434 pAllocator->FreeChunk(v48);
17435 v48 = v49;
17436 }
17437 while ( v49 );
17438 v47 = ptr_507BC0;
17439 }
17440 v47->pControlsHead = 0;
17441 ptr_507BC0->pControlsTail = 0;
17442 ptr_507BC0->uNumControls = 0;
17443 }
17444 }
17445 else
17446 {
17447 if ( v46 == (void *)553 )
17448 pVideoPlayer->bLoopPlaying = 0;
17449 }
17450 }
17451 goto LABEL_291;
17452 case EVENT_Jmp:
17453 //v124 = -1;
17454 v122 = _evt->v5 - 1;
17455 goto LABEL_291;
17456 case EVENT_ShowFace:
17457 v50 = _evt->v5;
17458 if ( (unsigned __int8)v50 <= 3u )
17459 {
17460 v117 = 0;
17461 v113 = _evt->v6;
17462 v53 = (unsigned __int8)v50;
17463 goto LABEL_108;
17464 }
17465 if ( v50 == 4 )
17466 {
17467 v117 = 0;
17468 v113 = _evt->v6;
17469 v52 = pPlayers[uActiveCharacter];
17470 goto LABEL_109;
17471 }
17472 if ( v50 != 5 )
17473 {
17474 v117 = 0;
17475 v113 = _evt->v6;
17476 v53 = rand() % 4;
17477 LABEL_108:
17478 v52 = &pParty->pPlayers[v53];
17479 LABEL_109:
17480 v52->PlayEmotion(v113, v117);
17481 goto LABEL_291;
17482 }
17483 v51 = pParty->pPlayers;
17484 do
17485 {
17486 v51->PlayEmotion(_evt->v6, 0);
17487 ++v51;
17488 }
17489 while ( (signed int)v51 < (signed int)pParty->pHirelings );
17490 LABEL_291:
17491 ++v122;
17492 //v4 = v124;
17493 //v5 = pSomeEVT;
17494 //v6 = v123;
17495 //v7 = "";
17496 break;
17497 case EVENT_CharacterAnimation:
17498 v54 = _evt->v5;
17499 if ( (unsigned __int8)v54 <= 3u )
17500 {
17501 v118 = 0;
17502 v114 = _evt->v6;
17503 v57 = (unsigned __int8)v54;
17504 goto LABEL_119;
17505 }
17506 if ( v54 == 4 )
17507 {
17508 v118 = 0;
17509 v114 = _evt->v6;
17510 v56 = pPlayers[uActiveCharacter];
17511 goto LABEL_120;
17512 }
17513 if ( v54 != 5 )
17514 {
17515 v118 = 0;
17516 v114 = _evt->v6;
17517 v57 = rand() % 4;
17518 LABEL_119:
17519 v56 = &pParty->pPlayers[v57];
17520 LABEL_120:
17521 v56->PlaySound(v114, v118);
17522 goto LABEL_291;
17523 }
17524 v55 = pParty->pPlayers;
17525 do
17526 {
17527 v55->PlaySound(_evt->v6, 0);
17528 ++v55;
17529 }
17530 while ( (signed int)v55 < (signed int)pParty->pHirelings );
17531 goto LABEL_291;
17532 case EVENT_ForPartyMember:
17533 v127 = _evt->v5;
17534 goto LABEL_291;
17535 case EVENT_SummonItem:
17536 sub_42F7EB_DropItemAt(
17537 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17538 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17539 _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8),
17540 _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8),
17541 _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8),
17542 _evt->v25,
17543 _evt->v26,
17544 0,
17545 0);
17546 goto LABEL_291;
17547 case EVENT_Compare:
17548 v58 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17549 if ( v127 == 5 )
17550 {
17551 v130 = 0;
17552 v59 = pParty->pPlayers;
17553 while ( 1 )
17554 {
17555 LOBYTE(v60) = v59->CompareVariable(
17556 (enum VariableType)(_evt->v5
17557 + ((uint)_evt->v6 << 8)),
17558 v58);
17559 if ( v60 )
17560 break;
17561 ++v130;
17562 ++v59;
17563 if ( (signed int)v59 >= (signed int)pParty->pHirelings )
17564 goto LABEL_291;
17565 }
17566 LABEL_129:
17567 v11 = _evt->v11;
17568 goto LABEL_130;
17569 }
17570 if ( v127 < 0 )
17571 goto LABEL_139;
17572 v61 = v127;
17573 if ( v127 <= 3 )
17574 goto LABEL_137;
17575 if ( v127 == 4 )
17576 {
17577 if ( uActiveCharacter )
17578 {
17579 v6 = pPlayers[uActiveCharacter];
17580 goto LABEL_138;
17581 }
17582 }
17583 else
17584 {
17585 if ( v127 != 6 )
17586 goto LABEL_139;
17587 }
17588 v61 = rand() % 4;
17589 //v5 = pSomeEVT;
17590 LABEL_137:
17591 v6 = &pParty->pPlayers[v61];
17592 LABEL_138:
17593 //v123 = v6;
17594 LABEL_139:
17595 LOBYTE(v62) = ((Player *)v6)->CompareVariable(
17596 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17597 v58);
17598 LABEL_140:
17599 if ( v62 )
17600 goto LABEL_129;
17601 goto LABEL_291;
17602 case EVENT_IsActorAlive:
17603 v62 = IsActorAlive(
17604 _evt->v5,
17605 _evt->v6 + ((_evt->v7 + ((_evt->v8 + ((uint)_evt->v9 << 8)) << 8)) << 8),
17606 _evt->v10);
17607 goto LABEL_140;
17608 case EVENT_Substract:
17609 v63 = (void *)(_evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8));
17610 if ( _evt->v5 + ((uint)_evt->v6 << 8) == VAR_PlayerItemInHands )
17611 {
17612 v64 = 0;
17613 if ( (void *)pParty->pPickedItem.uItemID == v63 )
17614 {
17615 pMouse->RemoveHoldingItem();
17616 goto LABEL_291;
17617 }
17618 v65 = 0;
17619 v66 = pPlayers[uActiveCharacter];
17620 v67 = (int)v66->pInventoryIndices;
17621 do
17622 {
17623 if ( *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 )
17624 {
17625 v66->RemoveItemAtInventoryIndex(v65);
17626 goto LABEL_291;
17627 }
17628 ++v65;
17629 v67 += 4;
17630 }
17631 while ( (signed int)v65 < 126 );
17632 v68 = 0;
17633 v69 = (int)&v66->pEquipment;
17634 do
17635 {
17636 if ( *(int *)v69 && *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 )
17637 {
17638 *(&v66->pEquipment.uOffHand + v68) = 0;
17639 goto LABEL_291;
17640 }
17641 ++v68;
17642 v69 += 4;
17643 }
17644 while ( v68 < 16 );
17645 v125 = (signed int)&pPlayers[1];
17646 while ( 1 )
17647 {
17648 v70 = *(Player **)v125;
17649 if ( !v64 )
17650 {
17651 v71 = 0;
17652 v72 = (int)v70->pInventoryIndices;
17653 do
17654 {
17655 if ( *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 )
17656 {
17657 v70->RemoveItemAtInventoryIndex(v71);
17658 goto LABEL_169;
17659 }
17660 ++v71;
17661 v72 += 4;
17662 }
17663 while ( (signed int)v71 < 126 );
17664 v73 = 0;
17665 v74 = (int)&v70->pEquipment;
17666 while ( !*(int *)v74
17667 || *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 )
17668 {
17669 ++v73;
17670 v74 += 4;
17671 if ( v73 >= 16 )
17672 goto LABEL_170;
17673 }
17674 *(&v70->pEquipment.uOffHand + v73) = 0;
17675 LABEL_169:
17676 v64 = 1;
17677 }
17678 LABEL_170:
17679 v125 += 4;
17680 if ( v125 > (signed int)&pPlayers[4] )
17681 goto LABEL_291;
17682 }
17683 }
17684 v75 = v127;
17685 if ( v127 != 5 )
17686 {
17687 if ( v127 < 0 )
17688 goto LABEL_183;
17689 if ( v127 > 3 )
17690 {
17691 if ( v127 != 4 )
17692 {
17693 if ( v127 == 6 )
17694 goto LABEL_180;
17695 LABEL_183:
17696 ((Player *)v6)->SubtractVariable(
17697 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17698 v63);
17699 goto LABEL_291;
17700 }
17701 if ( uActiveCharacter )
17702 {
17703 v6 = pPlayers[uActiveCharacter];
17704 goto LABEL_182;
17705 }
17706 LABEL_180:
17707 v75 = rand() % 4;
17708 //v5 = pSomeEVT;
17709 }
17710 v6 = &pParty->pPlayers[v75];
17711 LABEL_182:
17712 //v123 = v6;
17713 goto LABEL_183;
17714 }
17715 v76 = pParty->pPlayers;
17716 v130 = 4;
17717 do
17718 {
17719 v76->SubtractVariable(
17720 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17721 v63);
17722 ++v76;
17723 }
17724 while ( (signed int)v76 < (signed int)pParty->pHirelings );
17725 goto LABEL_291;
17726 case EVENT_Set:
17727 v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17728 v78 = v127;
17729 if ( v127 != 5 )
17730 {
17731 if ( v127 < 0 )
17732 goto LABEL_197;
17733 if ( v127 > 3 )
17734 {
17735 if ( v127 != 4 )
17736 {
17737 if ( v127 == 6 )
17738 goto LABEL_194;
17739 LABEL_197:
17740 ((Player *)v6)->SetVariable(
17741 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17742 v77);
17743 goto LABEL_291;
17744 }
17745 if ( uActiveCharacter )
17746 {
17747 v6 = pPlayers[uActiveCharacter];
17748 goto LABEL_196;
17749 }
17750 LABEL_194:
17751 v78 = rand() % 4;
17752 //v5 = pSomeEVT;
17753 }
17754 v6 = &pParty->pPlayers[v78];
17755 LABEL_196:
17756 //v123 = v6;
17757 goto LABEL_197;
17758 }
17759 v79 = pParty->pPlayers;
17760 v130 = 4;
17761 do
17762 {
17763 v79->SetVariable(
17764 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17765 v77);
17766 ++v79;
17767 }
17768 while ( (signed int)v79 < (signed int)pParty->pHirelings );
17769 goto LABEL_291;
17770 case EVENT_Add:
17771 v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17772 v81 = v127;
17773 if ( v127 != 5 )
17774 {
17775 if ( v127 < 0 )
17776 goto LABEL_211;
17777 if ( v127 > 3 )
17778 {
17779 if ( v127 != 4 )
17780 {
17781 if ( v127 == 6 )
17782 goto LABEL_208;
17783 LABEL_211:
17784 ((Player *)v6)->AddVariable(
17785 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17786 v80);
17787 goto LABEL_212;
17788 }
17789 if ( uActiveCharacter )
17790 {
17791 v6 = pPlayers[uActiveCharacter];
17792 goto LABEL_210;
17793 }
17794 LABEL_208:
17795 v81 = rand() % 4;
17796 //v5 = pSomeEVT;
17797 }
17798 v6 = &pParty->pPlayers[v81];
17799 LABEL_210:
17800 //v123 = v6;
17801 goto LABEL_211;
17802 }
17803 v82 = pParty->pPlayers;
17804 v130 = 4;
17805 do
17806 {
17807 v82->AddVariable(
17808 (enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)),
17809 v80);
17810 ++v82;
17811 }
17812 while ( (signed int)v82 < (signed int)pParty->pHirelings );
17813 LABEL_212:
17814 v83 = _evt->v5 + ((uint)_evt->v6 << 8);
17815 if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
17816 viewparams->bRedrawGameUI = 1;
17817 goto LABEL_291;
17818 case EVENT_InputString:
17819 if ( !dword_597F18 )
17820 {
17821 strcpy(
17822 GameUI_StatusBar_TimedString,
17823 &pLevelStr[pLevelStrOffsets[_evt->v5
17824 + ((_evt->v6
17825 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)]]);
17826 v105 = v122;
17827 v121 = 26;
17828 LABEL_295:
17829 sub_4451A8_press_any_key(uEventID, v105, v121);
17830 LABEL_301:
17831 if ( v133 == 1 )
17832 LABEL_302:
17833 OnMapLeave();
17834 return;
17835 }
17836 v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
17837 if ( !_strcmpi(
17838 GameUI_StatusBar_TimedString,
17839 &pLevelStr[pLevelStrOffsets[_evt->v9
17840 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]])
17841 || !_strcmpi(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[v84]]) )
17842 {
17843 v11 = _evt->v17;
17844 LABEL_130:
17845 //v124 = -1;
17846 LABEL_131:
17847 v122 = v11 - 1;
17848 }
17849 goto LABEL_291;
17850 case EVENT_RandomGoTo:
17851 //v124 = -1;
17852 v11 = (unsigned __int8)*(&_evt->v5
17853 + rand()
17854 % ((_evt->v5 != 0)
17855 + (_evt->v6 != 0)
17856 + (_evt->v7 != 0)
17857 + (_evt->v8 != 0)
17858 + (_evt->v9 != 0)
17859 + (_evt->v10 != 0)));
17860 goto LABEL_131;
17861 case EVENT_ReceiveDamage:
17862 v85 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17863 v86 = _evt->v5;
17864 if ( (unsigned __int8)v86 <= 3u )
17865 {
17866 v119 = _evt->v6;
17867 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17868 v89 = (unsigned __int8)v86;
17869 goto LABEL_233;
17870 }
17871 if ( v86 == 4 )
17872 {
17873 if ( !uActiveCharacter )
17874 goto LABEL_291;
17875 v119 = _evt->v6;
17876 v88 = pPlayers[uActiveCharacter];
17877 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
17878 goto LABEL_234;
17879 }
17880 if ( v86 != 5 )
17881 {
17882 v119 = _evt->v6;
17883 v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v1 << 8)) << 8)) << 8);
17884 v89 = rand() % 4;
17885 LABEL_233:
17886 v88 = &pParty->pPlayers[v89];
17887 LABEL_234:
17888 v88->ReceiveDamage(v115, v119);
17889 goto LABEL_291;
17890 }
17891 v87 = pParty->pPlayers;
17892 do
17893 {
17894 v87->ReceiveDamage(v85, _evt->v6);
17895 ++v87;
17896 }
17897 while ( (signed int)v87 < (signed int)pParty->pHirelings );
17898 goto LABEL_291;
17899 case EVENT_ToggleIndoorLight:
17900 pIndoor->ToggleLight(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9);
17901 goto LABEL_291;
17902 case EVENT_SetFacesBit:
17903 sub_44892E_set_faces_bit(
17904 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17905 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17906 _evt->v13);
17907 goto LABEL_291;
17908 case EVENT_ToggleChestFlag:
17909 Chest::ToggleFlag(
17910 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17911 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17912 _evt->v13);
17913 goto LABEL_291;
17914 case EVENT_ToggleActorFlag:
17915 Actor::ToggleFlag(
17916 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17917 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17918 _evt->v13);
17919 goto LABEL_291;
17920 case EVENT_ToggleActorGroupFlag:
17921 ToggleActorGroupFlag(
17922 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17923 _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
17924 _evt->v13);
17925 goto LABEL_291;
17926 case EVENT_SetSnow:
17927 if ( !_evt->v5 )
17928 pWeather->bRenderSnow = _evt->v6 != 0;
17929 goto LABEL_291;
17930 case EVENT_StatusText:
17931 v90 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17932 if ( _5C3420_pDecoration )
17933 {
17934 if ( _5C3420_pDecoration == (LevelDecoration *)1 )
17935 {
17936 ptr_F8B1E8 = (&dword_721664)[8 * v90];
17937 goto LABEL_291;
17938 }
17939 if ( a3 == 1 )
17940 {
17941 v91 = (&dword_721664)[8 * v90];
17942 LABEL_248:
17943 ShowStatusBarString(v91, 2u);
17944 goto LABEL_291;
17945 }
17946 }
17947 else
17948 {
17949 if ( a3 == 1 )
17950 {
17951 v91 = &pLevelStr[pLevelStrOffsets[v90]];
17952 goto LABEL_248;
17953 }
17954 }
17955 goto LABEL_291;
17956 case EVENT_ShowMessage:
17957 v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
17958 if ( _5C3420_pDecoration )
17959 {
17960 v93 = (&dword_721664)[8 * v92];
17961 byte_5B0938[0] = 0;
17962 ptr_F8B1E8 = v93;
17963 }
17964 else
17965 {
17966 strcpy(byte_5B0938, &pLevelStr[pLevelStrOffsets[v92]]);
17967 }
17968 goto LABEL_291;
17969 case EVENT_CastSpell:
17970 sub_448DF8_cast_spell(
17971 _evt->v5,
17972 _evt->v6,
17973 _evt->v7,
17974 _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
17975 _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
17976 _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
17977 _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
17978 _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8),
17979 _evt->v28 + ((_evt->v29 + ((_evt->v30 + ((uint)_evt->v31 << 8)) << 8)) << 8));
17980 goto LABEL_291;
17981 case EVENT_SetTexture:
17982 sub_44861E_set_texture(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), (char *)&_evt->v9);
17983 goto LABEL_291;
17984 case EVENT_SetSprite:
17985 SetDecorationSprite(
17986 _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
17987 _evt->v9,
17988 (char *)&_evt->v10);
17989 goto LABEL_291;
17990 case EVENT_SummonMonsters:
17991 sub_448CF4_spawn_monsters(
17992 _evt->v5,
17993 _evt->v6,
17994 _evt->v7,
17995 _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
17996 _evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
17997 _evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
17998 _evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
17999 _evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8));
18000 goto LABEL_291;
18001 case EVENT_MouseOver:
18002 case EVENT_LocationName:
18003 --v122;
18004 goto LABEL_291;
18005 case EVENT_ChangeDoorState:
18006 sub_449A49_door_switch_animation(_evt->v5, _evt->v6);
18007 goto LABEL_291;
18008 case EVENT_OpenChest:
18009 if ( !Chest::Open(_evt->v5) )
18010 goto LABEL_301;
18011 goto LABEL_291;
18012 case EVENT_MoveToMap:
18013 v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
18014 v135 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
18015 v132 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
18016 v126 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
18017 v129 = _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8);
18018 v95 = _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8);
18019 v96 = _evt->v25;
18020 v97 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8);
18021 v134 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8);
18022 if ( _evt->v29 || _evt->v30 )
18023 {
18024 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
18025 pRenderer->_49FD3A();
18026 sub_444839_move_map(
18027 _evt->v29,
18028 _evt->v30,
18029 v135,
18030 v132,
18031 v126,
18032 v129,
18033 v95,
18034 v134,
18035 (char *)&_evt->v31);
18036 dword_5C3418 = uEventID;
18037 dword_5C341C = v122 + 1;
18038 goto LABEL_301;
18039 }
18040 _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
18041 _5B65A8_npcdata_uflags_or_other = v94;
18042 _5B65B0_npcdata_rep_or_other = v126;
18043 if ( v129 == -1 )
18044 {
18045 v98 = _5B65B4_npcdata_loword_house_or_other;
18046 }
18047 else
18048 {
18049 v98 = v129 & stru_5C6E00->uDoublePiMask;
18050 _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask;
18051 }
18052 v99 = (char *)&_evt->v31;
18053 _5B65B8_npcdata_hiword_house_or_other = v95;
18054 dword_5B65BC = v97;
18055 v100 = v94 | v132 | v126 | v95 | v97 | v98;
18056 dword_5B65C0 = v100;
18057 if ( *v99 == 48 )
18058 {
18059 if ( v100 )
18060 {
18061 pParty->vPosition.x = v135;
18062 pParty->vPosition.y = v132;
18063 pParty->vPosition.z = v126;
18064 pParty->uFallStartY = v126;
18065 if ( _5B65B4_npcdata_loword_house_or_other != -1 )
18066 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
18067 _5B65B4_npcdata_loword_house_or_other = -1;
18068 v120 = 0;
18069 v116 = 0;
18070 v111 = 0;
18071 v110 = 0;
18072 v109 = -1;
18073 v108 = 0;
18074 v107 = 0;
18075 pParty->sRotationX = v95;
18076 pParty->uFallSpeed = v134;
18077 dword_5B65C0 = 0;
18078 dword_5B65BC = 0;
18079 _5B65B8_npcdata_hiword_house_or_other = 0;
18080 _5B65B0_npcdata_rep_or_other = 0;
18081 _5B65AC_npcdata_fame_or_other = 0;
18082 _5B65A8_npcdata_uflags_or_other = 0;
18083 v106 = 232;
18084 LABEL_280:
18085 pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120);
18086 }
18087 }
18088 else
18089 {
18090 pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((_5C3420_pDecoration == 0) + 1);
18091 sub_44987B(v99, 0);
18092 v133 = 1;
18093 if ( pCurrentScreen == 13 )
18094 {
18095 if ( uGameState == 2 )
18096 {
18097 pAudioPlayer->StopChannels(-1, -1);
18098 dword_F8B19C = 0;
18099 while ( sub_4BD8B5() )
18100 ;
18101 pVideoPlayer->Unload();
18102 ptr_507BC0->Release();
18103 ptr_507BC0 = 0;
18104 if ( pMessageQueue_50CBD0->uNumMessages )
18105 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
18106 pCurrentScreen = 0;
18107 viewparams->bRedrawGameUI = 1;
18108 array_5913D8[6] = 0;
18109 pDialogueWindow->Release();
18110 dword_F8B19C = 0;
18111 pDialogueWindow = 0;
18112 pIcons_LOD->_40F9C5();
18113 }
18114 goto LABEL_302;
18115 }
18116 }
18117 goto LABEL_291;
18118 case EVENT_PlaySound:
18119 v120 = 0;
18120 v116 = 0;
18121 v111 = 0;
18122 v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
18123 v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
18124 v108 = 0;
18125 v107 = 0;
18126 v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
18127 goto LABEL_280;
18128 case EVENT_GiveItem:
18129 item.Reset();
18130 //v101 = &pSomeEVT[v9];
18131 v102 = _evt->v7
18132 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
18133 pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item);
18134 if ( v102 )
18135 item.uItemID = v102;
18136 pParty->SetHoldingItem(&item);
18137 goto LABEL_291;
18138 case EVENT_SpeakInHouse:
18139 v103 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
18140 if ( EnterHouse((enum HOUSE_TYPE)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
18141 {
18142 if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
18143 pRenderer->_49FD3A();
18144 pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
18145 pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0);
18146 v104 = 187;
18147 if ( uCurrentHouse_Animation != 167 )
18148 v104 = v103;
18149 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
18150 ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
18151 ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
18152 ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
18153 ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
18154 ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
18155 }
18156 goto LABEL_291;
18157 default:
18158 goto LABEL_291;
18159 case EVENT_PressAnyKey:
18160 v121 = 33;
18161 v105 = v122 + 1;
18162 goto LABEL_295;
18163 case EVENT_Exit:
18164 goto LABEL_301;
18165 }
18166 }
18167 //++v4;
18168 //v124 = v4;
18169 //if ( v4 >= (signed int)uSomeEVT_NumEvents )
18170 //goto LABEL_301;
18171 //}
18172 }
18173 }
18174
18175
18176
18177 //----- (0044861E) --------------------------------------------------------
18178 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
18179 {
18180 unsigned int v2; // eax@2
18181 unsigned __int16 v3; // di@2
18182 signed int v4; // esi@5
18183 BLVFace *v5; // eax@7
18184 unsigned int *v6; // eax@8
18185 char *v7; // eax@9
18186 int v8; // edi@16
18187 char *v9; // esi@16
18188 ODMFace *v10; // eax@17
18189 unsigned int *v11; // eax@19
18190 unsigned __int16 v12; // [sp+Ch] [bp-18h]@2
18191 const char *Str2; // [sp+10h] [bp-14h]@1
18192 unsigned int v14; // [sp+14h] [bp-10h]@1
18193 signed int v15; // [sp+18h] [bp-Ch]@14
18194 int v16; // [sp+1Ch] [bp-8h]@15
18195 signed int v17; // [sp+20h] [bp-4h]@4
18196 signed int v18; // [sp+20h] [bp-4h]@16
18197
18198 Str2 = pFilename;
18199 v14 = uFaceCog;
18200 if ( uFaceCog )
18201 {
18202 v2 = pBitmaps_LOD->LoadTexture(pFilename);
18203 v3 = v2;
18204 v12 = v2;
18205 if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 )
18206 {
18207 pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1);
18208
18209 if ( uCurrentlyLoadedLevelType == 1 )
18210 {
18211 v17 = 1;
18212 if ( (signed int)pIndoor->uNumFaceExtras > 1 )
18213 {
18214 v4 = 1;
18215 do
18216 {
18217 if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 )
18218 {
18219 v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C];
18220 if ( BYTE1(v5->uAttributes) & 0x40 )
18221 {
18222 pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(
18223 Str2);
18224 v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID;
18225 if ( *(_WORD *)v6 )
18226 {
18227 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6);
18228 }
18229 else
18230 {
18231 *(_WORD *)v6 = v3;
18232 v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
18233 v7[1] &= 0xBFu;
18234 }
18235 }
18236 else
18237 {
18238 v5->uBitmapID = v3;
18239 }
18240 }
18241 ++v17;
18242 ++v4;
18243 }
18244 while ( v17 < (signed int)pIndoor->uNumFaceExtras );
18245 }
18246 pParty->uFlags |= 2u;
18247 }
18248 else
18249 {
18250 v15 = 0;
18251 if ( (signed int)pOutdoor->uNumBModels > 0 )
18252 {
18253 v16 = 0;
18254 do
18255 {
18256 v8 = 0;
18257 v9 = (char *)&pOutdoor->pBModels[v16].pVertices;
18258 v18 = 0;
18259 if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 )
18260 {
18261 do
18262 {
18263 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
18264 if ( v10->sCogNumber == v14 )
18265 {
18266 if ( BYTE1(v10->uAttributes) & 0x40 )
18267 {
18268 *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
18269 Str2);
18270 v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272);
18271 if ( *(_WORD *)v11 )
18272 {
18273 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11);
18274 }
18275 else
18276 {
18277 *(_WORD *)v11 = v12;
18278 *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu;
18279 }
18280 }
18281 else
18282 {
18283 v10->uTextureID = v12;
18284 }
18285 }
18286 ++v18;
18287 v8 += 308;
18288 }
18289 while ( v18 < *((_DWORD *)v9 + 2) );
18290 }
18291 ++v15;
18292 ++v16;
18293 }
18294 while ( v15 < (signed int)pOutdoor->uNumBModels );
18295 }
18296 }
18297 pParty->uFlags |= 2u;
18298 }
18299 }
18300 }
18301
18302
18303
18304
18305 //----- (0044882F) --------------------------------------------------------
18306 void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName)
18307 {
18308 signed int v3; // ebp@1
18309 char *v4; // esi@2
18310 unsigned __int16 v5; // ax@6
18311 unsigned int v6; // [sp+4h] [bp-8h]@1
18312 int v7; // [sp+8h] [bp-4h]@1
18313
18314 v3 = 0;
18315 v7 = a2;
18316 v6 = uCog;
18317 if ( (signed int)uNumLevelDecorations > 0 )
18318 {
18319 v4 = (char *)&pLevelDecorations[0].field_2;
18320 do
18321 {
18322 if ( *((_WORD *)v4 + 9) == v6 )
18323 {
18324 if ( pFileName && _strcmpi(pFileName, "0") )
18325 {
18326 v5 = pDecorationList->GetDecorIdByName(pFileName);
18327 *((_WORD *)v4 - 1) = v5;
18328 pDecorationList->InitializeDecorationSprite((signed __int16)v5);
18329 }
18330 if ( v7 )
18331 *v4 &= 0xDFu;
18332 else
18333 *v4 |= 0x20u;
18334 pParty->uFlags |= 2u;
18335 }
18336 ++v3;
18337 v4 += 32;
18338 }
18339 while ( v3 < (signed int)uNumLevelDecorations );
18340 }
18341 }
18342
18343
18344 //----- (004488B6) --------------------------------------------------------
18345 unsigned __int16 DecorationList::GetDecorIdByName(const char *pName)
18346 {
18347 DecorationList *v2; // esi@1
18348 signed int uID; // edi@2
18349 signed int v4; // ebx@3
18350 unsigned __int16 result; // ax@6
18351
18352 v2 = this;
18353 if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) )
18354 {
18355 v4 = 1;
18356 while ( _strcmpi(pName, v2->pDecorations[v4].pName) )
18357 {
18358 ++uID;
18359 ++v4;
18360 if ( uID >= (signed int)v2->uNumDecorations )
18361 goto LABEL_6;
18362 }
18363 result = uID;
18364 }
18365 else
18366 {
18367 LABEL_6:
18368 result = 0;
18369 }
18370 return result;
18371 }
18372
18373
18374 //----- (0044892E) --------------------------------------------------------
18375 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
18376 {
18377 signed int v3; // esi@2
18378 signed int v4; // ecx@4
18379 char *v5; // eax@6
18380 int v6; // edi@13
18381 char *v7; // esi@13
18382 signed int v8; // ecx@13
18383 ODMFace *v9; // eax@14
18384 int v10; // [sp+0h] [bp-Ch]@1
18385 signed int v11; // [sp+4h] [bp-8h]@11
18386 int v12; // [sp+8h] [bp-4h]@12
18387
18388 v10 = sCogNumber;
18389 if ( sCogNumber )
18390 {
18391 v3 = 1;
18392 if ( uCurrentlyLoadedLevelType == 1 )
18393 {
18394 if ( (signed int)pIndoor->uNumFaceExtras > 1 )
18395 {
18396 v4 = 1;
18397 do
18398 {
18399 if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 )
18400 {
18401 v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
18402 if ( on )
18403 *(_DWORD *)v5 |= bit;
18404 else
18405 *(_DWORD *)v5 &= ~bit;
18406 }
18407 ++v3;
18408 ++v4;
18409 }
18410 while ( v3 < (signed int)pIndoor->uNumFaceExtras );
18411 }
18412 pParty->uFlags |= 2u;
18413 }
18414 else
18415 {
18416 v11 = 0;
18417 if ( (signed int)pOutdoor->uNumBModels > 0 )
18418 {
18419 v12 = 0;
18420 do
18421 {
18422 v6 = 0;
18423 v7 = (char *)&pOutdoor->pBModels[v12].pVertices;
18424 v8 = 0;
18425 if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 )
18426 {
18427 do
18428 {
18429 v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4));
18430 if ( v9->sCogNumber == v10 )
18431 {
18432 if ( on )
18433 v9->uAttributes |= bit;
18434 else
18435 v9->uAttributes &= ~bit;
18436 }
18437 ++v8;
18438 v6 += 308;
18439 }
18440 while ( v8 < *((_DWORD *)v7 + 2) );
18441 }
18442 ++v11;
18443 ++v12;
18444 }
18445 while ( v11 < (signed int)pOutdoor->uNumBModels );
18446 }
18447 }
18448 pParty->uFlags |= 2u;
18449 }
18450 }
18451
18452
18453 //----- (00448A17) --------------------------------------------------------
18454 void Chest::ToggleFlag(unsigned int uChestID, unsigned __int16 uFlag, unsigned int bToggle)
18455 {
18456 unsigned __int16 *pFlags; // eax@3
18457
18458 if ( (uChestID & 0x80000000u) == 0 && (signed int)uChestID <= 19 )
18459 {
18460 pFlags = &pChests[uChestID].uFlags;
18461 if ( bToggle )
18462 *pFlags |= uFlag;
18463 else
18464 *pFlags &= ~uFlag;
18465 }
18466 }
18467
18468 //----- (00448A40) --------------------------------------------------------
18469 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle)
18470 {
18471 if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) )
18472 {
18473 if ( bToggle )
18474 {
18475 pActors[uActorID].uAttributes |= uFlag;
18476 }
18477 else
18478 {
18479 if ( uFlag == 0x10000 )
18480 {
18481 if (pActors[uActorID].uAIState == Disabled )
18482 pActors[uActorID].uAIState = Standing;
18483 }
18484 pActors[uActorID].uAttributes &= ~uFlag;
18485 }
18486 }
18487 }
18488
18489 //----- (00448A98) --------------------------------------------------------
18490 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
18491 {
18492 unsigned int v3; // ebx@1
18493 unsigned int v4; // ebp@1
18494 signed int v5; // edi@1
18495 char *v6; // esi@4
18496 size_t v7; // ecx@10
18497 char *v8; // eax@11
18498 unsigned __int16 v9; // dx@14
18499
18500 v4 = uGroupID;
18501 v5 = Standing;
18502 v3 = uFlag;
18503 if ( uGroupID )
18504 {
18505 if ( bToggle )
18506 {
18507 if ( (signed int)uNumActors > Standing )
18508 {
18509 v6 = (char *)&pActors[0].uAttributes;
18510 do
18511 {
18512 if ( *((_DWORD *)v6 + 168) == v4 )
18513 {
18514 *(_DWORD *)v6 |= v3;
18515 if ( v3 == 0x10000 )
18516 {
18517 *((_WORD *)v6 + 70) = Disabled;
18518 ((Actor *)(v6 - 36))->UpdateAnimation();
18519 }
18520 }
18521 ++v5;
18522 v6 += 836;
18523 }
18524 while ( v5 < (signed int)uNumActors );
18525 }
18526 }
18527 else
18528 {
18529 v7 = uNumActors;
18530 if ( (signed int)uNumActors > Standing )
18531 {
18532 v8 = (char *)&pActors[0].uAIState;
18533 do
18534 {
18535 if ( *((_DWORD *)v8 + 133) == v4 )
18536 {
18537 if ( v3 == 0x10000 )
18538 {
18539 v9 = *(_WORD *)v8;
18540 if ( *(_WORD *)v8 != Dead )
18541 {
18542 if ( v9 != 4 && v9 != 11 )
18543 *(_WORD *)v8 = Standing;
18544 }
18545 }
18546 *((_DWORD *)v8 - 35) &= ~v3;
18547 }
18548 v8 += 836;
18549 --v7;
18550 }
18551 while ( v7 );
18552 }
18553 }
18554 }
18555 }
18556
18557
18558 //----- (00448B45) --------------------------------------------------------
18559 void __thiscall GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
18560 {
18561 if ( bForceHide || GameUI_StatusBar_TimedStringTimeLeft && GetTickCount() >= GameUI_StatusBar_TimedStringTimeLeft )
18562 GameUI_StatusBar_TimedStringTimeLeft = 0;
18563 }
18564
18565 //----- (00448B67) --------------------------------------------------------
18566 void __thiscall OnTimer(int a1)
18567 {
18568 int v1; // ebp@1
18569 unsigned int v2; // ebx@4
18570 unsigned int v3; // edi@4
18571 char *v4; // esi@6
18572 __int16 v5; // ax@8
18573 int v6; // ecx@10
18574 unsigned int v7; // ebp@12
18575 int v8; // eax@16
18576 int v9; // eax@19
18577 unsigned __int64 v10; // qax@20
18578 int v11; // ecx@24
18579 int v12; // [sp+Ch] [bp-10h]@5
18580 unsigned int v13; // [sp+10h] [bp-Ch]@4
18581
18582 v1 = 0;
18583 if ( !pEventTimer->bPaused )
18584 {
18585 if ( a1 )
18586 dword_5773C0 = 0;
18587 v3 = HIDWORD(pParty->uTimePlayed);
18588 v2 = LODWORD(pParty->uTimePlayed);
18589 v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128;
18590 if ( v13 )
18591 {
18592 _5773B8_event_timer = pParty->uTimePlayed;
18593 v12 = 0;
18594 if ( dword_5B65C8 > 0 )
18595 {
18596 v4 = (char *)&array_5B5928[0].field_C;
18597 while ( 1 )
18598 {
18599 v5 = *(short *)v4;
18600 if ( *(short *)v4 != (short)v1 )
18601 break;
18602 v7 = *((int *)v4 - 2);
18603 if ( v7 <= v3 && (v7 < v3 || *((int *)v4 - 3) <= v2) )
18604 {
18605 if ( *((short *)v4 + 2) )
18606 {
18607 v8 = 29030400;
18608 }
18609 else
18610 {
18611 if ( *((short *)v4 + 3) )
18612 {
18613 v8 = 2419200;
18614 }
18615 else
18616 {
18617 v9 = -(*((short *)v4 + 4) != 0);
18618 v8 = (v9 & 0x7E900) + 86400;
18619 }
18620 }
18621 v10 = __PAIR__(v7, *((int *)v4 - 3)) + (signed __int64)((double)((signed __int64)v8 << 7) * 0.033333335);
18622 *((int *)v4 - 3) = v10;
18623 *((int *)v4 - 2) = HIDWORD(v10);
18624 if ( HIDWORD(v10) <= v3 && (HIDWORD(v10) < v3 || *((int *)v4 - 3) < v2) )
18625 {
18626 *((int *)v4 - 3) = v2;
18627 *((int *)v4 - 2) = v3;
18628 }
18629 v11 = *((short *)v4 - 2);
18630 dword_597F18 = *((short *)v4 - 1);
18631 EventProcessor(v11, 0, 1);
18632 dword_597F18 = 0;
18633 LABEL_25:
18634 v3 = HIDWORD(pParty->uTimePlayed);
18635 v2 = LODWORD(pParty->uTimePlayed);
18636 }
18637 LABEL_26:
18638 ++v12;
18639 v4 += 32;
18640 if ( v12 >= dword_5B65C8 )
18641 return;
18642 v1 = 0;
18643 }
18644 if ( v13 < v5 )
18645 {
18646 *(short *)v4 = v5 - v13;
18647 goto LABEL_26;
18648 }
18649 v6 = *((short *)v4 - 2);
18650 *(short *)v4 = *((short *)v4 + 1);
18651 dword_597F18 = *((short *)v4 - 1);
18652 EventProcessor(v6, 0, 1);
18653 dword_597F18 = v1;
18654 goto LABEL_25;
18655 }
18656 }
18657 }
18658 }
18659
18660 //----- (00481D77) --------------------------------------------------------
18661 void _outdoor_project(RenderVertexSoft *v)
18662 {
18663 double v1; // st7@1
18664 double v2; // st7@1
18665
18666 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001);
18667 v->flt_20 = v1;
18668 v2 = v1 * (double)pOutdoorCamera->int_fov_rad;
18669 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y;
18670 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z;
18671 }
18672
18673
18674 //----- (00448CF4) --------------------------------------------------------
18675 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName)
18676 {
18677 __int16 v8; // di@1
18678 __int16 v9; // si@1
18679 unsigned int v10; // eax@1
18680 size_t v11; // ebx@2
18681 signed int v12; // esi@2
18682 char *v13;//Actor_uYawAngle_cr *v13; // ebx@3
18683 AIDirection a3; // [sp+Ch] [bp-50h]@2
18684 AIDirection v15; // [sp+28h] [bp-34h]@2
18685 //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
18686
18687 v8 = typeindex;
18688 v9 = level;
18689
18690 SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
18691 //SpawnPointMM7::SpawnPointMM7(&v16);
18692
18693 v16.vPosition.x = x;
18694 v16.vPosition.y = y;
18695 v16.vPosition.z = z;
18696 v16.uGroup = group;
18697 v16.uRadius = 32;
18698 v16.uKind = 3;
18699 v16.uIndex = v8 + 2 * v9 + v9;
18700 v10 = pMapStats->GetMapInfo(pCurrentMapName);
18701 if ( v10 )
18702 {
18703 v11 = uNumActors;
18704 SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0);
18705 memcpy(&v15, Actor::GetDirectionInfo(8 * v11 | AI_OBJECT_ACTOR, 4u, &a3, 1), sizeof(v15));
18706 v12 = v11;
18707 if ( (signed int)v11 < (signed int)uNumActors )
18708 {
18709 v13 = (char *)&pActors[v11].uYawAngle;
18710 do
18711 {
18712 ((Actor *)((char *)v13 - 154))->PrepareSprites(0);
18713 ++v12;
18714 *(short *)v13/*->uYawAngle*/ = LOWORD(v15.uYawAngle);
18715 *(int *)(v13+666)/*->dword_000334_unique_name*/ = uUniqueName;
18716 ++v13;
18717 }
18718 while ( v12 < (signed int)uNumActors );
18719 }
18720 }
18721 }
18722
18723
18724 //----- (00448DF8) --------------------------------------------------------
18725 void __fastcall sub_448DF8_cast_spell(int spellnum, int rank, int level, int fromx, int fromy, int fromz, int tox, int toy, int toz)
18726 {
18727 int v9; // esi@1
18728 double v10; // st7@4
18729 double v11; // st6@4
18730 double v12; // st5@4
18731 double v13; // st7@6
18732 int v14; // ST44_4@7
18733 signed int v15; // ebx@9
18734 signed int v16; // edx@15
18735 char *v17; // ecx@16
18736 unsigned __int16 v18; // ax@20
18737 char *v19; // ecx@31
18738 int v20; // edx@35
18739 signed int v21; // edx@37
18740 char *v22; // ecx@38
18741 unsigned __int16 v23; // ax@41
18742 int i; // esi@42
18743 signed int v25; // edx@55
18744 char *v26; // ecx@56
18745 unsigned __int16 v27; // ax@59
18746 int j; // esi@60
18747 signed int v29; // edx@66
18748 char *v30; // ecx@67
18749 unsigned __int16 v31; // ax@70
18750 char *v32; // eax@80
18751 unsigned __int16 v33; // si@85
18752 int v34; // eax@96
18753 int v35; // eax@97
18754 unsigned __int64 v36; // qax@99
18755 SpellBuff *v37; // ecx@99
18756 int v38; // esi@103
18757 signed __int64 v39; // qax@105
18758 int v40; // ebx@108
18759 int v41; // ebx@109
18760 int v42; // esi@111
18761 int v43; // ebx@111
18762 int v44; // eax@117
18763 unsigned __int16 v45; // si@137
18764 unsigned __int16 v46; // [sp-8h] [bp-BCh]@99
18765 int v47; // [sp-4h] [bp-B8h]@35
18766 unsigned __int16 v48; // [sp-4h] [bp-B8h]@99
18767 int v49; // [sp+0h] [bp-B4h]@35
18768 int v50; // [sp+0h] [bp-B4h]@99
18769 int v51; // [sp+4h] [bp-B0h]@35
18770 unsigned __int8 v52; // [sp+4h] [bp-B0h]@99
18771 float v53; // [sp+14h] [bp-A0h]@4
18772 float v54; // [sp+18h] [bp-9Ch]@4
18773 int v55; // [sp+28h] [bp-8Ch]@7
18774 unsigned int yaw; // [sp+30h] [bp-84h]@7
18775 int pitch; // [sp+34h] [bp-80h]@7
18776 //LayingItem a1; // [sp+38h] [bp-7Ch]@12
18777 int v59; // [sp+A8h] [bp-Ch]@1
18778 int v60; // [sp+ACh] [bp-8h]@1
18779 int spellnum_; // [sp+B0h] [bp-4h]@1
18780 signed int levela; // [sp+BCh] [bp+8h]@80
18781 int a6_4; // [sp+C8h] [bp+14h]@117
18782 float a7a; // [sp+CCh] [bp+18h]@6
18783 signed int a7b; // [sp+CCh] [bp+18h]@12
18784 int a7c; // [sp+CCh] [bp+18h]@29
18785 int a7d; // [sp+CCh] [bp+18h]@55
18786 float a8a; // [sp+D0h] [bp+1Ch]@6
18787 int a8b; // [sp+D0h] [bp+1Ch]@37
18788 int a8c; // [sp+D0h] [bp+1Ch]@55
18789 float toza; // [sp+D4h] [bp+20h]@6
18790
18791 v9 = 0;
18792 v59 = rank + 1;
18793 spellnum_ = spellnum;
18794 v60 = 0;
18795 if ( tox || toy || toz )
18796 {
18797 v10 = (double)tox - (double)fromx;
18798 v53 = v10;
18799 v11 = (double)toy - (double)fromy;
18800 v54 = v11;
18801 v12 = (double)toz;
18802 }
18803 else
18804 {
18805 v10 = (double)pParty->vPosition.x - (double)fromx;
18806 v53 = v10;
18807 v11 = (double)pParty->vPosition.y - (double)fromy;
18808 v54 = v11;
18809 v12 = (double)(pParty->vPosition.z + pParty->sEyelevel);
18810 }
18811 a7a = v12 - (double)fromz;
18812 toza = v11 * v11;
18813 a8a = v10 * v10;
18814 v13 = sqrt(a7a * a7a + a8a + toza);
18815 if ( v13 <= 1.0 )
18816 {
18817 LOBYTE(v55) = 1;
18818 yaw = 0;
18819 pitch = 0;
18820 }
18821 else
18822 {
18823 v55 = (signed __int64)v13;
18824 v14 = (signed __int64)sqrt(a8a + toza);
18825 yaw = stru_5C6E00->Atan2((signed __int64)v53, (signed __int64)v54);
18826 pitch = stru_5C6E00->Atan2(v14, (signed __int64)a7a);
18827 }
18828 v15 = v59;
18829 if ( v59 <= 0 || v59 > 4 )
18830 v15 = 1;
18831 a7b = v15;
18832
18833 LayingItem a1; // [sp+38h] [bp-7Ch]@12
18834 //LayingItem::LayingItem(&a1);
18835
18836 a1.uItemType = stru_4E3ACC[spellnum_].uItemType;
18837 if ( spellnum_ > 58 )
18838 {
18839 if ( spellnum_ == 69 )
18840 goto LABEL_117;
18841 if ( spellnum_ != 83 )
18842 return;
18843 v40 = v15 - 2;
18844 if ( v40 )
18845 {
18846 v41 = v40 - 1;
18847 if ( !v41 )
18848 {
18849 v42 = 14400 * level;
18850 v43 = 4 * level + 10;
18851 goto LABEL_114;
18852 }
18853 if ( v41 == 1 )
18854 {
18855 v42 = 18000 * level;
18856 v43 = 5 * level + 10;
18857 goto LABEL_114;
18858 }
18859 }
18860 v42 = 10800 * level;
18861 v43 = 3 * level + 10;
18862 LABEL_114:
18863 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 0);
18864 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 1u);
18865 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 2u);
18866 pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 3u);
18867 v52 = 0;
18868 v50 = 0;
18869 v48 = v43;
18870 v46 = a7b;
18871 v39 = (signed __int64)((double)(v42 << 7) * 0.033333335);
18872 v37 = &pParty->pPartyBuffs[2];
18873 LABEL_115:
18874 v36 = pParty->uTimePlayed + v39;
18875 LABEL_116:
18876 v37->Apply(v36, v46, v48, v50, v52);
18877 goto LABEL_139;
18878 }
18879 if ( spellnum_ != 58 )
18880 {
18881 switch ( spellnum_ )
18882 {
18883 case 2:
18884 case 6:
18885 case 18:
18886 case 26:
18887 case 29:
18888 case 32:
18889 case 39:
18890 case 41:
18891 a1.stru_24.Reset();
18892 v16 = 0;
18893 a1.field_48 = spellnum_;
18894 a1.field_4C = level;
18895 a1.field_50 = v15;
18896 if ( (signed int)pObjectList->uNumObjects <= 0 )
18897 goto LABEL_34;
18898 v17 = (char *)&pObjectList->pObjects->uObjectID;
18899 while ( (short)a1.uItemType != *(short *)v17 )
18900 {
18901 ++v16;
18902 v17 += 56;
18903 if ( v16 >= (signed int)pObjectList->uNumObjects )
18904 goto LABEL_34;
18905 }
18906 LABEL_20:
18907 v18 = v16;
18908 goto LABEL_35;
18909 case 24:
18910 switch ( v15 )
18911 {
18912 case 1:
18913 v60 = 1;
18914 break;
18915 case 2:
18916 v60 = 3;
18917 break;
18918 case 3:
18919 v60 = 5;
18920 break;
18921 case 4:
18922 v60 = 7;
18923 break;
18924 }
18925 a7c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
18926 if ( v60 != 1 )
18927 {
18928 a8b = a7c / (v60 - 1);
18929 a1.stru_24.Reset();
18930 v21 = 0;
18931 a1.field_48 = spellnum_;
18932 a1.field_4C = level;
18933 a1.field_50 = v15;
18934 if ( (signed int)pObjectList->uNumObjects <= 0 )
18935 {
18936 LABEL_41:
18937 v23 = 0;
18938 }
18939 else
18940 {
18941 v22 = (char *)&pObjectList->pObjects->uObjectID;
18942 while ( (short)a1.uItemType != *(short *)v22 )
18943 {
18944 ++v21;
18945 v22 += 56;
18946 if ( v21 >= (signed int)pObjectList->uNumObjects )
18947 goto LABEL_41;
18948 }
18949 v23 = v21;
18950 }
18951 a1.uObjectDescID = v23;
18952 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
18953 a1.vPosition.x = fromx;
18954 a1.uAttributes = 16;
18955 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
18956 a1.field_60_distance_related_prolly_lod = v55;
18957 a1.uSpriteFrameID = 0;
18958 a1.field_58 = 8002;
18959 a1.field_5C = 4;
18960 a1.uSoundID = 0;
18961 for ( i = a7c / -2; i <= a7c / 2; i += a8b )
18962 {
18963 a1.uFacing = i + yaw;
18964 a1.Create(
18965 (signed __int16)(i + (short)yaw),
18966 pitch,
18967 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
18968 0);
18969 }
18970 goto LABEL_139;
18971 }
18972 a1.stru_24.Reset();
18973 v16 = 0;
18974 a1.field_48 = spellnum_;
18975 a1.field_4C = level;
18976 a1.field_50 = v15;
18977 if ( (signed int)pObjectList->uNumObjects <= 0 )
18978 goto LABEL_34;
18979 v19 = (char *)&pObjectList->pObjects->uObjectID;
18980 do
18981 {
18982 if ( (short)a1.uItemType == *(short *)v19 )
18983 goto LABEL_20;
18984 ++v16;
18985 v19 += 56;
18986 }
18987 while ( v16 < (signed int)pObjectList->uNumObjects );
18988 LABEL_34:
18989 v18 = 0;
18990 LABEL_35:
18991 a1.uObjectDescID = v18;
18992 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
18993 a1.vPosition.x = fromx;
18994 a1.uAttributes = 16;
18995 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
18996 a1.field_60_distance_related_prolly_lod = v55;
18997 v20 = yaw;
18998 a1.uSpriteFrameID = 0;
18999 a1.field_58 = 8002;
19000 a1.field_5C = 0;
19001 a1.uFacing = yaw;
19002 a1.uSoundID = 0;
19003 v51 = 0;
19004 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
19005 v47 = pitch;
19006 goto LABEL_36;
19007 case 15:
19008 switch ( v15 )
19009 {
19010 case 1:
19011 v60 = 3;
19012 break;
19013 case 2:
19014 v60 = 5;
19015 break;
19016 case 3:
19017 v60 = 7;
19018 break;
19019 case 4:
19020 v60 = 9;
19021 break;
19022 }
19023 a7d = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
19024 a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1);
19025 a1.stru_24.Reset();
19026 v25 = 0;
19027 a1.field_48 = spellnum_;
19028 a1.field_4C = level;
19029 a1.field_50 = v15;
19030 if ( (signed int)pObjectList->uNumObjects <= 0 )
19031 goto LABEL_59;
19032 v26 = (char *)&pObjectList->pObjects->uObjectID;
19033 while ( (short)a1.uItemType != *(short *)v26 )
19034 {
19035 ++v25;
19036 v26 += 56;
19037 if ( v25 >= (signed int)pObjectList->uNumObjects )
19038 {
19039 LABEL_59:
19040 v27 = 0;
19041 goto LABEL_60;
19042 }
19043 }
19044 v27 = v25;
19045 LABEL_60:
19046 a1.uObjectDescID = v27;
19047 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
19048 a1.vPosition.x = fromx;
19049 a1.uAttributes = 16;
19050 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
19051 a1.field_60_distance_related_prolly_lod = v55;
19052 a1.uSpriteFrameID = 0;
19053 a1.field_58 = 8002;
19054 a1.field_5C = 4;
19055 a1.uSoundID = 0;
19056 for ( j = a7d / -2; j <= a7d / 2; j += a8c )
19057 {
19058 a1.uFacing = j + yaw;
19059 a1.Create(
19060 (signed __int16)(j + (short)yaw),
19061 pitch,
19062 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
19063 0);
19064 }
19065 goto LABEL_139;
19066 case 43:
19067 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
19068 return;
19069 a1.stru_24.Reset();
19070 v29 = 0;
19071 a1.field_48 = spellnum_;
19072 a1.field_4C = level;
19073 a1.field_50 = v15;
19074 if ( (signed int)pObjectList->uNumObjects <= 0 )
19075 goto LABEL_70;
19076 v30 = (char *)&pObjectList->pObjects->uObjectID;
19077 break;
19078 case 5:
19079 if ( v15 > 0 )
19080 {
19081 if ( v15 <= 2 )
19082 {
19083 v9 = 60 * (level + 60);
19084 }
19085 else
19086 {
19087 if ( v15 == 3 )
19088 {
19089 v9 = 180 * (level + 20);
19090 }
19091 else
19092 {
19093 if ( v15 == 4 )
19094 v9 = 240 * (level + 15);
19095 }
19096 }
19097 }
19098 levela = 1;
19099 v32 = (char *)&pParty->pPlayers[0].pConditions[1];
19100 do
19101 {
19102 if ( *(_QWORD *)v32 )
19103 levela = 0;
19104 v32 += 6972;
19105 }
19106 while ( (signed int)v32 < (signed int)&pParty->pHirelings[0].uFlags );
19107 if ( !levela )
19108 return;
19109 pParty->pPartyBuffs[8].Apply(
19110 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335),
19111 v15,
19112 0,
19113 0,
19114 0);
19115 v33 = spellnum_;
19116 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
19117 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 1u);
19118 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 2u);
19119 pGame->pStru6Instance->SetPlayerBuffAnim(v33, 3u);
19120 goto LABEL_138;
19121 case 17:
19122 case 38:
19123 case 51:
19124 switch ( v15 )
19125 {
19126 case 1:
19127 case 2:
19128 v9 = 300 * (level + 12);
19129 break;
19130 case 3:
19131 v9 = 900 * (level + 4);
19132 break;
19133 case 4:
19134 v9 = 3600 * (level + 1);
19135 break;
19136 }
19137 switch ( spellnum_ )
19138 {
19139 case 17:
19140 v60 = 0;
19141 level = 14;
19142 break;
19143 case 38:
19144 v35 = level + 5;
19145 level = 15;
19146 v60 = v35;
19147 break;
19148 case 51:
19149 v34 = level + 5;
19150 level = 9;
19151 v60 = v34;
19152 break;
19153 }
19154 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
19155 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 1u);
19156 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 2u);
19157 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 3u);
19158 v52 = 0;
19159 v50 = 0;
19160 v48 = v60;
19161 v46 = v15;
19162 v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335);
19163 v37 = &pParty->pPartyBuffs[level];
19164 goto LABEL_116;
19165 case 8:
19166 if ( v15 == 2 || v15 == 3 || v15 != 4 )
19167 v38 = 60 * level;
19168 else
19169 v38 = 600 * level;
19170 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
19171 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 1u);
19172 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 2u);
19173 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 3u);
19174 v52 = 0;
19175 v50 = 0;
19176 v48 = level;
19177 v46 = v15;
19178 v39 = (signed __int64)((double)(v38 << 7) * 0.033333335);
19179 v37 = &pParty->pPartyBuffs[10];
19180 goto LABEL_115;
19181 case 3:
19182 case 14:
19183 case 25:
19184 case 36:
19185 goto LABEL_117;
19186 default:
19187 return;
19188 }
19189 while ( (short)a1.uItemType != *(short *)v30 )
19190 {
19191 ++v29;
19192 v30 += 56;
19193 if ( v29 >= (signed int)pObjectList->uNumObjects )
19194 {
19195 LABEL_70:
19196 v31 = 0;
19197 goto LABEL_71;
19198 }
19199 }
19200 v31 = v29;
19201 LABEL_71:
19202 a1.uObjectDescID = v31;
19203 *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
19204 a1.vPosition.x = fromx;
19205 a1.uAttributes = 16;
19206 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
19207 a1.field_60_distance_related_prolly_lod = v55;
19208 a1.uSpriteFrameID = 0;
19209 a1.field_58 = 8002;
19210 a1.field_5C = 4;
19211 a1.uSoundID = 0;
19212 v51 = 0;
19213 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
19214 v20 = yaw;
19215 v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
19216 LABEL_36:
19217 a1.Create(v20, v47, v49, v51);
19218 goto LABEL_139;
19219 }
19220 LABEL_117:
19221 v44 = level;
19222 a6_4 = 3600 * level;
19223 if ( v15 == 1 )
19224 {
19225 LABEL_124:
19226 v60 = v44;
19227 goto LABEL_125;
19228 }
19229 if ( v15 == 2 )
19230 {
19231 v44 = 2 * level;
19232 goto LABEL_124;
19233 }
19234 if ( v15 == 3 )
19235 {
19236 v44 = 3 * level;
19237 goto LABEL_124;
19238 }
19239 if ( v15 == 4 )
19240 {
19241 v44 = 4 * level;
19242 goto LABEL_124;
19243 }
19244 LABEL_125:
19245 switch ( spellnum_ )
19246 {
19247 case 3:
19248 level = 6;
19249 break;
19250 case 14:
19251 level = 0;
19252 break;
19253 case 25:
19254 level = 17;
19255 break;
19256 case 36:
19257 level = 4;
19258 break;
19259 case 58:
19260 level = 12;
19261 break;
19262 case 69:
19263 level = 1;
19264 break;
19265 }
19266 v45 = spellnum_;
19267 pGame->pStru6Instance->SetPlayerBuffAnim(spellnum_, 0);
19268 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 1u);
19269 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 2u);
19270 pGame->pStru6Instance->SetPlayerBuffAnim(v45, 3u);
19271 pParty->pPartyBuffs[level].Apply(
19272 pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669),
19273 v15,
19274 v60,
19275 0,
19276 0);
19277 levela = 1;
19278 LABEL_138:
19279 if ( levela )
19280 LABEL_139:
19281 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[spellnum_], 0, 0, fromx, fromy, 0, 0, 0);
19282 }
19283 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
19284
19285 //----- (0044987B) --------------------------------------------------------
19286 char *__fastcall sub_44987B(const char *pMapName, unsigned int uStartingPointType)
19287 {
19288 const char *v2; // edi@1
19289 unsigned int v3; // ebx@1
19290 char *result; // eax@3
19291
19292 v2 = pMapName;
19293 v3 = uStartingPointType;
19294 pAudioPlayer->StopChannels(-1, -1);
19295 pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)0);
19296 if ( _strcmpi(pCurrentMapName, v2) )
19297 SaveGame(1, 0);
19298 uGameState = 2;
19299 result = strcpy(pCurrentMapName, v2);
19300 uLevel_StartingPointType = v3;
19301 return result;
19302 }
19303 // 6BE35C: using guessed type int uLevel_StartingPointType;
19304
19305 //----- (004498D5) --------------------------------------------------------
19306 void __thiscall TeleportToStartingPoint(unsigned int uPointType)
19307 {
19308 unsigned int v1; // ecx@2
19309 int v2; // ecx@3
19310 int v3; // ecx@4
19311 unsigned __int16 v4; // ax@11
19312 signed int v5; // ecx@12
19313 LevelDecoration *v6; // edx@13
19314 signed int v7; // ecx@17
19315 int v8; // eax@17
19316 int v9; // ecx@17
19317 const char *v10; // [sp-4h] [bp-84h]@6
19318 char pName[128]; // [sp+8h] [bp-78h]@11
19319
19320 if ( uPointType )
19321 {
19322 v1 = uPointType - 1;
19323 if ( v1 )
19324 {
19325 v2 = v1 - 1;
19326 if ( v2 )
19327 {
19328 v3 = v2 - 1;
19329 if ( v3 )
19330 {
19331 if ( v3 != 1 )
19332 return;
19333 v10 = "West Start";
19334 }
19335 else
19336 {
19337 v10 = "East Start";
19338 }
19339 }
19340 else
19341 {
19342 v10 = "South Start";
19343 }
19344 }
19345 else
19346 {
19347 v10 = "North Start";
19348 }
19349 }
19350 else
19351 {
19352 v10 = "Party Start";
19353 }
19354 strcpy(pName, v10);
19355 v4 = pDecorationList->GetDecorIdByName(pName);
19356 if ( v4 )
19357 {
19358 v5 = 0;
19359 if ( (signed int)uNumLevelDecorations > 0 )
19360 {
19361 v6 = pLevelDecorations;
19362 while ( v6->uDecorationDescID != (signed __int16)v4 )
19363 {
19364 ++v5;
19365 ++v6;
19366 if ( v5 >= (signed int)uNumLevelDecorations )
19367 goto LABEL_20;
19368 }
19369 v7 = v5;
19370 pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
19371 pParty->vPosition.y = pLevelDecorations[v7].vPosition.y;
19372 pParty->vPosition.z = pLevelDecorations[v7].vPosition.z;
19373 pParty->uFallStartY = pParty->vPosition.z;
19374 v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90;
19375 v9 = pLevelDecorations[v7].field_10_y_rot;
19376 pParty->sRotationY = v8;
19377 if ( v9 )
19378 pParty->sRotationY = v9;
19379 pParty->sRotationX = 0;
19380 pParty->uFallSpeed = 0;
19381 }
19382 LABEL_20:
19383 if ( dword_5B65C0 )
19384 {
19385 if ( _5B65A8_npcdata_uflags_or_other )
19386 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other;
19387 if ( _5B65AC_npcdata_fame_or_other )
19388 pParty->vPosition.y = _5B65AC_npcdata_fame_or_other;
19389 if ( _5B65B0_npcdata_rep_or_other )
19390 {
19391 pParty->vPosition.z = _5B65B0_npcdata_rep_or_other;
19392 pParty->uFallStartY = _5B65B0_npcdata_rep_or_other;
19393 }
19394 if ( _5B65B4_npcdata_loword_house_or_other )
19395 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
19396 if ( _5B65B8_npcdata_hiword_house_or_other )
19397 pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other;
19398 if ( dword_5B65BC )
19399 pParty->uFallSpeed = dword_5B65BC;
19400 }
19401 _5B65B4_npcdata_loword_house_or_other = -1;
19402 dword_5B65C0 = 0;
19403 dword_5B65BC = 0;
19404 _5B65B8_npcdata_hiword_house_or_other = 0;
19405 _5B65B0_npcdata_rep_or_other = 0;
19406 _5B65AC_npcdata_fame_or_other = 0;
19407 _5B65A8_npcdata_uflags_or_other = 0;
19408 }
19409 }
19410 // 5B65A8: using guessed type int _5B65A8_npcdata_uflags_or_other;
19411 // 5B65AC: using guessed type int _5B65AC_npcdata_fame_or_other;
19412 // 5B65B0: using guessed type int _5B65B0_npcdata_rep_or_other;
19413 // 5B65B4: using guessed type int _5B65B4_npcdata_loword_house_or_other;
19414 // 5B65B8: using guessed type int _5B65B8_npcdata_hiword_house_or_other;
19415 // 5B65BC: using guessed type int dword_5B65BC;
19416 // 5B65C0: using guessed type int dword_5B65C0;
19417
19418 //----- (00449A49) --------------------------------------------------------
19419 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2)
19420 {
19421 int v2; // eax@1
19422 int v3; // ebx@1
19423 signed int v4; // esi@2
19424 int v5; // edx@2
19425 BLVDoor *v6; // ecx@8
19426 unsigned int v7; // edx@18
19427 signed int v8; // esi@19
19428 int v9; // eax@19
19429 char Args; // [sp+Ch] [bp-78h]@6
19430
19431 LOWORD(v2) = LOWORD(pIndoor->pDoors);
19432 v3 = a2;
19433 if ( !pIndoor->pDoors )
19434 return v2;
19435 v4 = 0;
19436 v5 = (int)&pIndoor->pDoors->uDoorID;
19437 do
19438 {
19439 if ( *(int *)v5 == uDoorID )
19440 break;
19441 ++v4;
19442 v5 += 80;
19443 }
19444 while ( v4 < 200 );
19445 if ( v4 >= 200 )
19446 {
19447 sprintf(&Args, "Unable to find Door ID: %i!", uDoorID);
19448 Abortf(&Args);
19449 }
19450 v6 = &pIndoor->pDoors[v4];
19451 if ( v3 == 2 )
19452 {
19453 LOWORD(v2) = v6->uState;
19454 if ( (short)v2 == 3 || (short)v2 == 1 )
19455 return v2;
19456 if ( (short)v2 )
19457 goto LABEL_14;
19458 }
19459 else
19460 {
19461 if ( !v3 )
19462 {
19463 LABEL_14:
19464 LOWORD(v2) = v6->uState;
19465 if ( (short)v2 && (short)v2 != 3 )
19466 {
19467 v6->uState = BLVDoor::Closing;
19468 if ( (short)v2 == 2 )
19469 {
19470 LABEL_17:
19471 v6->uTimeSinceTriggered = 0;
19472 return v2;
19473 }
19474 v7 = v6->uTimeSinceTriggered;
19475 v2 = 15360;
19476 if ( v7 != 15360 )
19477 {
19478 v8 = v6->uOpenSpeed;
19479 v9 = v6->uCloseSpeed;
19480 LABEL_26:
19481 v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8;
19482 goto LABEL_27;
19483 }
19484 goto LABEL_27;
19485 }
19486 return v2;
19487 }
19488 if ( v3 != 1 )
19489 return v2;
19490 }
19491 LOWORD(v2) = v6->uState;
19492 if ( (short)v2 != 2 && (short)v2 != 1 )
19493 {
19494 v6->uState = BLVDoor::Opening;
19495 if ( !(short)v2 )
19496 goto LABEL_17;
19497 v7 = v6->uTimeSinceTriggered;
19498 v2 = 15360;
19499 if ( v7 != 15360 )
19500 {
19501 v8 = v6->uCloseSpeed;
19502 v9 = v6->uOpenSpeed;
19503 goto LABEL_26;
19504 }
19505 LABEL_27:
19506 v6->uTimeSinceTriggered = v2;
19507 }
19508 return v2;
19509 }
19510
19511 //----- (00449B57) --------------------------------------------------------
19512 unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
19513 {
19514 return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8);
19515 }
19516
19517 //----- (00449B7E) --------------------------------------------------------
19518 unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle)
19519 {
19520 signed int v3; // esi@1
19521 unsigned char *result; // eax@1
19522 unsigned int v5; // edx@1
19523
19524 v3 = a2 - 1;
19525 result = &pArray[v3 / 8];
19526 v5 = 0x80 >> v3 % 8;
19527 if ( bToggle )
19528 *result |= v5;
19529 else
19530 *result &= ~(unsigned char)v5;
19531 return result;
19532 }
19533
19534
19535 //----- (0044A56A) --------------------------------------------------------
19536 void __cdecl sub_44A56A()
19537 {
19538 signed int v0; // edi@1
19539 NPCData *v1; // esi@2
19540
19541 pParty->field_70A = 0;
19542 v0 = 0;
19543 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
19544 {
19545 v1 = pNPCStats->pNewNPCData;
19546 do
19547 {
19548 if ( v1->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v1->pName, pParty->pHirelings[0].pName)) )
19549 {
19550 if ( !pParty->pHirelings[1].pName || strcmp(v1->pName, pParty->pHirelings[1].pName) )
19551 ++pParty->field_70A;
19552 }
19553 ++v0;
19554 ++v1;
19555 }
19556 while ( v0 < (signed int)pNPCStats->uNumNewNPCs );
19557 }
19558 }
19559
19560
19561 //----- (0044C175) --------------------------------------------------------
19562 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds)
19563 {
19564 unsigned int v2; // esi@1
19565 int i; // eax@1
19566
19567 v2 = uNumSeconds;
19568 strcpy(GameUI_StatusBar_TimedString, pString);
19569 GameUI_StatusBar_TimedStringTimeLeft = 1000 * v2 + GetTickCount();
19570 for ( i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString);
19571 i > 450;
19572 i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString) )
19573 byte_5C3427[strlen(GameUI_StatusBar_TimedString)] = 0;
19574 }
19575
19576 //----- (0044C1D0) --------------------------------------------------------
19577 void __cdecl ShowNothingHereStatus()
19578 {
19579 if ( !GameUI_StatusBar_TimedStringTimeLeft )
19580 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
19581 }
19582
19583
19584 //----- (0044C28B) --------------------------------------------------------
19585 signed int __cdecl const_2()
19586 {
19587 return 2;
19588 }
19589
19590 //----- (0044C28F) --------------------------------------------------------
19591 bool __cdecl sub_44C28F_open_nwc_dungeon()
19592 {
19593 bool result; // eax@1
19594
19595 result = _strcmpi("nwc.blv", pCurrentMapName);
19596 if ( result )
19597 {
19598 _5B65A8_npcdata_uflags_or_other = 0;
19599 _5B65AC_npcdata_fame_or_other = 0;
19600 _5B65B0_npcdata_rep_or_other = 0;
19601 _5B65B4_npcdata_loword_house_or_other = 0;
19602 _5B65B8_npcdata_hiword_house_or_other = 0;
19603 dword_5B65BC = 0;
19604 dword_5B65C0 = 0;
19605 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
19606 sub_44987B("nwc.blv", 0);
19607 pCurrentScreen = 0;
19608 result = 1;
19609 }
19610 return result;
19611 }
19612
19613
19614 //----- (0044C2F4) --------------------------------------------------------
19615 int LevelDecoration::IsInteractive()
19616 {
19617 signed int v1; // eax@1
19618
19619 v1 = this->uDecorationDescID;
19620 if ( v1 > 34 )
19621 {
19622 if ( v1 == 184 || v1 == 187 || v1 == 190 || v1 > 205 && v1 <= 221 )
19623 return 1;
19624 }
19625 else
19626 {
19627 if ( v1 == 34 || v1 >= 4 && (v1 <= 6 || v1 == 11 || v1 > 12 && (v1 <= 14 || v1 == 24)) )
19628 return 1;
19629 }
19630 return 0;
19631 }
19632
19633 //----- (0044C362) --------------------------------------------------------
19634 void Vec3_int_::Normalize_float()
19635 {
19636 Vec3_int_ *v1; // esi@1
19637 double v2; // st6@1
19638 float v3; // ST20_4@1
19639 double v4; // st5@1
19640 float v5; // ST18_4@1
19641 double v6; // st4@1
19642 float v7; // ST14_4@1
19643 float v8; // ST24_4@1
19644 float v9; // ST20_4@1
19645 double v10; // ST0C_8@1
19646 float v11; // ST18_4@1
19647 double v12; // ST0C_8@1
19648 float v13; // ST14_4@1
19649 double v14; // ST0C_8@1
19650
19651 v1 = this;
19652 v2 = (double)this->x * 0.000015258789;
19653 v3 = v2;
19654 v4 = (double)this->y * 0.000015258789;
19655 v5 = v4;
19656 v6 = (double)this->z * 0.000015258789;
19657 v7 = v6;
19658 v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2);
19659 v9 = v8 * v3 * 65536.0;
19660 v10 = v9 + 6.7553994e15;
19661 v1->x = LODWORD(v10);
19662 v11 = v8 * v5 * 65536.0;
19663 v12 = v11 + 6.7553994e15;
19664 v1->y = LODWORD(v12);
19665 v13 = v8 * v7 * 65536.0;
19666 v14 = v13 + 6.7553994e15;
19667 v1->z = LODWORD(v14);
19668 }
19669
19670 //----- (0044C448) --------------------------------------------------------
19671 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...)
19672 {
19673 GUIFont *result; // eax@1
19674 const char *v3; // edi@1
19675 const char **v4; // ebx@2
19676 unsigned int v5; // eax@3
19677 unsigned __int16 **v6; // ecx@6
19678 GUIFont *v7; // [sp+4h] [bp-Ch]@1
19679 int v8; // [sp+8h] [bp-8h]@1
19680 unsigned __int16 **v9; // [sp+Ch] [bp-4h]@2
19681
19682 result = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0);
19683 v3 = pFontPalette;
19684 v8 = 0;
19685 v7 = result;
19686 if ( pFontPalette )
19687 {
19688 v4 = &pFontPalette;
19689 v9 = result->pFontPalettes;
19690 do
19691 {
19692 v5 = pIcons_LOD->LoadTexture(v3, TEXTURE_16BIT_PALETTE);
19693 if ( v5 == -1 )
19694 {
19695 sprintf(pTmpBuf, "Unable to open %s", v3);
19696 Abortf(pTmpBuf);
19697 }
19698 ++v4;
19699 v6 = v9;
19700 v3 = *v4;
19701 ++v8;
19702 ++v9;
19703 *v6 = (v5 != -1 ? pIcons_LOD->pTextures[v5].pPalette16 : 0);
19704 }
19705 while ( v3 );
19706 result = v7;
19707 }
19708 result->field_8 = v8;
19709 return result;
19710 }
19711
19712
19713
19714
19715 //----- (0044C768) --------------------------------------------------------
19716 char *__fastcall FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5)
19717 {
19718 const char *v5; // edi@1
19719 GUIFont *v6; // esi@1
19720 unsigned int v8; // eax@3
19721 int v9; // edi@3
19722 unsigned __int8 v10; // cl@4
19723 int v11; // edx@10
19724 GUICharMetric *v12; // ecx@10
19725 int v13; // edx@11
19726 int v14; // edx@12
19727 int v15; // edx@13
19728 unsigned int v16; // esi@15
19729 unsigned int v17; // edx@15
19730 unsigned int v18; // ecx@15
19731 int v19; // ebx@16
19732 unsigned __int8 v20; // zf@16
19733 char v21; // sf@16
19734 unsigned __int8 v22; // of@16
19735 int v23; // edi@16
19736 unsigned __int8 v24; // dl@17
19737 int v25; // edi@39
19738 int v26; // eax@42
19739 std::string v27; // [sp-18h] [bp-40h]@2
19740 const char *v28; // [sp-8h] [bp-30h]@2
19741 int v29; // [sp-4h] [bp-2Ch]@2
19742 const char *v30; // [sp+Ch] [bp-1Ch]@1
19743 char Str[3]; // [sp+10h] [bp-18h]@42
19744 char v32; // [sp+13h] [bp-15h]@42
19745 size_t v33; // [sp+14h] [bp-14h]@3
19746 unsigned int v34; // [sp+18h] [bp-10h]@3
19747 GUIFont *v35; // [sp+1Ch] [bp-Ch]@1
19748 int v36; // [sp+20h] [bp-8h]@3
19749 int v37; // [sp+24h] [bp-4h]@3
19750
19751 v5 = pInString;
19752 v6 = pFont;
19753 v30 = pInString;
19754 v35 = pFont;
19755 if ( !pInString )
19756 {
19757 MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
19758 return 0;
19759 }
19760 v33 = strlen(pInString);
19761 strcpy(pTmpBuf3, v5);
19762 v8 = uX;
19763 v9 = 0;
19764 v36 = 0;
19765 v34 = uX;
19766 v37 = 0;
19767 if ( (signed int)v33 > 0 )
19768 {
19769 while ( 1 )
19770 {
19771 v10 = pTmpBuf3[v9];
19772 if ((v10 < v6->cFirstChar || v10 > v6->cLastChar)
19773 && v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' )
19774 goto LABEL_34;
19775 v11 = v10 - 9;
19776 v12 = &v6->pMetrics[v10];
19777 if ( !v11 )
19778 {
19779 strncpy(Str, &pTmpBuf3[v9 + 1], 3u);
19780 v32 = 0;
19781 v26 = atoi(Str);
19782 v8 = uX + v26;
19783 v25 = v9 + 3;
19784 v34 = v8;
19785 goto LABEL_43;
19786 }
19787 v13 = v11 - 1;
19788 if ( !v13 )
19789 break;
19790 v14 = v13 - 2;
19791 if ( !v14 )
19792 {
19793 v25 = v9 + 5;
19794 LABEL_43:
19795 v37 = v25;
19796 goto LABEL_34;
19797 }
19798 v15 = v14 - 1;
19799 if ( v15 )
19800 {
19801 if ( v15 != 19 )
19802 {
19803 v16 = v12->uRightSpacing;
19804 v17 = v12->uWidth;
19805 v18 = v12->uLeftSpacing;
19806 if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth )
19807 {
19808 if ( v37 > v36 )
19809 v8 += v18;
19810 v8 += v17;
19811 if ( v37 < (signed int)v33 )
19812 v8 += v16;
19813 v6 = v35;
19814 }
19815 else
19816 {
19817 v19 = v36;
19818 v8 = v34;
19819 v22 = v36 > v37;
19820 v20 = v36 == v37;
19821 v21 = v36 - v37 < 0;
19822 v6 = v35;
19823 pTmpBuf3[v36] = 10;
19824 v23 = v19;
19825 if ( (unsigned __int8)(v21 ^ v22) | v20 )
19826 {
19827 do
19828 {
19829 v24 = pTmpBuf3[v23];
19830 if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 )
19831 {
19832 if ( v23 > v19 )
19833 v8 += v6->pMetrics[v24].uLeftSpacing;
19834 v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9);
19835 if ( v23 < v37 )
19836 v8 += v6->pMetrics[v24].uRightSpacing;
19837 }
19838 ++v23;
19839 }
19840 while ( v23 <= v37 );
19841 }
19842 }
19843 goto LABEL_34;
19844 }
19845 v8 += v12->uWidth;
19846 goto LABEL_41;
19847 }
19848 if ( !a5 )
19849 return (char *)v30;
19850 LABEL_34:
19851 v9 = v37++ + 1;
19852 if ( v37 >= (signed int)v33 )
19853 return pTmpBuf3;
19854 }
19855 v8 = v34;
19856 LABEL_41:
19857 v36 = v9;
19858 goto LABEL_34;
19859 }
19860 return pTmpBuf3;
19861 }
19862 //----- (00401000) --------------------------------------------------------
19863 void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int))
19864 {
19865 void *v4; // esi@2
19866 int v5; // edi@2
19867
19868 if ( numObjs - 1 >= 0 )
19869 {
19870 v4 = a1;
19871 v5 = numObjs;
19872 do
19873 {
19874 constructor((int)v4);
19875 v4 = (char *)v4 + objSize;
19876 --v5;
19877 }
19878 while ( v5 );
19879 }
19880 }
19881
19882
19883 //----- (004014E6) --------------------------------------------------------
19884 int __cdecl ODM_4014E6_AI()
19885 {
19886 int v0; // esi@2
19887 int v1; // eax@4
19888 int v2; // ebx@4
19889 unsigned int v3; // ecx@4
19890 int v4; // edx@5
19891 int v5; // edx@7
19892 unsigned int v6; // edx@9
19893 unsigned int v7; // ST20_4@10
19894 int v8; // eax@10
19895 int v9; // edi@10
19896 int v10; // ebx@14
19897 char v11; // zf@16
19898 int v12; // eax@22
19899 int result; // eax@24
19900 int v14; // edx@25
19901 int v15; // ecx@25
19902 int v16; // ebx@26
19903 unsigned int *v17; // ecx@27
19904 unsigned int v18; // esi@27
19905 int i; // edx@33
19906 char *v20; // ecx@34
19907 int v21; // [sp+Ch] [bp-14h]@4
19908 int v22; // [sp+10h] [bp-10h]@4
19909 int v23; // [sp+14h] [bp-Ch]@10
19910 int v24; // [sp+14h] [bp-Ch]@29
19911 signed int v25; // [sp+18h] [bp-8h]@1
19912 signed int v26; // [sp+18h] [bp-8h]@25
19913 int v27; // [sp+1Ch] [bp-4h]@1
19914
19915 pParty->uFlags &= 0xFFFFFFCFu;
19916 v27 = 0;
19917 v25 = 0;
19918 if ( (signed int)uNumActors > 0 )
19919 {
19920 v0 = (int)&pActors[0].uAttributes;
19921 do
19922 {
19923 *(char *)(v0 + 1) &= 0xFBu;
19924 if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
19925 goto LABEL_37;
19926 v22 = abs(pParty->vPosition.z - *(short *)(v0 + 110));
19927 v21 = abs(pParty->vPosition.y - *(short *)(v0 + 108));
19928 v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
19929 v2 = v21;
19930 v3 = v22;
19931 if ( v1 < v21 )
19932 {
19933 v4 = v1;
19934 v1 = v21;
19935 v2 = v4;
19936 }
19937 if ( v1 < v22 )
19938 {
19939 v5 = v1;
19940 v1 = v22;
19941 v3 = v5;
19942 }
19943 if ( v2 < (signed int)v3 )
19944 {
19945 v6 = v3;
19946 v3 = v2;
19947 v2 = v6;
19948 }
19949 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
19950 v8 = *(short *)(v0 + 100);
19951 v9 = v7 - v8;
19952 v23 = v7 - v8;
19953 if ( v23 < 0 )
19954 {
19955 v9 = 0;
19956 v23 = 0;
19957 }
19958 if ( v9 < 5632 )
19959 {
19960 v10 = *(int *)v0 & 0xFEFFFFFF;
19961 *(int *)v0 = v10;
19962 if ( v10 & 0x80000 || ((Actor *)(v0 - offsetof(Actor, uAttributes)))->GetActorsRelation(0) )
19963 {
19964 v11 = (pParty->uFlags & 0x10) == 0;
19965 *(int *)v0 = v10 | 0x1000000;
19966 if ( v11 && (double)v23 < 307.2 )
19967 pParty->uFlags |= 0x10u;
19968 if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
19969 pParty->uFlags |= 0x20u;
19970 }
19971 *(char *)(v0 + 1) |= 0x40u;
19972 v12 = v27++;
19973 ai_array_4F75E0[v12] = v9;
19974 ai_array_4F7DB0_actor_ids[v12] = v25;
19975 }
19976 else
19977 {
19978 LABEL_37:
19979 *(char *)(v0 + 1) &= 0xBFu;
19980 }
19981 ++v25;
19982 v0 += 836;
19983 }
19984 while ( v25 < (signed int)uNumActors );
19985 }
19986 result = v27;
19987 if ( v27 > 0 )
19988 {
19989 v14 = 0;
19990 v15 = 1;
19991 v26 = 1;
19992 do
19993 {
19994 while ( 1 )
19995 {
19996 v24 = v15;
19997 if ( v15 >= result )
19998 break;
19999 v16 = ai_array_4F75E0[v14];
20000 if ( v16 > ai_array_4F75E0[v15] )
20001 {
20002 v17 = &ai_array_4F7DB0_actor_ids[v15];
20003 v18 = ai_array_4F7DB0_actor_ids[v14];
20004 ai_array_4F7DB0_actor_ids[v14] = *v17;
20005 *v17 = v18;
20006 v15 = v24;
20007 ai_array_4F75E0[v14] = ai_array_4F75E0[v24];
20008 ai_array_4F75E0[v24] = v16;
20009 }
20010 result = v27;
20011 ++v15;
20012 }
20013 ++v14;
20014 v15 = v26 + 1;
20015 v26 = v15;
20016 }
20017 while ( v15 - 1 < result );
20018 }
20019 ai_arrays_size = result;
20020 if ( result > 30 )
20021 {
20022 result = 30;
20023 ai_arrays_size = 30;
20024 }
20025 for ( i = 0; i < result; ++i )
20026 {
20027 v20 = (char *)&pActors[ai_array_4F7DB0_actor_ids[i]].uAttributes;
20028 v20[1] |= 4u;
20029 }
20030 return result;
20031 }
20032 // 4F75D8: using guessed type int ai_arrays_size;
20033
20034 //----- (004016FA) --------------------------------------------------------
20035 int __cdecl BLV_4016FA_AI()
20036 {
20037 char *v0; // esi@2
20038 int v1; // eax@4
20039 int v2; // ebx@4
20040 unsigned int v3; // ecx@4
20041 int v4; // edx@5
20042 int v5; // edx@7
20043 unsigned int v6; // edx@9
20044 unsigned int v7; // ST24_4@10
20045 int v8; // eax@10
20046 int v9; // edi@10
20047 int v10; // ebx@14
20048 char v11; // zf@16
20049 int v12; // eax@22
20050 int v13; // edx@24
20051 int v14; // ecx@25
20052 int v15; // ebx@26
20053 unsigned int *v16; // ecx@27
20054 unsigned int v17; // esi@27
20055 int v18; // ecx@31
20056 signed int v19; // edi@31
20057 Actor *v20; // esi@32
20058 bool v21; // eax@33
20059 int v22; // eax@34
20060 signed int v23; // ebx@36
20061 char *v24; // esi@37
20062 signed int v25; // eax@40
20063 int v26; // eax@43
20064 int v27; // ebx@45
20065 int j; // edi@45
20066 unsigned int v29; // eax@46
20067 int v30; // eax@48
20068 int v31; // ecx@51
20069 int v32; // eax@51
20070 signed int v33; // eax@53
20071 __int64 v34; // qax@55
20072 char *v35; // ecx@56
20073 int v37; // [sp+Ch] [bp-18h]@1
20074 int v38; // [sp+10h] [bp-14h]@4
20075 int v39; // [sp+14h] [bp-10h]@4
20076 int v40; // [sp+18h] [bp-Ch]@10
20077 int v41; // [sp+18h] [bp-Ch]@29
20078 int i; // [sp+18h] [bp-Ch]@31
20079 signed int v43; // [sp+1Ch] [bp-8h]@1
20080 signed int v44; // [sp+1Ch] [bp-8h]@25
20081 int v45; // [sp+20h] [bp-4h]@1
20082
20083 pParty->uFlags &= 0xFFFFFFCFu;
20084 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
20085 v45 = 0;
20086 v43 = 0;
20087 if ( (signed int)uNumActors > 0 )
20088 {
20089 v0 = (char *)&pActors[0].uAttributes;
20090 do
20091 {
20092 v0[1] &= 0xFBu;
20093 if ( ! ((Actor *)(v0 - 36))->CanAct() )
20094 goto LABEL_60;
20095 v39 = abs(pParty->vPosition.z - *((short *)v0 + 55));
20096 v38 = abs(pParty->vPosition.y - *((short *)v0 + 54));
20097 v1 = abs(pParty->vPosition.x - *((short *)v0 + 53));
20098 v2 = v38;
20099 v3 = v39;
20100 if ( v1 < v38 )
20101 {
20102 v4 = v1;
20103 v1 = v38;
20104 v2 = v4;
20105 }
20106 if ( v1 < v39 )
20107 {
20108 v5 = v1;
20109 v1 = v39;
20110 v3 = v5;
20111 }
20112 if ( v2 < (signed int)v3 )
20113 {
20114 v6 = v3;
20115 v3 = v2;
20116 v2 = v6;
20117 }
20118 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
20119 v8 = *((short *)v0 + 50);
20120 v9 = v7 - v8;
20121 v40 = v7 - v8;
20122 if ( v40 < 0 )
20123 {
20124 v9 = 0;
20125 v40 = 0;
20126 }
20127 if ( v9 < 10240 )
20128 {
20129 v10 = *(int *)v0 & 0xFEFFFFFF;
20130 *(int *)v0 = v10;
20131 if ( v10 & 0x80000 || ((Actor *)(v0 - 36))->GetActorsRelation(0) )
20132 {
20133 v11 = (pParty->uFlags & 0x10) == 0;
20134 *(int *)v0 = v10 | 0x1000000;
20135 if ( v11 && (double)v40 < 307.2 )
20136 pParty->uFlags |= 0x10u;
20137 if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
20138 pParty->uFlags |= 0x20u;
20139 }
20140 v12 = v45++;
20141 ai_array_4F75E0[v12] = v9;
20142 ai_array_4F7DB0_actor_ids[v12] = v43;
20143 }
20144 else
20145 {
20146 LABEL_60:
20147 v0[1] &= 0xBFu;
20148 }
20149 ++v43;
20150 v0 += 836;
20151 }
20152 while ( v43 < (signed int)uNumActors );
20153 }
20154 v13 = 0;
20155 if ( v45 > 0 )
20156 {
20157 v14 = 1;
20158 v44 = 1;
20159 do
20160 {
20161 while ( 1 )
20162 {
20163 v41 = v14;
20164 if ( v14 >= v45 )
20165 break;
20166 v15 = ai_array_4F75E0[v13];
20167 if ( v15 > ai_array_4F75E0[v14] )
20168 {
20169 v16 = &ai_array_4F7DB0_actor_ids[v14];
20170 v17 = ai_array_4F7DB0_actor_ids[v13];
20171 ai_array_4F7DB0_actor_ids[v13] = *v16;
20172 *v16 = v17;
20173 v14 = v41;
20174 ai_array_4F75E0[v13] = ai_array_4F75E0[v41];
20175 ai_array_4F75E0[v41] = v15;
20176 }
20177 ++v14;
20178 }
20179 ++v13;
20180 v14 = v44 + 1;
20181 v44 = v14;
20182 }
20183 while ( v14 - 1 < v45 );
20184 }
20185 v18 = 0;
20186 v19 = 0;
20187 for ( i = 0; v18 < v45; i = v18 )
20188 {
20189 v20 = &pActors[ai_array_4F7DB0_actor_ids[v18]];
20190 if ( v20->uAttributes & 0x8000
20191 || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_array_4F7DB0_actor_ids[v18] | 3, 4u), v18 = i, v21) )
20192 {
20193 v22 = ai_array_4F7DB0_actor_ids[v18];
20194 v20->uAttributes |= 0x8000u;
20195 ai_array_4F6638_actor_ids[v19] = v22;
20196 ai_array_4F5E68[v19++] = ai_array_4F75E0[v18];
20197 if ( v19 >= 30 )
20198 break;
20199 }
20200 ++v18;
20201 }
20202 v23 = 0;
20203 ai_arrays_size = v19;
20204 if ( (signed int)uNumActors > 0 )
20205 {
20206 v24 = (char *)&pActors[0].uAttributes;
20207 do
20208 {
20209 if ( ((Actor *)(v24 - 36))->CanAct() && *((short *)v24 + 61) == v37 )
20210 {
20211 v25 = 0;
20212 if ( v19 <= 0 )
20213 {
20214 LABEL_43:
20215 v26 = ai_arrays_size;
20216 v24[1] |= 0x40u;
20217 ++ai_arrays_size;
20218 ai_array_4F6638_actor_ids[v26] = v23;
20219 }
20220 else
20221 {
20222 while ( ai_array_4F6638_actor_ids[v25] != v23 )
20223 {
20224 ++v25;
20225 if ( v25 >= v19 )
20226 goto LABEL_43;
20227 }
20228 }
20229 }
20230 ++v23;
20231 v24 += 836;
20232 }
20233 while ( v23 < (signed int)uNumActors );
20234 }
20235 v27 = ai_arrays_size;
20236 for ( j = 0; j < v45; ++j )
20237 {
20238 v29 = ai_array_4F7DB0_actor_ids[j];
20239 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() )
20240 {
20241 v30 = 0;
20242 if ( v27 <= 0 )
20243 {
20244 LABEL_51:
20245 v31 = ai_arrays_size;
20246 v32 = ai_array_4F7DB0_actor_ids[j];
20247 ++ai_arrays_size;
20248 ai_array_4F6638_actor_ids[v31] = v32;
20249 }
20250 else
20251 {
20252 while ( ai_array_4F6638_actor_ids[v30] != ai_array_4F7DB0_actor_ids[j] )
20253 {
20254 ++v30;
20255 if ( v30 >= v27 )
20256 goto LABEL_51;
20257 }
20258 }
20259 }
20260 }
20261 v33 = ai_arrays_size;
20262 if ( ai_arrays_size > 30 )
20263 {
20264 v33 = 30;
20265 ai_arrays_size = 30;
20266 }
20267 memcpy(ai_array_4F7DB0_actor_ids, ai_array_4F6638_actor_ids, 4 * v33);
20268 memcpy(ai_array_4F75E0, ai_array_4F5E68, 4 * ai_arrays_size);
20269 v34 = (unsigned int)ai_arrays_size;
20270 if ( ai_arrays_size > 0 )
20271 {
20272 do
20273 {
20274 v35 = (char *)&pActors[ai_array_4F7DB0_actor_ids[HIDWORD(v34)]].uAttributes;
20275 v35[1] |= 4u;
20276 ++HIDWORD(v34);
20277 }
20278 while ( SHIDWORD(v34) < (signed int)v34 );
20279 }
20280 return v34;
20281 }
20282 // 4F75D8: using guessed type int ai_arrays_size;
20283
20284 //----- (00401A91) --------------------------------------------------------
20285 void __cdecl sub_401A91_AI()
20286 {
20287 unsigned int v0; // esi@4
20288 int v1; // eax@7
20289 int v2; // ecx@7
20290 int v3; // eax@7
20291 signed int v4; // edi@10
20292 char *v5; // esi@12
20293 signed int v6; // eax@14
20294 __int16 v7; // cx@14
20295 Player **v8; // esi@20
20296 Player *pPlayer; // ecx@21
20297 Actor *pActor; // esi@34
20298 __int16 v11; // ax@34
20299 unsigned int v12; // eax@47
20300 signed int v13; // edi@47
20301 SpellBuff *v14; // ebx@47
20302 unsigned int v15; // edi@67
20303 char *v16; // eax@67
20304 unsigned int v17; // edx@67
20305 unsigned int v18; // ecx@67
20306 unsigned __int16 v19; // ax@72
20307 int *v20; // esi@80
20308 Actor *v21; // ebx@80
20309 unsigned __int16 v22; // ax@86
20310 signed int v23; // eax@94
20311 unsigned int v24; // eax@102
20312 signed int v25; // edi@102
20313 SpellBuff *v26; // esi@102
20314 unsigned int v27; // ecx@123
20315 unsigned int v28; // eax@123
20316 unsigned int v29; // eax@127
20317 AIDirection *v30; // eax@129
20318 unsigned __int16 v31; // ax@132
20319 unsigned int v32; // esi@142
20320 int v33; // eax@144
20321 int v34; // eax@147
20322 char v35; // al@150
20323 unsigned int v36; // edi@152
20324 signed int v37; // eax@154
20325 unsigned __int8 v38; // sf@158
20326 unsigned __int8 v39; // of@158
20327 signed int v40; // edx@166
20328 unsigned int v41; // ecx@166
20329 double v42; // st7@176
20330 double v43; // st6@176
20331 bool v44; // eax@189
20332 bool v45; // eax@192
20333 unsigned __int8 v46; // cl@197
20334 double v47; // st7@206
20335 double v48; // st7@207
20336 char v49; // zf@208
20337 char v50; // zf@214
20338 signed int v51; // edx@219
20339 unsigned int v52; // ecx@219
20340 __int16 v53; // fps@224
20341 unsigned __int8 v54; // c0@224
20342 unsigned __int8 v55; // c3@224
20343 double v56; // st7@226
20344 AIDirection *v57; // eax@246
20345 double v58; // st7@246
20346 signed int v59; // [sp-18h] [bp-C8h]@213
20347 int v60; // [sp-14h] [bp-C4h]@144
20348 int v61; // [sp-14h] [bp-C4h]@168
20349 AIDirection *v62; // [sp-14h] [bp-C4h]@213
20350 signed int v63; // [sp-14h] [bp-C4h]@216
20351 unsigned int v64; // [sp-14h] [bp-C4h]@219
20352 unsigned int v65; // [sp-10h] [bp-C0h]@144
20353 char v66; // [sp-10h] [bp-C0h]@147
20354 AIDirection *v67; // [sp-10h] [bp-C0h]@167
20355 int v68; // [sp-10h] [bp-C0h]@168
20356 AIDirection *v69; // [sp-10h] [bp-C0h]@206
20357 int v70; // [sp-10h] [bp-C0h]@213
20358 AIDirection *v71; // [sp-10h] [bp-C0h]@216
20359 AIDirection v72; // [sp+0h] [bp-B0h]@246
20360 AIDirection a3; // [sp+1Ch] [bp-94h]@129
20361 AIDirection v74; // [sp+38h] [bp-78h]@246
20362 AIDirection v75; // [sp+54h] [bp-5Ch]@129
20363 int v76; // [sp+70h] [bp-40h]@83
20364 signed int a1; // [sp+74h] [bp-3Ch]@129
20365 int v78; // [sp+78h] [bp-38h]@79
20366 AIDirection pDir; // [sp+7Ch] [bp-34h]@129
20367 float v80; // [sp+98h] [bp-18h]@33
20368 int v81; // [sp+9Ch] [bp-14h]@100
20369 int v82; // [sp+A0h] [bp-10h]@45
20370 unsigned int uActorID; // [sp+A4h] [bp-Ch]@32
20371 unsigned int v84; // [sp+A8h] [bp-8h]@11
20372 signed int a2; // [sp+ACh] [bp-4h]@83
20373
20374 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
20375 ODM_4014E6_AI();
20376 else
20377 BLV_4016FA_AI();
20378 v0 = 0;
20379 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->field_1613C > 0 )
20380 {
20381 if ( pParty->field_1613C > 417 )
20382 {
20383 pParty->field_1613C = 0;
20384 }
20385 else
20386 {
20387 pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8);
20388 v1 = rand();
20389 v2 = 128;
20390 v3 = pParty->sRotationX + v1 % 16 - 8;
20391 pParty->sRotationX = v3;
20392 if ( v3 > 128 || (v2 = -128, v3 < -128) )
20393 pParty->sRotationX = v2;
20394 pParty->uFlags |= 2u;
20395 pParty->field_1613C -= pMiscTimer->uTimeElapsed;
20396 v4 = pParty->field_16140 + 50;
20397 if ( pParty->field_1613C <= 0 )
20398 {
20399 pParty->field_1613C = 0;
20400 v84 = 0;
20401 if ( (signed int)uNumActors > 0 )
20402 {
20403 v5 = (char *)&pActors[0].sCurrentHP;
20404 do
20405 {
20406 if ( ((Actor *)(v5 - 40))->CanAct() )
20407 {
20408 v6 = stru_50C198.CalcMagicalDamageToActor((Actor *)(v5 - 40), 5, v4);
20409 v7 = *(short *)v5 - v6;
20410 *(short *)v5 = v7;
20411 if ( v6 )
20412 {
20413 if ( v7 >= 0 )
20414 {
20415 Actor::_4030AD(v84, 4, 0);
20416 }
20417 else
20418 {
20419 Actor::Die(v84);
20420 if ( *((int *)v5 + 19) )
20421 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[*((short *)v5 + 28)].uExp);
20422 }
20423 }
20424 }
20425 ++v84;
20426 v5 += 836;
20427 }
20428 while ( (signed int)v84 < (signed int)uNumActors );
20429 }
20430 v8 = &pPlayers[1];
20431 do
20432 {
20433 pPlayer = *v8;
20434 if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
20435 pPlayer->ReceiveDamage(v4, 5);
20436 ++v8;
20437 }
20438 while ( (signed int)v8 <= (signed int)&pPlayers[4] );
20439 v0 = 0;
20440 }
20441 if ( pTurnEngine->field_1C != v0 )
20442 --pTurnEngine->field_1C;
20443 }
20444 }
20445 if ( pParty->bTurnBasedModeOn == 1 )
20446 {
20447 pTurnEngine->_405E14();
20448 return;
20449 }
20450 uActorID = v0;
20451 if ( (signed int)uNumActors > (signed int)v0 )
20452 {
20453 LODWORD(v80) = (int)(char *)pActors + 176;
20454 do
20455 {
20456 pActor = (Actor *)(LODWORD(v80) - 176);
20457 v11 = *(unsigned int *)LODWORD(v80);
20458 v49 = *(unsigned int *)LODWORD(v80) == 5;
20459 dword_4F6E08[uActorID] = 4;
20460 if ( v49 || v11 == 11 || v11 == 19 || *(char *)(LODWORD(v80) - 139) & 4 )
20461 goto LABEL_78;
20462 if ( !*(short *)(LODWORD(v80) - 136) && v11 != 4 )
20463 Actor::Die(uActorID);
20464 v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
20465 v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1;
20466 v12 = 0;
20467 v13 = 0;
20468 v14 = (SpellBuff *)(LODWORD(v80) + 36);
20469 do
20470 {
20471 if ( v13 != 10 )
20472 {
20473 v14->_4585CA(pParty->uTimePlayed);
20474 v12 = 0;
20475 }
20476 ++v13;
20477 ++v14;
20478 }
20479 while ( v13 < 22 );
20480 if ( v84 != v12
20481 && SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12
20482 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12
20483 || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) )
20484 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
20485 if ( v82 != v12 )
20486 {
20487 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
20488 if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) <= (signed int)v12 )
20489 {
20490 if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) < (signed int)v12
20491 || LODWORD(pActor->pActorBuffs[1].uExpireTime) <= v12 )
20492 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
20493 }
20494 }
20495 if ( SHIDWORD(pActor->pActorBuffs[5].uExpireTime) > (signed int)v12
20496 || SHIDWORD(pActor->pActorBuffs[5].uExpireTime) >= (signed int)v12
20497 && LODWORD(pActor->pActorBuffs[5].uExpireTime)
20498 || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) > 0
20499 || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(pActor->pActorBuffs[6].uExpireTime) )
20500 goto LABEL_78;
20501 v15 = pMiscTimer->uTimeElapsed;
20502 v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
20503 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
20504 v17 = pActor->uCurrentActionTime;
20505 v18 = pActor->pMonsterInfo.uRecoveryTime;
20506 if ( (signed int)v18 > 0 )
20507 *(int *)v16 = v18 - v15;
20508 if ( *(int *)v16 < 0 )
20509 *(int *)v16 = 0;
20510 if ( (signed int)v17 < pActor->uCurrentActionLength )
20511 goto LABEL_78;
20512 v19 = pActor->uAIState;
20513 if ( v19 == Dying )
20514 {
20515 pActor->uAIState = Dead;
20516 }
20517 else
20518 {
20519 if ( v19 != 17 )
20520 {
20521 Actor::_403F58(uActorID, Dying, 256, 0);
20522 goto LABEL_78;
20523 }
20524 pActor->uAIState = Standing;
20525 }
20526 pActor->uCurrentActionTime = 0;
20527 pActor->uCurrentActionLength = 0;
20528 pActor->UpdateAnimation();
20529 LABEL_78:
20530 ++uActorID;
20531 LODWORD(v80) += 836;
20532 }
20533 while ( (signed int)uActorID < (signed int)uNumActors );
20534 }
20535 v78 = 0;
20536 if ( ai_arrays_size > 0 )
20537 {
20538 while ( 1 )
20539 {
20540 uActorID = ai_array_4F7DB0_actor_ids[v78];
20541 v20 = &dword_4F6E08[uActorID];
20542 v21 = &pActors[uActorID];
20543 Actor::_401221(uActorID, &dword_4F6E08[uActorID], 1u);
20544 if ( v21->pMonsterInfo.uHostilityType && !*v20 )
20545 v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
20546 a2 = *v20;
20547 v76 = a2 & 7;
20548 if ( (a2 & 7) == 3 )
20549 v80 = 0.5;
20550 else
20551 v80 = 1.0;
20552 v22 = v21->uAIState;
20553 if ( v22 == 4 || v22 == 5 || v22 == 11 || v22 == 19 || v22 == 17 )
20554 goto LABEL_254;
20555 if ( !v21->sCurrentHP )
20556 Actor::Die(uActorID);
20557 if ( (signed __int64)v21->pActorBuffs[3].uExpireTime <= 0 )
20558 {
20559 v84 = 0;
20560 v23 = 1;
20561 }
20562 else
20563 {
20564 v23 = 1;
20565 v84 = 1;
20566 }
20567 if ( (signed __int64)v21->pActorBuffs[1].uExpireTime <= 0 )
20568 v82 = 0;
20569 else
20570 v82 = v23;
20571 if ( (signed __int64)v21->pActorBuffs[2].uExpireTime <= 0 )
20572 v81 = 0;
20573 else
20574 v81 = v23;
20575 v24 = 0;
20576 v25 = 0;
20577 v26 = v21->pActorBuffs;
20578 do
20579 {
20580 if ( v25 != 10 )
20581 {
20582 v26->_4585CA(pParty->uTimePlayed);
20583 v24 = 0;
20584 }
20585 ++v25;
20586 ++v26;
20587 }
20588 while ( v25 < 22 );
20589 if ( v84 != v24
20590 && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= (signed int)v24
20591 && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < (signed int)v24
20592 || LODWORD(v21->pActorBuffs[3].uExpireTime) <= v24) )
20593 v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
20594 if ( v82 != v24 )
20595 {
20596 v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
20597 if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= (signed int)v24 )
20598 {
20599 if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < (signed int)v24
20600 || LODWORD(v21->pActorBuffs[1].uExpireTime) <= v24 )
20601 v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
20602 }
20603 }
20604 if ( v81 != v24
20605 && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= (signed int)v24
20606 && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < (signed int)v24
20607 || LODWORD(v21->pActorBuffs[2].uExpireTime) <= v24) )
20608 {
20609 v21->uAIState = Removed;
20610 goto LABEL_254;
20611 }
20612 if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )
20613 goto LABEL_254;
20614 v27 = pMiscTimer->uTimeElapsed;
20615 v28 = v21->pMonsterInfo.uRecoveryTime;
20616 v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
20617 if ( (signed int)v28 > 0 )
20618 v21->pMonsterInfo.uRecoveryTime = v28 - v27;
20619 if ( (v21->pMonsterInfo.uRecoveryTime & 0x80000000u) != 0 )
20620 v21->pMonsterInfo.uRecoveryTime = 0;
20621 v29 = v21->uAttributes;
20622 if ( !(v29 & 0x8000) )
20623 v21->uAttributes = v29 | 0x8000;
20624 a1 = 8 * uActorID | 3;
20625 v30 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0);
20626 v49 = v21->pMonsterInfo.uHostilityType == 0;
20627 memcpy(&v75, v30, sizeof(v75));
20628 memcpy(&pDir, &v75, sizeof(pDir));
20629 if ( !v49 && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
20630 {
20631 if ( v80 * 307.2 >= (double)(signed int)v75.uDistance
20632 && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9)
20633 || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 )
20634 {
20635 v32 = uActorID;
20636 goto LABEL_152;
20637 }
20638 }
20639 if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
20640 goto LABEL_254;
20641 if ( v21->uAIState == 2 )
20642 {
20643 v32 = uActorID;
20644 v35 = stru_50C198.special_ability_use_check(v21, uActorID);
20645 stru_50FE08.Add(
20646 a1,
20647 5120,
20648 v21->vPosition.x,
20649 v21->vPosition.y,
20650 v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
20651 v35,
20652 1);
20653 goto LABEL_152;
20654 }
20655 if ( v21->uAIState == 3 )
20656 {
20657 v34 = v21->pMonsterInfo.uMissleAttack1Type;
20658 v66 = 0;
20659 goto LABEL_149;
20660 }
20661 if ( v21->uAIState == 12 )
20662 {
20663 v34 = v21->pMonsterInfo.uMissleAttack2Type;
20664 v66 = 1;
20665 LABEL_149:
20666 v32 = uActorID;
20667 Actor::_404874(uActorID, &pDir, v34, v66);
20668 goto LABEL_152;
20669 }
20670 v32 = uActorID;
20671 if ( v21->uAIState == 13 )
20672 break;
20673 if ( v21->uAIState == 18 )
20674 {
20675 v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
20676 v60 = 3;
20677 v33 = v21->pMonsterInfo.uSpell2ID;
20678 LABEL_146:
20679 Actor::_404AC7(uActorID, &pDir, v33, v60, v65);
20680 }
20681 LABEL_152:
20682 v36 = v75.uDistance;
20683 if ( v21->pMonsterInfo.uHostilityType )
20684 goto LABEL_165;
20685 if ( v76 == 3 )
20686 {
20687 v36 = v75.uDistance;
20688 v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
20689 + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3);
20690 }
20691 else
20692 {
20693 v37 = 4;
20694 }
20695 if ( v37 == 1 )
20696 goto LABEL_257;
20697 if ( v37 == 2 )
20698 {
20699 v39 = __OFSUB__(v36, 1024);
20700 v38 = ((v36 - 1024) & 0x80000000u) != 0;
20701 }
20702 else
20703 {
20704 if ( v37 == 3 )
20705 {
20706 v39 = __OFSUB__(v36, 2560);
20707 v38 = ((v36 - 2560) & 0x80000000u) != 0;
20708 }
20709 else
20710 {
20711 if ( v37 != 4 )
20712 goto LABEL_165;
20713 v39 = __OFSUB__(v36, 5120);
20714 v38 = ((v36 - 5120) & 0x80000000u) != 0;
20715 }
20716 }
20717 if ( v38 ^ v39 )
20718 LABEL_257:
20719 v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
20720 LABEL_165:
20721 if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
20722 {
20723 v40 = a2;
20724 v41 = v32;
20725 if ( (signed int)v36 >= 10240 )
20726 {
20727 v68 = 0;
20728 v61 = 1024;
20729 goto LABEL_253;
20730 }
20731 v67 = &pDir;
20732 goto LABEL_182;
20733 }
20734 if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 )
20735 goto LABEL_241;
20736 if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 )
20737 {
20738 if ( v21->pMonsterInfo.uAIType == 1 )
20739 {
20740 v67 = &pDir;
20741 if ( v21->pMonsterInfo.uMovementType != 5 )
20742 goto LABEL_181;
20743 Actor::_403EB6(
20744 v32,
20745 a2,
20746 (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),
20747 &pDir);
20748 }
20749 else
20750 {
20751 if ( v21->pMonsterInfo.uAIType == 2 )
20752 {
20753 v84 = v21->sCurrentHP;
20754 v42 = (double)(signed int)v84;
20755 v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
20756 }
20757 else
20758 {
20759 if ( v21->pMonsterInfo.uAIType != 3 )
20760 goto LABEL_185;
20761 v84 = v21->sCurrentHP;
20762 v42 = (double)(signed int)v84;
20763 v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
20764 }
20765 if ( v43 > v42 && (signed int)v36 < 10240 )
20766 {
20767 v67 = &pDir;
20768 LABEL_181:
20769 v40 = a2;
20770 v41 = v32;
20771 LABEL_182:
20772 Actor::_402968(v41, v40, 0, v67);
20773 goto LABEL_254;
20774 }
20775 }
20776 }
20777 LABEL_185:
20778 v81 = v36 - v21->uActorRadius;
20779 if ( v76 == 3 )
20780 v81 -= pActors[a2 >> 3].uActorRadius;
20781 if ( v81 < 0 )
20782 v81 = 0;
20783 rand();
20784 v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0;
20785 v21->uAttributes &= 0xFBFFFF;
20786 v82 = 0;
20787 v49 = v21->pMonsterInfo.uMovementType == 5;
20788 v84 = v44;
20789 if ( v49 )
20790 v82 = 1;
20791 if ( v81 >= 5120 )
20792 goto LABEL_241;
20793 v45 = stru_50C198.special_ability_use_check(v21, v32);
20794 if ( !v45 )
20795 {
20796 if ( v21->pMonsterInfo.uMissleAttack1Type )
20797 {
20798 if ( v84 )
20799 {
20800 Actor::_403476(v32, a2, &pDir);
20801 goto LABEL_254;
20802 }
20803 LABEL_223:
20804 if ( v82 )
20805 goto LABEL_217;
20806 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
20807 //UNDEF(v53);
20808 v69 = &pDir;
20809 if ( !(v54 | v55) )
20810 goto LABEL_219;
20811 LABEL_225:
20812 Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
20813 goto LABEL_254;
20814 }
20815 v56 = v80 * 307.2;
20816 if ( (double)v81 >= v56 )
20817 {
20818 if ( v81 >= 1024 )
20819 {
20820 if ( v82 )
20821 goto LABEL_217;
20822 v71 = &pDir;
20823 v63 = 0;
20824 goto LABEL_240;
20825 }
20826 goto LABEL_235;
20827 }
20828 goto LABEL_227;
20829 }
20830 if ( v45 != 1 )
20831 {
20832 if ( v45 > 1 && v45 <= 3 )
20833 {
20834 if ( v45 == 2 )
20835 v46 = v21->pMonsterInfo.uSpell1ID;
20836 else
20837 v46 = v21->pMonsterInfo.uSpell2ID;
20838 if ( v46 )
20839 {
20840 if ( v84 )
20841 {
20842 if ( v45 == 2 )
20843 Actor::_403854(v32, a2, &pDir);
20844 else
20845 Actor::_403A60(v32, a2, &pDir);
20846 goto LABEL_254;
20847 }
20848 if ( v80 * 307.2 > (double)v81 || v82 )
20849 {
20850 LABEL_217:
20851 v69 = &pDir;
20852 LABEL_218:
20853 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
20854 LABEL_219:
20855 v51 = a2;
20856 v64 = (signed __int64)v47;
20857 v52 = v32;
20858 LABEL_247:
20859 Actor::_403EB6(v52, v51, v64, v69);
20860 goto LABEL_254;
20861 }
20862 v69 = &pDir;
20863 v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
20864 goto LABEL_225;
20865 }
20866 v48 = v80 * 307.2;
20867 if ( (double)v81 >= v48 )
20868 {
20869 if ( v81 >= 1024 )
20870 {
20871 v50 = v82 == 0;
20872 LABEL_215:
20873 if ( !v50 )
20874 goto LABEL_217;
20875 v71 = &pDir;
20876 v63 = 256;
20877 LABEL_240:
20878 Actor::_402686(v32, a2, v63, v71);
20879 goto LABEL_254;
20880 }
20881 if ( v82 )
20882 goto LABEL_217;
20883 v70 = (signed __int64)v48;
20884 v62 = &pDir;
20885 v59 = 0;
20886 goto LABEL_237;
20887 }
20888 v49 = v84 == 0;
20889 goto LABEL_209;
20890 }
20891 LABEL_241:
20892 if ( !v21->pMonsterInfo.uMovementType )
20893 {
20894 v68 = 0;
20895 v61 = 1024;
20896 LABEL_252:
20897 v41 = v32;
20898 v40 = 4;
20899 LABEL_253:
20900 Actor::_4032B2(v41, v40, v61, v68);
20901 goto LABEL_254;
20902 }
20903 if ( v21->pMonsterInfo.uMovementType == 1 )
20904 {
20905 v68 = 0;
20906 v61 = 2560;
20907 goto LABEL_252;
20908 }
20909 if ( v21->pMonsterInfo.uMovementType == 2 )
20910 {
20911 v68 = 0;
20912 v61 = 5120;
20913 goto LABEL_252;
20914 }
20915 if ( v21->pMonsterInfo.uMovementType == 4 )
20916 {
20917 v68 = 0;
20918 v61 = 10240;
20919 goto LABEL_252;
20920 }
20921 if ( v21->pMonsterInfo.uMovementType == 5 )
20922 {
20923 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
20924 v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
20925 memcpy(&v74, v57, sizeof(v74));
20926 memcpy(&pDir, &v74, sizeof(pDir));
20927 v69 = &pDir;
20928 v52 = uActorID;
20929 v64 = (signed __int64)v58;
20930 v51 = 4;
20931 goto LABEL_247;
20932 }
20933 goto LABEL_254;
20934 }
20935 if ( !v21->pMonsterInfo.uMissleAttack2Type )
20936 {
20937 v56 = v80 * 307.2;
20938 if ( (double)v81 >= v56 )
20939 {
20940 if ( v81 >= 1024 )
20941 {
20942 v50 = v82 == 0;
20943 goto LABEL_215;
20944 }
20945 LABEL_235:
20946 if ( v82 )
20947 goto LABEL_217;
20948 v70 = (signed __int64)v56;
20949 v62 = &pDir;
20950 v59 = 0;
20951 LABEL_237:
20952 Actor::_40281C(v32, a2, v59, v62, v70);
20953 goto LABEL_254;
20954 }
20955 LABEL_227:
20956 v49 = v84 == 0;
20957 LABEL_209:
20958 v69 = &pDir;
20959 if ( v49 )
20960 goto LABEL_218;
20961 Actor::_403C6C(v32, a2, &pDir);
20962 goto LABEL_254;
20963 }
20964 if ( !v84 )
20965 goto LABEL_223;
20966 Actor::_40368B(v32, a2, &pDir);
20967 LABEL_254:
20968 ++v78;
20969 if ( v78 >= ai_arrays_size )
20970 return;
20971 }
20972 v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
20973 v60 = 2;
20974 v33 = v21->pMonsterInfo.uSpell1ID;
20975 goto LABEL_146;
20976 }
20977 }
20978
20979
20980
20981
20982 //----- (0040261D) --------------------------------------------------------
20983 int stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8)
20984 {
20985 int result; // eax@1
20986
20987 result = this->count;
20988 if ( this->count < 100 )
20989 {
20990 this->pIDs[result] = uID;
20991 this->pXs[this->count] = x;
20992 this->pYs[this->count] = y;
20993 this->pZs[this->count] = z;
20994 this->field_324[this->count] = a3;
20995 this->field_3EC[this->count] = a8;
20996 result = this->count;
20997 this->field_450[this->count++] = a7;
20998 }
20999 return result;
21000 }
21001
21002
21003
21004
21005
21006 //----- (00402CAE) --------------------------------------------------------
21007 int stru193_math::SinCos(int angle)
21008 {
21009 int v2; // eax@1
21010
21011 //a2: (angle - uIntegerHalfPi) for sin(angle)
21012 // (angle) for cos(angle)
21013
21014 v2 = uDoublePiMask & angle;
21015
21016 if ( v2 > uIntegerPi )
21017 v2 = uIntegerDoublePi - v2;
21018 if ( v2 >= uIntegerHalfPi )
21019 return -pCosTable[uIntegerPi - v2];
21020 else
21021 return pCosTable[v2];
21022 }
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037 //----- (00404544) --------------------------------------------------------
21038 signed int stru262_TurnBased::_404544()
21039 {
21040 stru262_TurnBased *v1; // ebx@1
21041 TurnBased_QueueElem *v2; // esi@2
21042 Actor *v3; // edi@4
21043 Actor *v4; // ecx@4
21044 Player *v5; // eax@7
21045 int v6; // ecx@15
21046 TurnBased_QueueElem *v7; // eax@16
21047 TurnBased_QueueElem *v8; // ecx@18
21048 int v9; // edx@19
21049 int v10; // esi@19
21050 int v11; // esi@21
21051 int v12; // ST0C_4@25
21052 int v13; // ST10_4@25
21053 int v14; // ST14_4@25
21054 int v15; // ST18_4@25
21055 signed int result; // eax@28
21056 TurnBased_QueueElem *v17; // edi@32
21057 int v18; // [sp+20h] [bp-Ch]@17
21058 int v19; // [sp+24h] [bp-8h]@1
21059 int v20; // [sp+28h] [bp-4h]@1
21060 signed int v21; // [sp+28h] [bp-4h]@16
21061 int v22; // [sp+28h] [bp-4h]@31
21062
21063 v20 = 0;
21064 v1 = this;
21065 v19 = this->uActorQueueSize;
21066 if ( this->uActorQueueSize > 0 )
21067 {
21068 v2 = this->pQueue;
21069 do
21070 {
21071 if ( (v2->uPackedID & 7) == 3 )
21072 {
21073 v3 = &pActors[v2->uPackedID >> 3];
21074 v4 = &pActors[v2->uPackedID >> 3];
21075 LOBYTE(v4->uAttributes) |= 0x80u;
21076 if ( !v4->CanAct() )
21077 {
21078 --v19;
21079 v2->field_4 = 1001;
21080 LOBYTE(v3->uAttributes) &= 0x7Fu;
21081 }
21082 }
21083 if ( (v2->uPackedID & 7) == 4 )
21084 {
21085 v5 = &pParty->pPlayers[v2->uPackedID >> 3];
21086 if ( v5->pConditions[14]
21087 || v5->pConditions[16]
21088 || v5->pConditions[15]
21089 || v5->pConditions[13]
21090 || v5->pConditions[12]
21091 || v5->pConditions[2] )
21092 {
21093 --v19;
21094 v2->field_4 = 1001;
21095 }
21096 }
21097 ++v20;
21098 ++v2;
21099 }
21100 while ( v20 < v1->uActorQueueSize );
21101 }
21102 v6 = v1->uActorQueueSize;
21103 if ( v6 > 0 )
21104 {
21105 v21 = 1;
21106 v7 = v1->pQueue;
21107 do
21108 {
21109 v18 = v21;
21110 if ( v21 < v6 )
21111 {
21112 v8 = v7 + 1;
21113 do
21114 {
21115 v9 = v8->field_4;
21116 v10 = v7->field_4;
21117 if ( v9 < v10
21118 || v9 == v10
21119 && ((v11 = v8->uPackedID & 7, v11 == 4) && (v7->uPackedID & 7) == 3
21120 || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) )
21121 {
21122 v12 = v7->uPackedID;
21123 v13 = v7->field_4;
21124 v14 = v7->uActionLength;
21125 v15 = v7->field_C;
21126 v7->uPackedID = v8->uPackedID;
21127 v7->field_4 = v8->field_4;
21128 v7->uActionLength = v8->uActionLength;
21129 v7->field_C = v8->field_C;
21130 v8->uPackedID = v12;
21131 v8->field_4 = v13;
21132 v8->uActionLength = v14;
21133 v8->field_C = v15;
21134 }
21135 ++v18;
21136 ++v8;
21137 }
21138 while ( v18 < v1->uActorQueueSize );
21139 }
21140 ++v21;
21141 v6 = v1->uActorQueueSize;
21142 ++v7;
21143 }
21144 while ( v21 - 1 < v6 );
21145 }
21146 v1->uActorQueueSize = v19;
21147 result = v1->pQueue[0].uPackedID;
21148 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
21149 {
21150 result = (result >> 3) + 1;
21151 uActiveCharacter = result;
21152 v1->field_18 |= 4u;
21153 }
21154 else
21155 {
21156 uActiveCharacter = 0;
21157 v1->field_18 &= 0xFFFFFFFBu;
21158 }
21159 v22 = 0;
21160 if ( v1->uActorQueueSize > 0 )
21161 {
21162 v17 = v1->pQueue;
21163 do
21164 {
21165 if ( (v17->uPackedID & 7) == 4 )
21166 pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875);
21167 ++v22;
21168 ++v17;
21169 result = v22;
21170 }
21171 while ( v22 < v1->uActorQueueSize );
21172 }
21173 return result;
21174 }
21175
21176 //----- (0040471C) --------------------------------------------------------
21177 void stru262_TurnBased::_40471C()
21178 {
21179 if ( pParty->bTurnBasedModeOn == 1 )
21180 {
21181 if ( pTurnEngine->field_4 == 2 )
21182 _406457(0);
21183 }
21184 }
21185
21186
21187 //----- (00404828) --------------------------------------------------------
21188 LayingItem::LayingItem()
21189 {
21190 LayingItem *v1; // esi@1
21191
21192 v1 = this;
21193 v1->field_22 = 1;
21194 v1->uSoundID = 0;
21195 v1->uFacing = 0;
21196 v1->vVelocity.z = 0;
21197 v1->vVelocity.y = 0;
21198 v1->vVelocity.x = 0;
21199 v1->uItemType = 0;
21200 v1->uObjectDescID = 0;
21201 v1->field_61 = 0;
21202 v1->field_60_distance_related_prolly_lod = 0;
21203 v1->field_20 = 0;
21204 v1->uSpriteFrameID = 0;
21205 v1->field_50 = 0;
21206 v1->field_4C = 0;
21207 v1->field_48 = 0;
21208 v1->field_54 = 0;
21209 }
21210
21211
21212
21213 //----- (004059DB) --------------------------------------------------------
21214 signed int stru262_TurnBased::Start()
21215 {
21216 stru262_TurnBased *v1; // ebx@1
21217 unsigned int v2; // edi@1
21218 int v3; // esi@1
21219 int v4; // eax@5
21220 unsigned int v5; // esi@7
21221 Actor *v6; // edi@7
21222 unsigned int v7; // eax@9
21223 unsigned int v8; // edx@10
21224 unsigned __int8 v9; // zf@14
21225 unsigned __int8 v10; // sf@14
21226 unsigned __int8 v11; // of@14
21227 char *v12; // esi@15
21228 int v13; // ecx@16
21229 unsigned __int16 v14; // ax@17
21230 int v15; // ecx@18
21231 signed __int64 v16; // qax@19
21232 int v17; // edx@22
21233 unsigned int v18; // esi@27
21234 char *v19; // esi@32
21235 int v20; // edx@33
21236 char *v21; // eax@33
21237 int v22; // ecx@33
21238 int v23; // eax@34
21239 char *v24; // eax@34
21240 char *v25; // ecx@34
21241 int v26; // edx@34
21242 int v27; // eax@38
21243 int v28; // ecx@38
21244 AIDirection v30; // [sp+Ch] [bp-68h]@10
21245 AIDirection v31; // [sp+28h] [bp-4Ch]@10
21246 AIDirection a3; // [sp+44h] [bp-30h]@10
21247 int v33; // [sp+60h] [bp-14h]@10
21248 int *v34; // [sp+64h] [bp-10h]@6
21249 int v35; // [sp+68h] [bp-Ch]@5
21250 int v40; // [sp+6Ch] [bp-8h]@1
21251 unsigned int v37; // [sp+70h] [bp-4h]@7
21252
21253 pTurnEngine->field_18 &= 0xFFFFFFFDu;
21254 v1 = this;
21255 pEventTimer->TrackGameTime();
21256 pAudioPlayer->StopChannels(-1, -1);
21257 v2 = 0;
21258 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
21259 v40 = (int)pParty->pPlayers;
21260 dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength;
21261 dword_50C994 = 0;
21262 v1->field_10 = 100;
21263 v1->field_0 = 0;
21264 v1->field_8 = 64;
21265 v1->field_4 = 1;
21266 v1->uActorQueueSize = 0;
21267 v3 = 0;
21268 do
21269 {
21270 if ( ((Player *)v40)->CanAct() )
21271 {
21272 *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = 8 * v3 | OBJECT_Player;
21273 v1->pQueue[v1->uActorQueueSize].field_C = 2;
21274 v1->pQueue[v1->uActorQueueSize].uActionLength = 0;
21275 pParty->pTurnBasedPlayerRecoveryTimes[v1->uActorQueueSize++] = 0;
21276 }
21277 v40 += 6972;
21278 ++v3;
21279 }
21280 while ( v40 < (signed int)pParty->pHirelings );
21281 v35 = v1->uActorQueueSize;
21282 v4 = v35;
21283 v40 = v35;
21284 if ( v40 < v40 + ai_arrays_size )
21285 {
21286 v34 = (int *)ai_array_4F7DB0_actor_ids;
21287 do
21288 {
21289 v37 = *v34;
21290 v5 = v37;
21291 v6 = &pActors[v37];
21292 if ( v37 != 10 )
21293 {
21294 if ( pActors[v37].CanAct() )
21295 {
21296 v7 = v6->uAttributes;
21297 if ( v7 & 0x8000 < 0 )
21298 {
21299 v8 = dword_4F6E08[v5];
21300 LOBYTE(v7) = v7 | 0x80;
21301 v6->uAttributes = v7;
21302 v33 = 8 * v5 | OBJECT_Actor;
21303 memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31));
21304 memcpy(&v30, &v31, sizeof(v30));
21305 Actor::_403F58(v37, 4, 32, &v30);
21306 *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33;
21307 v1->pQueue[v1->uActorQueueSize].field_C = 2;
21308 v1->pQueue[v1->uActorQueueSize++].uActionLength = 0;
21309 }
21310 }
21311 v4 = v35;
21312 }
21313 ++v40;
21314 ++v34;
21315 }
21316 while ( v40 < v4 + ai_arrays_size );
21317 v2 = 0;
21318 }
21319 v11 = __OFSUB__(v1->uActorQueueSize, v2);
21320 v9 = v1->uActorQueueSize == v2;
21321 v10 = ((v1->uActorQueueSize - v2) & 0x80000000u) != 0;
21322 v37 = v2;
21323 v40 = v2;
21324 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
21325 {
21326 v12 = (char *)&v1->pQueue[0].field_4;
21327 while ( 1 )
21328 {
21329 v13 = *((int *)v12 - 1) & 7;
21330 if ( v13 != OBJECT_Player )
21331 break;
21332 v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery;
21333 if ( v14 != (short)v2 )
21334 {
21335 v33 = v14;
21336 v16 = (signed __int64)((double)v14 * 0.46875);
21337 LABEL_20:
21338 *(int *)v12 = v16;
21339 goto LABEL_26;
21340 }
21341 v15 = v37++;
21342 *(&a3.uDistance + v15) = v40;
21343 LABEL_26:
21344 ++v40;
21345 v12 += 16;
21346 if ( v40 >= v1->uActorQueueSize )
21347 goto LABEL_27;
21348 }
21349 if ( v13 != 3 )
21350 {
21351 *(int *)v12 = 666;
21352 goto LABEL_26;
21353 }
21354 v17 = rand() % 99;
21355 if ( v17 < 33 )
21356 {
21357 *(int *)v12 = 1;
21358 goto LABEL_26;
21359 }
21360 LODWORD(v16) = SHIDWORD(v16) < 66;
21361 LOBYTE(v16) = SHIDWORD(v16) >= 66;
21362 LODWORD(v16) = 2 * v16 + 3;
21363 goto LABEL_20;
21364 }
21365 LABEL_27:
21366 v18 = 0;
21367 if ( (signed int)v37 > (signed int)v2 )
21368 {
21369 do
21370 {
21371 *(&v31.uDistance + v18) = pParty->pPlayers[*(&v1->field_0 + 4 * (*(&a3.uDistance + v18) + 2)) >> 3].GetAttackRecoveryTime(
21372 v2);
21373 ++v18;
21374 }
21375 while ( (signed int)v18 < (signed int)v37 );
21376 if ( (signed int)v37 > (signed int)v2 )
21377 {
21378 v35 = v2;
21379 v34 = (int *)1;
21380 do
21381 {
21382 v40 = (int)v34;
21383 if ( (signed int)v34 < (signed int)v37 )
21384 {
21385 v19 = (char *)&v31.uDistance + v35;
21386 do
21387 {
21388 v20 = *(int *)v19;
21389 v33 = 4 * v40;
21390 v21 = (char *)(&v31.uDistance + v40);
21391 v22 = *(int *)v21;
21392 if ( *(int *)v21 < v20 )
21393 {
21394 *(int *)v21 = v20;
21395 v23 = v33;
21396 *(int *)v19 = v22;
21397 v24 = (char *)&a3.uDistance + v23;
21398 v25 = (char *)&a3.uDistance + v35;
21399 v26 = *(int *)v24;
21400 *(int *)v24 = *(unsigned int *)((char *)&a3.uDistance + v35);
21401 *(int *)v25 = v26;
21402 v2 = 0;
21403 }
21404 ++v40;
21405 }
21406 while ( v40 < (signed int)v37 );
21407 }
21408 v34 = (int *)((char *)v34 + 1);
21409 v35 += 4;
21410 }
21411 while ( (signed int)((char *)v34 - 1) < (signed int)v37 );
21412 if ( (signed int)v37 > (signed int)v2 )
21413 {
21414 do
21415 {
21416 v27 = v2 + 2;
21417 v28 = *(&a3.uDistance + v2++);
21418 v11 = __OFSUB__(v2, v37);
21419 v10 = ((v2 - v37) & 0x80000000u) != 0;
21420 v1->pQueue[v28].field_4 = v27;
21421 }
21422 while ( v10 ^ v11 );
21423 }
21424 }
21425 }
21426 return v1->_404544();
21427 }
21428