comparison mm7_4.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children bf31c505f4d3
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include <io.h>
2 #include <direct.h>
3
4 #include "MapInfo.h"
5 #include "Game.h"
6 #include "GUIWindow.h"
7 #include "GUIButton.h"
8 #include "GUIFont.h"
9 #include "Party.h"
10 #include "AudioPlayer.h"
11 #include "Outdoor.h"
12 #include "IndoorCamera.h"
13 #include "Overlays.h"
14 #include "Monsters.h"
15 #include "Arcomage.h"
16 #include "LOD.h"
17 #include "Actor.h"
18 #include "Allocator.h"
19 #include "Events.h"
20 #include "Viewport.h"
21 #include "FrameTableInc.h"
22 #include "Math.h"
23 #include "LayingItem.h"
24 #include "ObjectList.h"
25 #include "Chest.h"
26 #include "PaletteManager.h"
27 #include "DecorationList.h"
28 #include "SaveLoad.h"
29 #include "stru123.h"
30 #include "stru287.h"
31 #include "Time.h"
32 #include "IconFrameTable.h"
33 #include "GUIProgressBar.h"
34 #include "stru157.h"
35 #include "Bink_Smacker.h"
36 #include "TileFrameTable.h"
37 #include "PlayerFrameTable.h"
38 #include "Awards.h"
39 #include "Autonotes.h"
40 #include "stru160.h"
41 #include "stru279.h"
42 #include "TurnEngine.h"
43 #include "FactionTable.h"
44 #include "StorylineTextTable.h"
45 #include "Random.h"
46 #include "stru277.h"
47 #include "stru298.h"
48 #include "stru12.h"
49 #include "stru351.h"
50 #include "Events2D.h"
51 #include "stru159.h"
52 #include "Log.h"
53
54 #include "mm7_data.h"
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 //----- (0046CC4B) --------------------------------------------------------
71 void __cdecl _46CC4B_check_event_triggers()
72 {
73 int v0; // eax@1
74 LevelDecoration *v1; // esi@2
75 signed int v2; // edi@2
76 int v3; // ebx@2
77 int v4; // eax@3
78 int v5; // ebx@3
79 unsigned int v6; // ecx@3
80 unsigned int v7; // edx@6
81 unsigned int v8; // edx@8
82 char *v9; // edi@13
83 int v10; // ebx@14
84 int v11; // eax@14
85 int v12; // ebx@14
86 unsigned int v13; // ecx@14
87 int v14; // edx@15
88 unsigned int v15; // edx@17
89 unsigned int v16; // edx@19
90 char *v17; // edi@25
91 int v18; // ebx@26
92 int v19; // eax@26
93 int v20; // ebx@26
94 unsigned int v21; // ecx@26
95 int v22; // edx@27
96 unsigned int v23; // edx@29
97 unsigned int v24; // edx@31
98 int v25; // [sp+0h] [bp-24h]@3
99 int v26; // [sp+0h] [bp-24h]@14
100 int v27; // [sp+0h] [bp-24h]@26
101 int v28; // [sp+4h] [bp-20h]@3
102 int v29; // [sp+4h] [bp-20h]@14
103 int v30; // [sp+4h] [bp-20h]@26
104 signed int v31; // [sp+8h] [bp-1Ch]@2
105 int v32; // [sp+Ch] [bp-18h]@2
106 int v33; // [sp+10h] [bp-14h]@2
107 int i; // [sp+14h] [bp-10h]@1
108 int v35; // [sp+18h] [bp-Ch]@2
109 int v36; // [sp+1Ch] [bp-8h]@3
110 signed int v37; // [sp+1Ch] [bp-8h]@12
111 signed int v38; // [sp+20h] [bp-4h]@24
112
113 v0 = 0;
114 for ( i = 0; i < _6836C8_num_decorations_6807E8; ++i )
115 {
116 v1 = &pLevelDecorations[_6807E8_level_decorations_ids[v0]];
117 v2 = v1->field_18;
118 v3 = v1->vPosition.y;
119 v33 = v1->vPosition.x;
120 v32 = v1->vPosition.y;
121 v35 = v1->vPosition.z;
122 v31 = v1->field_18;
123 if ( v1->field_2 & 1 )
124 {
125 v36 = abs(v1->vPosition.x - pParty->vPosition.x);
126 v25 = abs(v3 - pParty->vPosition.y);
127 v28 = abs(v35 - pParty->vPosition.z);
128 v4 = v36;
129 v5 = v25;
130 v6 = v28;
131 if ( v36 < v25 )
132 {
133 v4 = v25;
134 v5 = v36;
135 }
136 if ( v4 < v28 )
137 {
138 v7 = v4;
139 v4 = v28;
140 v6 = v7;
141 }
142 if ( v5 < (signed int)v6 )
143 {
144 v8 = v6;
145 v6 = v5;
146 v5 = v8;
147 }
148 if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 )
149 EventProcessor(v1->field_16_event_id, 8 * i | 5, 1);
150 }
151 if ( v1->field_2 & 2 )
152 {
153 v37 = 0;
154 if ( (signed int)uNumActors > 0 )
155 {
156 v9 = (char *)&pActors[0].vPosition.y;
157 do
158 {
159 v10 = abs(v33 - *((short *)v9 - 1));
160 v29 = abs(v32 - *(short *)v9);
161 v26 = abs(v35 - *((short *)v9 + 1));
162 v11 = v10;
163 v12 = v29;
164 v13 = v26;
165 if ( v11 < v29 )
166 {
167 v14 = v11;
168 v11 = v29;
169 v12 = v14;
170 }
171 if ( v11 < v26 )
172 {
173 v15 = v11;
174 v11 = v26;
175 v13 = v15;
176 }
177 if ( v12 < (signed int)v13 )
178 {
179 v16 = v13;
180 v13 = v12;
181 v12 = v16;
182 }
183 if ( (signed int)(((unsigned int)(11 * v12) >> 5) + (v13 >> 2) + v11) < v31 )
184 EventProcessor(v1->field_16_event_id, 0, 1);
185 ++v37;
186 v9 += 836;
187 }
188 while ( v37 < (signed int)uNumActors );
189 }
190 }
191 if ( v1->field_2 & 4 )
192 {
193 v38 = 0;
194 if ( (signed int)uNumLayingItems > 0 )
195 {
196 v17 = (char *)&pLayingItems[0].vPosition.y;
197 do
198 {
199 v18 = abs(v33 - *((int *)v17 - 1));
200 v30 = abs(v32 - *(int *)v17);
201 v27 = abs(v35 - *((int *)v17 + 1));
202 v19 = v18;
203 v20 = v30;
204 v21 = v27;
205 if ( v19 < v30 )
206 {
207 v22 = v19;
208 v19 = v30;
209 v20 = v22;
210 }
211 if ( v19 < v27 )
212 {
213 v23 = v19;
214 v19 = v27;
215 v21 = v23;
216 }
217 if ( v20 < (signed int)v21 )
218 {
219 v24 = v21;
220 v21 = v20;
221 v20 = v24;
222 }
223 if ( (signed int)(((unsigned int)(11 * v20) >> 5) + (v21 >> 2) + v19) < v31 )
224 EventProcessor(v1->field_16_event_id, 0, 1);
225 ++v38;
226 v17 += 112;
227 }
228 while ( v38 < (signed int)uNumLayingItems );
229 }
230 }
231 v0 = i + 1;
232 }
233 }
234 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8;
235
236 //----- (0046CEC3) --------------------------------------------------------
237 int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID)
238 {
239 //BLVSector *v5; // edi@1
240 //int v6; // ecx@1
241 //Vec3_short_ *v7; // edx@1
242 //BLVFace *v8; // esi@2
243 //int v9; // eax@8
244 //int v10; // edi@8
245 //int v11; // eax@10
246 int v12; // ecx@10
247 int v13; // ecx@13
248 signed int v14; // ebx@14
249 int v15; // eax@16
250 int v16; // edx@19
251 int v17; // ST18_4@19
252 signed int v18; // edx@19
253 signed __int64 v19; // qtt@19
254 PolygonType v20; // al@25
255 int v21; // eax@27
256 int v22; // ecx@29
257 //BLVFace *v23; // eax@33
258 //int v24; // esi@39
259 //int v25; // edi@39
260 int v26; // esi@41
261 int v27; // ecx@43
262 signed int v28; // eax@45
263 int v29; // ebx@47
264 int v30; // edx@49
265 int v31; // ST10_4@49
266 signed int v32; // edx@49
267 signed __int64 v33; // qtt@49
268 signed int v34; // eax@54
269 signed int v35; // esi@56
270 int result; // eax@57
271 int v37; // edi@61
272 int v38; // edx@62
273 //int v39; // [sp+Ch] [bp-34h]@1
274 //int v40; // [sp+10h] [bp-30h]@2
275 int v41; // [sp+14h] [bp-2Ch]@12
276 //unsigned __int16 *v42; // [sp+18h] [bp-28h]@1
277 //BLVSector *v43; // [sp+1Ch] [bp-24h]@1
278 int v44; // [sp+20h] [bp-20h]@10
279 int v45; // [sp+24h] [bp-1Ch]@10
280 //signed int v46; // [sp+24h] [bp-1Ch]@38
281 bool v47; // [sp+24h] [bp-1Ch]@43
282 bool v48; // [sp+28h] [bp-18h]@10
283 bool v49; // [sp+28h] [bp-18h]@41
284 bool v50; // [sp+2Ch] [bp-14h]@12
285 int v51; // [sp+2Ch] [bp-14h]@41
286 //signed int v52; // [sp+30h] [bp-10h]@7
287 signed int v53; // [sp+30h] [bp-10h]@10
288 signed int v54; // [sp+30h] [bp-10h]@41
289 signed int v55; // [sp+34h] [bp-Ch]@1
290 //signed int v56; // [sp+38h] [bp-8h]@1
291 //signed int v57; // [sp+3Ch] [bp-4h]@1
292 //int uSectorIDa; // [sp+4Ch] [bp+Ch]@1
293 //signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32
294
295 LOG_DECOMPILATION_WARNING();
296
297 //auto a1 = x;
298 //auto a2 = y;
299 //auto a3 = z;
300
301 //v5 = &pIndoor->pSectors[uSectorID];
302 auto pSector = &pIndoor->pSectors[uSectorID];
303 //v57 = y;
304 //v56 = x;
305 //v6 = 0;
306 v55 = 0;
307 //v43 = v5;
308 //v42 = v5->pFloors;
309 //v7 = pIndoor->pVertices;
310 //v39 = v5->uNumFloors;
311 //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa )
312 for (uint i = 0; i < pSector->uNumFloors; ++i)
313 {
314 //v40 = (int)&v42[v6];
315 //v8 = &pIndoor->pFaces[pSector->pFloors[i]];
316 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]];
317 if (pFloor->Clickable())
318 continue;
319
320 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 &&
321 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1)
322 {
323 //v52 = 0;
324 for (uint j = 0; j < pFloor->uNumVertices; ++j)
325 {
326 //v9 = v52;
327 //v10 = 2 * v52;
328 word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x;
329 word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x;
330 word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y;
331 word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y;
332 //}
333 //while ( v52 < v8->uNumVertices );
334 //v5 = v43;
335 }
336 v44 = 2 * pFloor->uNumVertices;
337 //v11 = 2 * pFloor->uNumVertices;
338 word_721460[2 * pFloor->uNumVertices] = word_721460[0];
339 word_721390[2 * pFloor->uNumVertices] = word_721390[0];
340
341 v48 = word_721390[0] >= y;
342 v12 = 0;
343 v53 = 0;
344 v45 = 0;
345 if ( pFloor->uNumVertices > 0 )
346 {
347 do
348 {
349 if ( v53 >= 2 )
350 break;
351 v41 = word_721390[v12 + 1];
352 v50 = word_721390[v12 + 1] >= y;
353 if ( v48 == v50 )
354 {
355 v13 = v45;
356 }
357 else
358 {
359 v13 = v45;
360 if ( word_721460[v45 + 1] >= x )
361 v14 = 0;
362 else
363 v14 = 2;
364 v15 = v14 | word_721460[v45] < x;
365 if ( v15 != 3 )
366 {
367 if ( !v15
368 || (v16 = word_721390[v45],
369 v17 = v41 - v16,
370 v18 = y - v16,
371 LODWORD(v19) = v18 << 16,
372 HIDWORD(v19) = v18 >> 16,
373 //v7 = pIndoor->pVertices,
374 (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45])
375 * v19
376 / v17) >> 16)
377 + word_721460[v45]) >= x) )
378 ++v53;
379 }
380 }
381 v12 = v13 + 1;
382 v48 = v50;
383 v45 = v12;
384 }
385 while ( v12 < v44 );
386
387 if ( v53 == 1 )
388 {
389 if ( v55 >= 50 )
390 break;
391 v20 = pFloor->uPolygonType;
392 if ( v20 == 3 || v20 == 5 )
393 {
394 v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z;
395 }
396 else
397 {
398 //v7 = pIndoor->pVertices;
399 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16)
400 + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16)
401 + HIWORD(pFloor->zCalc3);
402 }
403 v22 = v55++;
404 dword_7212C8[v22] = v21;
405 dword_721200[v22] = pSector->pFloors[i];
406 }
407 }
408 }
409 //v6 = uSectorIDa + 1;
410 }
411
412 if ( pSector->field_0 & 8 )
413 {
414 for (uint i = 0; i < pSector->uNumPortals; ++i)
415 {
416 //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]];
417 auto portal = &pIndoor->pFaces[pSector->pPortals[i]];
418 if (portal->uPolygonType != POLYGON_Floor)
419 continue;
420
421 if (x <= portal->pBounding.x2 &&
422 x >= portal->pBounding.x1 &&
423 y <= portal->pBounding.y2 &&
424 y >= portal->pBounding.y1 )
425 {
426 //v46 = 0;
427 for (uint j = 0; j < portal->uNumVertices; ++j)
428 {
429 //v24 = v46;
430 //v25 = 2 * v46;
431 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x;
432 word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x;
433 word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y;
434 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y;
435 //}
436 //while ( v46 < v23->uNumVertices );
437 //v5 = v43;
438 }
439
440 //v26 = 2 * v23->uNumVertices;
441 word_721460[2 * portal->uNumVertices] = word_721460[0];
442 word_721390[2 * portal->uNumVertices] = word_721390[0];
443 v54 = 0;
444 v51 = 0;
445 v49 = word_721390[0] >= y;
446 if ( v26 > 0 )
447 {
448 do
449 {
450 if ( v54 >= 2 )
451 break;
452 v27 = v51;
453 v47 = word_721390[v51 + 1] >= y;
454 if ( v49 != v47 )
455 {
456 if ( word_721460[v27 + 1] >= x )
457 v28 = 0;
458 else
459 v28 = 2;
460 v29 = v28 | word_721460[v27] < x;
461 if ( v29 != 3 )
462 {
463 if ( !v29
464 || (v30 = word_721390[v27],
465 v31 = word_721390[v51 + 1] - v30,
466 v32 = y - v30,
467 LODWORD(v33) = v32 << 16,
468 HIDWORD(v33) = v32 >> 16,
469 //v7 = pIndoor->pVertices,
470 (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27])
471 * v33
472 / v31) >> 16)
473 + word_721460[v27]) >= x) )
474 ++v54;
475 }
476 }
477 ++v51;
478 v49 = v47;
479 }
480 while ( v51 < v26 );
481 if ( v54 == 1 )
482 {
483 if ( v55 >= 50 )
484 break;
485 v34 = v55++;
486 dword_7212C8[v34] = -29000;
487 dword_721200[v34] = pSector->pPortals[i];
488 }
489 }
490 }
491 }
492 }
493
494 v35 = 1;
495 if ( v55 == 1 )
496 {
497 *pFaceID = dword_721200[0];
498 return dword_7212C8[0];
499 }
500 if ( !v55 )
501 return -30000;
502 *pFaceID = dword_721200[0];
503 result = dword_7212C8[0];
504 if ( v55 > 1 )
505 {
506 v37 = z + 5;
507 while ( 1 )
508 {
509 v38 = dword_7212C8[v35];
510 if ( result <= v37 )
511 break;
512 if ( v38 < result )
513 goto LABEL_67;
514 LABEL_68:
515 ++v35;
516 if ( v35 >= v55 )
517 return result;
518 }
519 if ( v38 <= result || v38 > v37 )
520 goto LABEL_68;
521 LABEL_67:
522 result = dword_7212C8[v35];
523 *pFaceID = dword_721200[v35];
524 goto LABEL_68;
525 }
526 return result;
527 }
528
529 //----- (0046D49E) --------------------------------------------------------
530 int __fastcall sub_46D49E_prolly_get_world_y_under_party(int a1, signed int a2, int a3, int a4, int *a5, int *a6, int a7)
531 {
532 signed int v7; // edi@1
533 int v8; // ebx@1
534 int v9; // eax@1
535 BSPModel *v10; // esi@4
536 ODMFace *v11; // ecx@11
537 unsigned __int8 v12; // al@11
538 char *v13; // eax@19
539 int v14; // edx@20
540 int v15; // eax@22
541 int v16; // edx@22
542 int v17; // edi@24
543 signed int v18; // edx@26
544 int v19; // eax@28
545 int v20; // edx@30
546 int v21; // ST1C_4@30
547 signed int v22; // edx@30
548 signed __int64 v23; // qtt@30
549 int v24; // eax@36
550 signed int v25; // ecx@38
551 int result; // eax@42
552 signed int v27; // ecx@43
553 int v28; // edi@44
554 signed int v29; // edx@44
555 int v30; // esi@45
556 int v31; // eax@45
557 ODMFace *v32; // eax@57
558 int v33; // ecx@59
559 int v34; // [sp+Ch] [bp-34h]@8
560 int v35; // [sp+10h] [bp-30h]@22
561 int v36; // [sp+14h] [bp-2Ch]@24
562 int v37; // [sp+18h] [bp-28h]@22
563 int v38; // [sp+1Ch] [bp-24h]@2
564 int v39; // [sp+20h] [bp-20h]@9
565 int v40; // [sp+24h] [bp-1Ch]@1
566 signed int v41; // [sp+28h] [bp-18h]@1
567 int v42; // [sp+2Ch] [bp-14h]@8
568 bool v43; // [sp+30h] [bp-10h]@22
569 bool v44; // [sp+34h] [bp-Ch]@24
570 signed int v45; // [sp+38h] [bp-8h]@1
571 signed int v46; // [sp+3Ch] [bp-4h]@1
572 signed int v47; // [sp+58h] [bp+18h]@18
573 signed int v48; // [sp+58h] [bp+18h]@22
574 signed int v49; // [sp+58h] [bp+18h]@43
575
576 v7 = a2;
577 v8 = a1;
578 v45 = a2;
579 v40 = a1;
580 v46 = 1;
581 v9 = GetTerrainHeightsAroundParty2(a1, a2, a5, a7);
582 dword_721160[0] = -1;
583 dword_721110[0] = -1;
584 dword_7211B0[0] = v9;
585 v41 = 0;
586 if ( (signed int)pOutdoor->uNumBModels <= 0 )
587 goto LABEL_63;
588 v38 = 0;
589 while ( 1 )
590 {
591 v10 = &pOutdoor->pBModels[v38];
592 if ( v8 <= pOutdoor->pBModels[v38].sMaxX )
593 {
594 if ( v8 >= v10->sMinX )
595 {
596 if ( v7 <= v10->sMaxY )
597 {
598 if ( v7 >= v10->sMinY )
599 {
600 v42 = 0;
601 v34 = v10->uNumFaces;
602 if ( (signed int)v10->uNumFaces > 0 )
603 {
604 v39 = 0;
605 while ( 1 )
606 {
607 v11 = &v10->pFaces[v39];
608 v12 = v11->uPolygonType;
609 if ( (v12 == 3 || v12 == 4)
610 && !(v11->uAttributes & 0x20000000)
611 && v8 <= v11->pBoundingBox.x2
612 && v8 >= v11->pBoundingBox.x1
613 && v7 <= v11->pBoundingBox.y2
614 && v7 >= v11->pBoundingBox.y1 )
615 {
616 v47 = 0;
617 if ( v11->uNumVertices )
618 {
619 v13 = (char *)v11->pXInterceptDisplacements;
620 do
621 {
622 v14 = 2 * v47;
623 word_721040[2 * v47] = *(short *)v13 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].x);
624 word_720F70[2 * v47] = *((short *)v13 + 20)
625 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].y);
626 word_721040[2 * v47++ + 1] = *(short *)v13
627 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].x);
628 word_720F70[v14 + 1] = *((short *)v13 + 20)
629 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].y);
630 v13 += 2;
631 }
632 while ( v47 < v11->uNumVertices );
633 v8 = v40;
634 }
635 v15 = 2 * v11->uNumVertices;
636 word_721040[2 * v11->uNumVertices] = word_721040[0];
637 word_720F70[v15] = word_720F70[0];
638 v35 = v15;
639 v16 = 0;
640 v43 = word_720F70[0] >= v45;
641 v48 = 0;
642 v37 = 0;
643 if ( v15 > 0 )
644 {
645 do
646 {
647 if ( v48 >= 2 )
648 break;
649 v17 = v16;
650 v8 = v40;
651 v36 = word_720F70[v16 + 1];
652 v44 = word_720F70[v16 + 1] >= v45;
653 if ( v43 != v44 )
654 {
655 v18 = word_721040[v17 + 1] >= v40 ? 0 : 2;
656 v19 = v18 | word_721040[v17] < v40;
657 if ( v19 != 3 )
658 {
659 if ( !v19
660 || (v20 = word_720F70[v17],
661 v21 = v36 - v20,
662 v22 = v45 - v20,
663 LODWORD(v23) = v22 << 16,
664 HIDWORD(v23) = v22 >> 16,
665 (signed int)(((unsigned __int64)(((signed int)word_721040[v17 + 1]
666 - (signed int)word_721040[v17])
667 * v23
668 / v21) >> 16)
669 + word_721040[v17]) >= v40) )
670 ++v48;
671 }
672 }
673 v16 = v37 + 1;
674 v43 = v44;
675 ++v37;
676 }
677 while ( v37 < v35 );
678 if ( v48 == 1 )
679 {
680 if ( v46 >= 20 )
681 break;
682 if ( v11->uPolygonType == 3 )
683 v24 = v10->pVertices.pVertices[v11->pVertexIDs[0]].z;
684 else
685 v24 = ((unsigned __int64)(v11->zCalc1 * (signed __int64)v8) >> 16)
686 + ((unsigned __int64)(v11->zCalc2 * (signed __int64)v45) >> 16)
687 + HIWORD(v11->zCalc3);
688 v25 = v46++;
689 dword_7211B0[v25] = v24;
690 dword_721160[v25] = v41;
691 dword_721110[v25] = v42;
692 }
693 }
694 }
695 ++v42;
696 ++v39;
697 if ( v42 >= v34 )
698 break;
699 v7 = v45;
700 }
701 }
702 }
703 }
704 }
705 }
706 ++v41;
707 ++v38;
708 if ( v41 >= (signed int)pOutdoor->uNumBModels )
709 break;
710 v7 = v45;
711 }
712 if ( v46 == 1 )
713 {
714 LABEL_63:
715 *a6 = 0;
716 return dword_7211B0[0];
717 }
718 v27 = 0;
719 v49 = 1;
720 if ( v46 <= 1 )
721 {
722 LABEL_55:
723 *a6 = 0;
724 goto LABEL_56;
725 }
726 v28 = 0;
727 v29 = 1;
728 do
729 {
730 v30 = dword_7211B0[v29];
731 v31 = *(int *)((char *)dword_7211B0 + v28);
732 if ( v30 == v31 )
733 goto LABEL_51;
734 if ( v31 > a3 + 5 )
735 {
736 if ( v30 >= v31 )
737 goto LABEL_52;
738 LABEL_51:
739 v27 = v49;
740 v28 = v29 * 4;
741 goto LABEL_52;
742 }
743 if ( v30 > v31 && v30 <= a3 + 5 )
744 goto LABEL_51;
745 LABEL_52:
746 ++v49;
747 ++v29;
748 }
749 while ( v49 < v46 );
750 if ( !v27 )
751 goto LABEL_55;
752 *a6 = dword_721110[v27] | (dword_721160[v27] << 6);
753 LABEL_56:
754 if ( v27 )
755 {
756 v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]];
757 *a5 = 0;
758 if ( v32->uAttributes & 0x10 )
759 *a5 = 1;
760 }
761 v33 = dword_7211B0[v27];
762 result = dword_7211B0[0];
763 if ( v33 >= dword_7211B0[0] )
764 result = v33;
765 return result;
766 }
767
768 //----- (0046D8E3) --------------------------------------------------------
769 int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4)
770 {
771 int v4; // ebx@1
772 unsigned int v5; // ecx@1
773 BSPModel *v6; // edi@3
774 ODMFace *v7; // esi@10
775 unsigned __int8 v8; // al@10
776 unsigned __int16 *v9; // eax@18
777 int v10; // edx@19
778 int v11; // ecx@21
779 int v12; // ecx@23
780 signed int v13; // eax@25
781 int v14; // edx@27
782 int v15; // edx@29
783 int v16; // ST18_4@29
784 signed int v17; // edx@29
785 signed __int64 v18; // qtt@29
786 int v19; // eax@35
787 signed int v20; // ecx@37
788 signed int v22; // ebx@42
789 unsigned int v23; // esi@43
790 int v24; // edx@44
791 int v25; // eax@44
792 int v26; // [sp+Ch] [bp-38h]@7
793 int v27; // [sp+10h] [bp-34h]@21
794 int v28; // [sp+18h] [bp-2Ch]@21
795 int v29; // [sp+1Ch] [bp-28h]@2
796 unsigned int v30; // [sp+20h] [bp-24h]@8
797 signed int v31; // [sp+24h] [bp-20h]@1
798 signed int v32; // [sp+28h] [bp-1Ch]@1
799 int v33; // [sp+2Ch] [bp-18h]@7
800 bool v34; // [sp+30h] [bp-14h]@21
801 bool v35; // [sp+34h] [bp-10h]@23
802 signed int v36; // [sp+38h] [bp-Ch]@17
803 signed int v37; // [sp+38h] [bp-Ch]@21
804 signed int v38; // [sp+38h] [bp-Ch]@42
805 signed int v39; // [sp+3Ch] [bp-8h]@1
806 signed int v40; // [sp+40h] [bp-4h]@1
807
808 dword_720ED0[0] = -1;
809 dword_720E80[0] = -1;
810 v4 = a1;
811 v5 = 0;
812 v40 = a2;
813 v31 = v4;
814 v39 = 1;
815 dword_720F20[0] = 10000;
816 v32 = 0;
817 if ( (signed int)pOutdoor->uNumBModels > 0 )
818 {
819 v29 = 0;
820 do
821 {
822 v6 = &pOutdoor->pBModels[v29];
823 if ( v4 <= pOutdoor->pBModels[v29].sMaxX )
824 {
825 if ( v4 >= v6->sMinX )
826 {
827 if ( v40 <= v6->sMaxY )
828 {
829 if ( v40 >= v6->sMinY )
830 {
831 v33 = v5;
832 v26 = v6->uNumFaces;
833 if ( (signed int)v6->uNumFaces > (signed int)v5 )
834 {
835 v30 = v5;
836 while ( 1 )
837 {
838 v7 = (ODMFace *)((char *)v6->pFaces + v30);
839 v8 = v7->uPolygonType;
840 if ( (v8 == 5 || v8 == 6)
841 && !(BYTE3(v7->uAttributes) & 0x20)
842 && v4 <= v7->pBoundingBox.x2
843 && v4 >= v7->pBoundingBox.x1
844 && v40 <= v7->pBoundingBox.y2
845 && v40 >= v7->pBoundingBox.y1 )
846 {
847 v36 = v5;
848 if ( v7->uNumVertices )
849 {
850 v9 = v7->pXInterceptDisplacements;
851 do
852 {
853 v10 = 2 * v36;
854 word_720DB0_xs[2 * v36] = *v9 + LOWORD(v6->pVertices.pVertices[*(v9 - 60)].x);
855 word_720CE0_ys[2 * v36] = v9[20] + LOWORD(v6->pVertices.pVertices[*(v9 - 60)].y);
856 word_720DB0_xs[2 * v36++ + 1] = *v9 + LOWORD(v6->pVertices.pVertices[*(v9 - 59)].x);
857 word_720CE0_ys[v10 + 1] = v9[20] + LOWORD(v6->pVertices.pVertices[*(v9 - 59)].y);
858 ++v9;
859 }
860 while ( v36 < v7->uNumVertices );
861 v4 = v31;
862 }
863 v27 = 2 * v7->uNumVertices;
864 word_720DB0_xs[2 * v7->uNumVertices] = word_720DB0_xs[0];
865 word_720CE0_ys[v27] = word_720CE0_ys[0];
866 v11 = 0;
867 v34 = word_720CE0_ys[0] >= v40;
868 v37 = 0;
869 v28 = 0;
870 if ( v27 > 0 )
871 {
872 do
873 {
874 if ( v37 >= 2 )
875 break;
876 v12 = v11;
877 v4 = v31;
878 v35 = word_720CE0_ys[v12 + 1] >= v40;
879 if ( v34 != v35 )
880 {
881 v13 = word_720DB0_xs[v12 + 1] >= v31 ? 0 : 2;
882 v14 = v13 | word_720DB0_xs[v12] < v31;
883 if ( v14 != 3 )
884 {
885 if ( !v14
886 || (v15 = word_720CE0_ys[v12],
887 v16 = word_720CE0_ys[v12 + 1] - v15,
888 v17 = v40 - v15,
889 LODWORD(v18) = v17 << 16,
890 HIDWORD(v18) = v17 >> 16,
891 (signed int)(((unsigned __int64)(((signed int)word_720DB0_xs[v12 + 1]
892 - (signed int)word_720DB0_xs[v12])
893 * v18
894 / v16) >> 16)
895 + word_720DB0_xs[v12]) >= v31) )
896 ++v37;
897 }
898 }
899 v11 = v28 + 1;
900 v34 = v35;
901 ++v28;
902 }
903 while ( v28 < v27 );
904 if ( v37 == 1 )
905 {
906 if ( v39 >= 20 )
907 break;
908 if ( v7->uPolygonType == 5 )
909 v19 = v6->pVertices.pVertices[v7->pVertexIDs[0]].z;
910 else
911 v19 = ((unsigned __int64)(v7->zCalc1 * (signed __int64)v4) >> 16)
912 + ((unsigned __int64)(v7->zCalc2 * (signed __int64)v40) >> 16)
913 + HIWORD(v7->zCalc3);
914 v20 = v39++;
915 dword_720F20[v20] = v19;
916 dword_720ED0[v20] = v32;
917 dword_720E80[v20] = v33;
918 }
919 }
920 }
921 ++v33;
922 v30 += 308;
923 if ( v33 >= v26 )
924 break;
925 v5 = 0;
926 }
927 }
928 }
929 }
930 }
931 }
932 ++v32;
933 ++v29;
934 v5 = 0;
935 }
936 while ( v32 < (signed int)pOutdoor->uNumBModels );
937 if ( !v39 )
938 {
939 *(int *)a4 = 0;
940 return dword_720F20[0];
941 }
942 }
943 v22 = 0;
944 v38 = v5;
945 if ( v39 <= (signed int)v5 )
946 goto LABEL_54;
947 v23 = 0;
948 do
949 {
950 v24 = dword_720F20[v5 / 4];
951 v25 = *(int *)((char *)dword_720F20 + v23);
952 if ( v24 == v25 )
953 goto LABEL_50;
954 if ( v25 > a3 + 15 )
955 {
956 if ( v24 >= v25 )
957 goto LABEL_51;
958 LABEL_50:
959 v22 = v38;
960 v23 = v5;
961 goto LABEL_51;
962 }
963 if ( v24 > v25 && v24 <= a3 + 15 )
964 goto LABEL_50;
965 LABEL_51:
966 ++v38;
967 v5 += 4;
968 }
969 while ( v38 < v39 );
970 if ( v22 )
971 {
972 *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6);
973 return dword_720F20[v22];
974 }
975 LABEL_54:
976 *(int *)a4 = 0;
977 return dword_720F20[v22];
978 }
979
980 //----- (0046DCC8) --------------------------------------------------------
981 signed __int64 __fastcall _46DCC8_get_gravity_direction_outdoor(int a1, int a2, Vec3_int_ *a3)
982 {
983 int v3; // ebx@1
984 int v4; // ST4C_4@1
985 unsigned int v5; // ST54_4@1
986 unsigned int v6; // edi@1
987 unsigned int v7; // ST50_4@1
988 int v8; // edi@1
989 int v9; // esi@1
990 int v10; // ebx@1
991 int v11; // ecx@2
992 int v12; // eax@2
993 int v13; // edx@2
994 int v14; // ebx@2
995 double v15; // st7@4
996 double v16; // st6@4
997 double v17; // st5@4
998 float v18; // ST44_4@4
999 float v19; // ST54_4@4
1000 double v20; // st4@4
1001 double v21; // st5@4
1002 float v22; // ST44_4@6
1003 double v23; // st7@4
1004 double v24; // st7@6
1005 signed __int64 result; // qax@6
1006 int v26; // [sp+14h] [bp-44h]@1
1007 int v27; // [sp+18h] [bp-40h]@1
1008 int v28; // [sp+20h] [bp-38h]@1
1009 int v29; // [sp+24h] [bp-34h]@1
1010 int v30; // [sp+28h] [bp-30h]@1
1011 int v31; // [sp+2Ch] [bp-2Ch]@1
1012 int v32; // [sp+30h] [bp-28h]@1
1013 int v33; // [sp+34h] [bp-24h]@1
1014 int v34; // [sp+38h] [bp-20h]@1
1015 int v35; // [sp+3Ch] [bp-1Ch]@1
1016 int v36; // [sp+40h] [bp-18h]@1
1017 int v37; // [sp+4Ch] [bp-Ch]@2
1018 float v38; // [sp+4Ch] [bp-Ch]@4
1019 int v39; // [sp+50h] [bp-8h]@2
1020 float v40; // [sp+50h] [bp-8h]@4
1021 int v41; // [sp+54h] [bp-4h]@2
1022
1023 v3 = a1;
1024 v4 = a2;
1025 v5 = WorldPosToGridCellX(a1);
1026 v6 = WorldPosToGridCellZ(v4) - 1;
1027 v33 = GridCellToWorldPosX(v5);
1028 v34 = GridCellToWorldPosX(v5 + 1);
1029 v35 = GridCellToWorldPosX(v5 + 1);
1030 v36 = GridCellToWorldPosX(v5);
1031 v29 = GridCellToWorldPosZ(v6);
1032 v30 = GridCellToWorldPosZ(v6);
1033 v7 = v6 + 1;
1034 v31 = GridCellToWorldPosZ(v6 + 1);
1035 v32 = GridCellToWorldPosZ(v6 + 1);
1036 v26 = pOutdoor->DoGetHeightOnTerrain(v5, v6);
1037 v27 = pOutdoor->DoGetHeightOnTerrain(v5 + 1, v6);
1038 v8 = pOutdoor->DoGetHeightOnTerrain(v5 + 1, v6 + 1);
1039 v28 = pOutdoor->DoGetHeightOnTerrain(v5, v7);
1040 v9 = v29;
1041 v10 = abs(v3 - v33);
1042 if ( abs(v29 - v4) >= v10 )
1043 {
1044 v11 = v33;
1045 v37 = v28;
1046 v39 = v36;
1047 v12 = v35;
1048 v41 = v32;
1049 v13 = v31;
1050 v14 = v8;
1051 v8 = v26;
1052 }
1053 else
1054 {
1055 v11 = v35;
1056 v41 = v30;
1057 v39 = v34;
1058 v12 = v33;
1059 v13 = v29;
1060 v9 = v31;
1061 v37 = v27;
1062 v14 = v26;
1063 }
1064 v15 = (double)(v12 - v39);
1065 v16 = (double)(v13 - v41);
1066 v17 = (double)(v14 - v37);
1067 v18 = (double)(v11 - v39);
1068 v19 = (double)(v9 - v41);
1069 v20 = (double)(v8 - v37);
1070 v38 = v20 * v16 - v19 * v17;
1071 v40 = v18 * v17 - v20 * v15;
1072 v21 = v19 * v15 - v18 * v16;
1073 v23 = sqrt(v21 * v21 + v40 * v40 + v38 * v38);
1074 if ( v23 == 0.0 )
1075 {
1076 a3->y = 0;
1077 a3->x = 0;
1078 a3->z = 65536;
1079 }
1080 v24 = 1.0 / v23;
1081 a3->x = (signed __int64)(v24 * v38 * 65536.0);
1082 a3->y = (signed __int64)(v24 * v40 * 65536.0);
1083 v22 = v21;
1084 result = (signed __int64)(v24 * v22 * 65536.0);
1085 a3->z = result;
1086 return result;
1087 }
1088 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
1089 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
1090 // 47F469: using guessed type int __stdcall GridCellToWorldPosX(int);
1091 // 47F476: using guessed type int __stdcall GridCellToWorldPosZ(int);
1092
1093 //----- (0046DEF2) --------------------------------------------------------
1094 unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID)
1095 {
1096 unsigned int result; // eax@1
1097
1098 result = uLayingItemID;
1099 if ( pObjectList->pObjects[pLayingItems[uLayingItemID].uObjectDescID].uFlags & 0x10 )
1100 result = _46BFFA_check_object_intercept(uLayingItemID, a2);
1101 return result;
1102 }
1103
1104 //----- (0046DF1A) --------------------------------------------------------
1105 signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2)
1106 {
1107 Actor *v2; // edi@1
1108 unsigned __int16 v3; // ax@1
1109 int v4; // esi@6
1110 int v5; // ecx@8
1111 int v6; // eax@10
1112 int v7; // edx@12
1113 int v8; // ecx@14
1114 int v9; // eax@14
1115 int v10; // ebx@14
1116 int v11; // esi@14
1117 int v12; // ebx@15
1118 int v13; // ebx@17
1119 unsigned int v14; // eax@20
1120 signed int result; // eax@21
1121 int v16; // [sp+Ch] [bp-10h]@1
1122 int v17; // [sp+10h] [bp-Ch]@14
1123 int v18; // [sp+14h] [bp-8h]@14
1124 int v19; // [sp+18h] [bp-4h]@14
1125
1126 v16 = a1;
1127 v2 = &pActors[a1];
1128 v3 = v2->uAIState;
1129 if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 )
1130 goto LABEL_25;
1131 v4 = v2->uActorRadius;
1132 if ( a2 )
1133 v4 = a2;
1134 v5 = v2->vPosition.x;
1135 if ( stru_721530.sMaxX > v5 + v4
1136 || stru_721530.sMinX < v5 - v4
1137 || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4)
1138 || stru_721530.sMinY < v6 - v4
1139 || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight)
1140 || stru_721530.sMinZ < v7
1141 || (v8 = v5 - stru_721530.normal.x,
1142 v9 = v6 - stru_721530.normal.y,
1143 v10 = stru_721530.prolly_normal_d + v4,
1144 v17 = stru_721530.prolly_normal_d + v4,
1145 v11 = (v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16,
1146 v18 = v8,
1147 v19 = v9,
1148 abs((v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16) > v10)
1149 || (v12 = (v18 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16, v12 <= 0)
1150 || (signed int)(((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z )
1151 {
1152 LABEL_25:
1153 result = 0;
1154 }
1155 else
1156 {
1157 v13 = v12 - sub_452A9E(v17 * v17 - v11 * v11);
1158 if ( v13 < 0 )
1159 v13 = 0;
1160 if ( v13 < stru_721530.field_7C )
1161 {
1162 stru_721530.field_7C = v13;
1163 v14 = 8 * v16;
1164 LOBYTE(v14) = 8 * v16 | 3;
1165 stru_721530.uFaceID = v14;
1166 }
1167 result = 1;
1168 }
1169 return result;
1170 }
1171 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
1172
1173 //----- (0046E0B2) --------------------------------------------------------
1174 void __cdecl _46E0B2_collide_against_decorations()
1175 {
1176 BLVSector *v0; // ebp@1
1177 LevelDecoration *v1; // edi@2
1178 DecorationDesc *v2; // esi@3
1179 int v3; // edx@4
1180 int v4; // eax@4
1181 int v5; // ecx@6
1182 int v6; // ebx@8
1183 int v7; // esi@8
1184 int v8; // ebx@10
1185 int v9; // esi@11
1186 int v10; // edi@12
1187 int v11; // eax@12
1188 int v12; // esi@14
1189 unsigned int v13; // eax@17
1190 signed int i; // [sp+4h] [bp-14h]@1
1191 int v15; // [sp+8h] [bp-10h]@10
1192 int v16; // [sp+Ch] [bp-Ch]@10
1193 int v17; // [sp+10h] [bp-8h]@10
1194 int v18; // [sp+14h] [bp-4h]@8
1195
1196 v0 = &pIndoor->pSectors[stru_721530.uSectorID];
1197 for ( i = 0; i < v0->uNumDecorations; ++i )
1198 {
1199 v1 = &pLevelDecorations[v0->pDecorationIDs[i]];
1200 if ( !(v1->field_2 & 0x20) )
1201 {
1202 v2 = &pDecorationList->pDecorations[v1->uDecorationDescID];
1203 if ( !(v2->uFlags & 1) )
1204 {
1205 v3 = v2->uRadius;
1206 v4 = v1->vPosition.x;
1207 if ( stru_721530.sMaxX <= v4 + v3 )
1208 {
1209 if ( stru_721530.sMinX >= v4 - v3 )
1210 {
1211 v5 = v1->vPosition.y;
1212 if ( stru_721530.sMaxY <= v5 + v3 )
1213 {
1214 if ( stru_721530.sMinY >= v5 - v3 )
1215 {
1216 v6 = v2->uDecorationHeight;
1217 v7 = v1->vPosition.z;
1218 v18 = v6;
1219 if ( stru_721530.sMaxZ <= v7 + v6 )
1220 {
1221 if ( stru_721530.sMinZ >= v7 )
1222 {
1223 v16 = v4 - stru_721530.normal.x;
1224 v15 = v5 - stru_721530.normal.y;
1225 v8 = stru_721530.prolly_normal_d + v3;
1226 v17 = ((v4 - stru_721530.normal.x) * stru_721530.field_58.y
1227 - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
1228 if ( abs(v17) <= stru_721530.prolly_normal_d + v3 )
1229 {
1230 v9 = (v16 * stru_721530.field_58.x + v15 * stru_721530.field_58.y) >> 16;
1231 if ( v9 > 0 )
1232 {
1233 v10 = v1->vPosition.z;
1234 v11 = stru_721530.normal.z
1235 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v9) >> 16);
1236 if ( v11 >= v10 )
1237 {
1238 if ( v11 <= v18 + v10 )
1239 {
1240 v12 = v9 - sub_452A9E(v8 * v8 - v17 * v17);
1241 if ( v12 < 0 )
1242 v12 = 0;
1243 if ( v12 < stru_721530.field_7C )
1244 {
1245 stru_721530.field_7C = v12;
1246 v13 = 8 * v0->pDecorationIDs[i];
1247 LOBYTE(v13) = v13 | 5;
1248 stru_721530.uFaceID = v13;
1249 }
1250 }
1251 }
1252 }
1253 }
1254 }
1255 }
1256 }
1257 }
1258 }
1259 }
1260 }
1261 }
1262 }
1263 }
1264
1265 //----- (0046E26D) --------------------------------------------------------
1266 void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2)
1267 {
1268 int v2; // edx@5
1269 unsigned __int16 *v3; // eax@5
1270 unsigned __int16 v4; // ax@6
1271 LevelDecoration *v5; // edi@7
1272 DecorationDesc *v6; // esi@8
1273 int v7; // edx@9
1274 int v8; // eax@9
1275 int v9; // ecx@11
1276 int v10; // ebx@13
1277 int v11; // esi@13
1278 int v12; // ebp@15
1279 int v13; // ebx@15
1280 int v14; // esi@16
1281 int v15; // edi@17
1282 int v16; // eax@17
1283 int v17; // esi@19
1284 char v18; // zf@23
1285 int v19; // [sp+0h] [bp-10h]@15
1286 unsigned __int16 *v20; // [sp+4h] [bp-Ch]@5
1287 int v21; // [sp+8h] [bp-8h]@15
1288 int v22; // [sp+Ch] [bp-4h]@13
1289
1290 if ( a1 >= 0 )
1291 {
1292 if ( a1 <= 127 )
1293 {
1294 if ( a2 >= 0 )
1295 {
1296 if ( a2 <= 127 )
1297 {
1298 v2 = a1 + (a2 << 7);
1299 v3 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]];
1300 v20 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]];
1301 if ( v3 )
1302 {
1303 do
1304 {
1305 v4 = *v3;
1306 if ( (v4 & 7) == 5 )
1307 {
1308 v5 = &pLevelDecorations[(signed __int16)v4 >> 3];
1309 if ( !(v5->field_2 & 0x20) )
1310 {
1311 v6 = &pDecorationList->pDecorations[v5->uDecorationDescID];
1312 if ( !(v6->uFlags & 1) )
1313 {
1314 v7 = v6->uRadius;
1315 v8 = v5->vPosition.x;
1316 if ( stru_721530.sMaxX <= v8 + v7 )
1317 {
1318 if ( stru_721530.sMinX >= v8 - v7 )
1319 {
1320 v9 = v5->vPosition.y;
1321 if ( stru_721530.sMaxY <= v9 + v7 )
1322 {
1323 if ( stru_721530.sMinY >= v9 - v7 )
1324 {
1325 v10 = v6->uDecorationHeight;
1326 v11 = v5->vPosition.z;
1327 v22 = v10;
1328 if ( stru_721530.sMaxZ <= v11 + v10 )
1329 {
1330 if ( stru_721530.sMinZ >= v11 )
1331 {
1332 v12 = v8 - stru_721530.normal.x;
1333 v19 = v9 - stru_721530.normal.y;
1334 v13 = stru_721530.prolly_normal_d + v7;
1335 v21 = ((v8 - stru_721530.normal.x) * stru_721530.field_58.y
1336 - (v9 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
1337 if ( abs(v21) <= stru_721530.prolly_normal_d + v7 )
1338 {
1339 v14 = (v12 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16;
1340 if ( v14 > 0 )
1341 {
1342 v15 = v5->vPosition.z;
1343 v16 = stru_721530.normal.z
1344 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v14) >> 16);
1345 if ( v16 >= v15 )
1346 {
1347 if ( v16 <= v22 + v15 )
1348 {
1349 v17 = v14 - sub_452A9E(v13 * v13 - v21 * v21);
1350 if ( v17 < 0 )
1351 v17 = 0;
1352 if ( v17 < stru_721530.field_7C )
1353 {
1354 stru_721530.field_7C = v17;
1355 stru_721530.uFaceID = (signed __int16)*v20;
1356 }
1357 }
1358 }
1359 }
1360 }
1361 }
1362 }
1363 }
1364 }
1365 }
1366 }
1367 }
1368 }
1369 }
1370 v3 = v20 + 1;
1371 v18 = *v20 == 0;
1372 ++v20;
1373 }
1374 while ( !v18 );
1375 }
1376 }
1377 }
1378 }
1379 }
1380 }
1381
1382 //----- (00486F92) --------------------------------------------------------
1383 void __cdecl sr_sub_486F92_MessWithEdgesAndSpans()
1384 {
1385 Span *v0; // ebx@1
1386 int v1; // eax@2
1387 Edge *v2; // ecx@3
1388 Edge *v3; // edx@3
1389 Edge *v4; // esi@6
1390 Edge *v5; // eax@7
1391 Edge *v6; // ecx@8
1392 Surf *v7; // esi@11
1393 double v8; // st7@13
1394 Surf *v9; // edi@13
1395 double v10; // st6@13
1396 double v11; // st7@14
1397 signed __int64 v12; // qax@14
1398 stru148 *v13; // eax@15
1399 Span *v14; // ecx@17
1400 double v15; // st7@28
1401 signed __int64 v16; // qax@28
1402 stru148 *v17; // eax@29
1403 Span *v18; // ecx@31
1404 Edge *i; // eax@40
1405 Edge *v20; // ecx@43
1406 Edge *v21; // esi@44
1407 double v22; // st7@45
1408 Edge *v23; // edx@48
1409 unsigned int v24; // [sp+10h] [bp-10h]@2
1410 float v25; // [sp+14h] [bp-Ch]@3
1411 Edge *v26; // [sp+18h] [bp-8h]@8
1412 unsigned int v27; // [sp+1Ch] [bp-4h]@1
1413
1414 v0 = pSpans;
1415 stru_80C9D8.pSurf = &stru_80C980;
1416 stru_80C9D8.field_0 = (double)(signed int)pViewport->uViewportX;
1417 stru_80C9A4.pSurf = &stru_80C980;
1418 stru_80C980.pPrev = &stru_80C980;
1419 stru_80C980.pNext = &stru_80C980;
1420 stru_80C9A4.field_0 = (double)(signed int)pViewport->uViewportZ;
1421 stru_80C980.field_8 = 0.0;
1422 stru_80C980.field_4 = 0.0;
1423 stru_80C9D8.pNext = &stru_80C9A4;
1424 stru_80C9D8.pPrev = 0;
1425 stru_80C9D8.field_8 = 1;
1426 stru_80C9A4.pNext = 0;
1427 stru_80C9A4.pPrev = &stru_80C9D8;
1428 stru_80C9A4.field_8 = 0;
1429 LODWORD(stru_80C980.field_0) = 0xC97423F0u;
1430 v27 = pViewport->uViewportY;
1431 if ( (signed int)pViewport->uViewportY > (signed int)pViewport->uViewportW )
1432 {
1433 LABEL_51:
1434 v0->field_8 = -1;
1435 }
1436 else
1437 {
1438 v1 = 52 * pViewport->uViewportY;
1439 v24 = 52 * pViewport->uViewportY;
1440 while ( 1 )
1441 {
1442 v2 = *(Edge **)((char *)&pNewEdges->pNext + v1);
1443 v3 = &stru_80C9D8;
1444 v25 = (double)(signed int)v27;
1445 if ( v2 != &defaultEdge )
1446 {
1447 do
1448 {
1449 while ( 1 )
1450 {
1451 v4 = v3->pNext;
1452 if ( v2->field_0 <= (double)v4->field_0 )
1453 break;
1454 v3 = v3->pNext;
1455 }
1456 v5 = v2->pNext;
1457 v2->pNext = v4;
1458 v2->pPrev = v3;
1459 v3->pNext->pPrev = v2;
1460 v3->pNext = v2;
1461 v3 = v2;
1462 v2 = v5;
1463 }
1464 while ( v5 != &defaultEdge );
1465 }
1466 v6 = stru_80C9D8.pNext;
1467 stru_80C980.field_20 = 0;
1468 stru_80C980.field_22 = 1;
1469 v26 = stru_80C9D8.pNext;
1470 if ( stru_80C9D8.pNext )
1471 {
1472 while ( 1 )
1473 {
1474 v7 = v6->pSurf;
1475 if ( v6->field_8 )
1476 {
1477 ++v7->field_22;
1478 if ( v7->field_22 == 1 )
1479 {
1480 v8 = v6->field_0 + 2.0;
1481 v9 = stru_80C980.pNext;
1482 v10 = (v8 - v7->field_C) * v7->field_4 + (v25 - v7->field_10) * v7->field_8 + v7->field_0;
1483 if ( v10 <= (v8 - stru_80C980.pNext->field_C) * stru_80C980.pNext->field_4
1484 + (v25 - stru_80C980.pNext->field_10) * stru_80C980.pNext->field_8
1485 + stru_80C980.pNext->field_0 )
1486 {
1487 do
1488 v9 = v9->pNext;
1489 while ( v10 <= (v8 - v9->field_C) * v9->field_4 + (v25 - v9->field_10) * v9->field_8 + v9->field_0 );
1490 v7->pNext = v9;
1491 v7->pPrev = v9->pPrev;
1492 v9->pPrev->pNext = v7;
1493 v9->pPrev = v7;
1494 }
1495 else
1496 {
1497 v11 = v6->field_0 + 0.5;
1498 v12 = (signed __int64)(v11 - (double)stru_80C980.pNext->field_20);
1499 v0->field_C = v12;
1500 if ( (signed __int16)v12 > 0 )
1501 {
1502 v0->field_A = v27;
1503 v0->field_8 = v9->field_20;
1504 v13 = v9->pParent;
1505 v0->pParent = v13;
1506 if ( v13 )
1507 {
1508 if ( v13->prolly_head )
1509 {
1510 v14 = v13->prolly_tail;
1511 if ( !v14 )
1512 return;
1513 v14->pNext = v0;
1514 }
1515 else
1516 {
1517 v13->prolly_head = v0;
1518 }
1519 v13->prolly_tail = v0;
1520 }
1521 if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 )
1522 return;
1523 ++v0;
1524 ++pOutdoorCamera->uNumSpans;
1525 }
1526 v6 = v26;
1527 v7->field_20 = (signed __int64)v11;
1528 v7->pNext = v9;
1529 v9->pPrev = v7;
1530 stru_80C980.pNext = v7;
1531 v7->pPrev = &stru_80C980;
1532 }
1533 }
1534 }
1535 else
1536 {
1537 --v7->field_22;
1538 if ( !v7->field_22 )
1539 {
1540 if ( stru_80C980.pNext == v7 )
1541 {
1542 v15 = v6->field_0 + 0.5;
1543 v16 = (signed __int64)(v15 - (double)v7->field_20);
1544 v0->field_C = v16;
1545 if ( (signed __int16)v16 > 0 )
1546 {
1547 v0->field_A = v27;
1548 v0->field_8 = v7->field_20;
1549 v17 = v7->pParent;
1550 v0->pParent = v17;
1551 if ( v17 )
1552 {
1553 if ( v17->prolly_head )
1554 {
1555 v18 = v17->prolly_tail;
1556 if ( !v18 )
1557 return;
1558 v18->pNext = v0;
1559 }
1560 else
1561 {
1562 v17->prolly_head = v0;
1563 }
1564 v17->prolly_tail = v0;
1565 }
1566 if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 )
1567 return;
1568 ++v0;
1569 ++pOutdoorCamera->uNumSpans;
1570 }
1571 v7->pNext->field_20 = (signed __int64)v15;
1572 v6 = v26;
1573 }
1574 v7->pNext->pPrev = v7->pPrev;
1575 v7->pPrev->pNext = v7->pNext;
1576 }
1577 }
1578 v26 = v6->pNext;
1579 if ( !v26 )
1580 break;
1581 v6 = v6->pNext;
1582 }
1583 }
1584 for ( i = ptr_80CA10[v27]; i; i = i->ptr_18 )
1585 {
1586 i->pPrev->pNext = i->pNext;
1587 i->pNext->pPrev = i->pPrev;
1588 }
1589 v20 = stru_80C9D8.pNext;
1590 if ( stru_80C9D8.pNext != &stru_80C9A4 )
1591 break;
1592 LABEL_50:
1593 ++v27;
1594 v1 = v24 + 52;
1595 v24 += 52;
1596 if ( (signed int)v27 > (signed int)pViewport->uViewportW )
1597 goto LABEL_51;
1598 }
1599 while ( 1 )
1600 {
1601 v21 = v20->pNext;
1602 if ( !v21 )
1603 break;
1604 v22 = v20->field_4 + v20->field_0;
1605 v20->field_0 = v22;
1606 if ( v22 < stru_80C9D8.field_0 )
1607 v20->field_0 = stru_80C9D8.field_0 + 0.0000001;
1608 while ( 1 )
1609 {
1610 v23 = v20->pPrev;
1611 if ( v20->field_0 >= (double)v23->field_0 )
1612 break;
1613 v23->pNext = v20->pNext;
1614 v20->pNext->pPrev = v23;
1615 v23->pPrev->pNext = v20;
1616 v20->pPrev = v23->pPrev;
1617 v20->pNext = v23;
1618 v23->pPrev = v20;
1619 }
1620 v20 = v21;
1621 if ( v21 == &stru_80C9A4 )
1622 goto LABEL_50;
1623 }
1624 }
1625 }
1626 // 4EC3EC: using guessed type Edge defaultEdge;
1627
1628
1629
1630 //----- (00487355) --------------------------------------------------------
1631 bool OutdoorCamera::_487355()
1632 {
1633 int v0; // esi@1
1634 stru148 *v1; // edi@2
1635 bool result; // eax@3
1636
1637 v0 = 0;
1638 if ( pOutdoorCamera->numStru148s > 0 )
1639 {
1640 v1 = array_77EC08;
1641 do
1642 {
1643 result = pGame->pLightmapBuilder->_45D3C7(v1);
1644 ++v0;
1645 ++v1;
1646 }
1647 while ( v0 < pOutdoorCamera->numStru148s );
1648 }
1649 return result;
1650 }
1651
1652
1653
1654 //----- (00487DA9) --------------------------------------------------------
1655 void __cdecl sub_487DA9()
1656 {
1657 char *v0; // eax@1
1658
1659 v0 = &array_77EC08[0].field_108;
1660 do
1661 {
1662 *v0 = 0;
1663 v0 += 268;
1664 }
1665 while ( (signed int)v0 < (signed int)&pVerticesSR_801A10[4] );
1666 }
1667
1668 //----- (00487DBE) --------------------------------------------------------
1669 void Software_ResetNewEdges()
1670 {
1671 int v0; // ecx@1
1672 Edge **v1; // eax@1
1673 signed int v2; // eax@3
1674
1675 v0 = 0;
1676 v1 = ptr_80CA10;
1677 do
1678 {
1679 ++v0;
1680 *((int *)&pNewEdges[v0] - 9) = (int)&defaultEdge;
1681 *v1 = 0;
1682 ++v1;
1683 }
1684 while ( (signed int)v1 < (signed int)&unk_80D190 );
1685 v2 = 2000;
1686 do
1687 {
1688 pSurfs->field_22 = 0;
1689 --v2;
1690 }
1691 while ( v2 );
1692 }
1693 // 4EC3EC: using guessed type Edge defaultEdge;
1694
1695
1696
1697
1698 //----- (00487E1D) --------------------------------------------------------
1699 TileTable::~TileTable()
1700 {
1701 if ( this->pTiles )
1702 {
1703 pAllocator->FreeChunk(this->pTiles);
1704 pTiles = nullptr;
1705 }
1706 uNumTiles = 0;
1707 }
1708
1709 //----- (00487E3B) --------------------------------------------------------
1710 TileDesc *TileTable::GetTileById(unsigned int uTileID)
1711 {
1712 TileDesc *result; // eax@3
1713
1714 if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) )
1715 result = this->pTiles;
1716 else
1717 result = &this->pTiles[uTileID];
1718 return result;
1719 }
1720
1721 //----- (00487E58) --------------------------------------------------------
1722 void TileTable::InitializeTileset(int uTerrainType)
1723 {
1724 TileTable *v2; // edi@1
1725 int v3; // ebx@1
1726 TileDesc *v4; // eax@2
1727 signed int i; // [sp+8h] [bp-4h]@1
1728
1729 v2 = this;
1730 v3 = 0;
1731 for ( i = 0; i < (signed int)v2->uNumTiles; ++v3 )
1732 {
1733 v4 = &v2->pTiles[v3];
1734 if ( uTerrainType == v4->uTerrainType && v4->pTileName[0] )
1735 {
1736 v2->pTiles[v3].uBitmapID = pBitmaps_LOD->LoadTexture(v4->pTileName);
1737 if ( v2->pTiles[v3].uBitmapID != -1 )
1738 pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id1);
1739 }
1740 ++i;
1741 }
1742 }
1743
1744 //----- (00487ED6) --------------------------------------------------------
1745 int TileTable::method_487ED6(signed int a1, int a2)
1746 {
1747 int v3; // esi@1
1748 TileTable *v4; // edi@1
1749 int v5; // edx@3
1750 int v6; // edx@11
1751 unsigned int v8; // [sp-4h] [bp-10h]@4
1752
1753 v3 = 0;
1754 v4 = this;
1755 if ( a1 > 8 )
1756 {
1757 v8 = 0;
1758 return v4->GetTileId(a1, v8);
1759 }
1760 if ( a2 || (v5 = rand() % 50, v5 < 20) )
1761 {
1762 v8 = 0;
1763 return v4->GetTileId(a1, v8);
1764 }
1765 if ( v5 < 30 )
1766 {
1767 v8 = 1;
1768 return v4->GetTileId(a1, v8);
1769 }
1770 if ( v5 < 40 )
1771 {
1772 v8 = 2;
1773 return v4->GetTileId(a1, v8);
1774 }
1775 if ( v5 < 48 )
1776 {
1777 v8 = 3;
1778 return v4->GetTileId(a1, v8);
1779 }
1780 v6 = rand() % 8;
1781 if ( !v6 )
1782 {
1783 v8 = 4;
1784 return v4->GetTileId(a1, v8);
1785 }
1786 if ( v6 == 1 )
1787 {
1788 v8 = 5;
1789 return v4->GetTileId(a1, v8);
1790 }
1791 if ( v6 == 2 )
1792 {
1793 v8 = 6;
1794 return v4->GetTileId(a1, v8);
1795 }
1796 if ( v6 == 3 )
1797 {
1798 v8 = 7;
1799 return v4->GetTileId(a1, v8);
1800 }
1801 if ( v6 == 4 )
1802 {
1803 v8 = 8;
1804 return v4->GetTileId(a1, v8);
1805 }
1806 if ( v6 == 5 )
1807 {
1808 v8 = 9;
1809 return v4->GetTileId(a1, v8);
1810 }
1811 if ( v6 == 6 )
1812 {
1813 v8 = 10;
1814 return v4->GetTileId(a1, v8);
1815 }
1816 if ( v6 == 7 )
1817 {
1818 v8 = 11;
1819 return v4->GetTileId(a1, v8);
1820 }
1821 return v3;
1822 }
1823
1824 //----- (00487F84) --------------------------------------------------------
1825 unsigned int TileTable::GetTileId(unsigned int uTerrainType, unsigned int uSection)
1826 {
1827 unsigned int v3; // edx@1
1828 unsigned int result; // eax@1
1829 unsigned __int16 *v5; // ecx@2
1830
1831 v3 = this->uNumTiles;
1832 result = 0;
1833 if ( (signed int)this->uNumTiles <= 0 )
1834 {
1835 LABEL_6:
1836 result = 0;
1837 }
1838 else
1839 {
1840 v5 = &this->pTiles->uSection;
1841 while ( (signed __int16)*(v5 - 1) != uTerrainType || (signed __int16)*v5 != uSection )
1842 {
1843 ++result;
1844 v5 += 13;
1845 if ( (signed int)result >= (signed int)v3 )
1846 goto LABEL_6;
1847 }
1848 }
1849 return result;
1850 }
1851
1852 //----- (00487FB4) --------------------------------------------------------
1853 void TileTable::ToFile()
1854 {
1855 TileTable *v1; // esi@1
1856 FILE *v2; // eax@1
1857 FILE *v3; // edi@1
1858
1859 auto Str = this;
1860
1861 v1 = Str;
1862 v2 = fopen("data\\dtile.bin", "wb");
1863 v3 = v2;
1864 if ( !v2 )
1865 Abortf("Unable to save dtile.bin!");
1866 fwrite(v1, 4u, 1u, v2);
1867 fwrite(v1->pTiles, 0x1Au, v1->uNumTiles, v3);
1868 fclose(v3);
1869 }
1870
1871 //----- (00488000) --------------------------------------------------------
1872 void TileTable::FromFile(void *pSerialized)
1873 {
1874 uNumTiles = *(int *)pSerialized;
1875 pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, 26 * uNumTiles, "Tile Descrip");
1876 memcpy(pTiles, (char *)pSerialized + 4, 26 * uNumTiles);
1877 }
1878
1879 //----- (00488047) --------------------------------------------------------
1880 int TileTable::FromFileTxt(const char *pFilename)
1881 {
1882 TileTable *v2; // ebp@1
1883 FILE *v3; // eax@1
1884 unsigned int v4; // ebx@3
1885 void *v5; // eax@9
1886 unsigned __int16 v6; // ax@14
1887 const char *v7; // ST14_4@14
1888 unsigned __int16 v8; // ax@14
1889 const char *v9; // esi@14
1890 int v10; // eax@17
1891 int v11; // eax@20
1892 int v12; // eax@22
1893 int v13; // eax@24
1894 int v14; // eax@26
1895 int v15; // eax@28
1896 int v16; // eax@30
1897 int v17; // eax@32
1898 int v18; // eax@34
1899 int v19; // eax@36
1900 int v20; // eax@38
1901 int v21; // eax@40
1902 int v22; // eax@42
1903 int v23; // eax@44
1904 int v24; // eax@46
1905 int v25; // eax@48
1906 int v26; // eax@50
1907 int v27; // eax@52
1908 int v28; // eax@54
1909 int v29; // eax@56
1910 int v30; // eax@58
1911 int v31; // eax@60
1912 int v32; // eax@62
1913 int v33; // eax@64
1914 int v34; // eax@66
1915 const char *v35; // esi@67
1916 int v36; // eax@70
1917 int v37; // eax@73
1918 int v38; // eax@75
1919 int v39; // eax@77
1920 int v40; // eax@79
1921 int v41; // eax@81
1922 int v42; // eax@83
1923 int v43; // eax@85
1924 int v44; // eax@87
1925 int v45; // eax@89
1926 int v46; // eax@91
1927 int v47; // eax@93
1928 int v48; // eax@108
1929 int v49; // eax@110
1930 int v50; // eax@112
1931 int v51; // eax@114
1932 int v52; // eax@116
1933 int v53; // eax@118
1934 int v54; // eax@120
1935 int v55; // eax@122
1936 int v56; // eax@124
1937 int v57; // eax@126
1938 int v58; // eax@128
1939 int v59; // eax@130
1940 int v60; // eax@132
1941 int v61; // eax@134
1942 int v62; // eax@136
1943 int v63; // eax@138
1944 int v64; // eax@140
1945 int v65; // eax@142
1946 int v66; // eax@144
1947 int v67; // eax@146
1948 int v68; // eax@148
1949 int v69; // eax@150
1950 int v70; // eax@151
1951 int j; // edi@152
1952 const char *v72; // esi@153
1953 int v73; // eax@154
1954 int v74; // eax@156
1955 int v75; // eax@160
1956 int v76; // eax@162
1957 int v77; // eax@164
1958 int v78; // eax@166
1959 int v79; // eax@168
1960 int v80; // eax@170
1961 FILE *i; // [sp-10h] [bp-304h]@3
1962 FILE *File; // [sp+4h] [bp-2F0h]@1
1963 FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4
1964 FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4
1965 char Buf; // [sp+100h] [bp-1F4h]@4
1966
1967 v2 = this;
1968 v3 = fopen(pFilename, "r");
1969 File = v3;
1970 if ( !v3 )
1971 Abortf("TileTable::load - Unable to open file: %s.");
1972 v4 = 0;
1973 for ( i = v3; fgets(&Buf, 490, i); i = File )
1974 {
1975 *strchr(&Buf, 10) = 0;
1976 memcpy(&v84, texture_frame_table_txt_parser(&Buf, &v85), sizeof(v84));
1977 if ( v84.field_0 && *v84.pProperties[0] != 47 )
1978 ++v4;
1979 }
1980 v2->uNumTiles = v4;
1981 v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip");
1982 v2->pTiles = (TileDesc *)v5;
1983 if ( !v5 )
1984 Abortf("TileTable::Load - Out of Memory!");
1985 memset(v5, 0, 26 * v2->uNumTiles);
1986 v2->uNumTiles = 0;
1987 fseek(File, 0, 0);
1988 if ( fgets(&Buf, 490, File) )
1989 {
1990 while ( 1 )
1991 {
1992 *strchr(&Buf, 10) = 0;
1993 memcpy(&v84, texture_frame_table_txt_parser(&Buf, &v85), sizeof(v84));
1994 if ( v84.field_0 )
1995 {
1996 if ( *v84.pProperties[0] != 47 )
1997 break;
1998 }
1999 LABEL_173:
2000 if ( !fgets(&Buf, 490, File) )
2001 goto LABEL_174;
2002 }
2003 strcpy(v2->pTiles[v2->uNumTiles].pTileName, v84.pProperties[0]);
2004 v6 = atoi(v84.pProperties[1]);
2005 v7 = v84.pProperties[2];
2006 v2->pTiles[v2->uNumTiles].uTileID = v6;
2007 v8 = atoi(v7);
2008 v9 = v84.pProperties[3];
2009 v2->pTiles[v2->uNumTiles].uBitmapID = v8;
2010 v2->pTiles[v2->uNumTiles].uTerrainType = 0;
2011 if ( _strcmpi(v9, "TTtype_NULL") )
2012 {
2013 if ( _strcmpi(v9, "TTtype_Start") )
2014 {
2015 if ( _strcmpi(v9, "TTtype_Grass") )
2016 {
2017 if ( _strcmpi(v9, "TTtype_Cracked") )
2018 {
2019 if ( _strcmpi(v9, "TTtype_Snow") )
2020 {
2021 if ( _strcmpi(v9, "TTtype_Sand") )
2022 {
2023 if ( _strcmpi(v9, "TTtype_Volcano") )
2024 {
2025 if ( _strcmpi(v9, "TTtype_Dirt") )
2026 {
2027 if ( _strcmpi(v9, "TTtype_Water") )
2028 {
2029 if ( _strcmpi(v9, "TTtype_Tropical") )
2030 {
2031 if ( _strcmpi(v9, "TTtype_Swamp") )
2032 {
2033 if ( _strcmpi(v9, "TTtype_City") )
2034 {
2035 if ( _strcmpi(v9, "TTtype_RoadGrassCobble") )
2036 {
2037 if ( _strcmpi(v9, "TTtype_RoadGrassDirt") )
2038 {
2039 if ( _strcmpi(v9, "TTtype_RoadCrackedCobble") )
2040 {
2041 if ( _strcmpi(v9, "TTtype_RoadCrackedDirt") )
2042 {
2043 if ( _strcmpi(v9, "TTtype_RoadSandCobble") )
2044 {
2045 if ( _strcmpi(v9, "TTtype_RoadSandDirt") )
2046 {
2047 if ( _strcmpi(v9, "TTtype_RoadVolcanoCobble") )
2048 {
2049 if ( _strcmpi(v9, "TTtype_RoadVolcanoDirt") )
2050 {
2051 if ( _strcmpi(v9, "TTtype_RoadSwampCobble") )
2052 {
2053 if ( _strcmpi(v9, "TTtype_RoadSwampDirt") )
2054 {
2055 if ( _strcmpi(v9, "TTtype_RoadTropicalCobble") )
2056 {
2057 if ( _strcmpi(v9, "TTtype_RoadTropicalDirt") )
2058 {
2059 if ( _strcmpi(v9, "TTtype_RoadSnowCobble") )
2060 {
2061 if ( _strcmpi(v9, "TTtype_RoadSnowDirt") )
2062 {
2063 if ( !_strcmpi(v9, "TTtype_RoadCityStone") )
2064 {
2065 v34 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2066 *(char *)v34 |= 0x1Cu;
2067 }
2068 }
2069 else
2070 {
2071 v33 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2072 *(char *)v33 |= 0xDu;
2073 }
2074 }
2075 else
2076 {
2077 v32 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2078 *(char *)v32 |= 0xCu;
2079 }
2080 }
2081 else
2082 {
2083 v31 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2084 *(char *)v31 |= 0x1Bu;
2085 }
2086 }
2087 else
2088 {
2089 v30 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2090 *(char *)v30 |= 0x1Au;
2091 }
2092 }
2093 else
2094 {
2095 v29 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2096 *(char *)v29 |= 0x19u;
2097 }
2098 }
2099 else
2100 {
2101 v28 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2102 *(char *)v28 |= 0x18u;
2103 }
2104 }
2105 else
2106 {
2107 v27 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2108 *(char *)v27 |= 0x11u;
2109 }
2110 }
2111 else
2112 {
2113 v26 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2114 *(char *)v26 |= 0x10u;
2115 }
2116 }
2117 else
2118 {
2119 v25 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2120 *(char *)v25 |= 0xFu;
2121 }
2122 }
2123 else
2124 {
2125 v24 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2126 *(char *)v24 |= 0xEu;
2127 }
2128 }
2129 else
2130 {
2131 v23 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2132 *(char *)v23 |= 0x17u;
2133 }
2134 }
2135 else
2136 {
2137 v22 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2138 *(char *)v22 |= 0x16u;
2139 }
2140 }
2141 else
2142 {
2143 v21 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2144 *(char *)v21 |= 0xBu;
2145 }
2146 }
2147 else
2148 {
2149 v20 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2150 *(char *)v20 |= 0xAu;
2151 }
2152 }
2153 else
2154 {
2155 v19 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2156 *(char *)v19 |= 9u;
2157 }
2158 }
2159 else
2160 {
2161 v18 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2162 *(char *)v18 |= 7u;
2163 }
2164 }
2165 else
2166 {
2167 v17 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2168 *(char *)v17 |= 8u;
2169 }
2170 }
2171 else
2172 {
2173 v16 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2174 *(char *)v16 |= 5u;
2175 }
2176 }
2177 else
2178 {
2179 v15 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2180 *(char *)v15 |= 4u;
2181 }
2182 }
2183 else
2184 {
2185 v14 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2186 *(char *)v14 |= 3u;
2187 }
2188 }
2189 else
2190 {
2191 v13 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2192 *(char *)v13 |= 2u;
2193 }
2194 }
2195 else
2196 {
2197 v12 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2198 *(char *)v12 |= 1u;
2199 }
2200 }
2201 else
2202 {
2203 v11 = (int)&v2->pTiles[v2->uNumTiles].uTerrainType;
2204 *(char *)v11 |= 6u;
2205 }
2206 }
2207 }
2208 else
2209 {
2210 v10 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2211 *(char *)v10 |= 0xFEu;
2212 }
2213 }
2214 else
2215 {
2216 LOBYTE(v2->pTiles[v2->uNumTiles].uTerrainType) = -1;
2217 }
2218 v35 = v84.pProperties[4];
2219 v2->pTiles[v2->uNumTiles].uSection = 0;
2220 v2->pTiles[v2->uNumTiles].uAttributes = 0;
2221 if ( !_strcmpi(v35, "TTsect_NULL") )
2222 {
2223 LOBYTE(v2->pTiles[v2->uNumTiles].uSection) = -1;
2224 LABEL_152:
2225 for ( j = 5; j < v84.field_0; ++j )
2226 {
2227 v72 = v84.pProperties[j];
2228 if ( _strcmpi(v84.pProperties[j], "TTattr_Burn") )
2229 {
2230 if ( _strcmpi(v72, "TTattr_Water") )
2231 {
2232 if ( _strcmpi(v72, "TTattr_Water2") )
2233 {
2234 if ( _strcmpi(v72, "TTattr_Block") )
2235 {
2236 if ( _strcmpi(v72, "TTattr_Repulse") )
2237 {
2238 if ( _strcmpi(v72, "TTattr_Flat") )
2239 {
2240 if ( _strcmpi(v72, "TTattr_Wave") )
2241 {
2242 if ( _strcmpi(v72, "TTattr_NoDraw") )
2243 {
2244 if ( !_strcmpi(v72, "TTattr_Transition") )
2245 {
2246 v80 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2247 *(short *)v80 |= 0x200u;
2248 }
2249 }
2250 else
2251 {
2252 v79 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2253 *(char *)v79 |= 0x40u;
2254 }
2255 }
2256 else
2257 {
2258 v78 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2259 *(char *)v78 |= 0x20u;
2260 }
2261 }
2262 else
2263 {
2264 v77 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2265 *(char *)v77 |= 0x10u;
2266 }
2267 }
2268 else
2269 {
2270 v76 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2271 *(char *)v76 |= 8u;
2272 }
2273 }
2274 else
2275 {
2276 v75 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2277 *(char *)v75 |= 4u;
2278 }
2279 }
2280 else
2281 {
2282 HIBYTE(v2->pTiles[v2->uNumTiles].uAttributes) |= 1u;
2283 }
2284 }
2285 else
2286 {
2287 v74 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2288 *(char *)v74 |= 2u;
2289 }
2290 }
2291 else
2292 {
2293 v73 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2294 *(char *)v73 |= 1u;
2295 }
2296 }
2297 ++v2->uNumTiles;
2298 goto LABEL_173;
2299 }
2300 if ( !_strcmpi(v35, "TTsect_Start") )
2301 {
2302 v36 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2303 *(char *)v36 |= 0xFEu;
2304 goto LABEL_152;
2305 }
2306 if ( !_strcmpi(v35, "TTsect_Base1") )
2307 goto LABEL_152;
2308 if ( !_strcmpi(v35, "TTsect_Base2") )
2309 {
2310 v37 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2311 *(char *)v37 |= 1u;
2312 goto LABEL_152;
2313 }
2314 if ( !_strcmpi(v35, "TTsect_Base3") )
2315 {
2316 v38 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2317 *(char *)v38 |= 2u;
2318 goto LABEL_152;
2319 }
2320 if ( !_strcmpi(v35, "TTsect_Base4") )
2321 {
2322 v39 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2323 *(char *)v39 |= 3u;
2324 goto LABEL_152;
2325 }
2326 if ( !_strcmpi(v35, "TTsect_Special1") )
2327 {
2328 v40 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2329 *(char *)v40 |= 4u;
2330 goto LABEL_152;
2331 }
2332 if ( !_strcmpi(v35, "TTsect_Special2") )
2333 {
2334 v41 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2335 *(char *)v41 |= 5u;
2336 goto LABEL_152;
2337 }
2338 if ( !_strcmpi(v35, "TTsect_Special3") )
2339 {
2340 v42 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2341 *(char *)v42 |= 6u;
2342 goto LABEL_152;
2343 }
2344 if ( !_strcmpi(v35, "TTsect_Special4") )
2345 {
2346 v43 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2347 *(char *)v43 |= 7u;
2348 goto LABEL_152;
2349 }
2350 if ( !_strcmpi(v35, "TTsect_Special5") )
2351 {
2352 v44 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2353 *(char *)v44 |= 8u;
2354 goto LABEL_152;
2355 }
2356 if ( !_strcmpi(v35, "TTsect_Special6") )
2357 {
2358 v45 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2359 *(char *)v45 |= 9u;
2360 goto LABEL_152;
2361 }
2362 if ( !_strcmpi(v35, "TTsect_Special7") )
2363 {
2364 v46 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2365 *(char *)v46 |= 0xAu;
2366 goto LABEL_152;
2367 }
2368 if ( !_strcmpi(v35, "TTsect_Special8") )
2369 {
2370 v47 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2371 *(char *)v47 |= 0xBu;
2372 goto LABEL_152;
2373 }
2374 if ( !_strcmpi(v35, "TTsect_NE1") )
2375 goto LABEL_130;
2376 if ( !_strcmpi(v35, "TTsect_NW1") )
2377 goto LABEL_134;
2378 if ( !_strcmpi(v35, "TTsect_SE1") )
2379 goto LABEL_130;
2380 if ( !_strcmpi(v35, "TTsect_SW1") )
2381 goto LABEL_134;
2382 if ( !_strcmpi(v35, "TTsect_E1") )
2383 goto LABEL_138;
2384 if ( !_strcmpi(v35, "TTsect_W1") )
2385 goto LABEL_140;
2386 if ( !_strcmpi(v35, "TTsect_N1") )
2387 goto LABEL_142;
2388 if ( !_strcmpi(v35, "TTsect_S1") )
2389 goto LABEL_144;
2390 if ( !_strcmpi(v35, "TTsect_XNE1") )
2391 goto LABEL_146;
2392 if ( _strcmpi(v35, "TTsect_XNW1") )
2393 {
2394 if ( !_strcmpi(v35, "TTsect_XSE1") )
2395 goto LABEL_146;
2396 if ( _strcmpi(v35, "TTsect_XSW1") )
2397 {
2398 if ( !_strcmpi(v35, "TTsect_CROS") )
2399 {
2400 LABEL_151:
2401 v70 = (int)&v2->pTiles[v2->uNumTiles].uAttributes;
2402 *(short *)v70 |= 0x200u;
2403 goto LABEL_152;
2404 }
2405 if ( !_strcmpi(v35, "TTsect_NS") )
2406 {
2407 v48 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2408 *(char *)v48 |= 1u;
2409 goto LABEL_151;
2410 }
2411 if ( !_strcmpi(v35, "TTsect_EW") )
2412 {
2413 v49 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2414 *(char *)v49 |= 2u;
2415 goto LABEL_151;
2416 }
2417 if ( !_strcmpi(v35, "TTsect_N_E") )
2418 {
2419 v50 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2420 *(char *)v50 |= 3u;
2421 goto LABEL_151;
2422 }
2423 if ( !_strcmpi(v35, "TTsect_N_W") )
2424 {
2425 v51 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2426 *(char *)v51 |= 4u;
2427 goto LABEL_151;
2428 }
2429 if ( !_strcmpi(v35, "TTsect_S_E") )
2430 {
2431 v52 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2432 *(char *)v52 |= 5u;
2433 goto LABEL_151;
2434 }
2435 if ( !_strcmpi(v35, "TTsect_S_W") )
2436 {
2437 v53 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2438 *(char *)v53 |= 6u;
2439 goto LABEL_151;
2440 }
2441 if ( !_strcmpi(v35, "TTsect_NS_E") )
2442 {
2443 v54 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2444 *(char *)v54 |= 7u;
2445 goto LABEL_151;
2446 }
2447 if ( !_strcmpi(v35, "TTsect_NS_W") )
2448 {
2449 v55 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2450 *(char *)v55 |= 8u;
2451 goto LABEL_151;
2452 }
2453 if ( !_strcmpi(v35, "TTsect_EW_N") )
2454 {
2455 v56 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2456 *(char *)v56 |= 9u;
2457 goto LABEL_151;
2458 }
2459 if ( !_strcmpi(v35, "TTsect_EW_S") )
2460 {
2461 v57 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2462 *(char *)v57 |= 0xAu;
2463 goto LABEL_151;
2464 }
2465 if ( !_strcmpi(v35, "TTsect_NCAP") )
2466 {
2467 v58 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2468 *(char *)v58 |= 0xBu;
2469 goto LABEL_151;
2470 }
2471 if ( !_strcmpi(v35, "TTsect_ECAP") )
2472 {
2473 LABEL_130:
2474 v59 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2475 *(char *)v59 |= 0xCu;
2476 goto LABEL_151;
2477 }
2478 if ( !_strcmpi(v35, "TTsect_SCAP") )
2479 {
2480 v60 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2481 *(char *)v60 |= 0xDu;
2482 goto LABEL_151;
2483 }
2484 if ( !_strcmpi(v35, "TTsect_WCAP") )
2485 {
2486 LABEL_134:
2487 v61 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2488 *(char *)v61 |= 0xEu;
2489 goto LABEL_151;
2490 }
2491 if ( !_strcmpi(v35, "TTsect_DN") )
2492 {
2493 v62 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2494 *(char *)v62 |= 0xFu;
2495 goto LABEL_151;
2496 }
2497 if ( !_strcmpi(v35, "TTsect_DS") )
2498 {
2499 LABEL_138:
2500 v63 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2501 *(char *)v63 |= 0x10u;
2502 goto LABEL_151;
2503 }
2504 if ( !_strcmpi(v35, "TTsect_DW") )
2505 {
2506 LABEL_140:
2507 v64 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2508 *(char *)v64 |= 0x11u;
2509 goto LABEL_151;
2510 }
2511 if ( !_strcmpi(v35, "TTsect_DE") )
2512 {
2513 LABEL_142:
2514 v65 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2515 *(char *)v65 |= 0x12u;
2516 goto LABEL_151;
2517 }
2518 if ( !_strcmpi(v35, "TTsect_DSW") )
2519 {
2520 LABEL_144:
2521 v66 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2522 *(char *)v66 |= 0x13u;
2523 goto LABEL_151;
2524 }
2525 if ( !_strcmpi(v35, "TTsect_DNE") )
2526 {
2527 LABEL_146:
2528 v67 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2529 *(char *)v67 |= 0x14u;
2530 goto LABEL_151;
2531 }
2532 if ( !_strcmpi(v35, "TTsect_DSE") )
2533 {
2534 v68 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2535 *(char *)v68 |= 0x15u;
2536 goto LABEL_151;
2537 }
2538 if ( _strcmpi(v35, "TTsect_DNW") )
2539 goto LABEL_152;
2540 }
2541 }
2542 v69 = (int)&v2->pTiles[v2->uNumTiles].uSection;
2543 *(char *)v69 |= 0x16u;
2544 goto LABEL_151;
2545 }
2546 LABEL_174:
2547 fclose(File);
2548 return 1;
2549 }
2550
2551
2552
2553 //----- (0048958E) --------------------------------------------------------
2554 stru12_MemoryBlock::stru12_MemoryBlock(int a2)
2555 {
2556 stru12_MemoryBlock *v2; // esi@1
2557 void *v3; // eax@1
2558 void *v4; // ecx@1
2559 stru12_MemoryBlock *result; // eax@1
2560
2561 v2 = this;
2562 v3 = operator new(8 * a2 + 16);
2563 v2->pBlockBase = v3;
2564 v4 = (char *)v3 + (-(signed int)v3 & 7);
2565 result = v2;
2566 v2->pAlignedBlock = v4;
2567 }
2568
2569 //----- (004895B7) --------------------------------------------------------
2570 stru12::stru12(stru11 *pStru11)
2571 {
2572 stru12 *v2; // esi@1
2573
2574 v2 = this;
2575 this->field_44 = 0x41000000u;
2576 this->field_4C = 0x46000000u;
2577 //this->vdestructor_ptr = stru12::_4898E6;
2578 this->field_48 = 0;
2579 this->field_50 = 0;
2580 this->field_54 = 0x33D6BF95u;
2581 this->field_58 = 0;
2582
2583 for (int i = 0; i < 12; ++i)
2584 v2->pMemBlocks[i] = new stru12_MemoryBlock(640);
2585 /*
2586 v3 = (stru12_MemoryBlock *)operator new(8u);
2587 if ( v3 )
2588 v4 = AllocAlignedMem(v3, 640);
2589 else
2590 v4 = 0;
2591 v2->pMemBlocks[0] = v4;
2592 /*v5 = (stru12_MemoryBlock *)operator new(8u);
2593 if ( v5 )
2594 v6 = AllocAlignedMem(v5, 640);
2595 else
2596 v6 = 0;
2597 v2->pMemBlocks[1] = v6;
2598 v7 = (stru12_MemoryBlock *)operator new(8u);
2599 if ( v7 )
2600 v8 = AllocAlignedMem(v7, 640);
2601 else
2602 v8 = 0;
2603 v2->pMemBlocks[2] = v8;
2604 v9 = (stru12_MemoryBlock *)operator new(8u);
2605 if ( v9 )
2606 v10 = AllocAlignedMem(v9, 640);
2607 else
2608 v10 = 0;
2609 v2->pMemBlocks[3] = v10;
2610 v11 = (stru12_MemoryBlock *)operator new(8u);
2611 if ( v11 )
2612 v12 = AllocAlignedMem(v11, 640);
2613 else
2614 v12 = 0;
2615 v2->pMemBlocks[4] = v12;
2616 v13 = (stru12_MemoryBlock *)operator new(8u);
2617 if ( v13 )
2618 v14 = AllocAlignedMem(v13, 640);
2619 else
2620 v14 = 0;
2621 v2->pMemBlocks[5] = v14;
2622 v15 = (stru12_MemoryBlock *)operator new(8u);
2623 if ( v15 )
2624 v16 = AllocAlignedMem(v15, 640);
2625 else
2626 v16 = 0;
2627 v2->pMemBlocks[6] = v16;
2628 v17 = (stru12_MemoryBlock *)operator new(8u);
2629 if ( v17 )
2630 v18 = AllocAlignedMem(v17, 640);
2631 else
2632 v18 = 0;
2633 v2->pMemBlocks[7] = v18;
2634 v19 = (stru12_MemoryBlock *)operator new(8u);
2635 if ( v19 )
2636 v20 = AllocAlignedMem(v19, 640);
2637 else
2638 v20 = 0;
2639 v2->pMemBlocks[8] = v20;
2640 v21 = (stru12_MemoryBlock *)operator new(8u);
2641 if ( v21 )
2642 v22 = AllocAlignedMem(v21, 640);
2643 else
2644 v22 = 0;
2645 v2->pMemBlocks[9] = v22;
2646 v23 = (stru12_MemoryBlock *)operator new(8u);
2647 if ( v23 )
2648 v24 = AllocAlignedMem(v23, 640);
2649 else
2650 v24 = 0;
2651 v2->pMemBlocks[10] = v24;
2652 v25 = (stru12_MemoryBlock *)operator new(8u);
2653 if ( v25 )
2654 v26 = AllocAlignedMem(v25, 640);
2655 else
2656 v26 = 0;
2657 v2->field_8C = 0;
2658 v2->pMemBlocks[11] = v26;*/
2659 }
2660
2661 //----- (00489810) --------------------------------------------------------
2662 stru12::~stru12()
2663 {
2664 for (int i = 0; i < 12; ++i)
2665 delete pMemBlocks[i];
2666 /*if ( v2 )
2667 stru12_MemoryBlock::dtor(v2, 1);
2668 v3 = v1->pMemBlocks[1];
2669 if ( v3 )
2670 stru12_MemoryBlock::dtor(v3, 1);
2671 v4 = v1->pMemBlocks[2];
2672 if ( v4 )
2673 stru12_MemoryBlock::dtor(v4, 1);
2674 v5 = v1->pMemBlocks[3];
2675 if ( v5 )
2676 stru12_MemoryBlock::dtor(v5, 1);
2677 v6 = v1->pMemBlocks[4];
2678 if ( v6 )
2679 stru12_MemoryBlock::dtor(v6, 1);
2680 v7 = v1->pMemBlocks[5];
2681 if ( v7 )
2682 stru12_MemoryBlock::dtor(v7, 1);
2683 v8 = v1->pMemBlocks[6];
2684 if ( v8 )
2685 stru12_MemoryBlock::dtor(v8, 1);
2686 v9 = v1->pMemBlocks[7];
2687 if ( v9 )
2688 stru12_MemoryBlock::dtor(v9, 1);
2689 v10 = v1->pMemBlocks[8];
2690 if ( v10 )
2691 stru12_MemoryBlock::dtor(v10, 1);
2692 v11 = v1->pMemBlocks[9];
2693 if ( v11 )
2694 stru12_MemoryBlock::dtor(v11, 1);
2695 v12 = v1->pMemBlocks[10];
2696 if ( v12 )
2697 stru12_MemoryBlock::dtor(v12, 1);
2698 v13 = v1->pMemBlocks[11];
2699 if ( v13 )
2700 stru12_MemoryBlock::dtor(v13, 1);*/
2701 }
2702
2703 //----- (004898BF) --------------------------------------------------------
2704 stru12_MemoryBlock::~stru12_MemoryBlock()
2705 {
2706 stru12_MemoryBlock *v2; // esi@1
2707 void *v3; // ST00_4@1
2708
2709 v2 = this;
2710 v3 = this->pBlockBase;
2711 this->pAlignedBlock = 0;
2712 free(v3);
2713 v2->pBlockBase = 0;
2714 /*if ( a2 & 1 )
2715 free(v2);*/
2716 }
2717
2718 //----- (004898E6) --------------------------------------------------------
2719 void stru12::_4898E6()
2720 {
2721 void *v1; // eax@1
2722 void *v2; // edx@1
2723 char *v3; // edi@2
2724 double v4; // st7@2
2725 char *v5; // ebx@2
2726 double v6; // st6@3
2727 double v7; // st5@3
2728 double v8; // st4@3
2729 int v9; // esi@3
2730 double v10; // st3@3
2731 float v11; // ST34_4@5
2732 double v12; // st6@10
2733 double v13; // ST0C_8@10
2734 char *v14; // [sp+14h] [bp-44h]@2
2735 char *v15; // [sp+18h] [bp-40h]@2
2736 char *v16; // [sp+1Ch] [bp-3Ch]@2
2737 char *v17; // [sp+20h] [bp-38h]@2
2738 char *v18; // [sp+24h] [bp-34h]@2
2739 float v19; // [sp+30h] [bp-28h]@3
2740 float v20; // [sp+38h] [bp-20h]@3
2741 char *v21; // [sp+3Ch] [bp-1Ch]@2
2742 int v22; // [sp+40h] [bp-18h]@1
2743 char *v23; // [sp+44h] [bp-14h]@2
2744 char *v24; // [sp+48h] [bp-10h]@2
2745 int v25; // [sp+4Ch] [bp-Ch]@2
2746 float v26; // [sp+50h] [bp-8h]@3
2747 float v27; // [sp+54h] [bp-4h]@3
2748
2749 v22 = 0;
2750 v1 = this->pMemBlocks[1]->pAlignedBlock;
2751 v2 = this->pMemBlocks[6]->pAlignedBlock;
2752 if ( this->field_8C > 0 )
2753 {
2754 v24 = (char *)((char *)pMemBlocks[0]->pAlignedBlock - v1);
2755 v23 = (char *)((char *)pMemBlocks[2]->pAlignedBlock - v1);
2756 v18 = (char *)((char *)pMemBlocks[7]->pAlignedBlock - v2);
2757 v17 = (char *)((char *)pMemBlocks[8]->pAlignedBlock - v2);
2758 v25 = (int)v1 - (int)v2;
2759 v16 = (char *)((char *)pMemBlocks[9]->pAlignedBlock - v2);
2760 v3 = (char *)((char *)pMemBlocks[4]->pAlignedBlock - v2);
2761 v15 = (char *)((char *)pMemBlocks[10]->pAlignedBlock - v2);
2762 v4 = 1.0;
2763 v5 = (char *)((char *)pMemBlocks[5]->pAlignedBlock - v2);
2764 v21 = (char *)((char *)pMemBlocks[3]->pAlignedBlock - v2);
2765 v14 = (char *)((char *)pMemBlocks[11]->pAlignedBlock - v2);
2766 do
2767 {
2768 v26 = *(float *)&v24[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.x;
2769 v27 = *(float *)((char *)v2 + v25) - (double)pIndoorCamera->pos.y;
2770 v6 = *(float *)&v23[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.z;
2771 v7 = pIndoorCamera->fRotationYCosine;
2772 v8 = pIndoorCamera->fRotationYSine;
2773 v20 = pIndoorCamera->fRotationXCosine;
2774 v19 = pIndoorCamera->fRotationXSine;
2775 v9 = (int)((char *)v2 + (int)v21);
2776 v10 = v27 * pIndoorCamera->fRotationYSine + pIndoorCamera->fRotationYCosine * v26;
2777 if ( pIndoorCamera->sRotationX )
2778 {
2779 v11 = v10;
2780 *(float *)v9 = v11 * pIndoorCamera->fRotationXCosine + pIndoorCamera->fRotationXSine * v6;
2781 *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26;
2782 *(float *)((char *)v2 + (int)v5) = v20 * v6 - v11 * v19;
2783 }
2784 else
2785 {
2786 *(float *)v9 = v10;
2787 *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26;
2788 *(float *)((char *)v2 + (int)v5) = v6;
2789 }
2790 if ( *(float *)v9 >= 8.0 )
2791 {
2792 if ( (double)pOutdoorCamera->shading_dist_mist >= *(float *)v9 )
2793 {
2794 *(int *)v2 = 0;
2795 v12 = v4 / (*(float *)v9 + 0.0000001) * (double)pOutdoorCamera->int_fov_rad;
2796 *(float *)((char *)v2 + (int)v18) = (double)pViewport->uScreenCenterX
2797 - v12 * *(float *)((char *)v2 + (int)v3);
2798 *(float *)((char *)v2 + (int)v17) = (double)pViewport->uScreenCenterY
2799 - v12 * *(float *)((char *)v2 + (int)v5);
2800 *(float *)((char *)v2 + (int)v16) = v4
2801 - v4 / (*(float *)v9 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
2802 *(float *)((char *)v2 + (int)v15) = v4 / (*(float *)v9 + 0.0000001);
2803 v13 = *(float *)v9 + 6.7553994e15;
2804 v4 = 1.0;
2805 *(int *)((char *)v2 + (int)v14) = LODWORD(v13);
2806 }
2807 else
2808 {
2809 *(int *)v2 = 2;
2810 }
2811 }
2812 else
2813 {
2814 *(int *)v2 = 1;
2815 }
2816 ++v22;
2817 v2 = (char *)v2 + 4;
2818 }
2819 while ( v22 < this->field_8C );
2820 }
2821 this->field_8C = 0;
2822 }
2823
2824
2825
2826
2827
2828 //----- (0048A959) --------------------------------------------------------
2829 unsigned int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace)
2830 {
2831 float r = ((uColor & 0x00FF0000) >> 16) / 255.0f,
2832 g = ((uColor & 0x0000FF00) >> 8) / 255.0f,
2833 b = (uColor & 0x000000FF) / 255.0f;
2834
2835 float h, s, v;
2836 RGB2HSV(&h, &s, r, g, b, &v);
2837
2838 if ( h_replace != -1.0 )
2839 h = h_replace;
2840 if ( s_replace != -1.0 )
2841 s = s_replace;
2842 if ( v_replace != -1.0 )
2843 v = v_replace;
2844 HSV2RGB(&r, &g, &b, h, s, v);
2845
2846 return (((uint)floorf(r * 255.0f + 0.5f) & 0xFF) << 16) |
2847 (((uint)floorf(g * 255.0f + 0.5f) & 0xFF) << 8) |
2848 ((uint)floorf(b * 255.0f + 0.5f) & 0xFF);
2849 }
2850
2851
2852 //----- (0048B561) --------------------------------------------------------
2853 int _48B561_mess_with_scaling_along_z(/*int a1, */float a2)
2854 {
2855 //v2 = a2 - 0.5;
2856 //v3 = v2 + 6.7553994e15;
2857 int v4 = floorf(a2 - 0.5f + 0.5f);
2858 //v7 = (a2 - (double)SLODWORD(v3)) * 65536.0;
2859 //v5 = v7 + 6.7553994e15;
2860 //return LODWORD(v5) | (v4 << 16);
2861 int v5 = floorf((a2 - v4) * 65536.0f + 0.5f);
2862 return v5 | (v4 << 16);
2863 }
2864
2865
2866
2867
2868 //----- (004908DE) --------------------------------------------------------
2869 signed int __cdecl sub_4908DE()
2870 {
2871 char *v0; // esi@1
2872 signed int v1; // edx@2
2873 char *v2; // eax@2
2874 signed int v3; // ecx@2
2875
2876 v0 = (char *)pParty->pPlayers[0].pActiveSkills;
2877 while ( 1 )
2878 {
2879 v1 = 0;
2880 v2 = v0;
2881 v3 = 37;
2882 do
2883 {
2884 if ( *(short *)v2 )
2885 ++v1;
2886 v2 += 2;
2887 --v3;
2888 }
2889 while ( v3 );
2890 if ( v1 < 4 )
2891 break;
2892 v0 += 6972;
2893 if ( (signed int)v0 >= (signed int)&pParty->field_777C[18] )
2894 return 1;
2895 }
2896 return 0;
2897 }
2898
2899
2900
2901
2902 //----- (00491CB5) --------------------------------------------------------
2903 void __cdecl LoadPlayerPortraintsAndVoices()
2904 {
2905 //Texture **v0; // ebx@1
2906 //int v1; // eax@2
2907 //int v2; // edi@3
2908 char *v3; // esi@5
2909 char *v4; // [sp+10h] [bp-4h]@1
2910
2911 pIcons_LOD->dword_011BA0 = pIcons_LOD->uNumLoadedFiles;
2912
2913 for (uint i = 0; i < 4; ++i)
2914 for (uint j = 0; j < 56; ++j)
2915 {
2916 sprintf(pTmpBuf, "%s%02d", pPlayerPortraitsNames[pParty->pPlayers[i].uFace], j + 1);
2917 pTextures_PlayerFaces[i][j] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
2918 }
2919
2920 pTexture_PlayerFaceEradicated = pIcons_LOD->LoadTexturePtr("ERADCATE", TEXTURE_16BIT_PALETTE);
2921 pTexture_PlayerFaceDead = pIcons_LOD->LoadTexturePtr("DEAD", TEXTURE_16BIT_PALETTE);
2922 pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE);
2923
2924 if (byte_4ED498)
2925 for (uint i = 0; i < 4; ++i)
2926 {
2927 pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0);
2928 pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0);
2929 }
2930 }
2931
2932 //----- (00491DE7) --------------------------------------------------------
2933 int __fastcall ReloadPlayerPortraits(int a1, int a2)
2934 {
2935 int result; // eax@1
2936 const char **v3; // ebp@1
2937 Texture **v4; // ebx@1
2938 int v5; // esi@2
2939
2940 result = 0;
2941 v3 = &pPlayerPortraitsNames[a2];
2942 v4 = pTextures_PlayerFaces[a1];
2943 do
2944 {
2945 v5 = result + 1;
2946 sprintf(pTmpBuf, "%s%02d", *v3, result + 1);
2947 pIcons_LOD->ReloadTexture(*v4, pTmpBuf, 2);
2948 result = v5;
2949 ++v4;
2950 }
2951 while ( v5 < 56 );
2952 return result;
2953 }
2954
2955
2956 //----- (00491E3A) --------------------------------------------------------
2957 void __cdecl sub_491E3A()
2958 {
2959 Player *v0; // ebx@1
2960 signed int v1; // esi@3
2961 char *v2; // eax@4
2962 unsigned int v3; // eax@7
2963 unsigned int v4; // edx@8
2964 char *v5; // ecx@9
2965 int v6; // edi@17
2966 Texture *v7; // ebx@18
2967 struct IDirect3DTexture2 **v8; // eax@19
2968 struct IDirect3DTexture2 *v9; // eax@20
2969 struct IDirectDrawSurface **v10; // eax@22
2970 struct IDirectDrawSurface *v11; // eax@23
2971 int v12; // eax@26
2972
2973 v0 = pParty->pPlayers;
2974 do
2975 {
2976 if ( byte_4ED498 )
2977 {
2978 v1 = 0;
2979 if ( (signed int)pSoundList->uNumSounds <= 0 )
2980 {
2981 LABEL_7:
2982 v3 = 0;
2983 }
2984 else
2985 {
2986 v2 = (char *)&pSoundList->pSounds->uSoundID;
2987 while ( *(int *)v2 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4998 )
2988 {
2989 ++v1;
2990 v2 += 120;
2991 if ( v1 >= (signed int)pSoundList->uNumSounds )
2992 goto LABEL_7;
2993 }
2994 v3 = v1;
2995 }
2996 pSoundList->_4A9DCD(v3, 1);
2997 v4 = 0;
2998 if ( (signed int)pSoundList->uNumSounds <= 0 )
2999 {
3000 LABEL_12:
3001 v4 = 0;
3002 }
3003 else
3004 {
3005 v5 = (char *)&pSoundList->pSounds->uSoundID;
3006 while ( *(int *)v5 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4999 )
3007 {
3008 ++v4;
3009 v5 += 120;
3010 if ( (signed int)v4 >= (signed int)pSoundList->uNumSounds )
3011 goto LABEL_12;
3012 }
3013 }
3014 pSoundList->_4A9DCD(v4, 1);
3015 }
3016 ++v0;
3017 }
3018 while ( (signed int)v0 < (signed int)pParty->pHirelings );
3019 v6 = pIcons_LOD->uNumLoadedFiles - 1;
3020 if ( v6 >= pIcons_LOD->dword_011BA0 )
3021 {
3022 v7 = &pIcons_LOD->pTextures[v6];
3023 do
3024 {
3025 v7->Release();
3026 v8 = pIcons_LOD->pHardwareTextures;
3027 if ( v8 )
3028 {
3029 v9 = v8[v6];
3030 if ( v9 )
3031 {
3032 v9->Release();
3033 pIcons_LOD->pHardwareTextures[v6] = 0;
3034 }
3035 }
3036 v10 = pIcons_LOD->pHardwareSurfaces;
3037 if ( v10 )
3038 {
3039 v11 = v10[v6];
3040 if ( v11 )
3041 {
3042 v11->Release();
3043 pIcons_LOD->pHardwareSurfaces[v6] = 0;
3044 }
3045 }
3046 --v6;
3047 --v7;
3048 }
3049 while ( v6 >= pIcons_LOD->dword_011BA0 );
3050 }
3051 v12 = pIcons_LOD->dword_011BA0;
3052 pIcons_LOD->dword_011BA0 = 0;
3053 pIcons_LOD->uNumLoadedFiles = v12;
3054 }
3055 // 4ED498: using guessed type char byte_4ED498;
3056
3057 //----- (00491F87) --------------------------------------------------------
3058 void __cdecl DrawHiredNPCs()
3059 {
3060 int v6; // eax@15
3061 char v7; // al@17
3062 unsigned int v8; // eax@18
3063 int v9; // esi@18
3064 int v10; // eax@18
3065 unsigned int v11; // eax@19
3066 unsigned int v12; // esi@19
3067 unsigned int v13; // eax@23
3068 IconFrame *v14; // eax@24
3069 unsigned int v15; // eax@26
3070 char pContainer[20]; // [sp+Ch] [bp-30h]@18
3071 unsigned int v17; // [sp+20h] [bp-1Ch]@19
3072 signed int uFrameID; // [sp+24h] [bp-18h]@19
3073 int i; // [sp+28h] [bp-14h]@15
3074 unsigned int v20; // [sp+2Ch] [bp-10h]@20
3075 unsigned int v21; // [sp+30h] [bp-Ch]@19
3076 int v22; // [sp+34h] [bp-8h]@2
3077 unsigned __int8 v23; // [sp+3Bh] [bp-1h]@2
3078
3079 if ( bNoNPCHiring != 1 )
3080 {
3081 v23 = 0;
3082 v22 = 0;
3083 for (uint i = 0; i < 2; ++i)
3084 {
3085 if (pParty->pHirelings[i].pName)
3086 pTmpBuf[v22++] = i;
3087 }
3088
3089 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
3090 {
3091 if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
3092 {
3093 if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
3094 {
3095 if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
3096 pTmpBuf[v22++] = i + 2;
3097 }
3098 }
3099 }
3100
3101 v6 = (unsigned __int8)pParty->field_709;
3102 for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
3103 {
3104 if ( v23 >= 2u )
3105 break;
3106 v7 = pTmpBuf[v6];
3107 if ( (unsigned __int8)v7 >= 2u )
3108 {
3109 sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
3110 v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
3111 pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23],
3112 (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
3113 }
3114 else
3115 {
3116 sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
3117 v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
3118 v9 = v23;
3119 pRenderer->DrawTextureIndexed(
3120 pHiredNPCsIconsOffsetsX[v9],
3121 pHiredNPCsIconsOffsetsY[v9],
3122 (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
3123 v10 = (unsigned __int8)pTmpBuf[i];
3124 if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 )
3125 {
3126 uFrameID = pParty->pHirelings[v10].evtb;
3127 v11 = pHiredNPCsIconsOffsetsX[v9];
3128 v12 = pHiredNPCsIconsOffsetsY[v9];
3129 v17 = v11;
3130 v21 = 0;
3131 if ( (signed int)pIconsFrameTable->uNumIcons <= 0 )
3132 {
3133 LABEL_23:
3134 v13 = 0;
3135 }
3136 else
3137 {
3138 v20 = 0;
3139 while ( _strcmpi("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) )
3140 {
3141 ++v21;
3142 v20 += 32;
3143 if ( (signed int)v21 >= (signed int)pIconsFrameTable->uNumIcons )
3144 goto LABEL_23;
3145 }
3146 v13 = v21;
3147 }
3148 v14 = pIconsFrameTable->GetFrame(v13, uFrameID);
3149 pRenderer->DrawTextureTransparent(v17, v12, &pIcons_LOD->pTextures[v14->uTextureID]);
3150 }
3151 }
3152 ++v23;
3153 }
3154 }
3155 }
3156 // 6BE3C5: using guessed type char bNoNPCHiring;
3157
3158
3159
3160 //----- (004921C1) --------------------------------------------------------
3161 void GameUI_DrawPortraits(unsigned int _this)
3162 {
3163 Texture *pFace; // eax@10
3164 unsigned int v7; // eax@17
3165 PlayerFrame *pFrame; // eax@21
3166 unsigned int v9; // eax@27
3167 bool v10; // eax@33
3168 bool v11; // edi@40
3169 bool v12; // edx@43
3170 bool v13; // ecx@46
3171 int v16; // eax@57
3172 int v19; // eax@62
3173 Texture *pPortrait; // [sp-4h] [bp-1Ch]@27
3174 unsigned int v22; // [sp+14h] [bp-4h]@1
3175
3176 v22 = _this;
3177 if ( qword_A750D8 )
3178 {
3179 qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
3180 if ( qword_A750D8 <= 0 )
3181 {
3182 if ( pPlayers[word_A750E2]->CanAct() )
3183 pPlayers[word_A750E2]->PlaySound(word_A750E0, 0);
3184 qword_A750D8 = 0i64;
3185 }
3186 }
3187
3188 for (uint i = 0; i < 4; ++i)
3189 {
3190 auto pPlayer = pParty->pPlayers + i;
3191
3192 if (pPlayer->Eradicated())
3193 {
3194 pFace = pTexture_PlayerFaceEradicated;
3195 LABEL_27:
3196 pPortrait = pFace;
3197 v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
3198 if ( pParty->pPartyBuffs[11].uExpireTime )
3199 pRenderer->_4A6E7E(v9, 0x183u, pPortrait);
3200 else
3201 pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait);
3202 auto _v1 = 0;
3203 v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
3204 if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
3205 _v1 = 1;
3206 v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
3207 v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
3208 v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
3209 if ( v13 | v12 | v11 | _v1 | v10 )
3210 sub_441A4E(i);
3211 goto LABEL_50;
3212 }
3213 if (pPlayer->Dead())
3214 {
3215 pFace = pTexture_PlayerFaceDead;
3216 goto LABEL_27;
3217 }
3218 v7 = 0;
3219 for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
3220 if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID)
3221 {
3222 v7 = j;
3223 break;
3224 }
3225 if ( v7 == 0 )
3226 v7 = 1;
3227 if (pPlayer->uExpressionID == 21 )
3228 pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->field_1AA8, &pPlayer->field_1AA4, pMiscTimer->uTimeElapsed);
3229 else
3230 pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
3231 if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 )
3232 {
3233 pPlayer->field_1AA2 = pFrame->uTextureID - 1;
3234 pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
3235 goto LABEL_27;
3236 }
3237 LABEL_50:
3238 ;
3239 }
3240 if ( pParty->bTurnBasedModeOn == 1 )
3241 {
3242 if ( pTurnEngine->field_4 != 1 )
3243 {
3244 if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
3245 {
3246 //v14 = 0;
3247 if ( pTurnEngine->uActorQueueSize > 0 )
3248 {
3249 //v15 = (char *)pTurnEngine->pQueue;
3250 for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
3251 {
3252 auto pElem = pTurnEngine->pQueue + i;
3253
3254 if ( (pElem->uPackedID & 7) != 4 )
3255 break;
3256 v16 = dword_5079D0;
3257 if ( pParty->uFlags & 0x10 )
3258 {
3259 v16 = dword_5079CC;
3260 }
3261 else
3262 {
3263 if ( pParty->uFlags & 0x20 )
3264 v16 = dword_5079C8;
3265 }
3266 pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
3267 0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
3268 }
3269 }
3270 }
3271 }
3272 }
3273 else
3274 {
3275 for (uint i = 0; i < 4; ++i)
3276 {
3277 auto pPlayer = pParty->pPlayers + i;
3278 if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
3279 {
3280 v19 = dword_5079D0;
3281 if ( pParty->uFlags & 0x10 )
3282 {
3283 v19 = dword_5079CC;
3284 }
3285 else
3286 {
3287 if ( pParty->uFlags & 0x20 )
3288 v19 = dword_5079C8;
3289 }
3290 pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
3291 0x181u, (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
3292 }
3293 }
3294 }
3295 }
3296
3297
3298 //----- (0049387A) --------------------------------------------------------
3299 int CycleCharacter(unsigned int _this)
3300 {
3301 signed int result; // eax@1
3302 signed int v2; // ecx@2
3303 signed int v3; // ecx@8
3304
3305 result = uActiveCharacter;
3306 if ( _this )
3307 {
3308 v2 = 0;
3309 while ( 1 )
3310 {
3311 --result;
3312 if ( result < 1 )
3313 result = 4;
3314 if ( !pPlayers[result]->uTimeToRecovery )
3315 break;
3316 ++v2;
3317 if ( v2 >= 4 )
3318 return uActiveCharacter;
3319 }
3320 }
3321 else
3322 {
3323 v3 = 0;
3324 while ( 1 )
3325 {
3326 ++result;
3327 if ( result > 4 )
3328 result = 1;
3329 if ( !pPlayers[result]->uTimeToRecovery )
3330 break;
3331 ++v3;
3332 if ( v3 >= 4 )
3333 return uActiveCharacter;
3334 }
3335 }
3336 return result;
3337 }
3338
3339 //----- (004938D1) --------------------------------------------------------
3340 void __fastcall Rest(unsigned int uHoursToSleep)
3341 {
3342 unsigned int v1; // esi@1
3343 double v2; // st7@3
3344 Player **v3; // esi@3
3345
3346 v1 = uHoursToSleep;
3347 if ( uHoursToSleep > 240 )
3348 InitializeActors();
3349 v2 = (double)(7680 * v1) * 0.033333335;
3350 pParty->uTimePlayed += (signed __int64)v2;
3351 v3 = &pPlayers[1];
3352 do
3353 {
3354 (*v3)->Recover((signed __int64)v2);
3355 ++v3;
3356 }
3357 while ( (signed int)v3 <= (signed int)&pPlayers[4] );
3358 _494035_timed_effects__water_walking_damage__etc();
3359 }
3360
3361 //----- (00493938) --------------------------------------------------------
3362 int __cdecl _493938_regenerate()
3363 {
3364 int v0; // edi@1
3365 signed __int64 v1; // qax@1
3366 int v2; // ecx@1
3367 int result; // eax@1
3368 int v4; // eax@2
3369 int v5; // edi@5
3370 char *v6; // ecx@5
3371 char v7; // sf@5
3372 char *v8; // ecx@10
3373 int v9; // edi@15
3374 signed int v10; // eax@15
3375 __int16 *v11; // edx@16
3376 int v12; // eax@20
3377 int v13; // ebx@20
3378 unsigned int *v14; // esi@21
3379 unsigned int v15; // ecx@21
3380 unsigned int v16; // eax@21
3381 int v17; // edx@21
3382 int v18; // eax@21
3383 signed int v19; // eax@21
3384 signed int v20; // ebx@25
3385 Player *v21; // esi@25
3386 ITEM_EQUIP_TYPE v22; // edi@30
3387 //int v23; // edx@31
3388 signed int v24; // ecx@32
3389 signed int v25; // eax@33
3390 int v26; // eax@35
3391 int v27; // eax@36
3392 int v28; // eax@37
3393 int v29; // eax@40
3394 int v30; // eax@41
3395 signed int v31; // ecx@53
3396 char *v32; // eax@53
3397 char *v33; // edi@82
3398 int v34; // ecx@88
3399 int v35; // eax@88
3400 char *v36; // edi@99
3401 int v37; // edi@104
3402 int v38; // edi@106
3403 int v39; // edi@111
3404 int v40; // ecx@113
3405 char v41[400]; // [sp+4h] [bp-22Ch]@20
3406 LayingItem a1; // [sp+194h] [bp-9Ch]@15
3407 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15
3408 int v44; // [sp+210h] [bp-20h]@22
3409 int v45; // [sp+214h] [bp-1Ch]@25
3410 int v46; // [sp+218h] [bp-18h]@25
3411 int v47; // [sp+21Ch] [bp-14h]@25
3412 int v48; // [sp+220h] [bp-10h]@25
3413 int v49; // [sp+224h] [bp-Ch]@24
3414 int v50; // [sp+228h] [bp-8h]@25
3415 int v51; // [sp+22Ch] [bp-4h]@2
3416
3417 v0 = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60;
3418 v1 = (signed __int64)((double)pParty->uLastRegenerationTime * 0.234375);
3419 v2 = (signed int)v1 / 60;
3420 result = (signed int)v1 / 60 + 5;
3421 if ( v0 >= result )
3422 {
3423 v51 = 0;
3424 v4 = (v0 - v2) / 5;
3425 if (pParty->FlyActive())
3426 {
3427 if ( pParty->bFlying )
3428 {
3429 if ( !(pParty->pPartyBuffs[7].uFlags & 1) )
3430 {
3431 v5 = v4 * pParty->pPartyBuffs[7].uPower;
3432 __debugbreak();
3433 v6 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000];
3434 v7 = *(int *)v6 - v5 < 0;
3435 *(int *)v6 -= v5;
3436 if ( v7 )
3437 {
3438 *(int *)v6 = 0;
3439 pParty->uFlags &= 0xFFFFFFBFu;
3440 pParty->bFlying = 0;
3441 v51 = 1;
3442 }
3443 }
3444 }
3445 }
3446 if (pParty->WaterWalkActive())
3447 {
3448 if (pParty->uFlags & 0x80 )
3449 {
3450 if ( !(pParty->pPartyBuffs[18].uFlags & 1) )
3451 {
3452 __debugbreak();
3453 v8 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000];
3454 v7 = *(int *)v8 - v4 < 0;
3455 *(int *)v8 -= v4;
3456 if ( v7 )
3457 {
3458 *(int *)v8 = 0;
3459 LOBYTE(pParty->uFlags) &= 0x7Fu;
3460 v51 = 1;
3461 }
3462 }
3463 }
3464 }
3465 if (pParty->ImmolationActive())
3466 {
3467 //LayingItem::LayingItem(&a1);
3468 v9 = 0;
3469 a3.z = 0;
3470 a3.y = 0;
3471 a3.x = 0;
3472 a1.stru_24.Reset();
3473 a1.field_4C = pParty->pPartyBuffs[10].uPower;
3474 a1.field_50 = pParty->ImmolationSkillLevel();
3475 v10 = 0;
3476 a1.uItemType = 1070;
3477 a1.field_48 = 8;
3478 if ( (signed int)pObjectList->uNumObjects <= 0 )
3479 {
3480 LABEL_19:
3481 LOWORD(v10) = 0;
3482 }
3483 else
3484 {
3485 v11 = &pObjectList->pObjects->uObjectID;
3486 while ( stru_4E3ACC[8].uItemType != *v11 )
3487 {
3488 ++v10;
3489 v11 += 28;
3490 if ( v10 >= (signed int)pObjectList->uNumObjects )
3491 goto LABEL_19;
3492 }
3493 }
3494 a1.uObjectDescID = v10;
3495 a1.field_60_distance_related_prolly_lod = 0;
3496 v12 = 8 * pParty->pPartyBuffs[10].uCaster;
3497 LOBYTE(v12) = v12 | 4;
3498 a1.uAttributes = 0;
3499 a1.uSectorID = 0;
3500 a1.uSpriteFrameID = 0;
3501 a1.field_58 = v12;
3502 a1.uFacing = 0;
3503 a1.uSoundID = 0;
3504 v13 = sub_46A89E((int)v41, 100, 307);
3505 if ( v13 > 0 )
3506 {
3507 do
3508 {
3509 v14 = (unsigned int *)&v41[4 * v9];
3510 v15 = *v14;
3511 v16 = *v14;
3512 a1.vPosition.x = pActors[v16].vPosition.x;
3513 v17 = pActors[v16].vPosition.y;
3514 a1.vPosition.z = pActors[v16].vPosition.z;
3515 v18 = 8 * v15;
3516 LOBYTE(v18) = 8 * v15 | 3;
3517 a1.vPosition.y = v17;
3518 a1.field_5C = v18;
3519 v19 = a1.Create(0, 0, 0, 0);
3520 DamageMonsterFromParty(8 * v19 | 2, *v14, &a3);
3521 ++v9;
3522 }
3523 while ( v9 < v13 );
3524 }
3525 }
3526 v44 = 0;
3527 if ( sub_476387() == 1 )
3528 v44 = 1;
3529 v49 = 0;
3530 LABEL_25:
3531 v20 = 0;
3532 v21 = &pParty->pPlayers[v49];
3533 v50 = 0;
3534 v47 = 0;
3535 v45 = 0;
3536 v48 = 0;
3537 v46 = 0;
3538 if ( v44 && v21->uClass == 31 )
3539 v50 = 1;
3540 if ( v21->uClass == 35 )
3541 v48 = 1;
3542 v22 = (ITEM_EQUIP_TYPE)0;
3543 while ( 1 )
3544 {
3545 if ( v21->HasItemEquipped(v22) )
3546 {
3547 //v23 = v21->pEquipment.pIndices;
3548 auto _idx = v21->pEquipment.pIndices[v22];
3549 v24 = v21->pInventoryItems[_idx].uItemID;
3550 if ( v24 > 134 )
3551 {
3552 if ( v24 == 529 )
3553 goto LABEL_43;
3554 if ( v24 == 535 )
3555 goto LABEL_44;
3556 if ( v24 == 515 )
3557 {
3558 v47 = 1;
3559 }
3560 else
3561 {
3562 if ( v24 == 532 )
3563 goto LABEL_50;
3564 }
3565 }
3566 else
3567 {
3568 v25 = v21->pInventoryItems[_idx].uAdditionalValue;
3569 if ( v25 <= 50 )
3570 {
3571 if ( v25 != 50 )
3572 {
3573 v26 = v25 - 37;
3574 if ( v26 )
3575 {
3576 v27 = v26 - 1;
3577 if ( !v27 )
3578 goto LABEL_50;
3579 v28 = v27 - 6;
3580 if ( v28 )
3581 {
3582 if ( v28 != 3 )
3583 goto LABEL_51;
3584 LABEL_50:
3585 v50 = 1;
3586 goto LABEL_51;
3587 }
3588 }
3589 }
3590 LABEL_44:
3591 v20 = 1;
3592 goto LABEL_51;
3593 }
3594 v29 = v25 - 54;
3595 if ( !v29 )
3596 goto LABEL_44;
3597 v30 = v29 - 1;
3598 if ( !v30 )
3599 goto LABEL_50;
3600 if ( v30 == 11 )
3601 {
3602 LABEL_43:
3603 v20 = 1;
3604 v50 = 1;
3605 goto LABEL_51;
3606 }
3607 }
3608 }
3609 LABEL_51:
3610 v22 = (ITEM_EQUIP_TYPE)((int)v22 + 1);
3611 if ( (signed int)v22 >= 16 )
3612 {
3613 if ( v48 )
3614 {
3615 v31 = 0;
3616 v32 = (char *)v21->pInventoryItems;
3617 while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 )
3618 {
3619 ++v31;
3620 v32 += 36;
3621 if ( v31 >= 138 )
3622 goto LABEL_59;
3623 }
3624 v48 = 0;
3625 v45 = 1;
3626 }
3627 LABEL_59:
3628 if ( v21->pConditions[17] )
3629 v46 = 1;
3630 if ( v20 && !v21->pConditions[14] && !v21->pConditions[16] )
3631 {
3632 ++v21->sHealth;
3633 if ( v21->sHealth > v21->GetMaxHealth() )
3634 v21->sHealth = v21->GetMaxHealth();
3635 if ( v21->pConditions[13] && v21->sHealth > 0 )
3636 {
3637 LODWORD(v21->pConditions[13]) = 0;
3638 HIDWORD(v21->pConditions[13]) = 0;
3639 }
3640 v51 = 1;
3641 }
3642 if ( SHIDWORD(v21->pPlayerBuffs[12].uExpireTime) >= 0
3643 && (SHIDWORD(v21->pPlayerBuffs[12].uExpireTime) > 0 || LODWORD(v21->pPlayerBuffs[12].uExpireTime))
3644 && !v21->pConditions[14]
3645 && !v21->pConditions[16] )
3646 {
3647 v21->sHealth += 5 * v21->pPlayerBuffs[12].uPower;
3648 if ( v21->sHealth > v21->GetMaxHealth() )
3649 v21->sHealth = v21->GetMaxHealth();
3650 if ( v21->pConditions[13] && v21->sHealth > 0 )
3651 {
3652 LODWORD(v21->pConditions[13]) = 0;
3653 HIDWORD(v21->pConditions[13]) = 0;
3654 }
3655 v51 = 1;
3656 }
3657 if ( v50 )
3658 {
3659 v33 = (char *)&v21->sMana;
3660 ++*(int *)v33;
3661 if ( v21->sMana > v21->GetMaxMana() )
3662 *(int *)v33 = v21->GetMaxMana();
3663 v51 = 1;
3664 }
3665 if ( v47 && !v21->pConditions[14] && !v21->pConditions[16] )
3666 {
3667 v34 = LODWORD(v21->pConditions[13]);
3668 --v21->sHealth;
3669 v35 = v21->sHealth;
3670 if ( !(HIDWORD(v21->pConditions[13]) | v34) && v35 < 0 )
3671 v21->pConditions[13] = pParty->uTimePlayed;
3672 if ( v35 < 1 )
3673 {
3674 if ( v21->sHealth + v21->uEndurance + v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1
3675 || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 )
3676 {
3677 v21->pConditions[13] = pParty->uTimePlayed;
3678 }
3679 else
3680 {
3681 if ( !v21->pConditions[14] )
3682 v21->pConditions[14] = pParty->uTimePlayed;
3683 }
3684 }
3685 v51 = 1;
3686 }
3687 if ( v45 )
3688 {
3689 v36 = (char *)&v21->sMana;
3690 ++*(int *)v36;
3691 if ( v21->sMana > v21->GetMaxMana() )
3692 *(int *)v36 = v21->GetMaxMana();
3693 }
3694 if ( v48 && !v21->pConditions[14] && !v21->pConditions[16] )
3695 {
3696 v37 = v21->sHealth;
3697 if ( v37 > v21->GetMaxHealth() / 2 )
3698 v21->sHealth = v37 - 2;
3699 v38 = v21->sMana;
3700 if ( v38 > v21->GetMaxMana() / 2 )
3701 v21->sMana = v38 - 2;
3702 }
3703 if ( v46 && !v21->pConditions[14] && !v21->pConditions[16] )
3704 {
3705 v39 = v21->sHealth;
3706 if ( v39 > v21->GetMaxHealth() / 2 )
3707 v21->sHealth = v39 - 1;
3708 v40 = v21->sMana;
3709 if ( v40 > 0 )
3710 v21->sMana = v40 - 1;
3711 }
3712 ++v49;
3713 if ( v49 >= 4 )
3714 {
3715 result = HIDWORD(pParty->uTimePlayed);
3716 pParty->uLastRegenerationTime = pParty->uTimePlayed;
3717 if ( !viewparams->bRedrawGameUI )
3718 {
3719 result = v51;
3720 viewparams->bRedrawGameUI = v51;
3721 }
3722 return result;
3723 }
3724 goto LABEL_25;
3725 }
3726 }
3727 }
3728 return result;
3729 }
3730
3731
3732
3733 //----- (00493F79) --------------------------------------------------------
3734 int sub_493F79(stru351 *_this, __int64 a2)
3735 {
3736 signed __int64 v2; // ST2C_8@1
3737 signed __int64 v3; // qax@1
3738 signed __int64 v4; // ST1C_8@1
3739 unsigned __int64 v5; // qax@1
3740 unsigned int v6; // ebx@1
3741 int result; // eax@1
3742
3743 v2 = (signed __int64)((double)a2 * 0.234375);
3744 v3 = v2 / 60 / 60;
3745 v4 = v3;
3746 v5 = (unsigned int)v3 / 0x18;
3747 v6 = (unsigned int)(v5 / 7) >> 2;
3748 _this->field_0 = v2 % 60;
3749 _this->field_4 = v2 / 60 % 60;
3750 _this->field_8 = v4 % 24;
3751 _this->field_10 = v5 / 7 & 3;
3752 _this->field_C = (unsigned int)v5 % 0x1C;
3753 result = v6 / 0xC + 1168;
3754 _this->field_14 = v6 % 0xC;
3755 _this->field_18 = result;
3756 return result;
3757 }
3758
3759
3760
3761
3762
3763 //----- (00494035) --------------------------------------------------------
3764 void __cdecl _494035_timed_effects__water_walking_damage__etc()
3765 {
3766 signed __int64 v0; // qax@1
3767 signed __int64 v1; // ST30_8@1
3768 signed __int64 v2; // ST38_8@1
3769 unsigned __int64 v3; // qax@1
3770 unsigned int v4; // edi@1
3771 //signed int v5; // eax@4
3772 //char *v6; // ecx@5
3773 //Player *v7; // esi@8
3774 //char *v8; // ecx@12
3775 Player *pPlayer; // esi@15
3776 //void *v10; // esi@25
3777 unsigned int v11; // ecx@27
3778 signed int v12; // edi@29
3779 Player *v13; // ecx@30
3780 Player *v14; // esi@35
3781 double v15; // st7@35
3782 Player **v16; // esi@43
3783 Player *v17; // edi@44
3784 double v18; // st7@44
3785 float v19; // ST28_4@48
3786 double v20; // ST38_8@48
3787 Player *v21; // esi@51
3788 signed int v22; // edi@53
3789 int v23; // eax@59
3790 int v24; // ecx@60
3791 int v25; // eax@63
3792 int v26; // ecx@64
3793 int v27; // eax@67
3794 int v28; // ecx@68
3795 int v29; // eax@71
3796 int v30; // ecx@72
3797 int v31; // eax@75
3798 int v32; // ecx@76
3799 int v33; // eax@79
3800 int v34; // ecx@80
3801 int v35; // eax@83
3802 int v36; // ecx@84
3803 int v37; // eax@87
3804 int v38; // ecx@88
3805 int v39; // eax@91
3806 int v40; // ecx@92
3807 int v41; // eax@95
3808 int v42; // ecx@96
3809 bool v43; // ebx@102
3810 //SpellBuff *v44; // edi@104
3811 //signed int v45; // ebp@104
3812 bool v46; // edi@111
3813 //SpellBuff *v47; // esi@113
3814 //Player **v48; // esi@119
3815 //signed int v49; // edi@121
3816 //char *v50; // esi@122
3817 signed int v51; // edx@128
3818 signed int v52; // ecx@130
3819 int v53; // eax@131
3820 Player *v54; // eax@141
3821 unsigned int v55; // [sp-8h] [bp-38h]@18
3822 unsigned int v56; // [sp-8h] [bp-38h]@55
3823 int v57; // [sp-4h] [bp-34h]@18
3824 int v58; // [sp-4h] [bp-34h]@33
3825 int v59; // [sp-4h] [bp-34h]@55
3826 unsigned int v60; // [sp+10h] [bp-20h]@1
3827 unsigned int v61; // [sp+14h] [bp-1Ch]@1
3828 Player **v62; // [sp+14h] [bp-1Ch]@50
3829 unsigned int a2; // [sp+18h] [bp-18h]@1
3830 signed int a2a; // [sp+18h] [bp-18h]@47
3831 signed int v65; // [sp+1Ch] [bp-14h]@47
3832
3833 a2 = pParty->uCurrentHour;
3834 v61 = pParty->uDaysPlayed;
3835 v60 = pEventTimer->uTimeElapsed;
3836 pParty->uTimePlayed += (signed int)pEventTimer->uTimeElapsed;
3837 v0 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60;
3838 v1 = v0;
3839 v0 /= 60i64;
3840 v2 = v0;
3841 v3 = (unsigned int)v0 / 24;
3842 v4 = (unsigned int)(v3 / 7) >> 2;
3843 pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60;
3844 pParty->uCurrentMinute = v1 % 60;
3845 pParty->uCurrentMonthWeek = v3 / 7 & 3;
3846 pParty->uCurrentHour = v2 % 24;
3847 pParty->uDaysPlayed = (unsigned int)v3 % 28;
3848 pParty->uCurrentMonth = v4 % 12;
3849 pParty->uCurrentYear = v4 / 0xC + 1168;
3850 if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 28 > v61) )
3851 {
3852 pParty->pHirelings[0].bHasUsedTheAbility = false;
3853 pParty->pHirelings[1].bHasUsedTheAbility = false;
3854
3855 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
3856 pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false;
3857
3858 ++pParty->field_764;
3859 if ( pParty->field_764 > 1u )
3860 {
3861 for (uint i = 0; i < 4; ++i)
3862 pParty->pPlayers[i].SetCondition(1, 0);
3863
3864 if ( pParty->uNumFoodRations )
3865 {
3866 Party::TakeFood(1u);
3867 }
3868 else
3869 {
3870 for (uint i = 0; i < 4; ++i)
3871 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / ((unsigned __int8)pParty->field_764 + 1) + 1;
3872 }
3873 if ( pParty->field_764 > 3u )
3874 {
3875 pPlayer = pParty->pPlayers;
3876 do
3877 {
3878 pPlayer->Zero();
3879 if ( !(pPlayer->pConditions[15] | pPlayer->pConditions[16] | pPlayer->pConditions[14]) )
3880 {
3881 if ( rand() % 100 < 5 * (unsigned __int8)pParty->field_764 )
3882 {
3883 v57 = 0;
3884 v55 = 14;
3885 LABEL_21:
3886 pPlayer->SetCondition(v55, v57);
3887 goto LABEL_22;
3888 }
3889 if ( rand() % 100 < 10 * (unsigned __int8)pParty->field_764 )
3890 {
3891 v57 = 0;
3892 v55 = 5;
3893 goto LABEL_21;
3894 }
3895 }
3896 LABEL_22:
3897 ++pPlayer;
3898 }
3899 while ( (signed int)pPlayer < (signed int)pParty->pHirelings );
3900 }
3901 }
3902 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
3903 pOutdoor->SetFog();
3904
3905 for (uint i = 0; i < 4; ++i)
3906 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
3907 }
3908 v11 = LODWORD(pParty->uTimePlayed);
3909 if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )
3910 {
3911 v12 = 1;
3912 pParty->field_6FC = LODWORD(pParty->uTimePlayed) + 128;
3913 viewparams->bRedrawGameUI = 1;
3914 while ( 1 )
3915 {
3916 if ( pPlayers[v12]->WearsItem(516, 3)
3917 || v13->HasEnchantedItemEquipped(71)
3918 || (signed __int64)v13->pPlayerBuffs[23].uExpireTime > 0 )
3919 {
3920 v58 = 0;
3921 }
3922 else
3923 {
3924 v58 = 0;
3925 if ( !sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v12) )
3926 {
3927 v14 = pPlayers[v12];
3928 v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1;
3929 v14->ReceiveDamage((signed __int64)v15, 0);
3930 if ( pParty->uFlags & 4 )
3931 {
3932 strcpy(GameUI_StatusBar_TimedString, pGlobalTXT_LocalizationStrings[660]);
3933 GameUI_StatusBar_TimedStringTimeLeft = 128;
3934 }
3935 goto LABEL_39;
3936 }
3937 v13 = pPlayers[v12];
3938 }
3939 v13->PlayEmotion(37, v58);
3940 LABEL_39:
3941 ++v12;
3942 if ( v12 > 4 )
3943 {
3944 v11 = LODWORD(pParty->uTimePlayed);
3945 break;
3946 }
3947 }
3948 }
3949 if ( pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)__PAIR__(HIDWORD(pParty->uTimePlayed), v11) )
3950 {
3951 viewparams->bRedrawGameUI = 1;
3952 pParty->field_6FC = v11 + 128;
3953 v16 = &pPlayers[1];
3954 do
3955 {
3956 v17 = *v16;
3957 v18 = (double)(*v16)->GetMaxHealth() * 0.1;
3958 v17->ReceiveDamage((signed __int64)v18, 0);
3959 if ( pParty->uFlags & 0x200 )
3960 {
3961 strcpy(GameUI_StatusBar_TimedString, pGlobalTXT_LocalizationStrings[661]);
3962 GameUI_StatusBar_TimedStringTimeLeft = 128;
3963 }
3964 ++v16;
3965 }
3966 while ( (signed int)v16 <= (signed int)&pPlayers[4] );
3967 }
3968 _493938_regenerate();
3969 v65 = 4;
3970 a2a = v60;
3971 if ( pParty->uFlags2 & 2 )
3972 {
3973 v19 = (double)(signed int)v60 * 0.5;
3974 v20 = v19 + 6.7553994e15;
3975 a2a = LODWORD(v20);
3976 if ( SLODWORD(v20) <= 0 )
3977 a2a = 1;
3978 }
3979 v62 = &pPlayers[1];
3980 do
3981 {
3982 v21 = *v62;
3983 if ( (*v62)->uTimeToRecovery )
3984 v21->Recover(a2a);
3985 v22 = v21->sHealth;
3986 if ( v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) + v22 + v21->uEndurance >= 1
3987 || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 )
3988 {
3989 if ( v22 >= 1 )
3990 goto LABEL_59;
3991 v59 = 0;
3992 v56 = 13;
3993 }
3994 else
3995 {
3996 v59 = 0;
3997 v56 = 14;
3998 }
3999 v21->SetCondition(v56, v59);
4000 LABEL_59:
4001 v23 = (int)&v21->field_E0;
4002 if ( v21->field_E0 )
4003 {
4004 v24 = *(int *)v23 - v60;
4005 if ( v24 > 0 )
4006 {
4007 *(int *)v23 = v24;
4008 }
4009 else
4010 {
4011 *(int *)v23 = 0;
4012 viewparams->bRedrawGameUI = 1;
4013 }
4014 }
4015 v25 = (int)&v21->field_E4;
4016 if ( v21->field_E4 )
4017 {
4018 v26 = *(int *)v25 - v60;
4019 if ( v26 > 0 )
4020 {
4021 *(int *)v25 = v26;
4022 }
4023 else
4024 {
4025 *(int *)v25 = 0;
4026 viewparams->bRedrawGameUI = 1;
4027 }
4028 }
4029 v27 = (int)&v21->field_E8;
4030 if ( v21->field_E8 )
4031 {
4032 v28 = *(int *)v27 - v60;
4033 if ( v28 > 0 )
4034 {
4035 *(int *)v27 = v28;
4036 }
4037 else
4038 {
4039 *(int *)v27 = 0;
4040 viewparams->bRedrawGameUI = 1;
4041 }
4042 }
4043 v29 = (int)&v21->field_EC;
4044 if ( v21->field_EC )
4045 {
4046 v30 = *(int *)v29 - v60;
4047 if ( v30 > 0 )
4048 {
4049 *(int *)v29 = v30;
4050 }
4051 else
4052 {
4053 *(int *)v29 = 0;
4054 viewparams->bRedrawGameUI = 1;
4055 }
4056 }
4057 v31 = (int)&v21->field_F0;
4058 if ( v21->field_F0 )
4059 {
4060 v32 = *(int *)v31 - v60;
4061 if ( v32 > 0 )
4062 {
4063 *(int *)v31 = v32;
4064 }
4065 else
4066 {
4067 *(int *)v31 = 0;
4068 viewparams->bRedrawGameUI = 1;
4069 }
4070 }
4071 v33 = (int)&v21->field_F4;
4072 if ( v21->field_F4 )
4073 {
4074 v34 = *(int *)v33 - v60;
4075 if ( v34 > 0 )
4076 {
4077 *(int *)v33 = v34;
4078 }
4079 else
4080 {
4081 *(int *)v33 = 0;
4082 viewparams->bRedrawGameUI = 1;
4083 }
4084 }
4085 v35 = (int)&v21->field_F8;
4086 if ( v21->field_F8 )
4087 {
4088 v36 = *(int *)v35 - v60;
4089 if ( v36 > 0 )
4090 {
4091 *(int *)v35 = v36;
4092 }
4093 else
4094 {
4095 *(int *)v35 = 0;
4096 viewparams->bRedrawGameUI = 1;
4097 }
4098 }
4099 v37 = (int)&v21->field_FC;
4100 if ( v21->field_FC )
4101 {
4102 v38 = *(int *)v37 - v60;
4103 if ( v38 > 0 )
4104 {
4105 *(int *)v37 = v38;
4106 }
4107 else
4108 {
4109 *(int *)v37 = 0;
4110 viewparams->bRedrawGameUI = 1;
4111 }
4112 }
4113 v39 = (int)&v21->field_100;
4114 if ( v21->field_100 )
4115 {
4116 v40 = *(int *)v39 - v60;
4117 if ( v40 > 0 )
4118 {
4119 *(int *)v39 = v40;
4120 }
4121 else
4122 {
4123 *(int *)v39 = 0;
4124 viewparams->bRedrawGameUI = 1;
4125 }
4126 }
4127 v41 = (int)&v21->field_104;
4128 if ( v21->field_104 )
4129 {
4130 v42 = *(int *)v41 - v60;
4131 if ( v42 > 0 )
4132 {
4133 *(int *)v41 = v42;
4134 }
4135 else
4136 {
4137 *(int *)v41 = 0;
4138 viewparams->bRedrawGameUI = 1;
4139 }
4140 }
4141 if ( v21->pConditions[2] | v21->pConditions[12] | v21->pConditions[13] | v21->pConditions[14] | v21->pConditions[15] | v21->pConditions[16] )
4142 --v65;
4143 v43 = (signed __int64)v21->pPlayerBuffs[7].uExpireTime > 0;
4144
4145 for (uint k = 0; k < 24; ++k)
4146 v21->pPlayerBuffs[k]._4585CA(pParty->uTimePlayed);
4147
4148 if ( v43 && (signed __int64)v21->pPlayerBuffs[7].uExpireTime <= 0 )
4149 v21->SetCondition(1u, 0);
4150 ++v62;
4151 }
4152 while ( (signed int)v62 <= (signed int)&pPlayers[4] );
4153 v46 = (signed __int64)pParty->pPartyBuffs[8].uExpireTime > 0;
4154
4155 for (uint i = 0; i < 20; ++i)
4156 {
4157 if (pParty->pPartyBuffs[i]._4585CA(pParty->uTimePlayed) == 1)
4158 viewparams->bRedrawGameUI = 1;
4159 }
4160
4161 if ( v46 && (signed __int64)pParty->pPartyBuffs[8].uExpireTime <= 0 )
4162 {
4163 for (uint i = 0; i < 4; ++i)
4164 pParty->pPlayers[i].SetCondition(1, 0);
4165 }
4166
4167 for (uint i = 0; i < 2; ++i)
4168 {
4169 auto pBuf = &pParty->pPartyBuffs[dword_4EE07C[i]];
4170 if (pBuf->uExpireTime == 0)
4171 continue;
4172
4173 if ( !(pBuf->uFlags & 1) )
4174 {
4175 if (!pPlayers[pBuf->uCaster]->CanAct())
4176 {
4177 pBuf->Reset();
4178 if (dword_4EE07C[i] == 7 )
4179 pParty->bFlying = false;
4180 }
4181 }
4182 }
4183
4184 v51 = v65;
4185 if ( v65 )
4186 goto LABEL_135;
4187 if ( pCurrentScreen != 5 )
4188 {
4189 v52 = (signed int)&pPlayers[1];
4190 while ( 1 )
4191 {
4192 v53 = *(int *)v52;
4193 if ( *(_QWORD *)(*(int *)v52 + 16) )
4194 break;
4195 v52 += 4;
4196 if ( v52 > (signed int)&pPlayers[4] )
4197 goto LABEL_135;
4198 }
4199 *(int *)(v53 + 16) = 0;
4200 *(int *)(v53 + 20) = 0;
4201 v51 = 1;
4202 LABEL_135:
4203 if ( pCurrentScreen != 5
4204 && (!v51 || dword_5C35C0) )
4205 uGameState = 8;
4206 }
4207 if ( uActiveCharacter )
4208 {
4209 if ( pCurrentScreen != 5 )
4210 {
4211 v54 = pPlayers[uActiveCharacter];
4212 if ( v54->pConditions[2]
4213 || v54->pConditions[12]
4214 || v54->pConditions[13]
4215 || v54->pConditions[14]
4216 || v54->pConditions[15]
4217 || v54->pConditions[16] )
4218 {
4219 viewparams->bRedrawGameUI = 1;
4220 uActiveCharacter = pParty->GetNextActiveCharacter();
4221 }
4222 }
4223 }
4224 }
4225
4226 //----- (00494820) --------------------------------------------------------
4227 unsigned int __fastcall sub_494820(unsigned int a1)
4228 {
4229 signed int v1; // eax@1
4230
4231 v1 = 5;
4232 if ( a1 % 0x18 >= 5 )
4233 v1 = 29;
4234 return v1 - a1 % 0x18;
4235 }
4236
4237 //----- (00494836) --------------------------------------------------------
4238 int stru339_spell_sound::_494836(int uSoundID, int a6)
4239 {
4240 int v3; // esi@1
4241 int result; // eax@1
4242 stru339_spell_sound *v5; // ebx@1
4243 int *v6; // edi@2
4244 unsigned int v7; // eax@3
4245 int v8; // [sp+Ch] [bp-8h]@3
4246 int v9; // [sp+10h] [bp-4h]@2
4247 int a2a; // [sp+1Ch] [bp+8h]@1
4248
4249 v3 = 0;
4250 result = word_4EE088_sound_ids[uSoundID];
4251 v5 = this;
4252 a2a = word_4EE088_sound_ids[uSoundID];
4253 if ( result )
4254 {
4255 v9 = 0;
4256 v6 = this->pSoundsOffsets;
4257 do
4258 {
4259 v7 = a2a++;
4260 result = pSoundList->LoadSound(v7, (char *)v5 + v3, 44744 - v3, &v8, a6);
4261 if ( !result )
4262 break;
4263 a6 += 4;
4264 result = v8 + 256;
4265 *v6 = v3;
4266 v3 += result;
4267 ++v9;
4268 *(v6 - 2) = result;
4269 ++v6;
4270 }
4271 while ( v9 < 2 );
4272 }
4273 return result;
4274 }
4275 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
4276
4277
4278
4279 //----- (00494AED) --------------------------------------------------------
4280 unsigned int PlayerFrameTable::GetFrameIdBy_field0(int uField0)
4281 {
4282 unsigned int _uNumFrames; // edx@1
4283 unsigned int result; // eax@1
4284 PlayerFrame *v4; // ecx@2
4285
4286 _uNumFrames = this->uNumFrames;
4287 result = 0;
4288 if ( (signed int)this->uNumFrames <= 0 )
4289 {
4290 LABEL_5:
4291 result = 0;
4292 }
4293 else
4294 {
4295 v4 = this->pFrames;
4296 while ( v4->uSequenceID != uField0 )
4297 {
4298 ++result;
4299 ++v4;
4300 if ( (signed int)result >= (signed int)_uNumFrames )
4301 goto LABEL_5;
4302 }
4303 }
4304 return result;
4305 }
4306
4307 //----- (00494B10) --------------------------------------------------------
4308 PlayerFrame *PlayerFrameTable::GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID)
4309 {
4310 unsigned int v3; // esi@1
4311 PlayerFrame *v4; // edi@1
4312 PlayerFrame *v5; // ecx@1
4313 __int16 v6; // dx@2
4314 int v7; // edx@3
4315 char *i; // eax@3
4316 int v9; // ecx@5
4317 PlayerFrame *result; // eax@6
4318
4319 v3 = uFramesetID;
4320 v4 = this->pFrames;
4321 v5 = &v4[uFramesetID];
4322 if ( v5->uFlags & 1 && (v6 = v5->uAnimLength) != 0 )
4323 {
4324 v7 = ((signed int)uFrameID >> 3) % (unsigned __int16)v6;
4325 for ( i = (char *)&v5->uAnimTime; ; i += 10 )
4326 {
4327 v9 = *(short *)i;
4328 if ( v7 <= v9 )
4329 break;
4330 v7 -= v9;
4331 ++v3;
4332 }
4333 result = &v4[v3];
4334 }
4335 else
4336 {
4337 result = &v4[uFramesetID];
4338 }
4339 return result;
4340 }
4341
4342 //----- (00494B5E) --------------------------------------------------------
4343 PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *a2, int *a3, int a4)
4344 {
4345 PlayerFrameTable *v4; // edi@1
4346 int v5; // esi@1
4347 int v6; // eax@2
4348
4349 v4 = this;
4350 v5 = a4 + *a3;
4351 if ( v5 < 8 * this->pFrames[*a2].uAnimTime )
4352 {
4353 *a3 = v5;
4354 }
4355 else
4356 {
4357 v6 = rand() % 4 + 21;
4358 *a2 = v6;
4359 *a3 = 8 * v5 % v4->pFrames[v6].uAnimTime;
4360 }
4361 return &v4->pFrames[*a2];
4362 }
4363
4364 //----- (00494BC3) --------------------------------------------------------
4365 void PlayerFrameTable::ToFile()
4366 {
4367 PlayerFrameTable *v1; // esi@1
4368 FILE *v2; // eax@1
4369 FILE *v3; // edi@1
4370
4371 auto Str = this;
4372
4373 v1 = Str;
4374 v2 = fopen("data\\dpft.bin", "wb");
4375 v3 = v2;
4376 if ( !v2 )
4377 Abortf("Unable to save dpft.bin!");
4378 fwrite(v1, 4u, 1u, v2);
4379 fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3);
4380 fclose(v3);
4381 }
4382
4383 //----- (00494C0F) --------------------------------------------------------
4384 void PlayerFrameTable::FromFile(void *pSerialized)
4385 {
4386 uNumFrames = *(int *)pSerialized;
4387 pFrames = (PlayerFrame *)pAllocator->AllocNamedChunk(pFrames, 10 * uNumFrames, "P Frames");
4388 memcpy(pFrames, (char *)pSerialized + 4, 10 * uNumFrames);
4389 }
4390
4391 //----- (00494C5A) --------------------------------------------------------
4392 int PlayerFrameTable::FromFileTxt(const char *Args)
4393 {
4394 PlayerFrameTable *v2; // ebx@1
4395 FILE *v3; // eax@1
4396 int v4; // esi@3
4397 void *v5; // eax@10
4398 FILE *v6; // ST0C_4@12
4399 char *i; // eax@12
4400 __int16 v8; // ax@15
4401 const char *v9; // ST10_4@15
4402 unsigned __int16 v10; // ax@15
4403 const char *v11; // ST0C_4@15
4404 int j; // esi@15
4405 int v13; // eax@17
4406 int v14; // edx@22
4407 int v15; // ecx@23
4408 int v16; // eax@24
4409 signed int k; // eax@27
4410 PlayerFrame *v18; // edx@28
4411 int v19; // esi@28
4412 int l; // ecx@29
4413 char Buf; // [sp+Ch] [bp-2F8h]@3
4414 FrameTableTxtLine v23; // [sp+200h] [bp-104h]@4
4415 FrameTableTxtLine v24; // [sp+27Ch] [bp-88h]@4
4416 int v25; // [sp+2F8h] [bp-Ch]@3
4417 int v26; // [sp+2FCh] [bp-8h]@3
4418 FILE *File; // [sp+300h] [bp-4h]@1
4419 int Argsa; // [sp+30Ch] [bp+8h]@28
4420
4421 v2 = this;
4422 //TileTable::dtor((TileTable *)this);
4423 v3 = fopen(Args, "r");
4424 File = v3;
4425 if ( !v3 )
4426 Abortf("PlayerFrameTable::load - Unable to open file: %s.", Args);
4427 v4 = 0;
4428 v25 = 0;
4429 v26 = 1;
4430 if ( fgets(&Buf, 490, v3) )
4431 {
4432 do
4433 {
4434 *strchr(&Buf, 10) = 0;
4435 memcpy(&v24, texture_frame_table_txt_parser(&Buf, &v23), sizeof(v24));
4436 if ( v24.field_0 && *v24.pProperties[0] != 47 )
4437 {
4438 if ( v24.field_0 < 3 )
4439 Abortf("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26);
4440 ++v25;
4441 }
4442 ++v26;
4443 }
4444 while ( fgets(&Buf, 490, File) );
4445 v4 = v25;
4446 }
4447 v2->uNumFrames = v4;
4448 v5 = pAllocator->AllocNamedChunk(v2->pFrames, 10 * v4, "P Frames");
4449 v2->pFrames = (PlayerFrame *)v5;
4450 if ( !v5 )
4451 Abortf("PlayerFrameTable::load - Out of Memory!");
4452 v6 = File;
4453 v2->uNumFrames = 0;
4454 fseek(v6, 0, 0);
4455 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
4456 {
4457 *strchr(&Buf, 10) = 0;
4458 memcpy(&v24, texture_frame_table_txt_parser(&Buf, &v23), sizeof(v24));
4459 if ( v24.field_0 && *v24.pProperties[0] != 47 )
4460 {
4461 v8 = atoi(v24.pProperties[0]);
4462 v9 = v24.pProperties[1];
4463 v2->pFrames[v2->uNumFrames].uSequenceID = v8;
4464 v10 = atoi(v9);
4465 v11 = v24.pProperties[2];
4466 v2->pFrames[v2->uNumFrames].uTextureID = v10;
4467 v2->pFrames[v2->uNumFrames].uAnimTime = atoi(v11);
4468 v2->pFrames[v2->uNumFrames].uAnimLength = 0;
4469 v2->pFrames[v2->uNumFrames].uFlags = 0;
4470 for ( j = 3; j < v24.field_0; ++j )
4471 {
4472 if ( !_strcmpi(v24.pProperties[j], "New") )
4473 {
4474 v13 = (int)&v2->pFrames[v2->uNumFrames].uFlags;
4475 *(char *)v13 |= 4u;
4476 }
4477 }
4478 ++v2->uNumFrames;
4479 }
4480 }
4481 fclose(File);
4482 v14 = 0;
4483 if ( (signed int)(v2->uNumFrames - 1) > 0 )
4484 {
4485 v15 = 0;
4486 do
4487 {
4488 v16 = (int)&v2->pFrames[v15];
4489 if ( !(*(char *)(v16 + 18) & 4) )
4490 *(char *)(v16 + 8) |= 1u;
4491 ++v14;
4492 ++v15;
4493 }
4494 while ( v14 < (signed int)(v2->uNumFrames - 1) );
4495 }
4496 for ( k = 0; k < (signed int)v2->uNumFrames; *(short *)(Argsa + 6) = v19 )
4497 {
4498 v18 = v2->pFrames;
4499 Argsa = (int)&v18[k];
4500 v19 = *(short *)(Argsa + 4);
4501 if ( *(char *)(Argsa + 8) & 1 )
4502 {
4503 ++k;
4504 for ( l = (int)&v18[k]; *(char *)(l + 8) & 1; l += 10 )
4505 {
4506 v19 += *(short *)(l + 4);
4507 ++k;
4508 }
4509 LOWORD(v19) = v18[k].uAnimTime + v19;
4510 }
4511 ++k;
4512 }
4513 return 1;
4514 }
4515
4516 //----- (00494F3A) --------------------------------------------------------
4517 unsigned int IconFrameTable::FindIcon(const char *pIconName)
4518 {
4519 IconFrameTable *v2; // esi@1
4520 int v3; // ebx@1
4521 unsigned int uID; // edi@1
4522 unsigned int result; // eax@4
4523
4524 v2 = this;
4525 v3 = 0;
4526 uID = 0;
4527 if ( (signed int)this->uNumIcons <= 0 )
4528 {
4529 LABEL_4:
4530 result = 0;
4531 }
4532 else
4533 {
4534 while ( _strcmpi(pIconName, v2->pIcons[v3].pAnimationName) )
4535 {
4536 ++uID;
4537 ++v3;
4538 if ( (signed int)uID >= (signed int)v2->uNumIcons )
4539 goto LABEL_4;
4540 }
4541 result = uID;
4542 }
4543 return result;
4544 }
4545
4546 //----- (00494F70) --------------------------------------------------------
4547 IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID)
4548 {
4549 IconFrame *v3; // edi@1
4550 IconFrame *v4; // ecx@1
4551 __int16 v5; // dx@2
4552 int v6; // edx@3
4553 unsigned int v7; // eax@3
4554 char *i; // ecx@3
4555 int v9; // esi@5
4556 IconFrame *result; // eax@6
4557
4558 v3 = this->pIcons;
4559 v4 = &v3[uIconID];
4560 if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 )
4561 {
4562 v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)v5;
4563 v7 = uIconID;
4564 for ( i = (char *)&v4->uAnimTime; ; i += 32 )
4565 {
4566 v9 = *(short *)i;
4567 if ( v6 <= v9 )
4568 break;
4569 v6 -= v9;
4570 ++v7;
4571 }
4572 result = &v3[v7];
4573 }
4574 else
4575 {
4576 result = &v3[uIconID];
4577 }
4578 return result;
4579 }
4580
4581 //----- (00494FBF) --------------------------------------------------------
4582 void IconFrameTable::InitializeAnimation(unsigned int uIconID)
4583 {
4584 IconFrameTable *v2; // esi@1
4585 unsigned int v3; // edi@3
4586 const char *i; // eax@3
4587 IconFrame *v5; // eax@5
4588
4589 v2 = this;
4590 if ( (signed int)uIconID <= (signed int)this->uNumIcons && (uIconID & 0x80000000u) == 0 )
4591 {
4592 v3 = uIconID;
4593 for ( i = this->pIcons[uIconID].pTextureName; ; i = v5[v3].pTextureName )
4594 {
4595 v2->pIcons[v3].uTextureID = pIcons_LOD->LoadTexture(i, TEXTURE_16BIT_PALETTE);
4596 v5 = v2->pIcons;
4597 if ( !(v5[v3].uFlags & 1) )
4598 break;
4599 ++v3;
4600 }
4601 }
4602 }
4603
4604 //----- (0049500A) --------------------------------------------------------
4605 void IconFrameTable::ToFile()
4606 {
4607 IconFrameTable *v1; // esi@1
4608 FILE *v2; // eax@1
4609 FILE *v3; // edi@1
4610
4611 auto Str = this;
4612
4613 v1 = Str;
4614 v2 = fopen("data\\dift.bin", "wb");
4615 v3 = v2;
4616 if ( !v2 )
4617 Abortf("Unable to save dift.bin!");
4618 fwrite(v1, 4u, 1u, v2);
4619 fwrite(v1->pIcons, 0x20u, v1->uNumIcons, v3);
4620 fclose(v3);
4621 }
4622
4623 //----- (00495056) --------------------------------------------------------
4624 void IconFrameTable::FromFile(void *pSerialized)
4625 {
4626 uNumIcons = *(int *)pSerialized;
4627 pIcons = (IconFrame *)pAllocator->AllocNamedChunk(pIcons, 32 * uNumIcons, "I Frames");
4628 memcpy(pIcons, (char *)pSerialized + 4, 32 * uNumIcons);
4629 }
4630
4631 //----- (0049509D) --------------------------------------------------------
4632 int IconFrameTable::FromFileTxt(const char *Args)
4633 {
4634 IconFrameTable *v2; // ebx@1
4635 FILE *v3; // eax@1
4636 int v4; // esi@3
4637 void *v5; // eax@10
4638 FILE *v6; // ST0C_4@12
4639 char *i; // eax@12
4640 const char *v8; // ST00_4@15
4641 int v9; // eax@16
4642 int v10; // edx@20
4643 int v11; // ecx@21
4644 int v12; // eax@22
4645 signed int j; // edx@25
4646 IconFrame *v14; // ecx@26
4647 int v15; // esi@26
4648 int k; // eax@27
4649 signed int result; // eax@11
4650 char Buf; // [sp+Ch] [bp-2F8h]@3
4651 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4
4652 FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4
4653 int v21; // [sp+2F8h] [bp-Ch]@3
4654 int v22; // [sp+2FCh] [bp-8h]@3
4655 FILE *File; // [sp+300h] [bp-4h]@1
4656 int Argsa; // [sp+30Ch] [bp+8h]@26
4657
4658 v2 = this;
4659 //TileTable::dtor((TileTable *)this);
4660 v3 = fopen(Args, "r");
4661 File = v3;
4662 if ( !v3 )
4663 Abortf("IconFrameTable::load - Unable to open file: %s.", Args);
4664 v4 = 0;
4665 v21 = 0;
4666 v22 = 1;
4667 if ( fgets(&Buf, 490, v3) )
4668 {
4669 do
4670 {
4671 *strchr(&Buf, 10) = 0;
4672 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
4673 if ( v20.field_0 && *v20.pProperties[0] != 47 )
4674 {
4675 if ( v20.field_0 < 3 )
4676 Abortf("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22);
4677 ++v21;
4678 }
4679 ++v22;
4680 }
4681 while ( fgets(&Buf, 490, File) );
4682 v4 = v21;
4683 }
4684 v2->uNumIcons = v4;
4685 v5 = pAllocator->AllocNamedChunk(v2->pIcons, 32 * v4, "I Frames");
4686 v2->pIcons = (IconFrame *)v5;
4687 if ( v5 )
4688 {
4689 v6 = File;
4690 v2->uNumIcons = 0;
4691 fseek(v6, 0, 0);
4692 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
4693 {
4694 *strchr(&Buf, 10) = 0;
4695 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
4696 if ( v20.field_0 && *v20.pProperties[0] != 47 )
4697 {
4698 strcpy(v2->pIcons[v2->uNumIcons].pAnimationName, v20.pProperties[0]);
4699 strcpy(v2->pIcons[v2->uNumIcons].pTextureName, v20.pProperties[1]);
4700 v8 = v20.pProperties[2];
4701 v2->pIcons[v2->uNumIcons].uFlags = 0;
4702 if ( !_strcmpi(v8, "new") )
4703 {
4704 v9 = (int)&v2->pIcons[v2->uNumIcons].uFlags;
4705 *(char *)v9 |= 4u;
4706 }
4707 v2->pIcons[v2->uNumIcons].uAnimTime = atoi(v20.pProperties[3]);
4708 v2->pIcons[v2->uNumIcons].uAnimLength = 0;
4709 v2->pIcons[v2->uNumIcons++].uTextureID = 0;
4710 }
4711 }
4712 fclose(File);
4713 v10 = 0;
4714 if ( (signed int)(v2->uNumIcons - 1) > 0 )
4715 {
4716 v11 = 0;
4717 do
4718 {
4719 v12 = (int)&v2->pIcons[v11];
4720 if ( !(*(char *)(v12 + 60) & 4) )
4721 *(char *)(v12 + 28) |= 1u;
4722 ++v10;
4723 ++v11;
4724 }
4725 while ( v10 < (signed int)(v2->uNumIcons - 1) );
4726 }
4727 for ( j = 0; j < (signed int)v2->uNumIcons; *(short *)(Argsa + 26) = v15 )
4728 {
4729 v14 = v2->pIcons;
4730 Argsa = (int)&v14[j];
4731 v15 = *(short *)(Argsa + 24);
4732 if ( *(char *)(Argsa + 28) & 1 )
4733 {
4734 ++j;
4735 for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 )
4736 {
4737 v15 += *(short *)(k + 24);
4738 ++j;
4739 }
4740 LOWORD(v15) = v14[j].uAnimTime + v15;
4741 }
4742 ++j;
4743 }
4744 result = 1;
4745 }
4746 else
4747 {
4748 fclose(File);
4749 result = 0;
4750 }
4751 return result;
4752 }
4753
4754
4755
4756 //----- (00495366) --------------------------------------------------------
4757 char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2)
4758 {
4759 int v2; // edi@1
4760 int v3; // edx@2
4761 int v4; // esi@3
4762 int v5; // ebx@5
4763 signed int v7; // [sp+Ch] [bp-14h]@1
4764 signed int v8; // [sp+10h] [bp-10h]@1
4765 int **v9; // [sp+14h] [bp-Ch]@4
4766 signed int v10; // [sp+18h] [bp-8h]@3
4767 unsigned __int8 v11; // [sp+1Ch] [bp-4h]@1
4768
4769 v2 = a1;
4770 v11 = a2;
4771 v8 = 0;
4772 v7 = 0;
4773 if ( dword_AE336C == a1 )
4774 {
4775 v3 = dword_AE3370;
4776 }
4777 else
4778 {
4779 v4 = a2;
4780 dword_AE336C = a1;
4781 v10 = 0;
4782 if ( (signed int)pNPCStats->uNumNPCNames[v4] <= 0 )
4783 goto LABEL_17;
4784 v9 = (int **)((char *)pNPCStats->pNPCNames + v4 * 4);
4785 do
4786 {
4787 v5 = tolower(*(char *)*v9);
4788 if ( v5 == tolower(v2) )
4789 {
4790 if ( v8 )
4791 v7 = v10;
4792 else
4793 v8 = v10;
4794 }
4795 ++v10;
4796 v9 += 2;
4797 }
4798 while ( v10 < (signed int)pNPCStats->uNumNPCNames[v4] );
4799 if ( v8 && v8 != v7 )
4800 v3 = v8 + rand() % (v7 - v8);
4801 else
4802 LABEL_17:
4803 v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4];
4804 }
4805 dword_AE3370 = v3;
4806 return pNPCStats->pNPCNames[0][v11 + 2 * v3];
4807 }
4808 // AE336C: using guessed type int dword_AE336C;
4809 // AE3370: using guessed type int dword_AE3370;
4810
4811 //----- (00495430) --------------------------------------------------------
4812 char *__fastcall GetReputationString(signed int a1)
4813 {
4814 char *result; // eax@2
4815
4816 if ( a1 < 25 )
4817 {
4818 if ( a1 < 6 )
4819 {
4820 if ( a1 < -5 )
4821 {
4822 result = pGlobalTXT_LocalizationStrings[402];
4823 if ( a1 < -24 )
4824 result = pGlobalTXT_LocalizationStrings[434];
4825 }
4826 else
4827 {
4828 result = pGlobalTXT_LocalizationStrings[399];
4829 }
4830 }
4831 else
4832 {
4833 result = pGlobalTXT_LocalizationStrings[392];
4834 }
4835 }
4836 else
4837 {
4838 result = pGlobalTXT_LocalizationStrings[379];
4839 }
4840 return result;
4841 }
4842
4843 //----- (00495461) --------------------------------------------------------
4844 char *__fastcall sub_495461(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6)
4845 {
4846 unsigned __int8 v6; // bl@1
4847 Player *pPlayer; // ebx@3
4848 NPCData *v9; // eax@4
4849 size_t v10; // eax@6
4850 char *v11; // esi@7
4851 int v12; // edx@7
4852 ItemGen *v13; // edi@7
4853 char v14; // cl@8
4854 char *v15; // ecx@10
4855 int v16; // edx@10
4856 int v17; // eax@10
4857 signed __int64 v18; // qax@18
4858 unsigned int v19; // edi@32
4859 unsigned __int8 *v20; // ebx@32
4860 int v21; // ecx@34
4861 __int16 v22; // ax@34
4862 int v23; // edx@39
4863 int v24; // eax@39
4864 int v25; // eax@45
4865 float *v26; // esi@68
4866 float v27; // ST18_4@68
4867 signed int v28; // eax@68
4868 int v29; // eax@68
4869 float v30; // ST18_4@72
4870 signed int v31; // eax@72
4871 float v32; // ST18_4@74
4872 signed int v33; // eax@74
4873 double v34; // st7@75
4874 float v35; // ST18_4@76
4875 signed int v36; // eax@76
4876 float *v37; // esi@78
4877 float v38; // ST18_4@78
4878 int v39; // eax@78
4879 float v40; // ST18_4@82
4880 int v41; // eax@82
4881 float v42; // ST18_4@83
4882 int v43; // eax@83
4883 float v44; // ST18_4@85
4884 int v45; // eax@85
4885 const char *v46; // eax@86
4886 unsigned int v47; // eax@87
4887 float v48; // ST18_4@97
4888 __int64 v49; // ST14_8@107
4889 int v50; // eax@107
4890 int v51; // eax@108
4891 Player *v52; // eax@109
4892 int v53; // [sp-4h] [bp-13Ch]@107
4893 int v54; // [sp+0h] [bp-138h]@107
4894 __int16 v55[56]; // [sp+10h] [bp-128h]@34
4895 stru351 v56; // [sp+80h] [bp-B8h]@107
4896 stru351 v57; // [sp+9Ch] [bp-9Ch]@115
4897 char a1[100]; // [sp+B8h] [bp-80h]@3
4898 unsigned int v59; // [sp+11Ch] [bp-1Ch]@3
4899 size_t v60; // [sp+120h] [bp-18h]@3
4900 Player *v61; // [sp+124h] [bp-14h]@3
4901 char *Str; // [sp+128h] [bp-10h]@1
4902 int v63; // [sp+12Ch] [bp-Ch]@32
4903 int v64; // [sp+130h] [bp-8h]@6
4904 NPCData *v65; // [sp+134h] [bp-4h]@6
4905
4906 v6 = uPlayerID;
4907 Str = lpsz;
4908 if ( IsBadStringPtrA(lpsz, 1u) )
4909 return "Invalid String Passed";
4910 v60 = strlen(Str);
4911 a1[0] = 0;
4912 pPlayer = &pParty->pPlayers[v6];
4913 v59 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
4914 v61 = pPlayer;
4915 memset(pTmpBuf2, 0, 0x7D0u);
4916 if ( dword_5C35D4 )
4917 v9 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
4918 else
4919 v9 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
4920 v65 = v9;
4921 v10 = 0;
4922 v64 = 0;
4923 if ( (signed int)v60 > 0 )
4924 {
4925 v11 = a4;
4926 v12 = v64;
4927 v13 = a3;
4928 while ( 1 )
4929 {
4930 v14 = Str[v12];
4931 if ( v14 == 37 )
4932 break;
4933 pTmpBuf2[v10++] = v14;
4934 LABEL_119:
4935 ++v12;
4936 v64 = v12;
4937 if ( v12 >= (signed int)v60 )
4938 return pTmpBuf2;
4939 }
4940 v15 = &Str[v12 + 1];
4941 v16 = (unsigned __int8)Str[v12 + 2];
4942 v17 = v16 + 10 * (unsigned __int8)*v15 - 528;
4943 if ( v17 <= 15 )
4944 {
4945 if ( v17 != 15 )
4946 {
4947 switch ( v16 + 10 * (unsigned __int8)*v15 )
4948 {
4949 case 0x211:
4950 v11 = v65->pName;
4951 goto LABEL_118;
4952 case 0x212:
4953 v11 = pPlayer->pName;
4954 goto LABEL_118;
4955 case 0x213:
4956 case 0x219:
4957 if ( v65->uSex )
4958 v11 = pGlobalTXT_LocalizationStrings[384];// "her"
4959 else
4960 v11 = pGlobalTXT_LocalizationStrings[383];// "his"
4961 goto LABEL_118;
4962 case 0x215:
4963 v18 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60 / 60 % 24;
4964 v11 = pGlobalTXT_LocalizationStrings[397];// "evening"
4965 if ( SHIDWORD(v18) <= 0 && SHIDWORD(v18) >= 0 && (unsigned int)v18 >= 5 && SHIDWORD(v18) <= 0 )
4966 {
4967 if ( SHIDWORD(v18) >= 0 && (unsigned int)v18 >= 0xB )
4968 {
4969 if ( v18 < 20 )
4970 v11 = pGlobalTXT_LocalizationStrings[396];// "day"
4971 }
4972 else
4973 {
4974 v11 = pGlobalTXT_LocalizationStrings[395];// "morning"
4975 }
4976 }
4977 goto LABEL_118;
4978 case 0x216:
4979 if ( pPlayer->uSex )
4980 v11 = pGlobalTXT_LocalizationStrings[387];// "lady"
4981 else
4982 v11 = pGlobalTXT_LocalizationStrings[385];// "sir"
4983 goto LABEL_118;
4984 case 0x217:
4985 if ( pPlayer->uSex )
4986 goto LABEL_43;
4987 v11 = pGlobalTXT_LocalizationStrings[386];// "Sir"
4988 goto LABEL_118;
4989 case 0x218:
4990 v19 = 0;
4991 v63 = 0;
4992 v20 = (unsigned __int8 *)v61->field_152;
4993 do
4994 {
4995 if ( (unsigned __int16)_449B57_test_bit(v20, word_4EE150[v19]) )
4996 {
4997 v21 = v63;
4998 v22 = word_4EE150[v19];
4999 ++v63;
5000 v55[v21] = v22;
5001 }
5002 ++v19;
5003 }
5004 while ( v19 < 28 );
5005 if ( v63 )
5006 {
5007 v23 = rand() % v63;
5008 v24 = dword_A74CDC;
5009 if ( dword_A74CDC == -1 )
5010 {
5011 v24 = v23;
5012 dword_A74CDC = v23;
5013 }
5014 v11 = (char *)dword_723E80_award_related[2 * v55[v24]];
5015 }
5016 else
5017 {
5018 v11 = (char *)pNPCTopics[55].pText;
5019 }
5020 pPlayer = v61;
5021 v13 = a3;
5022 goto LABEL_118;
5023 case 0x21A:
5024 if ( pPlayer->uSex )
5025 LABEL_43:
5026 v11 = pGlobalTXT_LocalizationStrings[389];// "Lady"
5027 else
5028 v11 = pGlobalTXT_LocalizationStrings[388];// "Lord"
5029 goto LABEL_118;
5030 case 0x21B:
5031 v25 = GetPartyReputation();
5032 goto LABEL_46;
5033 case 0x21C:
5034 v25 = v65->rep;
5035 LABEL_46:
5036 if ( v25 >= 25 )
5037 {
5038 v11 = pGlobalTXT_LocalizationStrings[379];
5039 }
5040 else
5041 {
5042 if ( v25 < 6 )
5043 {
5044 if ( v25 >= -5 )
5045 {
5046 v11 = pGlobalTXT_LocalizationStrings[399];
5047 }
5048 else
5049 {
5050 if ( v25 < -24 )
5051 v11 = pGlobalTXT_LocalizationStrings[434];
5052 else
5053 v11 = pGlobalTXT_LocalizationStrings[402];
5054 }
5055 }
5056 else
5057 {
5058 v11 = pGlobalTXT_LocalizationStrings[392];
5059 }
5060 }
5061 goto LABEL_118;
5062 case 0x21D:
5063 v11 = sub_495366(pPlayer->pName[0], pPlayer->uSex);
5064 goto LABEL_118;
5065 case 0x21E:
5066 goto LABEL_93;
5067 case 0x214:
5068 goto LABEL_117;
5069 default:
5070 goto LABEL_108;
5071 }
5072 goto LABEL_108;
5073 }
5074 v11 = pGlobalTXT_LocalizationStrings[393];// "daughter"
5075 LABEL_118:
5076 strcat(pTmpBuf2, v11);
5077 v10 = strlen(pTmpBuf2);
5078 v64 += 2;
5079 v12 = v64;
5080 goto LABEL_119;
5081 }
5082 if ( v17 <= 29 )
5083 {
5084 if ( v17 == 29 )
5085 {
5086 //v34 = p2DEvents_minus1__20[13 * (signed int)a4];
5087 v34 = p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
5088 }
5089 else
5090 {
5091 if ( v16 + 10 * (unsigned __int8)*v15 == 544 )
5092 {
5093 LABEL_93:
5094 if ( v65->uSex )
5095 v11 = pGlobalTXT_LocalizationStrings[391];// "sister"
5096 else
5097 v11 = pGlobalTXT_LocalizationStrings[390];// "brother"
5098 goto LABEL_118;
5099 }
5100 if ( v16 + 10 * (unsigned __int8)*v15 == 545 )
5101 {
5102 v29 = *(&pNPCStats->field_13A58 + 5 * v65->uProfession) / 100;
5103 goto LABEL_91;
5104 }
5105 if ( v16 + 10 * (unsigned __int8)*v15 == 551 )
5106 {
5107 v47 = pMapStats->GetMapInfo(pCurrentMapName);
5108 if ( v47 )
5109 v11 = pMapStats->pInfos[v47].pName;
5110 else
5111 v11 = pGlobalTXT_LocalizationStrings[394];// "Unknown"
5112 goto LABEL_118;
5113 }
5114 if ( v16 + 10 * (unsigned __int8)*v15 == 552 )
5115 {
5116 v46 = v13->GetDisplayName();
5117 sprintf(a1, format_4E2D80, v59, v46);
5118 LABEL_117:
5119 v11 = a1;
5120 goto LABEL_118;
5121 }
5122 if ( v16 + 10 * (unsigned __int8)*v15 == 553 )
5123 {
5124 //v37 = &p2DEvents_minus1__20[13 * (signed int)a4];
5125 v37 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
5126 v38 = *v37;
5127 v39 = v13->GetValue();
5128 v29 = pPlayer->_4B8233(v39, v38);
5129 switch ( a5 )
5130 {
5131 case 3:
5132 v44 = *v37;
5133 v45 = v13->GetValue();
5134 v29 = pPlayer->_4B8213(v45, v44);
5135 break;
5136 case 4:
5137 v29 = pPlayer->_4B824B(*v37);
5138 break;
5139 case 5:
5140 v42 = *v37;
5141 v43 = v13->GetValue();
5142 v29 = pPlayer->_4B8265(v43, v42);
5143 break;
5144 case 6:
5145 v40 = *v37;
5146 v41 = v13->GetValue();
5147 v29 = pPlayer->_4B8213(v41, v40) / 2;
5148 break;
5149 }
5150 goto LABEL_98;
5151 }
5152 if ( v16 + 10 * (unsigned __int8)*v15 != 555 )
5153 {
5154 if ( v16 + 10 * (unsigned __int8)*v15 == 556 )
5155 {
5156 //v11 = (char *)p2DEvents_minus1__10[13 * (signed int)a4];
5157 v11 = (char *)p2DEvents[(signed int)a4 - 1].pProprieterTitle;
5158 goto LABEL_118;
5159 }
5160 LABEL_108:
5161 strncpy(a1, v15, 2u);
5162 v51 = atoi(a1);
5163 sprintf(a1, "%lu", v51);
5164 goto LABEL_117;
5165 }
5166 v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
5167 v27 = *v26;
5168 v28 = v13->GetValue();
5169 v29 = pPlayer->_4B8142(v28, v27);
5170 if ( a5 == 3 )
5171 {
5172 v35 = *v26;
5173 v36 = v13->GetValue();
5174 v29 = pPlayer->_4B8102(v36, v35);
5175 if ( v13->uAttributes & 2 )
5176 {
5177 LABEL_77:
5178 v29 = 1;
5179 goto LABEL_98;
5180 }
5181 goto LABEL_98;
5182 }
5183 if ( a5 != 4 )
5184 {
5185 if ( a5 == 5 )
5186 {
5187 v32 = *v26;
5188 v33 = v13->GetValue();
5189 v29 = pPlayer->_4B81C3(v33, v32);
5190 }
5191 else
5192 {
5193 if ( a5 == 6 )
5194 {
5195 v30 = *v26;
5196 v31 = v13->GetValue();
5197 v29 = pPlayer->_4B8102(v31, v30) / 2;
5198 if ( v13->uAttributes & 2 )
5199 v29 = 1;
5200 LABEL_91:
5201 if ( v29 >= 1 )
5202 goto LABEL_98;
5203 goto LABEL_77;
5204 }
5205 }
5206 LABEL_98:
5207 sprintf(a1, "%lu", v29);
5208 goto LABEL_117;
5209 }
5210 v34 = *v26;
5211 }
5212 v48 = v34;
5213 v29 = pPlayer->_4B8179(v48);
5214 goto LABEL_98;
5215 }
5216 if ( v17 != 30 )
5217 {
5218 switch ( v17 )
5219 {
5220 case 31:
5221 v52 = pPlayers[1];
5222 break;
5223 case 32:
5224 v52 = pPlayers[2];
5225 break;
5226 case 33:
5227 v52 = pPlayers[3];
5228 break;
5229 default:
5230 if ( v17 != 34 )
5231 {
5232 if ( v17 <= 50 || v17 > 70 )
5233 goto LABEL_108;
5234 if ( v16 + 10 * (unsigned __int8)*v15 - 579 >= 20 )
5235 goto LABEL_118;
5236 HIDWORD(v49) = pParty->field_3C.field_440[2 * v17 + 1];
5237 LODWORD(v49) = pParty->field_3C.field_440[2 * v17];
5238 sub_493F79(&v56, v49);
5239 v54 = v56.field_18;
5240 v53 = v56.field_C + 1;
5241 v50 = v56.field_14;
5242 LABEL_116:
5243 sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54);
5244 goto LABEL_117;
5245 }
5246 v52 = pPlayers[4];
5247 break;
5248 }
5249 v11 = v52->pName;
5250 goto LABEL_118;
5251 }
5252 if ( !a6 )
5253 goto LABEL_118;
5254 sub_493F79(&v57, *a6);
5255 v54 = v57.field_18;
5256 v53 = v57.field_C + 1;
5257 v50 = v57.field_14;
5258 goto LABEL_116;
5259 }
5260 return pTmpBuf2;
5261 }
5262
5263 //----- (00495B39) --------------------------------------------------------
5264 void __cdecl PlayerCreationUI_Draw()
5265 {
5266 const char *uTitleText; // ST10_4@3
5267 int pTextCenter; // eax@3
5268 IconFrame *v3; // eax@3
5269 int v4; // ecx@7
5270 GUIButton *uPosActiveItem; // edi@12
5271 int v6; // esi@14
5272 int uNumLet; // eax@14
5273 char v8; // al@17
5274 int v9; // ecx@17
5275 char v10; // sf@17
5276 int v11; // ecx@19
5277 void *v12; // eax@20
5278 int v13; // ecx@21
5279 int v14; // ecx@22
5280 char *v15; // ST14_4@24
5281 size_t v16; // eax@28
5282 int v17; // eax@33
5283 enum CHARACTER_RACE uNumRace; // eax@35
5284 int v19; // eax@36
5285 int v20; // eax@37
5286 int uNumMight; // eax@44
5287 unsigned int v24; // eax@44
5288 int v25; // eax@44
5289 unsigned int v26; // eax@44
5290 int v27; // eax@44
5291 unsigned int v28; // eax@44
5292 int v29; // eax@44
5293 unsigned int v30; // eax@44
5294 int v31; // eax@44
5295 unsigned int v32; // eax@44
5296 int v33; // eax@44
5297 unsigned int v34; // eax@44
5298 int v35; // eax@44
5299 unsigned int v36; // eax@44
5300 enum PLAYER_SKILL_TYPE v37; // eax@44
5301 enum PLAYER_SKILL_TYPE v39; // eax@44
5302 enum PLAYER_SKILL_TYPE v41; // eax@44
5303 const char *v42; // edx@44
5304 char *v43; // ST1C_4@44
5305 int v45; // eax@44
5306 enum PLAYER_SKILL_TYPE v46; // eax@46
5307 const char *v47; // edx@46
5308 char *v48; // ST1C_4@46
5309 int v50; // eax@46
5310 int v51; // eax@49
5311 char *v52; // edi@52
5312 char v53; // al@52
5313 int uClassType; // edi@53
5314 int v55; // ST0C_4@53
5315 int v57; // eax@53
5316 int v61; // ecx@55
5317 int v64; // ST08_4@57
5318 int v66; // ecx@57
5319 int v71; // eax@59
5320 int v75; // eax@61
5321 int v80; // eax@63
5322 int v85; // eax@65
5323 int v89; // eax@67
5324 int v94; // eax@69
5325 enum PLAYER_SKILL_TYPE pSkillId; // edi@72
5326 size_t pLenText; // eax@72
5327 signed int v104; // ecx@72
5328 int pColorText; // ecx@79
5329 unsigned int v107; // ST0C_4@81
5330 int pTextY; // ST08_4@81
5331 int v111; // ST0C_4@82
5332 signed int v113; // edi@82
5333 int v114; // ST0C_4@82
5334 const char *uRaceName; // [sp+0h] [bp-170h]@39
5335 char pText[200]; // [sp+10h] [bp-160h]@14
5336 GUIWindow pWindow; // [sp+D8h] [bp-98h]@83
5337 int v119; // [sp+12Ch] [bp-44h]@18
5338 size_t v120; // [sp+130h] [bp-40h]@25
5339 int uY; // [sp+134h] [bp-3Ch]@18
5340 int v122; // [sp+138h] [bp-38h]@18
5341 int v123; // [sp+13Ch] [bp-34h]@11
5342 void *v124; // [sp+140h] [bp-30h]@18
5343 int uColor1; // [sp+144h] [bp-2Ch]@1
5344 int v126; // [sp+148h] [bp-28h]@25
5345 int uColorGreen; // [sp+14Ch] [bp-24h]@1
5346 int v128; // [sp+150h] [bp-20h]@14
5347 int v129; // [sp+154h] [bp-1Ch]@18
5348 int uColorTeal; // [sp+158h] [bp-18h]@1
5349 int uColorWhite; // [sp+15Ch] [bp-14h]@1
5350 int uX; // [sp+160h] [bp-10h]@18
5351 unsigned int v133; // [sp+164h] [bp-Ch]@25
5352 int pOrder; // [sp+168h] [bp-8h]@14
5353 char *Str; // [sp+16Ch] [bp-4h]@18
5354 Player *pPlayer;
5355 const char *pSkillName;
5356
5357 uColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xD1, 0xBB, 0x61);
5358 uColorTeal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xF7, 0xF7);
5359 uColorGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFF, 0);
5360 uColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
5361 pRenderer->BeginScene();
5362 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
5363 uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
5364 pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
5365 pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY);
5366 //if (uPlayerCreationUI_SkySliderPos > 640)
5367 //uPlayerCreationUI_SkySliderPos = 0;
5368 pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
5369 uTitleText = pGlobalTXT_LocalizationStrings[51];
5370 uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
5371 pTextCenter = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
5372 pGUIWindow_CurrentMenu->DrawText(pFontCChar, pTextCenter + 1, 0, 0, uTitleText, 0, 0, 0);
5373 pRenderer->DrawTextureTransparent(17, 35, pPlayerPortraits[pParty->pPlayers[0].uFace]);
5374 pRenderer->DrawTextureTransparent(176, 35, pPlayerPortraits[pParty->pPlayers[1].uFace]);
5375 pRenderer->DrawTextureTransparent(335, 35, pPlayerPortraits[pParty->pPlayers[2].uFace]);
5376 pRenderer->DrawTextureTransparent(494, 35, pPlayerPortraits[pParty->pPlayers[3].uFace]);
5377 v3 = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime);
5378 if ( uPlayerCreationUI_SelectedCharacter )
5379 {
5380 switch ( uPlayerCreationUI_SelectedCharacter )
5381 {
5382 case 1:
5383 v4 = 171;
5384 break;
5385 case 2:
5386 v4 = 329;
5387 break;
5388 case 3:
5389 v4 = 488;
5390 break;
5391 default:
5392 v4 = v123;
5393 break;
5394 }
5395 }
5396 else
5397 {
5398 v4 = 12;
5399 }
5400
5401 pRenderer->DrawTextureTransparent(v4, 29, &pIcons_LOD->pTextures[v3->uTextureID]);
5402 uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem);
5403 uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25;
5404 pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
5405 pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
5406 //if (uPlayerCreationUI_ArrowAnim < 0)
5407 // uPlayerCreationUI_ArrowAnim = 18;
5408 v6 = pFontCreate->uFontHeight - 2;
5409 v128 = pFontCreate->uFontHeight - 2;
5410 memset(pText, 0, 200);
5411 strcpy(pText, pGlobalTXT_LocalizationStrings[205]);// "Skills"
5412 uNumLet = strlen(pText) - 1;
5413 pOrder = uNumLet;
5414 if ( uNumLet >= 0 )
5415 {
5416 while ( 1 )
5417 {
5418 v8 = toupper((unsigned __int8)pText[uNumLet]);
5419 v9 = pOrder;
5420 v10 = pOrder-- - 1 < 0;
5421 pText[v9] = v8;
5422 if ( v10 )
5423 break;
5424 uNumLet = pOrder;
5425 }
5426 }
5427 pOrder = 18;
5428 v124 = 0;
5429 uX = 32;
5430 uY = 3 * v6 + 169;
5431 v122 = 5 * v6 + 169;
5432 v123 = 3 * v6 + 311;
5433 v129 = 493;
5434 //pPlayer = pParty->pPlayers;
5435 v119 = 6 * v6 + 169;
5436 //do
5437 for ( pPlayer = pParty->pPlayers; (signed int)pPlayer->pName < (signed int)&pParty->pPickedItem.uNumCharges; pPlayer++)
5438 {
5439 Str = pPlayer->pName;
5440 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pOrder + 73, 100, 0, pClassNames[(unsigned __int8)pPlayer->uClass], 0, 0, 0);
5441 pRenderer->DrawTextureTransparent(pOrder + 77, 50, pTexture_IC_KNIGHT[pPlayer->uClass/4]);
5442 v11 = pGUIWindow_CurrentMenu->field_40;
5443 if ( v11 && (v12 = pGUIWindow_CurrentMenu->ptr_1C, v12 == v124) )
5444 {
5445 v13 = v11 - 1;
5446 if ( v13 )
5447 {
5448 v14 = v13 - 1;
5449 if ( v14 )
5450 {
5451 if ( v14 == 1 )
5452 {
5453 pGUIWindow_CurrentMenu->field_40 = 0;
5454 pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pOrder, 124, 0, Str, 130, 0);
5455 SetCurrentMenuID(MENU_7);
5456 }
5457 }
5458 else
5459 {
5460 pGUIWindow_CurrentMenu->field_40 = 0;
5461 v120 = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
5462 v126 = 0;
5463 v133 = 0;
5464 if ( strlen((const char *)pKeyActionMap->pPressedKeysBuffer) )//edit name
5465 {
5466 do
5467 {
5468 if ( pKeyActionMap->pPressedKeysBuffer[v133] == ' ' )
5469 ++v126;
5470 ++v133;
5471 v16 = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
5472 }
5473 while ( v133 < v16 );
5474 }
5475 if ( v120 && v126 != v120 )
5476 strcpy(Str, (const char *)pKeyActionMap->pPressedKeysBuffer);
5477 pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pOrder, 0x7C, 0, Str, 130, 0);
5478 *((short *)pPlayer->pName + 3323) = 1; //
5479 }
5480 }
5481 else
5482 {
5483 v17 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, 159 * (int)v12 + 18, 0x7Cu, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 120, 1);
5484 pGUIWindow_CurrentMenu->DrawFlashingInputCursor(159 * (unsigned int)pGUIWindow_CurrentMenu->ptr_1C + v17 + 20, 124, pFontCreate);
5485 }
5486 }
5487 else
5488 {
5489 pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pOrder, 0x7C, 0, pPlayer->pName, 130, 0);
5490 }
5491 uNumRace = pPlayer->GetRace();
5492 switch (uNumRace)
5493 {
5494 case 0: uRaceName = pGlobalTXT_LocalizationStrings[99]; break; // "Human"
5495 case 1: uRaceName = pGlobalTXT_LocalizationStrings[103]; break; // "Dwarf"
5496 case 2: uRaceName = pGlobalTXT_LocalizationStrings[106]; break; // "Goblin"
5497 case 3: uRaceName = pGlobalTXT_LocalizationStrings[101]; break; // "Elf"
5498 };
5499 strcpy(pTmpBuf, uRaceName);
5500 pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pOrder + 72, v128 + 12, 0, pTmpBuf, 130, 0);
5501 pTextCenter = pFontCreate->AlignText_Center(0x96, pText);
5502 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + uX - 24, 291, uColor1, pText, 0, 0, 0);
5503 uNumMight = pPlayer->GetActualMight();
5504 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[144], v129, uNumMight);// "Might"
5505 LOWORD(v24) = pPlayer->GetStatColor(0);
5506 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 169, v24, pTmpBuf, 0, 0, 0);
5507 v25 = pPlayer->GetActualIntelligence();
5508 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[116], v129, v25);// "Intellect"
5509 LOWORD(v26) = pPlayer->GetStatColor(1);
5510 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v128 + 169, v26, pTmpBuf, 0, 0, 0);
5511 v27 = pPlayer->GetActualWillpower();
5512 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[163], v129, v27);// "Personality"
5513 LOWORD(v28) = pPlayer->GetStatColor(2);
5514 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 2 * v128 + 169, v28, pTmpBuf, 0, 0, 0);
5515 v29 = pPlayer->GetActualEndurance();
5516 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[75], v129, v29);// "Endurance"
5517 LOWORD(v30) = pPlayer->GetStatColor(3);
5518 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, uY, v30, pTmpBuf, 0, 0, 0);
5519 v31 = pPlayer->GetActualAccuracy();
5520 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[1], v129, v31);// "Accuracy"
5521 LOWORD(v32) = pPlayer->GetStatColor(4);
5522 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 4 * v128 + 169, v32, pTmpBuf, 0, 0, 0);
5523 v33 = pPlayer->GetActualSpeed();
5524 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[211], v129, v33);// "Speed"
5525 LOWORD(v34) = pPlayer->GetStatColor(5);
5526 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v122, v34, pTmpBuf, 0, 0, 0);
5527 v35 = pPlayer->GetActualLuck();
5528 sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[136], v129, v35);// "Luck"
5529 LOWORD(v36) = pPlayer->GetStatColor(6u);
5530 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v119, v36, pTmpBuf, 0, 0, 0);
5531 v37 = pPlayer->GetSkillIdxByOrder(0);
5532 pTextCenter = pFontCreate->AlignText_Center(0x96u, pSkillNames[v37]);
5533 sprintf(pTmpBuf, "\t%03u%s", pTextCenter, pSkillNames[v37]);
5534 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 311, uColorWhite, pTmpBuf, 0, 0, 0);
5535 v39 = pPlayer->GetSkillIdxByOrder(1);
5536 pTextCenter = pFontCreate->AlignText_Center(0x96u, pSkillNames[v39]);
5537 sprintf(pTmpBuf, "\t%03u%s", pTextCenter, pSkillNames[v39]);
5538 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v128 + 311, uColorWhite, pTmpBuf, 0, 0, 0);
5539 v41 = pPlayer->GetSkillIdxByOrder(2);
5540 pTextCenter = pFontCreate->AlignText_Center(150u, pSkillNames[v41]);
5541 sprintf(pTmpBuf, "\t%03u%s", pTextCenter, pSkillNames[v41]);
5542 v45 = uColorGreen;
5543 if ( (signed int)v41 >= 37 )
5544 v45 = uColorTeal;
5545 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 2 * v128 + 311, v45, pTmpBuf, 0, 0, 0);
5546 v46 = pPlayer->GetSkillIdxByOrder(3);
5547 pTextCenter = pFontCreate->AlignText_Center(150u, pSkillNames[v46]);
5548 sprintf(pTmpBuf, "\t%03u%s", pTextCenter, pSkillNames[v46]);
5549 v50 = uColorGreen;
5550 if ( (signed int)v46 >= 37 )
5551 v50 = uColorTeal;
5552 pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v123, v50, pTmpBuf, 0, 0, 0);
5553 //pPlayer++;
5554 v124 = (char *)v124 + 1;
5555 pOrder += 159;
5556 v129 -= 158;
5557 uX += 158;
5558 }
5559 //while ( (signed int)pPlayer->pName < (signed int)&pParty->pPickedItem.uNumCharges );
5560 strcpy(pText, pGlobalTXT_LocalizationStrings[41]);// "Class"
5561 v51 = strlen(pText) - 1;
5562 pOrder = v51;
5563 if ( v51 >= 0 )
5564 {
5565 while ( 1 )
5566 {
5567 v52 = &pText[v51];
5568 v53 = toupper((unsigned __int8)pText[v51]);
5569 v10 = pOrder-- - 1 < 0;
5570 *v52 = v53;
5571 if ( v10 )
5572 break;
5573 v51 = pOrder;
5574 }
5575 }
5576 uClassType = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].uClass;
5577 pTextCenter = pFontCreate->AlignText_Center(193u, pText);
5578 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 324, 395, uColor1, pText, 0, 0, 0);
5579 v57 = uColorTeal;
5580 if ( uClassType )
5581 v57 = uColorWhite;
5582 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[0]);
5583 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 417, v57, pClassNames[0], 0, 0, 0);
5584 v61 = uColorTeal;
5585 if ( uClassType != PLAYER_CLASS_PALADIN )
5586 v61 = uColorWhite;
5587 uColorGreen = v128 + 417;
5588 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[12]);
5589 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, v128 + 417, v61, pClassNames[12], 0, 0, 0);
5590 v66 = uColorTeal;
5591 if ( uClassType != PLAYER_CLASS_DRUID )
5592 v66 = uColorWhite;
5593 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[20]);
5594 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 2 * v128 + 417, v66, pClassNames[20], 0, 0, 0);
5595 v71 = uColorTeal;
5596 if ( uClassType != PLAYER_CLASS_CLERIC )
5597 v71 = uColorWhite;
5598 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[24]);
5599 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 417, v71, pClassNames[24], 0, 0, 0);
5600 v75 = uColorTeal;
5601 if ( uClassType != 28 )
5602 v75 = uColorWhite;
5603 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[28]);
5604 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, uColorGreen, v75, pClassNames[28], 0, 0, 0);
5605 v80 = uColorTeal;
5606 if ( uClassType != PLAYER_CLASS_SORCERER )
5607 v80 = uColorWhite;
5608 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[32]);
5609 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 2 * v128 + 417, v80, pClassNames[32], 0, 0, 0);
5610 v85 = uColorTeal;
5611 if ( uClassType != PLAYER_CLASS_SHOOTER )
5612 v85 = uColorWhite;
5613 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[16]);
5614 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 417, v85, pClassNames[16], 0, 0, 0);
5615 v89 = uColorTeal;
5616 if ( uClassType != PLAYER_CLASS_MONK )
5617 v89 = uColorWhite;
5618 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[8]);
5619 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, uColorGreen, v89, pClassNames[8], 0, 0, 0);
5620 v94 = uColorTeal;
5621 if ( uClassType != PLAYER_CLASS_THEIF )
5622 v94 = uColorWhite;
5623 pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[4]);
5624 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 2 * v128 + 417, v94, pClassNames[4], 0, 0, 0);
5625 pTextCenter = pFontCreate->AlignText_Center(0xECu, pGlobalTXT_LocalizationStrings[20]); // "Available Skills"
5626 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 37, 395, uColor1, pGlobalTXT_LocalizationStrings[20], 0, 0, 0);
5627 //pOrder = 0;
5628 //do
5629 for (pOrder = 0; pOrder < 9; ++pOrder)
5630 {
5631 pSkillId = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pOrder + 4);
5632 strcpy(pText, pSkillNames[pSkillId]);
5633 pLenText = strlen(pText);
5634 v104 = 0;
5635 if ( (signed int)pLenText > 0 )
5636 {
5637 if ( pText[v104] == 32 )
5638 {
5639 pText[v104] = 0;
5640 }
5641 else
5642 {
5643 //while ( pText[v104] != 32 )
5644 for (v104 = 0; v104 < (signed int)pLenText || pText[v104] != 32; ++v104)
5645 {
5646 //++v104;
5647 //if ( v104 >= (signed int)v103 )
5648 //break;
5649 }
5650 }
5651 }
5652 uColorGreen = -5;
5653 if ( (signed int)v124 > 2 )
5654 uColorGreen = 0;
5655 pColorText = uColorTeal;
5656 if ( !pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pSkillId] )
5657 pColorText = uColorWhite;
5658 pTextCenter = pFontCreate->AlignText_Center(100, pText);
5659 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 100 * (pOrder / 3) + pTextCenter + uColorGreen + 17, v128 * (pOrder % 3) + 417, pColorText, pText, 0, 0, 0);
5660 //++pOrder;
5661 }
5662 //while ( pOrder < 9 );
5663 pTextCenter = pFontCreate->AlignText_Center(0x5C, pGlobalTXT_LocalizationStrings[30]);// "Bonus"
5664 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 533, 394, uColor1, pGlobalTXT_LocalizationStrings[30], 0, 0, 0);
5665 v113 = PlayerCreation_ComputeAttributeBonus();
5666 sprintf(pTmpBuf, "%d", v113);
5667 pTextCenter = pFontCreate->AlignText_Center(84, pTmpBuf);
5668 pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 530, 410, uColorWhite, pTmpBuf, 0, 0, 0);
5669 if ( GameUI_StatusBar_TimedStringTimeLeft > GetTickCount() )
5670 {
5671 pWindow.Hint = pGlobalTXT_LocalizationStrings[412];// "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points."
5672 if ( v113 < 0 )
5673 pWindow.Hint = pGlobalTXT_LocalizationStrings[413];// "You can't spend more than 50 points."
5674 pWindow.uFrameWidth = 300;
5675 pWindow.uFrameHeight = 100;
5676 pWindow.uFrameX = 170;
5677 pWindow.uFrameY = 140;
5678 pWindow.uFrameZ = 469;
5679 pWindow.uFrameW = 239;
5680 pWindow.DrawMessageBox(0);
5681 }
5682 pRenderer->EndScene();
5683 }
5684
5685 //----- (0049695A) --------------------------------------------------------
5686 void __cdecl PlayerCreationUI_Initialize()
5687 {
5688 unsigned int v0; // ebx@5
5689 unsigned int v1; // eax@6
5690 int v2; // ecx@6
5691 unsigned int v3; // eax@8
5692 signed int v4; // ecx@8
5693 signed int uControlParam; // [sp+10h] [bp-Ch]@7
5694 unsigned int uControlParama; // [sp+10h] [bp-Ch]@9
5695 unsigned int uControlParamb; // [sp+10h] [bp-Ch]@11
5696 unsigned int uControlParamc; // [sp+10h] [bp-Ch]@13
5697 signed int uControlParamd; // [sp+10h] [bp-Ch]@15
5698 signed int uX; // [sp+14h] [bp-8h]@5
5699 unsigned int uXa; // [sp+14h] [bp-8h]@9
5700 unsigned int uXb; // [sp+14h] [bp-8h]@11
5701 unsigned int uXc; // [sp+14h] [bp-8h]@13
5702 signed int uXd; // [sp+14h] [bp-8h]@16
5703
5704 if ( pMessageQueue_50CBD0->uNumMessages )
5705 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5706 pAudioPlayer->SetMusicVolume((pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
5707 ++pIcons_LOD->uTexturePacksCount;
5708 if ( !pIcons_LOD->uNumPrevLoadedFiles )
5709 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
5710 pCurrentScreen = 21;//îêíî Ñîçäàíèÿ ãðóïïû
5711 uPlayerCreationUI_ArrowAnim = 0;
5712 uPlayerCreationUI_SkySliderPos = 0;
5713 uPlayerCreationUI_SelectedCharacter = 0;
5714 v0 = LOBYTE(pFontCreate->uFontHeight) - 2;
5715 pTexture_IC_KNIGHT[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_KNIGHT", TEXTURE_16BIT_PALETTE)];
5716 pTexture_IC_KNIGHT[1] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_THIEF", TEXTURE_16BIT_PALETTE)];
5717 pTexture_IC_KNIGHT[2] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_MONK", TEXTURE_16BIT_PALETTE)];
5718 pTexture_IC_KNIGHT[3] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_PALAD", TEXTURE_16BIT_PALETTE)];
5719 pTexture_IC_KNIGHT[4] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_ARCH", TEXTURE_16BIT_PALETTE)];
5720 pTexture_IC_KNIGHT[5] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_RANGER", TEXTURE_16BIT_PALETTE)];
5721 pTexture_IC_KNIGHT[6] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_CLER", TEXTURE_16BIT_PALETTE)];
5722 pTexture_IC_KNIGHT[7] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_DRUID", TEXTURE_16BIT_PALETTE)];
5723 pTexture_IC_KNIGHT[8] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_SORC", TEXTURE_16BIT_PALETTE)];
5724 pTexture_MAKETOP = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("MAKETOP", TEXTURE_16BIT_PALETTE)];
5725 uX = 0;
5726 pTexture_MAKESKY = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("MAKESKY", TEXTURE_16BIT_PALETTE)];
5727 do // load PlayerPortraits texture
5728 {
5729 sprintf(pTmpBuf, "%s01", pPlayerPortraitsNames[uX]);
5730 v1 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
5731 v2 = uX * 4;
5732 ++uX;
5733 *(Texture **)((char *)pPlayerPortraits + v2) = &pIcons_LOD->pTextures[v1];
5734 }
5735 while ( uX < 22 );
5736 pTexture_PlayerFaceMask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("FACEMASK", TEXTURE_16BIT_PALETTE)];
5737 pTexture_buttminu = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttminu", TEXTURE_16BIT_PALETTE)];
5738 pTexture_buttplus = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttplus", TEXTURE_16BIT_PALETTE)];
5739 pTexture_pressrigh = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presrigh", TEXTURE_16BIT_PALETTE)];
5740 pTexture_presleft = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presleft", TEXTURE_16BIT_PALETTE)];
5741 uControlParam = 1;
5742 do
5743 {
5744 sprintf(pTmpBuf, "arrowl%d", uControlParam);
5745 pTextures_arrowl[uControlParam] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
5746 sprintf(pTmpBuf, "arrowr%d", uControlParam);
5747 v3 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
5748 v4 = uControlParam++;
5749 pTextures_arrowr[v4] = &pIcons_LOD->pTextures[v3];
5750 }
5751 while ( uControlParam < 20 );
5752 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
5753 uControlParama = 0;
5754 uXa = 8;
5755 do
5756 {
5757 pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, 0x3Cu, uControlParama, 0, "", 0);
5758 uXa += 158;
5759 ++uControlParama;
5760 }
5761 while ( (signed int)uXa < 640 );
5762 pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton(10, 32, 11, 13, 1, 0, 0xABu, 0, 0, "", pTexture_presleft, 0);
5763 pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(169, 32, 11, 13, 1, 0, 0xABu, 1, 0, "", pTexture_presleft, 0);
5764 pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(327, 32, 11, 13, 1, 0, 0xABu, 2, 0, "", pTexture_presleft, 0);
5765 pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(486, 32, 11, 13, 1, 0, 0xABu, 3, 0, "", pTexture_presleft, 0);
5766 pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(74, 32, 11, 13, 1, 0, 0xACu, 0, 0, "", pTexture_pressrigh, 0);
5767 pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(233, 32, 11, 13, 1, 0, 0xACu, 1, 0, "", pTexture_pressrigh, 0);
5768 pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(391, 32, 11, 13, 1, 0, 0xACu, 2, 0, "", pTexture_pressrigh, 0);
5769 pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(549, 32, 11, 13, 1, 0, 0xACu, 3, 0, "", pTexture_pressrigh, 0);
5770 pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(10, 103, 11, 13, 1, 0, 0x90u, 0, 0, "", pTexture_presleft, 0);
5771 pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, 0x90u, 1, 0, "", pTexture_presleft, 0);
5772 pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, 0x90u, 2, 0, "", pTexture_presleft, 0);
5773 pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, 0x90u, 3, 0, "", pTexture_presleft, 0);
5774 pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(74, 103, 11, 13, 1, 0, 0x91u, 0, 0, "", pTexture_pressrigh, 0);
5775 pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(233, 103, 11, 13, 1, 0, 0x91u, 1, 0, "", pTexture_pressrigh, 0);
5776 pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(391, 103, 11, 13, 1, 0, 0x91u, 2, 0, "", pTexture_pressrigh, 0);
5777 pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(549, 103, 11, 13, 1, 0, 0x91u, 3, 0, "", pTexture_pressrigh, 0);
5778 uControlParamb = 0;
5779 uXb = 8;
5780 do
5781 {
5782 pGUIWindow_CurrentMenu->CreateButton(uXb, 308, 150, v0, 1, 0, 0x48u, uControlParamb, 0, "", 0);
5783 pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308, 150, v0, 1, 0, 0x49u, uControlParamb, 0, "", 0);
5784 pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150u, v0, 1, 0, 0x4Au, uControlParamb, 0, "", 0);
5785 pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150u, v0, 1, 0, 0x4Bu, uControlParamb, 0, "", 0);
5786 uXb += 158;
5787 ++uControlParamb;
5788 }
5789 while ( (signed int)uXb < 640 );
5790 pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 0, 0x31u, "", 0);
5791 pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 1u, 0x32u, "", 0);
5792 pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 2u, 0x33u, "", 0);
5793 pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 3u, 0x34u, "", 0);
5794 uXc = 23;
5795 uControlParamc = 2;
5796 do
5797 {
5798 pGUIWindow_CurrentMenu->CreateButton(uXc, 169, 120, 20, 1, 0, 0, uControlParamc - 2, 0, "", 0);
5799 pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169, 120, 20, 1, 0, 0, uControlParamc - 1, 0, "", 0);
5800 pGUIWindow_CurrentMenu->CreateButton(uXc, 2 * v0 + 169, 120, 20, 1, 0, 0, uControlParamc, 0, "", 0);
5801 pGUIWindow_CurrentMenu->CreateButton(uXc, 3 * v0 + 169, 120, 20, 1, 0, 0, uControlParamc + 1, 0, "", 0);
5802 pGUIWindow_CurrentMenu->CreateButton(uXc, 4 * v0 + 169, 120, 20, 1, 0, 0, uControlParamc + 2, 0, "", 0);
5803 pGUIWindow_CurrentMenu->CreateButton(uXc, 5 * v0 + 169, 120, 20, 1, 0, 0, uControlParamc + 3, 0, "", 0);
5804 pGUIWindow_CurrentMenu->CreateButton(uXc, 6 * v0 + 169, 120, 20, 1, 0, 0, uControlParamc + 4, 0, "", 0);
5805 uControlParamc += 7;
5806 uXc += 158;
5807 }
5808 while ( (signed int)uControlParamc < 30 );
5809 pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
5810 pGUIWindow_CurrentMenu->CreateButton(323, 417, 65, v0, 1, 0, 0x41, 0, 0, "", 0);
5811 pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417, 65, v0, 1, 0, 0x41, 0xC, 0, "", 0);
5812 pGUIWindow_CurrentMenu->CreateButton(323, 2 * v0 + 417, 65, v0, 1, 0, 0x41, 0x14, 0, "", 0);
5813 pGUIWindow_CurrentMenu->CreateButton(388, 417, 65, v0, 1, 0, 0x41, 0x18, 0, "", 0);
5814 pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417, 65, v0, 1, 0, 0x41, 0x1C, 0, "", 0);
5815 pGUIWindow_CurrentMenu->CreateButton(388, 2 * v0 + 417, 65, v0, 1, 0, 0x41, 0x20, 0, "", 0);
5816 pGUIWindow_CurrentMenu->CreateButton(453, 417, 65, v0, 1, 0, 0x41, 0x10, 0, "", 0);
5817 pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417, 65, v0, 1, 0, 0x41, 8, 0, "", 0);
5818 pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, 0x41, 4, 0, "", 0);
5819 uControlParamd = 0;
5820 do
5821 {
5822 uXd = -5;
5823 if ( uControlParamd <= 3 )
5824 uXd = 0;
5825 pGUIWindow_CurrentMenu->CreateButton(100 * (uControlParamd / 3) + uXd + 17, v0 * (uControlParamd % 3) + 417, 100, v0, 1, 0, 0x40,
5826 uControlParamd, 0, "", 0);
5827 ++uControlParamd;
5828 }
5829 while ( uControlParamd < 9 );
5830 pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, 0x42, 0, 0xD, "",
5831 (Texture *)(uTextureID_BUTTMAKE != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0), 0);
5832 pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, 0x43, 0, 0x43, "",
5833 (Texture *)(uTextureID_BUTTMAKE2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0), 0);
5834 pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, 0x3F, 0, 0x2D, "", pTexture_buttminu, 0);
5835 pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, 0x3E, 1, 0x2B, "", pTexture_buttplus, 0);
5836 pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0);
5837 }
5838 // 4E28F8: using guessed type int pCurrentScreen;
5839
5840 //----- (0049750E) --------------------------------------------------------
5841 void __cdecl DeleteCCharFont()
5842 {
5843 pAllocator->FreeChunk(pFontCChar);
5844 pFontCChar = 0;
5845 }
5846 //----- (00497526) --------------------------------------------------------
5847 bool __cdecl PlayerCreationUI_Loop()
5848 {
5849 RGBTexture *pTexture; // ebx@1
5850 UINT v1; // esi@1
5851 unsigned int v2; // ecx@3
5852 LONG uMouseX; // edi@6
5853 LONG uMouseY; // eax@6
5854 GUIButton *pControlsHead; // edx@6
5855 unsigned int pNumMessage; // ecx@7
5856 int pControlParam; // esi@12
5857 signed int v8; // edi@30
5858 int v9; // edx@31
5859 char *v10; // ebx@37
5860 Player *v11; // esi@38
5861 signed int uSpellBookPageCount; // ecx@40
5862 int v13; // eax@40
5863 signed int uSkillIdx; // eax@45
5864 int v15; // eax@70
5865 signed int v16; // ecx@70
5866 unsigned int v18; // [sp-4h] [bp-84h]@48
5867 ItemGen item; // [sp+Ch] [bp-74h]@37
5868 char v20[32]; // [sp+30h] [bp-50h]@29
5869 //char v21; // [sp+31h] [bp-4Fh]@29
5870 //__int16 v22; // [sp+4Dh] [bp-33h]@29
5871 char v23; // [sp+4Fh] [bp-31h]@29
5872 MSG Msg; // [sp+50h] [bp-30h]@17
5873 POINT v25; // [sp+6Ch] [bp-14h]@6
5874 bool v26; // [sp+74h] [bp-Ch]@1
5875 POINT v24; // [sp+78h] [bp-8h]@6
5876 Player *pPlayer;
5877
5878 pTexture = &pTexture_PCX;
5879 v1 = 0;
5880 v26 = 0;
5881 pTexture_PCX.Release();
5882 pTexture_PCX.Load("makeme.pcx", 0);
5883 if (pAsyncMouse)
5884 pAsyncMouse->Resume();
5885 v2 = 6;
5886 pGUIWindow_CurrentMenu->field_40 = 0;
5887 LABEL_27:
5888 SetCurrentMenuID((MENU_STATE)v2);
5889 while ( GetCurrentMenuID() == MENU_CREATEPARTY )
5890 {
5891 if ( pAsyncMouse != (void *)v1 )
5892 pAsyncMouse->_46B736_consume_click_lists(1);
5893 uMouseX = pMouse->GetCursorPos(&v24)->x;
5894 uMouseY = pMouse->GetCursorPos(&v25)->y;
5895 pControlsHead = pGUIWindow_CurrentMenu->pControlsHead;
5896 if ( pControlsHead != (GUIButton *)v1 )
5897 {
5898 pNumMessage = pMessageQueue_50CBD0->uNumMessages;
5899 do
5900 {
5901 if ( uMouseX >= (signed int)pControlsHead->uX && uMouseX <= (signed int)pControlsHead->uZ
5902 && uMouseY >= (signed int)pControlsHead->uY && uMouseY <= (signed int)pControlsHead->uW )//mouse movement
5903 {
5904 pControlParam = pControlsHead->uControlParam;
5905 if ( (signed int)pNumMessage < 40 )
5906 {
5907 pMessageQueue_50CBD0->pMessages[pNumMessage].eType = (UIMessageType)pControlsHead->field_1C;
5908 pTexture = &pTexture_PCX;
5909 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = pControlParam;
5910 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
5911 pNumMessage = pMessageQueue_50CBD0->uNumMessages + 1;
5912 ++pMessageQueue_50CBD0->uNumMessages;
5913 }
5914 v1 = 0;
5915 }
5916 pControlsHead = pControlsHead->pNext;
5917 }
5918 while ( pControlsHead != (GUIButton *)v1 );
5919 }
5920 while ( PeekMessageA(&Msg, (HWND)v1, v1, v1, PM_REMOVE) )
5921 {
5922 if ( Msg.message == WM_QUIT )
5923 Game_DeinitializeAndTerminate(0);
5924 TranslateMessage(&Msg);
5925 DispatchMessageA(&Msg);
5926 }
5927 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
5928 {
5929 WaitMessage();
5930 }
5931 else
5932 {
5933 PlayerCreationUI_Draw();
5934 GUI_MainMenuMessageProc();
5935 pRenderer->BeginScene();
5936 GUI_UpdateWindows();
5937 pRenderer->EndScene();
5938 pRenderer->Present();
5939 if ( uGameState == 1 )
5940 {
5941 v26 = 1;
5942 v2 = 0;
5943 goto LABEL_27;
5944 }
5945 if ( uGameState == 6 )
5946 {
5947 uGameState = v1;
5948 v2 = 1;
5949 goto LABEL_27;
5950 }
5951 }
5952 }
5953 pTexture->Release();
5954 pGUIWindow_CurrentMenu->Release();
5955 pIcons_LOD->_4114F2();
5956 v20[0] = 0;
5957 memset(&v20[1], 0, 0x1Cu);
5958 *(_WORD*)&v20[29] = 0;
5959 v20[31] = 0;
5960 do
5961 {
5962 v8 = 0;
5963 do
5964 {
5965 v9 = rand() % 32;
5966 if ( !v20[v9] )
5967 break;
5968 ++v8;
5969 }
5970 while ( v8 < 10 );
5971 if ( v8 == 10 )
5972 {
5973 v9 = 0;
5974 if ( v20[0] )
5975 {
5976 do
5977 ++v9;
5978 while ( v20[v9] );
5979 }
5980 }
5981 pParty->field_854[v1++] = v9;
5982 v20[v9] = 1;
5983 }
5984 while ( (signed int)v1 < 32 );
5985 item.Reset();
5986 //v10 = (char *)&pParty->pPlayers[0].sResMagicBase;
5987 for ( pPlayer = &pParty->pPlayers[0]; pPlayer < &pParty->pPlayers[4]; pPlayer++)
5988 {
5989 //v11 = pPlayer;
5990 if ( !pPlayer->uClass )
5991 pPlayer->sResMagicBase = 10;
5992 //*((short *)v10 + 400) = 0;
5993 pPlayer->pPlayerBuffs[22].uExpireTime = 0;
5994 uSpellBookPageCount = 0;
5995 for ( int i = 0; i < 9; i++)
5996 {
5997 if ( pPlayer->pActiveSkills[12+i] )
5998 ++uSpellBookPageCount;
5999 }
6000 pPlayer->pNumSpellBookPage = uSpellBookPageCount;
6001 pItemsTable->GenerateItem(2, 40, &item);
6002 pPlayer->AddItem2(-1, &item);
6003 uSkillIdx = 0;
6004 v24.y = 0;
6005 do
6006 {
6007 if ( pPlayer->pActiveSkills[uSkillIdx] )
6008 {
6009 switch ( uSkillIdx )
6010 {
6011 case 0:
6012 v18 = 61;
6013 pPlayer->AddItem(-1, v18);
6014 break;
6015 case 1:
6016 v18 = 1;
6017 pPlayer->AddItem(-1, v18);
6018 break;
6019 case 2:
6020 v18 = 15;
6021 pPlayer->AddItem(-1, v18);
6022 break;
6023 case 3:
6024 v18 = 23;
6025 pPlayer->AddItem(-1, v18);
6026 break;
6027 case 4:
6028 v18 = 31;
6029 pPlayer->AddItem(-1, v18);
6030 break;
6031 case 5:
6032 v18 = 47;
6033 pPlayer->AddItem(-1, v18);
6034 break;
6035 case 6:
6036 v18 = 50;
6037 pPlayer->AddItem(-1, v18);
6038 break;
6039 case 8:
6040 v18 = 84;
6041 pPlayer->AddItem(-1, v18);
6042 break;
6043 case 9:
6044 v18 = 66;
6045 pPlayer->AddItem(-1, v18);
6046 break;
6047 case 10:
6048 v18 = 71;
6049 pPlayer->AddItem(-1, v18);
6050 break;
6051 case 11:
6052 v18 = 76;
6053 pPlayer->AddItem(-1, v18);
6054 break;
6055 case 12:
6056 pPlayer->AddItem(-1, 0x191);
6057 pPlayer->spellbook.pFireSpellbook.bIsSpellbookAvailable = 1;
6058 break;
6059 case 13:
6060 pPlayer->AddItem(-1, 0x19C);
6061 pPlayer->spellbook.pAirSpellbook.bIsSpellbookAvailable = 1;
6062 break;
6063 case 14:
6064 pPlayer->AddItem(-1, 0x1A7);
6065 pPlayer->spellbook.pWaterSpellbook.bIsSpellbookAvailable = 1;
6066 break;
6067 case 15:
6068 pPlayer->AddItem(-1, 0x1B2);
6069 pPlayer->spellbook.pEarthSpellbook.bIsSpellbookAvailable = 1;
6070 break;
6071 case 16:
6072 pPlayer->AddItem(-1, 0x1BD);
6073 pPlayer->spellbook.pSpiritSpellbook.bIsSpellbookAvailable = 1;
6074 break;
6075 case 17:
6076 pPlayer->AddItem(-1, 0x1C8);
6077 pPlayer->spellbook.pMindSpellbook.bIsSpellbookAvailable = 1;
6078 break;
6079 case 18:
6080 pPlayer->AddItem(-1, 0x1D3);
6081 pPlayer->spellbook.pBodySpellbook.bIsSpellbookAvailable = 1;
6082 break;
6083 case 21:
6084 case 23:
6085 case 25:
6086 case 26:
6087 case 29:
6088 case 36:
6089 pPlayer->AddItem(-1, 0xDC);
6090 v18 = 5 * (rand() % 3 + 40);
6091 pPlayer->AddItem(-1, v18);
6092 break;
6093 case 30:
6094 v18 = 115;
6095 pPlayer->AddItem(-1, v18);
6096 break;
6097 case 31:
6098 v18 = 110;
6099 pPlayer->AddItem(-1, v18);
6100 break;
6101 default:
6102 break;
6103 }
6104 for ( int i = 0; i < 138; i++)
6105 {
6106 if ( &pPlayer->pInventoryItems[i] )
6107 pPlayer->pInventoryItems[i].uAttributes |= 1;
6108 }
6109 pPlayer->sHealth = pPlayer->GetMaxHealth();
6110 pPlayer->sMana = pPlayer->GetMaxMana();
6111 uSkillIdx = v24.y;
6112 }
6113 ++uSkillIdx;
6114 v24.y = uSkillIdx;
6115 }
6116 while ( uSkillIdx < 37 );
6117 //v10 += 6972;
6118 //pPlayer++;
6119 }
6120 //while ( (signed int)v10 < (signed int)((char *)&pParty->field_871C[455] + 2) );
6121 pAudioPlayer->StopChannels(-1, -1);
6122 if (pAsyncMouse)
6123 pAsyncMouse->Suspend();
6124 return v26;
6125 }
6126
6127 //----- (004979D2) --------------------------------------------------------
6128 MENU_STATE __cdecl CreditsMenu__Loop()
6129 {
6130 char *v0; // eax@5
6131 char *v1; // edi@5
6132 FILE *pFile; // eax@5
6133 unsigned int pSize; // esi@7
6134 GUIFont *pFont; // edx@9
6135 GUIFont *pFont2; // ecx@9
6136 __int16 pHeight; // ax@9
6137 void *v7; // eax@9
6138 unsigned int pNumPixels; // ST2C_4@9
6139 unsigned int teal; // eax@9
6140 unsigned int v10; // ST2C_4@19
6141 MSG Msg; // [sp+84h] [bp-B8h]@10
6142 int v17; // [sp+A0h] [bp-9Ch]@9
6143 int pX; // [sp+A4h] [bp-98h]@9
6144 unsigned int pY; // [sp+A8h] [bp-94h]@9
6145 int v20; // [sp+ACh] [bp-90h]@9
6146 int a4; // [sp+B0h] [bp-8Ch]@9
6147 int pColor2; // [sp+F8h] [bp-44h]@9
6148 int pColor1; // [sp+FCh] [bp-40h]@9
6149 int a5; // [sp+128h] [bp-14h]@1
6150 char *pString; // [sp+12Ch] [bp-10h]@9
6151 char *ptr; // [sp+130h] [bp-Ch]@5
6152 GUIFont *pFontQuick; // [sp+134h] [bp-8h]@1
6153 GUIFont *pFontCChar; // [sp+138h] [bp-4h]@1
6154 RGBTexture pTexture; // [sp+54h] [bp-E8h]@1
6155 RGBTexture pTexture2; // [sp+100h] [bp-3Ch]@1
6156 Texture pTexture3; // [sp+Ch] [bp-130h]@5
6157
6158 a5 = 0;
6159 pFontQuick = LoadFont("quick.fnt", "FONTPAL", 0);
6160 pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0);
6161 if ( pMessageQueue_50CBD0->uNumMessages )
6162 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
6163 ++pIcons_LOD->uTexturePacksCount;
6164 if ( !pIcons_LOD->uNumPrevLoadedFiles )
6165 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
6166 dword_A74C88 = 0;
6167 pAudioPlayer->PlayMusicTrack(MUSIC_Credits);
6168 pTexture.Load("mm6title.pcx", 0);
6169 v0 = (char *)pEvents_LOD->LoadRaw("credits.txt", 0);
6170 v1 = v0;
6171 ptr = v0;
6172 pFile = pEvents_LOD->FindContainer("credits.txt", 0);
6173 if ( !pFile )
6174 Abortf(pGlobalTXT_LocalizationStrings[63]); // "Might and Magic VII is having trouble loading files.
6175 // Please re-install to fix this problem. Note: Re-installing will not destroy your save games."
6176 fread(&pTexture3, 1, 0x30, pFile);
6177 pSize = pTexture3.uDecompressedSize;
6178 if ( !pTexture3.uDecompressedSize )
6179 pSize = pTexture3.uTextureSize;
6180 memset(&pTexture3, 0, 0x48);
6181 pFont = pFontCChar;
6182 pFont2 = pFontQuick;
6183 v1[pSize] = 0;
6184 v20 = 250;
6185 a4 = 440;
6186 pX = 389;
6187 pY = 19;
6188 pTexture2.uWidth = 250;
6189 pHeight = pFont2->GetStringHeight2(pFont, v1, (int)&pX, 0, 1);
6190 pTexture2.uHeight = pHeight + 2 * a4;
6191 pTexture2.uNumPixels = (signed __int16)pTexture2.uWidth * (signed __int16)pTexture2.uHeight;
6192 v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap");
6193 pNumPixels = pTexture2.uNumPixels;
6194 pTexture2.pPixels = (unsigned __int16 *)v7;
6195 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
6196 fill_pixels_fast(teal, pTexture2.pPixels, pNumPixels);
6197 pTexture2.field_20 = 0;
6198 pTexture2.field_22 = 0;
6199 pColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x70u, 0x8Fu, 0xFEu);
6200 pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xECu, 0xE6u, 0x9Cu);
6201 pString = (char *)operator new(2 * pSize);
6202 strncpy(pString, ptr, pSize);
6203 pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a4, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1,
6204 pColor2, pString, pTexture2.pPixels, (signed __int16)pTexture2.uWidth);
6205 free(pString);
6206 pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
6207 pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, "", 0);
6208 pCurrentScreen = 9; // îêíî Credits
6209 SetCurrentMenuID(MENU_Credits);
6210 do
6211 {
6212 while ( PeekMessageA(&Msg, 0, 0, 0, 1) )
6213 {
6214 if ( Msg.message == 18 )
6215 Game_DeinitializeAndTerminate(0);
6216 TranslateMessage(&Msg);
6217 DispatchMessageA(&Msg);
6218 }
6219 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
6220 {
6221 WaitMessage();
6222 }
6223 else
6224 {
6225 if (pAsyncMouse)
6226 pAsyncMouse->_46B736_consume_click_lists(1);
6227 pRenderer->BeginScene();
6228 pRenderer->DrawTextureRGB(0, 0, &pTexture);
6229 pRenderer->Clip(pX, pY, pX + v20, pY + a4);
6230 pRenderer->_4A5D33(pX, pY, 0, a5, &pTexture2);
6231 pRenderer->ResetClip();
6232 pRenderer->EndScene();
6233 ++a5;
6234 if ( a5 >= (signed __int16)pTexture2.uHeight )
6235 SetCurrentMenuID(MENU_MAIN);
6236 pRenderer->Present();
6237 pCurrentScreen = 0;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc()
6238 GUI_MainMenuMessageProc();
6239 }
6240 }
6241 while ( GetCurrentMenuID() == MENU_Credits );
6242 pAudioPlayer->_4AA258(1);
6243 pAllocator->FreeChunk(ptr);
6244 pAllocator->FreeChunk(pFontQuick);
6245 pAllocator->FreeChunk(pFontCChar);
6246 pWindow_MainMenu->Release();
6247 pIcons_LOD->_4114F2();
6248 pTexture.Release();
6249 pTexture2.Release();
6250 return MENU_MAIN; // return MENU_Main
6251 }
6252
6253 //----- (0049B04D) --------------------------------------------------------
6254 int stru154::_49B04D(ODMFace *a2, BSPVertexBuffer *a3)
6255 {
6256 stru154 *v3; // edi@1
6257 signed int v4; // eax@1
6258 signed int result; // eax@9
6259 signed int v6; // [sp-8h] [bp-18h]@8
6260 Vec3_float_ v; // [sp+4h] [bp-Ch]@1
6261
6262 v.x = 0.0;
6263 v3 = this;
6264 v.y = 0.0;
6265 v.z = 0.0;
6266 _49B13D(a2, a3, &v, (float *)&a3);
6267 v4 = 2;
6268 if ( a2->pFacePlane.vNormal.z )
6269 {
6270 if ( !a2->pFacePlane.vNormal.x && !a2->pFacePlane.vNormal.y )
6271 v4 = 1;
6272 }
6273 else
6274 {
6275 v4 = 0;
6276 }
6277 if ( v4 )
6278 {
6279 if ( v4 == 1 )
6280 v6 = 3;
6281 else
6282 v6 = 4;
6283 result = v6;
6284 }
6285 else
6286 {
6287 result = 1;
6288 }
6289 v3->face_plane.vNormal.x = v.x;
6290 v3->face_plane.vNormal.y = v.y;
6291 v3->face_plane.vNormal.z = v.z;
6292 v3->face_plane.dist = *(float *)&a3;
6293 v3->polygonType = (PolygonType)result;
6294 return result;
6295 }
6296
6297 //----- (0049B0C9) --------------------------------------------------------
6298 int stru154::_49B0C9(Vec3_float_ *pNormal, float dist)
6299 {
6300 signed int v3; // esi@1
6301 signed int result; // eax@9
6302 double v5; // st7@12
6303 double v6; // st6@12
6304 double v7; // st5@12
6305 signed int v8; // [sp+0h] [bp-4h]@8
6306
6307 v3 = 2;
6308 if ( pNormal->z == 0.0 )
6309 {
6310 v3 = 0;
6311 }
6312 else
6313 {
6314 if ( pNormal->x == 0.0 && pNormal->y == 0.0 )
6315 v3 = 1;
6316 }
6317 if ( v3 )
6318 {
6319 if ( v3 == 1 )
6320 v8 = 3;
6321 else
6322 v8 = 4;
6323 result = v8;
6324 }
6325 else
6326 {
6327 result = 1;
6328 }
6329 v5 = pNormal->z;
6330 v6 = pNormal->y;
6331 v7 = pNormal->x;
6332 this->polygonType = (PolygonType)result;
6333 this->face_plane.vNormal.x = v7;
6334 this->face_plane.dist = dist;
6335 this->face_plane.vNormal.y = v6;
6336 this->face_plane.vNormal.z = v5;
6337 return result;
6338 }
6339
6340 //----- (0049B13D) --------------------------------------------------------
6341 int stru154::_49B13D(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *a3, float *a4)
6342 {
6343 ODMFace *v5; // ebx@1
6344 int v6; // eax@1
6345 unsigned __int16 *v7; // ebx@2
6346 Vec3_int_ *v8; // eax@3
6347 Vec3_int_ *v9; // ecx@3
6348 double v10; // st7@3
6349 int v11; // ecx@3
6350 Vec3_int_ *v12; // ecx@3
6351 double v13; // st7@3
6352 double v14; // st6@3
6353 double v15; // st5@3
6354 int v16; // ecx@3
6355 Vec3_int_ *v17; // eax@3
6356 double v18; // st5@3
6357 Vec3_float_ *v19; // eax@3
6358 int result; // eax@8
6359 float v21; // ecx@10
6360 double v22; // st7@10
6361 double v23; // st6@10
6362 Vec3_float_ v2; // [sp+4h] [bp-64h]@3
6363 float v25; // [sp+18h] [bp-50h]@3
6364 float v26; // [sp+1Ch] [bp-4Ch]@3
6365 float v27; // [sp+20h] [bp-48h]@3
6366 float v28; // [sp+24h] [bp-44h]@3
6367 float v29; // [sp+2Ch] [bp-3Ch]@3
6368 float v30; // [sp+30h] [bp-38h]@3
6369 float v31; // [sp+34h] [bp-34h]@3
6370 float v32; // [sp+38h] [bp-30h]@3
6371 float v33; // [sp+3Ch] [bp-2Ch]@3
6372 Vec3_float_ v1; // [sp+40h] [bp-28h]@1
6373 float v35; // [sp+4Ch] [bp-1Ch]@3
6374 float v36; // [sp+50h] [bp-18h]@3
6375 float v37; // [sp+54h] [bp-14h]@3
6376 Vec3_float_ v38; // [sp+58h] [bp-10h]@3
6377 int v39; // [sp+64h] [bp-4h]@1
6378
6379 v39 = 0;
6380 v1.x = 0.0;
6381 v5 = pFace;
6382 v6 = pFace->uNumVertices;
6383 v1.y = 0.0;
6384 v1.z = 0.0;
6385 if ( v6 - 1 <= 0 )
6386 {
6387 LABEL_8:
6388 a3->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.x >> 16);
6389 a3->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.y >> 16);
6390 a3->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.z >> 16);
6391 result = (int)a4;
6392 *a4 = (double)(v5->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.dist >> 16);
6393 }
6394 else
6395 {
6396 v7 = &pFace->pVertexIDs[1];
6397 while ( 1 )
6398 {
6399 v8 = pVertices->pVertices;
6400 v9 = &v8[*(v7 - 1)];
6401 v35 = (double)v9->x;
6402 v36 = (double)v9->y;
6403 v10 = (double)v9->z;
6404 v11 = *v7;
6405 v37 = v10;
6406 v12 = &v8[v11];
6407 v13 = (double)v12->x;
6408 v14 = (double)v12->y;
6409 v15 = (double)v12->z;
6410 v16 = v7[1];
6411 v25 = v15;
6412 v17 = &v8[v16];
6413 v18 = (double)v17->x;
6414 v29 = (double)v17->y;
6415 v30 = (double)v17->z;
6416 v31 = v13 - v35;
6417 v32 = v14 - v36;
6418 v33 = v25 - v37;
6419 v1.x = v31;
6420 v26 = v18 - v13;
6421 v1.y = v32;
6422 v27 = v29 - v14;
6423 v1.z = v33;
6424 v28 = v30 - v25;
6425 v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28);
6426 v38.x = v19->x;
6427 v38.y = v19->y;
6428 v38.z = v19->z;
6429 if ( v38.x != 0.0 )
6430 break;
6431 if ( v38.y != 0.0 || v38.z != 0.0 )
6432 break;
6433 ++v39;
6434 ++v7;
6435 if ( v39 >= pFace->uNumVertices - 1 )
6436 {
6437 v5 = pFace;
6438 goto LABEL_8;
6439 }
6440 }
6441 v38.Normalize();
6442 v21 = v38.y;
6443 a3->x = v38.x;
6444 v22 = v37 * v38.z;
6445 v23 = v36 * v38.y;
6446 a3->y = v21;
6447 a3->z = v38.z;
6448 result = (int)a4;
6449 *a4 = -(v22 + v23 + v35 * v38.x);
6450 }
6451 return result;
6452 }
6453
6454
6455
6456
6457
6458 //----- (0049D700) --------------------------------------------------------
6459 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim)
6460 {
6461 unsigned int v1; // eax@1
6462 int v2; // ecx@1
6463 unsigned int v3; // eax@1
6464
6465 v1 = uDim;
6466 v2 = 0;
6467 v3 = v1 - 1;
6468 while ( v3 & 1 )
6469 {
6470 v3 >>= 1;
6471 ++v2;
6472 }
6473 return v3 == 0 ? v2 : 0;
6474 }
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485 //----- (004A19D8) --------------------------------------------------------
6486 int __fastcall sub_4A19D8(unsigned int a1, unsigned int a2)
6487 {
6488 signed __int64 v2; // ST10_8@1
6489 double v3; // st7@1
6490 float v4; // ST24_4@1
6491 double v5; // ST10_8@1
6492 int v6; // ST1C_4@1
6493 float v7; // ST24_4@1
6494 double v8; // ST10_8@1
6495 unsigned __int8 v9; // ST20_1@1
6496 float v10; // ST24_4@1
6497 double v11; // ST10_8@1
6498 float v12; // ST24_4@1
6499 double v13; // ST08_8@1
6500
6501 v2 = a1 >> 24;
6502 v3 = (double)v2 * 0.0039215689;
6503 LODWORD(v2) = a2 >> 24;
6504 v4 = v3 * (double)v2 * 0.0039215689 * 255.0;
6505 v5 = v4 + 6.7553994e15;
6506 v6 = LODWORD(v5);
6507 v7 = (double)((a1 >> 16) & 0xFFi64) * 0.0039215689 * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
6508 v8 = v7 + 6.7553994e15;
6509 v9 = LOBYTE(v8);
6510 v10 = (double)((unsigned __int16)a1 >> 8) * 0.0039215689 * (double)((unsigned __int16)a2 >> 8) * 0.0039215689 * 255.0;
6511 v11 = v10 + 6.7553994e15;
6512 v12 = (double)(a1 & 0xFFi64) * 0.0039215689 * (double)(unsigned __int8)a2 * 0.0039215689 * 255.0;
6513 v13 = v12 + 6.7553994e15;
6514 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);
6515 }
6516
6517
6518
6519 //----- (004A46E6) --------------------------------------------------------
6520 int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
6521 {
6522 int v5; // eax@1
6523 int z; // eax@1
6524 unsigned int v7; // eax@9
6525 unsigned int v8; // ecx@9
6526 int v9; // eax@9
6527 unsigned int v10; // eax@10
6528 int *v11; // esi@10
6529 int *v12; // edi@10
6530 int v13; // ecx@10
6531 int v14; // edx@10
6532 unsigned int v15; // eax@22
6533 int *v16; // esi@22
6534 int *v17; // edi@22
6535 int v18; // ecx@22
6536 int v19; // edx@22
6537 unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9
6538 int *pTargetZ; // [sp+10h] [bp-4h]@9
6539 unsigned int v22; // [sp+1Ch] [bp+8h]@9
6540 signed int v23; // [sp+20h] [bp+Ch]@1
6541
6542 v5 = a4;
6543 v23 = _z >> 16;
6544 z = x + v5;
6545 if ( z >= (signed int)pViewport->uViewportX
6546 && (signed int)x <= (signed int)pViewport->uViewportZ
6547 && y >= (signed int)pViewport->uViewportY
6548 && y <= (signed int)pViewport->uViewportW )
6549 {
6550 if ( (signed int)x < (signed int)pViewport->uViewportX )
6551 x = pViewport->uViewportX;
6552 if ( z > (signed int)pViewport->uViewportZ )
6553 z = pViewport->uViewportZ;
6554 pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
6555 v22 = z - x;
6556 pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
6557 v7 = lightColor >> 3;
6558 v8 = lightColor & 0xF0;
6559 v9 = v7 & 0x1E0000;
6560 if ( pRenderer->uTargetGBits == 5 )
6561 {
6562 v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
6563 v11 = (int *)pTarget;
6564 v12 = pTargetZ;
6565 v13 = v22;
6566 v14 = (v10 << 16) | v10;
6567 z = (unsigned __int8)pTarget & 2;
6568 if ( (unsigned __int8)pTarget & 2 )
6569 {
6570 z = (unsigned int)*pTargetZ >> 16;
6571 if ( z > v23 )
6572 {
6573 z = v14 + ((*pTarget & 0x7BDEu) >> 1);
6574 *pTarget = z;
6575 }
6576 v13 = v22 - 1;
6577 v11 = (int *)(pTarget + 1);
6578 v12 = pTargetZ + 1;
6579 }
6580 while ( v13 != 1 )
6581 {
6582 if ( v13 < 1 )
6583 return z;
6584 z = (unsigned int)*v12 >> 16;
6585 if ( z <= v23 )
6586 {
6587 v13 -= 2;
6588 ++v11;
6589 v12 += 2;
6590 }
6591 else
6592 {
6593 v12 += 2;
6594 z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1);
6595 v13 -= 2;
6596 *v11 = z;
6597 ++v11;
6598 }
6599 }
6600 z = (unsigned int)*v12 >> 16;
6601 if ( z > v23 )
6602 {
6603 z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1);
6604 *(short *)v11 = z;
6605 }
6606 }
6607 else
6608 {
6609 v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
6610 v16 = (int *)pTarget;
6611 v17 = pTargetZ;
6612 v18 = v22;
6613 v19 = (v15 << 16) | v15;
6614 z = (unsigned __int8)pTarget & 2;
6615 if ( (unsigned __int8)pTarget & 2 )
6616 {
6617 z = (unsigned int)*pTargetZ >> 16;
6618 if ( z > v23 )
6619 {
6620 z = v19 + ((*pTarget & 0xF7DEu) >> 1);
6621 *pTarget = z;
6622 }
6623 v18 = v22 - 1;
6624 v16 = (int *)(pTarget + 1);
6625 v17 = pTargetZ + 1;
6626 }
6627 while ( v18 != 1 )
6628 {
6629 if ( v18 < 1 )
6630 return z;
6631 z = (unsigned int)*v17 >> 16;
6632 if ( z <= v23 )
6633 {
6634 v18 -= 2;
6635 ++v16;
6636 v17 += 2;
6637 }
6638 else
6639 {
6640 v17 += 2;
6641 z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1);
6642 v18 -= 2;
6643 *v16 = z;
6644 ++v16;
6645 }
6646 }
6647 z = (unsigned int)*v17 >> 16;
6648 if ( z > v23 )
6649 {
6650 z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1);
6651 *(short *)v16 = z;
6652 }
6653 }
6654 }
6655 return z;
6656 }
6657
6658
6659 //----- (004A57E9) --------------------------------------------------------
6660 void __cdecl Present_ColorKey()
6661 {
6662 HRESULT v0; // eax@3
6663 HRESULT v1; // eax@3
6664 HRESULT v2; // eax@3
6665 HRESULT v3; // eax@3
6666 HRESULT v4; // eax@3
6667 RECT a2; // [sp+4h] [bp-14h]@3
6668 //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3
6669
6670 if ( !pRenderer->uNumSceneBegins )
6671 {
6672 if ( pRenderer->field_40110 )
6673 {
6674 a2.bottom = pViewport->uViewportY;
6675 a2.left = 0;
6676 a2.top = 0;
6677 a2.right = 640;
6678 ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u));
6679 a2.right = 640;
6680 a2.left = 0;
6681 a2.top = pViewport->uViewportW + 1;
6682 a2.bottom = 480;
6683 ErrD3D(pRenderer->pBackBuffer4->BltFast(
6684 0,
6685 pViewport->uViewportW + 1,
6686 pRenderer->pColorKeySurface4,
6687 &a2,
6688 16u));
6689 a2.right = pViewport->uViewportX;
6690 a2.bottom = pViewport->uViewportW + 1;
6691 a2.left = 0;
6692 a2.top = pViewport->uViewportY;
6693 ErrD3D(pRenderer->pBackBuffer4->BltFast(
6694 0,
6695 pViewport->uViewportY,
6696 pRenderer->pColorKeySurface4,
6697 &a2,
6698 16u));
6699 a2.left = pViewport->uViewportZ;
6700 a2.top = pViewport->uViewportY;
6701 a2.right = 640;
6702 a2.bottom = pViewport->uViewportW + 1;
6703 ErrD3D(pRenderer->pBackBuffer4->BltFast(
6704 pViewport->uViewportZ,
6705 pViewport->uViewportY,
6706 pRenderer->pColorKeySurface4,
6707 &a2,
6708 16u));
6709 a2.right = pViewport->uViewportZ;
6710 a2.bottom = pViewport->uViewportW + 1;
6711 a2.left = pViewport->uViewportX;
6712 a2.top = pViewport->uViewportY;
6713 ErrD3D(pRenderer->pBackBuffer4->BltFast(
6714 pViewport->uViewportX,
6715 pViewport->uViewportY,
6716 pRenderer->pColorKeySurface4,
6717 &a2,
6718 17u));
6719 }
6720 }
6721 }
6722
6723 //----- (004A597D) --------------------------------------------------------
6724 void Present_NoColorKey()
6725 {
6726 //unsigned __int16 *v0; // eax@4
6727 unsigned __int16 *v1; // esi@4
6728 void *v2; // edi@4
6729 //signed int v4; // ebx@4
6730 //signed int v5; // ebx@6
6731 //void *v6; // edi@7
6732 //const void *v7; // esi@7
6733 signed int v8; // ebx@8
6734 int v9; // eax@10
6735 unsigned int v10; // esi@10
6736 unsigned __int32 v11; // edi@10
6737 //int v12; // ecx@10
6738 unsigned int v13; // ebx@10
6739 int v14; // eax@11
6740 int v15; // eax@13
6741 int v16; // eax@14
6742 int v17; // eax@16
6743 HRESULT v18; // eax@22
6744 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
6745 int v20; // [sp+88h] [bp-1Ch]@10
6746 int v21; // [sp+8Ch] [bp-18h]@10
6747 __int32 v22; // [sp+90h] [bp-14h]@10
6748 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
6749 unsigned int v24; // [sp+98h] [bp-Ch]@4
6750 //unsigned int _this; // [sp+9Ch] [bp-8h]@10
6751 //LPVOID v26; // [sp+A0h] [bp-4h]@4
6752
6753 if ( !pRenderer->uNumSceneBegins )
6754 {
6755 if ( pRenderer->field_40110 )
6756 {
6757 memset(&Dst, 0, 0x7Cu);
6758 Dst.dwSize = 124;
6759 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) )
6760 {
6761 //v26 = Dst.lpSurface;
6762 pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
6763 v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask |
6764 ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16);
6765 pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
6766 pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
6767 v1 = pRenderer->pTargetSurface;
6768 v2 = Dst.lpSurface;
6769
6770
6771 /*for (uint y = 0; y < 480; ++y)
6772 {
6773 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
6774 for (uint x = 0; x < 640; ++x)
6775 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
6776 }*/
6777
6778 auto pSrc = pRenderer->pTargetSurface;
6779 auto pDst = (__int16 *)Dst.lpSurface;
6780
6781 for (uint y = 0; y < 8; ++y)
6782 memcpy(pDst + y * Dst.lPitch / 2,
6783
6784 pSrc + y * 640, 640 * sizeof(__int16));
6785
6786 for (uint y = 8; y < 352; ++y)
6787 {
6788 memcpy(pDst + y * Dst.lPitch / 2,
6789 pSrc + y * 640, 8 * sizeof(__int16));
6790 memcpy(pDst + 8 + 460/*462*/ + y * Dst.lPitch / 2,
6791 pSrc + 8 + 460/*462*/ + y * 640, 174/*172*/ * sizeof(__int16));
6792 }
6793
6794 for (uint y = 351/*352*/; y < 480; ++y)
6795 memcpy(pDst + y * Dst.lPitch / 2,
6796 pSrc + y * 640, 640 * sizeof(__int16));
6797
6798
6799 auto pSrc_x1y1 = pSrc + 640 * pViewport->uViewportY + pViewport->uViewportX;
6800 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
6801 auto pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportY + pViewport->uViewportX;
6802 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
6803 v9 = ((signed int)pViewport->uViewportX >> 1) - ((signed int)pViewport->uViewportZ >> 1);
6804 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
6805 v22 = 4 * ((Dst.lPitch / 4) + v9);
6806 v21 = 4 * v9 + 1280;
6807
6808 auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1;
6809 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
6810 v10 = (int)pSrc_x1y1;
6811 v11 = (int)pDst_x1y1;
6812 auto uHalfWidth = v20 = (pViewport->uViewportZ - pViewport->uViewportX) / 2;
6813 v13 = v24;
6814
6815 for (uint y = pViewport->uViewportY; y < pViewport->uViewportW + 1; ++y)
6816 {
6817 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
6818 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
6819 for (uint x = pViewport->uViewportX; x < pViewport->uViewportZ; ++x)
6820 {
6821 if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
6822 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
6823 }
6824 }
6825
6826 ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
6827
6828 /* while ( 1 )
6829 {
6830 while ( 1 )
6831 {
6832 v14 = *(int *)v10;
6833 v10 += 4;
6834 if ( v14 == v13 )
6835 break;
6836 if ( (short)v14 == (short)v13 )
6837 {
6838 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000;
6839 v11 += 4;
6840 --uHalfWidth;
6841 if ( !uHalfWidth )
6842 goto LABEL_21;
6843 }
6844 else
6845 {
6846 v15 = __ROL__(v14, 16);
6847 if ( (short)v15 == (short)v13 )
6848 {
6849 v17 = __ROR__(v15, 16);
6850 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17;
6851 v11 += 4;
6852 --uHalfWidth;
6853 if ( !uHalfWidth )
6854 goto LABEL_21;
6855 }
6856 else
6857 {
6858 v16 = __ROR__(v15, 16);
6859 *(int *)v11 = v16;
6860 v11 += 4;
6861 --uHalfWidth;
6862 if ( !uHalfWidth )
6863 goto LABEL_21;
6864 }
6865 }
6866 }
6867 v11 += 4;
6868 --uHalfWidth;
6869 if ( !uHalfWidth )
6870 {
6871 LABEL_21:
6872 v10 += v21;
6873 v11 += v22;
6874 uHalfWidth = v20;
6875 if ( !--uNumLines )
6876 {
6877 ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
6878 return;
6879 }
6880 }
6881 }*/
6882 }
6883 }
6884 }
6885 }
6886
6887
6888
6889 //----- (004A7063) --------------------------------------------------------
6890 int __thiscall sub_4A7063(unsigned int uDiffuse, float a2)
6891 {
6892 float v2; // ST1C_4@1
6893 double v3; // ST14_8@1
6894 signed int v4; // ebx@1
6895 float v5; // ST1C_4@1
6896 double v6; // ST14_8@1
6897 signed int v7; // edi@1
6898 double v8; // ST0C_8@1
6899 signed int v9; // esi@1
6900 signed int v10; // ecx@1
6901 double v12; // [sp+8h] [bp-18h]@1
6902 unsigned __int64 v13; // [sp+18h] [bp-8h]@1
6903
6904 v2 = (double)(uDiffuse >> 24) * a2;
6905 v3 = v2 + 6.7553994e15;
6906 v4 = LODWORD(v3);
6907 v5 = (double)((uDiffuse >> 16) & 0xFF) * a2;
6908 v6 = v5 + 6.7553994e15;
6909 v7 = LODWORD(v6);
6910 *((float *)&v6 + 1) = (double)((unsigned __int16)uDiffuse >> 8) * a2;
6911 v8 = *((float *)&v6 + 1) + 6.7553994e15;
6912 v13 = __PAIR__(LODWORD(v6), LODWORD(v8));
6913 v9 = LODWORD(v8);
6914 *((float *)&v6 + 1) = (double)(unsigned __int8)uDiffuse * a2;
6915 v12 = *((float *)&v6 + 1) + 6.7553994e15;
6916 v10 = LODWORD(v12);
6917 if ( v4 > 255 )
6918 v4 = 255;
6919 if ( v4 < 0 )
6920 v4 = 0;
6921 if ( SHIDWORD(v13) > 255 )
6922 v7 = 255;
6923 if ( v7 < 0 )
6924 v7 = 0;
6925 if ( (signed int)v13 > 255 )
6926 v9 = 255;
6927 if ( v9 < 0 )
6928 v9 = 0;
6929 if ( SLODWORD(v12) > 255 )
6930 v10 = 255;
6931 if ( v10 < 0 )
6932 v10 = 0;
6933 return v10 | ((v9 | ((v7 | (v4 << 8)) << 8)) << 8);
6934 }
6935
6936
6937
6938
6939
6940 //----- (004AC1C9) --------------------------------------------------------
6941 int __thiscall sub_4AC1C9(unsigned int _this, Vec4_int_ *a2)
6942 {
6943 unsigned int v2; // esi@1
6944 __int16 v3; // di@1
6945 signed int v4; // ebx@1
6946 int v5; // ecx@3
6947 Vec4_int_ *v6; // eax@10
6948 Vec4_int_ *v7; // esi@14
6949 int result; // eax@16
6950 char *v9; // esi@16
6951 Vec4_int_ a1; // [sp+Ch] [bp-34h]@10
6952 Vec4_int_ v11; // [sp+1Ch] [bp-24h]@14
6953 Vec4_int_ Dst; // [sp+2Ch] [bp-14h]@1
6954 int v13; // [sp+3Ch] [bp-4h]@1
6955
6956 v2 = _this;
6957 v3 = sub_4382BC(_this);
6958 v13 = sub_4383ED();
6959 v4 = 0;
6960 memset(&Dst, 0, 0x10u);
6961 if ( v3 < 0 )
6962 goto LABEL_19;
6963 if ( (signed int)v2 > 0 )
6964 {
6965 if ( (signed int)v2 > 150 )
6966 {
6967 v5 = (int)a2;
6968 }
6969 else
6970 {
6971 v5 = 4000 * v2;
6972 v4 = 1;
6973 }
6974 }
6975 else
6976 {
6977 v5 = 4000 * dword_4F031C[(unsigned __int16)v3];
6978 }
6979 if ( v13 & 0x10 && !v4 )
6980 {
6981 if ( v2 )
6982 v6 = sub_4AC4FD_get_cpu_clocks_rdtsc(v5, &a1);
6983 else
6984 v6 = sub_4AC33A_get_cpu_clocks_QPC(v5, &a1);
6985 goto LABEL_14;
6986 }
6987 if ( (unsigned __int16)v3 < 3u )
6988 {
6989 LABEL_19:
6990 v7 = &Dst;
6991 goto LABEL_16;
6992 }
6993 v6 = sub_4AC277(v5, &a1);
6994 LABEL_14:
6995 v11.x = v6->x;
6996 v11.y = v6->y;
6997 v11.z = v6->z;
6998 v11.w = v6->w;
6999 v7 = &v11;
7000 LABEL_16:
7001 result = (int)a2;
7002 a2->x = v7->x;
7003 v9 = (char *)&v7->y;
7004 a2->y = *(int *)v9;
7005 v9 += 4;
7006 a2->z = *(int *)v9;
7007 a2->w = *((int *)v9 + 1);
7008 return result;
7009 }
7010 // 4F031C: using guessed type int dword_4F031C[];
7011
7012 //----- (004AC277) --------------------------------------------------------
7013 Vec4_int_ *__thiscall sub_4AC277(unsigned int _this, Vec4_int_ *a2)
7014 {
7015 __debugbreak();
7016 return 0;
7017 /*signed int v2; // esi@1
7018 signed __int16 v4; // bx@3
7019 int v10; // esi@8
7020 int v11; // eax@10
7021 Vec4_int_ *result; // eax@13
7022 Vec4_int_ Dst; // [sp+8h] [bp-30h]@1
7023 LARGE_INTEGER Frequency; // [sp+18h] [bp-20h]@1
7024 LARGE_INTEGER PerformanceCount; // [sp+20h] [bp-18h]@3
7025 LARGE_INTEGER v16; // [sp+28h] [bp-10h]@5
7026 int v17; // [sp+30h] [bp-8h]@1
7027 int v18; // [sp+34h] [bp-4h]@2
7028
7029 v17 = _this;
7030 v2 = -1;
7031 memset(&Dst, 0, 0x10u);
7032 if ( QueryPerformanceFrequency(&Frequency) )
7033 {
7034 v18 = 10;
7035 do
7036 {
7037 QueryPerformanceCounter(&PerformanceCount);
7038 _EAX = -2147483648;
7039 v4 = 4000;
7040 do
7041 {
7042 __asm { bsf ecx, eax }
7043 --v4;
7044 }
7045 while ( v4 );
7046 QueryPerformanceCounter(&v16);
7047 if ( (signed int)v16.s.LowPart - (signed int)PerformanceCount.s.LowPart < (unsigned int)v2 )
7048 v2 = v16.s.LowPart - PerformanceCount.s.LowPart;
7049 --v18;
7050 }
7051 while ( v18 );
7052 v10 = 100000 * v2 / (Frequency.s.LowPart / 0xA);
7053 if ( v10 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
7054 ++v10;
7055 v11 = v17 / (unsigned int)v10;
7056 Dst.z = v17 / (unsigned int)v10;
7057 if ( v17 % (unsigned int)v10 > (unsigned int)v10 >> 1 )
7058 ++v11;
7059 Dst.x = v17;
7060 Dst.y = v10;
7061 Dst.w = v11;
7062 }
7063 result = a2;
7064 a2->x = Dst.x;
7065 a2->y = Dst.y;
7066 a2->z = Dst.z;
7067 a2->w = Dst.w;
7068 return result;*/
7069 }
7070
7071 //----- (004AC33A) --------------------------------------------------------
7072 Vec4_int_ *__thiscall sub_4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1)
7073 {
7074 __debugbreak();
7075 return 0;
7076 /*int v2; // esi@1
7077 int v3; // ebx@1
7078 unsigned __int64 v4; // qax@4
7079 unsigned __int64 v5; // qax@7
7080 DWORD v6; // edi@7
7081 DWORD v7; // eax@7
7082 unsigned int v8; // ecx@10
7083 unsigned __int64 v9; // qax@10
7084 unsigned int v10; // edi@10
7085 int v11; // eax@14
7086 unsigned int v12; // ecx@19
7087 Vec4_int_ *result; // eax@24
7088 int Dst; // [sp+Ch] [bp-4Ch]@1
7089 int v15; // [sp+10h] [bp-48h]@23
7090 int v16; // [sp+14h] [bp-44h]@21
7091 int v17; // [sp+18h] [bp-40h]@21
7092 LARGE_INTEGER Frequency; // [sp+1Ch] [bp-3Ch]@1
7093 LARGE_INTEGER PerformanceCount; // [sp+24h] [bp-34h]@2
7094 LARGE_INTEGER v20; // [sp+2Ch] [bp-2Ch]@2
7095 int v21; // [sp+34h] [bp-24h]@2
7096 int v22; // [sp+38h] [bp-20h]@2
7097 int v23; // [sp+3Ch] [bp-1Ch]@4
7098 int v24; // [sp+40h] [bp-18h]@7
7099 int nPriority; // [sp+44h] [bp-14h]@2
7100 unsigned int v26; // [sp+48h] [bp-10h]@1
7101 unsigned int v27; // [sp+4Ch] [bp-Ch]@1
7102 HANDLE hThread; // [sp+50h] [bp-8h]@1
7103 int v29; // [sp+54h] [bp-4h]@1
7104
7105 v2 = 0;
7106 v3 = 0;
7107 v29 = 0;
7108 v27 = 0;
7109 v26 = 0;
7110 hThread = GetCurrentThread();
7111 memset(&Dst, 0, 0x10u);
7112 if ( QueryPerformanceFrequency(&Frequency) )
7113 {
7114 do
7115 {
7116 ++v29;
7117 v22 = v2;
7118 v21 = v3;
7119 QueryPerformanceCounter(&PerformanceCount);
7120 v20 = PerformanceCount;
7121 nPriority = GetThreadPriority(hThread);
7122 if ( nPriority != 2147483647 )
7123 SetThreadPriority(hThread, 15);
7124 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x32 )
7125 {
7126 QueryPerformanceCounter(&v20);
7127 v4 = __rdtsc();
7128 v23 = v4;
7129 }
7130 PerformanceCount = v20;
7131 do
7132 {
7133 QueryPerformanceCounter(&v20);
7134 v5 = __rdtsc();
7135 v24 = v5;
7136 v6 = v20.s.LowPart;
7137 v7 = PerformanceCount.s.LowPart;
7138 }
7139 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x3E8 );
7140 if ( nPriority != 2147483647 )
7141 {
7142 SetThreadPriority(hThread, nPriority);
7143 v7 = PerformanceCount.s.LowPart;
7144 v6 = v20.s.LowPart;
7145 }
7146 v8 = v24 - v23;
7147 v27 += v24 - v23;
7148 v9 = (100000 * v6 - 100000 * v7) / (Frequency.s.LowPart / 0xA);
7149 v10 = v9;
7150 v26 += v9;
7151 if ( v9 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
7152 v10 = v9 + 1;
7153 v3 = v8 / v10;
7154 if ( v8 % v10 > v10 >> 1 )
7155 v3 = v8 / v10 + 1;
7156 v2 = v21;
7157 v11 = v3 + v22 + v21;
7158 }
7159 while ( v29 < 3
7160 || v29 < 20
7161 && ((unsigned int)(3 * v3 - v11) > 3 || (unsigned int)(3 * v21 - v11) > 3 || (unsigned int)(3 * v22 - v11) > 3) );
7162 v12 = 10 * v27 / v26;
7163 if ( 100 * v27 / v26 - 10 * v12 >= 6 )
7164 ++v12;
7165 v16 = v27 / v26;
7166 v17 = v27 / v26;
7167 if ( v12 - 10 * v27 / v26 >= 6 )
7168 v17 = v27 / v26 + 1;
7169 v15 = v26;
7170 Dst = v27;
7171 }
7172 result = a1;
7173 a1->x = Dst;
7174 a1->y = v15;
7175 a1->z = v16;
7176 a1->w = v17;
7177 return result;*/
7178 }
7179
7180 //----- (004AC4FD) --------------------------------------------------------
7181 Vec4_int_ *__thiscall sub_4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1)
7182 {
7183 __debugbreak();
7184 return 0;
7185 /*int v2; // eax@1
7186 int v3; // eax@4
7187 bool v4; // eax@5
7188 unsigned __int64 v5; // kr00_8@8
7189 int v6; // edi@9
7190 int v7; // eax@9
7191 bool v8; // eax@10
7192 unsigned __int64 v9; // kr08_8@13
7193 unsigned int v10; // eax@15
7194 Vec4_int_ *result; // eax@17
7195 int Dst; // [sp+Ch] [bp-2Ch]@1
7196 int v13; // [sp+10h] [bp-28h]@17
7197 int v14; // [sp+14h] [bp-24h]@15
7198 int v15; // [sp+18h] [bp-20h]@17
7199 unsigned int v16; // [sp+1Ch] [bp-1Ch]@8
7200 unsigned int v17; // [sp+20h] [bp-18h]@8
7201 unsigned int v18; // [sp+24h] [bp-14h]@13
7202 int nPriority; // [sp+28h] [bp-10h]@1
7203 __int64 v20; // [sp+2Ch] [bp-Ch]@1
7204 int v21; // [sp+34h] [bp-4h]@3
7205
7206 HIDWORD(v20) = GetCurrentThread();
7207 memset(&Dst, 0, 0x10u);
7208 v2 = GetThreadPriority(HIDWORD(v20));
7209 nPriority = v2;
7210 if ( v2 != 0x7FFFFFFF )
7211 SetThreadPriority(HIDWORD(v20), v2 + 1);
7212 __outbyte(0x70u, 0);
7213 v21 = __inbyte(0x71u);
7214 do
7215 {
7216 __outbyte(0x70u, 0);
7217 LODWORD(v20) = __inbyte(0x71u);
7218 v3 = v20 - v21;
7219 if ( (signed int)v20 >= v21 )
7220 v4 = v3 > 0;
7221 else
7222 v4 = v3 + 10;
7223 }
7224 while ( !v4 );
7225 v5 = __rdtsc();
7226 v16 = HIDWORD(v5);
7227 v17 = v5;
7228 do
7229 {
7230 __outbyte(0x70u, 0);
7231 v21 = __inbyte(0x71u);
7232 v6 = v21;
7233 v7 = v21 - v20;
7234 if ( v21 >= (signed int)v20 )
7235 v8 = v7 > 0;
7236 else
7237 v8 = v7 + 10;
7238 }
7239 while ( !v8 );
7240 v9 = __rdtsc();
7241 v18 = HIDWORD(v9);
7242 v21 = v9;
7243 if ( nPriority != 0x7FFFFFFF )
7244 SetThreadPriority(HIDWORD(v20), nPriority);
7245 nPriority = v21;
7246 *(__int64 *)((char *)&v20 + 4) = __PAIR__(v18, v21) - __PAIR__(v16, v17);
7247 Dst = HIDWORD(v20);
7248 v10 = HIDWORD(v20) / 0xF4240;
7249 v14 = HIDWORD(v20) / 0xF4240;
7250 if ( HIDWORD(v20) / 0x186A0 - 10 * HIDWORD(v20) / 0xF4240 >= 6 )
7251 ++v10;
7252 v15 = v10;
7253 result = a1;
7254 v13 = 1000000 * v6 - 1000000 * v20;
7255 a1->x = Dst;
7256 a1->y = v13;
7257 a1->z = v14;
7258 a1->w = v15;
7259 return result;*/
7260 }
7261
7262
7263
7264 //----- (004AD504) --------------------------------------------------------
7265 int __fastcall sub_4AD504(unsigned int uFaceID)
7266 {
7267 int result; // eax@1
7268 unsigned int v2; // ebx@1
7269 BLVFace *v3; // esi@3
7270 Texture *v4; // edi@6
7271 int v5; // eax@7
7272 int v6; // edx@7
7273 int v7; // ecx@7
7274 int v8; // ebx@8
7275 int v9; // eax@8
7276 int v10; // ebx@8
7277 unsigned int v11; // ebx@9
7278 int v12; // esi@10
7279 int v13; // eax@13
7280 unsigned __int16 *v14; // eax@13
7281 unsigned int v15; // eax@14
7282 unsigned __int16 *v16; // ebx@14
7283 int v17; // eax@15
7284 int v18; // ebx@15
7285 int v19; // esi@15
7286 int v20; // ecx@15
7287 int v21; // eax@15
7288 stru193_math *v22; // ebx@15
7289 int v23; // eax@15
7290 char *v24; // esi@16
7291 int v25; // eax@18
7292 int v26; // eax@18
7293 int v27; // eax@20
7294 signed int v28; // esi@20
7295 signed int v29; // edx@20
7296 signed int v30; // esi@20
7297 signed int v31; // edi@20
7298 int v32; // esi@20
7299 int v33; // eax@26
7300 int *v34; // esi@27
7301 unsigned __int16 *v35; // edi@27
7302 unsigned int v36; // edx@27
7303 int v37; // ebx@27
7304 char v38; // cl@27
7305 char v39; // ch@27
7306 int v40; // ebx@29
7307 int v41; // edx@29
7308 unsigned int v42; // ebx@30
7309 int v43; // edx@30
7310 int v44; // eax@33
7311 int *v45; // esi@34
7312 unsigned __int16 *v46; // edi@34
7313 unsigned int v47; // edx@34
7314 int v48; // ebx@34
7315 char v49; // cl@34
7316 char v50; // ch@34
7317 int v51; // ebx@36
7318 int v52; // edx@36
7319 unsigned __int16 v53; // bx@37
7320 int v54; // edx@37
7321 int v55; // eax@40
7322 int v56; // eax@41
7323 int *v57; // esi@42
7324 unsigned __int16 *v58; // edi@42
7325 unsigned int v59; // edx@42
7326 int v60; // ebx@42
7327 char v61; // cl@42
7328 char v62; // ch@42
7329 unsigned int v63; // ebx@44
7330 int v64; // edx@44
7331 unsigned int v65; // ebx@44
7332 int v66; // edx@44
7333 unsigned int v67; // ebx@45
7334 int v68; // edx@45
7335 int v69; // ebx@45
7336 int v70; // edx@45
7337 int v71; // eax@48
7338 int *v72; // esi@49
7339 unsigned __int16 *v73; // edi@49
7340 unsigned int v74; // edx@49
7341 int v75; // ebx@49
7342 char v76; // cl@49
7343 char v77; // ch@49
7344 unsigned int v78; // ebx@51
7345 int v79; // edx@51
7346 unsigned int v80; // ebx@51
7347 int v81; // edx@51
7348 unsigned int v82; // ebx@52
7349 int v83; // edx@52
7350 int v84; // ebx@52
7351 int v85; // edx@52
7352 unsigned __int8 *v86; // [sp+Ch] [bp-98h]@9
7353 unsigned __int8 *v87; // [sp+10h] [bp-94h]@9
7354 unsigned __int8 *v88; // [sp+14h] [bp-90h]@9
7355 unsigned __int8 *v89; // [sp+18h] [bp-8Ch]@9
7356 int v90; // [sp+1Ch] [bp-88h]@20
7357 BLVFace *v91; // [sp+20h] [bp-84h]@3
7358 int v92; // [sp+24h] [bp-80h]@7
7359 int i; // [sp+28h] [bp-7Ch]@7
7360 unsigned __int16 *v94; // [sp+2Ch] [bp-78h]@9
7361 unsigned int v95; // [sp+30h] [bp-74h]@1
7362 Texture *v96; // [sp+34h] [bp-70h]@6
7363 int v97; // [sp+38h] [bp-6Ch]@15
7364 unsigned int v98; // [sp+3Ch] [bp-68h]@9
7365 int v99; // [sp+40h] [bp-64h]@9
7366 int v100; // [sp+44h] [bp-60h]@24
7367 int v101; // [sp+48h] [bp-5Ch]@10
7368 int v102; // [sp+4Ch] [bp-58h]@20
7369 int v103; // [sp+50h] [bp-54h]@20
7370 int v104; // [sp+54h] [bp-50h]@9
7371 unsigned __int8 *v105; // [sp+58h] [bp-4Ch]@20
7372 int v106; // [sp+5Ch] [bp-48h]@24
7373 int v107; // [sp+60h] [bp-44h]@20
7374 int v108; // [sp+64h] [bp-40h]@20
7375 int v109; // [sp+68h] [bp-3Ch]@20
7376 int v110; // [sp+6Ch] [bp-38h]@15
7377 int v111; // [sp+70h] [bp-34h]@20
7378 int a1; // [sp+74h] [bp-30h]@12
7379 int a2; // [sp+78h] [bp-2Ch]@9
7380 int *v114; // [sp+7Ch] [bp-28h]@16
7381 int v115; // [sp+80h] [bp-24h]@18
7382 int v116; // [sp+84h] [bp-20h]@7
7383 unsigned int v117; // [sp+88h] [bp-1Ch]@15
7384 unsigned int v118; // [sp+8Ch] [bp-18h]@24
7385 int *v119; // [sp+90h] [bp-14h]@13
7386 int v120; // [sp+94h] [bp-10h]@15
7387 unsigned int v121; // [sp+98h] [bp-Ch]@15
7388 unsigned __int16 *v122; // [sp+9Ch] [bp-8h]@15
7389 unsigned int v123; // [sp+A0h] [bp-4h]@13
7390
7391 result = pRenderer->uTargetSurfacePitch;
7392 v2 = uFaceID;
7393 v95 = pRenderer->uTargetSurfacePitch;
7394 if ( (uFaceID & 0x80000000u) == 0 )
7395 {
7396 if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces )
7397 {
7398 v3 = &pIndoor->pFaces[uFaceID];
7399 v91 = &pIndoor->pFaces[uFaceID];
7400 if ( !pRenderer->pRenderD3D )
7401 {
7402 result = sub_423B5D(uFaceID);
7403 if ( result )
7404 {
7405 result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
7406 if ( result )
7407 {
7408 result = (int)v3->GetTexture();
7409 v4 = (Texture *)result;
7410 v96 = (Texture *)result;
7411 if ( result )
7412 {
7413 v5 = *(short *)(result + 38);
7414 LOBYTE(v3->uAttributes) |= 0x80u;
7415 v92 = v5;
7416 sub_4AE5F1(v2);
7417 ++pBLVRenderParams->field_84;
7418 v6 = stru_F8AD28.pDeltaUV[0];
7419 v116 = stru_F8AD28.pDeltaUV[1];
7420 v7 = 0;
7421 for ( i = bUseLoResSprites; v7 < stru_F8AD28.uNumLightsApplied; *(int *)v9 = v10 )
7422 {
7423 v8 = v116;
7424 stru_F8AD28._blv_lights_xs[v7] += v6;
7425 v9 = 4 * v7 + 16297672;
7426 v10 = v8 - stru_F8AD28._blv_lights_ys[v7++];
7427 }
7428 v94 = sr_sub_47C24C_get_palette(v3, v92, 0, 1);
7429 result = stru_F8A590._viewport_space_y;
7430 a2 = stru_F8A590._viewport_space_y;
7431 v11 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch;
7432 v99 = 640 * stru_F8A590._viewport_space_y;
7433 v86 = v4->pLevelOfDetail0;
7434 v87 = v4->pLevelOfDetail1;
7435 v88 = v4->pLevelOfDetail2;
7436 v89 = v4->pLevelOfDetail3;
7437 v98 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch;
7438 v104 = 2 * pBLVRenderParams->field_0_timer_;
7439 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
7440 {
7441 v12 = 2 * stru_F8A590._viewport_space_y;
7442 v101 = 2 * stru_F8A590._viewport_space_y;
7443 while ( 1 )
7444 {
7445 a1 = *(__int16 *)((char *)stru_F8A590.array_18 + v12);
7446 sub_4AE313(a1, result, &stru_F81018.field_0);
7447 if ( LOBYTE(viewparams->field_20) )
7448 {
7449 v15 = v95 * (v12 - pBLVRenderParams->uViewportY);
7450 v119 = &pBLVRenderParams->pTargetZBuffer[2
7451 * (*(__int16 *)((char *)stru_F8A590.array_18 + v12)
7452 + 320 * (v12 - pBLVRenderParams->uViewportY))
7453 - pBLVRenderParams->uViewportX];
7454 v16 = &pBLVRenderParams->pRenderTarget[v15
7455 + 2 * *(__int16 *)((char *)stru_F8A590.array_18 + v12)
7456 - pBLVRenderParams->uViewportX];
7457 v14 = &pBLVRenderParams->pRenderTarget[v15
7458 + 2 * *(__int16 *)((char *)stru_F8A590.array_3D8 + v12)
7459 - pBLVRenderParams->uViewportX];
7460 v123 = (unsigned int)v16;
7461 }
7462 else
7463 {
7464 v13 = *(__int16 *)((char *)stru_F8A590.array_18 + v12);
7465 v119 = &pBLVRenderParams->pTargetZBuffer[v13 + v99];
7466 v123 = (unsigned int)&pBLVRenderParams->pRenderTarget[v13 + v11];
7467 v14 = &pBLVRenderParams->pRenderTarget[v11 + *(__int16 *)((char *)stru_F8A590.array_3D8 + v12)];
7468 }
7469 v117 = (unsigned int)v14;
7470 HIWORD(v17) = HIWORD(stru_F81018.field_0.field_0);
7471 v18 = stru_F81018.field_0.field_10;
7472 LOWORD(v17) = 0;
7473 v97 = stru_F8AD28.field_0 | v17;
7474 v110 = sub_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8));
7475 v19 = stru_F81018.field_0.field_4 >> i;
7476 v20 = 11 - v18;
7477 v116 = stru_F81018.field_0.field_8 >> i;
7478 v21 = stru_F81018.field_0.field_8 >> i >> (11 - v18);
7479 v22 = stru_5C6E00;
7480 v122 = (unsigned __int16 *)v20;
7481 v121 = (stru_F81018.field_0.field_4 >> i) + 4 * stru_5C6E00->SinCos(v104 + v21);
7482 v23 = stru_5C6E00->SinCos(v104 + (v19 >> (char)v122) - stru_5C6E00->uIntegerHalfPi);
7483 v120 = v116 + 4 * v23;
7484 if ( v123 < v117 )
7485 {
7486 v24 = (char *)&stru_F81018.field_34.field_8;
7487 v114 = &stru_F81018.field_34.field_8;
7488 a1 += 16;
7489 while ( 1 )
7490 {
7491 sub_4AE313(a1, a2, (stru337_stru0 *)(v24 - 8));
7492 v25 = *((int *)v24 - 2);
7493 LOWORD(v25) = 0;
7494 v115 = v97;
7495 v26 = stru_F8AD28.field_0 | v25;
7496 if ( v97 <= (unsigned int)v26 )
7497 v115 = v26;
7498 v97 = v26;
7499 v27 = *((int *)v24 - 11);
7500 v28 = *((int *)v24 - 1);
7501 v105 = (&v86)[4 * v27];
7502 v111 = v27 + 16;
7503 v29 = v4->uWidthMinus1;
7504 v109 = v27 + v27 + 16 - v4->uWidthLn2;
7505 v107 = v29 >> v27;
7506 v30 = v28 >> i;
7507 v102 = v4->uHeightMinus1 >> v27 << (v27 + 16);
7508 v31 = *v114 >> i;
7509 v122 = (unsigned __int16 *)(11 - v27);
7510 v116 = v30 + 4 * stru_5C6E00->SinCos(v104 + (v31 >> (11 - v27)));
7511 v90 = v31 + 4 * stru_5C6E00->SinCos(v104 + (v30 >> (char)v122) - stru_5C6E00->uIntegerHalfPi);
7512 v108 = (signed int)(v116 - v121) >> 4;
7513 v103 = (v90 - v120) >> 4;
7514 v32 = v123 + 32;
7515 if ( LOBYTE(viewparams->field_20) )
7516 v32 = v123 + 64;
7517 if ( v32 > v117 )
7518 v32 = v117;
7519 v118 = v32;
7520 v100 = sub_4AE491(*((short *)v114 - 1), *((short *)v114 + 1));
7521 v106 = (signed int)(v32 - v123) >> 1;
7522 if ( v110 >> 16 == v100 >> 16 )
7523 {
7524 v122 = sr_sub_47C24C_get_palette(v91, v92, v110 >> 16, 1);
7525 if ( LOBYTE(viewparams->field_20) )
7526 {
7527 v44 = v123;
7528 if ( v123 < v118 )
7529 {
7530 v45 = v119;
7531 v46 = v122;
7532 v47 = v121;
7533 v48 = v120;
7534 v49 = v111;
7535 v50 = v109;
7536 if ( v106 & 2 )
7537 {
7538 *v119 = v115;
7539 v45 -= 2;
7540 v44 = v123 + 4;
7541 goto LABEL_37;
7542 }
7543 do
7544 {
7545 v44 += 8;
7546 v51 = *(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50));
7547 v52 = v115;
7548 LOWORD(v51) = v46[v51];
7549 *v45 = v115;
7550 v45[1] = v52;
7551 v45[640] = v52;
7552 v45[641] = v52;
7553 *(short *)(v44 - 8) = v51;
7554 *(short *)(v44 - 6) = v51;
7555 *(short *)(v44 + 1272) = v51;
7556 *(short *)(v44 + 1274) = v51;
7557 v45[2] = v52;
7558 v45[3] = v52;
7559 v45[642] = v52;
7560 v45[643] = v52;
7561 v121 += v108;
7562 v120 += v103;
7563 v47 = v121;
7564 v48 = v120;
7565 LABEL_37:
7566 v45 += 4;
7567 v53 = v46[*(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50))];
7568 v54 = v108;
7569 *(short *)(v44 - 4) = v53;
7570 *(short *)(v44 - 2) = v53;
7571 *(short *)(v44 + 1276) = v53;
7572 *(short *)(v44 + 1278) = v53;
7573 v121 += v54;
7574 v120 += v103;
7575 v47 = v121;
7576 v48 = v120;
7577 }
7578 while ( v44 < v118 );
7579 v123 = v44;
7580 v119 = v45;
7581 }
7582 }
7583 else
7584 {
7585 v33 = v123;
7586 if ( v123 < v118 )
7587 {
7588 v34 = v119;
7589 v35 = v122;
7590 v36 = v121;
7591 v37 = v120;
7592 v38 = v111;
7593 v39 = v109;
7594 if ( v106 & 1 )
7595 {
7596 *v119 = v115;
7597 --v34;
7598 v33 = v123 + 2;
7599 goto LABEL_30;
7600 }
7601 do
7602 {
7603 v33 += 4;
7604 v40 = *(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39));
7605 v41 = v115;
7606 LOWORD(v40) = v35[v40];
7607 *v34 = v115;
7608 *(short *)(v33 - 4) = v40;
7609 v34[1] = v41;
7610 v121 += v108;
7611 v120 += v103;
7612 v36 = v121;
7613 v37 = v120;
7614 LABEL_30:
7615 v42 = (unsigned int)(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39));
7616 v34 += 2;
7617 v43 = v108;
7618 *(short *)(v33 - 2) = v35[*(char *)v42];
7619 v121 += v43;
7620 v120 += v103;
7621 v36 = v121;
7622 v37 = v120;
7623 }
7624 while ( v33 < v118 );
7625 v123 = v33;
7626 v119 = v34;
7627 }
7628 }
7629 }
7630 else
7631 {
7632 v55 = v110 - ((v100 - v110) >> 4);
7633 v110 = (v100 - v110) >> 4;
7634 v122 = (unsigned __int16 *)v55;
7635 if ( LOBYTE(viewparams->field_20) )
7636 {
7637 v71 = v123;
7638 if ( v123 < v118 )
7639 {
7640 v72 = v119;
7641 v73 = v94;
7642 v74 = v121;
7643 v75 = v120;
7644 v76 = v111;
7645 v77 = v109;
7646 if ( v106 & 2 )
7647 {
7648 *v119 = v115;
7649 v72 += 2;
7650 v71 = v123 + 4;
7651 goto LABEL_52;
7652 }
7653 do
7654 {
7655 v78 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77);
7656 v79 = (int)((char *)v122 + v110);
7657 v71 += 8;
7658 v122 = (unsigned __int16 *)v79;
7659 v80 = ((v79 & 0xFFFF0000u) >> 8) + v105[v78];
7660 v81 = v115;
7661 LOWORD(v80) = v73[v80];
7662 *v72 = v115;
7663 v72[1] = v81;
7664 v72[640] = v81;
7665 v72[641] = v81;
7666 *(short *)(v71 - 8) = v80;
7667 *(short *)(v71 - 6) = v80;
7668 *(short *)(v71 + 1272) = v80;
7669 *(short *)(v71 + 1274) = v80;
7670 v72[2] = v81;
7671 v72[3] = v81;
7672 v72[642] = v81;
7673 v72[643] = v81;
7674 v121 += v108;
7675 v120 += v103;
7676 v74 = v121;
7677 v75 = v120;
7678 v72 += 4;
7679 LABEL_52:
7680 v82 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77);
7681 v83 = (int)((char *)v122 + v110);
7682 v84 = v105[v82];
7683 v122 = (unsigned __int16 *)v83;
7684 LOWORD(v84) = v73[((v83 & 0xFFFF0000u) >> 8) + v84];
7685 v85 = v108;
7686 *(short *)(v71 - 4) = v84;
7687 *(short *)(v71 - 2) = v84;
7688 *(short *)(v71 + 1276) = v84;
7689 *(short *)(v71 + 1278) = v84;
7690 v121 += v85;
7691 v120 += v103;
7692 v74 = v121;
7693 v75 = v120;
7694 }
7695 while ( v71 < v118 );
7696 v123 = v71;
7697 v119 = v72;
7698 }
7699 }
7700 else
7701 {
7702 v56 = v123;
7703 if ( v123 < v118 )
7704 {
7705 v57 = v119;
7706 v58 = v94;
7707 v59 = v121;
7708 v60 = v120;
7709 v61 = v111;
7710 v62 = v109;
7711 if ( v106 & 1 )
7712 {
7713 *v119 = v115;
7714 ++v57;
7715 v56 = v123 + 2;
7716 goto LABEL_45;
7717 }
7718 do
7719 {
7720 v63 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62);
7721 v64 = (int)((char *)v122 + v110);
7722 v56 += 4;
7723 v122 = (unsigned __int16 *)v64;
7724 v65 = ((v64 & 0xFFFF0000u) >> 8) + v105[v63];
7725 v66 = v115;
7726 LOWORD(v65) = v58[v65];
7727 *v57 = v115;
7728 *(short *)(v56 - 4) = v65;
7729 v57[1] = v66;
7730 v121 += v108;
7731 v120 += v103;
7732 v59 = v121;
7733 v60 = v120;
7734 v57 += 2;
7735 LABEL_45:
7736 v67 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62);
7737 v68 = (int)((char *)v122 + v110);
7738 v69 = v105[v67];
7739 v122 = (unsigned __int16 *)v68;
7740 LOWORD(v69) = v58[((v68 & 0xFFFF0000u) >> 8) + v69];
7741 v70 = v108;
7742 *(short *)(v56 - 2) = v69;
7743 v121 += v70;
7744 v120 += v103;
7745 v59 = v121;
7746 v60 = v120;
7747 }
7748 while ( v56 < v118 );
7749 v123 = v56;
7750 v119 = v57;
7751 }
7752 }
7753 }
7754 v114 += 13;
7755 v110 = v100;
7756 a1 += 16;
7757 v4 = v96;
7758 v121 = v116;
7759 v120 = v90;
7760 if ( v123 >= v117 )
7761 break;
7762 v24 = (char *)v114;
7763 v22 = stru_5C6E00;
7764 }
7765 }
7766 ++a2;
7767 v98 += v95;
7768 result = a2;
7769 v101 += 2;
7770 v99 += 640;
7771 if ( a2 > stru_F8A590._viewport_space_w )
7772 break;
7773 v12 = v101;
7774 result = a2;
7775 v11 = v98;
7776 }
7777 }
7778 }
7779 }
7780 }
7781 }
7782 }
7783 }
7784 return result;
7785 }
7786 // 4AE491: using guessed type int __fastcall sub_4AE491(int, int);
7787
7788 //----- (004ADD1D) --------------------------------------------------------
7789 void __fastcall sub_4ADD1D(int uFaceID)
7790 {
7791 int v1; // edi@1
7792 BLVFace *v2; // esi@3
7793 signed int v3; // ebx@4
7794 Texture *v4; // edi@9
7795 signed int v5; // eax@9
7796 char *v6; // edi@12
7797 signed int v7; // eax@15
7798 unsigned int v8; // eax@16
7799 __int16 v9; // cx@19
7800 unsigned __int8 *v10; // eax@19
7801 unsigned __int16 *v11; // eax@19
7802 int v12; // edi@19
7803 int v13; // ebx@20
7804 stru352 *v14; // esi@20
7805 DWORD v15; // eax@22
7806 signed int v16; // ecx@22
7807 signed int v17; // ST68_4@22
7808 int v18; // eax@22
7809 int v19; // ecx@22
7810 unsigned int v20; // esi@23
7811 int v21; // edi@23
7812 int v22; // eax@23
7813 int *v23; // ebx@24
7814 int v24; // edx@24
7815 int v25; // ebx@25
7816 unsigned __int16 v26; // cx@25
7817 int v27; // edx@26
7818 unsigned __int16 v28; // cx@26
7819 unsigned __int8 v29; // sf@27
7820 unsigned __int8 v30; // of@27
7821 unsigned int v31; // esi@29
7822 int v32; // edi@29
7823 unsigned __int16 *v33; // eax@29
7824 int *v34; // ebx@30
7825 int v35; // edx@30
7826 int v36; // ebx@31
7827 unsigned __int16 v37; // cx@31
7828 int v38; // edx@32
7829 unsigned __int16 v39; // cx@32
7830 Texture *v40; // [sp-10h] [bp-6Ch]@16
7831 int v41; // [sp-Ch] [bp-68h]@15
7832 unsigned int v42; // [sp+10h] [bp-4Ch]@1
7833 signed int v43; // [sp+14h] [bp-48h]@12
7834 signed int v44; // [sp+14h] [bp-48h]@22
7835 int v45; // [sp+1Ch] [bp-40h]@22
7836 int v46; // [sp+20h] [bp-3Ch]@22
7837 int v47; // [sp+24h] [bp-38h]@19
7838 char v48; // [sp+28h] [bp-34h]@19
7839 int v49; // [sp+2Ch] [bp-30h]@19
7840 unsigned __int8 *v50; // [sp+30h] [bp-2Ch]@19
7841 unsigned __int16 *v51; // [sp+34h] [bp-28h]@19
7842 int v52; // [sp+38h] [bp-24h]@22
7843 int v53; // [sp+3Ch] [bp-20h]@22
7844 signed int v54; // [sp+40h] [bp-1Ch]@12
7845 int v55; // [sp+40h] [bp-1Ch]@20
7846 int v56; // [sp+44h] [bp-18h]@20
7847 stru352 *i; // [sp+48h] [bp-14h]@20
7848 unsigned __int16 *v58; // [sp+4Ch] [bp-10h]@23
7849 int v59; // [sp+50h] [bp-Ch]@4
7850 int v60; // [sp+50h] [bp-Ch]@19
7851 int v61; // [sp+54h] [bp-8h]@22
7852 int *v62; // [sp+58h] [bp-4h]@23
7853 int *v63; // [sp+58h] [bp-4h]@29
7854
7855 v1 = uFaceID;
7856 v42 = pRenderer->uTargetSurfacePitch;
7857 if ( uFaceID >= 0 && uFaceID < (signed int)pIndoor->uNumFaces )
7858 {
7859 v2 = &pIndoor->pFaces[uFaceID];
7860 if ( pRenderer->pRenderD3D )
7861 {
7862 v3 = sub_424579(uFaceID, &stru_F8AD28);
7863 v59 = v3;
7864 }
7865 else
7866 {
7867 v59 = sub_423B5D(uFaceID);
7868 v3 = v59;
7869 }
7870 if ( v3 && (pRenderer->pRenderD3D || sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1)) )
7871 {
7872 v4 = v2->GetTexture();
7873 v5 = 0;
7874 if ( v4 )
7875 {
7876 if ( pRenderer->pRenderD3D )
7877 {
7878 if ( v3 > 0 )
7879 {
7880 v54 = v3;
7881 v43 = v3;
7882 v6 = (char *)&array_507D30[0].v;
7883 do
7884 {
7885 *((float *)v6 - 1) = (double)((GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x) + *((float *)v6 - 1);
7886 *(float *)v6 = (double)(pBLVRenderParams->vPartyPos.y + (GetTickCount() >> 5)) + *(float *)v6;
7887 v6 += 48;
7888 --v54;
7889 }
7890 while ( v54 );
7891 v3 = v59;
7892 v5 = v43;
7893 }
7894 v7 = v5;
7895 v41 = stru_F8AD28.field_0;
7896 array_507D30[v7].u = array_507D30[v7].u * 0.25;
7897 array_507D30[v7].v = array_507D30[v7].v * 0.25;
7898 if ( BYTE1(v2->uAttributes) & 0x40 )
7899 {
7900 v40 = v2->GetTexture();
7901 v8 = pTextureFrameTable->GetFrameTexture(v2->uBitmapID, pBLVRenderParams->field_0_timer_);
7902 }
7903 else
7904 {
7905 v40 = v2->GetTexture();
7906 v8 = v2->uBitmapID;
7907 }
7908 pRenderer->DrawIndoorPolygon(v3, v2, pBitmaps_LOD->pHardwareTextures[v8], v40, v41, -1, 0);
7909 }
7910 else
7911 {
7912 v49 = v4->uWidthMinus1;
7913 v47 = v4->uHeightMinus1 << 16;
7914 v9 = 16 - v4->uWidthLn2;
7915 v10 = v4->pLevelOfDetail0;
7916 LOBYTE(v2->uAttributes) |= 0x80u;
7917 v48 = v9;
7918 v50 = v10;
7919 sub_4AF412();
7920 ++pBLVRenderParams->uNumFacesRenderedThisFrame;
7921 v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1);
7922 v12 = stru_F8A590._viewport_space_y;
7923 v51 = v11;
7924 v60 = stru_F8A590._viewport_space_y;
7925 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
7926 {
7927 v13 = 2 * stru_F8A590._viewport_space_y;
7928 v14 = &stru_F83B80[stru_F8A590._viewport_space_y];
7929 v55 = 2 * stru_F8A590._viewport_space_y;
7930 v56 = 640 * stru_F8A590._viewport_space_y;
7931 for ( i = &stru_F83B80[stru_F8A590._viewport_space_y]; ; v14 = i )
7932 {
7933 sub_4AE1E7(v12, *(__int16 *)((char *)stru_F8A590.array_18 + v13), v12);
7934 v14->field_0 += (GetTickCount() << 11) - (pBLVRenderParams->vPartyPos.x << 16);
7935 v15 = GetTickCount();
7936 v16 = v14->field_0;
7937 v14->field_4 += (32 * pBLVRenderParams->vPartyPos.y + v15) << 11;
7938 v45 = v14->field_4 >> 3;
7939 v44 = v16 >> 3;
7940 v17 = (signed int)((unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)v14->field_28) >> 16) >> 3;
7941 v52 = (unsigned __int64)(v17 * (signed __int64)-pBLVRenderParams->sSineY) >> 16;
7942 v53 = (unsigned __int64)(v17 * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
7943 v18 = v14->field_28;
7944 v19 = *(__int16 *)((char *)stru_F8A590.array_18 + v13);
7945 LOWORD(v18) = 0;
7946 v46 = stru_F8AD28.field_0 | v18;
7947 v61 = *(__int16 *)((char *)stru_F8A590.array_3D8 + v13) - v19;
7948 if ( LOBYTE(viewparams->field_20) )
7949 {
7950 v63 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY))
7951 - pBLVRenderParams->uViewportX];
7952 v31 = v44;
7953 v32 = v45;
7954 v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY)
7955 + 2 * v19
7956 - pBLVRenderParams->uViewportX];
7957 if ( v61 & 1 )
7958 {
7959 --v61;
7960 v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY)
7961 + 2 * v19
7962 - pBLVRenderParams->uViewportX
7963 - 2];
7964 v34 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY))
7965 - pBLVRenderParams->uViewportX];
7966 v35 = v46;
7967 v63 += 2;
7968 goto LABEL_32;
7969 }
7970 while ( 1 )
7971 {
7972 v30 = __OFSUB__(v61, 2);
7973 v29 = v61 - 2 < 0;
7974 v61 -= 2;
7975 if ( v29 ^ v30 )
7976 break;
7977 v36 = *(&v50[v49 & (v31 >> 16)] + ((v47 & (unsigned int)v32) >> v48));
7978 v31 += v52;
7979 v37 = v51[v36];
7980 v32 += v53;
7981 v34 = v63;
7982 v35 = v46;
7983 *v33 = v37;
7984 v33[1] = v37;
7985 v33[640] = v37;
7986 v33[641] = v37;
7987 v63 += 4;
7988 v34[2] = v46;
7989 v34[3] = v46;
7990 v34[642] = v46;
7991 v34[643] = v46;
7992 LABEL_32:
7993 *v34 = v35;
7994 v34[1] = v35;
7995 v34[640] = v35;
7996 v34[641] = v35;
7997 v38 = v49 & (v31 >> 16);
7998 v33 += 4;
7999 v31 += v52;
8000 v39 = v51[*(&v50[v38] + ((v47 & (unsigned int)v32) >> v48))];
8001 v32 += v53;
8002 *(v33 - 2) = v39;
8003 *(v33 - 1) = v39;
8004 v33[638] = v39;
8005 v33[639] = v39;
8006 }
8007 }
8008 else
8009 {
8010 v58 = &pBLVRenderParams->pRenderTarget[v19 + v12 * pRenderer->uTargetSurfacePitch];
8011 v62 = &pBLVRenderParams->pTargetZBuffer[v56 + v19];
8012 v20 = v44;
8013 v21 = v45;
8014 v22 = (int)v58;
8015 if ( v61 & 1 )
8016 {
8017 --v61;
8018 v22 = (int)(v58 - 1);
8019 v23 = &pBLVRenderParams->pTargetZBuffer[v56 + v19];
8020 v24 = v46;
8021 ++v62;
8022 goto LABEL_26;
8023 }
8024 while ( 1 )
8025 {
8026 v30 = __OFSUB__(v61, 2);
8027 v29 = v61 - 2 < 0;
8028 v61 -= 2;
8029 if ( v29 ^ v30 )
8030 break;
8031 v25 = *(&v50[v49 & (v20 >> 16)] + ((v47 & (unsigned int)v21) >> v48));
8032 v20 += v52;
8033 v26 = v51[v25];
8034 v21 += v53;
8035 v23 = v62;
8036 v24 = v46;
8037 *(short *)v22 = v26;
8038 v62 += 2;
8039 v23[1] = v46;
8040 LABEL_26:
8041 *v23 = v24;
8042 v27 = v49 & (v20 >> 16);
8043 v22 += 4;
8044 v20 += v52;
8045 v28 = v51[*(&v50[v27] + ((v47 & (unsigned int)v21) >> v48))];
8046 v21 += v53;
8047 *(short *)(v22 - 2) = v28;
8048 }
8049 }
8050 ++v60;
8051 ++i;
8052 v56 += 640;
8053 v55 += 2;
8054 if ( v60 > stru_F8A590._viewport_space_w )
8055 break;
8056 v13 = v55;
8057 v12 = v60;
8058 }
8059 }
8060 }
8061 }
8062 }
8063 }
8064 }
8065
8066 //----- (004AE1E7) --------------------------------------------------------
8067 int __fastcall sub_4AE1E7(int a1, int a2, int a3)
8068 {
8069 int v3; // ebx@1
8070 int v4; // edi@1
8071 int v5; // esi@1
8072 signed __int64 v6; // qtt@3
8073 int v7; // esi@3
8074 int v8; // eax@5
8075 int result; // eax@5
8076 int v10; // edx@5
8077 int v11; // [sp+Ch] [bp-8h]@1
8078 int v12; // [sp+1Ch] [bp+8h]@2
8079
8080 v3 = pBLVRenderParams->uViewportCenterY - a3;
8081 v4 = pBLVRenderParams->uViewportCenterX - a2;
8082 v11 = a1;
8083 v5 = (pBLVRenderParams->uViewportCenterY - a3) * stru_F8AD28.vec_80.y
8084 + stru_F8AD28.field_7C
8085 + (pBLVRenderParams->uViewportCenterX - a2) * stru_F8AD28.vec_80.x;
8086 if ( v5 && (v12 = abs(stru_F8AD28.vec_80.z) >> 14, v12 <= abs(v5)) )
8087 {
8088 LODWORD(v6) = stru_F8AD28.vec_80.z << 16;
8089 HIDWORD(v6) = stru_F8AD28.vec_80.z >> 16;
8090 v7 = v6 / (v3 * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C + v4 * stru_F8AD28.vec_80.x);
8091 }
8092 else
8093 {
8094 v7 = 1073741824;
8095 }
8096 v8 = stru_F8AD28.vec_9C.z;
8097 stru_F83B80[v11].field_0 = ((unsigned __int64)((v3 * stru_F8AD28.vec_8C.z
8098 + stru_F8AD28.vec_8C.x
8099 + v4 * stru_F8AD28.vec_8C.y)
8100 * (signed __int64)v7) >> 16)
8101 + stru_F8AD28.field_98;
8102 result = (unsigned __int64)((v3 * v8 + stru_F8AD28.vec_9C.x + v4 * stru_F8AD28.vec_9C.y) * (signed __int64)v7) >> 16;
8103 v10 = result + stru_F8AD28.field_A8;
8104 stru_F83B80[v11].field_28 = v7;
8105 stru_F83B80[v11].field_4 = v10;
8106 return result;
8107 }
8108
8109 //----- (004AE313) --------------------------------------------------------
8110 int __fastcall sub_4AE313(int viewport_space_x, int viewport_space_y, stru337_stru0 *p)
8111 {
8112 int _dy; // ebx@1
8113 int _dx; // edi@1
8114 int v5; // ecx@1
8115 int v6; // esi@1
8116 int v7; // ST18_4@2
8117 signed __int64 v8; // qtt@3
8118 unsigned int v9; // ecx@3
8119 int result; // eax@8
8120 int v11; // [sp+Ch] [bp-8h]@1
8121
8122 _dy = pBLVRenderParams->uViewportCenterY - viewport_space_y;
8123 _dx = pBLVRenderParams->uViewportCenterX - viewport_space_x;
8124 ++pBLVRenderParams->field_88;
8125 v5 = (pBLVRenderParams->uViewportCenterY - viewport_space_y) * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C;
8126 v6 = v5 + _dx * stru_F8AD28.vec_80.x;
8127 v11 = v5 + _dx * stru_F8AD28.vec_80.x;
8128 if ( v5 + _dx * stru_F8AD28.vec_80.x && (v7 = abs(stru_F8AD28.vec_80.z) >> 14, v7 <= abs(v6)) )
8129 {
8130 LODWORD(v8) = stru_F8AD28.vec_80.z << 16;
8131 HIDWORD(v8) = stru_F8AD28.vec_80.z >> 16;
8132 v9 = v8 / v11;
8133 }
8134 else
8135 {
8136 v9 = 0x40000000u;
8137 }
8138 if ( (signed int)v9 >= stru_F8AD28.field_34 )
8139 p->field_0 = v9;
8140 else
8141 p->field_0 = stru_F8AD28.field_34;
8142 p->field_4 = ((unsigned __int64)((_dy * stru_F8AD28.vec_8C.z + stru_F8AD28.vec_8C.x + _dx * stru_F8AD28.vec_8C.y)
8143 * (signed __int64)(signed int)v9) >> 16)
8144 + stru_F8AD28.field_98
8145 + (stru_F8AD28.pDeltaUV[0] << 16);
8146 p->field_8 = ((unsigned __int64)((_dy * stru_F8AD28.vec_9C.z + stru_F8AD28.vec_9C.x + _dx * stru_F8AD28.vec_9C.y)
8147 * (signed __int64)(signed int)v9) >> 16)
8148 + stru_F8AD28.field_A8
8149 + (stru_F8AD28.pDeltaUV[1] << 16);
8150 result = abs((__int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)(signed int)v9) >> 16);
8151 if ( result < 369620 || bUseLoResSprites )
8152 {
8153 if ( result < 184810 )
8154 p->field_10 = result > 92405;
8155 else
8156 p->field_10 = 2;
8157 }
8158 else
8159 {
8160 p->field_10 = 3;
8161 }
8162 return result;
8163 }
8164
8165 //----- (004AE491) --------------------------------------------------------
8166 int __fastcall sub_4AE491(signed int a1, signed int a2)
8167 {
8168 signed int v2; // eax@1
8169 signed int v3; // edi@1
8170 int v4; // ecx@1
8171 int v5; // esi@2
8172 int v6; // eax@2
8173 int v7; // ebx@2
8174 unsigned int v8; // ecx@2
8175 int v9; // edx@5
8176 int v10; // edx@7
8177 unsigned int v11; // eax@8
8178 int v13; // [sp+4h] [bp-18h]@2
8179 int v14; // [sp+8h] [bp-14h]@2
8180 signed int v15; // [sp+Ch] [bp-10h]@1
8181 int v16; // [sp+14h] [bp-8h]@1
8182 int v17; // [sp+18h] [bp-4h]@1
8183
8184 v2 = a1 >> SLOBYTE(stru_F8AD28.field_38);
8185 v3 = a2 >> SLOBYTE(stru_F8AD28.field_38);
8186 v17 = stru_F8AD28.uCurrentAmbientLightLevel;
8187 v4 = 0;
8188 v15 = v2;
8189 v16 = 0;
8190 if ( stru_F8AD28.uNumLightsApplied > 0 )
8191 {
8192 do
8193 {
8194 v5 = v16;
8195 v13 = abs(v2 - stru_F8AD28._blv_lights_xs[v16]);
8196 v14 = abs(v3 - stru_F8AD28._blv_lights_ys[v16]);
8197 v6 = stru_F8AD28._blv_lights_light_dot_faces[v16];
8198 v7 = v13;
8199 v8 = v14;
8200 if ( v6 < v13 )
8201 {
8202 v6 = v13;
8203 v7 = stru_F8AD28._blv_lights_light_dot_faces[v16];
8204 }
8205 if ( v6 < v14 )
8206 {
8207 v9 = v6;
8208 v6 = v14;
8209 v8 = v9;
8210 }
8211 if ( v7 < (signed int)v8 )
8212 {
8213 v10 = v8;
8214 v8 = v7;
8215 v7 = v10;
8216 }
8217 v11 = ((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6;
8218 if ( (signed int)v11 < stru_F8AD28._blv_lights_radii[v5] )
8219 v17 += 30 * (v11 * stru_F8AD28._blv_lights_inv_radii[v5] - 65536);
8220 ++v16;
8221 v2 = v15;
8222 }
8223 while ( v16 < stru_F8AD28.uNumLightsApplied );
8224 v4 = 0;
8225 }
8226 if ( stru_F8AD28.field_3E4 != v4 )
8227 v17 -= stru_F8AD28.field_3E8 * (v2 - stru_F8AD28.field_3F0) + stru_F8AD28.field_3EC * (v3 - stru_F8AD28.field_3F4);
8228 if ( v17 >= v4 )
8229 {
8230 if ( v17 > 2031616 )
8231 v17 = 2031616;
8232 }
8233 else
8234 {
8235 v17 = v4;
8236 }
8237 ++pBLVRenderParams->field_8C;
8238 return v17;
8239 }
8240 // 4AE491: using guessed type int __fastcall sub_4AE491(int, int);
8241
8242
8243
8244
8245 //----- (004AE5F1) --------------------------------------------------------
8246 void __fastcall sub_4AE5F1(unsigned int uFaceID)
8247 {
8248 BLVFace *v1; // esi@1
8249 BLVFaceExtra *v2; // ebx@1
8250 int v3; // eax@1
8251 int v4; // edi@1
8252 Texture *v5; // edi@1
8253 int v6; // eax@1
8254 unsigned int v7; // eax@1
8255 unsigned int v8; // ecx@1
8256 unsigned int v9; // eax@1
8257 unsigned int v10; // ecx@5
8258 int v11; // edi@10
8259 int v12; // ecx@10
8260 int v13; // eax@10
8261 int v14; // edx@10
8262 int v15; // ebx@12
8263 double v16; // st7@16
8264 int v17; // eax@16
8265 char *v18; // ebx@17
8266 int v19; // ecx@19
8267 int v20; // eax@19
8268 int v21; // edx@21
8269 int v22; // eax@23
8270 int v23; // ST04_4@26
8271 int v24; // edi@26
8272 double v25; // st6@26
8273 int v26; // eax@26
8274 double v27; // st6@26
8275 int v28; // ecx@26
8276 char v29; // al@26
8277 int v30; // edx@28
8278 int v31; // ecx@28
8279 BLVLightMM7 *v32; // ecx@32
8280 int v33; // edi@33
8281 int v34; // edx@33
8282 int v35; // eax@33
8283 int v36; // edi@35
8284 int v37; // edx@37
8285 int v38; // ebx@39
8286 int v39; // edi@42
8287 int v40; // eax@42
8288 char *v41; // ebx@45
8289 signed int v42; // ecx@47
8290 int v43; // edi@47
8291 int v44; // eax@49
8292 int v45; // edx@51
8293 int v46; // eax@53
8294 int v47; // ST04_4@55
8295 int v48; // edi@55
8296 double v49; // st6@55
8297 int v50; // eax@55
8298 double v51; // st6@55
8299 int v52; // eax@55
8300 int v53; // ecx@57
8301 int v54; // ecx@58
8302 int v55; // ecx@59
8303 int v56; // edx@62
8304 int v57; // ecx@62
8305 int v58; // eax@63
8306 int v59; // edx@64
8307 int v60; // ecx@67
8308 int v61; // edx@67
8309 int v62; // eax@68
8310 int v63; // edx@69
8311 signed int v64; // ecx@72
8312 double v65; // st7@75
8313 Vec3_int_ v66; // [sp+Ch] [bp-34h]@9
8314 Vec3_int_ v67; // [sp+18h] [bp-28h]@9
8315 BLVFaceExtra *v68; // [sp+24h] [bp-1Ch]@1
8316 int v69; // [sp+28h] [bp-18h]@10
8317 int v70; // [sp+2Ch] [bp-14h]@10
8318 int X; // [sp+30h] [bp-10h]@10
8319 int v72; // [sp+34h] [bp-Ch]@10
8320 int v73; // [sp+38h] [bp-8h]@10
8321 int v74; // [sp+3Ch] [bp-4h]@10
8322
8323 v1 = &pIndoor->pFaces[uFaceID];
8324 v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID];
8325 v3 = v1->uBitmapID;
8326 v4 = v1->uBitmapID;
8327 v68 = v2;
8328 v5 = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0);
8329 v6 = 8 * uFaceID;
8330 LOBYTE(v6) = 8 * uFaceID | 6;
8331 stru_F8AD28.field_0 = v6;
8332 stru_F8AD28.plane_4.vNormal.x = v1->pFacePlane_old.vNormal.x;
8333 stru_F8AD28.plane_4.vNormal.y = v1->pFacePlane_old.vNormal.y;
8334 stru_F8AD28.plane_4.vNormal.z = v1->pFacePlane_old.vNormal.z;
8335 stru_F8AD28.plane_4.dist = v1->pFacePlane_old.dist;
8336 stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU;
8337 stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV;
8338 v7 = GetTickCount();
8339 v8 = v1->uAttributes;
8340 v9 = v7 >> 3;
8341 if ( v8 & 4 )
8342 {
8343 stru_F8AD28.pDeltaUV[1] -= v9 & v5->uHeightMinus1;
8344 }
8345 else
8346 {
8347 if ( v8 & 0x20 )
8348 stru_F8AD28.pDeltaUV[1] += v9 & v5->uHeightMinus1;
8349 }
8350 v10 = v1->uAttributes;
8351 if ( BYTE1(v10) & 8 )
8352 {
8353 stru_F8AD28.pDeltaUV[0] -= v9 & v5->uWidthMinus1;
8354 }
8355 else
8356 {
8357 if ( v10 & 0x40 )
8358 stru_F8AD28.pDeltaUV[0] += v9 & v5->uWidthMinus1;
8359 }
8360 v1->_get_normals(&v67, &v66);
8361 stru_F8AD28.vec_14.x = v67.x;
8362 stru_F8AD28.vec_14.y = v67.y;
8363 stru_F8AD28.vec_14.z = v67.z;
8364 stru_F8AD28.vec_20.x = v66.x;
8365 stru_F8AD28.vec_20.y = v66.y;
8366 stru_F8AD28.vec_20.z = v66.z;
8367 stru_F8AD28.uDefaultAmbientLightLevel = v2->field_22;
8368 if ( pBLVRenderParams->sPartyRotX )
8369 {
8370 v74 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8371 v74 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v74;
8372 X = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
8373 stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - X;
8374 stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8375 * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8376 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y
8377 * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8378 stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8379 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z
8380 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8381 v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8382 v74 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70;
8383 v70 = (unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
8384 stru_F8AD28.vec_60.y = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70;
8385 stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8386 + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8387 stru_F8AD28.field_6C = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8388 + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8389 v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8390 v74 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70;
8391 X = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8392 v72 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
8393 v70 = (unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
8394 stru_F8AD28.vec_70.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70;
8395 stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8396 + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8397 stru_F8AD28.vec_70.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8398 + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8399 v74 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y
8400 - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x;
8401 v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y
8402 + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x);
8403 v73 = -65536 * pBLVRenderParams->vPartyPos.z;
8404 v70 = (unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
8405 v12 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70;
8406 v69 = (unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
8407 v13 = pBLVRenderParams->vPartyPos.y;
8408 v70 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8409 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8410 v14 = pBLVRenderParams->vPartyPos.x;
8411 }
8412 else
8413 {
8414 v70 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8415 stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8416 * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8417 - v70;
8418 stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z;
8419 stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8420 * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8421 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y
8422 * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8423 v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8424 stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8425 - v70;
8426 stru_F8AD28.field_6C = stru_F8AD28.vec_14.z;
8427 stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8428 + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8429 v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8430 stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8431 - v70;
8432 v69 = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16;
8433 v14 = pBLVRenderParams->vPartyPos.x;
8434 stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z;
8435 v13 = pBLVRenderParams->vPartyPos.y;
8436 stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8437 + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8438 v12 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y
8439 - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x;
8440 v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y
8441 + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x);
8442 v70 = -65536 * pBLVRenderParams->vPartyPos.z;
8443 }
8444 stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x;
8445 stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.z * pBLVRenderParams->vPartyPos.z
8446 + stru_F8AD28.plane_4.dist
8447 + stru_F8AD28.plane_4.vNormal.y * v13
8448 + stru_F8AD28.plane_4.vNormal.x * v14;
8449 stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44)
8450 * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16;
8451 stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44)
8452 * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16;
8453 stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x;
8454 stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y;
8455 stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16;
8456 stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16;
8457 X = (unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v12) >> 16;
8458 v15 = v70;
8459 v70 = (unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v70) >> 16;
8460 stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x;
8461 stru_F8AD28.field_98 = -(X + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v11) >> 16) + v70);
8462 stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16;
8463 stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16;
8464 X = (unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v12) >> 16;
8465 v69 = (unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16;
8466 v70 = (unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16;
8467 stru_F8AD28.field_38 = 0;
8468 stru_F8AD28.field_A8 = -(X
8469 + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16)
8470 + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16));
8471 if ( *(int *)&v68->field_4 || *(int *)&v68->field_8 )
8472 {
8473 stru_F8AD28.field_3E4 = 1;
8474 stru_F8AD28.field_3E8 = *(int *)&v68->field_4;
8475 stru_F8AD28.field_3EC = *(int *)&v68->field_8;
8476 stru_F8AD28.field_3F0 = v68->field_1E;
8477 stru_F8AD28.field_3F4 = v68->field_20;
8478 }
8479 else
8480 {
8481 stru_F8AD28.field_3E4 = 0;
8482 }
8483 v16 = 0.0039215689;
8484 v17 = 116 * v1->uSectorID;
8485 v69 = v17;
8486 v74 = 0;
8487 v73 = 0;
8488 stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16;
8489 v70 = pMobileLightsStack->uNumLightsActive;
8490 if ( pMobileLightsStack->uNumLightsActive > 0 )
8491 {
8492 v18 = (char *)&pMobileLightsStack->pLights[0].vPosition.y;
8493 do
8494 {
8495 if ( v74 >= 20 )
8496 break;
8497 v19 = *((short *)v18 + 2);
8498 v20 = *((short *)v18 - 1);
8499 if ( v20 > v1->pBounding.x1 - v19 )
8500 {
8501 if ( v20 < v19 + v1->pBounding.x2 )
8502 {
8503 v21 = *(short *)v18;
8504 if ( v21 > v1->pBounding.y1 - v19 )
8505 {
8506 if ( v21 < v19 + v1->pBounding.y2 )
8507 {
8508 v22 = *((short *)v18 + 1);
8509 if ( v22 > v1->pBounding.z1 - v19 )
8510 {
8511 if ( v22 < v19 + v1->pBounding.z2 )
8512 {
8513 X = (v1->pFacePlane_old.dist
8514 + *((short *)v18 + 1) * v1->pFacePlane_old.vNormal.z
8515 + v21 * v1->pFacePlane_old.vNormal.y
8516 + *((short *)v18 - 1) * v1->pFacePlane_old.vNormal.x) >> 16;
8517 if ( X <= v19 )
8518 {
8519 v23 = X;
8520 v24 = v74;
8521 stru_F8AD28._blv_lights_radii[v74] = v19;
8522 stru_F8AD28._blv_lights_inv_radii[v24] = 65536 / v19;
8523 *(int *)((char *)&stru_F8AD28.field_240 + v24 * 4) = *((short *)v18 + 5) << 16;
8524 stru_F8AD28._blv_lights_xs[v24] = *((short *)v18 - 1);
8525 stru_F8AD28._blv_lights_ys[v24] = *(short *)v18;
8526 stru_F8AD28._blv_lights_zs[v24] = *((short *)v18 + 1);
8527 v68 = (BLVFaceExtra *)(unsigned __int8)v18[6];
8528 v25 = (double)(signed int)v68 * v16;
8529 v68 = (BLVFaceExtra *)(unsigned __int8)v18[7];
8530 v26 = (unsigned __int8)v18[8];
8531 *(float *)(v24 * 4 + 16297992) = v25;
8532 v27 = (double)(signed int)v68;
8533 v68 = (BLVFaceExtra *)v26;
8534 *(float *)(v24 * 4 + 16298072) = v27 * v16;
8535 *(float *)(v24 * 4 + 16298152) = (double)(signed int)v68 * v16;
8536 v16 = 0.0039215689;
8537 stru_F8AD28._blv_lights_light_dot_faces[v24] = abs(v23);
8538 v28 = v74;
8539 v29 = v18[9];
8540 ++v74;
8541 stru_F8AD28._blv_lights_types[v28] = v29;
8542 }
8543 }
8544 }
8545 }
8546 }
8547 }
8548 }
8549 ++v73;
8550 v18 += 18;
8551 v17 = v69;
8552 }
8553 while ( v73 < v70 );
8554 }
8555 v30 = 0;
8556 v73 = 0;
8557 v31 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17);
8558 v70 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17);
8559 if ( v31 > 0 )
8560 {
8561 while ( v74 < 20 )
8562 {
8563 v32 = &pIndoor->pLights[*(&(*(BLVLightMM7 **)((char *)&pIndoor->pSectors->pLights + v17))->vPosition.x + v30)];
8564 if ( !(v32->uAtributes & 8) )
8565 {
8566 v33 = v1->pBounding.x1;
8567 v34 = v32->vPosition.x;
8568 X = v32->uBrightness;
8569 v35 = v32->uRadius;
8570 v68 = (BLVFaceExtra *)v32->uRadius;
8571 if ( v34 > v33 - v35 )
8572 {
8573 if ( v34 < v35 + v1->pBounding.x2 )
8574 {
8575 v36 = v32->vPosition.y;
8576 if ( v36 > v1->pBounding.y1 - v35 )
8577 {
8578 if ( v36 < v35 + v1->pBounding.y2 )
8579 {
8580 v37 = v32->vPosition.z;
8581 if ( v37 > v1->pBounding.z1 - v35 )
8582 {
8583 if ( v37 < v35 + v1->pBounding.z2 )
8584 {
8585 v38 = (v1->pFacePlane_old.dist
8586 + v32->vPosition.x * v1->pFacePlane_old.vNormal.x
8587 + v37 * v1->pFacePlane_old.vNormal.z
8588 + v36 * v1->pFacePlane_old.vNormal.y) >> 16;
8589 if ( v38 >= 0 )
8590 {
8591 if ( v38 <= v35 && v35 )
8592 {
8593 v39 = v74;
8594 stru_F8AD28._blv_lights_radii[v74] = v35;
8595 stru_F8AD28._blv_lights_inv_radii[v39] = 65536 / (signed int)v68;
8596 *(int *)((char *)&stru_F8AD28.field_240 + v39 * 4) = X << 16;
8597 stru_F8AD28._blv_lights_xs[v39] = v32->vPosition.x;
8598 stru_F8AD28._blv_lights_ys[v39] = v32->vPosition.y;
8599 stru_F8AD28._blv_lights_zs[v39] = v32->vPosition.z;
8600 v68 = (BLVFaceExtra *)v32->uRed;
8601 stru_F8AD28._blv_lights_rs[v39] = (double)(signed int)v68 * v16;
8602 v68 = (BLVFaceExtra *)v32->uGreen;
8603 stru_F8AD28._blv_lights_gs[v39] = (double)(signed int)v68 * v16;
8604 v68 = (BLVFaceExtra *)v32->uBlue;
8605 stru_F8AD28._blv_lights_bs[v39] = (double)(signed int)v68 * v16;
8606 v16 = 0.0039215689;
8607 stru_F8AD28._blv_lights_light_dot_faces[v39] = abs(v38);
8608 v40 = v74++;
8609 stru_F8AD28._blv_lights_types[v40] = 1;
8610 }
8611 }
8612 }
8613 }
8614 }
8615 }
8616 }
8617 }
8618 }
8619 v30 = v73++ + 1;
8620 if ( v73 >= v70 )
8621 break;
8622 v17 = v69;
8623 }
8624 }
8625 v73 = 0;
8626 if ( pStationaryLightsStack->uNumLightsActive > 0 )
8627 {
8628 v41 = (char *)&pStationaryLightsStack->pLights[0].vPosition.y;
8629 do
8630 {
8631 if ( v74 >= 20 )
8632 break;
8633 v42 = *((short *)v41 + 2);
8634 v43 = *((short *)v41 - 1);
8635 if ( v43 > v1->pBounding.x1 - v42 )
8636 {
8637 if ( v43 < v42 + v1->pBounding.x2 )
8638 {
8639 v44 = *(short *)v41;
8640 if ( v44 > v1->pBounding.y1 - v42 )
8641 {
8642 if ( v44 < v42 + v1->pBounding.y2 )
8643 {
8644 v45 = *((short *)v41 + 1);
8645 if ( v45 > v1->pBounding.z1 - v42 )
8646 {
8647 if ( v45 < v42 + v1->pBounding.z2 )
8648 {
8649 v46 = (v1->pFacePlane_old.dist
8650 + *(short *)v41 * v1->pFacePlane_old.vNormal.y
8651 + v43 * v1->pFacePlane_old.vNormal.x
8652 + v45 * v1->pFacePlane_old.vNormal.z) >> 16;
8653 v69 = v46;
8654 if ( v46 >= 0 )
8655 {
8656 if ( v46 <= v42 )
8657 {
8658 v47 = v69;
8659 v48 = v74;
8660 stru_F8AD28._blv_lights_radii[v74] = v42;
8661 stru_F8AD28._blv_lights_inv_radii[v48] = 65536 / v42;
8662 stru_F8AD28._blv_lights_xs[v48] = *((short *)v41 - 1);
8663 stru_F8AD28._blv_lights_ys[v48] = *(short *)v41;
8664 stru_F8AD28._blv_lights_zs[v48] = *((short *)v41 + 1);
8665 v68 = (BLVFaceExtra *)(unsigned __int8)v41[6];
8666 v49 = (double)(signed int)v68 * v16;
8667 v68 = (BLVFaceExtra *)(unsigned __int8)v41[7];
8668 v50 = (unsigned __int8)v41[8];
8669 stru_F8AD28._blv_lights_rs[v48] = v49;
8670 v51 = (double)(signed int)v68;
8671 v68 = (BLVFaceExtra *)v50;
8672 stru_F8AD28._blv_lights_gs[v48] = v51 * v16;
8673 stru_F8AD28._blv_lights_bs[v48] = (double)(signed int)v68 * v16;
8674 v16 = 0.0039215689;
8675 stru_F8AD28._blv_lights_light_dot_faces[v48] = abs(v47);
8676 v52 = v74++;
8677 stru_F8AD28._blv_lights_types[v52] = 1;
8678 }
8679 }
8680 }
8681 }
8682 }
8683 }
8684 }
8685 }
8686 ++v73;
8687 v41 += 12;
8688 }
8689 while ( v73 < pStationaryLightsStack->uNumLightsActive );
8690 }
8691 stru_F8AD28.uNumLightsApplied = v74;
8692 v53 = v1->pBounding.x2;
8693 if ( pBLVRenderParams->vPartyPos.x <= v53 )
8694 {
8695 v55 = v1->pBounding.x1;
8696 if ( pBLVRenderParams->vPartyPos.x >= v55 )
8697 v54 = 0;
8698 else
8699 v54 = v55 - pBLVRenderParams->vPartyPos.x;
8700 }
8701 else
8702 {
8703 v54 = pBLVRenderParams->vPartyPos.x - v53;
8704 }
8705 v56 = v1->pBounding.y2;
8706 v57 = v54 * v54;
8707 if ( pBLVRenderParams->vPartyPos.y <= v56 )
8708 {
8709 v59 = v1->pBounding.y1;
8710 if ( pBLVRenderParams->vPartyPos.y >= v59 )
8711 v58 = 0;
8712 else
8713 v58 = v59 - pBLVRenderParams->vPartyPos.y;
8714 }
8715 else
8716 {
8717 v58 = pBLVRenderParams->vPartyPos.y - v56;
8718 }
8719 v60 = v58 * v58 + v57;
8720 v61 = v1->pBounding.z2;
8721 if ( pBLVRenderParams->vPartyPos.z <= v61 )
8722 {
8723 v63 = v1->pBounding.z1;
8724 if ( pBLVRenderParams->vPartyPos.z >= v63 )
8725 v62 = 0;
8726 else
8727 v62 = v63 - pBLVRenderParams->vPartyPos.z;
8728 }
8729 else
8730 {
8731 v62 = pBLVRenderParams->vPartyPos.z - v61;
8732 }
8733 v64 = v62 * v62 + v60;
8734 if ( v64 )
8735 stru_F8AD28.field_34 = sub_452A9E(v64) << 16;
8736 else
8737 stru_F8AD28.field_34 = 0;
8738 v68 = (BLVFaceExtra *)abs(stru_F8AD28.rotated_normal.y);
8739 v65 = (double)(signed int)v68;
8740 if ( v65 >= 655.36 )
8741 {
8742 if ( v65 >= 26214.4 )
8743 {
8744 if ( v65 >= 45875.2 )
8745 {
8746 stru_F8AD28.field_44 = 8;
8747 stru_F8AD28.field_48 = 3;
8748 }
8749 else
8750 {
8751 stru_F8AD28.field_44 = 16;
8752 stru_F8AD28.field_48 = 4;
8753 }
8754 }
8755 else
8756 {
8757 stru_F8AD28.field_44 = 32;
8758 stru_F8AD28.field_48 = 5;
8759 }
8760 }
8761 else
8762 {
8763 stru_F8AD28.field_44 = 64;
8764 stru_F8AD28.field_48 = 6;
8765 }
8766 }
8767 // 519AB4: using guessed type int uNumStationaryLightsApplied;
8768
8769 //----- (004AF412) --------------------------------------------------------
8770 int __cdecl sub_4AF412()
8771 {
8772 int v0; // ST20_4@2
8773 int v1; // ST20_4@2
8774 int v2; // ST20_4@2
8775 int v3; // esi@2
8776 int v4; // ST20_4@2
8777 int v5; // ecx@2
8778 int v6; // ebx@2
8779 int v7; // edi@2
8780 int v8; // edx@2
8781 int v9; // eax@2
8782 int result; // eax@4
8783
8784 stru_F8AD28.plane_4.vNormal.z = -65536;
8785 stru_F8AD28.vec_20.y = -65536;
8786 stru_F8AD28.plane_4.vNormal.x = 0;
8787 stru_F8AD28.plane_4.vNormal.y = 0;
8788 stru_F8AD28.plane_4.dist = (pBLVRenderParams->vPartyPos.z + 800) << 16;
8789 stru_F8AD28.vec_14.x = 65536;
8790 stru_F8AD28.vec_14.y = 0;
8791 stru_F8AD28.vec_14.z = 0;
8792 stru_F8AD28.vec_20.x = 0;
8793 stru_F8AD28.vec_20.z = 0;
8794 stru_F8AD28.uDefaultAmbientLightLevel = 0;
8795 if ( pBLVRenderParams->sPartyRotX )
8796 {
8797 v0 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8798 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8799 stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
8800 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z
8801 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
8802 stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8803 * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8804 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y
8805 * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8806 stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8807 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z
8808 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8809 v1 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8810 - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8811 stru_F8AD28.vec_60.y = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
8812 - ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
8813 stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8814 + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8815 stru_F8AD28.field_6C = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8816 + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8817 v2 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8818 - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8819 stru_F8AD28.vec_70.x = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
8820 - ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
8821 stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8822 + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8823 stru_F8AD28.vec_70.z = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
8824 + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
8825 v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y
8826 + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x);
8827 v4 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y
8828 - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x;
8829 v5 = ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
8830 - ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
8831 v6 = pBLVRenderParams->vPartyPos.z;
8832 v7 = ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
8833 + ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
8834 v8 = pBLVRenderParams->vPartyPos.y;
8835 v9 = pBLVRenderParams->vPartyPos.x;
8836 }
8837 else
8838 {
8839 stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8840 * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8841 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y
8842 * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8843 stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z;
8844 stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x
8845 * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8846 + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y
8847 * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8848 stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8849 - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8850 stru_F8AD28.field_6C = stru_F8AD28.vec_14.z;
8851 stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8852 + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8853 stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
8854 - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
8855 v8 = pBLVRenderParams->vPartyPos.y;
8856 stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
8857 + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
8858 stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z;
8859 v9 = pBLVRenderParams->vPartyPos.x;
8860 v5 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y
8861 - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x;
8862 v6 = pBLVRenderParams->vPartyPos.z;
8863 v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y
8864 + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x);
8865 v7 = -65536 * pBLVRenderParams->vPartyPos.z;
8866 }
8867 stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x;
8868 stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.y * v8
8869 + stru_F8AD28.plane_4.dist
8870 + stru_F8AD28.plane_4.vNormal.x * v9
8871 + stru_F8AD28.plane_4.vNormal.z * v6;
8872 stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44)
8873 * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16;
8874 stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44)
8875 * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16;
8876 stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x;
8877 stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y;
8878 stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16;
8879 stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16;
8880 stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x;
8881 stru_F8AD28.field_98 = -(((unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v5) >> 16)
8882 + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v3) >> 16)
8883 + ((unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v7) >> 16));
8884 stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16;
8885 stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16;
8886 result = 0;
8887 stru_F8AD28.field_A8 = -(((unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v5) >> 16)
8888 + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v3) >> 16)
8889 + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v7) >> 16));
8890 stru_F8AD28.field_38 = 0;
8891 stru_F8AD28.field_3E4 = 0;
8892 stru_F8AD28.uCurrentAmbientLightLevel = 0;
8893 stru_F8AD28.uNumLightsApplied = 0;
8894 stru_F8AD28.field_34 = 0;
8895 return result;
8896 }
8897
8898
8899
8900
8901
8902
8903 //----- (004B1447) --------------------------------------------------------
8904 Player *__fastcall sub_4B1447_party_fine(int a1, int a2, int a3)
8905 {
8906 signed int v3; // esi@1
8907 char v4; // sf@8
8908 int v5; // eax@8
8909 unsigned __int64 v6; // qax@12
8910 DDM_DLV_Header *v7; // eax@14
8911 Player **v8; // edi@18
8912 Player *result; // eax@19
8913 char *v10; // esi@20
8914
8915 v3 = 0;
8916 if ( a2 )
8917 {
8918 if ( a2 != 1 )
8919 {
8920 if ( a2 == 2 )
8921 v3 = 2;
8922 goto LABEL_13;
8923 }
8924 v3 = 2;
8925 }
8926 else
8927 {
8928 v3 = 1;
8929 }
8930 if ( pParty->uFine < 4000000 )
8931 {
8932 v4 = a3 + pParty->uFine < 0;
8933 v5 = a3 + pParty->uFine;
8934 pParty->uFine += a3;
8935 if ( v4 )
8936 {
8937 v5 = 0;
8938 pParty->uFine = 0;
8939 }
8940 if ( v5 > 4000000 )
8941 pParty->uFine = 4000000;
8942 }
8943 v6 = pParty->uTimePlayed + 368640;
8944 pParty->field_3C._shop_ban_times[2 * a1] = LODWORD(pParty->uTimePlayed) + 368640;
8945 pParty->field_3C._shop_ban_times[2 * a1 + 1] = HIDWORD(v6);
8946 LABEL_13:
8947 *(int *)&pParty->field_16154[4 * a1] = 1;
8948 if ( v3 )
8949 {
8950 v7 = &pOutdoor->ddm;
8951 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
8952 v7 = &pIndoor->dlv;
8953 v7->uReputation += v3;
8954 if ( v7->uReputation > 10000 )
8955 v7->uReputation = 10000;
8956 }
8957 v8 = &pPlayers[1];
8958 do
8959 {
8960 result = *v8;
8961 if ( pParty->uFine )
8962 {
8963 v10 = result->field_152;
8964 result = (Player *)_449B57_test_bit((unsigned __int8 *)result->field_152, 1);
8965 if ( !(short)result )
8966 result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u);
8967 }
8968 ++v8;
8969 }
8970 while ( (signed int)v8 <= (signed int)&pPlayers[4] );
8971 return result;
8972 }
8973
8974 //----- (004B1523) --------------------------------------------------------
8975 char *__thiscall sub_4B1523(int *_this)
8976 {
8977 int v1; // esi@1
8978 int v2; // edx@1
8979 unsigned int v3; // eax@2
8980 int v4; // eax@4
8981 LONG v5; // ecx@4
8982 int v6; // eax@10
8983 char *v7; // ST44_4@12
8984 unsigned __int16 v8; // ax@12
8985 GUIWindow a1; // [sp+Ch] [bp-68h]@4
8986 unsigned int v11; // [sp+60h] [bp-14h]@1
8987 POINT a2; // [sp+64h] [bp-10h]@1
8988 int v13; // [sp+6Ch] [bp-8h]@4
8989 int v14; // [sp+70h] [bp-4h]@4
8990
8991 v1 = *_this - 399;
8992 v2 = (*_this - 400) % 11 + 1;
8993 v11 = 4 * (*_this - 400) / 11;
8994 sprintf(pTmpBuf, "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2);
8995 if ( pMouse->GetCursorPos(&a2)->y <= 320 )
8996 v3 = pMouse->GetCursorPos(&a2)->y + 30;
8997 else
8998 v3 = 30;
8999 a1.Hint = 0;
9000 a1.uFrameY = v3;
9001 a1.uFrameWidth = 328;
9002 a1.uFrameHeight = 68;
9003 a1.uFrameX = 90;
9004 a1.uFrameZ = 417;
9005 a1.uFrameW = v3 + 67;
9006 a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);
9007 v14 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);
9008 v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);
9009 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);
9010 v5 = a2.y;
9011 if ( v14 > a2.y )
9012 v5 = v14;
9013 if ( v13 > v5 )
9014 v5 = v13;
9015 if ( v4 > v5 )
9016 v5 = v4;
9017 sprintf(
9018 pTmpBuf2,
9019 "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s",
9020 pSpellStats->pInfos[v1].pDescription,
9021 pGlobalTXT_LocalizationStrings[431], // "Normal"
9022 v5 + 3,
9023 v5 + 10,
9024 pSpellStats->pInfos[v1].pBasicSkillDesc,
9025 pGlobalTXT_LocalizationStrings[433], // "Expert"
9026 v5 + 3,
9027 v5 + 10,
9028 pSpellStats->pInfos[v1].pExpertSkillDesc,
9029 pGlobalTXT_LocalizationStrings[432], // "Master"
9030 v5 + 3,
9031 v5 + 10,
9032 pSpellStats->pInfos[v1].pMasterSkillDesc,
9033 pGlobalTXT_LocalizationStrings[96], // "Grand"
9034 v5 + 3,
9035 v5 + 10,
9036 pSpellStats->pInfos[v1].pGrandmasterSkillDesc);
9037 v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0);
9038 a1.uFrameHeight += v6;
9039 if ( (signed int)a1.uFrameHeight < 150 )
9040 a1.uFrameHeight = 150;
9041 a1.uFrameWidth = 460;
9042 a1.DrawMessageBox(0);
9043 a1.uFrameWidth -= 12;
9044 a1.uFrameHeight -= 12;
9045 v7 = pSpellStats->pInfos[v1].pName;
9046 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
9047 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
9048 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
9049 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
9050 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
9051 a1.uFrameZ = a1.uFrameX + 107;
9052 a1.uFrameWidth = 108;
9053 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u);
9054 sprintf(pTmpBuf, "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1));
9055 return a1.DrawTitleText(
9056 pFontComic,
9057 0xCu,
9058 a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16,
9059 0,
9060 pTmpBuf,
9061 3u);
9062 }
9063
9064
9065 //----- (004B1784) --------------------------------------------------------
9066 bool __cdecl sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
9067 {
9068 Player *pPlayer; // ebx@1
9069 bool result; // eax@2
9070 unsigned __int16 v2; // ST0C_2@3
9071 int v3; // eax@3
9072 GUIWindow v4; // [sp+4h] [bp-54h]@3
9073
9074 pPlayer = pPlayers[uActiveCharacter];
9075 if ( pPlayer->CanAct() )
9076 {
9077 pDialogueWindow->pNumPresenceButton = dword_F8B1E0;
9078 result = 1;
9079 }
9080 else
9081 {
9082 pDialogueWindow->pNumPresenceButton = 0;
9083 memcpy(&v4, pPrimaryWindow, sizeof(v4));
9084 v4.uFrameX = 483;
9085 v4.uFrameWidth = 148;
9086 v4.uFrameZ = 334;
9087 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);//
9088 // "%s is in no condition to %s"
9089 // "do anything"
9090 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
9091 v3 = pFontArrus->CalcTextHeight(pTmpBuf, &v4, 0, 0);
9092 v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf, 3u);
9093 result = 0;
9094 }
9095 return result;
9096 }
9097 // F8B1E0: using guessed type int dword_F8B1E0;
9098
9099
9100
9101 //----- (004B1A2D) --------------------------------------------------------
9102 void __cdecl sub_4B1A2D()
9103 {
9104 Player *v0; // edi@1
9105 POINT *v1; // esi@5
9106 unsigned int v2; // eax@5
9107 int v3; // ecx@5
9108 POINT *v4; // esi@12
9109 int v5; // eax@12
9110 unsigned int v6; // eax@13
9111 ItemGen *v7; // ecx@13
9112 signed int v8; // esi@17
9113 unsigned int v9; // eax@19
9114 char v10; // [sp+8h] [bp-44h]@12
9115 char v11; // [sp+10h] [bp-3Ch]@12
9116 char v12; // [sp+18h] [bp-34h]@18
9117 char v13; // [sp+20h] [bp-2Ch]@17
9118 char v14; // [sp+28h] [bp-24h]@17
9119 char v15; // [sp+30h] [bp-1Ch]@17
9120 char v16; // [sp+38h] [bp-14h]@5
9121 POINT a2; // [sp+40h] [bp-Ch]@5
9122 int v18; // [sp+48h] [bp-4h]@5
9123
9124 v0 = pPlayers[uActiveCharacter];
9125 if ( dword_F8B198 <= 0 )
9126 return;
9127 if ( dword_F8B198 <= 4 )
9128 {
9129 if ( dword_F8B19C != 2 )
9130 {
9131 if ( dword_F8B19C <= 2 )
9132 return;
9133 if ( dword_F8B19C <= 5 || dword_F8B19C == 94 )
9134 {
9135 v8 = pMouse->GetCursorPos((POINT *)&v15)->x - 14;
9136 v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos((POINT *)&v14)->y - 17) >> 5);
9137 if ( pMouse->GetCursorPos((POINT *)&v13)->x <= 13
9138 || pMouse->GetCursorPos((POINT *)&v12)->x >= 462
9139 || (v9 = v0->GetItemIDAtInventoryIndex(&v18)) == 0 )
9140 return;
9141 v7 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v9 + 5];
9142 LABEL_15:
9143 GameUI_DrawItemInfo(v7);
9144 return;
9145 }
9146 if ( dword_F8B19C != 95 )
9147 return;
9148 }
9149 v4 = pMouse->GetCursorPos((POINT *)&v11);
9150 v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v10)->y]] & 0xFFFF;
9151 v18 = v5;
9152 if ( !v5 )
9153 return;
9154 v6 = 9 * (v5 + 12 * (unsigned int)ptr_507BC0->ptr_1C);
9155 v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
9156 if ( dword_F8B19C != 2 )
9157 v7 = (ItemGen *)&pParty->field_C59C[v6 + 715];
9158 goto LABEL_15;
9159 }
9160 if ( dword_F8B198 <= 16 && dword_F8B19C == 18 )
9161 {
9162 v1 = pMouse->GetCursorPos(&a2);
9163 v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v16)->y];
9164 v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
9165 v18 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
9166 if ( v18 )
9167 sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)ptr_507BC0->ptr_1C));
9168 }
9169 }
9170 // F8B198: using guessed type int dword_F8B198;
9171 // F8B19C: using guessed type int dword_F8B19C;
9172
9173 //----- (004B1BDB) --------------------------------------------------------
9174 void __stdcall RestAndHeal(__int64 uNumMinutes)
9175 {
9176 signed __int64 v1; // ST2C_8@1
9177 signed __int64 v2; // qax@1
9178 signed __int64 v3; // ST1C_8@1
9179 unsigned __int64 v4; // qax@1
9180 unsigned int v5; // ebx@1
9181 void *v6; // ebx@1
9182
9183 pParty->pHirelings[0].bHasUsedTheAbility = 0;
9184 pParty->pHirelings[1].bHasUsedTheAbility = 0;
9185 pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335);
9186 v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
9187 v2 = v1 / 60 / 60;
9188 v3 = v2;
9189 v4 = (unsigned int)v2 / 0x18;
9190 v5 = (unsigned int)(v4 / 7) >> 2;
9191 pParty->uCurrentTimeSecond = v1 % 60;
9192 pParty->uCurrentMinute = v1 / 60 % 60;
9193 pParty->uCurrentHour = v3 % 24;
9194 pParty->uCurrentMonthWeek = v4 / 7 & 3;
9195 pParty->uDaysPlayed = (unsigned int)v4 % 0x1C;
9196 pParty->uCurrentMonth = v5 % 0xC;
9197 pParty->uCurrentYear = v5 / 0xC + 1168;
9198 pParty->RestAndHeal();
9199 dword_507B94 = 1;
9200 v6 = &pParty->pPlayers[0].uNumDivineInterventionCastsThisDay;
9201 do
9202 {
9203 *((short *)v6 - 258) = 0;
9204 memset(v6, 0, 4u);
9205 v6 = (char *)v6 + 6972;
9206 }
9207 while ( (signed int)v6 < (signed int)&pParty->field_871C[694] );
9208 pParty->_4909F4();
9209 }
9210 // 507B94: using guessed type int dword_507B94;
9211
9212 //----- (004B1D27) --------------------------------------------------------
9213 void __cdecl sub_4B1D27()
9214 {
9215 int v0; // edx@2
9216 unsigned int v1; // ecx@7
9217 signed int v2; // edi@10
9218 int v3; // esi@10
9219 __int16 v4; // ax@15
9220 signed int v5; // edi@20
9221 int v6; // esi@20
9222 int v7[4]; // [sp+Ch] [bp-10h]@12
9223
9224 if ( dword_F8B198 > 0 )
9225 {
9226 v0 = 3;
9227 if ( dword_F8B198 > 3 )
9228 {
9229 if ( dword_F8B198 == 22 )
9230 {
9231 if ( !dword_F8B1E4 )
9232 return;
9233 }
9234 else
9235 {
9236 if ( dword_F8B198 != 23 )
9237 return;
9238 }
9239 v1 = (unsigned int)ptr_507BC0->ptr_1C;
9240 LABEL_28:
9241 HousePlaySomeSound(v1, v0);
9242 return;
9243 }
9244 v1 = (unsigned int)ptr_507BC0->ptr_1C;
9245 if ( (signed __int64)__PAIR__(pParty->field_3C._shop_ban_times[2 * v1 + 1], pParty->field_3C._shop_ban_times[2 * v1]) <= (signed __int64)pParty->uTimePlayed )
9246 {
9247 if ( pParty->uNumGold <= 0x2710 )
9248 {
9249 if ( !dword_F8B1E4 )
9250 return;
9251 v0 = 4;
9252 goto LABEL_28;
9253 }
9254 HousePlaySomeSound(v1, dword_F8B1E4 + 3);
9255 if ( !dword_F8B1E4 && !qword_A750D8 )
9256 {
9257 v5 = 0;
9258 v6 = 1;
9259 do
9260 {
9261 if ( pPlayers[v6]->CanAct() )
9262 v7[v5++] = v6;
9263 ++v6;
9264 }
9265 while ( v6 <= 4 );
9266 if ( v5 )
9267 {
9268 qword_A750D8 = 256i64;
9269 word_A750E0 = 80;
9270 v4 = LOWORD(v7[rand() % v5]);
9271 goto LABEL_16;
9272 }
9273 }
9274 }
9275 else
9276 {
9277 if ( !qword_A750D8 )
9278 {
9279 v2 = 0;
9280 v3 = 1;
9281 do
9282 {
9283 if ( pPlayers[v3]->CanAct() )
9284 v7[v2++] = v3;
9285 ++v3;
9286 }
9287 while ( v3 <= 4 );
9288 if ( v2 )
9289 {
9290 qword_A750D8 = 256i64;
9291 word_A750E0 = 80;
9292 v4 = LOWORD(v7[rand() % v2]);
9293 LABEL_16:
9294 word_A750E2 = v4;
9295 return;
9296 }
9297 }
9298 }
9299 }
9300 }
9301
9302 //----- (004B1E92) --------------------------------------------------------
9303 void __fastcall HousePlaySomeSound(unsigned int uHouseID, int a2)
9304 {
9305 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
9306 if ( BYTE1(pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_C) )
9307 pAudioPlayer->PlaySound(
9308 //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
9309 (SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_C) + 300)),
9310 806,
9311 0,
9312 -1,
9313 0,
9314 0,
9315 0,
9316 0);
9317 }
9318
9319 //----- (004B1ECE) --------------------------------------------------------
9320 void __cdecl sub_4B1ECE()
9321 {
9322 __int16 *v0; // edi@1
9323 int v1; // ebx@3
9324 Player *v2; // esi@3
9325 int v3; // eax@4
9326 signed int v4; // eax@9
9327 int v5; // ebx@11
9328 char *v6; // esi@13
9329 char *v7; // eax@14
9330 signed int v8; // edi@14
9331 int v9; // [sp+Ch] [bp-Ch]@11
9332 signed int v10; // [sp+10h] [bp-8h]@13
9333 int v11; // [sp+14h] [bp-4h]@1
9334 char *v12; // [sp+14h] [bp-4h]@11
9335
9336 dword_F8B1A8 = 0;
9337 v11 = 0;
9338 uDialogueType = 84;
9339 ptr_F8B1E8 = (char *)pNPCTopics[667].pText;
9340 v0 = _4F0882_evt_VAR_PlayerItemInHands_vals;
9341 while ( 1 )
9342 {
9343 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, *(v0 - 1)) )
9344 {
9345 v1 = 0;
9346 v2 = pParty->pPlayers;
9347 do
9348 {
9349 LOBYTE(v3) = v2->CompareVariable(VAR_PlayerItemInHands, *v0);
9350 if ( v3 )
9351 break;
9352 ++v2;
9353 ++v1;
9354 }
9355 while ( (signed int)v2 < (signed int)pParty->pHirelings );
9356 if ( v1 == 4 )
9357 break;
9358 }
9359 ++v11;
9360 v0 += 2;
9361 if ( (signed int)v0 >= (signed int)((char *)dword_4F08EC + 2) )
9362 goto LABEL_10;
9363 }
9364 ptr_F8B1E8 = (char *)pNPCTopics[666].pText;
9365 v4 = _4F0882_evt_VAR_PlayerItemInHands_vals[2 * v11];
9366 dword_F8B1A8 = _4F0882_evt_VAR_PlayerItemInHands_vals[2 * v11];
9367 pParty->pPlayers[0].AddVariable(VAR_PlayerItemInHands, v4);
9368 LABEL_10:
9369 if ( dword_F8B1A8 == 601 )
9370 {
9371 v5 = 0;
9372 v12 = (char *)&pParty->pPlayers[0].uClass;
9373 v9 = 0;
9374 while ( 1 )
9375 {
9376 if ( *v12 == 35 )
9377 {
9378 v10 = 0;
9379 v6 = &pParty->pPlayers[0].pInventoryItems[0].field_1A;
9380 do
9381 {
9382 v7 = v6;
9383 v8 = 138;
9384 do
9385 {
9386 if ( *(int *)(v7 - 26) == 601 )
9387 {
9388 if ( !*v7 )
9389 v9 = (int)(v7 - 26);
9390 if ( (unsigned __int8)*v7 == v5 )
9391 v10 = 1;
9392 }
9393 v7 += 36;
9394 --v8;
9395 }
9396 while ( v8 );
9397 v6 += 6972;
9398 }
9399 while ( (signed int)v6 < (signed int)((char *)&pParty->field_777C[91] + 2) );
9400 if ( !v10 )
9401 break;
9402 }
9403 v12 += 6972;
9404 ++v5;
9405 if ( (signed int)v12 >= (signed int)((char *)&pParty->pPickedItem.uExpireTime + 5) )
9406 return;
9407 }
9408 if ( v9 )
9409 *(char *)(v9 + 26) = v5;
9410 }
9411 }
9412 // 4F08EC: using guessed type int dword_4F08EC[];
9413 // 722B3C: using guessed type int dword_722B3C;
9414 // 722B44: using guessed type int dword_722B44;
9415 // F8B1A8: using guessed type int dword_F8B1A8;
9416
9417 //----- (004B2001) --------------------------------------------------------
9418 void __fastcall sub_4B2001(signed int a1)
9419 {
9420 signed int v1; // eax@1
9421 NPCData *v2; // ebp@1
9422 int v3; // ecx@8
9423 Player *v4; // esi@20
9424 int v5; // eax@28
9425 int v6; // eax@31
9426 int v7; // eax@34
9427 int v8; // eax@37
9428 int v9; // eax@40
9429 unsigned int v10; // eax@43
9430 unsigned int v11; // eax@48
9431 char *v12; // eax@53
9432 char *v13; // eax@56
9433 char *v14; // eax@57
9434 char *v15; // eax@58
9435 unsigned int v16; // ebp@62
9436 char *v17; // ecx@63
9437 char *v18; // eax@65
9438 const char *v19; // ecx@68
9439 unsigned int v20; // eax@69
9440 unsigned int v21; // ecx@70
9441 char *v22; // [sp-Ch] [bp-18h]@73
9442 int v23; // [sp-8h] [bp-14h]@49
9443 char *v24; // [sp-8h] [bp-14h]@73
9444 int v25; // [sp-4h] [bp-10h]@49
9445
9446 v1 = a1;
9447 uDialogueType = a1 + 1;
9448 v2 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
9449 if ( a1 <= 23 )
9450 {
9451 if ( a1 == 23 )
9452 {
9453 v3 = v2->evte;
9454 }
9455 else
9456 {
9457 if ( a1 == 13 )
9458 {
9459 ptr_F8B1E8 = (char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
9460 ptr_F8B1E8 = sub_495461((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
9461 sub_4B40E6();
9462 byte_F8B1EC = 0;
9463 goto _return;
9464 }
9465 switch ( a1 )
9466 {
9467 case 19:
9468 v3 = v2->bDrawSomeAnim;
9469 break;
9470 case 20:
9471 v3 = v2->evtb;
9472 break;
9473 case 21:
9474 v3 = v2->evtc;
9475 break;
9476 default:
9477 if ( a1 != 22 )
9478 goto _return;
9479 v3 = v2->evtd;
9480 break;
9481 }
9482 }
9483 goto LABEL_84;
9484 }
9485 if ( a1 == 24 )
9486 {
9487 v3 = v2->evtf;
9488 LABEL_84:
9489 if ( v3 < 200 || v3 > 310 )
9490 {
9491 if ( v3 < 400 || v3 > 410 )
9492 {
9493 if ( v3 == 139 )
9494 {
9495 sub_4B1ECE();
9496 }
9497 else
9498 {
9499 if ( v3 == 311 )
9500 {
9501 sub_4BBA85_bounties();
9502 }
9503 else
9504 {
9505 ptr_F8B1E8 = 0;
9506 _5C3420_pDecoration = (LevelDecoration *)1;
9507 EventProcessor(v3, 0, 1);
9508 _5C3420_pDecoration = 0;
9509 }
9510 }
9511 }
9512 else
9513 {
9514 dword_F8B1D8 = v1;
9515 sub_4B3EF0(v3 - 400);
9516 }
9517 }
9518 else
9519 {
9520 sub_4B3FE5(v3);
9521 }
9522 goto _return;
9523 }
9524 if ( a1 != 76 )
9525 {
9526 if ( a1 == 77 )
9527 {
9528 v16 = v2->uProfession;
9529 if ( byte_F8B1EC )
9530 v17 = (char *)*(&pNPCStats->field_13A64 + 5 * v16);
9531 else
9532 v17 = (char *)*(&pNPCStats->field_13A5C + 5 * v16);
9533 ptr_F8B1E8 = v17;
9534 v18 = sub_495461(v17, uActiveCharacter - 1, 0, 0, 0, 0);
9535 byte_F8B1EC ^= 1u;
9536 ptr_F8B1E8 = v18;
9537 }
9538 else
9539 {
9540 if ( a1 == 79 )
9541 {
9542 if ( dword_F8B1A8 )
9543 {
9544 Party::TakeGold(dword_F8B1B4);
9545 if ( uActiveCharacter )
9546 {
9547 v12 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_something_todo_with_awards];
9548 *(short *)v12 &= 0x3Fu;
9549 switch ( dword_F8B1B0 )
9550 {
9551 case 2:
9552 v15 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_something_todo_with_awards];
9553 *v15 |= 0x40u;
9554 break;
9555 case 3:
9556 v14 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_something_todo_with_awards];
9557 *v14 |= 0x80u;
9558 break;
9559 case 4:
9560 v13 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_something_todo_with_awards];
9561 v13[1] |= 1u;
9562 break;
9563 }
9564 pPlayers[uActiveCharacter]->PlaySound(85, 0);
9565 }
9566 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
9567 {
9568 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
9569 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
9570 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
9571 ++pMessageQueue_50CBD0->uNumMessages;
9572 }
9573 }
9574 }
9575 else
9576 {
9577 if ( a1 == 82 && dword_F8B1A8 )
9578 {
9579 Party::TakeGold(dword_F8B1B4);
9580 v4 = pParty->pPlayers;
9581 do
9582 {
9583 v4->SetVariable(VAR_Award, dword_F8B1AC_something_todo_with_awards);
9584 ++v4;
9585 }
9586 while ( (signed int)v4 < (signed int)pParty->pHirelings );
9587 switch ( dword_F8B1D8 )
9588 {
9589 case 19:
9590 v10 = v2->bDrawSomeAnim;
9591 if ( (signed int)v10 >= 400 && (signed int)v10 <= 416 )
9592 v2->bDrawSomeAnim = 0;
9593 break;
9594 case 20:
9595 v9 = v2->evtb;
9596 if ( v9 >= 400 && v9 <= 416 )
9597 v2->evtb = 0;
9598 break;
9599 case 21:
9600 v8 = v2->evtc;
9601 if ( v8 >= 400 && v8 <= 416 )
9602 v2->evtc = 0;
9603 break;
9604 case 22:
9605 v7 = v2->evtd;
9606 if ( v7 >= 400 && v7 <= 416 )
9607 v2->evtd = 0;
9608 break;
9609 case 23:
9610 v6 = v2->evte;
9611 if ( v6 >= 400 && v6 <= 416 )
9612 v2->evte = 0;
9613 break;
9614 case 24:
9615 v5 = v2->evtf;
9616 if ( v5 >= 400 )
9617 {
9618 if ( v5 <= 416 )
9619 v2->evtf = 0;
9620 }
9621 break;
9622 }
9623 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
9624 {
9625 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
9626 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
9627 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
9628 ++pMessageQueue_50CBD0->uNumMessages;
9629 }
9630 v11 = uActiveCharacter;
9631 if ( uActiveCharacter )
9632 {
9633 v25 = 0;
9634 v23 = 86;
9635 LABEL_50:
9636 pPlayers[v11]->PlaySound(v23, v25);
9637 goto _return;
9638 }
9639 }
9640 }
9641 }
9642 goto _return;
9643 }
9644 if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
9645 {
9646 v19 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
9647 LABEL_77:
9648 ShowStatusBarString(v19, 2u);
9649 goto _return;
9650 }
9651 v20 = v2->uProfession;
9652 if ( v20 != 51 )
9653 {
9654 v21 = *(&pNPCStats->field_13A58 + 5 * v20);
9655 if ( pParty->uNumGold < v21 )
9656 {
9657 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
9658 byte_F8B1EC = 0;
9659 uDialogueType = 13;
9660 ptr_F8B1E8 = (char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
9661 ptr_F8B1E8 = sub_495461((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
9662 if ( uActiveCharacter )
9663 pPlayers[uActiveCharacter]->PlaySound(38, 0);
9664 v19 = pGlobalTXT_LocalizationStrings[155];
9665 goto LABEL_77;
9666 }
9667 Party::TakeGold(v21);
9668 }
9669 LOBYTE(v2->uFlags) |= 0x80u;
9670 pParty->field_709 = 0;
9671 sub_44A56A();
9672 if ( pParty->pHirelings[0].pName )
9673 {
9674 memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1]));
9675 v24 = v2->pName;
9676 v22 = pParty->pHireling2Name;
9677 }
9678 else
9679 {
9680 memcpy(pParty->pHirelings, v2, 0x4Cu);
9681 v24 = v2->pName;
9682 v22 = pParty->pHireling1Name;
9683 }
9684 strcpy(v22, v24);
9685 pParty->field_709 = 0;
9686 sub_44A56A();
9687 PrepareHouse((unsigned int)ptr_507BC0->ptr_1C);
9688 dword_F8B19C = 1;
9689 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
9690 {
9691 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
9692 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
9693 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
9694 ++pMessageQueue_50CBD0->uNumMessages;
9695 }
9696 v11 = uActiveCharacter;
9697 if ( uActiveCharacter )
9698 {
9699 v25 = 0;
9700 v23 = 61;
9701 goto LABEL_50;
9702 }
9703 _return:
9704 pVideoPlayer->_4BF5B2();
9705 }
9706
9707
9708 //----- (004B254D) --------------------------------------------------------
9709 char *__thiscall _4B254D_SkillMasteryTeacher(int _this)
9710 {
9711 Player *v1; // esi@1
9712 int v2; // edx@1
9713 int v3; // ecx@1
9714 int v4; // edi@1
9715 int v5; // eax@7
9716 int v6; // eax@7
9717 int v7; // ebx@7
9718 int v8; // ebx@8
9719 signed int v9; // esi@8
9720 int v10; // eax@8
9721 char *v11; // ecx@8
9722 int v12; // edi@9
9723 char *v13; // edx@9
9724 signed int v14; // edi@10
9725 unsigned int v16; // eax@29
9726 int v17; // eax@36
9727 char v18; // cl@46
9728 __int16 v19; // dx@56
9729 int v20; // eax@60
9730 char *v21; // [sp-Ch] [bp-38h]@82
9731 const char *v22; // [sp-8h] [bp-34h]@21
9732 unsigned int v23; // [sp-8h] [bp-34h]@38
9733 char *v24; // [sp-8h] [bp-34h]@82
9734 char *v25; // [sp-4h] [bp-30h]@14
9735 int v26; // [sp-4h] [bp-30h]@38
9736 int v27; // [sp-4h] [bp-30h]@82
9737 char v28[4]; // [sp+Ch] [bp-20h]@9
9738 int v29; // [sp+10h] [bp-1Ch]@13
9739 int v30; // [sp+14h] [bp-18h]@15
9740 int v31; // [sp+18h] [bp-14h]@16
9741 unsigned __int16 a1[2]; // [sp+1Ch] [bp-10h]@7
9742 int v33; // [sp+20h] [bp-Ch]@7
9743 int v34; // [sp+24h] [bp-8h]@7
9744 char *v35; // [sp+28h] [bp-4h]@1
9745
9746 v1 = pPlayers[uActiveCharacter];
9747 dword_F8B1A8 = 0;
9748 v2 = (_this - 200) % 3;
9749 v3 = (_this - 200) / 3;
9750 v4 = v2;
9751 v35 = (char *)pNPCTopics[127].pText;
9752 dword_F8B1AC_something_todo_with_awards = v3;
9753 if ( v2 )
9754 {
9755 if ( v2 == 1 )
9756 {
9757 dword_F8B1B4 = 5000;
9758 dword_F8B1B0 = 3;
9759 }
9760 else
9761 {
9762 if ( v2 == 2 )
9763 {
9764 dword_F8B1B4 = 8000;
9765 dword_F8B1B0 = 4;
9766 }
9767 }
9768 }
9769 else
9770 {
9771 dword_F8B1B4 = 2000;
9772 dword_F8B1B0 = 2;
9773 }
9774 v5 = v1->uClass;
9775 v33 = v5;
9776 v6 = byte_4ED970_skill_learn_ability_by_class_table[v5][v3];
9777 *(int *)a1 = v1->pActiveSkills[v3];
9778 v7 = a1[0] & 0x3F;
9779 v34 = v2 + 2;
9780 if ( v6 < v2 + 2 )
9781 {
9782 v8 = v33;
9783 v9 = 0;
9784 v10 = v33 - v33 % 4;
9785 v11 = &byte_4ED970_skill_learn_ability_by_class_table[v33 - v33 % 4][v3];
9786 do
9787 {
9788 v12 = (unsigned __int8)*v11;
9789 v13 = &v28[4 * v9];
9790 *(int *)v13 = 0;
9791 if ( v12 < v34 )
9792 {
9793 v14 = 1;
9794 }
9795 else
9796 {
9797 v14 = 1;
9798 *(int *)v13 = 1;
9799 }
9800 ++v9;
9801 v11 += 37;
9802 }
9803 while ( v9 < 4 );
9804 if ( v29 == v14 )
9805 {
9806 v25 = pClassNames[v10 + 1];
9807 }
9808 else
9809 {
9810 if ( v30 == v14 )
9811 {
9812 if ( v31 == v14 )
9813 {
9814 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);
9815 return pTmpBuf;
9816 }
9817 v25 = pClassNames[v10 + 2];
9818 }
9819 else
9820 {
9821 if ( v31 != v14 )
9822 {
9823 v25 = pClassNames[v8];
9824 v22 = pGlobalTXT_LocalizationStrings[632];
9825 goto LABEL_23;
9826 }
9827 v25 = pClassNames[v10 + 3];
9828 }
9829 }
9830 v22 = pGlobalTXT_LocalizationStrings[633];
9831 LABEL_23:
9832 sprintf(pTmpBuf, v22, v25);
9833 return pTmpBuf;
9834 }
9835 if ( !v1->CanAct() )
9836 return (char *)pNPCTopics[122].pText;
9837 if ( !v7 )
9838 return (char *)pNPCTopics[131].pText;
9839 v16 = SkillToMastery(a1[0]);
9840 if ( (signed int)v16 > v4 + 1 )
9841 return (char *)pNPCTopics[v4 + 128].pText;
9842 if ( v34 != 2 )
9843 {
9844 if ( v34 == 3 )
9845 {
9846 if ( (signed int)v16 >= 2 && v7 >= 7 )
9847 {
9848 v17 = dword_F8B1AC_something_todo_with_awards;
9849 switch ( dword_F8B1AC_something_todo_with_awards )
9850 {
9851 default:
9852 goto LABEL_41;
9853 case 12:
9854 case 13:
9855 case 14:
9856 case 15:
9857 case 16:
9858 case 17:
9859 case 18:
9860 dword_F8B1B4 = 4000;
9861 goto LABEL_42;
9862 case 19:
9863 v19 = 114;
9864 goto LABEL_57;
9865 case 20:
9866 v19 = 110;
9867 LABEL_57:
9868 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v19) )
9869 return v35;
9870 goto LABEL_40;
9871 case 22:
9872 v20 = v1->GetBaseWillpower();
9873 goto LABEL_61;
9874 case 24:
9875 dword_F8B1B4 = 2500;
9876 v20 = v1->GetBaseEndurance();
9877 goto LABEL_61;
9878 case 36:
9879 v20 = v1->GetBaseIntelligence();
9880 LABEL_61:
9881 if ( v20 < 50 )
9882 return v35;
9883 goto LABEL_40;
9884 case 21:
9885 case 23:
9886 case 25:
9887 case 26:
9888 case 29:
9889 case 32:
9890 case 34:
9891 case 35:
9892 dword_F8B1B4 = 2500;
9893 goto LABEL_42;
9894 case 8:
9895 case 9:
9896 case 10:
9897 case 11:
9898 dword_F8B1B4 = 3000;
9899 goto LABEL_42;
9900 case 7:
9901 goto LABEL_67;
9902 }
9903 goto LABEL_67;
9904 }
9905 }
9906 else
9907 {
9908 if ( v34 != 4 )
9909 {
9910 LABEL_40:
9911 v17 = dword_F8B1AC_something_todo_with_awards;
9912 goto LABEL_41;
9913 }
9914 if ( (signed int)v16 >= 3 && v7 >= 10 )
9915 {
9916 v17 = dword_F8B1AC_something_todo_with_awards;
9917 switch ( dword_F8B1AC_something_todo_with_awards )
9918 {
9919 case 19:
9920 if ( v1->_49327B(0x22u, 1) == 1 )
9921 goto LABEL_40;
9922 v26 = 1;
9923 v23 = 26;
9924 goto LABEL_39;
9925 default:
9926 goto LABEL_41;
9927 case 20:
9928 if ( v1->_49327B(0x23u, 1) == 1 )
9929 goto LABEL_40;
9930 v26 = 1;
9931 v23 = 27;
9932 LABEL_39:
9933 if ( v1->_49327B(v23, v26) == 1 )
9934 goto LABEL_40;
9935 return v35;
9936 case 30:
9937 v18 = LOBYTE(v1->pActiveSkills[31]);
9938 goto LABEL_47;
9939 case 31:
9940 v18 = LOBYTE(v1->pActiveSkills[30]);
9941 LABEL_47:
9942 if ( (v18 & 0x3Fu) < 0xA )
9943 return v35;
9944 goto LABEL_41;
9945 case 21:
9946 case 23:
9947 case 24:
9948 case 25:
9949 case 26:
9950 case 29:
9951 case 32:
9952 case 34:
9953 case 35:
9954 dword_F8B1B4 = 6000;
9955 goto LABEL_42;
9956 case 8:
9957 case 9:
9958 case 10:
9959 case 11:
9960 dword_F8B1B4 = 7000;
9961 goto LABEL_42;
9962 case 7:
9963 break;
9964 }
9965 LABEL_67:
9966 dword_F8B1B4 = 0;
9967 goto LABEL_41;
9968 }
9969 }
9970 return v35;
9971 }
9972 if ( v7 < 4 )
9973 return v35;
9974 v17 = dword_F8B1AC_something_todo_with_awards;
9975 if ( dword_F8B1AC_something_todo_with_awards > 27 )
9976 {
9977 if ( dword_F8B1AC_something_todo_with_awards != 29
9978 && dword_F8B1AC_something_todo_with_awards != 32
9979 && (dword_F8B1AC_something_todo_with_awards <= 33 || dword_F8B1AC_something_todo_with_awards > 35) )
9980 {
9981 LABEL_41:
9982 if ( !dword_F8B1B4 )
9983 goto LABEL_79;
9984 goto LABEL_42;
9985 }
9986 LABEL_87:
9987 dword_F8B1B4 = 500;
9988 goto LABEL_41;
9989 }
9990 if ( dword_F8B1AC_something_todo_with_awards >= 23 )
9991 goto LABEL_87;
9992 if ( dword_F8B1AC_something_todo_with_awards == 7 )
9993 {
9994 dword_F8B1B4 = 0;
9995 goto LABEL_79;
9996 }
9997 if ( dword_F8B1AC_something_todo_with_awards <= 7 )
9998 goto LABEL_41;
9999 if ( dword_F8B1AC_something_todo_with_awards > 18 )
10000 {
10001 if ( dword_F8B1AC_something_todo_with_awards != 21 )
10002 goto LABEL_41;
10003 goto LABEL_87;
10004 }
10005 dword_F8B1B4 = 1000;
10006 LABEL_42:
10007 if ( dword_F8B1B4 > pParty->uNumGold )
10008 return (char *)pNPCTopics[124].pText;
10009 LABEL_79:
10010 dword_F8B1A8 = 1;
10011 if ( v34 == 2 )
10012 {
10013 v27 = dword_F8B1B4;
10014 v24 = pSkillNames[v17];
10015 v21 = pGlobalTXT_LocalizationStrings[433];
10016 goto LABEL_90;
10017 }
10018 if ( v34 == 3 )
10019 {
10020 v27 = dword_F8B1B4;
10021 v24 = pSkillNames[v17];
10022 v21 = pGlobalTXT_LocalizationStrings[432];
10023 goto LABEL_90;
10024 }
10025 if ( v34 == 4 )
10026 {
10027 v27 = dword_F8B1B4;
10028 v24 = pSkillNames[v17];
10029 v21 = pGlobalTXT_LocalizationStrings[225];
10030 LABEL_90:
10031 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27);
10032 }
10033 return pTmpBuf2;
10034 }
10035
10036
10037
10038 //----- (004B29F2) --------------------------------------------------------
10039 const char *__fastcall sub_4B29F2(int a1)
10040 {
10041 int v1; // esi@1
10042 Player *v2; // edi@1
10043 int v3; // eax@1
10044 Player *v4; // ecx@1
10045
10046 v1 = a1;
10047 dword_F8B1A8 = 0;
10048 v2 = pPlayers[uActiveCharacter];
10049 v3 = a1 + 50;
10050 v4 = pPlayers[uActiveCharacter];
10051 dword_F8B1AC_something_todo_with_awards = v3;
10052 dword_F8B1B4 = dword_4F08EC[v1];
10053 if ( v4->CanAct() )
10054 {
10055 if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v2->field_152, dword_F8B1AC_something_todo_with_awards) )
10056 {
10057 return pNPCTopics[123].pText;
10058 }
10059 else
10060 {
10061 if ( dword_F8B1B4 <= pParty->uNumGold )
10062 {
10063 dword_F8B1A8 = 1;
10064 return pNPCTopics[v1 + 110].pText;
10065 }
10066 else
10067 {
10068 return pNPCTopics[124].pText;
10069 }
10070 }
10071 }
10072 else
10073 {
10074 return pNPCTopics[122].pText;
10075 }
10076 }
10077
10078
10079 //----- (004B2A74) --------------------------------------------------------
10080 char __cdecl sub_4B2A74()
10081 {
10082 char *v0; // esi@3
10083 char *v1; // ST1C_4@3
10084 char *v2; // eax@3
10085 const char *v3; // ST1C_4@5
10086 int v4; // eax@5
10087 unsigned int i; // eax@5
10088 NPCData *v6; // esi@6
10089 unsigned __int16 v7; // bx@6
10090 unsigned int v8; // eax@6
10091 int v9; // eax@11
10092 unsigned int v10; // ecx@12
10093 int v11; // eax@12
10094 int v12; // esi@12
10095 char *v13; // eax@12
10096 GUIWindow *v14; // ebx@13
10097 char *v15; // esi@14
10098 GUIButton *v16; // eax@15
10099 unsigned int v17; // ecx@15
10100 int v18; // ecx@17
10101 int v19; // ecx@18
10102 int v20; // ecx@19
10103 int v21; // ecx@20
10104 int v22; // ecx@21
10105 unsigned int v23; // ecx@23
10106 int v24; // ecx@35
10107 int v25; // ecx@36
10108 int v26; // ecx@37
10109 int v27; // ecx@38
10110 int v28; // ecx@39
10111 char *v29; // esi@42
10112 unsigned int v30; // ST20_4@42
10113 int v31; // ST1C_4@42
10114 unsigned int v32; // eax@42
10115 char *v33; // eax@43
10116 int v34; // esi@51
10117 int v35; // eax@51
10118 unsigned int v36; // edi@51
10119 GUIButton *v37; // eax@52
10120 int v38; // eax@52
10121 signed int v39; // ecx@54
10122 int v40; // edi@57
10123 GUIButton *v41; // eax@60
10124 GUIButton *v42; // esi@60
10125 const char *v43; // ebx@60
10126 int v44; // eax@60
10127 unsigned int v45; // ecx@60
10128 unsigned __int16 v46; // ax@60
10129 GUIFont *v47; // ebx@64
10130 int v48; // esi@64
10131 char *v49; // eax@66
10132 GUIWindow w; // [sp+Ch] [bp-110h]@64
10133 GUIWindow v52; // [sp+60h] [bp-BCh]@13
10134 GUIWindow a1; // [sp+B4h] [bp-68h]@1
10135 unsigned int v54; // [sp+108h] [bp-14h]@14
10136 int v55; // [sp+10Ch] [bp-10h]@6
10137 int v56; // [sp+110h] [bp-Ch]@13
10138 char *pInString; // [sp+114h] [bp-8h]@12
10139 NPCData *v58; // [sp+118h] [bp-4h]@6
10140
10141 memcpy(&a1, pDialogueWindow, sizeof(a1));
10142 if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
10143 {
10144 v0 = pMapStats->pInfos[uHouse_ExitPic].pName;
10145 v1 = pMapStats->pInfos[uHouse_ExitPic].pName;
10146 a1.uFrameX = 493;
10147 a1.uFrameWidth = 126;
10148 a1.uFrameZ = 366;
10149 a1.DrawTitleText(pFontCreate, 0, 2u, 0, v1, 3u);
10150 a1.uFrameX = 483;
10151 a1.uFrameWidth = 148;
10152 a1.uFrameZ = 334;
10153 v2 = (&off_4EB080)[4 * uHouse_ExitPic];
10154 if ( !v2 )
10155 {
10156 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0);
10157 v2 = pTmpBuf;
10158 }
10159 v3 = v2;
10160 v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0);
10161 LOBYTE(i) = (unsigned int)a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u);
10162 return i;
10163 }
10164 a1.uFrameWidth -= 10;
10165 a1.uFrameZ -= 10;
10166 v58 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
10167 v6 = v58;
10168 v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
10169 v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
10170 v8 = v6->uProfession;
10171 if ( v8 )
10172 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
10173 else
10174 strcpy(pTmpBuf, v6->pName);
10175 a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf, 3u);
10176 if ( !dword_591080 )
10177 {
10178 if ( !uDialogueType )
10179 {
10180 v9 = v6->greet;
10181 if ( v9 )
10182 {
10183 v10 = v6->uFlags;
10184 a1.uFrameWidth = 460;
10185 a1.uFrameZ = 452;
10186 pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9);
10187 v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0);
10188 v12 = v11 + 7;
10189 pRenderer->_4A6A68(
10190 8u,
10191 352 - (v11 + 7),
10192 (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0),
10193 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - (v11 + 7));
10194 pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
10195 v13 = FitTextInAWindow(pInString, pFontArrus, &a1, 0xDu, 0);
10196 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0);
10197 }
10198 }
10199 }
10200 v14 = pDialogueWindow;
10201 memcpy(&v52, pDialogueWindow, sizeof(v52));
10202 v52.uFrameX = 483;
10203 v52.uFrameWidth = 148;
10204 v52.uFrameZ = 334;
10205 v56 = v52.pStartingPosActiveItem;
10206 if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton )
10207 {
10208 v15 = (char *)v54;
10209 while ( 1 )
10210 {
10211 v16 = v52.GetControl(v56);
10212 v17 = v16->uControlParam;
10213 pInString = (char *)v16;
10214 if ( (signed int)v17 > 24 )
10215 {
10216 v24 = v17 - 76;
10217 if ( !v24 )
10218 {
10219 v15 = pGlobalTXT_LocalizationStrings[406];
10220 goto LABEL_49;
10221 }
10222 v25 = v24 - 1;
10223 if ( !v25 )
10224 {
10225 v15 = pGlobalTXT_LocalizationStrings[407];
10226 goto LABEL_49;
10227 }
10228 v26 = v25 - 2;
10229 if ( !v26 )
10230 {
10231 v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C);
10232 LABEL_44:
10233 v15 = v33;
10234 LABEL_45:
10235 v16 = (GUIButton *)pInString;
10236 goto LABEL_49;
10237 }
10238 v27 = v26 - 3;
10239 if ( !v27 )
10240 {
10241 v33 = (char *)sub_4B29F2((int)v52.ptr_1C);
10242 goto LABEL_44;
10243 }
10244 v28 = v27 - 1;
10245 if ( !v28 )
10246 {
10247 v29 = (char *)&pMonsterStats + 88 * word_F8B1A0;
10248 v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
10249 v31 = *(int *)v29;
10250 v32 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
10251 sprintf(pTmpBuf, &byte_4F0F98, v32, v31, v30);
10252 sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
10253 ptr_F8B1E8 = pTmpBuf2;
10254 v15 = "";
10255 goto LABEL_45;
10256 }
10257 if ( v28 != 10 )
10258 goto LABEL_41;
10259 }
10260 else
10261 {
10262 if ( v17 == 24 )
10263 {
10264 v23 = v58->evtf;
10265 LABEL_33:
10266 v15 = (&dword_721660)[8 * v23];
10267 if ( !v15 )
10268 {
10269 v16->uControlParam = 0;
10270 v15 = "";
10271 }
10272 goto LABEL_49;
10273 }
10274 v18 = v17 - 13;
10275 if ( v18 )
10276 {
10277 v19 = v18 - 6;
10278 if ( !v19 )
10279 {
10280 v23 = v58->bDrawSomeAnim;
10281 goto LABEL_33;
10282 }
10283 v20 = v19 - 1;
10284 if ( !v20 )
10285 {
10286 v15 = (&dword_721660)[8 * v58->evtb];
10287 if ( !v15 )
10288 {
10289 v16->uControlParam = 0;
10290 v15 = "";
10291 }
10292 if ( uDialogueType != 84 )
10293 goto LABEL_49;
10294 sprintf(pTmpBuf, format_4E2D80, v55, pItemsTable->pItems[dword_F8B1A8].pUnidentifiedName);
10295 sprintf(pTmpBuf2, ptr_F8B1E8, pTmpBuf);
10296 ptr_F8B1E8 = pTmpBuf2;
10297 goto LABEL_45;
10298 }
10299 v21 = v20 - 1;
10300 if ( !v21 )
10301 {
10302 v23 = v58->evtc;
10303 goto LABEL_33;
10304 }
10305 v22 = v21 - 1;
10306 if ( !v22 )
10307 {
10308 v23 = v58->evtd;
10309 goto LABEL_33;
10310 }
10311 if ( v22 == 1 )
10312 {
10313 v23 = v58->evte;
10314 goto LABEL_33;
10315 }
10316 LABEL_41:
10317 v15 = "";
10318 goto LABEL_49;
10319 }
10320 v15 = pGlobalTXT_LocalizationStrings[122];
10321 }
10322 LABEL_49:
10323 strcpy(v16->pButtonName, v15);
10324 ++v56;
10325 if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton )
10326 {
10327 v14 = pDialogueWindow;
10328 break;
10329 }
10330 }
10331 }
10332 v34 = 0;
10333 v54 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
10334 v35 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
10335 v36 = v14->pStartingPosActiveItem;
10336 v55 = v35;
10337 for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
10338 + pDialogueWindow->pStartingPosActiveItem )
10339 {
10340 v37 = v14->GetControl(v36);
10341 v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0);
10342 v14 = pDialogueWindow;
10343 v34 += v38;
10344 ++v36;
10345 }
10346 v39 = v14->pNumPresenceButton;
10347 if ( v39 )
10348 {
10349 v58 = (NPCData *)((174 - v34) / v39);
10350 if ( (signed int)v58 > 32 )
10351 v58 = (NPCData *)32;
10352 pInString = (char *)2;
10353 v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138;
10354 v56 = v14->pStartingPosActiveItem;
10355 i = v56;
10356 if ( (signed int)i < (signed int)(i + v39) )
10357 {
10358 while ( 1 )
10359 {
10360 v41 = v14->GetControl(i);
10361 v42 = v41;
10362 v43 = v41->pButtonName;
10363 v41->uY = (unsigned int)((char *)v58 + v40);
10364 v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0);
10365 v45 = v42->uY;
10366 v42->uHeight = v44;
10367 v40 = v45 + v44 - 1;
10368 v42->uW = v40;
10369 v46 = v55;
10370 if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString )
10371 v46 = v54;
10372 v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3u);
10373 v14 = pDialogueWindow;
10374 ++pInString;
10375 ++v56;
10376 i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
10377 if ( v56 >= (signed int)i )
10378 break;
10379 i = v56;
10380 }
10381 }
10382 }
10383 if ( ptr_F8B1E8 )
10384 {
10385 w.uFrameWidth = 458;
10386 w.uFrameZ = 457;
10387 v47 = pFontArrus;
10388 v48 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
10389 if ( 352 - v48 < 8 )
10390 {
10391 v47 = pFontCreate;
10392 v48 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
10393 }
10394 pRenderer->_4A6A68(
10395 8u,
10396 352 - v48,
10397 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
10398 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v48);
10399 pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428);
10400 v49 = FitTextInAWindow(ptr_F8B1E8, v47, &w, 0xDu, 0);
10401 LOBYTE(i) = a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0);
10402 }
10403 return i;
10404 }
10405
10406
10407
10408
10409
10410 //----- (004B36CC) --------------------------------------------------------
10411 GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2)
10412 {
10413 return pDialogueWindow->CreateButton(
10414 0x1E0u,
10415 30 * a1 + 146,
10416 0x8Cu,
10417 0x1Eu,
10418 1,
10419 0,
10420 0x195u,
10421 a2,
10422 0,
10423 "",
10424 0);
10425 }
10426
10427 //----- (004B3703) --------------------------------------------------------
10428 int __thiscall sub_4B3703(void *_this)
10429 {
10430 signed int v1; // edi@1
10431 int v2; // eax@1
10432 char *v3; // ecx@1
10433 signed int v4; // ebx@1
10434 int v5; // ecx@2
10435 int v6; // ecx@3
10436 int v7; // ecx@4
10437 int v8; // ecx@5
10438 int v9; // ecx@6
10439 signed int v10; // ebx@13
10440 signed int v11; // edi@14
10441 signed int v12; // esi@15
10442 unsigned int v13; // ecx@16
10443 int v14; // ecx@16
10444 int v15; // ecx@17
10445 int v16; // ecx@19
10446 int v17; // ecx@20
10447 int v18; // ecx@21
10448 signed int v19; // esi@32
10449 char *v20; // ecx@33
10450 int v21; // ecx@34
10451 int v22; // ecx@36
10452 int v23; // ecx@37
10453 int v24; // ecx@38
10454 int v25; // ecx@39
10455 int v26; // ecx@40
10456 int v27; // ecx@41
10457 int *v28; // esi@54
10458 unsigned int v29; // edx@56
10459 char *v30; // ecx@65
10460 int v31; // ecx@106
10461 int result; // eax@107
10462 int v33; // [sp-4h] [bp-2Ch]@23
10463 int v34; // [sp-4h] [bp-2Ch]@43
10464 int v35[5]; // [sp+Ch] [bp-1Ch]@8
10465 int a2; // [sp+20h] [bp-8h]@1
10466 int v37; // [sp+24h] [bp-4h]@1
10467
10468 v1 = 0;
10469 v2 = 0;
10470 v3 = (char *)_this - 1;
10471 a2 = 0;
10472 v37 = 0;
10473 dword_F8B1DC = 0;
10474 v4 = 2;
10475 if ( !v3 )
10476 {
10477 while ( 1 )
10478 {
10479 v19 = 1;
10480 do
10481 {
10482 v20 = (char *)ptr_507BC0->ptr_1C + 4 * (unsigned int)ptr_507BC0->ptr_1C + v19;
10483 if ( v1 )
10484 v21 = word_4F063E[(signed int)v20];
10485 else
10486 v21 = word_4F03FE[(signed int)v20];
10487 v22 = v21 - 23;
10488 if ( v22 )
10489 {
10490 v23 = v22 - 1;
10491 if ( v23 )
10492 {
10493 v24 = v23 - 1;
10494 if ( v24 )
10495 {
10496 v25 = v24 - 1;
10497 if ( v25 )
10498 {
10499 v26 = v25 - 1;
10500 if ( v26 )
10501 {
10502 v27 = v26 - 1;
10503 if ( v27 )
10504 {
10505 if ( v27 != v4 )
10506 goto LABEL_51;
10507 v34 = 36;
10508 }
10509 else
10510 {
10511 v34 = 42;
10512 }
10513 }
10514 else
10515 {
10516 v34 = 41;
10517 }
10518 }
10519 else
10520 {
10521 v34 = 40;
10522 }
10523 }
10524 else
10525 {
10526 v34 = 39;
10527 }
10528 }
10529 else
10530 {
10531 v34 = 38;
10532 }
10533 }
10534 else
10535 {
10536 v34 = 37;
10537 }
10538 v37 = sub_4BE571(v34, v35, v37, 5);
10539 v2 = dword_F8B1DC;
10540 v4 = 2;
10541 LABEL_51:
10542 ++v19;
10543 }
10544 while ( v19 <= 4 );
10545 ++v1;
10546 if ( v1 >= v4 )
10547 goto LABEL_53;
10548 }
10549 }
10550 v5 = (int)(v3 - 1);
10551 if ( !v5 )
10552 {
10553 v10 = 0;
10554 while ( 1 )
10555 {
10556 v11 = 0;
10557 do
10558 {
10559 v12 = 1;
10560 do
10561 {
10562 v13 = v11 + 2 * (unsigned int)ptr_507BC0->ptr_1C - 30;
10563 v14 = v12 + 4 * v13 + v13;
10564 if ( v10 )
10565 v15 = word_4F06D8[v14];
10566 else
10567 v15 = word_4F0498[v14];
10568 v16 = v15 - 31;
10569 if ( v16 )
10570 {
10571 v17 = v16 - 1;
10572 if ( v17 )
10573 {
10574 v18 = v17 - 1;
10575 if ( v18 )
10576 {
10577 if ( v18 != 1 )
10578 goto LABEL_28;
10579 v33 = 44;
10580 }
10581 else
10582 {
10583 v33 = 47;
10584 }
10585 }
10586 else
10587 {
10588 v33 = 46;
10589 }
10590 }
10591 else
10592 {
10593 v33 = 45;
10594 }
10595 v37 = sub_4BE571(v33, v35, v37, 5);
10596 v2 = dword_F8B1DC;
10597 LABEL_28:
10598 ++v12;
10599 }
10600 while ( v12 <= 4 );
10601 ++v11;
10602 }
10603 while ( v11 < 2 );
10604 ++v10;
10605 if ( v10 >= 2 )
10606 goto LABEL_53;
10607 }
10608 }
10609 v6 = v5 - 1;
10610 if ( v6 )
10611 {
10612 v7 = v6 - 1;
10613 if ( v7 )
10614 {
10615 v8 = v7 - 17;
10616 if ( v8 )
10617 {
10618 v9 = v8 - 2;
10619 if ( v9 )
10620 {
10621 if ( v9 == 7 )
10622 {
10623 v37 = 2;
10624 v35[0] = 69;
10625 v35[1] = 60;
10626 }
10627 }
10628 else
10629 {
10630 v37 = 3;
10631 v35[0] = 67;
10632 v35[1] = 66;
10633 v35[2] = 58;
10634 }
10635 }
10636 else
10637 {
10638 v37 = 3;
10639 v35[0] = 70;
10640 v35[1] = 65;
10641 v35[2] = 62;
10642 }
10643 }
10644 else
10645 {
10646 v37 = 2;
10647 v35[0] = 71;
10648 v35[1] = 68;
10649 }
10650 }
10651 else
10652 {
10653 v37 = 2;
10654 v35[0] = 57;
10655 v35[1] = 59;
10656 }
10657 LABEL_53:
10658 if ( v37 > 0 )
10659 {
10660 v28 = v35;
10661 while ( 1 )
10662 {
10663 v29 = *v28;
10664 if ( *v28 <= 47 )
10665 break;
10666 if ( (signed int)v29 <= 66 )
10667 {
10668 if ( v29 == 66 )
10669 {
10670 v30 = pSkillNames[30];
10671 goto LABEL_106;
10672 }
10673 if ( v29 == 57 )
10674 {
10675 v30 = pSkillNames[21];
10676 goto LABEL_106;
10677 }
10678 if ( v29 == 58 )
10679 {
10680 v30 = pSkillNames[22];
10681 goto LABEL_106;
10682 }
10683 if ( v29 == 60 )
10684 {
10685 v30 = pSkillNames[24];
10686 goto LABEL_106;
10687 }
10688 if ( v29 == 62 )
10689 {
10690 v30 = pSkillNames[26];
10691 goto LABEL_106;
10692 }
10693 if ( v29 == 65 )
10694 {
10695 v30 = pSkillNames[29];
10696 goto LABEL_106;
10697 }
10698 goto LABEL_100;
10699 }
10700 switch ( v29 )
10701 {
10702 case 0x43u:
10703 v30 = pSkillNames[31];
10704 break;
10705 case 0x44u:
10706 v30 = pSkillNames[32];
10707 break;
10708 case 0x45u:
10709 v30 = pSkillNames[33];
10710 break;
10711 case 0x46u:
10712 v30 = pSkillNames[34];
10713 break;
10714 default:
10715 if ( v29 != 71 )
10716 goto LABEL_100;
10717 v30 = pSkillNames[35];
10718 break;
10719 }
10720 LABEL_106:
10721 pShopOptions[v2] = v30;
10722 v31 = a2++;
10723 dword_F8B1DC = v2 + 1;
10724 sub_4B36CC(v31, v29);
10725 ++v28;
10726 if ( a2 >= v37 )
10727 goto LABEL_107;
10728 v2 = dword_F8B1DC;
10729 }
10730 if ( *v28 == 47 )
10731 {
10732 v30 = pSkillNames[11];
10733 goto LABEL_106;
10734 }
10735 if ( (signed int)v29 > 40 )
10736 {
10737 if ( v29 == 41 )
10738 {
10739 v30 = pSkillNames[5];
10740 goto LABEL_106;
10741 }
10742 if ( v29 == 42 )
10743 {
10744 v30 = pSkillNames[6];
10745 goto LABEL_106;
10746 }
10747 if ( v29 == 44 )
10748 {
10749 v30 = pSkillNames[8];
10750 goto LABEL_106;
10751 }
10752 if ( v29 == 45 )
10753 {
10754 v30 = pSkillNames[9];
10755 goto LABEL_106;
10756 }
10757 if ( v29 == 46 )
10758 {
10759 v30 = pSkillNames[10];
10760 goto LABEL_106;
10761 }
10762 }
10763 else
10764 {
10765 if ( v29 == 40 )
10766 {
10767 v30 = pSkillNames[4];
10768 goto LABEL_106;
10769 }
10770 if ( v29 == 5 )
10771 {
10772 v30 = pSkillNames[23];
10773 goto LABEL_106;
10774 }
10775 if ( v29 == 36 )
10776 {
10777 v30 = pSkillNames[0];
10778 goto LABEL_106;
10779 }
10780 if ( v29 == 37 )
10781 {
10782 v30 = pSkillNames[1];
10783 goto LABEL_106;
10784 }
10785 if ( v29 == 38 )
10786 {
10787 v30 = pSkillNames[2];
10788 goto LABEL_106;
10789 }
10790 if ( v29 == 39 )
10791 {
10792 v30 = pSkillNames[3];
10793 goto LABEL_106;
10794 }
10795 }
10796 LABEL_100:
10797 v30 = pGlobalTXT_LocalizationStrings[127];
10798 goto LABEL_106;
10799 }
10800 LABEL_107:
10801 pDialogueWindow->_41D08F(a2, 1, 0, 2);
10802 result = pDialogueWindow->pNumPresenceButton;
10803 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
10804 return result;
10805 }
10806
10807
10808 //----- (004B3A72) --------------------------------------------------------
10809 int __thiscall sub_4B3A72(int a1)
10810 {
10811 int v1; // esi@1
10812 int result; // eax@4
10813
10814 v1 = 0;
10815 if ( a1 == 21 )
10816 {
10817 sub_4B36CC(0, 0x66u);
10818 v1 = 2;
10819 sub_4B36CC(1, 0x67u);
10820 if ( pParty->HasItem(0x28Bu) )
10821 {
10822 v1 = 3;
10823 sub_4B36CC(2, 0x68u);
10824 }
10825 }
10826 pDialogueWindow->_41D08F(v1, 1, 0, 2);
10827 result = pDialogueWindow->pNumPresenceButton;
10828 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
10829 return result;
10830 }
10831 // F8B1E0: using guessed type int dword_F8B1E0;
10832
10833 //----- (004B3AD4) --------------------------------------------------------
10834 int __fastcall sub_4B3AD4(signed int a1)
10835 {
10836 int result; // eax@7
10837 int v2; // [sp-10h] [bp-10h]@4
10838 int v3; // [sp-Ch] [bp-Ch]@4
10839 int v4; // [sp-8h] [bp-8h]@4
10840 int v5; // [sp-4h] [bp-4h]@4
10841
10842 if ( a1 > 0 )
10843 {
10844 if ( a1 <= 3 )
10845 {
10846 sub_4B36CC(0, 3u);
10847 sub_4B36CC(1, 4u);
10848 sub_4B36CC(2, 5u);
10849 v5 = 2;
10850 v4 = 0;
10851 v3 = 1;
10852 v2 = 3;
10853 goto LABEL_6;
10854 }
10855 if ( a1 == 4 )
10856 {
10857 sub_4B36CC(0, 3u);
10858 sub_4B36CC(1, 4u);
10859 v5 = 2;
10860 v4 = 0;
10861 v3 = 1;
10862 v2 = 2;
10863 LABEL_6:
10864 pDialogueWindow->_41D08F(v2, v3, v4, v5);
10865 goto LABEL_7;
10866 }
10867 }
10868 LABEL_7:
10869 result = pDialogueWindow->pNumPresenceButton;
10870 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
10871 return result;
10872 }
10873 // F8B1E0: using guessed type int dword_F8B1E0;
10874
10875 //----- (004B3B42) --------------------------------------------------------
10876 int __fastcall sub_4B3B42(signed int a1)
10877 {
10878 int v1; // ecx@18
10879 int v2; // ecx@19
10880 int v3; // ecx@20
10881 signed int v4; // esi@22
10882 signed int v5; // eax@22
10883 unsigned int v6; // edx@24
10884 int v7; // ecx@24
10885 int result; // eax@43
10886 int v9; // [sp-10h] [bp-14h]@28
10887 int v10; // [sp-Ch] [bp-10h]@28
10888 int v11; // [sp-8h] [bp-Ch]@28
10889 unsigned int v12; // [sp-4h] [bp-8h]@4
10890 unsigned int v13; // [sp-4h] [bp-8h]@5
10891 unsigned int v14; // [sp-4h] [bp-8h]@9
10892 unsigned int v15; // [sp-4h] [bp-8h]@10
10893 unsigned int v16; // [sp-4h] [bp-8h]@14
10894 int v17; // [sp-4h] [bp-8h]@28
10895
10896 if ( a1 > 13 )
10897 {
10898 if ( a1 > 22 )
10899 {
10900 if ( a1 == 23 )
10901 {
10902 sub_4B36CC(0, 0xAu);
10903 sub_4B36CC(1, 0xBu);
10904 v14 = 96;
10905 LABEL_41:
10906 sub_4B36CC(2, v14);
10907 v17 = 2;
10908 v11 = 0;
10909 v10 = 1;
10910 v9 = 3;
10911 goto LABEL_42;
10912 }
10913 if ( a1 <= 26 )
10914 goto LABEL_43;
10915 if ( a1 > 28 )
10916 {
10917 if ( a1 != 30 )
10918 goto LABEL_43;
10919 sub_4B36CC(0, 0x11u);
10920 v16 = 96;
10921 goto LABEL_37;
10922 }
10923 sub_4B36CC(0, 0x69u);
10924 sub_4B36CC(1, 0x6Au);
10925 sub_4B36CC(2, 0x6Bu);
10926 v12 = 108;
10927 }
10928 else
10929 {
10930 if ( a1 == 22 )
10931 {
10932 sub_4B36CC(0, 7u);
10933 v16 = 8;
10934 goto LABEL_37;
10935 }
10936 v1 = a1 - 14;
10937 if ( !v1 )
10938 {
10939 sub_4B36CC(0, 0x12u);
10940 sub_4B36CC(1, 0x30u);
10941 sub_4B36CC(2, 0x31u);
10942 sub_4B36CC(3, 0x32u);
10943 sub_4B36CC(4, 0x33u);
10944 v17 = 2;
10945 v11 = 0;
10946 v10 = 1;
10947 v9 = 5;
10948 goto LABEL_42;
10949 }
10950 v2 = v1 - 1;
10951 if ( v2 )
10952 {
10953 v3 = v2 - 2;
10954 if ( v3 )
10955 {
10956 if ( v3 != 4 )
10957 goto LABEL_43;
10958 sub_4B36CC(0, 0xFu);
10959 sub_4B36CC(1, 0x10u);
10960 v4 = 3;
10961 sub_4B36CC(2, 0x60u);
10962 v5 = (signed int)ptr_507BC0->ptr_1C;
10963 if ( v5 < 108 || v5 > 120 )
10964 goto LABEL_28;
10965 v4 = 4;
10966 v6 = 101;
10967 v7 = 3;
10968 }
10969 else
10970 {
10971 v4 = 1;
10972 sub_4B36CC(0, 0x63u);
10973 if ( !pParty->uFine )
10974 {
10975 LABEL_28:
10976 v17 = 2;
10977 v11 = 0;
10978 v10 = 1;
10979 v9 = v4;
10980 LABEL_42:
10981 pDialogueWindow->_41D08F(v9, v10, v11, v17);
10982 goto LABEL_43;
10983 }
10984 v4 = 2;
10985 v7 = 1;
10986 v6 = 100;
10987 }
10988 sub_4B36CC(v7, v6);
10989 goto LABEL_28;
10990 }
10991 sub_4B36CC(0, 0x12u);
10992 sub_4B36CC(1, 0x34u);
10993 sub_4B36CC(2, 0x35u);
10994 v12 = 54;
10995 }
10996 LABEL_39:
10997 sub_4B36CC(3, v12);
10998 v17 = 2;
10999 v11 = 0;
11000 v10 = 1;
11001 v9 = 4;
11002 goto LABEL_42;
11003 }
11004 if ( a1 == 13 )
11005 {
11006 sub_4B36CC(0, 0x12u);
11007 v16 = 56;
11008 LABEL_37:
11009 sub_4B36CC(1, v16);
11010 v17 = 2;
11011 v11 = 0;
11012 v10 = 1;
11013 v9 = 2;
11014 goto LABEL_42;
11015 }
11016 switch ( a1 )
11017 {
11018 case 1:
11019 case 2:
11020 case 3:
11021 case 4:
11022 sub_4B36CC(0, 2u);
11023 sub_4B36CC(1, 0x5Fu);
11024 sub_4B36CC(2, 0x5Eu);
11025 v12 = 96;
11026 goto LABEL_39;
11027 case 5:
11028 sub_4B36CC(0, 0x12u);
11029 v13 = 48;
11030 goto LABEL_9;
11031 case 6:
11032 sub_4B36CC(0, 0x12u);
11033 v13 = 49;
11034 goto LABEL_9;
11035 case 7:
11036 sub_4B36CC(0, 0x12u);
11037 v13 = 50;
11038 goto LABEL_9;
11039 case 8:
11040 sub_4B36CC(0, 0x12u);
11041 v13 = 51;
11042 LABEL_9:
11043 sub_4B36CC(1, v13);
11044 v14 = 72;
11045 goto LABEL_41;
11046 case 9:
11047 sub_4B36CC(0, 0x12u);
11048 v15 = 52;
11049 goto LABEL_13;
11050 case 10:
11051 sub_4B36CC(0, 0x12u);
11052 v15 = 53;
11053 goto LABEL_13;
11054 case 11:
11055 sub_4B36CC(0, 0x12u);
11056 v15 = 54;
11057 LABEL_13:
11058 sub_4B36CC(1, v15);
11059 v14 = 61;
11060 goto LABEL_41;
11061 case 12:
11062 sub_4B36CC(0, 0x12u);
11063 v16 = 55;
11064 goto LABEL_37;
11065 default:
11066 break;
11067 }
11068 LABEL_43:
11069 result = pDialogueWindow->pNumPresenceButton;
11070 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
11071 return result;
11072 }
11073 // F8B1E0: using guessed type int dword_F8B1E0;
11074
11075 //----- (004B3E1E) --------------------------------------------------------
11076 void __cdecl sub_4B3E1E()
11077 {
11078 NPCData *v0; // ST40_4@1
11079 signed int v1; // edi@1
11080 GUIWindow *v2; // ecx@1
11081
11082 v0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
11083 v1 = 0;
11084 pDialogueWindow->eWindowType = WINDOW_MainMenu;
11085 pDialogueWindow->Release();
11086 v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_A, 1, 0);
11087 pDialogueWindow = v2;
11088 if ( *(&pNPCStats->field_13A5C + 5 * v0->uProfession) )
11089 {
11090 v2->CreateButton(
11091 0x1E0u,
11092 0xA0u,
11093 0x8Cu,
11094 0x1Eu,
11095 1,
11096 0,
11097 0x88u,
11098 0x4Du,
11099 0,
11100 pGlobalTXT_LocalizationStrings[407],
11101 0);
11102 v1 = 1;
11103 }
11104 pDialogueWindow->CreateButton(
11105 0x1E0u,
11106 30 * v1 + 160,
11107 0x8Cu,
11108 0x1Eu,
11109 1,
11110 0,
11111 0x88u,
11112 0x4Cu,
11113 0,
11114 pGlobalTXT_LocalizationStrings[406],
11115 0);
11116 pDialogueWindow->_41D08F(v1 + 1, 1, 0, 1);
11117 }
11118
11119 //----- (004B3EF0) --------------------------------------------------------
11120 void __fastcall sub_4B3EF0(int a4)
11121 {
11122 int v1; // edi@1
11123
11124 v1 = a4;
11125 uDialogueType = 81;
11126 ptr_F8B1E8 = (char *)pNPCTopics[a4 + 99].pText;
11127 sub_4B29F2(a4);
11128 pDialogueWindow->Release();
11129 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, v1, 0);
11130 pBtn_ExitCancel = pDialogueWindow->CreateButton(
11131 0x1D7,
11132 0x1BD,
11133 0xA9,
11134 0x23,
11135 1,
11136 0,
11137 0x71,
11138 0,
11139 0,
11140 pGlobalTXT_LocalizationStrings[34],
11141 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
11142 0);
11143 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
11144 pDialogueWindow->CreateButton(
11145 0x1E0u,
11146 0xA0u,
11147 0x8Cu,
11148 0x1Eu,
11149 1,
11150 0,
11151 0xAFu,
11152 0x52u,
11153 0,
11154 pGlobalTXT_LocalizationStrings[122],
11155 0);
11156 pDialogueWindow->_41D08F(1, 1, 0, 2);
11157 dword_F8B19C = -1;
11158 }
11159 // F8B19C: using guessed type int dword_F8B19C;
11160
11161 //----- (004B3FE5) --------------------------------------------------------
11162 void __fastcall sub_4B3FE5(int a4)
11163 {
11164 int v1; // edi@1
11165 char *v2; // edi@1
11166
11167 v1 = a4;
11168 uDialogueType = 78;
11169 ptr_F8B1E8 = (char *)pNPCTopics[a4 + 168].pText;
11170 _4B254D_SkillMasteryTeacher(a4);
11171 pDialogueWindow->Release();
11172 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
11173 v2 = "";
11174 pBtn_ExitCancel = pDialogueWindow->CreateButton(
11175 0x1D7u,
11176 0x1BDu,
11177 0xA9u,
11178 0x23u,
11179 1,
11180 0,
11181 0x71u,
11182 0,
11183 0,
11184 pGlobalTXT_LocalizationStrings[34],
11185 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
11186 0);
11187 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
11188 if ( dword_F8B1A8 )
11189 v2 = pGlobalTXT_LocalizationStrings[535];
11190 pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x4Fu, 0, v2, 0);
11191 pDialogueWindow->_41D08F(1, 1, 0, 2);
11192 dword_F8B19C = -1;
11193 }
11194 // F8B19C: using guessed type int dword_F8B19C;
11195 // F8B1A8: using guessed type int dword_F8B1A8;
11196
11197 //----- (004B40E6) --------------------------------------------------------
11198 void __cdecl sub_4B40E6()
11199 {
11200 signed int v0; // ebx@1
11201 NPCData *v1; // edi@1
11202
11203 v0 = 0;
11204 v1 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
11205 pDialogueWindow->Release();
11206 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
11207 pBtn_ExitCancel = pDialogueWindow->CreateButton(
11208 0x1D7u,
11209 0x1BDu,
11210 0xA9u,
11211 0x23u,
11212 1,
11213 0,
11214 0x71u,
11215 0,
11216 0,
11217 pGlobalTXT_LocalizationStrings[34],
11218 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
11219 0);
11220 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
11221 if ( *(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
11222 {
11223 pDialogueWindow->CreateButton(
11224 0x1E0u,
11225 0xA0u,
11226 0x8Cu,
11227 0x1Eu,
11228 1,
11229 0,
11230 0xAFu,
11231 0x4Du,
11232 0,
11233 pGlobalTXT_LocalizationStrings[407],
11234 0);
11235 v0 = 1;
11236 }
11237 pDialogueWindow->CreateButton(
11238 0x1E0u,
11239 30 * v0 + 160,
11240 0x8Cu,
11241 0x1Eu,
11242 1,
11243 0,
11244 0xAFu,
11245 0x4Cu,
11246 0,
11247 pGlobalTXT_LocalizationStrings[406],
11248 0);
11249 pDialogueWindow->_41D08F(v0 + 1, 1, 0, 2);
11250 dword_F8B19C = -1;
11251 }
11252
11253
11254 //----- (004B4224) --------------------------------------------------------
11255 GUIButton *_4B4224_UpdateNPCTopics(int _this)
11256 {
11257 int v1; // ebx@1
11258 GUIButton *result; // eax@3
11259 int i; // ebp@5
11260 signed int v4; // ebp@9
11261 void *v5; // ecx@14
11262 bool v6; // eax@16
11263 void *v7; // ecx@19
11264 bool v8; // eax@21
11265 void *v9; // ecx@24
11266 bool v10; // eax@26
11267 void *v11; // ecx@29
11268 bool v12; // eax@31
11269 void *v13; // ecx@34
11270 bool v14; // eax@36
11271 void *v15; // ecx@39
11272 bool v16; // eax@41
11273 NPCData *v17; // [sp+10h] [bp-4h]@4
11274
11275 v1 = 0;
11276 array_5913D8[6] = (NPCData *)(_this + 1);
11277 if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
11278 {
11279 pDialogueWindow->Release();
11280 pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
11281 sprintf(byte_591098, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);
11282 pBtn_ExitCancel = pDialogueWindow->CreateButton(
11283 0x236u,
11284 0x1BDu,
11285 0x4Bu,
11286 0x21u,
11287 1,
11288 0,
11289 0x71u,
11290 0,
11291 0x4Eu,
11292 pGlobalTXT_LocalizationStrings[34],// "Cancel"
11293 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
11294 0);
11295 pBtn_YES = pDialogueWindow->CreateButton(
11296 486u,
11297 445u,
11298 75u,
11299 33u,
11300 1,
11301 0,
11302 0xBFu,
11303 1u,
11304 0x59u,
11305 byte_591098,
11306 (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
11307 0);
11308 pDialogueWindow->CreateButton(
11309 _4E5E50_transui_x,
11310 _4E5EE0_transui_y,
11311 63u,
11312 73u,
11313 1,
11314 0,
11315 0xBFu,
11316 1u,
11317 0x20u,
11318 byte_591098,
11319 0);
11320 result = pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, byte_591098, 0);
11321 }
11322 else
11323 {
11324 v17 = array_5913D8[_this + 1 - ((dword_591080 != 0) + 1)];
11325 if ( dword_F8B19C == -1 )
11326 {
11327 pDialogueWindow->Release();
11328 }
11329 else
11330 {
11331 for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
11332 GUIButton::_41D0D8((GUIButton *)array_5913D8[i + 7]);
11333 }
11334 v4 = 1;
11335 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
11336 pBtn_ExitCancel = pDialogueWindow->CreateButton(
11337 471u,
11338 445u,
11339 169u,
11340 35u,
11341 1,
11342 0,
11343 0x71u,
11344 0,
11345 0,
11346 pGlobalTXT_LocalizationStrings[74],// "End Conversation"
11347 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
11348 0);
11349 pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
11350 if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
11351 {
11352 result = (GUIButton *)sub_4B3B42(dword_F8B198);
11353 }
11354 else
11355 {
11356 if ( v17->joins )
11357 {
11358 v1 = 1;
11359 pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, "", 0);
11360 }
11361 v5 = (void *)v17->bDrawSomeAnim;
11362 if ( v5 )
11363 {
11364 if ( v1 < 4 )
11365 {
11366 v6 = sub_4466C4(v5);
11367 if ( v6 == 1 || v6 == 2 )
11368 pDialogueWindow->CreateButton(
11369 480u,
11370 30 * v1++ + 160,
11371 140u,
11372 30u,
11373 1,
11374 0,
11375 0xAFu,
11376 0x13u,
11377 0,
11378 "",
11379 0);
11380 }
11381 }
11382 v7 = (void *)v17->evtb;
11383 if ( v7 )
11384 {
11385 if ( v1 < 4 )
11386 {
11387 v8 = sub_4466C4(v7);
11388 if ( v8 == 1 || v8 == 2 )
11389 pDialogueWindow->CreateButton(
11390 480u,
11391 30 * v1++ + 160,
11392 140u,
11393 30u,
11394 1,
11395 0,
11396 0xAFu,
11397 0x14u,
11398 0,
11399 "",
11400 0);
11401 }
11402 }
11403 v9 = (void *)v17->evtc;
11404 if ( v9 )
11405 {
11406 if ( v1 < 4 )
11407 {
11408 v10 = sub_4466C4(v9);
11409 if ( v10 == 1 || v10 == 2 )
11410 pDialogueWindow->CreateButton(
11411 480u,
11412 30 * v1++ + 160,
11413 140u,
11414 30u,
11415 1,
11416 0,
11417 0xAFu,
11418 0x15u,
11419 0,
11420 "",
11421 0);
11422 }
11423 }
11424 v11 = (void *)v17->evtd;
11425 if ( v11 )
11426 {
11427 if ( v1 < 4 )
11428 {
11429 v12 = sub_4466C4(v11);
11430 if ( v12 == 1 || v12 == 2 )
11431 pDialogueWindow->CreateButton(
11432 0x1E0u,
11433 30 * v1++ + 160,
11434 0x8Cu,
11435 0x1Eu,
11436 1,
11437 0,
11438 0xAFu,
11439 0x16u,
11440 0,
11441 "",
11442 0);
11443 }
11444 }
11445 v13 = (void *)v17->evte;
11446 if ( v13 )
11447 {
11448 if ( v1 < 4 )
11449 {
11450 v14 = sub_4466C4(v13);
11451 if ( v14 == 1 || v14 == 2 )
11452 pDialogueWindow->CreateButton(
11453 0x1E0u,
11454 30 * v1++ + 160,
11455 0x8Cu,
11456 0x1Eu,
11457 1,
11458 0,
11459 0xAFu,
11460 0x17u,
11461 0,
11462 "",
11463 0);
11464 }
11465 }
11466 v15 = (void *)v17->evtf;
11467 if ( v15 )
11468 {
11469 if ( v1 < 4 )
11470 {
11471 v16 = sub_4466C4(v15);
11472 if ( v16 == 1 || v16 == 2 )
11473 pDialogueWindow->CreateButton(
11474 0x1E0u,
11475 30 * v1++ + 160,
11476 0x8Cu,
11477 0x1Eu,
11478 1,
11479 0,
11480 0xAFu,
11481 0x18u,
11482 0,
11483 "",
11484 0);
11485 }
11486 }
11487 pDialogueWindow->_41D08F(v1, 1, 0, 2);
11488 v4 = 1;
11489 result = (GUIButton *)pDialogueWindow->pNumPresenceButton;
11490 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
11491 }
11492 dword_F8B19C = v4;
11493 }
11494 return result;
11495 }
11496
11497
11498
11499 //----- (004B46A5) --------------------------------------------------------
11500 char __fastcall sub_4B46A5(const char *Str, int a5)
11501 {
11502 const char *v2; // esi@1
11503 int v3; // edi@1
11504 int v4; // eax@1
11505
11506 v2 = Str;
11507 v3 = a5;
11508 pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
11509 v4 = pFontLucida->AlignText_Center(0x1C2u, v2);
11510 return pPrimaryWindow->DrawText(pFontLucida, v4 + 11, 357, v3, v2, 0, 0, 0);
11511 }
11512
11513 //----- (004B46F8) --------------------------------------------------------
11514 int __fastcall sub_4B46F8(int a1)
11515 {
11516 int v1; // eax@1
11517 int i; // edx@1
11518
11519 v1 = 0;
11520 for ( i = 0; i < a1; ++i )
11521 v1 += i + 1;
11522 return 1000 * v1;
11523 }
11524
11525 //----- (004B4710) --------------------------------------------------------
11526 int __cdecl ui_training()
11527 {
11528 Player *v0; // ebx@1
11529 int color2; // eax@1
11530 unsigned int v2; // ecx@1
11531 int v3; // eax@1
11532 signed int v4; // edx@1
11533 int v5; // edi@3
11534 unsigned int v6; // esi@3
11535 void *v7; // ecx@3
11536 int v8; // edx@4
11537 double v9; // st7@6
11538 signed int v10; // esi@6
11539 int v11; // ecx@6
11540 int result; // eax@9
11541 GUIWindow *v13; // edi@14
11542 signed int v14; // esi@14
11543 unsigned int v15; // esi@16
11544 int v16; // eax@16
11545 unsigned int v17; // eax@17
11546 int v18; // eax@19
11547 int v19; // ecx@24
11548 GUIButton *v20; // eax@26
11549 GUIButton *v21; // esi@26
11550 int v22; // eax@26
11551 const char *v23; // eax@28
11552 int v24; // eax@28
11553 unsigned int v25; // ecx@28
11554 int v26; // eax@28
11555 unsigned __int16 v27; // ax@28
11556 int v28; // eax@32
11557 unsigned __int16 v29; // ST14_2@34
11558 int v30; // eax@34
11559 const char *v31; // ST18_4@36
11560 unsigned __int16 v32; // ST14_2@36
11561 int v33; // eax@36
11562 int v34; // eax@37
11563 unsigned int v35; // edi@38
11564 unsigned int v36; // eax@38
11565 int v37; // ecx@41
11566 char *v38; // eax@41
11567 int *v39; // eax@45
11568 unsigned int v40; // eax@46
11569 void *v41; // ecx@46
11570 unsigned int v42; // eax@46
11571 GUIWindow *v43; // ecx@59
11572 int v44; // edx@59
11573 char **v45; // esi@60
11574 int v46; // eax@62
11575 int v47; // eax@68
11576 int v48; // edx@69
11577 int v49; // ebx@69
11578 unsigned __int8 v50; // sf@69
11579 char **v51; // edi@70
11580 GUIButton *v52; // eax@71
11581 GUIButton *v53; // esi@71
11582 int v54; // eax@71
11583 unsigned int v55; // ecx@71
11584 int v56; // eax@71
11585 unsigned __int16 v57; // ax@71
11586 unsigned __int16 v58; // [sp-Ch] [bp-90h]@38
11587 const char *v59; // [sp-Ch] [bp-90h]@63
11588 char *v60; // [sp-8h] [bp-8Ch]@38
11589 char *v61; // [sp-8h] [bp-8Ch]@63
11590 unsigned int v62; // [sp-4h] [bp-88h]@38
11591 int v63; // [sp-4h] [bp-88h]@52
11592 char *v64; // [sp-4h] [bp-88h]@63
11593 GUIWindow v65; // [sp+Ch] [bp-78h]@1
11594 __int64 v66; // [sp+60h] [bp-24h]@3
11595 unsigned int white; // [sp+68h] [bp-1Ch]@1
11596 int v68; // [sp+6Ch] [bp-18h]@3
11597 int v69; // [sp+70h] [bp-14h]@6
11598 unsigned int i; // [sp+74h] [bp-10h]@1
11599 int v71; // [sp+78h] [bp-Ch]@1
11600 int v72; // [sp+7Ch] [bp-8h]@16
11601 int v73; // [sp+80h] [bp-4h]@14
11602
11603 v0 = pPlayers[uActiveCharacter];
11604 memcpy(&v65, ptr_507BC0, sizeof(v65));
11605 v65.uFrameX = 483;
11606 v65.uFrameWidth = 148;
11607 v65.uFrameZ = 334;
11608 white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
11609 color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
11610 v2 = v0->uLevel;
11611 v71 = color2;
11612 v3 = 0;
11613 v4 = 0;
11614 for ( i = v2; v4 < (signed int)v2; ++v4 )
11615 v3 += v4 + 1;
11616 v5 = 1000 * v3;
11617 v6 = HIDWORD(v0->uExperience);
11618 v7 = ptr_507BC0->ptr_1C;
11619 v68 = (unsigned __int16)word_4F0866[(signed int)v7];
11620 v66 = 1000 * v3;
11621 if ( (signed __int64)__PAIR__(v6, LODWORD(v0->uExperience)) >= v66 )
11622 {
11623 v8 = v0->uClass % 4 + 1;
11624 if ( v8 == 4 )
11625 v8 = 3;
11626 v9 = (double)(signed int)i;
11627 i = 0;
11628 v69 = v8;
11629 //v10 = (signed __int64)(v9 * p2DEvents_minus1__20[13 * (signed int)v7] * (double)v8);
11630 v10 = (signed __int64)(v9 * p2DEvents[(signed int)v7 - 1].fPriceMultiplier * (double)v8);
11631 v11 = v10 * (100 - v0->GetMerchant()) / 100;
11632 if ( v11 < v10 / 3 )
11633 v11 = v10 / 3;
11634 i = v11;
11635 }
11636 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
11637 if ( result )
11638 {
11639 if ( dword_F8B19C != 1 )
11640 {
11641 if ( dword_F8B19C != 17 )
11642 {
11643 result = dword_F8B19C - 96;
11644 if ( dword_F8B19C == 96 )
11645 {
11646 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
11647 if ( result )
11648 {
11649 i = 0;
11650 v13 = pDialogueWindow;
11651 //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
11652 v14 = (signed __int64)(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].flt_24 * 500.0);
11653 v73 = v14 * (100 - v0->GetMerchant()) / 100;
11654 if ( v73 < v14 / 3 )
11655 v73 = v14 / 3;
11656 v15 = v13->pStartingPosActiveItem;
11657 v16 = v13->pNumPresenceButton;
11658 v72 = 0;
11659 if ( (signed int)v15 >= (signed int)(v15 + v16) )
11660 goto LABEL_76;
11661 do
11662 {
11663 v17 = v13->GetControl(v15)->uControlParam - 36;
11664 if ( byte_4ED970_skill_learn_ability_by_class_table[v0->uClass][v17] && !v0->pActiveSkills[v17] )
11665 {
11666 v18 = pFontArrus->CalcTextHeight(pSkillNames[v17], &v65, 0, 0);
11667 i += v18;
11668 ++v72;
11669 }
11670 ++v15;
11671 }
11672 while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem );
11673 if ( v72 )
11674 {
11675 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
11676 v65.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
11677 v73 = (signed int)(149 - i) / v72;
11678 if ( v73 > 32 )
11679 v73 = 32;
11680 result = v13->pStartingPosActiveItem;
11681 v19 = (signed int)(149 - v72 * v73 - i) / 2 - v73 / 2 + 162;
11682 i = result;
11683 v68 = v19;
11684 if ( result < result + v13->pNumPresenceButton )
11685 {
11686 v72 = 2;
11687 do
11688 {
11689 v20 = v13->GetControl(i);
11690 v21 = v20;
11691 v22 = v20->uControlParam - 36;
11692 if ( !byte_4ED970_skill_learn_ability_by_class_table[v0->uClass][v22] || v0->pActiveSkills[v22] )
11693 {
11694 v21->uW = 0;
11695 v21->uHeight = 0;
11696 v21->uY = 0;
11697 }
11698 else
11699 {
11700 v23 = pSkillNames[v22];
11701 v21->uY = v73 + v68;
11702 HIDWORD(v66) = (int)v23;
11703 v24 = pFontArrus->CalcTextHeight(v23, &v65, 0, 0);
11704 v25 = v21->uY;
11705 v21->uHeight = v24;
11706 v26 = v25 + v24 - 1;
11707 v21->uW = v26;
11708 v68 = v26;
11709 v27 = v71;
11710 if ( pDialogueWindow->pCurrentPosActiveItem != v72 )
11711 v27 = white;
11712 v65.DrawTitleText(pFontArrus, 0, v25, v27, (char *)HIDWORD(v66), 3u);
11713 }
11714 v28 = v13->pStartingPosActiveItem;
11715 ++i;
11716 result = v13->pNumPresenceButton + v28;
11717 ++v72;
11718 }
11719 while ( (signed int)i < result );
11720 }
11721 }
11722 else
11723 {
11724 LABEL_76:
11725 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);//
11726 // "Seek knowledge elsewhere %s the %s"
11727 strcat(pTmpBuf, "\n \n");
11728 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
11729 v29 = v71;
11730 v30 = pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0);
11731 result = (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u);
11732 }
11733 }
11734 }
11735 return result;
11736 }
11737 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
11738 {
11739 v31 = pNPCTopics[122].pText;
11740 v32 = v71;
11741 v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
11742 v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, v32, v31, 3u);
11743 result = (int)pDialogueWindow;
11744 pDialogueWindow->pNumPresenceButton = 0;
11745 return result;
11746 }
11747 v34 = v0->uLevel;
11748 if ( v34 < v68 )
11749 {
11750 if ( (signed __int64)v0->uExperience >= v66 )
11751 {
11752 if ( pParty->uNumGold >= i )
11753 {
11754 Party::TakeGold(i);
11755 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
11756 ++v0->uLevel;
11757 v0->uSkillPoints += v0->uLevel / 10 + 5;
11758 v0->sHealth = v0->GetMaxHealth();
11759 v0->sMana = v0->GetMaxMana();
11760 v37 = 0;
11761 v38 = byte_F8B148;
11762 do
11763 {
11764 if ( *(int *)v38 > v37 )
11765 v37 = *(int *)v38;
11766 v38 += 4;
11767 }
11768 while ( (signed int)v38 < (signed int)word_F8B158 );
11769 v39 = &dword_F8B144 + uActiveCharacter;
11770 ++*v39;
11771 if ( *v39 > v37 )
11772 {
11773 v40 = sub_494820(pParty->uCurrentHour);
11774 v41 = ptr_507BC0->ptr_1C;
11775 v42 = 60 * (v40 + 4) - pParty->uCurrentMinute;
11776 if ( v41 == (void *)94 || v41 == (void *)95 )
11777 v42 += 720;
11778 RestAndHeal((signed int)(v42 + 10080));
11779 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
11780 pOutdoor->SetFog();
11781 }
11782 v0->PlaySound(87, 0);
11783 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);//
11784 // "%s is now Level %lu and has earned %lu Skill Points!"
11785 ShowStatusBarString(pTmpBuf, 2u);
11786 goto LABEL_56;
11787 }
11788 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
11789 v63 = 4;
11790 LABEL_55:
11791 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v63);
11792 LABEL_56:
11793 result = pMessageQueue_50CBD0->uNumMessages;
11794 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
11795 {
11796 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
11797 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
11798 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
11799 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
11800 ++pMessageQueue_50CBD0->uNumMessages;
11801 }
11802 return result;
11803 }
11804 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[538], v5 - LODWORD(v0->uExperience), v34 + 1);//
11805 // "You need %d more experience to train to level %d"
11806 v35 = 0;
11807 v62 = 3;
11808 v60 = pTmpBuf;
11809 v58 = v71;
11810 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0)) / 2 + 88;
11811 }
11812 else
11813 {
11814 sprintf(pTmpBuf, "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);//
11815 // ""With your skills, you should be working here as a teacher.""
11816 // ""Sorry, but we are unable to train you.""
11817 v35 = 0;
11818 v62 = 3;
11819 v60 = pTmpBuf;
11820 v58 = v71;
11821 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0)) / 2 + 101;
11822 }
11823 v65.DrawTitleText(pFontArrus, v35, v36, v58, v60, v62);
11824 v63 = 3;
11825 goto LABEL_55;
11826 }
11827 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
11828 if ( result )
11829 {
11830 v43 = pDialogueWindow;
11831 v72 = 0;
11832 pShopOptions[0] = pTmpBuf;
11833 pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
11834 v44 = pDialogueWindow->pNumPresenceButton;
11835 v73 = pDialogueWindow->pStartingPosActiveItem;
11836 if ( v73 < v73 + v44 )
11837 {
11838 v45 = pShopOptions;
11839 do
11840 {
11841 if ( v43->GetControl(v73)->uControlParam == 17 )
11842 {
11843 v46 = v0->uLevel;
11844 if ( v46 < v68 )
11845 {
11846 if ( (signed __int64)v0->uExperience < v66 )
11847 {
11848 v64 = (char *)(v46 + 1);
11849 v61 = (char *)(v5 - LODWORD(v0->uExperience));
11850 v59 = pGlobalTXT_LocalizationStrings[538];// "You need %d more experience to train to level %d"
11851 }
11852 else
11853 {
11854 v64 = (char *)i;
11855 v61 = (char *)(v46 + 1);
11856 v59 = pGlobalTXT_LocalizationStrings[537];// "Train to level %d for %d gold"
11857 }
11858 }
11859 else
11860 {
11861 v64 = pGlobalTXT_LocalizationStrings[529];// ""Sorry, but we are unable to train you.""
11862 v61 = pGlobalTXT_LocalizationStrings[536];// ""With your skills, you should be working here as a teacher.""
11863 v59 = "%s\n \n%s";
11864 }
11865 sprintf(*v45, v59, v61, v64);
11866 }
11867 v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0);
11868 v43 = pDialogueWindow;
11869 v72 += v47;
11870 ++v45;
11871 ++v73;
11872 }
11873 while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
11874 }
11875 HIDWORD(v66) = (174 - v72) / 2;
11876 result = v43->pStartingPosActiveItem;
11877 v48 = result + v43->pNumPresenceButton;
11878 v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138;
11879 v50 = -v43->pNumPresenceButton < 0;
11880 v73 = v43->pStartingPosActiveItem;
11881 if ( v50 ^ __OFSUB__(result, v48) )
11882 {
11883 i = 2;
11884 v51 = pShopOptions;
11885 do
11886 {
11887 v52 = v43->GetControl(v73);
11888 v53 = v52;
11889 v52->uY = HIDWORD(v66) + v49;
11890 v54 = pFontArrus->CalcTextHeight(*v51, &v65, 0, 0);
11891 v55 = v53->uY;
11892 v53->uHeight = v54;
11893 v56 = v54 + v55 - 1;
11894 v53->uW = v56;
11895 v49 = v56;
11896 v57 = v71;
11897 if ( pDialogueWindow->pCurrentPosActiveItem != i )
11898 v57 = white;
11899 v65.DrawTitleText(pFontArrus, 0, v55, v57, *v51, 3u);
11900 v43 = pDialogueWindow;
11901 ++i;
11902 ++v51;
11903 ++v73;
11904 result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
11905 }
11906 while ( v73 < result );
11907 }
11908 }
11909 }
11910 return result;
11911 }
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921 //----- (004B4FCF) --------------------------------------------------------
11922 int __cdecl ui_shop_teachers()
11923 {
11924 Player *v0; // ebx@1
11925 int result; // eax@6
11926 signed int v2; // esi@8
11927 unsigned int v3; // ebx@10
11928 char *v4; // eax@11
11929 char *v5; // eax@12
11930 unsigned int v6; // eax@12
11931 int v7; // ST08_4@14
11932 int v8; // eax@14
11933 unsigned __int8 v9; // dl@14
11934 char *v10; // ecx@14
11935 signed int v11; // esi@16
11936 int v12; // ST08_4@19
11937 int v13; // eax@19
11938 int v14; // edi@21
11939 char **v15; // esi@21
11940 int v16; // eax@22
11941 GUIWindow *v17; // ecx@23
11942 int v18; // edx@23
11943 int v19; // edi@23
11944 unsigned __int8 v20; // sf@23
11945 GUIButton *v21; // esi@25
11946 const char **v22; // eax@25
11947 int v23; // eax@25
11948 unsigned int v24; // ecx@25
11949 const char **v25; // edx@25
11950 unsigned __int16 v26; // ax@25
11951 signed int v27; // esi@30
11952 int v28; // ST08_4@34
11953 int v29; // eax@34
11954 char *v30; // edx@35
11955 GUIWindow *v31; // edi@40
11956 void *v32; // eax@40
11957 signed int v33; // esi@40
11958 unsigned int v34; // esi@42
11959 int v35; // eax@42
11960 unsigned int v36; // eax@43
11961 int v37; // eax@45
11962 int v38; // ecx@50
11963 GUIButton *v39; // eax@52
11964 GUIButton *v40; // esi@52
11965 int v41; // eax@52
11966 char *v42; // eax@54
11967 int v43; // eax@54
11968 unsigned int v44; // ecx@54
11969 int v45; // edx@54
11970 int v46; // eax@54
11971 unsigned __int16 v47; // ax@54
11972 int v48; // eax@58
11973 signed int v49; // esi@62
11974 Texture *v50; // ecx@64
11975 unsigned int v51; // edi@64
11976 unsigned int v52; // esi@66
11977 int v53; // edx@70
11978 Texture *v54; // ecx@76
11979 unsigned int v55; // edi@76
11980 unsigned int v56; // esi@76
11981 int v57; // edx@80
11982 Texture *v58; // ecx@86
11983 unsigned int v59; // edi@86
11984 unsigned int v60; // esi@88
11985 int v61; // edx@92
11986 Texture *v62; // ecx@98
11987 unsigned int v63; // edi@98
11988 unsigned int v64; // esi@100
11989 int v65; // edx@104
11990 signed int v66; // ecx@109
11991 SHORT v67; // di@117
11992 bool v68; // eax@117
11993 const char *v69; // ecx@119
11994 POINT *v70; // esi@124
11995 int v71; // ecx@125
11996 int v72; // eax@125
11997 int v73; // ecx@125
11998 ItemGen *v74; // esi@125
11999 int v75; // eax@130
12000 int v76; // esi@131
12001 char **v77; // edi@131
12002 int v78; // eax@132
12003 GUIWindow *v79; // ecx@133
12004 int v80; // edx@133
12005 int v81; // edi@133
12006 GUIButton *v82; // esi@135
12007 const char **v83; // eax@135
12008 int v84; // eax@135
12009 unsigned int v85; // ecx@135
12010 int v86; // edx@135
12011 unsigned __int16 v87; // ax@135
12012 GUIWindow *v88; // [sp-18h] [bp-110h]@35
12013 int v89; // [sp-14h] [bp-10Ch]@35
12014 ItemGen *v90; // [sp-10h] [bp-108h]@14
12015 int v91; // [sp-10h] [bp-108h]@35
12016 unsigned __int16 v92; // [sp-Ch] [bp-104h]@12
12017 void *v93; // [sp-Ch] [bp-104h]@14
12018 int v94; // [sp-8h] [bp-100h]@11
12019 char *v95; // [sp-8h] [bp-100h]@12
12020 __int64 *v96; // [sp-4h] [bp-FCh]@11
12021 unsigned int v97; // [sp-4h] [bp-FCh]@12
12022 POINT v98; // [sp+Ch] [bp-ECh]@8
12023 POINT v99; // [sp+14h] [bp-E4h]@16
12024 POINT v100; // [sp+1Ch] [bp-DCh]@124
12025 POINT v101; // [sp+24h] [bp-D4h]@17
12026 POINT v102; // [sp+2Ch] [bp-CCh]@124
12027 POINT v103; // [sp+34h] [bp-C4h]@9
12028 POINT v104; // [sp+3Ch] [bp-BCh]@31
12029 POINT v105; // [sp+44h] [bp-B4h]@16
12030 POINT v106; // [sp+4Ch] [bp-ACh]@30
12031 POINT v107; // [sp+54h] [bp-A4h]@16
12032 POINT v108; // [sp+5Ch] [bp-9Ch]@30
12033 POINT a2; // [sp+64h] [bp-94h]@8
12034 POINT v110; // [sp+6Ch] [bp-8Ch]@30
12035 POINT v111; // [sp+74h] [bp-84h]@8
12036 GUIWindow v112; // [sp+7Ch] [bp-7Ch]@1
12037 char *Str; // [sp+D0h] [bp-28h]@54
12038 int v114; // [sp+D4h] [bp-24h]@23
12039 unsigned int color2; // [sp+D8h] [bp-20h]@1
12040 unsigned int white; // [sp+DCh] [bp-1Ch]@1
12041 __int32 v117; // [sp+E0h] [bp-18h]@8
12042 int v118; // [sp+E4h] [bp-14h]@40
12043 const char **v119; // [sp+E8h] [bp-10h]@24
12044 Player *_this; // [sp+ECh] [bp-Ch]@1
12045 unsigned __int8 uPlayerID; // [sp+F3h] [bp-5h]@14
12046 int v122; // [sp+F4h] [bp-4h]@23
12047
12048 v0 = pPlayers[uActiveCharacter];
12049 _this = pPlayers[uActiveCharacter];
12050 memcpy(&v112, ptr_507BC0, sizeof(v112));
12051 v112.uFrameX = 483;
12052 v112.uFrameWidth = 148;
12053 v112.uFrameZ = 334;
12054 white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
12055 color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
12056 if ( dword_F8B19C > 5 )
12057 {
12058 if ( dword_F8B19C == 94 )
12059 {
12060 draw_leather();
12061 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
12062 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell"
12063 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify"
12064 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair"
12065 v76 = 0;
12066 v77 = pShopOptions;
12067 do
12068 {
12069 v78 = pFontArrus->CalcTextHeight(*v77, &v112, 0, 0);
12070 ++v77;
12071 v76 += v78;
12072 }
12073 while ( (signed int)v77 < (signed int)&pShopOptions[3] );
12074 v79 = pDialogueWindow;
12075 _this = (Player *)((174 - v76) / 3);
12076 result = pDialogueWindow->pStartingPosActiveItem;
12077 v80 = result + pDialogueWindow->pNumPresenceButton;
12078 v81 = (3 * (58 - (signed int)_this) - v76) / 2 - (174 - v76) / 3 / 2 + 138;
12079 v20 = -pDialogueWindow->pNumPresenceButton < 0;
12080 v118 = pDialogueWindow->pStartingPosActiveItem;
12081 if ( v20 ^ __OFSUB__(result, v80) )
12082 {
12083 v122 = 2;
12084 v119 = (const char **)pShopOptions;
12085 do
12086 {
12087 v82 = v79->GetControl(v118);
12088 v83 = v119;
12089 v82->uY = (unsigned int)((char *)_this + v81);
12090 v84 = pFontArrus->CalcTextHeight(*v83, &v112, 0, 0);
12091 v85 = v82->uY;
12092 v86 = v122;
12093 v82->uHeight = v84;
12094 v81 = v84 + v85 - 1;
12095 v82->uW = v81;
12096 v87 = color2;
12097 if ( pDialogueWindow->pCurrentPosActiveItem != v86 )
12098 v87 = white;
12099 v112.DrawTitleText(pFontArrus, 0, v85, v87, *v119, 3u);
12100 v79 = pDialogueWindow;
12101 ++v122;
12102 ++v119;
12103 ++v118;
12104 result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
12105 }
12106 while ( v118 < result );
12107 }
12108 return result;
12109 }
12110 if ( dword_F8B19C != 95 )
12111 {
12112 result = dword_F8B19C - 96;
12113 if ( dword_F8B19C == 96 )
12114 {
12115 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12116 if ( result )
12117 {
12118 v31 = pDialogueWindow;
12119 v3 = 0;
12120 v32 = ptr_507BC0->ptr_1C;
12121 v118 = 0;
12122 //v33 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v32] * 500.0);
12123 v33 = (signed __int64)(p2DEvents[(signed int)v32 - 1].flt_24 * 500.0);
12124 v119 = (const char **)(v33 * (100 - _this->GetMerchant()) / 100);
12125 if ( (signed int)v119 < v33 / 3 )
12126 v119 = (const char **)(v33 / 3);
12127 v34 = v31->pStartingPosActiveItem;
12128 v35 = v34 + v31->pNumPresenceButton;
12129 v122 = 0;
12130 if ( (signed int)v34 >= v35 )
12131 goto LABEL_140;
12132 do
12133 {
12134 v36 = v31->GetControl(v34)->uControlParam - 36;
12135 if ( byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v36] && !_this->pActiveSkills[v36] )
12136 {
12137 v37 = pFontArrus->CalcTextHeight(pSkillNames[v36], &v112, 0, 0);
12138 v118 += v37;
12139 ++v122;
12140 }
12141 ++v34;
12142 }
12143 while ( (signed int)v34 < v31->pNumPresenceButton + v31->pStartingPosActiveItem );
12144 if ( !v122 )
12145 {
12146 LABEL_140:
12147 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);//
12148 // "Seek knowledge elsewhere %s the %s"
12149 strcat(pTmpBuf, "\n \n");
12150 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
12151 v30 = pTmpBuf;
12152 v97 = 3;
12153 v95 = pTmpBuf;
12154 v92 = color2;
12155 v91 = 0;
12156 v89 = 0;
12157 v88 = &v112;
12158 goto LABEL_61;
12159 }
12160 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu"
12161 v112.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
12162 v119 = (const char **)((149 - v118) / v122);
12163 if ( (149 - v118) / v122 > 32 )
12164 v119 = (const char **)32;
12165 result = v31->pStartingPosActiveItem;
12166 v38 = (149 - v122 * (signed int)v119 - v118) / 2 - (signed int)v119 / 2 + 162;
12167 v118 = result;
12168 v114 = v38;
12169 if ( result < result + v31->pNumPresenceButton )
12170 {
12171 v122 = 2;
12172 do
12173 {
12174 v39 = v31->GetControl(v118);
12175 v40 = v39;
12176 v41 = v39->uControlParam - 36;
12177 if ( !byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v41] || _this->pActiveSkills[v41] )
12178 {
12179 v40->uW = 0;
12180 v40->uHeight = 0;
12181 v40->uY = 0;
12182 }
12183 else
12184 {
12185 v42 = pSkillNames[v41];
12186 v40->uY = (unsigned int)((char *)v119 + v114);
12187 Str = v42;
12188 v43 = pFontArrus->CalcTextHeight(v42, &v112, 0, 0);
12189 v44 = v40->uY;
12190 v45 = v122;
12191 v40->uHeight = v43;
12192 v46 = v44 + v43 - 1;
12193 v40->uW = v46;
12194 v114 = v46;
12195 v47 = color2;
12196 if ( pDialogueWindow->pCurrentPosActiveItem != v45 )
12197 v47 = white;
12198 v112.DrawTitleText(pFontArrus, 0, v44, v47, Str, 3u);
12199 }
12200 v48 = v31->pStartingPosActiveItem;
12201 ++v118;
12202 result = v31->pNumPresenceButton + v48;
12203 ++v122;
12204 }
12205 while ( v118 < result );
12206 }
12207 }
12208 }
12209 return result;
12210 }
12211 }
12212 else
12213 {
12214 if ( dword_F8B19C == 5 )
12215 {
12216 draw_leather();
12217 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
12218 sub_4B46A5(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair"
12219 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12220 if ( !result
12221 || (v27 = pMouse->GetCursorPos(&v110)->x - 14,
12222 v117 = (v27 >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5),
12223 result = (int)pMouse->GetCursorPos(&v106),
12224 *(int *)result <= 13)
12225 || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462)
12226 || (result = v0->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result)
12227 || (result *= 9, !(_this->field_1F5[4 * result + 15] & 2)) )
12228 return result;
12229 v96 = 0;
12230 v94 = 5;
12231 v93 = ptr_507BC0->ptr_1C;
12232 v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5];
12233 v28 = (int)ptr_507BC0->ptr_1C;
12234 uPlayerID = uActiveCharacter - 1;
12235 v29 = _this->_490EEE((ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5], 3, v28, 5);
12236 v9 = uPlayerID;
12237 v10 = (char *)pMerchantsRepairPhrases[v29];
12238 goto LABEL_35;
12239 }
12240 if ( dword_F8B19C == 1 )
12241 {
12242 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12243 if ( result )
12244 {
12245 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];// "Buy Standard"
12246 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];// "Buy Special"
12247 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];// "Display Inventory"
12248 v14 = 0;
12249 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
12250 v15 = pShopOptions;
12251 do
12252 {
12253 v16 = pFontArrus->CalcTextHeight(*v15, &v112, 0, 0);
12254 ++v15;
12255 v14 += v16;
12256 }
12257 while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
12258 v17 = pDialogueWindow;
12259 v114 = (174 - v14) / 4;
12260 result = pDialogueWindow->pStartingPosActiveItem;
12261 v18 = result + pDialogueWindow->pNumPresenceButton;
12262 v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
12263 v20 = -pDialogueWindow->pNumPresenceButton < 0;
12264 v122 = pDialogueWindow->pStartingPosActiveItem;
12265 if ( v20 ^ __OFSUB__(result, v18) )
12266 {
12267 v119 = (const char **)2;
12268 _this = (Player *)pShopOptions;
12269 do
12270 {
12271 v21 = v17->GetControl(v122);
12272 v22 = (const char **)_this;
12273 v21->uY = v114 + v19;
12274 v23 = pFontArrus->CalcTextHeight(*v22, &v112, 0, 0);
12275 v24 = v21->uY;
12276 v25 = v119;
12277 v21->uHeight = v23;
12278 v19 = v24 + v23 - 1;
12279 v21->uW = v19;
12280 v26 = color2;
12281 if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v25 )
12282 v26 = white;
12283 v112.DrawTitleText(pFontArrus, 0, v24, v26, (const char *)LODWORD(_this->pConditions[0]), 3u);
12284 v17 = pDialogueWindow;
12285 v119 = (const char **)((char *)v119 + 1);
12286 _this = (Player *)((char *)_this + 4);
12287 ++v122;
12288 result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
12289 }
12290 while ( v122 < result );
12291 }
12292 }
12293 return result;
12294 }
12295 if ( dword_F8B19C != 2 )
12296 {
12297 if ( dword_F8B19C != 3 )
12298 {
12299 result = dword_F8B19C - 4;
12300 if ( dword_F8B19C == 4 )
12301 {
12302 draw_leather();
12303 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
12304 sub_4B46A5(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify"
12305 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12306 if ( result )
12307 {
12308 v2 = pMouse->GetCursorPos(&a2)->x - 14;
12309 v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5);
12310 result = (int)pMouse->GetCursorPos(&v111);
12311 if ( *(int *)result > 13 )
12312 {
12313 result = (int)pMouse->GetCursorPos(&v103);
12314 if ( *(int *)result < 462 )
12315 {
12316 result = v0->GetItemIDAtInventoryIndex((int *)&v117);
12317 v3 = 0;
12318 if ( result )
12319 {
12320 v96 = 0;
12321 v94 = 4;
12322 v4 = &_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
12323 if ( v4[20] & 1 )
12324 {
12325 v5 = sub_495461("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0);
12326 v97 = 3;
12327 v95 = v5;
12328 v92 = white;
12329 v6 = (212 - pFontArrus->CalcTextHeight(v5, &v112, 0, 0)) / 2 + 101;
12330 return (int)v112.DrawTitleText(pFontArrus, v3, v6, v92, v95, v97);
12331 }
12332 v93 = ptr_507BC0->ptr_1C;
12333 v90 = (ItemGen *)v4;
12334 v7 = (int)ptr_507BC0->ptr_1C;
12335 uPlayerID = uActiveCharacter - 1;
12336 v8 = ((Player *)_this)->_490EEE((ItemGen *)v4, 3, v7, 4);
12337 v9 = uPlayerID;
12338 v10 = (char *)pMerchantsIdentifyPhrases[v8];
12339 goto LABEL_35;
12340 }
12341 }
12342 }
12343 }
12344 }
12345 return result;
12346 }
12347 draw_leather();
12348 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
12349 sub_4B46A5(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell"
12350 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12351 if ( !result
12352 || (v11 = pMouse->GetCursorPos(&v107)->x - 14,
12353 v117 = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v99)->y - 17) >> 5),
12354 result = (int)pMouse->GetCursorPos(&v105),
12355 *(int *)result <= 13)
12356 || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462)
12357 || (result = v0->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) )
12358 return result;
12359 v96 = 0;
12360 v94 = 3;
12361 v93 = ptr_507BC0->ptr_1C;
12362 v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
12363 v12 = (int)ptr_507BC0->ptr_1C;
12364 uPlayerID = uActiveCharacter - 1;
12365 v13 = _this->_490EEE(v90, 3, v12, 3);
12366 v9 = uPlayerID;
12367 v10 = (char *)pMerchantsSellPhrases[v13];
12368 LABEL_35:
12369 v30 = sub_495461(v10, v9, v90, (char *)v93, v94, v96);
12370 v97 = 3;
12371 v95 = v30;
12372 v92 = white;
12373 v91 = v3;
12374 v89 = v3;
12375 v88 = &v112;
12376 LABEL_61:
12377 v6 = (174 - pFontArrus->CalcTextHeight(v30, v88, v89, v91)) / 2 + 138;
12378 return (int)v112.DrawTitleText(pFontArrus, v3, v6, v92, v95, v97);
12379 }
12380 }
12381 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
12382 v3 = 0;
12383 v49 = 0;
12384 v122 = 0;
12385 if ( dword_F8B19C == 2 )
12386 {
12387 do
12388 {
12389 if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
12390 {
12391 v50 = dword_F8B168[v49];
12392 v51 = 152 - v50->uTextureHeight;
12393 if ( (signed int)v51 < 1 )
12394 v51 = 0;
12395 v52 = 75 * v49 - v50->uTextureWidth / 2 + 40;
12396 if ( v122 )
12397 {
12398 if ( v122 == 5 )
12399 {
12400 v53 = dword_F8B168[5]->uTextureWidth;
12401 if ( (signed int)v52 > 457 - v53 )
12402 v52 = 457 - v53;
12403 }
12404 }
12405 else
12406 {
12407 if ( (signed int)v52 < 18 )
12408 v52 = 18;
12409 }
12410 pRenderer->DrawTextureTransparent(v52, v51, v50);
12411 sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], dword_F8B168[v122], v122 + 1);
12412 v49 = v122;
12413 }
12414 ++v49;
12415 v122 = v49;
12416 }
12417 while ( v49 < 6 );
12418 v122 = 0;
12419 do
12420 {
12421 if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 54] )
12422 {
12423 v54 = dword_F8B168[v122 + 6];
12424 v55 = 306 - v54->uTextureHeight;
12425 v56 = 75 * v122 - v54->uTextureWidth / 2 + 40;
12426 if ( v122 )
12427 {
12428 if ( v122 == 5 )
12429 {
12430 v57 = dword_F8B168[11]->uTextureWidth;
12431 if ( (signed int)v56 > 457 - v57 )
12432 v56 = 457 - v57;
12433 }
12434 }
12435 else
12436 {
12437 if ( (signed int)v56 < 18 )
12438 v56 = 18;
12439 }
12440 pRenderer->DrawTextureTransparent(v56, v55, v54);
12441 sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], dword_F8B168[v122 + 6], v122 + 7);
12442 }
12443 ++v122;
12444 }
12445 while ( v122 < 6 );
12446 }
12447 else
12448 {
12449 do
12450 {
12451 if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
12452 {
12453 v58 = dword_F8B168[v49];
12454 v59 = 152 - v58->uTextureHeight;
12455 if ( (signed int)v59 < 1 )
12456 v59 = 0;
12457 v60 = 75 * v49 - v58->uTextureWidth / 2 + 40;
12458 if ( v122 )
12459 {
12460 if ( v122 == 5 )
12461 {
12462 v61 = dword_F8B168[5]->uTextureWidth;
12463 if ( (signed int)v60 > 457 - v61 )
12464 v60 = 457 - v61;
12465 }
12466 }
12467 else
12468 {
12469 if ( (signed int)v60 < 18 )
12470 v60 = 18;
12471 }
12472 pRenderer->DrawTextureTransparent(v60, v59, v58);
12473 sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], dword_F8B168[v122], v122 + 1);
12474 v49 = v122;
12475 }
12476 ++v49;
12477 v122 = v49;
12478 }
12479 while ( v49 < 6 );
12480 v122 = 0;
12481 do
12482 {
12483 if ( pParty->field_C59C[9 * (v122 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 778] )
12484 {
12485 v62 = dword_F8B168[v122 + 6];
12486 v63 = 306 - v62->uTextureHeight;
12487 if ( (signed int)v63 < 1 )
12488 v63 = 0;
12489 v64 = 75 * v122 - v62->uTextureWidth / 2 + 40;
12490 if ( v122 )
12491 {
12492 if ( v122 == 5 )
12493 {
12494 v65 = dword_F8B168[11]->uTextureWidth;
12495 if ( (signed int)v64 > 457 - v65 )
12496 v64 = 457 - v65;
12497 }
12498 }
12499 else
12500 {
12501 if ( (signed int)v64 < 18 )
12502 v64 = 18;
12503 }
12504 pRenderer->DrawTextureTransparent(v64, v63, v62);
12505 sub_40F92A(&pRenderer->pActiveZBuffer[v64 + 640 * v63], dword_F8B168[v122 + 6], v122 + 7);
12506 }
12507 ++v122;
12508 }
12509 while ( v122 < 6 );
12510 }
12511 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
12512 if ( result )
12513 {
12514 v66 = 0;
12515 v117 = 0;
12516 if ( dword_F8B19C == 2 )
12517 {
12518 do
12519 {
12520 if ( pParty->field_777C[9 * (v66 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
12521 ++v117;
12522 ++v66;
12523 }
12524 while ( v66 < 12 );
12525 }
12526 else
12527 {
12528 do
12529 {
12530 if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
12531 ++v117;
12532 ++v66;
12533 }
12534 while ( v66 < 12 );
12535 }
12536 v67 = GetAsyncKeyState(VK_CONTROL);
12537 v68 = _this->CanSteal();
12538 Str = (char *)v68;
12539 if ( v67 && v68 )
12540 {
12541 v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item"
12542 }
12543 else
12544 {
12545 v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy"
12546 if ( dword_F8B19C != 2 )
12547 v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy"
12548 }
12549 sub_4B46A5(v69, 0);
12550 if ( !v117 )
12551 return (int)v112._4B1854(
12552 __PAIR__(
12553 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C + 1],
12554 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C])
12555 - pParty->uTimePlayed);
12556 v70 = pMouse->GetCursorPos(&v102);
12557 result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y];
12558 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
12559 {
12560 v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
12561 v117 = v71;
12562 v72 = (int)ptr_507BC0->ptr_1C;
12563 v73 = 9 * (v71 + 12 * v72);
12564 v74 = (ItemGen *)&pParty->field_777C[v73];
12565 if ( dword_F8B19C != 2 )
12566 v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
12567 if ( v67 && Str )
12568 {
12569 v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
12570 v96 = 0;
12571 v94 = 2;
12572 v93 = ptr_507BC0->ptr_1C;
12573 v90 = v74;
12574 v9 = uActiveCharacter - 1;
12575 }
12576 else
12577 {
12578 v96 = 0;
12579 v94 = 2;
12580 v93 = ptr_507BC0->ptr_1C;
12581 v90 = v74;
12582 uPlayerID = uActiveCharacter - 1;
12583 v75 = _this->_490EEE(v74, 3, v72, 2);
12584 v9 = uPlayerID;
12585 v10 = (char *)pMerchantsBuyPhrases[v75];
12586 }
12587 goto LABEL_35;
12588 }
12589 }
12590 return result;
12591 }
12592
12593 //----- (004BC49B) --------------------------------------------------------
12594 void __thiscall sub_4BC49B(unsigned int _this)
12595 {
12596 unsigned int v1; // esi@1
12597 NPCData *v2; // ebp@1
12598 unsigned int v3; // eax@1
12599 int v4; // ecx@10
12600 signed int v5; // edi@14
12601 char *v6; // esi@15
12602 const char *v7; // ecx@22
12603 signed int v8; // edi@37
12604 unsigned int v9; // eax@56
12605 unsigned int v10; // ecx@57
12606 void *v11; // [sp-Ch] [bp-1Ch]@46
12607 int v12; // [sp-8h] [bp-18h]@46
12608 char *v13; // [sp-8h] [bp-18h]@60
12609 size_t v14; // [sp-4h] [bp-14h]@46
12610 const char *v15; // [sp-4h] [bp-14h]@60
12611
12612 v1 = _this;
12613 v2 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
12614 v3 = v1;
12615 uDialogueType = v1;
12616 if ( !v2->uFlags )
12617 {
12618 v2->uFlags = 1;
12619 v3 = uDialogueType;
12620 }
12621 if ( (signed int)v3 > 22 )
12622 {
12623 if ( v3 == 23 )
12624 {
12625 v4 = v2->evte;
12626 goto LABEL_74;
12627 }
12628 if ( v3 == 24 )
12629 {
12630 v4 = v2->evtf;
12631 goto LABEL_74;
12632 }
12633 if ( v3 != 76 )
12634 {
12635 if ( v3 == 77 )
12636 {
12637 byte_F8B1EC ^= 1u;
12638 }
12639 else
12640 {
12641 if ( (signed int)v3 > 84 && (signed int)v3 <= 88 )
12642 {
12643 ArenaFight();
12644 return;
12645 }
12646 }
12647 goto LABEL_87;
12648 }
12649 if ( v2->uFlags & 0x80 )
12650 {
12651 v8 = 0;
12652 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
12653 {
12654 v6 = (char *)pNPCStats->pNewNPCData;
12655 while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) )
12656 {
12657 ++v8;
12658 v6 += 76;
12659 if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
12660 goto LABEL_44;
12661 }
12662 goto LABEL_43;
12663 }
12664 LABEL_44:
12665 if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, v2->pName) )
12666 {
12667 if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, v2->pName) )
12668 {
12669 LABEL_51:
12670 pParty->field_709 = 0;
12671 sub_44A56A();
12672 dword_591084 = 0;
12673 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12674 {
12675 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
12676 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
12677 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
12678 ++pMessageQueue_50CBD0->uNumMessages;
12679 }
12680 goto LABEL_89;
12681 }
12682 v14 = 76;
12683 v12 = 0;
12684 v11 = &pParty->pHirelings[1];
12685 }
12686 else
12687 {
12688 v14 = 76;
12689 v12 = 0;
12690 v11 = pParty->pHirelings;
12691 }
12692 memset(v11, v12, v14);
12693 goto LABEL_51;
12694 }
12695 if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
12696 {
12697 v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
12698 LABEL_64:
12699 ShowStatusBarString(v7, 2u);
12700 goto LABEL_87;
12701 }
12702 v9 = v2->uProfession;
12703 if ( v9 != 51 )
12704 {
12705 v10 = *(&pNPCStats->field_13A58 + 5 * v9);
12706 if ( pParty->uNumGold < v10 )
12707 {
12708 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
12709 byte_F8B1EC = 0;
12710 uDialogueType = 13;
12711 if ( uActiveCharacter )
12712 pPlayers[uActiveCharacter]->PlaySound(38, 0);
12713 v7 = pGlobalTXT_LocalizationStrings[155];
12714 goto LABEL_64;
12715 }
12716 Party::TakeGold(v10);
12717 }
12718 LOBYTE(v2->uFlags) |= 0x80u;
12719 if ( pParty->pHirelings[0].pName )
12720 {
12721 memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1]));
12722 v15 = v2->pName;
12723 v13 = pParty->pHireling2Name;
12724 }
12725 else
12726 {
12727 memcpy(pParty->pHirelings, v2, 0x4Cu);
12728 v15 = v2->pName;
12729 v13 = pParty->pHireling1Name;
12730 }
12731 strcpy(v13, v15);
12732 pParty->field_709 = 0;
12733 sub_44A56A();
12734 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12735 {
12736 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
12737 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
12738 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
12739 ++pMessageQueue_50CBD0->uNumMessages;
12740 }
12741 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
12742 pDialogue_SpeakingActor->uAIState = Removed;
12743 if ( uActiveCharacter )
12744 pPlayers[uActiveCharacter]->PlaySound(61, 0);
12745 goto LABEL_87;
12746 }
12747 if ( v3 == 22 )
12748 {
12749 v4 = v2->evtd;
12750 goto LABEL_74;
12751 }
12752 if ( v3 == 9 )
12753 {
12754 if ( !sub_4BB756(v2->uProfession) )
12755 {
12756 if ( v2->uProfession != 41 )
12757 v2->bHasUsedTheAbility = 1;
12758 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12759 {
12760 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
12761 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
12762 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
12763 ++pMessageQueue_50CBD0->uNumMessages;
12764 }
12765 goto LABEL_87;
12766 }
12767 v7 = pGlobalTXT_LocalizationStrings[140];
12768 goto LABEL_64;
12769 }
12770 if ( v3 == 13 )
12771 {
12772 if ( !(v2->uFlags & 0x80) )
12773 {
12774 sub_4B3E1E();
12775 byte_F8B1EC = 0;
12776 goto LABEL_87;
12777 }
12778 v5 = 0;
12779 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
12780 {
12781 v6 = (char *)pNPCStats->pNewNPCData;
12782 while ( !(v6[8] & 0x80) || strcmp(v2->pName, *(const char **)v6) )
12783 {
12784 ++v5;
12785 v6 += 76;
12786 if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
12787 goto LABEL_44;
12788 }
12789 LABEL_43:
12790 v6[8] &= 0x7Fu;
12791 goto LABEL_44;
12792 }
12793 goto LABEL_44;
12794 }
12795 if ( v3 == 19 )
12796 {
12797 v4 = v2->bDrawSomeAnim;
12798 goto LABEL_74;
12799 }
12800 if ( v3 == 20 )
12801 {
12802 v4 = v2->evtb;
12803 goto LABEL_74;
12804 }
12805 if ( v3 == 21 )
12806 {
12807 v4 = v2->evtc;
12808 LABEL_74:
12809 if ( v4 < 200 || v4 > 310 )
12810 {
12811 if ( v4 < 400 || v4 > 410 )
12812 {
12813 switch ( v4 )
12814 {
12815 case 139:
12816 sub_4B1ECE();
12817 break;
12818 case 311:
12819 sub_4BBA85_bounties();
12820 break;
12821 case 399:
12822 sub_4BBCDD();
12823 break;
12824 default:
12825 _5C3420_pDecoration = (LevelDecoration *)1;
12826 ptr_F8B1E8 = 0;
12827 EventProcessor(v4, 0, 1);
12828 _5C3420_pDecoration = 0;
12829 break;
12830 }
12831 }
12832 else
12833 {
12834 dword_F8B1D8 = v3;
12835 sub_4B3EF0(v4 - 400);
12836 }
12837 }
12838 else
12839 {
12840 sub_4B3FE5(v4);
12841 }
12842 }
12843 LABEL_87:
12844 if ( !dword_7241C8 )
12845 pGame->Draw();
12846 LABEL_89:
12847 dword_7241C8 = 0;
12848 }
12849
12850
12851
12852 //----- (004BDAAF) --------------------------------------------------------
12853 bool __fastcall sub_4BDAAF(ItemGen *a1, int _2da_idx)
12854 {
12855 int v2; // edx@1
12856 unsigned int v3; // esi@1
12857 unsigned int v4; // eax@1
12858 signed int v5; // edi@1
12859 int v6; // edx@8
12860 int v7; // edx@9
12861 int v8; // edx@10
12862 unsigned __int8 v9; // zf@16
12863 char v10; // sf@16
12864 unsigned __int8 v11; // of@16
12865
12866 auto a2 = _2da_idx;
12867 //v2 = p2DEvents_minus1___00[26 * a2];
12868 v2 = p2DEvents[a2 - 1].uType;
12869 v3 = a1->uItemID;
12870 v4 = a1->uItemID;
12871 v5 = pItemsTable->pItems[v4].uEquipType;
12872 if ( (v2 != 4 || (signed int)v3 < 740 || (signed int)v3 > 771)
12873 && ((signed int)v3 >= 600 || (signed int)v3 >= 529 && (signed int)v3 <= 599)
12874 || BYTE1(a1->uAttributes) & 1 )
12875 return 0;
12876 v6 = v2 - 1;
12877 if ( !v6 )
12878 {
12879 v11 = __OFSUB__(v5, 2);
12880 v9 = v5 == 2;
12881 v10 = v5 - 2 < 0;
12882 goto LABEL_23;
12883 }
12884 v7 = v6 - 1;
12885 if ( v7 )
12886 {
12887 v8 = v7 - 1;
12888 if ( !v8 )
12889 {
12890 if ( pItemsTable->pItems[v4].uSkillType != 38 )
12891 return v5 == 16;
12892 return 1;
12893 }
12894 if ( v8 != 1 || v5 < 13 )
12895 return 0;
12896 if ( v5 <= 14 )
12897 return 1;
12898 if ( v5 != 17 || (signed int)v3 < 740 )
12899 return 0;
12900 v11 = __OFSUB__(v3, 771);
12901 v9 = v3 == 771;
12902 v10 = ((v3 - 771) & 0x80000000u) != 0;
12903 LABEL_23:
12904 if ( !((unsigned __int8)(v10 ^ v11) | v9) )
12905 return 0;
12906 return 1;
12907 }
12908 if ( v5 >= 3 )
12909 {
12910 v11 = __OFSUB__(v5, 9);
12911 v9 = v5 == 9;
12912 v10 = v5 - 9 < 0;
12913 goto LABEL_23;
12914 }
12915 return 0;
12916 }
12917
12918
12919
12920 //----- (004B5D7C) --------------------------------------------------------
12921 int __cdecl sub_4B5D7C()
12922 {
12923 GUIWindow *v0; // ebx@1
12924 Player *v1; // edi@1
12925 signed int v2; // ebx@1
12926 int v3; // edi@6
12927 int result; // eax@11
12928 unsigned int v5; // ebx@13
12929 int v6; // esi@13
12930 signed int v7; // esi@17
12931 int v8; // esi@22
12932 signed int v9; // ecx@22
12933 char *v10; // eax@22
12934 const char *v11; // ecx@26
12935 POINT *v12; // esi@30
12936 int v13; // ecx@30
12937 void *v14; // ST1C_4@31
12938 ItemGen *v15; // ST18_4@31
12939 int v16; // ST10_4@31
12940 int v17; // eax@31
12941 char *v18; // edx@31
12942 int v19; // eax@32
12943 GUIWindow *v20; // edi@35
12944 int v21; // esi@35
12945 int v22; // eax@35
12946 unsigned int v23; // eax@36
12947 int v24; // eax@39
12948 int v25; // eax@40
12949 int v26; // ecx@47
12950 GUIButton *v27; // eax@49
12951 GUIButton *v28; // esi@49
12952 unsigned int v29; // eax@49
12953 char *v30; // eax@52
12954 int v31; // eax@55
12955 unsigned int v32; // ecx@55
12956 int v33; // eax@55
12957 unsigned __int16 v34; // ax@55
12958 int v35; // eax@58
12959 const char *v36; // ST20_4@61
12960 unsigned __int16 v37; // ST1C_2@61
12961 int v38; // eax@61
12962 GUIWindow *v39; // [sp-18h] [bp-304h]@31
12963 int v40; // [sp-14h] [bp-300h]@31
12964 int v41; // [sp-10h] [bp-2FCh]@31
12965 unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31
12966 char *v43; // [sp-8h] [bp-2F4h]@31
12967 unsigned int v44; // [sp-4h] [bp-2F0h]@31
12968 char Dest[100]; // [sp+Ch] [bp-2E0h]@3
12969 char v46[100]; // [sp+70h] [bp-27Ch]@3
12970 char v47[100]; // [sp+D4h] [bp-218h]@3
12971 char v48[100]; // [sp+138h] [bp-1B4h]@3
12972 char v49[100]; // [sp+19Ch] [bp-150h]@3
12973 POINT v50; // [sp+264h] [bp-88h]@30
12974 POINT v51; // [sp+26Ch] [bp-80h]@30
12975 GUIWindow v52; // [sp+274h] [bp-78h]@1
12976 signed int v53; // [sp+27Ch] [bp-70h]@1
12977 signed int v54; // [sp+284h] [bp-68h]@1
12978 int v55; // [sp+2C8h] [bp-24h]@47
12979 int v56; // [sp+2CCh] [bp-20h]@1
12980 int v57; // [sp+2D0h] [bp-1Ch]@1
12981 Player *v58; // [sp+2D4h] [bp-18h]@1
12982 unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
12983 char *Str; // [sp+2DCh] [bp-10h]@35
12984 int v61; // [sp+2E0h] [bp-Ch]@35
12985 unsigned int v62; // [sp+2E4h] [bp-8h]@13
12986 int v63; // [sp+2E8h] [bp-4h]@1
12987
12988 v0 = ptr_507BC0;
12989 memcpy(&v52, ptr_507BC0, sizeof(v52));
12990 v58 = pPlayers[uActiveCharacter];
12991 v1 = v58;
12992 v52.uFrameX = 483;
12993 v53 = 148;
12994 v54 = 334;
12995 v56 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
12996 v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
12997 //v2 = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C] * 500.0);
12998 v2 = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0);
12999 v63 = v2 * (100 - v1->GetMerchant()) / 100;
13000 if ( v63 < v2 / 3 )
13001 v63 = v2 / 3;
13002 strcpy(Dest, "");
13003 strcpy(v46, "");
13004 strcpy(v47, "");
13005 strcpy(v48, "");
13006 strcpy(v49, "");
13007 if ( dword_F8B19C != 1 )
13008 {
13009 if ( dword_F8B19C != 18 )
13010 {
13011 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
13012 {
13013 v3 = (int)(&v1->uIntelligence + dword_F8B19C);
13014 if ( *(short *)v3 )
13015 {
13016 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]);
13017 ShowStatusBarString(pTmpBuf, 2u);
13018 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
13019 }
13020 else
13021 {
13022 if ( pParty->uNumGold < v63 )
13023 {
13024 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
13025 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
13026 }
13027 else
13028 {
13029 Party::TakeGold(v63);
13030 *(short *)v3 = 1;
13031 }
13032 }
13033 }
13034 result = pMessageQueue_50CBD0->uNumMessages;
13035 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
13036 {
13037 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
13038 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
13039 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
13040 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
13041 ++pMessageQueue_50CBD0->uNumMessages;
13042 }
13043 return result;
13044 }
13045 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
13046 v5 = 0;
13047 v6 = 0;
13048 v62 = 0;
13049 v63 = 32;
13050 do
13051 {
13052 if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)ptr_507BC0->ptr_1C)) )
13053 {
13054 pRenderer->DrawTextureTransparent(v63, 0x5Au, dword_F8B168[v6]);
13055 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), dword_F8B168[v6], v6 + 1);
13056 v1 = v58;
13057 }
13058 v63 += 70;
13059 v62 += 280;
13060 ++v6;
13061 }
13062 while ( v63 < 452 );
13063 v62 = 1680;
13064 v7 = 6;
13065 v63 = 32;
13066 do
13067 {
13068 if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)ptr_507BC0->ptr_1C)) )
13069 {
13070 pRenderer->DrawTextureTransparent(v63, 0xFAu, dword_F8B168[v7]);
13071 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), dword_F8B168[v7], v7 + 1);
13072 v1 = v58;
13073 }
13074 v63 += 70;
13075 v62 += 280;
13076 ++v7;
13077 }
13078 while ( v63 < 452 );
13079 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
13080 if ( result )
13081 {
13082 v8 = 0;
13083 v9 = 12;
13084 v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)ptr_507BC0->ptr_1C);
13085 do
13086 {
13087 if ( *(int *)v10 )
13088 ++v8;
13089 v10 += 36;
13090 --v9;
13091 }
13092 while ( v9 );
13093 GetAsyncKeyState(17);
13094 v11 = pGlobalTXT_LocalizationStrings[195];
13095 if ( dword_F8B19C != 2 )
13096 v11 = pGlobalTXT_LocalizationStrings[196];
13097 sub_4B46A5(v11, 0);
13098 if ( !v8 )
13099 return (int)v52._4B1854(
13100 __PAIR__(
13101 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)ptr_507BC0->ptr_1C + 44472],
13102 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)ptr_507BC0->ptr_1C + 44468])
13103 - pParty->uTimePlayed);
13104 v12 = pMouse->GetCursorPos(&v51);
13105 result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y];
13106 v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF;
13107 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
13108 {
13109 v14 = ptr_507BC0->ptr_1C;
13110 v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14));
13111 v16 = (int)ptr_507BC0->ptr_1C;
13112 uPlayerID = uActiveCharacter - 1;
13113 v17 = v1->_490EEE(
13114 (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14,
13115 3,
13116 v16,
13117 2);
13118 v18 = sub_495461((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);
13119 v44 = 3;
13120 v43 = v18;
13121 v42 = v56;
13122 v41 = 0;
13123 v40 = 0;
13124 v39 = &v52;
13125 LABEL_32:
13126 v19 = pFontArrus->CalcTextHeight(v18, v39, v40, v41);
13127 return (int)v52.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, v42, v43, v44);
13128 }
13129 }
13130 return result;
13131 }
13132 if ( !(unsigned __int16)_449B57_test_bit(
13133 (unsigned __int8 *)v1->field_152,
13134 word_4F0704[2 * (unsigned int)ptr_507BC0->ptr_1C]) )
13135 {
13136 v36 = pNPCTopics[121].pText;
13137 v37 = v57;
13138 v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &v52, 0, 0);
13139 v52.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, v37, v36, 3u);
13140 result = (int)pDialogueWindow;
13141 pDialogueWindow->pNumPresenceButton = 0;
13142 return result;
13143 }
13144 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
13145 if ( !result )
13146 return result;
13147 v20 = pDialogueWindow;
13148 v5 = 0;
13149 v62 = 0;
13150 Str = 0;
13151 v21 = pDialogueWindow->pStartingPosActiveItem;
13152 v22 = v21 + pDialogueWindow->pNumPresenceButton;
13153 v61 = 0;
13154 if ( v21 >= v22 )
13155 goto LABEL_64;
13156 do
13157 {
13158 v23 = v20->GetControl(v21)->uControlParam;
13159 if ( v23 == 18 )
13160 {
13161 v25 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &v52, 0, 0);
13162 v62 += v25;
13163 ++v61;
13164 }
13165 else
13166 {
13167 __debugbreak();
13168 //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
13169 // or
13170 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
13171 // or
13172 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
13173
13174 //if ( *(&byte_4ED94C[37 * v58->uClass] + v23) && !*(&v58->uIntelligence + v23) )
13175 {
13176 v24 = pFontArrus->CalcTextHeight(pClassNames[v23 + 20], &v52, 0, 0);
13177 v62 += v24;
13178 ++v61;
13179 ++Str;
13180 }
13181 }
13182 ++v21;
13183 }
13184 while ( v21 < v20->pNumPresenceButton + v20->pStartingPosActiveItem );
13185 if ( !v61 )
13186 {
13187 LABEL_64:
13188 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->uClass]);
13189 strcat(pTmpBuf, "\n \n");
13190 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
13191 v18 = pTmpBuf;
13192 v44 = 3;
13193 v43 = pTmpBuf;
13194 v42 = v57;
13195 v41 = 0;
13196 v40 = 0;
13197 v39 = &v52;
13198 goto LABEL_32;
13199 }
13200 if ( Str )
13201 {
13202 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63);
13203 v52.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
13204 }
13205 v63 = (signed int)(149 - v62) / v61;
13206 if ( v63 > 32 )
13207 v63 = 32;
13208 result = v20->pStartingPosActiveItem;
13209 v26 = (signed int)(149 - v61 * v63 - v62) / 2 - v63 / 2 + 162;
13210 v62 = result;
13211 v55 = v26;
13212 if ( result < result + v20->pNumPresenceButton )
13213 {
13214 v61 = 2;
13215 while ( 1 )
13216 {
13217 v27 = v20->GetControl(v62);
13218 v28 = v27;
13219 v29 = v27->uControlParam;
13220 if ( v29 == 18 )
13221 break;
13222
13223 __debugbreak();
13224 //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
13225 // or
13226 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
13227 // or
13228 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
13229
13230 //if ( *(&byte_4ED94C[37 * v58->uClass] + v29) && !*(&v58->uIntelligence + v29) )
13231 {
13232 v30 = pClassNames[v29 + 20];
13233 LABEL_55:
13234 Str = v30;
13235 v28->uY = v63 + v55;
13236 v31 = pFontArrus->CalcTextHeight(v30, &v52, 0, 0);
13237 v32 = v28->uY;
13238 v28->uHeight = v31;
13239 v33 = v32 + v31 - 1;
13240 v28->uW = v33;
13241 v55 = v33;
13242 v34 = v57;
13243 if ( pDialogueWindow->pCurrentPosActiveItem != v61 )
13244 v34 = v56;
13245 v52.DrawTitleText(pFontArrus, 0, v32, v34, Str, 3u);
13246 goto LABEL_58;
13247 }
13248 v28->uW = 0;
13249 v28->uHeight = 0;
13250 v28->uY = 0;
13251 LABEL_58:
13252 v35 = v20->pStartingPosActiveItem;
13253 ++v62;
13254 result = v20->pNumPresenceButton + v35;
13255 ++v61;
13256 if ( (signed int)v62 >= result )
13257 return result;
13258 }
13259 v30 = pGlobalTXT_LocalizationStrings[400];
13260 goto LABEL_55;
13261 }
13262 return result;
13263 }
13264
13265
13266
13267 //----- (004B705E) --------------------------------------------------------
13268 int __cdecl sub_4B705E()
13269 {
13270 GUIWindow *v0; // ebx@1
13271 Player *v1; // esi@1
13272 int v2; // edi@1
13273 int result; // eax@4
13274 GUIWindow *v4; // edi@6
13275 void *v5; // eax@6
13276 int v6; // eax@6
13277 unsigned int v7; // eax@8
13278 int v8; // ecx@8
13279 unsigned int v9; // eax@9
13280 int v10; // eax@11
13281 int v11; // eax@12
13282 GUIWindow *v12; // ecx@16
13283 int v13; // edx@16
13284 GUIButton *v14; // eax@19
13285 GUIButton *v15; // edi@19
13286 int v16; // eax@19
13287 const char *v17; // eax@21
13288 int v18; // eax@21
13289 unsigned int v19; // ecx@21
13290 int v20; // eax@21
13291 unsigned __int16 v21; // ax@21
13292 unsigned __int16 v22; // ST14_2@27
13293 int v23; // eax@27
13294 double v24; // st7@28
13295 unsigned int v25; // ebx@28
13296 DDM_DLV_Header *v26; // edi@29
13297 int v27; // eax@31
13298 int v28; // eax@32
13299 unsigned int v29; // ecx@34
13300 unsigned int v30; // edx@36
13301 unsigned int v31; // edx@38
13302 unsigned int v32; // edx@40
13303 unsigned int v33; // edx@42
13304 unsigned int v34; // edx@44
13305 int v35; // edi@50
13306 signed int v36; // eax@50
13307 unsigned __int8 v37; // al@54
13308 int v38; // ecx@54
13309 GUIWindow *v39; // eax@56
13310 unsigned __int8 v40; // al@61
13311 GUIButton *v41; // edi@64
13312 int v42; // esi@66
13313 GUIWindow *v43; // ecx@66
13314 int v44; // edi@66
13315 int v45; // eax@68
13316 signed int v46; // edi@69
13317 int v47; // edi@71
13318 GUIButton *v48; // eax@73
13319 const char *v49; // edx@73
13320 GUIButton *v50; // esi@73
13321 int v51; // eax@73
13322 unsigned int v52; // ecx@73
13323 unsigned __int16 v53; // ax@73
13324 char a1[100]; // [sp+10h] [bp-1B4h]@64
13325 char Dest; // [sp+74h] [bp-150h]@66
13326 char v56; // [sp+D8h] [bp-ECh]@66
13327 GUIWindow v57; // [sp+13Ch] [bp-88h]@1
13328 __int64 v58; // [sp+190h] [bp-34h]@1
13329 __int64 v59; // [sp+198h] [bp-2Ch]@1
13330 __int64 v60; // [sp+1A0h] [bp-24h]@1
13331 GUIWindow *v61; // [sp+1ACh] [bp-18h]@6
13332 unsigned int v62; // [sp+1B0h] [bp-14h]@8
13333 unsigned __int8 v63; // [sp+1B7h] [bp-Dh]@64
13334 int v64; // [sp+1B8h] [bp-Ch]@6
13335 unsigned int v65; // [sp+1BCh] [bp-8h]@6
13336 DDM_DLV_Header *v66; // [sp+1C0h] [bp-4h]@6
13337
13338 v0 = ptr_507BC0;
13339 memcpy(&v57, ptr_507BC0, sizeof(v57));
13340 v57.uFrameX = 483;
13341 v57.uFrameWidth = 148;
13342 v57.uFrameZ = 334;
13343 HIDWORD(v58) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
13344 HIDWORD(v59) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
13345 v1 = pPlayers[uActiveCharacter];
13346 //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
13347 v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
13348 HIDWORD(v60) = v2;
13349 if ( dword_F8B19C != 1 )
13350 {
13351 if ( dword_F8B19C != 10 )
13352 {
13353 if ( dword_F8B19C != 11 )
13354 {
13355 result = dword_F8B19C - 96;
13356 if ( dword_F8B19C == 96 )
13357 {
13358 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
13359 if ( result )
13360 {
13361 v4 = pDialogueWindow;
13362 v61 = pDialogueWindow;
13363 v5 = ptr_507BC0->ptr_1C;
13364 v66 = 0;
13365 //v65 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v5] * 500.0);
13366 v65 = (signed __int64)(p2DEvents[(signed int)v5 - 1].flt_24 * 500.0);
13367 v6 = v1->GetMerchant();
13368 v64 = (signed int)(v65 * (100 - v6)) / 100;
13369 if ( v64 < (signed int)v65 / 3 )
13370 v64 = (signed int)v65 / 3;
13371 v7 = v4->pStartingPosActiveItem;
13372 v8 = v7 + v4->pNumPresenceButton;
13373 v65 = 0;
13374 v62 = v7;
13375 if ( (signed int)v7 >= v8 )
13376 goto LABEL_78;
13377 do
13378 {
13379 v9 = v4->GetControl(v62)->uControlParam - 36;
13380 if ( byte_4ED970_skill_learn_ability_by_class_table[v1->uClass][v9] && !v1->pActiveSkills[v9] )
13381 {
13382 v10 = pFontArrus->CalcTextHeight(pSkillNames[v9], &v57, 0, 0);
13383 v66 = (DDM_DLV_Header *)((char *)v66 + v10);
13384 ++v65;
13385 }
13386 v11 = v4->pStartingPosActiveItem;
13387 ++v62;
13388 }
13389 while ( (signed int)v62 < v4->pNumPresenceButton + v11 );
13390 if ( v65 )
13391 {
13392 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v64);
13393 v57.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
13394 v64 = (149 - (signed int)v66) / (signed int)v65;
13395 if ( v64 > 32 )
13396 v64 = 32;
13397 v65 = (signed int)(149 - v65 * v64 - (int)v66) / 2 - v64 / 2 + 162;
13398 v12 = v61;
13399 result = v61->pStartingPosActiveItem;
13400 v13 = result + v61->pNumPresenceButton;
13401 v62 = v61->pStartingPosActiveItem;
13402 if ( result < v13 )
13403 {
13404 v66 = (DDM_DLV_Header *)2;
13405 while ( 1 )
13406 {
13407 v14 = v12->GetControl(v62);
13408 v15 = v14;
13409 v16 = v14->uControlParam - 36;
13410 if ( !byte_4ED970_skill_learn_ability_by_class_table[v1->uClass][v16] || v1->pActiveSkills[v16] )
13411 {
13412 v15->uW = 0;
13413 v15->uHeight = 0;
13414 v15->uY = 0;
13415 }
13416 else
13417 {
13418 v17 = pSkillNames[v16];
13419 v15->uY = v64 + v65;
13420 HIDWORD(v60) = (uint32)v17;
13421 v18 = pFontArrus->CalcTextHeight(v17, &v57, 0, 0);
13422 v19 = v15->uY;
13423 v15->uHeight = v18;
13424 v20 = v19 + v18 - 1;
13425 v15->uW = v20;
13426 v65 = v20;
13427 v21 = WORD2(v59);
13428 if ( (DDM_DLV_Header *)pDialogueWindow->pCurrentPosActiveItem != v66 )
13429 v21 = WORD2(v58);
13430 v57.DrawTitleText(pFontArrus, 0, v19, v21, (const char *)HIDWORD(v60), 3u);
13431 }
13432 result = (int)v61;
13433 ++v62;
13434 v66 = (DDM_DLV_Header *)((char *)v66 + 1);
13435 if ( (signed int)v62 >= v61->pNumPresenceButton + v61->pStartingPosActiveItem )
13436 break;
13437 v12 = v61;
13438 }
13439 }
13440 }
13441 else
13442 {
13443 LABEL_78:
13444 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
13445 strcat(pTmpBuf, "\n \n");
13446 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
13447 v22 = WORD2(v59);
13448 v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v57, 0, 0);
13449 result = (int)v57.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
13450 }
13451 }
13452 }
13453 return result;
13454 }
13455 //v24 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
13456 v24 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
13457 v25 = 0;
13458 if ( pParty->uNumGold >= (unsigned int)(signed __int64)v24 )
13459 {
13460 Party::TakeGold((signed __int64)v24);
13461 v26 = &pOutdoor->ddm;
13462 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
13463 v26 = &pIndoor->dlv;
13464 v27 = v26->uReputation;
13465 v66 = v26;
13466 if ( v27 > -5 )
13467 {
13468 v28 = v27 - 1;
13469 v26->uReputation = v28;
13470 if ( v28 < -5 )
13471 v26->uReputation = -5;
13472 }
13473 v29 = uActiveCharacter;
13474 if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 )
13475 {
13476 if ( v26->uReputation <= -5 )
13477 {
13478 v30 = pParty->uDaysPlayed % 7 + 1;
13479 LOBYTE(v30) = v30 | 0x80;
13480 _42777D_CastSpell_UseWand_ShootArrow(12, uActiveCharacter - 1, v30, 48, 0);
13481 v29 = uActiveCharacter;
13482 }
13483 if ( v26->uReputation <= -10 )
13484 {
13485 v31 = pParty->uDaysPlayed % 7 + 1;
13486 LOBYTE(v31) = v31 | 0x80;
13487 _42777D_CastSpell_UseWand_ShootArrow(50, v29 - 1, v31, 48, 0);
13488 v29 = uActiveCharacter;
13489 v26 = v66;
13490 }
13491 if ( v26->uReputation <= -15 )
13492 {
13493 v32 = pParty->uDaysPlayed % 7 + 1;
13494 LOBYTE(v32) = v32 | 0x80;
13495 _42777D_CastSpell_UseWand_ShootArrow(75, v29 - 1, v32, 48, 0);
13496 v29 = uActiveCharacter;
13497 v26 = v66;
13498 }
13499 if ( v26->uReputation <= -20 )
13500 {
13501 v33 = pParty->uDaysPlayed % 7 + 1;
13502 LOBYTE(v33) = v33 | 0x80;
13503 _42777D_CastSpell_UseWand_ShootArrow(86, v29 - 1, v33, 48, 0);
13504 v29 = uActiveCharacter;
13505 v26 = v66;
13506 }
13507 if ( v26->uReputation <= -25 )
13508 {
13509 v34 = pParty->uDaysPlayed % 7 + 1;
13510 LOBYTE(v34) = v34 | 0x80;
13511 _42777D_CastSpell_UseWand_ShootArrow(85, v29 - 1, v34, 48, 0);
13512 v29 = uActiveCharacter;
13513 }
13514 }
13515 ++byte_F8B1EF[v29];
13516 v1->PlaySound(83, 0);
13517 ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2u);
13518 goto LABEL_46;
13519 }
13520 goto LABEL_55;
13521 }
13522 result = v1->_4B6FF9();
13523 if ( !result )
13524 return result;
13525 v25 = 0;
13526 if ( pParty->uNumGold < v2 )
13527 {
13528 LABEL_55:
13529 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
13530 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
13531 goto LABEL_46;
13532 }
13533 Party::TakeGold(v2);
13534 v35 = LODWORD(v1->pConditions[17]);
13535 v59 = v1->pConditions[14];
13536 v58 = v1->pConditions[15];
13537 v60 = v1->pConditions[16];
13538 v61 = (GUIWindow *)HIDWORD(v1->pConditions[17]);
13539 memset(v1, 0, 0xA0u);
13540 v1->sHealth = v1->GetMaxHealth();
13541 v1->sMana = v1->GetMaxMana();
13542 v36 = (signed int)ptr_507BC0->ptr_1C;
13543 if ( v36 != 78 && (v36 <= 80 || v36 > 82) )
13544 {
13545 if ( (unsigned int)v61 | v35 )
13546 {
13547 v37 = LOBYTE(v1->field_1928);
13548 v38 = v1->field_1924;
13549 v1->uFace = v37;
13550 v1->uVoiceID = v38;
13551 ReloadPlayerPortraits(uActiveCharacter - 1, (char)v37);
13552 }
13553 goto LABEL_63;
13554 }
13555 v39 = v61;
13556 if ( (unsigned int)v61 | v35 )
13557 {
13558 LODWORD(v1->pConditions[17]) = v35;
13559 }
13560 else
13561 {
13562 if ( !v60 && !v58 && !v59 )
13563 goto LABEL_63;
13564 v1->field_1928 = v1->uFace;
13565 v1->field_1924 = v1->uVoiceID;
13566 v1->SetCondition(0x11u, 1);
13567 v1->uVoiceID = (v1->GetSexByVoice() != 0) + 23;
13568 v40 = (v1->GetSexByVoice() != 0) + 23;
13569 v1->uFace = v40;
13570 ReloadPlayerPortraits(uActiveCharacter - 1, (char)v40);
13571 LODWORD(v1->pConditions[17]) = LODWORD(pParty->uTimePlayed);
13572 v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed);
13573 }
13574 HIDWORD(v1->pConditions[17]) = (int)v39;
13575 LABEL_63:
13576 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
13577 v1->PlaySound(82, 0);
13578 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
13579 LABEL_46:
13580 result = pMessageQueue_50CBD0->uNumMessages;
13581 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
13582 {
13583 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
13584 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
13585 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
13586 *(&pMessageQueue_50CBD0->uNumMessages + result) = v25;
13587 ++pMessageQueue_50CBD0->uNumMessages;
13588 }
13589 return result;
13590 }
13591 v63 = 1;
13592 v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
13593 strcpy(a1, "");
13594 v41->uHeight = 0;
13595 v41->uY = 0;
13596 if ( v1->_4B6FF9() )
13597 {
13598 sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]);
13599 v63 = 0;
13600 }
13601 strcpy(&Dest, pGlobalTXT_LocalizationStrings[68]);
13602 strcpy(&v56, pGlobalTXT_LocalizationStrings[160]);
13603 v42 = v63;
13604 v43 = pDialogueWindow;
13605 v44 = v63;
13606 v66 = 0;
13607 if ( v63 < pDialogueWindow->pNumPresenceButton )
13608 {
13609 v61 = (GUIWindow *)&a1[100 * v63];
13610 do
13611 {
13612 v45 = pFontArrus->CalcTextHeight((const char *)v61, &v57, 0, 0);
13613 v66 = (DDM_DLV_Header *)((char *)v66 + v45);
13614 v43 = pDialogueWindow;
13615 v61 = (GUIWindow *)((char *)v61 + 100);
13616 ++v44;
13617 }
13618 while ( v44 < pDialogueWindow->pNumPresenceButton );
13619 }
13620 v46 = v43->pNumPresenceButton - v42;
13621 v64 = (174 - (signed int)v66) / v46;
13622 if ( v64 > 32 )
13623 v64 = 32;
13624 result = v43->pStartingPosActiveItem;
13625 v47 = (174 - v64 * v46 - (signed int)v66) / 2 - v64 / 2 + 138;
13626 v65 = v42 + result;
13627 if ( v42 + result < result + v43->pNumPresenceButton )
13628 {
13629 v61 = (GUIWindow *)(v42 + 2);
13630 v66 = (DDM_DLV_Header *)&a1[100 * v42];
13631 do
13632 {
13633 v48 = v43->GetControl(v65);
13634 v49 = (const char *)v66;
13635 v50 = v48;
13636 v48->uY = v64 + v47;
13637 v51 = pFontArrus->CalcTextHeight(v49, &v57, 0, 0);
13638 v52 = v50->uY;
13639 v50->uHeight = v51;
13640 v47 = v52 + v51 - 1;
13641 v50->uW = v47;
13642 v53 = WORD2(v59);
13643 if ( (GUIWindow *)pDialogueWindow->pCurrentPosActiveItem != v61 )
13644 v53 = WORD2(v58);
13645 v57.DrawTitleText(pFontArrus, 0, v52, v53, (const char *)v66, 3u);
13646 v43 = pDialogueWindow;
13647 v66 = (DDM_DLV_Header *)((char *)v66 + 100);
13648 v61 = (GUIWindow *)((char *)v61 + 1);
13649 ++v65;
13650 result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
13651 }
13652 while ( (signed int)v65 < result );
13653 }
13654 return result;
13655 }
13656
13657
13658
13659 //----- (004B8F94) --------------------------------------------------------
13660 void *__cdecl sub_4B8F94()
13661 {
13662 GUIWindow *v0; // edi@1
13663 signed int v1; // ebp@1
13664 int v2; // ebx@1
13665 signed int v3; // esi@1
13666 int v4; // eax@3
13667 int v5; // ebx@3
13668 int v6; // ecx@3
13669 bool v7; // eax@5
13670 bool v8; // ST1C_4@5
13671 int v9; // eax@5
13672 int v10; // eax@10
13673 void *result; // eax@15
13674 signed int v12; // [sp-4h] [bp-18h]@7
13675
13676 v0 = ptr_507BC0;
13677 v1 = 0;
13678 v2 = (int)&ptr_507BC0->ptr_1C;
13679 v3 = (signed int)ptr_507BC0->ptr_1C;
13680 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] )
13681 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].uType] )
13682 {
13683 while ( v3 > 14 )
13684 {
13685 if ( v3 <= 28 )
13686 {
13687 v7 = v1 > 3;
13688 v8 = v7;
13689 v9 = 5 * (v7 + 2 * v3 - 30);
13690 v3 = (signed int)v0->ptr_1C;
13691 v5 = word_4F06D8[v9];
13692 v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4];
13693 goto LABEL_13;
13694 }
13695 if ( v3 <= 41 )
13696 {
13697 v5 = word_4F07B6[v3];
13698 v12 = 22;
13699 goto LABEL_12;
13700 }
13701 if ( v3 <= 53 )
13702 {
13703 if ( v1 >= 6 )
13704 {
13705 v5 = word_4F07B6[v3 + 1];
13706 v12 = 44;
13707 LABEL_12:
13708 v6 = v12;
13709 LABEL_13:
13710 pItemsTable->GenerateItem(v5, v6, (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
13711 v0 = ptr_507BC0;
13712 v2 = (int)&ptr_507BC0->ptr_1C;
13713 pParty->field_C59C[9 * (v1 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 729] = 1;
13714 goto LABEL_14;
13715 }
13716 auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
13717 _a->Reset();
13718 v2 = (int)&v0->ptr_1C;
13719 v10 = rand();
13720 v0 = ptr_507BC0;
13721 pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
13722 }
13723 LABEL_14:
13724 v3 = *(int *)v2;
13725 ++v1;
13726 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] )
13727 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[*(int *)v2 - 1].uType] )
13728 goto LABEL_15;
13729 }
13730 v4 = 5 * v3;
13731 v3 = (signed int)v0->ptr_1C;
13732 v5 = word_4F063E[v4];
13733 v6 = word_4F063E[5 * v3 + rand() % 4 + 1];
13734 goto LABEL_13;
13735 }
13736 LABEL_15:
13737 result = v0->ptr_1C;
13738 *(int *)&pParty->field_16154[4 * (int)result] = 0;
13739 return result;
13740 }
13741
13742
13743 //----- (004B6478) --------------------------------------------------------
13744 int __cdecl sub_4B6478()
13745 {
13746 GUIWindow *v0; // ebx@1
13747 Player *v1; // edi@1
13748 unsigned int v2; // eax@1
13749 signed int v3; // esi@1
13750 int v4; // ebx@1
13751 unsigned int v5; // esi@5
13752 int v6; // edi@6
13753 int result; // eax@13
13754 GUIWindow *v8; // ebx@17
13755 int v9; // eax@17
13756 int v10; // ecx@17
13757 unsigned int v11; // ecx@18
13758 int v12; // eax@20
13759 int v13; // eax@21
13760 GUIButton *v14; // esi@27
13761 int v15; // ecx@27
13762 unsigned int v16; // eax@28
13763 const char *v17; // ebx@29
13764 int v18; // eax@29
13765 unsigned int v19; // ecx@29
13766 int v20; // eax@29
13767 unsigned __int16 v21; // ax@29
13768 unsigned __int16 v22; // ST14_2@36
13769 int v23; // eax@36
13770 const char *v24; // ST18_4@37
13771 unsigned __int16 v25; // ST14_2@37
13772 int v26; // eax@37
13773 int v27; // [sp-4h] [bp-80h]@8
13774 GUIWindow v28; // [sp+Ch] [bp-70h]@1
13775 GUIWindow *v29; // [sp+60h] [bp-1Ch]@17
13776 unsigned int v30; // [sp+64h] [bp-18h]@1
13777 int v31; // [sp+68h] [bp-14h]@1
13778 int v32; // [sp+6Ch] [bp-10h]@1
13779 int v33; // [sp+70h] [bp-Ch]@17
13780 int v34; // [sp+74h] [bp-8h]@17
13781 int v35; // [sp+78h] [bp-4h]@17
13782
13783 v0 = ptr_507BC0;
13784 memcpy(&v28, ptr_507BC0, sizeof(v28));
13785 v1 = pPlayers[uActiveCharacter];
13786 v28.uFrameX = 483;
13787 v28.uFrameWidth = 148;
13788 v28.uFrameZ = 334;
13789 v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
13790 v31 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
13791 v2 = 52 * (unsigned int)v0->ptr_1C;
13792 //v32 = (unsigned __int8)(((p2DEvents_minus1___00[v2 / 2] != 18) - 1) & 0x96) + 100;
13793 v32 = (unsigned __int8)(((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != 18) - 1) & 0x96) + 100;
13794 //v3 = (signed __int64)((double)v32 * p2DEvents_minus1__20[v2 / 4]);
13795 v3 = (signed __int64)((double)v32 * p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
13796 v4 = v3 * (100 - v1->GetMerchant()) / 100;
13797 v32 = v4;
13798 if ( v4 < v3 / 3 )
13799 {
13800 v4 = v3 / 3;
13801 v32 = v3 / 3;
13802 }
13803 if ( dword_F8B19C != 1 )
13804 {
13805 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
13806 {
13807 v5 = 0;
13808
13809 __debugbreak();
13810 //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
13811 // or
13812 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
13813 // or
13814 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
13815
13816 if (false
13817 //if ( !*(&byte_4ED94C[37 * v1->uClass / 3] + dword_F8B19C)
13818 || (v6 = (int)(&v1->uIntelligence + dword_F8B19C), *(short *)v6) )
13819 {
13820 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
13821 }
13822 else
13823 {
13824 if ( pParty->uNumGold < v4 )
13825 {
13826 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
13827 v27 = 4;
13828 }
13829 else
13830 {
13831 Party::TakeGold(v4);
13832 *(short *)v6 = 1;
13833 v27 = 2;
13834 }
13835 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v27);
13836 }
13837 }
13838 else
13839 {
13840 v5 = 0;
13841 }
13842 result = pMessageQueue_50CBD0->uNumMessages;
13843 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
13844 {
13845 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
13846 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
13847 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
13848 *(&pMessageQueue_50CBD0->uNumMessages + result) = v5;
13849 ++pMessageQueue_50CBD0->uNumMessages;
13850 }
13851 return result;
13852 }
13853 if ( !(unsigned __int16)_449B57_test_bit(
13854 (unsigned __int8 *)v1->field_152,
13855 word_4F0754[2 * (unsigned int)ptr_507BC0->ptr_1C]) )
13856 {
13857 v24 = pNPCTopics[171].pText;
13858 v25 = v31;
13859 v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0);
13860 v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u);
13861 result = (int)pDialogueWindow;
13862 pDialogueWindow->pNumPresenceButton = 0;
13863 return result;
13864 }
13865 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
13866 if ( !result )
13867 return result;
13868 v8 = pDialogueWindow;
13869 v33 = 0;
13870 v34 = 0;
13871 v29 = pDialogueWindow;
13872 v9 = pDialogueWindow->pStartingPosActiveItem;
13873 v10 = v9 + pDialogueWindow->pNumPresenceButton;
13874 v35 = pDialogueWindow->pStartingPosActiveItem;
13875 if ( v9 >= v10 )
13876 goto LABEL_40;
13877 do
13878 {
13879 v11 = v8->GetControl(v35)->uControlParam - 36;
13880 if ( byte_4ED970_skill_learn_ability_by_class_table[v1->uClass / 3][v11] && !v1->pActiveSkills[v11] )
13881 {
13882 v12 = pFontArrus->CalcTextHeight(pSkillNames[v11], &v28, 0, 0);
13883 v33 += v12;
13884 ++v34;
13885 }
13886 v13 = v8->pStartingPosActiveItem;
13887 ++v35;
13888 }
13889 while ( v35 < v8->pNumPresenceButton + v13 );
13890 if ( !v34 )
13891 {
13892 LABEL_40:
13893 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
13894 strcat(pTmpBuf, "\n \n");
13895 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
13896 v22 = v31;
13897 v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0);
13898 return (int)v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
13899 }
13900 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
13901 v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
13902 v32 = (149 - v33) / v34;
13903 if ( (149 - v33) / v34 > 32 )
13904 v32 = 32;
13905 result = v8->pStartingPosActiveItem;
13906 v35 = result;
13907 v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162;
13908 if ( result < result + v8->pNumPresenceButton )
13909 {
13910 v33 = 2;
13911 do
13912 {
13913 v14 = v8->GetControl(v35);
13914 v15 = v14->uControlParam - 36;
13915 if ( byte_4ED970_skill_learn_ability_by_class_table[v1->uClass / 3][v15] )
13916 {
13917 v16 = 0;
13918 if ( !v1->pActiveSkills[v15] )
13919 {
13920 v17 = pSkillNames[v15];
13921 v14->uY = v32 + v34;
13922 v18 = pFontArrus->CalcTextHeight(v17, &v28, 0, 0);
13923 v19 = v14->uY;
13924 v14->uHeight = v18;
13925 v20 = v19 + v18 - 1;
13926 v14->uW = v20;
13927 v34 = v20;
13928 v21 = v31;
13929 if ( pDialogueWindow->pCurrentPosActiveItem != v33 )
13930 v21 = v30;
13931 v28.DrawTitleText(pFontArrus, 0, v19, v21, v17, 3u);
13932 goto LABEL_34;
13933 }
13934 }
13935 else
13936 {
13937 v16 = 0;
13938 }
13939 v14->uW = v16;
13940 v14->uHeight = v16;
13941 v14->uY = v16;
13942 LABEL_34:
13943 v8 = v29;
13944 ++v35;
13945 ++v33;
13946 result = v29->pNumPresenceButton + v29->pStartingPosActiveItem;
13947 }
13948 while ( v35 < result );
13949 }
13950 return result;
13951 }
13952
13953
13954
13955 //----- (004B6943) --------------------------------------------------------
13956 void __cdecl TravelByTransport()
13957 {
13958 GUIWindow *v0; // ebx@1
13959 Player *v1; // esi@1
13960 signed int v2; // edi@1
13961 unsigned int v3; // eax@1
13962 signed int v4; // ebx@1
13963 char *v5; // esi@7
13964 int v6; // eax@9
13965 int v7; // eax@9
13966 int v8; // eax@12
13967 int v9; // edi@12
13968 int v10; // edx@12
13969 int v11; // ecx@12
13970 signed int v12; // esi@13
13971 signed int v13; // edi@14
13972 DWORD v14; // eax@26
13973 DWORD v15; // edi@26
13974 GUIWindow *v16; // ebx@36
13975 int v17; // esi@36
13976 int v18; // eax@36
13977 int v19; // ecx@36
13978 int v20; // esi@36
13979 int v21; // eax@36
13980 void *v22; // eax@39
13981 Player *v23; // esi@39
13982 GUIButton *v24; // ebx@39
13983 signed int v25; // eax@41
13984 int v26; // esi@44
13985 const char *v27; // eax@46
13986 char *v28; // eax@62
13987 int v29; // eax@62
13988 unsigned int v30; // ecx@62
13989 char *v31; // eax@63
13990 char v32; // [sp-3Ch] [bp-2CCh]@62
13991 int v33; // [sp-38h] [bp-2C8h]@62
13992 int v34; // [sp-34h] [bp-2C4h]@62
13993 int v35; // [sp-30h] [bp-2C0h]@62
13994 int v36; // [sp-2Ch] [bp-2BCh]@62
13995 int v37; // [sp-28h] [bp-2B8h]@62
13996 int v38; // [sp-24h] [bp-2B4h]@62
13997 int v39; // [sp-20h] [bp-2B0h]@62
13998 int v40; // [sp-1Ch] [bp-2ACh]@62
13999 int v41; // [sp-18h] [bp-2A8h]@62
14000 int v42; // [sp-14h] [bp-2A4h]@62
14001 char *v43; // [sp-10h] [bp-2A0h]@62
14002 char *v44; // [sp-Ch] [bp-29Ch]@62
14003 unsigned int v45; // [sp-8h] [bp-298h]@62
14004 char *v46; // [sp-4h] [bp-294h]@62
14005 const char *v47[5]; // [sp+0h] [bp-290h]@7
14006 char v48; // [sp+14h] [bp-27Ch]@37
14007 char v49; // [sp+78h] [bp-218h]@68
14008 char v50; // [sp+DCh] [bp-1B4h]@68
14009 char v51; // [sp+140h] [bp-150h]@68
14010 char Dest; // [sp+1A4h] [bp-ECh]@36
14011 GUIWindow v53; // [sp+208h] [bp-88h]@1
14012 int v54; // [sp+25Ch] [bp-34h]@36
14013 int v55; // [sp+260h] [bp-30h]@36
14014 unsigned int v56; // [sp+264h] [bp-2Ch]@1
14015 __int16 v57[2]; // [sp+268h] [bp-28h]@1
14016 Player *v58; // [sp+26Ch] [bp-24h]@36
14017 GUIWindow *v59; // [sp+270h] [bp-20h]@1
14018 unsigned int v60; // [sp+274h] [bp-1Ch]@36
14019 Player *v61; // [sp+278h] [bp-18h]@1
14020 int v62; // [sp+27Ch] [bp-14h]@36
14021 int v63; // [sp+280h] [bp-10h]@14
14022 char *a1; // [sp+284h] [bp-Ch]@37
14023 unsigned int s1; // [sp+288h] [bp-8h]@1
14024 int v66; // [sp+28Ch] [bp-4h]@48
14025
14026 v0 = ptr_507BC0;
14027 memcpy(&v53, ptr_507BC0, sizeof(v53));
14028 v2 = 255;
14029 v61 = pPlayers[uActiveCharacter];
14030 v1 = v61;
14031 v53.uFrameX = 483;
14032 v53.uFrameWidth = 148;
14033 v53.uFrameZ = 334;
14034 *(int *)v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14035 v56 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
14036 v3 = 52 * (unsigned int)v0->ptr_1C;
14037 //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
14038 v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != 27) - 1) & 0xFFFFFFE7) + 50);
14039 //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]);
14040 v4 = (signed __int64)((double)(signed int)v59 * p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
14041 s1 = v4 * (100 - v1->GetMerchant()) / 100;
14042 if ( (signed int)s1 < v4 / 3 )
14043 s1 = v4 / 3;
14044 if ( dword_F8B19C == 1 )
14045 {
14046 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
14047 {
14048 v16 = pDialogueWindow;
14049 v58 = (Player *)-1;
14050 v62 = 0;
14051 v17 = LOBYTE(pFontArrus->uFontHeight) - 3;
14052 v59 = pDialogueWindow;
14053 v54 = v17;
14054 strcpy(&Dest, "");
14055 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
14056 v18 = pFontArrus->CalcTextHeight(pTmpBuf2, &v53, 0, 0);
14057 v19 = v16->pNumPresenceButton;
14058 v20 = v18 + v17 + 146;
14059 v21 = v16->pStartingPosActiveItem;
14060 v63 = v20;
14061 v55 = v20;
14062 v60 = v21;
14063 if ( v21 >= v21 + v19 )
14064 goto LABEL_71;
14065 s1 = 2;
14066 a1 = &v48;
14067 while ( 1 )
14068 {
14069 v47[1] = (const char *)v60;
14070 v22 = ptr_507BC0->ptr_1C;
14071 v23 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
14072 v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
14073 v24 = v16->GetControl(v60);
14074 if ( v23 != v58
14075 && ((signed int)s1 >= 6 ? (v25 = 1) : (v25 = (unsigned __int8)*(&byte_4F09B1[32 * (int)v23]
14076 + pParty->uDaysPlayed % 7)),
14077 v25
14078 && ((v26 = 8 * (int)v23, !dword_4F09CC[v26])
14079 || (unsigned __int16)_449B57_test_bit(pParty->_award_bits, LOWORD(dword_4F09CC[v26])))) )
14080 {
14081 v58 = v61;
14082 v27 = (const char *)v56;
14083 if ( pDialogueWindow->pCurrentPosActiveItem != s1 )
14084 v27 = *(const char **)v57;
14085 v47[1] = v27;
14086 sprintf(a1, format_4E2DC8, v27);
14087 v66 = (unsigned __int8)byte_4F09B8[v26 * 4];
14088 if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
14089 {
14090 if ( CheckHiredNPCSpeciality(8u) )
14091 v66 -= 2;
14092 if ( CheckHiredNPCSpeciality(9u) )
14093 v66 -= 3;
14094 v47[1] = (const char *)45;
14095 }
14096 else
14097 {
14098 v47[1] = (const char *)35;
14099 }
14100 if ( CheckHiredNPCSpeciality((unsigned int)v47[1]) )
14101 v66 -= 2;
14102 if ( CheckHiredNPCSpeciality(0x2Cu) )
14103 --v66;
14104 if ( v66 < 1 )
14105 v66 = 1;
14106 if ( v61 != (Player *)v2 )
14107 {
14108 memcpy(&v32, (char *)&pMapStats + 68 * (unsigned __int8)byte_4F09B0[v26 * 4], 0x44u);
14109 sprintf(
14110 pTmpBuf,
14111 pGlobalTXT_LocalizationStrings[404],
14112 v66,
14113 *(int *)&v32,
14114 v33,
14115 v34,
14116 v35,
14117 v36,
14118 v37,
14119 v38,
14120 v39,
14121 v40,
14122 v41,
14123 v42,
14124 v43,
14125 v44,
14126 v45,
14127 v46,
14128 *(_QWORD *)v47);
14129 strcat(a1, pTmpBuf);
14130 v28 = a1;
14131 a1 += 100;
14132 ++v62;
14133 ++s1;
14134 strcat(v28, "\n \n");
14135 v24->uY = v63;
14136 v29 = pFontArrus->CalcTextHeight(pTmpBuf, &v53, 0, 0);
14137 v30 = v24->uY;
14138 v24->uHeight = v29;
14139 v2 = 255;
14140 v24->uW = v30 + v29 - 1;
14141 v63 += v54 + v29;
14142 }
14143 }
14144 else
14145 {
14146 v31 = a1;
14147 ++v62;
14148 ++s1;
14149 a1 += 100;
14150 strcpy(v31, "");
14151 if ( v24 )
14152 {
14153 v24->uW = 0;
14154 v24->uHeight = 0;
14155 v24->uY = 0;
14156 }
14157 }
14158 ++v60;
14159 if ( (signed int)v60 >= v59->pNumPresenceButton + v59->pStartingPosActiveItem )
14160 break;
14161 v16 = v59;
14162 }
14163 if ( v63 != v55 )
14164 {
14165 v47[1] = &Dest;
14166 v47[0] = &v51;
14167 v46 = &v50;
14168 v45 = (unsigned int)&v49;
14169 v44 = &v48;
14170 v43 = pTmpBuf2;
14171 sprintf(pTmpBuf, "%s\n \n%s%s%s%s%s", pTmpBuf2, &v48, &v49, &v50, &v51, &Dest);
14172 v53.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
14173 }
14174 else
14175 {
14176 LABEL_71:
14177 v47[1] = (const char *)3;
14178 v47[0] = pGlobalTXT_LocalizationStrings[561];
14179 v46 = *(char **)v57;
14180 v45 = (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &v53, 0, 0)) / 2 + 138;
14181 v53.DrawTitleText(pFontArrus, 0, v45, (unsigned __int16)v46, v47[0], (unsigned int)v47[1]);
14182 pAudioPlayer->StopChannels(-1, -1);
14183 }
14184 }
14185 }
14186 else
14187 {
14188 if ( dword_F8B19C > 104 && dword_F8B19C <= 108 )
14189 {
14190 if ( pParty->uNumGold < s1 )
14191 {
14192 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
14193 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 3);
14194 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
14195 return;
14196 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
14197 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
14198 goto LABEL_33;
14199 }
14200 Party::TakeGold(s1);
14201 v47[1] = (const char *)7;
14202 v5 = &byte_4F09B0[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)ptr_507BC0->ptr_1C] + dword_F8B19C)];
14203 if ( v5[pParty->uDaysPlayed % 7 + 1] )
14204 {
14205 if ( _strcmpi(pCurrentMapName, pMapStats->pInfos[(unsigned __int8)*v5].pFilename) )
14206 {
14207 SaveGame(1, 0);
14208 strcpy(pCurrentMapName, pMapStats->pInfos[(unsigned __int8)*v5].pFilename);
14209 v8 = *((int *)v5 + 6);
14210 v9 = *((int *)v5 + 5);
14211 v10 = *((int *)v5 + 4);
14212 dword_6BE364_game_settings_1 |= 1u;
14213 _5B65B8_npcdata_hiword_house_or_other = 0;
14214 dword_5B65BC = 0;
14215 _5B65B4_npcdata_loword_house_or_other = v8;
14216 v11 = *((int *)v5 + 3);
14217 uGameState = 2;
14218 _5B65A8_npcdata_uflags_or_other = v11;
14219 _5B65AC_npcdata_fame_or_other = v10;
14220 _5B65B0_npcdata_rep_or_other = v9;
14221 dword_5B65C0 = v11 | v10 | v9 | v8;
14222 }
14223 else
14224 {
14225 v6 = *((int *)v5 + 3);
14226 pParty->sRotationX = 0;
14227 pParty->vPosition.x = v6;
14228 v7 = *((int *)v5 + 4);
14229 pIndoorCamera->sRotationY = 0;
14230 pParty->uFlags |= 2u;
14231 pParty->vPosition.y = v7;
14232 pParty->vPosition.z = *((int *)v5 + 5);
14233 pParty->uFallStartY = pParty->vPosition.z;
14234 pParty->sRotationY = *((int *)v5 + 6);
14235 }
14236 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
14237 v12 = (unsigned __int8)v5[8];
14238 if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
14239 {
14240 v63 = 72;
14241 v13 = 2500;
14242 if ( CheckHiredNPCSpeciality(8u) )
14243 v12 -= 2;
14244 if ( CheckHiredNPCSpeciality(9u) )
14245 v12 -= 3;
14246 v47[1] = (const char *)45;
14247 }
14248 else
14249 {
14250 v63 = 71;
14251 v13 = 1500;
14252 v47[1] = (const char *)35;
14253 }
14254 if ( CheckHiredNPCSpeciality((unsigned int)v47[1]) )
14255 v12 -= 2;
14256 if ( CheckHiredNPCSpeciality(0x2Cu) )
14257 --v12;
14258 if ( v12 < 1 )
14259 v12 = 1;
14260 RestAndHeal(1440 * v12);
14261 v61->PlaySound(v63, 0);
14262 v14 = GetTickCount();
14263 v15 = v14 + v13;
14264 if ( v15 < v14 )
14265 v15 = v14;
14266 while ( GetTickCount() < v15 )
14267 sqrt(3.1415926);
14268 while ( sub_4BD8B5() )
14269 ;
14270 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
14271 {
14272 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
14273 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14274 LABEL_33:
14275 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14276 ++pMessageQueue_50CBD0->uNumMessages;
14277 return;
14278 }
14279 }
14280 else
14281 {
14282 dword_F8B19C = 1;
14283 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
14284 }
14285 }
14286 }
14287 }
14288
14289
14290
14291
14292
14293 //----- (00405CFF) --------------------------------------------------------
14294 void stru262_TurnBased::End(bool bPlaySound)
14295 {
14296 stru262_TurnBased *v2; // edi@1
14297 int v3; // ebx@1
14298 int v4; // esi@1
14299 unsigned __int8 v5; // zf@1
14300 unsigned __int8 v6; // sf@1
14301 TurnBased_QueueElem *v7; // ecx@2
14302 unsigned __int16 *pAttributes; // ecx@7
14303 size_t v9; // edx@7
14304 unsigned __int16 v10; // ax@8
14305 TurnBased_QueueElem *v11; // ebx@12
14306 ObjectType objType; // eax@13
14307 int objID; // esi@13
14308 int v14; // [sp+Ch] [bp-4h]@11
14309
14310 v2 = this;
14311 v3 = 0;
14312 v4 = 0;
14313 v5 = this->uActorQueueSize == 0;
14314 v6 = this->uActorQueueSize < 0;
14315 this->field_4 = 0;
14316 if ( !(v6 | v5) )
14317 {
14318 v7 = this->pQueue;
14319 do
14320 {
14321 if ( (v7->uPackedID & 7) == OBJECT_Actor )
14322 LOBYTE(pActors[v7->uPackedID >> 3].uAttributes) &= 0x7Fu;
14323 ++v4;
14324 ++v7;
14325 }
14326 while ( v4 < v2->uActorQueueSize );
14327 }
14328 if ( (signed int)uNumLayingItems > 0 )
14329 {
14330 pAttributes = &pLayingItems[0].uAttributes;
14331 v9 = uNumLayingItems;
14332 do
14333 {
14334 v10 = *pAttributes;
14335 if ( *pAttributes & 4 )
14336 {
14337 LOBYTE(v10) = v10 & 0xFB;
14338 *pAttributes = v10;
14339 }
14340 pAttributes += 56;
14341 --v9;
14342 }
14343 while ( v9 );
14344 }
14345 v14 = 0;
14346 if ( v2->uActorQueueSize > 0 )
14347 {
14348 v11 = v2->pQueue;
14349 do
14350 {
14351 objType = (ObjectType)(v11->uPackedID & 7);
14352 objID = v11->uPackedID >> 3;
14353 if ( objType == OBJECT_Player )
14354 {
14355 pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)v11->field_4 * 2.133333333333333);
14356 }
14357 else
14358 {
14359 if ( objType == OBJECT_Actor )
14360 pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)v11->field_4 * 2.133333333333333);
14361 }
14362 ++v14;
14363 ++v11;
14364 }
14365 while ( v14 < v2->uActorQueueSize );
14366 v3 = 0;
14367 }
14368 pAudioPlayer->StopChannels(-1, -1);
14369 if ( bPlaySound != v3 )
14370 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse), v3, v3, -1, v3, v3, v3, v3);
14371 pTurnEngine->field_18 &= 0xFFFFFFFDu;
14372 pEventTimer->StopGameTime();
14373 dword_50C994 = v3;
14374 dword_50C998_turnbased_icon_1A = v3;
14375 }
14376 // 50C994: using guessed type int dword_50C994;
14377 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
14378
14379 //----- (00405E14) --------------------------------------------------------
14380 void stru262_TurnBased::_405E14()
14381 {
14382 stru262_TurnBased *v1; // esi@1
14383 int v2; // ecx@1
14384 SpellBuff *v3; // edi@2
14385 Actor *v4; // ebx@3
14386 signed int v5; // edx@20
14387 AIDirection *v6; // esi@21
14388 int v7; // eax@21
14389 int v8; // eax@21
14390 int v9; // eax@22
14391 int v10; // eax@23
14392 int v11; // eax@37
14393 int v12; // eax@44
14394 AIDirection a3; // [sp+4h] [bp-68h]@21
14395 AIDirection v14; // [sp+20h] [bp-4Ch]@21
14396 AIDirection v15; // [sp+3Ch] [bp-30h]@21
14397 SpellBuff *v16; // [sp+58h] [bp-14h]@2
14398 int v17; // [sp+5Ch] [bp-10h]@6
14399 stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1
14400 int v19; // [sp+64h] [bp-8h]@8
14401 unsigned int v20; // [sp+68h] [bp-4h]@1
14402
14403 v1 = this;
14404 v2 = 0;
14405 v18 = v1;
14406 v20 = 0;
14407 if ( (signed int)uNumActors > 0 )
14408 {
14409 v3 = pActors[0].pActorBuffs;
14410 v16 = pActors[0].pActorBuffs;
14411 do
14412 {
14413 v4 = (Actor *)((char *)&v3[-13] - 4);
14414 if ( SHIDWORD(v3[3].uExpireTime) < v2 || SHIDWORD(v3[3].uExpireTime) <= v2 && LODWORD(v3[3].uExpireTime) <= v2 )
14415 v17 = v2;
14416 else
14417 v17 = 1;
14418 v19 = v2;
14419 do
14420 {
14421 if ( v19 != 10 )
14422 {
14423 v3->_4585CA(pParty->uTimePlayed);
14424 v2 = 0;
14425 }
14426 ++v19;
14427 ++v3;
14428 }
14429 while ( v19 < 22 );
14430 if ( v17 != v2
14431 && SHIDWORD(v4->pActorBuffs[3].uExpireTime) <= v2
14432 && (SHIDWORD(v4->pActorBuffs[3].uExpireTime) < v2 || LODWORD(v4->pActorBuffs[3].uExpireTime) <= v2) )
14433 v4->uActorHeight = pMonsterList->pMonsters[v4->pMonsterInfo.uID - 1].uMonsterHeight;
14434 if ( !(v4->uAttributes & 0x80) )
14435 {
14436 if ( !v4->pActorBuffs[5].uExpireTime )
14437 {
14438 if ( !v4->pActorBuffs[6].uExpireTime )
14439 {
14440 v5 = v4->uCurrentActionLength;
14441 v4->uCurrentActionTime += pMiscTimer->uTimeElapsed;
14442 if ( (signed int)v4->uCurrentActionTime >= v5 )
14443 {
14444 v17 = dword_4F6E08[v20];
14445 v6 = Actor::GetDirectionInfo(8 * v20 | 3, v17, &a3, v2);
14446 v7 = v4->uAIState;
14447 memcpy(&v15, v6, sizeof(v15));
14448 v8 = v7 - 4;
14449 memcpy(&v14, &v15, sizeof(v14));
14450 if ( v8 )
14451 {
14452 v9 = v8 - 1;
14453 if ( v9 )
14454 {
14455 v10 = v9 - 6;
14456 if ( v10 )
14457 {
14458 if ( v10 != 8 )
14459 Actor::_403F58(v20, v17, 32, &v14);
14460 }
14461 }
14462 }
14463 else
14464 {
14465 v4->uCurrentActionTime = 0;
14466 v4->uCurrentActionLength = 0;
14467 v4->uAIState = Dead;
14468 v4->UpdateAnimation();
14469 }
14470 v1 = v18;
14471 v2 = 0;
14472 }
14473 }
14474 }
14475 }
14476 ++v20;
14477 v3 = (SpellBuff *)((char *)v16 + 836);
14478 v16 = (SpellBuff *)((char *)v16 + 836);
14479 }
14480 while ( (signed int)v20 < (signed int)uNumActors );
14481 }
14482 if ( v1->field_4 == 1 )
14483 {
14484 v12 = v1->field_8;
14485 if ( v12 == 64 )
14486 {
14487 v1->_406A63();
14488 }
14489 else
14490 {
14491 if ( v12 > v2 )
14492 {
14493 v1->_406B9F();
14494 }
14495 else
14496 {
14497 v1->_406AFE();
14498 v1->field_10 = 100;
14499 }
14500 }
14501 v1->field_8 -= pEventTimer->uTimeElapsed;
14502 return;
14503 }
14504 if ( v1->field_4 == 2 )
14505 {
14506 if ( !(v1->field_18 & 1) )
14507 {
14508 v11 = v1->field_10;
14509 if ( v11 == 100 )
14510 {
14511 v1->StartTurn();
14512 LABEL_39:
14513 v1->_40652A();
14514 return;
14515 }
14516 if ( v11 > v2 || v1->pQueue[0].field_4 <= v2 )
14517 {
14518 v1->_4065B0();
14519 goto LABEL_39;
14520 }
14521 }
14522 v1->NextTurn();
14523 return;
14524 }
14525 if ( v1->field_4 == 3 )
14526 {
14527 if ( v1->uActionPointsLeft <= v2 || v1->field_18 & 8 )
14528 {
14529 v1->field_18 &= 0xFFFFFFF7u;
14530 v1->field_4 = 1;
14531 v1->field_8 = 64;
14532 }
14533 else
14534 {
14535 v1->_406FA8();
14536 }
14537 }
14538 }
14539
14540
14541
14542
14543 //----- (0043FDED) --------------------------------------------------------
14544 void PrepareActorRenderList_BLV()
14545 {
14546 RenderBillboard *v0; // esi@0
14547 unsigned __int16 v3; // ax@3
14548 unsigned int v4; // eax@5
14549 unsigned __int16 v5; // cx@5
14550 int v6; // esi@5
14551 unsigned int v7; // eax@7
14552 int v8; // eax@10
14553 SpriteFrame *v9; // eax@16
14554 SpriteFrame *v10; // ebx@18
14555 //int *v11; // eax@18
14556 int v12; // ecx@28
14557 //IndoorCameraD3D **v14; // eax@36
14558 double v15; // st7@36
14559 float v16; // eax@36
14560 //double v17; // ST30_8@36
14561 signed __int64 v18; // qtt@36
14562 int v19; // ST5C_4@36
14563 signed __int64 v20; // qtt@37
14564 int v21; // ST5C_4@37
14565 signed __int16 v22; // cx@39
14566 int v23; // ST50_4@40
14567 signed int v24; // ecx@40
14568 int v25; // edx@44
14569 __int16 v26; // ax@44
14570 //MonsterDesc *v27; // edx@44
14571 //int v28; // ecx@44
14572 unsigned __int8 v29; // zf@44
14573 unsigned __int8 v30; // sf@44
14574 unsigned int v31; // [sp-8h] [bp-5Ch]@15
14575 int v32; // [sp+1Ch] [bp-38h]@5
14576 int a3; // [sp+20h] [bp-34h]@5
14577 int a2; // [sp+24h] [bp-30h]@5
14578 int a1a; // [sp+28h] [bp-2Ch]@5
14579 __int16 a5; // [sp+2Ch] [bp-28h]@5
14580 int a5a; // [sp+2Ch] [bp-28h]@36
14581 int a5b; // [sp+2Ch] [bp-28h]@40
14582 __int16 v41; // [sp+3Ch] [bp-18h]@18
14583 int a6; // [sp+40h] [bp-14h]@34
14584 int v43; // [sp+44h] [bp-10h]@34
14585 int z; // [sp+48h] [bp-Ch]@32
14586 signed int y; // [sp+4Ch] [bp-8h]@32
14587 int x; // [sp+50h] [bp-4h]@32
14588
14589 for (uint i = 0; i < uNumActors; ++i)
14590 {
14591 auto p = pActors + i;
14592
14593 if (p->uAIState == Removed ||
14594 p->uAIState == Disabled)
14595 continue;
14596
14597 a5 = p->uSectorID;
14598 a2 = p->vPosition.y;
14599 a1a = p->vPosition.x;
14600 a3 = p->vPosition.z;
14601 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
14602 LOWORD(v0) = p->uYawAngle;
14603 v5 = p->uCurrentActionAnimation;
14604 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7;
14605 v32 = v6;
14606 if ( pParty->bTurnBasedModeOn )
14607 {
14608 if ( v5 == 1 )
14609 {
14610 v7 = pMiscTimer->uTotalGameTimeElapsed;
14611 goto LABEL_10;
14612 }
14613 }
14614 else
14615 {
14616 if ( v5 == 1 )
14617 {
14618 v7 = pBLVRenderParams->field_0_timer_;
14619 LABEL_10:
14620 v8 = i * 32 + v7;
14621 goto LABEL_12;
14622 }
14623 }
14624 v8 = p->uCurrentActionTime;
14625 LABEL_12:
14626 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
14627 v8 = 0;
14628 v31 = p->pSpriteIDs[v5];
14629 if (p->uAIState == Resurrected)
14630 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
14631 else
14632 v9 = pSpriteFrameTable->GetFrame(v31, v8);
14633 v41 = 0;
14634 v10 = v9;
14635 //v11 = (int *)v9->uFlags;
14636 if (v9->uFlags & 2)
14637 v41 = 2;
14638 if (v9->uFlags & 0x40000)
14639 v41 |= 0x40u;
14640 if (v9->uFlags & 0x20000)
14641 LOBYTE(v41) = v41 | 0x80;
14642 v0 = (RenderBillboard *)(256 << v6);
14643 if ( (unsigned int)v0 & v9->uFlags)
14644 v41 |= 4u;
14645 if ( v10->uGlowRadius )
14646 {
14647 //LOBYTE(v11) = byte_4E94D3;
14648 pMobileLightsStack->AddLight(
14649 a1a,
14650 a2,
14651 a3,
14652 a5,
14653 v10->uGlowRadius,
14654 0xFFu,
14655 0xFFu,
14656 0xFFu,
14657 byte_4E94D3);
14658 }
14659 v12 = 0;
14660 if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 )
14661 continue;
14662 while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID)
14663 {
14664 ++v12;
14665 if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors )
14666 goto _continue;
14667 }
14668 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
14669 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
14670 continue;
14671 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
14672
14673 v0 = &pBillboardRenderList[uNumBillboardsToDraw];
14674 if (uNumBillboardsToDraw >= 500)
14675 break;
14676 ++uNumBillboardsToDraw;
14677 ++uNumSpritesDrawnThisFrame;
14678 p->uAttributes |= 8u;
14679 v29 = pRenderer->pRenderD3D == 0;
14680 v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
14681 v0->uPalette = v10->uPaletteIndex;
14682 v0->uIndoorSectorID = a5;
14683 if ( v29 )
14684 {
14685 LODWORD(v20) = pBLVRenderParams->field_40 << 16;
14686 HIDWORD(v20) = pBLVRenderParams->field_40 >> 16;
14687 v21 = v20 / x;
14688 v0->field_0 = (unsigned __int64)(v10->scale * v20 / x) >> 16;
14689 a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16;
14690 }
14691 else
14692 {
14693 //v14 = &pGame->pIndoorCameraD3D;
14694 v0->fov_x = pGame->pIndoorCameraD3D->fov_x;
14695 v15 = pGame->pIndoorCameraD3D->fov_y;
14696 v16 = v0->fov_x;
14697 v0->fov_y = v15;
14698 //v17 = v16 + 6.7553994e15;
14699 LODWORD(v18) = 0;
14700 HIDWORD(v18) = floorf(v16 + 0.5f);
14701 v19 = v18 / x;
14702 v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16;
14703 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
14704 }
14705 v0->field_4 = a5a;
14706 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 )
14707 {
14708 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 )
14709 {
14710 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16;
14711 goto LABEL_43;
14712 }
14713 }
14714 else
14715 {
14716 v22 = p->pActorBuffs[3].uPower;
14717 if ( v22 )
14718 {
14719 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16;
14720 v24 = p->pActorBuffs[3].uPower;
14721 v0->field_0 = v23;
14722 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16;
14723 LABEL_43:
14724 v0->field_4 = a5b;
14725 goto LABEL_44;
14726 }
14727 }
14728 LABEL_44:
14729 HIWORD(v25) = HIWORD(x);
14730 v0->some_x = a1a;
14731 v0->some_y = a2;
14732 v0->some_z = a3;
14733 v0->uScreenSpaceX = v43;
14734 v0->uScreenSpaceY = a6;
14735 LOWORD(v25) = 0;
14736 LOBYTE(v26) = v41;
14737 v0->sZValue = v25 + (8 * i | 3);
14738 //v27 = pMonsterList->pMonsters;
14739 //v28 = p->pMonsterInfo.uID;
14740 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
14741 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
14742 v0->field_1E = v41;
14743 v0->pSpriteFrame = v10;
14744 v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor;
14745 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
14746 {
14747 HIBYTE(v26) = HIBYTE(v41) | 1;
14748 v0->field_1E = v26;
14749 }
14750
14751 _continue:
14752 ;
14753 }
14754 }
14755
14756
14757
14758
14759
14760 //----- (00444732) --------------------------------------------------------
14761 char *_444732_GetEventHintString(unsigned int uEventID)
14762 {
14763 signed int v1; // edx@1
14764 char *v2; // eax@2
14765 int v3; // ebx@4
14766 int v4; // esi@4
14767 char *result; // eax@6
14768 int v6; // eax@9
14769 char *i; // esi@11
14770 int v8; // edx@12
14771
14772 v1 = 0;
14773 if ( (signed int)uLevelEVT_NumEvents <= 0 )
14774 {
14775 LABEL_6:
14776 result = 0;
14777 }
14778 else
14779 {
14780 v2 = (char *)&pLevelEVT_Events[0].uEventOffsetInEVT;
14781 while ( 1 )
14782 {
14783 if ( *((int *)v2 - 2) == uEventID )
14784 {
14785 v3 = *(int *)v2;
14786 v4 = *((int *)v2 + 3);
14787 if ( pLevelEVT[*(int *)v2 + 4] == 4 )
14788 break;
14789 }
14790 ++v1;
14791 v2 += 12;
14792 if ( v1 >= (signed int)uLevelEVT_NumEvents )
14793 goto LABEL_6;
14794 }
14795 if ( pLevelEVT[v4 + 4] == 2 )
14796 {
14797 v6 = (unsigned __int8)pLevelEVT[v4 + 5]
14798 + (((unsigned __int8)pLevelEVT[v4 + 6]
14799 + (((unsigned __int8)pLevelEVT[v4 + 7] + ((unsigned __int8)pLevelEVT[v4 + 8] << 8)) << 8)) << 8);
14800 LABEL_10:
14801 //result = (char *)p2DEvents_minus1_::04[13 * v6];
14802 result = (char *)p2DEvents[v6 - 1].pName;
14803 }
14804 else
14805 {
14806 for ( i = (char *)pLevelEVT_Events + 4 * (3 * v1 + 3); *(int *)i == uEventID; i += 12 )
14807 {
14808 v8 = *((int *)i + 2);
14809 if ( pLevelEVT[v8 + 4] == 2 )
14810 {
14811 v6 = (unsigned __int8)pLevelEVT[v8 + 5]
14812 + (((unsigned __int8)pLevelEVT[v8 + 6]
14813 + (((unsigned __int8)pLevelEVT[v8 + 7] + ((unsigned __int8)pLevelEVT[v8 + 8] << 8)) << 8)) << 8);
14814 if ( (unsigned int)v6 < 0x258 )
14815 goto LABEL_10;
14816 }
14817 }
14818 result = &pLevelStr[pLevelStrOffsets[(unsigned __int8)pLevelEVT[v3 + 5]]];
14819 }
14820 }
14821 return result;
14822 }
14823
14824
14825
14826
14827 //----- (00444839) --------------------------------------------------------
14828 unsigned int __fastcall sub_444839_move_map(unsigned int a1, int a2, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName)
14829 {
14830 unsigned int v9; // ebx@1
14831 int v10; // edi@1
14832 signed int v11; // eax@1
14833 unsigned int v12; // eax@6
14834 const char *v13; // ST0C_4@6
14835 unsigned int v14; // eax@8
14836 const char *v15; // eax@14
14837 unsigned int v16; // eax@16
14838 unsigned int result; // eax@26
14839 const char *v18; // [sp-8h] [bp-40h]@9
14840 const char *v19; // [sp-4h] [bp-3Ch]@2
14841 char *v20; // [sp-4h] [bp-3Ch]@9
14842 const char *v21; // [sp-4h] [bp-3Ch]@11
14843 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
14844 unsigned int v23; // [sp+34h] [bp-4h]@1
14845
14846 v9 = a1;
14847 v10 = a2;
14848 v23 = IndoorLocation::GetLocationIndex(pLocationName);
14849 dword_59117C_teleportx = x;
14850 dword_591178_teleporty = y;
14851 dword_591174_teleportz = z;
14852 dword_591170_teleport_directiony = directiony;
14853 dword_59116C_teleport_directionx = directionx;
14854 dword_591168_teleport_speedz = a8;
14855 dword_591164_teleport_map_name = (char *)pLocationName;
14856 uCurrentHouse_Animation = v9;
14857 pEventTimer->Pause();
14858 pAudioPlayer->StopChannels(-1, -1);
14859 v11 = const_2();
14860 sprintf(pContainer, "evt%02d", v11);
14861 if ( pParty->uAlignment )
14862 {
14863 if ( pParty->uAlignment != 2 )
14864 goto LABEL_6;
14865 v19 = "-c";
14866 }
14867 else
14868 {
14869 v19 = "-b";
14870 }
14871 strcat(pContainer, v19);
14872 LABEL_6:
14873 v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
14874 v13 = pHouse_ExitPictures[v10];
14875 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
14876 pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v13, TEXTURE_16BIT_PALETTE)];
14877 if ( v9 )
14878 {
14879 if ( !v23 )
14880 //pVideoPlayer->_4BF28F(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_0, 1u);
14881 pVideoPlayer->_4BF28F(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_0, 1u);
14882 }
14883 else
14884 {
14885 if ( !v23 )
14886 {
14887 v14 = pMapStats->GetMapInfo(pCurrentMapName);
14888 if ( v14 )
14889 {
14890 v20 = pMapStats->pInfos[v14].pName;
14891 v18 = pGlobalTXT_LocalizationStrings[410];
14892 LABEL_10:
14893 sprintf(byte_591098, v18, v20);
14894 goto LABEL_20;
14895 }
14896 v21 = pGlobalTXT_LocalizationStrings[79];
14897 goto LABEL_19;
14898 }
14899 }
14900 v15 = pLocationName;
14901 if ( *pLocationName == 48 )
14902 v15 = pCurrentMapName;
14903 v16 = pMapStats->GetMapInfo(v15);
14904 if ( v16 )
14905 {
14906 v20 = pMapStats->pInfos[v16].pName;
14907 v18 = pGlobalTXT_LocalizationStrings[411];
14908 goto LABEL_10;
14909 }
14910 v21 = pGlobalTXT_LocalizationStrings[73];
14911 LABEL_19:
14912 strcpy(byte_591098, v21);
14913 LABEL_20:
14914 pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)byte_591098);
14915 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
14916 if ( BYTE1(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_C) )
14917 HousePlaySomeSound(v9, 1);
14918 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
14919 pPlayers[uActiveCharacter]->PlaySound(47, 0);
14920 result = v23;
14921 if ( v23 )
14922 uCurrentHouse_Animation = v23;
14923 return result;
14924 }
14925
14926
14927 //----- (0044606A) --------------------------------------------------------
14928 int __fastcall PrepareHouse(unsigned int uHouseID)
14929 {
14930 unsigned int v1; // ebx@1
14931 signed int v2; // esi@1
14932 int uExitPic; // edi@1
14933 __int16 uExitMapID; // ax@2
14934 int result; // eax@5
14935 unsigned int *v6; // ecx@8
14936 int v7; // ebx@11
14937 int v8; // esi@16
14938 unsigned int v9; // eax@16
14939 unsigned int v10; // eax@19
14940 int v11; // ecx@19
14941 char pContainer[36]; // [sp+Ch] [bp-54h]@16
14942 int v13; // [sp+30h] [bp-30h]@11
14943 int Dst[6]; // [sp+34h] [bp-2Ch]@1
14944 unsigned int v15; // [sp+4Ch] [bp-14h]@1
14945 int uAnimationID; // [sp+50h] [bp-10h]@1
14946 unsigned int *v17; // [sp+54h] [bp-Ch]@3
14947 unsigned int v18; // [sp+58h] [bp-8h]@1
14948 int v19; // [sp+5Ch] [bp-4h]@7
14949
14950 v15 = uHouseID;
14951 v1 = 52 * uHouseID;
14952 //uAnimationID = p2DEvents_minus1___02[26 * uHouseID];
14953 uAnimationID = p2DEvents[uHouseID - 1].uAnimationID;
14954 v2 = 0;
14955 v18 = 52 * uHouseID;
14956 memset(Dst, 0, 0x18u);
14957 //uExitPic = *(__int16 *)((char *)p2DEvents_minus1_::2C + v1);
14958 uExitPic = p2DEvents[uHouseID - 1].uExitPicID;
14959 uNumDialogueNPCPortraits = 0;
14960 uHouse_ExitPic = uExitPic;
14961 if ( uExitPic )
14962 {
14963 //uExitMapID = *(__int16 *)((char *)p2DEvents_minus1_::30 + v1);
14964 uExitMapID = p2DEvents[uHouseID - 1]._quest_related;
14965 if ( uExitMapID > 0 )
14966 {
14967 v17 = (unsigned int *)(uExitMapID - 1);
14968 if ( !((unsigned __int8)(0x80u >> (signed int)v17 % 8) & pParty->_award_bits[(uExitMapID - 1) >> 3]) )
14969 {
14970 uExitPic = 0;
14971 uHouse_ExitPic = 0;
14972 }
14973 }
14974 }
14975 dword_591080 = pAnimatedRooms[uAnimationID].field_8;
14976 result = dword_591080;
14977 if ( dword_591080 )
14978 {
14979 v2 = 1;
14980 Dst[0] = dword_591080;
14981 uNumDialogueNPCPortraits = 1;
14982 }
14983 v19 = 1;
14984 if ( (signed int)pNPCStats->uNumNewNPCs > 1 )
14985 {
14986 v6 = &pNPCStats->pNewNPCData[1].uFlags;
14987 v17 = &pNPCStats->pNewNPCData[1].uFlags;
14988 do
14989 {
14990 if ( v6[3] == v15 )
14991 {
14992 if ( !(*(char *)v6 & 0x80) )
14993 {
14994 v7 = v2++ - (result != 0);
14995 array_5913D8[v7] = (NPCData *)(v6 - 2);
14996 v6 = v17;
14997 *(&v13 + v2) = *(v17 - 1);
14998 v1 = v18;
14999 if ( (*v6 & 3) != 2 )
15000 ++*v6;
15001 }
15002 }
15003 ++v19;
15004 v6 += 19;
15005 v17 = v6;
15006 }
15007 while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
15008 uNumDialogueNPCPortraits = v2;
15009 }
15010 v19 = 0;
15011 if ( v2 > 0 )
15012 {
15013 do
15014 {
15015 v8 = v19;
15016 sprintf(pContainer, "npc%03u", Dst[v19]);
15017 v9 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
15018 ++v19;
15019 pDialogueNPCPortraits[v8] = &pIcons_LOD->pTextures[v9];
15020 result = v19;
15021 }
15022 while ( v19 < uNumDialogueNPCPortraits );
15023 uExitPic = uHouse_ExitPic;
15024 }
15025 if ( uExitPic )
15026 {
15027 v10 = pIcons_LOD->LoadTexture(pHouse_ExitPictures[uExitPic], TEXTURE_16BIT_PALETTE);
15028 v11 = uNumDialogueNPCPortraits++;
15029 pDialogueNPCPortraits[v11] = &pIcons_LOD->pTextures[v10];
15030 //result = *(__int16 *)((char *)p2DEvents_minus1_::2E + v1);
15031 result = p2DEvents[uHouseID - 1].uExitMapID;
15032 uHouse_ExitPic = result;
15033 }
15034 return result;
15035 }
15036
15037
15038
15039
15040
15041 //----- (0044622E) --------------------------------------------------------
15042 bool __fastcall EnterHouse(enum HOUSE_TYPE uHouseID)
15043 {
15044 enum HOUSE_TYPE v1; // edi@1
15045 int v2; // edi@5
15046 unsigned int uOpenTime; // eax@5
15047 int uCloseTime; // esi@5
15048 unsigned int v5; // esi@5
15049 int v6; // edx@5
15050 signed int v7; // ecx@10
15051 signed int v8; // eax@10
15052 int v9; // esi@10
15053 unsigned int v10; // esi@16
15054 int v11; // ecx@17
15055 unsigned int v12; // kr00_4@25
15056 void *v13; // esi@25
15057 int v14; // eax@25
15058 Player *v15; // esi@27
15059 signed int v16; // eax@32
15060 unsigned int v17; // eax@37
15061 signed int v18; // edi@37
15062 signed int v19; // edi@41
15063 unsigned int v20; // ecx@41
15064 const char *v22; // [sp-4h] [bp-40h]@33
15065 char pContainer[40]; // [sp+Ch] [bp-30h]@32
15066 unsigned int v24; // [sp+34h] [bp-8h]@5
15067 enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
15068
15069 v1 = uHouseID;
15070 v25 = uHouseID;
15071 GameUI_StatusBar_TimedString[0] = 0;
15072 pStatusBarString[0] = 0;
15073 ShowStatusBarString("", 2u);
15074 if ( pMessageQueue_50CBD0->uNumMessages )
15075 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
15076 viewparams->bRedrawGameUI = 1;
15077 uDialogueType = 0;
15078 pKeyActionMap->_459ED1(3);
15079 pKeyActionMap->ResetKeys();
15080 if ( v1 == 600 || v1 == 601 )
15081 {
15082 GameOverMenu(0);
15083 return 0;
15084 }
15085 v2 = 26 * v1;
15086 //uOpenTime = p2DEvents_minus1_::uOpenTime[v2];
15087 uOpenTime = p2DEvents[v1 - 1].uOpenTime;
15088 //uCloseTime = p2DEvents_minus1_::uCloseTime[v2];
15089 uCloseTime = p2DEvents[v1 - 1].uCloseTime;
15090 ptr_F8B1E8 = 0;
15091 v24 = uOpenTime;
15092 v5 = uCloseTime - 1;
15093 dword_F8B1E4 = 0;
15094 dword_F8B1F4 = 0;
15095 memset(byte_F8B1F0, 0, 4u);
15096 memset(byte_F8B148, 0, 0x10u);
15097 pRenderer->ClearZBuffer(0, 479);
15098 v6 = v24;
15099 if ( (signed int)v5 <= (signed int)v24 )
15100 {
15101 if ( pParty->uCurrentHour >= v24 )
15102 goto LABEL_16;
15103 }
15104 else
15105 {
15106 if ( pParty->uCurrentHour < v24 )
15107 {
15108 LABEL_10:
15109 v7 = 0;
15110 v8 = 0;
15111 v9 = v5 + 1;
15112 if ( (signed int)v24 > 12 )
15113 {
15114 v6 = v24 - 12;
15115 v7 = 1;
15116 }
15117 if ( v9 > 12 )
15118 {
15119 v9 -= 12;
15120 v8 = 1;
15121 }
15122 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[414], v6, aAMPMNames[v7], v9, aAMPMNames[v8]);
15123 ShowStatusBarString(pTmpBuf, 2u);
15124 if ( uActiveCharacter )
15125 pPlayers[uActiveCharacter]->PlaySound(3, 0);
15126 return 0;
15127 }
15128 }
15129 if ( pParty->uCurrentHour > v5 )
15130 goto LABEL_10;
15131 LABEL_16:
15132 v10 = v25;
15133 if ( (signed int)v25 >= 53 )
15134 goto LABEL_21;
15135 v11 = pParty->field_3C._shop_ban_times[2 * v25 + 1];
15136 if ( !(v11 | pParty->field_3C._shop_ban_times[2 * v25])
15137 || (signed __int64)__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * v25]) <= (signed __int64)pParty->uTimePlayed )
15138 {
15139 pParty->field_3C._shop_ban_times[2 * v25] = 0;
15140 pParty->field_3C._shop_ban_times[2 * v10 + 1] = 0;
15141 LABEL_21:
15142 if ( !dword_597F18 )
15143 pAudioPlayer->StopChannels(-1, -1);
15144 //uCurrentHouse_Animation = p2DEvents_minus1___02[v2];
15145 uCurrentHouse_Animation = p2DEvents[v2 / sizeof(_2devent) - 1].uAnimationID;
15146 dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
15147 if ( dword_F8B198 == 20 && pParty->uFine )
15148 {
15149 uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
15150 v25 = (HOUSE_TYPE)187;
15151 v12 = LODWORD(pParty->uTimePlayed);
15152 LODWORD(pParty->uTimePlayed) += 0x7620000u;
15153 v13 = &pParty->pPlayers[0].uNumDivineInterventionCastsThisDay;
15154 v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[186].uAnimationID].field_C);
15155 pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000;
15156 dword_F8B198 = v14;
15157 do
15158 {
15159 *((short *)v13 - 258) = 0;
15160 memset(v13, 0, 4u);
15161 v13 = (char *)v13 + 6972;
15162 }
15163 while ( (signed int)v13 < (signed int)&pParty->field_871C[694] );
15164 ++pParty->uNumPrisonTerms;
15165 pParty->uFine = 0;
15166 v15 = pParty->pPlayers;
15167 do
15168 {
15169 v15->SetVariable(VAR_Award, 87);
15170 ++v15;
15171 }
15172 while ( (signed int)v15 < (signed int)pParty->pHirelings );
15173 v10 = v25;
15174 }
15175 ++pIcons_LOD->uTexturePacksCount;
15176 if ( !pIcons_LOD->uNumPrevLoadedFiles )
15177 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
15178 v16 = const_2();
15179 sprintf(pContainer, "evt%02d", v16);
15180 if ( pParty->uAlignment )
15181 {
15182 if ( pParty->uAlignment != 2 )
15183 goto LABEL_37;
15184 v22 = "-c";
15185 }
15186 else
15187 {
15188 v22 = "-b";
15189 }
15190 strcat(pContainer, v22);
15191 LABEL_37:
15192 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
15193 array_5913D8[6] = 0;
15194 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
15195 uTextureID_507B04 = uTextureID_right_panel;
15196 PrepareHouse(v10);
15197 v18 = 1;
15198 uTextureID_507B04 = uTextureID_right_panel;
15199 if ( uNumDialogueNPCPortraits == 1 )
15200 array_5913D8[6] = (NPCData *)1;
15201 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
15202 if ( (signed int)v10 < 139 || (signed int)v10 > 172 )
15203 {
15204 if ( (signed int)v10 >= 54 && (signed int)v10 <= 73 && !sub_4B68EA(v10 - 54) )
15205 goto LABEL_49;
15206 v20 = v10;
15207 }
15208 else
15209 {
15210 v19 = word_4F0704[2 * v10] - 1;
15211 v20 = v10;
15212 if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->field_152[v19 >> 3]) )
15213 {
15214 HousePlaySomeSound(v10, 3);
15215 v18 = 1;
15216 LABEL_49:
15217 dword_5C35D4 = v18;
15218 return v18;
15219 }
15220 v18 = 1;
15221 }
15222 HousePlaySomeSound(v20, v18);
15223 goto LABEL_49;
15224 }
15225 ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"
15226 return 0;
15227 }