comparison mm7_1.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 13da46a8d45d
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 /* This file has been generated by the Hex-Rays decompiler.
2 Copyright (c) 2007-2011 Hex-Rays <info@hex-rays.com>
3
4 Detected compiler: Visual C++
5 */
6
7 //#include <defs.h>
8 #include "MM7.h"
9
10 #include "MapInfo.h"
11 #include "Game.h"
12 #include "GUIWindow.h"
13 #include "GUIFont.h"
14 #include "GUIButton.h"
15 #include "GUIProgressBar.h"
16 #include "Party.h"
17 #include "AudioPlayer.h"
18 #include "Outdoor.h"
19 #include "IndoorCamera.h"
20 #include "Overlays.h"
21 #include "Monsters.h"
22 #include "Arcomage.h"
23 #include "LOD.h"
24 #include "Actor.h"
25 #include "Allocator.h"
26 #include "Events.h"
27 #include "Viewport.h"
28 #include "FrameTableInc.h"
29 #include "Math.h"
30 #include "LayingItem.h"
31 #include "ObjectList.h"
32 #include "Chest.h"
33 #include "PaletteManager.h"
34 #include "DecorationList.h"
35 #include "SaveLoad.h"
36 #include "stru123.h"
37 #include "Time.h"
38 #include "IconFrameTable.h"
39 #include "stru179.h"
40 #include "Awards.h"
41 #include "Autonotes.h"
42 #include "stru160.h"
43 #include "stru279.h"
44 #include "TurnEngine.h"
45 #include "stru277.h"
46 #include "Weather.h"
47 #include "stru272.h"
48 #include "stru298.h"
49 #include "StorylineTextTable.h"
50 #include "Events2D.h"
51
52 #include "mm7_data.h"
53
54
55
56
57 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
58 int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4);
59 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive);
60 bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine);
61
62
63
64
65
66
67 void __cdecl FreeSavegameThumbnails()
68 {
69 for (int i = 0; i < 40; ++i)
70 //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels);
71 pSavegameThumbnails[i].Release();
72 }
73
74
75 //----- (004196A0) --------------------------------------------------------
76 void __cdecl sub_4196A0()
77 {
78 GUIButton *i; // esi@2
79 GUIButton *j; // esi@7
80
81 if ( dword_507CC0 )
82 {
83 dword_507CC0 = 0;
84 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
85 {
86 if ( BYTE1(i->field_1C) & 0x80 )
87 GUIButton::_41D0D8(i);
88 }
89 for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext )
90 {
91 if ( j->uControlID == 120 )
92 {
93 j->uX = dword_50698C;
94 j->uY = dword_506988;
95 j->uZ = dword_506984;
96 j->uW = dword_506980;
97 pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
98 }
99 }
100 }
101 }
102 // 506980: using guessed type int dword_506980;
103 // 506984: using guessed type int dword_506984;
104 // 506988: using guessed type int dword_506988;
105 // 50698C: using guessed type int dword_50698C;
106 // 507CC0: using guessed type int dword_507CC0;
107
108 //----- (00419719) --------------------------------------------------------
109 char __fastcall CharacterUI_SkillsTab_Draw(unsigned int uPlayerID)
110 {
111 unsigned int v1; // esi@1
112 Player *pPlayer; // ebp@1
113 unsigned int v3; // eax@1
114 signed int v4; // ecx@1
115 int v5; // edi@3
116 GUIWindow *v6; // ecx@3
117 int v7; // eax@4
118 GUIButton *v8; // edx@5
119 int v9; // eax@7
120 unsigned int v10; // ecx@9
121 unsigned __int16 v11; // ax@9
122 int v12; // eax@9
123 unsigned __int8 v13; // cf@12
124 unsigned __int8 v14; // zf@12
125 unsigned int v15; // eax@12
126 char *v16; // ecx@22
127 GUIWindow *v17; // ecx@33
128 int v18; // edx@34
129 GUIButton *v19; // eax@35
130 int v20; // edx@37
131 unsigned __int16 v21; // cx@39
132 unsigned int v22; // eax@39
133 int v23; // edi@39
134 unsigned int v24; // eax@42
135 char v25; // sf@52
136 char *v26; // ecx@52
137 int v27; // edi@63
138 GUIWindow *v28; // ecx@63
139 int v29; // edx@64
140 GUIButton *v30; // eax@65
141 int v31; // edx@67
142 unsigned int v32; // ecx@69
143 int v33; // eax@69
144 unsigned int v34; // eax@72
145 char *v35; // ecx@82
146 GUIWindow *v36; // ecx@93
147 int v37; // edx@94
148 GUIButton *v38; // eax@94
149 int v39; // edx@97
150 unsigned __int16 v40; // cx@99
151 unsigned int v41; // eax@99
152 int v42; // edi@99
153 unsigned int v43; // eax@102
154 char *v44; // ecx@112
155 char *v46; // [sp-Ch] [bp-4Ch]@19
156 char *v47; // [sp-Ch] [bp-4Ch]@49
157 char *v48; // [sp-Ch] [bp-4Ch]@79
158 char *v49; // [sp-Ch] [bp-4Ch]@109
159 unsigned int v50; // [sp-8h] [bp-48h]@19
160 unsigned int v51; // [sp-8h] [bp-48h]@49
161 unsigned int v52; // [sp-8h] [bp-48h]@79
162 unsigned int v53; // [sp-8h] [bp-48h]@109
163 int v54; // [sp-4h] [bp-44h]@19
164 int v55; // [sp-4h] [bp-44h]@49
165 int v56; // [sp-4h] [bp-44h]@79
166 int v57; // [sp-4h] [bp-44h]@109
167 unsigned int v58; // [sp+10h] [bp-30h]@9
168 unsigned int v59; // [sp+10h] [bp-30h]@39
169 unsigned int v60; // [sp+10h] [bp-30h]@69
170 unsigned int v61; // [sp+10h] [bp-30h]@99
171 int v62; // [sp+14h] [bp-2Ch]@4
172 int v63; // [sp+14h] [bp-2Ch]@34
173 int v64; // [sp+14h] [bp-2Ch]@64
174 int v65; // [sp+14h] [bp-2Ch]@94
175 signed int i; // [sp+18h] [bp-28h]@4
176 signed int v67; // [sp+18h] [bp-28h]@34
177 signed int v68; // [sp+18h] [bp-28h]@64
178 signed int v69; // [sp+18h] [bp-28h]@94
179 int v70; // [sp+1Ch] [bp-24h]@3
180 int v71; // [sp+1Ch] [bp-24h]@33
181 int v72; // [sp+1Ch] [bp-24h]@63
182 int v73; // [sp+1Ch] [bp-24h]@93
183 int uY; // [sp+20h] [bp-20h]@9
184 int uYa; // [sp+20h] [bp-20h]@33
185 int uYb; // [sp+20h] [bp-20h]@69
186 int uYc; // [sp+20h] [bp-20h]@93
187 unsigned int a5; // [sp+24h] [bp-1Ch]@1
188 unsigned int v79; // [sp+28h] [bp-18h]@1
189 int *v80; // [sp+2Ch] [bp-14h]@3
190 int *v81; // [sp+2Ch] [bp-14h]@33
191 int *v82; // [sp+2Ch] [bp-14h]@63
192 int *v83; // [sp+2Ch] [bp-14h]@93
193 unsigned int v84; // [sp+30h] [bp-10h]@1
194 int v85; // [sp+34h] [bp-Ch]@1
195 unsigned int v86; // [sp+38h] [bp-8h]@1
196 unsigned __int16 v87; // [sp+3Ch] [bp-4h]@9
197 char *v88; // [sp+3Ch] [bp-4h]@24
198 char *v89; // [sp+3Ch] [bp-4h]@54
199 unsigned __int16 v90; // [sp+3Ch] [bp-4h]@69
200 char *v91; // [sp+3Ch] [bp-4h]@84
201 char *v92; // [sp+3Ch] [bp-4h]@114
202
203 v1 = uPlayerID;
204 a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
205 v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xAFu, 0xFFu);
206 v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
207 v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
208 v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
209 pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * v1 + 40552];
210 v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE);
211 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
212 v4 = v79;
213 if ( !pPlayer->uSkillPoints )
214 v4 = 65535;
215 sprintf(
216 pTmpBuf,
217 "%s ",
218 pGlobalTXT_LocalizationStrings[206], // Skills for
219 a5,
220 pPlayer->pName,
221 pGlobalTXT_LocalizationStrings[207], // Skill Points
222 v4,
223 pPlayer->uSkillPoints);
224 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
225 v5 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;// Weapons, Level
226 sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[242], pGlobalTXT_LocalizationStrings[131]);
227 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, v5, a5, pTmpBuf, 0, 0, 0);
228 v6 = pGUIWindow_CurrentMenu;
229 v70 = 0;
230 v80 = dword_4E2A2C;
231 do
232 {
233 v62 = *v80;
234 v7 = 0;
235 for ( i = 0; i < (signed int)v6->uNumControls; v7 = i++ + 1 )
236 {
237 v8 = v6->pControlsHead;
238 if ( v7 > 0 )
239 {
240 do
241 {
242 v8 = v8->pNext;
243 --v7;
244 }
245 while ( v7 );
246 }
247 v9 = v8->field_1C;
248 if ( SBYTE1(v9) >= 0 )
249 continue;
250 BYTE1(v9) &= 0x7Fu;
251 if ( v9 != v62 )
252 continue;
253 v5 = v8->uY;
254 v10 = pPlayer->uSkillPoints;
255 ++v70;
256 v11 = pPlayer->pActiveSkills[v62];
257 v87 = pPlayer->pActiveSkills[v62];
258 v12 = v11 & 0x3F;
259 v58 = 0;
260 uY = v12;
261 if ( v10 >= v12 + 1 )
262 v58 = v84;
263 if ( v85 == i )
264 {
265 v13 = v10 < v12;
266 v14 = v10 == v12;
267 v15 = v86;
268 if ( !(v13 | v14) )
269 v15 = v79;
270 v58 = v15;
271 }
272 else
273 {
274 v15 = v58;
275 }
276 if ( HIBYTE(v87) & 1 )
277 {
278 if ( !v15 )
279 v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
280 v54 = uY;
281 v50 = v58;
282 v46 = pGlobalTXT_LocalizationStrings[96];
283 }
284 else
285 {
286 if ( !(v87 & 0xC0) )
287 {
288 sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v62], uY);
289 goto LABEL_28;
290 }
291 v16 = pGlobalTXT_LocalizationStrings[432];
292 if ( (v87 & 0x80u) == 0 )
293 v16 = pGlobalTXT_LocalizationStrings[433];
294 v88 = v16;
295 if ( !v15 )
296 v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
297 v54 = uY;
298 v50 = v58;
299 v46 = v88;
300 }
301 sprintf(pTmpBuf, "%s ", pSkillNames[v62], v15, v46, v50, v54);
302 LABEL_28:
303 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, v5, v58, pTmpBuf, 0, 0, 0);
304 v6 = pGUIWindow_CurrentMenu;
305 }
306 ++v80;
307 }
308 while ( (signed int)v80 < (signed int)dword_4E2A50 );
309 if ( !v70 )
310 {
311 v5 = v5 + LOBYTE(pFontLucida->uFontHeight) - 3;
312 v6->DrawText(pFontLucida, 24, v5, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
313 }
314 uYa = v5 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
315 sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[138], pGlobalTXT_LocalizationStrings[131]);
316 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, uYa, a5, pTmpBuf, 0, 0, 0);
317 v17 = pGUIWindow_CurrentMenu;
318 v71 = 0;
319 v81 = _4E2A80_skills;
320 do
321 {
322 v18 = 0;
323 v67 = 0;
324 v63 = *v81;
325 while ( v67 < (signed int)v17->uNumControls )
326 {
327 v19 = v17->pControlsHead;
328 if ( v18 > 0 )
329 {
330 do
331 {
332 v19 = v19->pNext;
333 --v18;
334 }
335 while ( v18 );
336 }
337 v20 = v19->field_1C;
338 if ( SBYTE1(v20) >= 0 || (BYTE1(v20) &= 0x7Fu, v20 != v63) )
339 goto LABEL_59;
340 ++v71;
341 uYa = v19->uY;
342 v21 = pPlayer->pActiveSkills[v63];
343 v22 = pPlayer->uSkillPoints;
344 v23 = pPlayer->pActiveSkills[v63] & 0x3F;
345 v59 = 0;
346 if ( v22 >= v23 + 1 )
347 v59 = v84;
348 if ( v85 == v67 )
349 {
350 v13 = v22 < v23;
351 v14 = v22 == v23;
352 v24 = v86;
353 if ( !(v13 | v14) )
354 v24 = v79;
355 v59 = v24;
356 }
357 else
358 {
359 v24 = v59;
360 }
361 if ( HIBYTE(v21) & 1 )
362 {
363 if ( !v24 )
364 v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
365 v55 = v23;
366 v51 = v59;
367 v47 = pGlobalTXT_LocalizationStrings[96];
368 }
369 else
370 {
371 if ( !(v21 & 0xC0) )
372 {
373 sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v63], v23);
374 goto LABEL_58;
375 }
376 v25 = (v21 & 0x80u) != 0;
377 v26 = pGlobalTXT_LocalizationStrings[432];
378 if ( !v25 )
379 v26 = pGlobalTXT_LocalizationStrings[433];
380 v89 = v26;
381 if ( !v24 )
382 v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
383 v55 = v23;
384 v51 = v59;
385 v47 = v89;
386 }
387 sprintf(pTmpBuf, "%s ", pSkillNames[v63], v24, v47, v51, v55);
388 LABEL_58:
389 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, uYa, v59, pTmpBuf, 0, 0, 0);
390 v17 = pGUIWindow_CurrentMenu;
391 LABEL_59:
392 v18 = v67++ + 1;
393 }
394 ++v81;
395 }
396 while ( (signed int)v81 < (signed int)pAwardsTextColors );
397 if ( !v71 )
398 v17->DrawText(
399 pFontLucida,
400 24,
401 LOBYTE(pFontLucida->uFontHeight) + uYa - 3,
402 0,
403 pGlobalTXT_LocalizationStrings[153],
404 0,
405 0,
406 0);
407 v27 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
408 sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[11], pGlobalTXT_LocalizationStrings[131]);
409 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, v27, a5, pTmpBuf, 0, 0, 0);
410 v28 = pGUIWindow_CurrentMenu;
411 v72 = 0;
412 v82 = dword_4E2A18;
413 do
414 {
415 v29 = 0;
416 v68 = 0;
417 v64 = *v82;
418 while ( v68 < (signed int)v28->uNumControls )
419 {
420 v30 = v28->pControlsHead;
421 if ( v29 > 0 )
422 {
423 do
424 {
425 v30 = v30->pNext;
426 --v29;
427 }
428 while ( v29 );
429 }
430 v31 = v30->field_1C;
431 if ( SBYTE1(v31) >= 0 || (BYTE1(v31) &= 0x7Fu, v31 != v64) )
432 goto LABEL_89;
433 v27 = v30->uY;
434 ++v72;
435 v60 = 0;
436 v90 = pPlayer->pActiveSkills[v64];
437 v32 = pPlayer->uSkillPoints;
438 v33 = pPlayer->pActiveSkills[v64] & 0x3F;
439 uYb = v33;
440 if ( v32 >= v33 + 1 )
441 v60 = v84;
442 if ( v85 == v68 )
443 {
444 v13 = v32 < v33;
445 v14 = v32 == v33;
446 v34 = v86;
447 if ( !(v13 | v14) )
448 v34 = v79;
449 v60 = v34;
450 }
451 else
452 {
453 v34 = v60;
454 }
455 if ( (pPlayer->pActiveSkills[v64] >> 8) & 1 )
456 {
457 if ( !v34 )
458 v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
459 v56 = uYb;
460 v52 = v60;
461 v48 = pGlobalTXT_LocalizationStrings[96];
462 }
463 else
464 {
465 if ( !(v90 & 0xC0) )
466 {
467 sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v64], uYb);
468 goto LABEL_88;
469 }
470 v35 = pGlobalTXT_LocalizationStrings[432];
471 if ( (v90 & 0x80u) == 0 )
472 v35 = pGlobalTXT_LocalizationStrings[433];
473 v91 = v35;
474 if ( !v34 )
475 v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
476 v56 = uYb;
477 v52 = v60;
478 v48 = v91;
479 }
480 sprintf(pTmpBuf, "%s ", pSkillNames[v64], v34, v48, v52, v56);
481 LABEL_88:
482 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, v27, v60, pTmpBuf, 0, 0, 0);
483 v28 = pGUIWindow_CurrentMenu;
484 LABEL_89:
485 v29 = v68++ + 1;
486 }
487 ++v82;
488 }
489 while ( (signed int)v82 < (signed int)dword_4E2A2C );
490 if ( !v72 )
491 {
492 v27 = v27 + LOBYTE(pFontLucida->uFontHeight) - 3;
493 v28->DrawText(pFontLucida, 248, v27, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
494 }
495 uYc = v27 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
496 sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[143], pGlobalTXT_LocalizationStrings[131]);
497 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, uYc, a5, pTmpBuf, 0, 0, 0);
498 v36 = pGUIWindow_CurrentMenu;
499 v73 = 0;
500 v83 = dword_4E2A50;
501 do
502 {
503 v37 = 0;
504 v69 = 0;
505 v38 = (GUIButton *)*v83;
506 v65 = *v83;
507 while ( v69 < (signed int)v36->uNumControls )
508 {
509 v38 = v36->pControlsHead;
510 if ( v37 > 0 )
511 {
512 do
513 {
514 v38 = v38->pNext;
515 --v37;
516 }
517 while ( v37 );
518 }
519 v39 = v38->field_1C;
520 if ( SBYTE1(v39) >= 0 || (BYTE1(v39) &= 0x7Fu, v39 != v65) )
521 goto LABEL_119;
522 ++v73;
523 uYc = v38->uY;
524 v40 = pPlayer->pActiveSkills[v65];
525 v41 = pPlayer->uSkillPoints;
526 v42 = pPlayer->pActiveSkills[v65] & 0x3F;
527 v61 = 0;
528 if ( v41 >= v42 + 1 )
529 v61 = v84;
530 if ( v85 == v69 )
531 {
532 v13 = v41 < v42;
533 v14 = v41 == v42;
534 v43 = v86;
535 if ( !(v13 | v14) )
536 v43 = v79;
537 v61 = v43;
538 }
539 else
540 {
541 v43 = v61;
542 }
543 if ( HIBYTE(v40) & 1 )
544 {
545 if ( !v43 )
546 v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
547 v57 = v42;
548 v53 = v61;
549 v49 = pGlobalTXT_LocalizationStrings[96];
550 }
551 else
552 {
553 if ( !(v40 & 0xC0) )
554 {
555 sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v65], v42);
556 goto LABEL_118;
557 }
558 v25 = (v40 & 0x80u) != 0;
559 v44 = pGlobalTXT_LocalizationStrings[432];
560 if ( !v25 )
561 v44 = pGlobalTXT_LocalizationStrings[433];
562 v92 = v44;
563 if ( !v43 )
564 v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
565 v57 = v42;
566 v53 = v61;
567 v49 = v92;
568 }
569 sprintf(pTmpBuf, "%s ", pSkillNames[v65], v43, v49, v53, v57);
570 LABEL_118:
571 LOBYTE(v38) = pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, uYc, v61, pTmpBuf, 0, 0, 0);
572 v36 = pGUIWindow_CurrentMenu;
573 LABEL_119:
574 v37 = v69++ + 1;
575 }
576 ++v83;
577 }
578 while ( (signed int)v83 < (signed int)_4E2A80_skills );
579 if ( !v73 )
580 LOBYTE(v38) = v36->DrawText(
581 pFontLucida,
582 248,
583 LOBYTE(pFontLucida->uFontHeight) + uYc - 3,
584 0,
585 pGlobalTXT_LocalizationStrings[153],
586 0,
587 0,
588 0);
589 return (char)v38;
590 }
591
592 //----- (0041A000) --------------------------------------------------------
593 unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID)
594 {
595 unsigned int v1; // esi@1
596 unsigned int v2; // ebx@1
597 unsigned int v3; // eax@1
598 unsigned int result; // eax@1
599 int v5; // eax@15
600 char *v6; // ebx@15
601 int v7; // eax@23
602 int v8; // eax@24
603 int v9; // eax@25
604 int v10; // eax@27
605 int v11; // eax@32
606 int v12; // eax@33
607 int v13; // eax@34
608 signed int v14; // eax@43
609 unsigned int v15; // eax@43
610 int v16; // eax@43
611 int v17; // [sp-4h] [bp-D4h]@16
612 char Source[100]; // [sp+Ch] [bp-C4h]@1
613 GUIWindow a1; // [sp+70h] [bp-60h]@1
614 unsigned int v20; // [sp+C4h] [bp-Ch]@15
615 int v21; // [sp+C8h] [bp-8h]@14
616 int v22; // [sp+CCh] [bp-4h]@40
617
618 v1 = uPlayerID;
619 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
620 v3 = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
621 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
622 sprintf(pTmpBuf, "%s ", pGlobalTXT_LocalizationStrings[23], v2);// TODO check args
623 sprintf(
624 Source,
625 pGlobalTXT_LocalizationStrings[429],
626 &stru_AA1058[3].pSounds[6972 * v1 + 40720],
627 pClassNames[stru_AA1058[3].pSounds[6972 * v1 + 40737]]);
628 strcat(pTmpBuf, Source);
629 strcat(pTmpBuf, "\xC" "00000");
630 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
631 result = dword_506528;
632 a1.uFrameX = 12;
633 a1.uFrameY = 48;
634 a1.uFrameWidth = 424;
635 a1.uFrameHeight = 290;
636 a1.uFrameZ = 435;
637 a1.uFrameW = 337;
638 if ( dword_506544 && dword_506520 + dword_506528 < dword_506524 )
639 result = dword_506528++ + 1;
640 if ( dword_506548 && result )
641 {
642 --result;
643 dword_506528 = result;
644 }
645 if ( dword_50651C < 0 )
646 {
647 result += dword_506520;
648 dword_506528 = result;
649 if ( (signed int)(dword_506520 + result) <= dword_506524 )
650 goto LABEL_14;
651 result = dword_506524 - dword_506520;
652 goto LABEL_13;
653 }
654 if ( dword_50651C > 0 )
655 {
656 result -= dword_506520;
657 dword_506528 = result;
658 if ( (result & 0x80000000u) != 0 )
659 {
660 result = 0;
661 LABEL_13:
662 dword_506528 = result;
663 goto LABEL_14;
664 }
665 }
666 LABEL_14:
667 dword_506544 = 0;
668 dword_506548 = 0;
669 dword_506520 = 0;
670 dword_50651C = 0;
671 v21 = result;
672 if ( (signed int)result < dword_506524 )
673 {
674 while ( 1 )
675 {
676 v5 = pStru179->field_0[v21];
677 v20 = 8 * pStru179->field_0[v21];
678 v6 = (char *)dword_723E80_award_related[v20 / 4];
679 if ( v5 != 1 )
680 break;
681 v17 = pParty->uFine;
682 LABEL_42:
683 sprintf(pTmpBuf, v6, v17);
684 v6 = pTmpBuf;
685 LABEL_43:
686 v14 = dword_723E84[v20 / 4];
687 ++dword_506520;
688 v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
689 pAwardsTextColors[3 * v14 % 6],
690 pAwardsTextColors[3 * v14 % 6 + 1],
691 pAwardsTextColors[3 * v14 % 6 + 2]);
692 a1.DrawText(pFontArrus, 0, 0, v15, v6, 0, 0, 0);
693 v16 = pFontArrus->CalcTextHeight(v6, &a1, 0, 0);
694 result = v16 + a1.uFrameY + 4;
695 if ( (signed int)result <= (signed int)a1.uFrameHeight )
696 {
697 ++v21;
698 a1.uFrameY = result;
699 result = v21;
700 if ( v21 < dword_506524 )
701 continue;
702 }
703 return result;
704 }
705 if ( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) )
706 goto LABEL_43;
707 if ( v5 > 89 )
708 {
709 v11 = v5 - 90;
710 if ( !v11 )
711 {
712 v10 = (unsigned __int8)pParty->uNumArenaKnightWins;
713 goto LABEL_40;
714 }
715 v12 = v11 - 1;
716 if ( !v12 )
717 {
718 v10 = (unsigned __int8)pParty->uNumArenaLordWins;
719 goto LABEL_40;
720 }
721 v13 = v12 - 12;
722 if ( !v13 )
723 {
724 v10 = pParty->field_874;
725 goto LABEL_40;
726 }
727 if ( v13 == 1 )
728 {
729 v10 = pParty->field_878;
730 goto LABEL_40;
731 }
732 }
733 else
734 {
735 if ( v5 == 89 )
736 {
737 v10 = (unsigned __int8)pParty->uNumArenaSquireWins;
738 goto LABEL_40;
739 }
740 v7 = v5 - 85;
741 if ( !v7 )
742 {
743 v10 = pParty->uNumDeaths;
744 goto LABEL_40;
745 }
746 v8 = v7 - 1;
747 if ( !v8 )
748 {
749 v10 = pParty->uNumBountiesCollected;
750 goto LABEL_40;
751 }
752 v9 = v8 - 1;
753 if ( !v9 )
754 {
755 v10 = pParty->uNumPrisonTerms;
756 goto LABEL_40;
757 }
758 if ( v9 == 1 )
759 {
760 v10 = (unsigned __int8)pParty->uNumArenaPageWins;
761 LABEL_40:
762 v22 = v10;
763 goto LABEL_41;
764 }
765 }
766 LABEL_41:
767 v17 = v22;
768 goto LABEL_42;
769 }
770 return result;
771 }
772 // 50651C: using guessed type int dword_50651C;
773 // 506520: using guessed type int dword_506520;
774 // 506524: using guessed type int dword_506524;
775 // 506528: using guessed type int dword_506528;
776 // 506544: using guessed type int dword_506544;
777 // 506548: using guessed type int dword_506548;
778 // 723E80: using guessed type int dword_723E80_award_related[];
779 // 723E84: using guessed type int dword_723E84[];
780
781 //----- (0041A2C1) --------------------------------------------------------
782 unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels)
783 {
784 if ( (signed int)uNumPixels < 14 )
785 uNumPixels = 14;
786 return ((signed int)(uNumPixels - 14) >> 5) + 1;
787 }
788
789 //----- (0041A2D1) --------------------------------------------------------
790 void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2)
791 {
792 Player *v2; // esi@1
793 char v3; // bl@1
794 unsigned int v4; // eax@2
795 ItemGen *v5; // ebx@5
796 unsigned int v6; // eax@6
797 Texture *v7; // esi@6
798 __int16 v8; // ax@6
799 signed int v9; // edi@6
800 signed int v10; // ecx@6
801 signed int v11; // edx@6
802 signed int v12; // eax@11
803 int v13; // eax@13
804 signed int v14; // edx@13
805 int v15; // eax@13
806 unsigned int v16; // ebx@15
807 unsigned int v17; // edi@15
808 Texture *v18; // ebx@24
809 double v19; // st7@26
810 const char *v20; // [sp-8h] [bp-40h]@20
811 Player *v21; // [sp+14h] [bp-24h]@1
812 int uTextureId; // [sp+18h] [bp-20h]@6
813 int *v23; // [sp+1Ch] [bp-1Ch]@1
814 int v24; // [sp+20h] [bp-18h]@5
815 ItemGen *v25; // [sp+24h] [bp-14h]@5
816 int v26; // [sp+28h] [bp-10h]@3
817 signed int v27; // [sp+2Ch] [bp-Ch]@3
818 int a2a; // [sp+30h] [bp-8h]@5
819 int a3; // [sp+34h] [bp-4h]@5
820
821 v23 = pRenderer->pActiveZBuffer;
822 v2 = pPlayers[uPlayerID];
823 v3 = a2;
824 v21 = pPlayers[uPlayerID];
825 pRenderer->DrawTextureIndexed(
826 8u,
827 8u,
828 (Texture *)(uTextureID_507958 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507958] : 0));
829 if ( v3 )
830 {
831 v4 = pIcons_LOD->LoadTexture("fr_strip", TEXTURE_16BIT_PALETTE);
832 pRenderer->DrawTextureIndexed(8u, 0x131u, (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0));
833 }
834 v27 = 0;
835 v26 = (int)v2->pInventoryIndices;
836 do
837 {
838 if ( *(int *)v26 > 0 )
839 {
840 v24 = *(int *)v26 - 1;
841 a3 = 32 * v27 / 14 + 17;
842 v5 = &v2->pInventoryItems[v24];
843 a2a = 32 * v27 % 14 + 14;
844 v25 = v5;
845 if ( v5->uItemID )
846 {
847 v6 = pIcons_LOD->LoadTexture(
848 pItemsTable->pItems[v5->uItemID].pIconName,
849 TEXTURE_16BIT_PALETTE);
850 uTextureId = v6;
851 v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
852 v8 = (v6 != -1 ? pIcons_LOD->pTextures[v6].uTextureWidth : 24);
853 v9 = v7->uTextureHeight;
854 v10 = v7->uTextureWidth;
855 v11 = v7->uTextureWidth;
856 if ( v10 < 14 )
857 v11 = 14;
858 if ( (v11 - 14) >> 5 == 0 && v8 < 32 )
859 a2a += (32 - v10) / 2;
860 v12 = v7->uTextureWidth;
861 if ( v10 < 14 )
862 v12 = 14;
863 v13 = v12 - 14;
864 v14 = v7->uTextureHeight;
865 LOBYTE(v13) = v13 & 0xE0;
866 v15 = v13 + 32;
867 if ( v9 < 14 )
868 v14 = 14;
869 v16 = v5->uAttributes;
870 v17 = a2a + ((v15 - v10) >> 1) + pSRZBufferLineOffsets[a3 + ((((v14 - 14) & 0xFFFFFFE0) - v9 + 32) >> 1)];
871 if ( !(v16 & 0xF0) )
872 {
873 if ( v16 & 1
874 || pCurrentScreen != 13 )
875 {
876 if ( v16 & 2 )
877 pRenderer->_4A6776(a2a, a3, v7);
878 else
879 pRenderer->DrawTextureTransparent(a2a, a3, v7);
880 }
881 else
882 {
883 pRenderer->DrawTransparentGreenShade(a2a, a3, v7);
884 }
885 goto LABEL_33;
886 }
887 if ( (unsigned __int8)(v16 & 0xF0) != 16 )
888 {
889 if ( (unsigned __int8)(v16 & 0xF0) == 32 )
890 {
891 v20 = "sp28a";
892 goto LABEL_24;
893 }
894 if ( (unsigned __int8)(v16 & 0xF0) == 64 )
895 {
896 v20 = "sp30a";
897 goto LABEL_24;
898 }
899 if ( (unsigned __int8)(v16 & 0xF0) == 128 )
900 {
901 v20 = "sp91a";
902 LABEL_24:
903 v18 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
904 dword_50C9A8 -= pEventTimer->uTimeElapsed;
905 if ( dword_50C9A8 <= 0 )
906 {
907 dword_50C9A8 = 0;
908 LOBYTE(v25->uAttributes) &= 0xFu;
909 ptr_50C9A4 = 0;
910 }
911 v19 = (double)GetTickCount() * 0.1;
912 pRenderer->_4A63E6(a2a, a3, v7, v18, (signed __int64)v19, 0, 255);
913 LABEL_33:
914 ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
915 v2 = v21;
916 goto LABEL_34;
917 }
918 }
919 v20 = "sptext01";
920 goto LABEL_24;
921 }
922 }
923 LABEL_34:
924 ++v27;
925 v26 += 4;
926 }
927 while ( v27 < 126 );
928 }
929 // 4E28F8: using guessed type int pCurrentScreen;
930 // 507958: using guessed type int uTextureID_507958;
931 // 50C9A8: using guessed type int dword_50C9A8;
932
933 //----- (0041A556) --------------------------------------------------------
934 void __cdecl draw_leather()
935 {
936 pRenderer->DrawTextureIndexed(
937 8u,
938 8u,
939 (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0));
940 }
941
942 //----- (0041A57E) --------------------------------------------------------
943 char __cdecl QuickRefDraw()
944 {
945 unsigned int v0; // ebx@1
946 unsigned int v1; // eax@1
947 Player *pPlayer; // ebp@2
948 int v3; // eax@6
949 int v4; // edi@6
950 unsigned int v5; // eax@7
951 unsigned int v6; // edi@9
952 unsigned int v7; // edi@11
953 signed int v8; // eax@13
954 unsigned int v9; // eax@13
955 unsigned int v10; // edi@13
956 int v11; // eax@15
957 unsigned int v12; // eax@15
958 unsigned int v13; // edi@15
959 int v14; // eax@17
960 int v15; // ST18_4@17
961 int v16; // ebx@17
962 int v17; // eax@17
963 unsigned int v18; // eax@17
964 unsigned int v19; // edi@17
965 int v20; // eax@19
966 unsigned int v21; // edi@19
967 char *v22; // eax@21
968 unsigned int v23; // edi@21
969 int v24; // eax@23
970 unsigned int v25; // edi@23
971 char *v26; // eax@25
972 unsigned int v27; // edi@25
973 int v28; // ecx@27
974 char *v29; // eax@27
975 signed int v30; // edx@27
976 unsigned int v31; // edi@31
977 unsigned int v32; // edi@33
978 const char *v33; // ST10_4@35
979 unsigned int v34; // eax@35
980 unsigned int v35; // edi@35
981 unsigned __int8 v36; // al@37
982 char *v37; // eax@38
983 int v38; // eax@41
984 signed int v39; // edi@42
985 char *v40; // eax@45
986 unsigned int v41; // eax@45
987 signed int v43; // [sp+10h] [bp-1Ch]@1
988 unsigned int v44; // [sp+14h] [bp-18h]@2
989 int v45; // [sp+18h] [bp-14h]@1
990 unsigned int v46; // [sp+1Ch] [bp-10h]@1
991 unsigned int v47; // [sp+20h] [bp-Ch]@1
992 unsigned int v48; // [sp+24h] [bp-8h]@33
993 unsigned int v49; // [sp+28h] [bp-4h]@1
994
995 v0 = 0;
996 v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
997 v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
998 v46 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
999 v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE);
1000 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
1001 v43 = 0;
1002 v45 = LOBYTE(pFontArrus->uFontHeight) + 1;
1003 do
1004 {
1005 pPlayer = &pParty->pPlayers[v43];
1006 v44 = 94 * v43 + 89;
1007 if ( v43 == v0 )
1008 pGUIWindow_CurrentMenu->DrawTextInRect(
1009 pFontArrus,
1010 0x16u,
1011 0x12u,
1012 v0,
1013 pGlobalTXT_LocalizationStrings[149],
1014 60,
1015 v0);
1016 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 94 * v43 + 89, 0x12u, v47, pPlayer->pName, 84, v0);
1017 if ( v43 == v0 )
1018 pGUIWindow_CurrentMenu->DrawTextInRect(
1019 pFontArrus,
1020 0x16u,
1021 0x2Fu,
1022 v0,
1023 pGlobalTXT_LocalizationStrings[131],
1024 60,
1025 v0);
1026 v3 = pPlayer->GetActualLevel();
1027 sprintf(pTmpBuf, "%lu", v3);
1028 v4 = pPlayer->GetBaseLevel();
1029 if ( pPlayer->GetActualLevel() <= v4 )
1030 v5 = pPlayer->GetExperienceDisplayColor();
1031 else
1032 v5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, v0);
1033 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf, 84, v0);
1034 v6 = v45 + 47;
1035 if ( v43 == v0 )
1036 pGUIWindow_CurrentMenu->DrawTextInRect(
1037 pFontArrus,
1038 0x16u,
1039 v45 + 47,
1040 v0,
1041 pGlobalTXT_LocalizationStrings[41],
1042 60,
1043 v0);
1044 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v6, v0, pClassNames[pPlayer->uClass], 84, v0);
1045 v7 = v45 + v6;
1046 if ( v43 == v0 )
1047 pGUIWindow_CurrentMenu->DrawTextInRect(
1048 pFontArrus,
1049 0x16u,
1050 v7,
1051 v0,
1052 pGlobalTXT_LocalizationStrings[107],
1053 60,
1054 v0);
1055 sprintf(pTmpBuf, "%d", pPlayer->sHealth);
1056 v8 = pPlayer->GetMaxHealth();
1057 v9 = UI_GetHealthManaStringColor(pPlayer->sHealth, v8);
1058 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf, 84, v0);
1059 v10 = v45 + v7;
1060 if ( v43 == v0 )
1061 pGUIWindow_CurrentMenu->DrawTextInRect(
1062 pFontArrus,
1063 0x16u,
1064 v10,
1065 v0,
1066 pGlobalTXT_LocalizationStrings[209],
1067 60,
1068 v0);
1069 sprintf(pTmpBuf, "%d", pPlayer->sMana);
1070 v11 = pPlayer->GetMaxMana();
1071 v12 = UI_GetHealthManaStringColor(pPlayer->sMana, v11);
1072 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf, 84, v0);
1073 v13 = v45 + v10;
1074 if ( v43 == v0 )
1075 pGUIWindow_CurrentMenu->DrawTextInRect(
1076 pFontArrus,
1077 0x16u,
1078 v13,
1079 v0,
1080 pGlobalTXT_LocalizationStrings[0],
1081 60,
1082 v0);
1083 v14 = pPlayer->GetActualAC();
1084 sprintf(pTmpBuf, "%d", v14);
1085 v15 = v0;
1086 v16 = pPlayer->GetBaseAC();
1087 v17 = pPlayer->GetActualAC();
1088 v18 = UI_GetHealthManaStringColor(v17, v16);
1089 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf, 84, v15);
1090 v0 = 0;
1091 v19 = v45 + v13;
1092 if ( !v43 )
1093 pGUIWindow_CurrentMenu->DrawTextInRect(
1094 pFontArrus,
1095 0x16u,
1096 v19,
1097 0,
1098 pGlobalTXT_LocalizationStrings[18],
1099 60,
1100 0);
1101 v20 = pPlayer->GetActualAttack(0);
1102 sprintf(pTmpBuf, "%+d", v20);
1103 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf, 84, 0);
1104 v21 = v45 + v19;
1105 if ( !v43 )
1106 pGUIWindow_CurrentMenu->DrawTextInRect(
1107 pFontArrus,
1108 0x16u,
1109 v21,
1110 0,
1111 pGlobalTXT_LocalizationStrings[66],
1112 60,
1113 0);
1114 v22 = pPlayer->GetMeleeDamageString();
1115 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v21, 0, v22, 84, 0);
1116 v23 = v45 + v21;
1117 if ( !v43 )
1118 pGUIWindow_CurrentMenu->DrawTextInRect(
1119 pFontArrus,
1120 0x16u,
1121 v23,
1122 0,
1123 pGlobalTXT_LocalizationStrings[203],
1124 60,
1125 0);
1126 v24 = pPlayer->GetRangedAttack();
1127 sprintf(pTmpBuf, "%+d", v24);
1128 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf, 84, 0);
1129 v25 = v45 + v23;
1130 if ( !v43 )
1131 pGUIWindow_CurrentMenu->DrawTextInRect(
1132 pFontArrus,
1133 0x16u,
1134 v25,
1135 0,
1136 pGlobalTXT_LocalizationStrings[66],
1137 60,
1138 0);
1139 v26 = pPlayer->GetRangedDamageString();
1140 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v25, 0, v26, 84, 0);
1141 v27 = v45 + v25;
1142 if ( !v43 )
1143 pGUIWindow_CurrentMenu->DrawTextInRect(
1144 pFontArrus,
1145 0x16u,
1146 v27,
1147 0,
1148 pGlobalTXT_LocalizationStrings[205],
1149 60,
1150 0);
1151 v28 = 0;
1152 v29 = (char *)pPlayer->pActiveSkills;
1153 v30 = 36;
1154 do
1155 {
1156 if ( *(short *)v29 )
1157 ++v28;
1158 v29 += 2;
1159 --v30;
1160 }
1161 while ( v30 );
1162 sprintf(pTmpBuf, "%lu", v28);
1163 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf, 84, 0);
1164 v31 = v45 + v27;
1165 if ( !v43 )
1166 pGUIWindow_CurrentMenu->DrawTextInRect(
1167 pFontArrus,
1168 0x16u,
1169 v31,
1170 0,
1171 pGlobalTXT_LocalizationStrings[168],
1172 60,
1173 0);
1174 sprintf(pTmpBuf, "%lu", pPlayer->uSkillPoints);
1175 pGUIWindow_CurrentMenu->DrawTextInRect(
1176 pFontArrus,
1177 v44,
1178 v31,
1179 pPlayer->uSkillPoints != 0 ? v46 : 0,
1180 pTmpBuf,
1181 84,
1182 0);
1183 v32 = v45 + v31;
1184 v48 = pPlayer->GetMajorConditionIdx();
1185 if ( !v43 )
1186 pGUIWindow_CurrentMenu->DrawTextInRect(
1187 pFontArrus,
1188 0x16u,
1189 v32,
1190 0,
1191 pGlobalTXT_LocalizationStrings[45],
1192 60,
1193 0);
1194 v33 = aCharacterConditionNames[v48];
1195 v34 = GetConditionDrawColor(v48);
1196 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v32, v34, v33, 84, 0);
1197 v35 = v45 + v32;
1198 if ( !v43 )
1199 pGUIWindow_CurrentMenu->DrawTextInRect(
1200 pFontArrus,
1201 0x16u,
1202 v35,
1203 0,
1204 pGlobalTXT_LocalizationStrings[170],
1205 60,
1206 0);
1207 v36 = pPlayer->uQuickSpell;
1208 if ( v36 )
1209 v37 = pSpellStats->pInfos[v36].pShortName;
1210 else
1211 v37 = pGlobalTXT_LocalizationStrings[153];
1212 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v35, 0, v37, 84, 0);
1213 ++v43;
1214 }
1215 while ( v43 < 4 );
1216 v38 = GetPartyReputation();
1217 if ( v38 >= 0 )
1218 {
1219 v39 = v49;
1220 if ( v38 <= 5 )
1221 v39 = 65535;
1222 }
1223 else
1224 {
1225 v39 = v46;
1226 }
1227 v40 = GetReputationString(v38);
1228 sprintf(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[180], v39, v40);
1229 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf, 0, 0, 0);
1230 v41 = pParty->GetPartyFame();
1231 sprintf(pTmpBuf, "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], v41);// Fame
1232 return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf, 0, 0, 0);
1233 }
1234
1235 //----- (0041ABFD) --------------------------------------------------------
1236 void __thiscall CharacterUI_CharacterScreen_Draw(unsigned int uPlayerIdx)
1237 {
1238 unsigned int v1; // edi@1
1239 unsigned int v2; // eax@6
1240 Texture *v3; // ecx@6
1241 GUIButton *v4; // eax@6
1242 unsigned int v5; // eax@7
1243 unsigned int v6; // eax@10
1244 unsigned int v7; // eax@11
1245
1246 v1 = uPlayerIdx;
1247 if ( uPlayerIdx )
1248 {
1249 pRenderer->ClearZBuffer(0, 479);
1250 switch ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] )
1251 {
1252 case 0x64: // stats
1253 sub_4196A0();
1254 sub_419379();
1255 CharacterUI_StatsTab_Draw(v1);
1256 v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
1257 v3 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
1258 v4 = pCharacterScreen_StatsBtn;
1259 break;
1260 case 0x65: // skills
1261 if ( dword_507CC0 != uActiveCharacter )
1262 {
1263 sub_4196A0();
1264 sub_419401();
1265 }
1266 sub_419379();
1267 CharacterUI_SkillsTab_Draw(v1);
1268 v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
1269 v3 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
1270 v4 = pCharacterScreen_SkillsBtn;
1271 break;
1272 case 0x66: // awards
1273 sub_4196A0();
1274 sub_419379();
1275 sub_419220();
1276 CharacterUI_AwardsTab_Draw(v1);
1277 v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
1278 v3 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
1279 v4 = pCharacterScreen_AwardsBtn;
1280 break;
1281 default:
1282 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103 )
1283 goto LABEL_13;
1284 sub_4196A0();
1285 sub_419379();
1286 CharacterUI_InventoryTab_Draw(v1, 0);
1287 v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
1288 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
1289 v4 = pCharacterScreen_InventoryBtn;
1290 break;
1291 }
1292 pRenderer->DrawTextureIndexed(v4->uX, v4->uY, v3);
1293 LABEL_13:
1294 if ( bRingsShownInCharScreen )
1295 CharacterUI_DrawPaperdollWithRingOverlay(v1);
1296 else
1297 CharacterUI_DrawPaperdoll(v1);
1298 }
1299 }
1300 // 507CC0: using guessed type int dword_507CC0;
1301 // 5118E0: using guessed type int bRingsShownInCharScreen;
1302
1303 //----- (0041AD6E) --------------------------------------------------------
1304 void __cdecl GameUI_DrawRightPanelItems()
1305 {
1306 if ( (signed int)((pParty->uTimePlayed - qword_507CC8) >> 32) <= 0
1307 && (((pParty->uTimePlayed - qword_507CC8) >> 32) & 0x80000000u) != 0i64 )
1308 qword_507CC8 = 0i64;
1309 if ( (((pParty->uTimePlayed - qword_507CC8) >> 32) & 0x80000000u) == 0i64
1310 && (!(SHIDWORD(pParty->uTimePlayed) < (LODWORD(pParty->uTimePlayed) < (unsigned int)qword_507CC8)
1311 + HIDWORD(qword_507CC8) | (pParty->uTimePlayed - qword_507CC8) >> 32 == 0)
1312 || (unsigned int)(LODWORD(pParty->uTimePlayed) - qword_507CC8) > 0x80) )
1313 {
1314 qword_507CC8 = pParty->uTimePlayed;
1315 byte_50697C = byte_50697C == 0;
1316 if ( byte_50697C
1317 && pCurrentScreen != 5 )
1318 {
1319 if ( bFlashQuestBook )
1320 pRenderer->DrawTextureTransparent(
1321 493u,
1322 355u,
1323 (Texture *)(uTextureID_ib_td1_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0));
1324 if ( bFlashAutonotesBook )
1325 pRenderer->DrawTextureTransparent(
1326 527u,
1327 353u,
1328 (Texture *)(uTextureID_ib_td2_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0));
1329 if ( bFlashHistoryBook )
1330 pRenderer->DrawTextureTransparent(
1331 600u,
1332 361u,
1333 (Texture *)(uTextureID_ib_td5_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0));
1334 }
1335 else
1336 {
1337 pRenderer->DrawTextureRGB(468u, 0, pTexture_RightFrame);
1338 DrawHiredNPCs();
1339 }
1340 }
1341 }
1342
1343 //----- (0041AEBB) --------------------------------------------------------
1344 void __cdecl GameUI_DrawFoodAndGold()
1345 {
1346 unsigned int v0; // ebx@2
1347 unsigned int v1; // ebp@2
1348 int v2; // esi@2
1349
1350 if ( uGameState != GAME_STATE_FINAL_WINDOW )
1351 {
1352 v0 = uGameUIFontMain;
1353 v1 = uGameUIFontShadow;
1354 v2 = sub_44100D() != 0 ? 381 : 322;
1355 sprintf(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
1356 pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
1357 sprintf(pTmpBuf, "\r028%lu", pParty->uNumGold);
1358 pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
1359 }
1360 }
1361
1362 //----- (0041AF52) --------------------------------------------------------
1363 void Actor::DrawHealthBar(Actor *a1, GUIWindow *a2)
1364 {
1365 unsigned int v2; // eax@1
1366 GUIWindow *v3; // edi@1
1367 unsigned int v4; // esi@1
1368 signed int v5; // ebx@4
1369 double v6; // st7@5
1370 unsigned int v7; // eax@6
1371 unsigned int v8; // ebx@10
1372 unsigned int v9; // [sp+14h] [bp-Ch]@4
1373 unsigned int v10; // [sp+1Ch] [bp-4h]@4
1374
1375 v2 = a1->pMonsterInfo.uHP;
1376 v3 = a2;
1377 v4 = 25;
1378 if ( (signed int)v2 > 25 )
1379 {
1380 v4 = 200;
1381 if ( (signed int)v2 < 200 )
1382 v4 = a1->pMonsterInfo.uHP;
1383 }
1384 v5 = a1->sCurrentHP;
1385 v10 = v4;
1386 v9 = uTextureID_mhp_grn;
1387 if ( v5 < (signed int)v2 )
1388 {
1389 v6 = (double)(signed int)v2;
1390 v10 = (signed __int64)((double)(signed int)v4 / (double)(signed int)v2 * (double)a1->sCurrentHP);
1391 if ( v5 <= (signed int)(signed __int64)(0.34 * v6) )
1392 {
1393 v7 = uTextureID_mhp_red;
1394 LABEL_9:
1395 v9 = v7;
1396 goto LABEL_10;
1397 }
1398 if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) )
1399 {
1400 v7 = uTextureID_mhp_yel;
1401 goto LABEL_9;
1402 }
1403 }
1404 LABEL_10:
1405 v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2;
1406 pRenderer->Clip(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52);
1407 pRenderer->DrawTextureIndexed(
1408 v8,
1409 v3->uFrameY + 32,
1410 (Texture *)(uTextureID_mhp_bd != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_bd] : 0));
1411 pRenderer->Clip(v8, v3->uFrameY + 32, v8 + v10, v3->uFrameY + 52);
1412 pRenderer->DrawTextureIndexed(
1413 v8,
1414 v3->uFrameY + 34,
1415 (Texture *)(v9 != -1 ? (int)&pIcons_LOD->pTextures[v9] : 0));
1416 pRenderer->ResetClip();
1417 pRenderer->DrawTextureIndexed(
1418 v8 - 5,
1419 v3->uFrameY + 32,
1420 (Texture *)(uTextureID_mhp_capl != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capl] : 0));
1421 pRenderer->DrawTextureIndexed(
1422 v8 + v4,
1423 v3->uFrameY + 32,
1424 (Texture *)(uTextureID_mhp_capr != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capr] : 0));
1425 }
1426
1427 //----- (0041B0C9) --------------------------------------------------------
1428 void __cdecl GameUI_DrawLifeManaBars()
1429 {
1430 Texture *v0; // ebx@1
1431 Player *v1; // ecx@2
1432 float v2; // ST38_4@3
1433 double v3; // st7@3
1434 signed __int64 v4; // qax@6
1435 Player *v5; // ecx@24
1436 float v6; // ST30_4@25
1437 double v7; // st7@25
1438 bool v8; // ST38_4@27
1439 Texture *v9; // [sp-4h] [bp-30h]@10
1440 Texture *v10; // [sp+Ch] [bp-20h]@1
1441 Player *v11; // [sp+10h] [bp-1Ch]@2
1442 int v12; // [sp+10h] [bp-1Ch]@24
1443 Texture *v13; // [sp+14h] [bp-18h]@1
1444 Texture *v14; // [sp+18h] [bp-14h]@1
1445 float v15; // [sp+1Ch] [bp-10h]@1
1446 signed int v16; // [sp+24h] [bp-8h]@1
1447 signed int v17; // [sp+28h] [bp-4h]@8
1448
1449 v0 = (Texture *)(uTextureID_BarGreen != -1 ? &pIcons_LOD->pTextures[uTextureID_BarGreen] : 0);
1450 v14 = (Texture *)(uTextureID_BarYellow != -1 ? &pIcons_LOD->pTextures[uTextureID_BarYellow] : 0);
1451 v13 = (Texture *)(uTextureID_BarRed != -1 ? &pIcons_LOD->pTextures[uTextureID_BarRed] : 0);
1452 v16 = 0;
1453 v10 = (Texture *)(uTextureID_BarBlue != -1 ? &pIcons_LOD->pTextures[uTextureID_BarBlue] : 0);
1454 v15 = (double)(uTextureID_BarGreen != -1 ? pIcons_LOD->pTextures[uTextureID_BarGreen].uTextureHeight : 26);
1455 do
1456 {
1457 v1 = &pParty->pPlayers[v16];
1458 v11 = v1;
1459 if ( v1->sHealth <= 0 )
1460 goto LABEL_24;
1461 v11 = &pParty->pPlayers[v16];
1462 v2 = (double)v1->sHealth;
1463 v3 = v2 / (double)v1->GetMaxHealth();
1464 if ( v3 <= 0.5 )
1465 {
1466 if ( v3 <= 0.25 )
1467 {
1468 if ( v3 <= 0.0 )
1469 goto LABEL_24;
1470 if ( v16 == 2 || v16 == 3 )
1471 v17 = 2;
1472 else
1473 v17 = 0;
1474 pRenderer->Clip(
1475 v17 + pHealthBarPos[v16],
1476 (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
1477 v17 + pHealthBarPos[v16] + v13->uTextureWidth,
1478 v13->uTextureHeight + 402);
1479 v9 = v13;
1480 }
1481 else
1482 {
1483 if ( v16 == 2 || v16 == 3 )
1484 v17 = 2;
1485 else
1486 v17 = 0;
1487 pRenderer->Clip(
1488 v17 + pHealthBarPos[v16],
1489 (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
1490 v17 + pHealthBarPos[v16] + v14->uTextureWidth,
1491 v14->uTextureHeight + 402);
1492 v9 = v14;
1493 }
1494 }
1495 else
1496 {
1497 if ( v3 > 1.0 )
1498 v3 = 1.0;
1499 v4 = (signed __int64)((1.0 - v3) * v15);
1500 if ( v16 == 2 || v16 == 3 )
1501 v17 = 2;
1502 else
1503 v17 = 0;
1504 pRenderer->Clip(
1505 v17 + pHealthBarPos[v16],
1506 v4 + 402,
1507 v17 + pHealthBarPos[v16] + v0->uTextureWidth,
1508 v0->uTextureHeight + 402);
1509 v9 = v0;
1510 }
1511 pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9);
1512 pRenderer->ResetClip();
1513 LABEL_24:
1514 v5 = v11;
1515 v12 = v11->sMana;
1516 if ( v12 > 0 )
1517 {
1518 v6 = (double)v12;
1519 v7 = v6 / (double)v5->GetMaxMana();
1520 if ( v7 > 1.0 )
1521 v7 = 1.0;
1522 v8 = v16 == 2;
1523 pRenderer->Clip(
1524 (v16 == 2) + pManaBarPos[v16],
1525 (unsigned __int64)(signed __int64)((1.0 - v7) * v15) + 402,
1526 v8 + pManaBarPos[v16] + v10->uTextureWidth,
1527 v10->uTextureHeight + 402);
1528 pRenderer->DrawTextureIndexed(v8 + pManaBarPos[v16], 0x192u, v10);
1529 pRenderer->ResetClip();
1530 }
1531 ++v16;
1532 }
1533 while ( v16 < 4 );
1534 }
1535
1536 //----- (0041B3B6) --------------------------------------------------------
1537 void __cdecl draw_right_panel()
1538 {
1539 pRenderer->DrawTextureTransparent(
1540 pViewport->uViewportZ,
1541 0,
1542 (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
1543 }
1544
1545 //----- (0041B3E2) --------------------------------------------------------
1546 void __cdecl GameUI_DrawRightPanelFrames()
1547 {
1548 pRenderer->DrawTextureRGB(0, 0, pTexture_TopFrame);
1549 pRenderer->DrawTextureRGB(0, 8u, pTexture_LeftFrame);
1550 pRenderer->DrawTextureRGB(468u, 0, pTexture_RightFrame);
1551 pRenderer->DrawTextureRGB(0, 352u, pTexture_BottomFrame);
1552 GameUI_DrawFoodAndGold();
1553 GameUI_DrawRightPanelItems();
1554 }
1555
1556 //----- (0041B438) --------------------------------------------------------
1557 GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey)
1558 {
1559 char v1; // al@1
1560 int v2; // esi@1
1561 char v3; // dl@1
1562 GUIWindow *v4; // ecx@2
1563 GUIButton *result; // eax@2
1564 int v6; // edx@12
1565
1566 v1 = toupper(uHotkey);
1567 v2 = uNumVisibleWindows;
1568 v3 = v1;
1569 if ( uNumVisibleWindows >= 0 )
1570 {
1571 while ( 2 )
1572 {
1573 v4 = &pWindowList[pVisibleWindowsIdxs[v2] - 1];
1574 for ( result = v4->pControlsHead; result; result = result->pNext )
1575 {
1576 if ( result->uHotkey == v3 )
1577 {
1578 v6 = result->uControlParam;
1579 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
1580 {
1581 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)result->uControlID;
1582 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6;
1583 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
1584 ++pMessageQueue_50CBD0->uNumMessages;
1585 }
1586 return result;
1587 }
1588 }
1589 if ( v4->uFrameX || v4->uFrameY || !(v4->uFrameWidth == 640 & v4->uFrameHeight == 480) )
1590 {
1591 --v2;
1592 if ( v2 >= 0 )
1593 continue;
1594 }
1595 break;
1596 }
1597 }
1598 return 0;
1599 }
1600 // 5075E0: using guessed type int pVisibleWindowsIdxs[20];
1601
1602 //----- (0041B4E1) --------------------------------------------------------
1603 int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall)
1604 {
1605 unsigned __int8 v3; // bl@1
1606 int result; // eax@1
1607 int i; // edx@2
1608 GUIButton *j; // ecx@3
1609 int k; // edx@7
1610 GUIButton *l; // ecx@8
1611 unsigned __int8 v9; // [sp+4h] [bp-8h]@1
1612 char v10; // [sp+8h] [bp-4h]@1
1613
1614 v3 = uNewHotkey;
1615 v10 = toupper(uOldHotkey);
1616 result = toupper(v3);
1617 v9 = result;
1618 if ( bFirstCall )
1619 {
1620 for ( i = uNumVisibleWindows; i >= 0; --i )
1621 {
1622 result = 84 * pVisibleWindowsIdxs[i];
1623 //for ( j = *(GUIButton **)((char *)pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_ + result); j; j = j->pNext )
1624 for ( j = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; j; j = j->pNext )
1625 j->field_28 = 0;
1626 }
1627 }
1628 for ( k = uNumVisibleWindows; k >= 0; --k )
1629 {
1630 result = 84 * pVisibleWindowsIdxs[k];
1631 //for ( l = *(GUIButton **)((char *)pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_ + result); l; l = l->pNext )
1632 for ( l = pWindowList[pVisibleWindowsIdxs[k] - 1].pControlsHead; l; l = l->pNext )
1633 {
1634 LOBYTE(result) = v10;
1635 if ( l->uHotkey == v10 )
1636 {
1637 if ( !l->field_28 )
1638 {
1639 LOBYTE(result) = v9;
1640 l->field_28 = 1;
1641 l->uHotkey = v9;
1642 }
1643 }
1644 }
1645 }
1646 return result;
1647 }
1648 // 5075E0: using guessed type int pVisibleWindowsIdxs[20];
1649
1650 //----- (0041B578) --------------------------------------------------------
1651 void __cdecl MainMenuUI_LoadFontsAndSomeStuff()
1652 {
1653 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits,
1654 pRenderer->uTargetGBits,
1655 pRenderer->uTargetBBits);
1656 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits,
1657 pRenderer->uTargetGBits,
1658 pRenderer->uTargetBBits);
1659 pPaletteManager->RecalculateAll();
1660
1661 for (uint i = 0; i < 480; ++i)
1662 pSRZBufferLineOffsets[i] = 640 * i;
1663
1664 pRenderer->ResetClip();
1665
1666 uTextureID_FONTPAL = pIcons_LOD->LoadTexture("FONTPAL", TEXTURE_16BIT_PALETTE);
1667 pFontArrus = LoadFont("arrus.fnt", "FONTPAL", 0);
1668 pFontLucida = LoadFont("lucida.fnt", "FONTPAL", 0);
1669 pFontCreate = LoadFont("create.fnt", "FONTPAL", 0);
1670 pFontSmallnum = LoadFont("smallnum.fnt", "FONTPAL", 0);
1671 pFontComic = LoadFont("comic.fnt", "FONTPAL", 0);
1672 pFontArrus->field_3 = 0;
1673 pFontLucida->field_3 = 0;
1674 pFontCreate->field_3 = 0;
1675
1676 for (uint i = 0; i < 20; ++i)
1677 pWindowList[i].eWindowType = WINDOW_null;
1678
1679 uNumVisibleWindows = -1;
1680 memset(pVisibleWindowsIdxs, 0, sizeof(pVisibleWindowsIdxs));
1681 }
1682
1683 //----- (0041B690) --------------------------------------------------------
1684 void __cdecl MainMenuUI_Create()
1685 {
1686 unsigned int v0; // eax@1
1687 unsigned int v1; // eax@1
1688 unsigned int v2; // eax@1
1689 unsigned int v3; // eax@1
1690 unsigned int v4; // eax@1
1691 unsigned int v5; // eax@1
1692 Texture *v6; // ST78_4@1
1693 const char *v7; // ST5C_4@1
1694 unsigned __int8 v8; // al@1
1695 //Texture *v9; // ST60_4@1
1696 Texture *v10; // ST78_4@1
1697 const char *v11; // ST5C_4@1
1698 unsigned __int8 v12; // al@1
1699 //Texture *v13; // ST60_4@1
1700 unsigned int v14; // eax@1
1701 Texture *v15; // ST78_4@1
1702 const char *v16; // ST5C_4@1
1703 unsigned __int8 v17; // al@1
1704 //Texture *v18; // ST60_4@1
1705 unsigned int uTextureID_ib_td4_A; // eax@1
1706 Texture *v20; // ST78_4@1
1707 const char *v21; // ST5C_4@1
1708 unsigned __int8 v22; // al@1
1709 //Texture *v23; // ST60_4@1
1710 Texture *v24; // eax@1
1711 Texture *v25; // esi@1
1712 Texture *v26; // ST60_4@1
1713 const char *v27; // ST5C_4@1
1714 unsigned __int8 v28; // al@1
1715 Texture *v29; // eax@1
1716 Texture *v30; // esi@1
1717 Texture *v31; // ST60_4@1
1718 const char *v32; // ST5C_4@1
1719 unsigned __int8 v33; // al@1
1720
1721 v0 = pIconsFrameTable->FindIcon("wizeyeC");
1722 pIconsFrameTable->InitializeAnimation(v0);
1723 v1 = pIconsFrameTable->FindIcon("wizeyeB");
1724 pIconsFrameTable->InitializeAnimation(v1);
1725 v2 = pIconsFrameTable->FindIcon("wizeyeA");
1726 pIconsFrameTable->InitializeAnimation(v2);
1727 v3 = pIconsFrameTable->FindIcon("torchC");
1728 pIconsFrameTable->InitializeAnimation(v3);
1729 v4 = pIconsFrameTable->FindIcon("torchB");
1730 pIconsFrameTable->InitializeAnimation(v4);
1731 v5 = pIconsFrameTable->FindIcon("torchA");
1732 pIconsFrameTable->InitializeAnimation(v5);
1733 pTextureIDs_pMapDirs[0] = pIcons_LOD->LoadTexture("MAPDIR8", TEXTURE_16BIT_PALETTE);
1734 pTextureIDs_pMapDirs[1] = pIcons_LOD->LoadTexture("MAPDIR1", TEXTURE_16BIT_PALETTE);
1735 pTextureIDs_pMapDirs[2] = pIcons_LOD->LoadTexture("MAPDIR2", TEXTURE_16BIT_PALETTE);
1736 pTextureIDs_pMapDirs[3] = pIcons_LOD->LoadTexture("MAPDIR3", TEXTURE_16BIT_PALETTE);
1737 pTextureIDs_pMapDirs[4] = pIcons_LOD->LoadTexture("MAPDIR4", TEXTURE_16BIT_PALETTE);
1738 pTextureIDs_pMapDirs[5] = pIcons_LOD->LoadTexture("MAPDIR5", TEXTURE_16BIT_PALETTE);
1739 pTextureIDs_pMapDirs[6] = pIcons_LOD->LoadTexture("MAPDIR6", TEXTURE_16BIT_PALETTE);
1740 pTextureIDs_pMapDirs[7] = pIcons_LOD->LoadTexture("MAPDIR7", TEXTURE_16BIT_PALETTE);
1741 uTextureID_BarBlue = pIcons_LOD->LoadTexture("ib-statB", TEXTURE_16BIT_PALETTE);
1742 uTextureID_BarGreen = pIcons_LOD->LoadTexture("ib-statG", TEXTURE_16BIT_PALETTE);
1743 uTextureID_BarYellow = pIcons_LOD->LoadTexture("ib-statY", TEXTURE_16BIT_PALETTE);
1744 uTextureID_BarRed = pIcons_LOD->LoadTexture("ib-statR", TEXTURE_16BIT_PALETTE);
1745 uTextureID_mhp_bd = pIcons_LOD->LoadTexture("mhp_bg", TEXTURE_16BIT_PALETTE);
1746 uTextureID_mhp_capl = pIcons_LOD->LoadTexture("mhp_capl", TEXTURE_16BIT_PALETTE);
1747 uTextureID_mhp_capr = pIcons_LOD->LoadTexture("mhp_capr", TEXTURE_16BIT_PALETTE);
1748 uTextureID_mhp_grn = pIcons_LOD->LoadTexture("mhp_grn", TEXTURE_16BIT_PALETTE);
1749 uTextureID_mhp_red = pIcons_LOD->LoadTexture("mhp_red", TEXTURE_16BIT_PALETTE);
1750 uTextureID_mhp_yel = pIcons_LOD->LoadTexture("mhp_yel", TEXTURE_16BIT_PALETTE);
1751 uTextureID_Leather = pIcons_LOD->LoadTexture("LEATHER", TEXTURE_16BIT_PALETTE);
1752 pTexture_Leather = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ibground", TEXTURE_16BIT_PALETTE)];
1753 uTextureID_x_x_u = pIcons_LOD->LoadTexture("x_x_u", TEXTURE_16BIT_PALETTE);
1754 uTextureID_BUTTDESC2 = pIcons_LOD->LoadTexture("BUTTESC2", TEXTURE_16BIT_PALETTE);
1755 uTextureID_x_ok_u = pIcons_LOD->LoadTexture("x_ok_u", TEXTURE_16BIT_PALETTE);
1756 uTextureID_BUTTYES2 = pIcons_LOD->LoadTexture("BUTTYES2", TEXTURE_16BIT_PALETTE);
1757 uTextureID_BUTTMAKE = pIcons_LOD->LoadTexture("BUTTMAKE", TEXTURE_16BIT_PALETTE);
1758 uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE);
1759
1760 pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
1761 pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, 0xAu, 0, 0, "", 0);
1762 pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
1763 pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
1764 pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
1765 pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
1766 pPrimaryWindow->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
1767 pPrimaryWindow->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
1768 pPrimaryWindow->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
1769 pPrimaryWindow->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
1770 pPrimaryWindow->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
1771 pPrimaryWindow->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
1772 pPrimaryWindow->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
1773 pPrimaryWindow->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
1774 uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
1775 v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
1776 v7 = pGlobalTXT_LocalizationStrings[174];
1777 v8 = pKeyActionMap->GetActionVKey(INPUT_Quest);
1778 pBtn_Quests = pPrimaryWindow->CreateButton(
1779 0x1EBu,
1780 0x161u,
1781 v6->uTextureWidth,
1782 v6->uTextureHeight,
1783 1,
1784 0,
1785 0xC8u,
1786 0,
1787 v8,
1788 v7,
1789 v6, 0);
1790 uTextureID_ib_td2_A = pIcons_LOD->LoadTexture("ib-td2-A", TEXTURE_16BIT_PALETTE);
1791 v10 = (Texture *)(uTextureID_ib_td2_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0);
1792 v11 = pGlobalTXT_LocalizationStrings[154];
1793 v12 = pKeyActionMap->GetActionVKey(INPUT_Autonotes);
1794 pBtn_Autonotes = pPrimaryWindow->CreateButton(
1795 0x20Fu,
1796 0x161u,
1797 v10->uTextureWidth,
1798 v10->uTextureHeight,
1799 1,
1800 0,
1801 0xC9u,
1802 0,
1803 v12,
1804 v11,
1805 v10);
1806 v14 = pIcons_LOD->LoadTexture("ib-td3-A", TEXTURE_16BIT_PALETTE);
1807 v15 = (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0);
1808 v16 = pGlobalTXT_LocalizationStrings[139];
1809 v17 = pKeyActionMap->GetActionVKey(INPUT_Mapbook);
1810 pBtn_Maps = pPrimaryWindow->CreateButton(
1811 0x222u,
1812 0x161u,
1813 v15->uTextureWidth,
1814 v15->uTextureHeight,
1815 1,
1816 0,
1817 0xCAu,
1818 0,
1819 v17,
1820 v16,
1821 v15);
1822 uTextureID_ib_td4_A = pIcons_LOD->LoadTexture("ib-td4-A", TEXTURE_16BIT_PALETTE);
1823 v20 = (Texture *)(uTextureID_ib_td4_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td4_A] : 0);
1824 v21 = pGlobalTXT_LocalizationStrings[78];
1825 v22 = pKeyActionMap->GetActionVKey(INPUT_TimeCal);
1826 pBtn_Calendar = pPrimaryWindow->CreateButton(
1827 0x23Au,
1828 0x161u,
1829 v20->uTextureWidth,
1830 v20->uTextureHeight,
1831 1,
1832 0,
1833 0xCBu,
1834 0,
1835 v22,
1836 v21,
1837 v20);
1838 uTextureID_ib_td5_A = pIcons_LOD->LoadTexture("ib-td5-A", TEXTURE_16BIT_PALETTE);
1839 pBtn_History = pPrimaryWindow->CreateButton(
1840 0x258u,
1841 0x169u,
1842 (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureWidth : 24),
1843 (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureHeight : 26),
1844 1,
1845 0,
1846 0xE0u,
1847 0,
1848 0x48u,
1849 pGlobalTXT_LocalizationStrings[602],
1850 (Texture *)(uTextureID_ib_td5_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0),
1851 0);
1852 v24 = &pIcons_LOD->pTextures[uTextureID_507980];
1853 v25 = (Texture *)(uTextureID_507980 != -1 ? (int)v24 : 0);
1854 bFlashHistoryBook = 0;
1855 v26 = (Texture *)(uTextureID_507980 != -1 ? (int)v24 : 0);
1856 bFlashAutonotesBook = 0;
1857 v27 = pGlobalTXT_LocalizationStrings[252];
1858 bFlashQuestBook = 0;
1859 v28 = pKeyActionMap->GetActionVKey(INPUT_ZoomIn);
1860 dword_507A18 = pPrimaryWindow->CreateButton(
1861 0x23Eu,
1862 0x88u,
1863 v25->uTextureWidth,
1864 v25->uTextureHeight,
1865 2,
1866 0,
1867 0x170u,
1868 0,
1869 v28,
1870 v27,
1871 v26,
1872 0);
1873 v29 = &pIcons_LOD->pTextures[uTextureID_507984];
1874 v30 = (Texture *)(uTextureID_507984 != -1 ? (int)v29 : 0);
1875 v31 = (Texture *)(uTextureID_507984 != -1 ? (int)v29 : 0);
1876 v32 = pGlobalTXT_LocalizationStrings[251];
1877 v33 = pKeyActionMap->GetActionVKey(INPUT_ZoomOut);
1878 dword_507A14 = pPrimaryWindow->CreateButton(
1879 0x207u,
1880 0x88u,
1881 v30->uTextureWidth,
1882 v30->uTextureHeight,
1883 2,
1884 0,
1885 0x16Fu,
1886 0,
1887 v33,
1888 v32,
1889 v31,
1890 0);
1891 pPrimaryWindow->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, 0, 0, 0, "", 0);
1892 pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x86u, 0, 0x35u, "", 0);
1893 pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x87u, 0, 0x36u, "", 0);
1894 pPrimaryWindow->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, 0, 0, 0, "", 0);
1895 pPrimaryWindow->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, 0, 0, 0, "", 0);
1896 pBtn_CastSpell = pPrimaryWindow->CreateButton(
1897 0x1DCu,
1898 0x1C2u,
1899 (uTextureID_50797C != -1 ? pIcons_LOD->pTextures[uTextureID_50797C].uTextureWidth : 24),
1900 (uTextureID_50797C != -1 ? pIcons_LOD->pTextures[uTextureID_50797C].uTextureHeight : 26),
1901 1,
1902 0,
1903 0x69u,
1904 0,
1905 0x43u,
1906 pGlobalTXT_LocalizationStrings[38],
1907 (Texture *)(uTextureID_50797C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50797C] : 0),
1908 0);
1909 pBtn_Rest = pPrimaryWindow->CreateButton(
1910 0x206u,
1911 0x1C2u,
1912 (uTextureID_507978 != -1 ? pIcons_LOD->pTextures[uTextureID_507978].uTextureWidth : 24),
1913 (uTextureID_507978 != -1 ? pIcons_LOD->pTextures[uTextureID_507978].uTextureHeight : 26),
1914 1,
1915 0,
1916 0x68u,
1917 0,
1918 0x52u,
1919 pGlobalTXT_LocalizationStrings[182],
1920 (Texture *)(uTextureID_507978 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507978] : 0),
1921 0);
1922 pBtn_QuickReference = pPrimaryWindow->CreateButton(
1923 0x230u,
1924 0x1C2u,
1925 (dword_507974 != -1 ? pIcons_LOD->pTextures[dword_507974].uTextureWidth : 24),
1926 (dword_507974 != -1 ? pIcons_LOD->pTextures[dword_507974].uTextureHeight : 26),
1927 1,
1928 0,
1929 0x6Au,
1930 0,
1931 0x5Au,
1932 pGlobalTXT_LocalizationStrings[173],
1933 (Texture *)(dword_507974 != -1 ? &pIcons_LOD->pTextures[dword_507974] : 0),
1934 0);
1935 pBtn_GameSettings = pPrimaryWindow->CreateButton(
1936 0x25Au,
1937 0x1C2u,
1938 (uTextureID_507970 != -1 ? pIcons_LOD->pTextures[uTextureID_507970].uTextureWidth : 24),
1939 (uTextureID_507970 != -1 ? pIcons_LOD->pTextures[uTextureID_507970].uTextureHeight : 26),
1940 1,
1941 0,
1942 0x6Bu,
1943 0,
1944 0,
1945 pGlobalTXT_LocalizationStrings[93],
1946 (Texture *)(uTextureID_507970 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507970] : 0),
1947 0);
1948 pBtn_NPCLeft = pPrimaryWindow->CreateButton(
1949 0x1D5u,
1950 0xB2u,
1951 (uTextureID_507990 != -1 ? pIcons_LOD->pTextures[uTextureID_507990].uTextureWidth : 24),
1952 (uTextureID_507990 != -1 ? pIcons_LOD->pTextures[uTextureID_507990].uTextureHeight : 26),
1953 1,
1954 0,
1955 0xBCu,
1956 0,
1957 0,
1958 "",
1959 (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
1960 0);
1961 pBtn_NPCRight = pPrimaryWindow->CreateButton(
1962 0x272u,
1963 0xB2u,
1964 (uTextureID_50798C != -1 ? pIcons_LOD->pTextures[uTextureID_50798C].uTextureWidth : 24),
1965 (uTextureID_50798C != -1 ? pIcons_LOD->pTextures[uTextureID_50798C].uTextureHeight : 26),
1966 1,
1967 0,
1968 0xBCu,
1969 1u,
1970 0,
1971 "",
1972 (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
1973 0);
1974 Load_isn_spells_21_27();
1975 }
1976
1977
1978
1979 //----- (0041C047) --------------------------------------------------------
1980 void __cdecl GameUI_DrawStatusBar_2()
1981 {
1982 unsigned int v0; // eax@1
1983 char *v1; // edx@2
1984 unsigned int v2; // ST18_4@5
1985 const char *v3; // ST0C_4@5
1986 unsigned int v4; // ST08_4@5
1987 int v5; // eax@5
1988
1989 pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar);
1990 if ( GameUI_StatusBar_TimedStringTimeLeft )
1991 {
1992 v1 = GameUI_StatusBar_TimedString;
1993 }
1994 else
1995 {
1996 if ( !pStatusBarString[0] )
1997 return;
1998 v1 = pStatusBarString;
1999 }
2000 LOWORD(v0) = uGameUIFontShadow;
2001 v2 = v0;
2002 LOWORD(v0) = uGameUIFontMain;
2003 v3 = v1;
2004 v4 = v0;
2005 v5 = pFontLucida->AlignText_Center(0x1C2u, v1);
2006 pPrimaryWindow->DrawText(pFontLucida, v5 + 11, 357, v4, v3, 0, 0, v2);
2007 }
2008
2009 //----- (0041C0B8) --------------------------------------------------------
2010 void __thiscall sub_41C0B8_set_status_string(const char *pStr)
2011 {
2012 const char *v1; // esi@1
2013 int i; // eax@7
2014 int j; // eax@11
2015
2016 v1 = pStr;
2017 if ( pStr && strcmp(pStr, "test") && !IsBadStringPtrA(v1, 1u) && (*v1 || GameUI_StatusBar_TimedStringTimeLeft) )
2018 {
2019 if ( GameUI_StatusBar_TimedStringTimeLeft )
2020 {
2021 for ( i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString);
2022 i > 450;
2023 i = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString) )
2024 byte_5C3427[strlen(GameUI_StatusBar_TimedString)] = 0;
2025 }
2026 else
2027 {
2028 strcpy(pStatusBarString, v1);
2029 for ( j = pFontLucida->GetLineWidth(pStatusBarString);
2030 j > 450;
2031 j = pFontLucida->GetLineWidth(pStatusBarString) )
2032 GameUI_StatusBar_TimedString[strlen(pStatusBarString) + 199] = 0;
2033 }
2034 }
2035 }
2036
2037 //----- (0041C179) --------------------------------------------------------
2038 void __cdecl GameUI_DrawStatusBar()
2039 {
2040 unsigned int v0; // ebp@1
2041 char *v1; // edi@5
2042 int v2; // eax@5
2043 unsigned int v3; // esi@5
2044 size_t v4; // eax@6
2045 GUIFont *v5; // ecx@6
2046 int v6; // eax@9
2047 size_t v7; // eax@10
2048 GUIFont *v8; // ecx@10
2049 char v9; // zf@12
2050 unsigned int v10; // ST08_4@13
2051 int v11; // eax@13
2052
2053 v0 = uGameUIFontShadow;
2054 if ( pStatusBarString[0] || GameUI_StatusBar_TimedStringTimeLeft || bForceDrawStatusBar )
2055 {
2056 pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar);
2057 if ( GameUI_StatusBar_TimedStringTimeLeft )
2058 {
2059 v1 = GameUI_StatusBar_TimedString;
2060 v2 = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString);
2061 v3 = 450;
2062 while ( v2 > 450 )
2063 {
2064 v4 = strlen(GameUI_StatusBar_TimedString);
2065 v5 = pFontLucida;
2066 byte_5C3427[v4] = 0;
2067 v2 = pFontLucida->GetLineWidth(GameUI_StatusBar_TimedString);
2068 }
2069 }
2070 else
2071 {
2072 v1 = pStatusBarString;
2073 v6 = pFontLucida->GetLineWidth(pStatusBarString);
2074 v3 = 450;
2075 while ( v6 > 450 )
2076 {
2077 v7 = strlen(pStatusBarString);
2078 v8 = pFontLucida;
2079 GameUI_StatusBar_TimedString[v7 + 199] = 0;
2080 v6 = pFontLucida->GetLineWidth(pStatusBarString);
2081 }
2082 }
2083 v9 = *v1 == 0;
2084 bForceDrawStatusBar = 0;
2085 if ( !v9 )
2086 {
2087 v10 = uGameUIFontMain;
2088 v11 = pFontLucida->AlignText_Center(v3, v1);
2089 pPrimaryWindow->DrawText(pFontLucida, v11 + 11, 357, v10, v1, 0, 0, v0);
2090 }
2091 }
2092 }
2093 // 5C35BC: using guessed type int bForceDrawStatusBar;
2094
2095
2096 //----- (0041CD4F) --------------------------------------------------------
2097 bool __thiscall sub_41CD4F(unsigned int _this)
2098 {
2099 unsigned int v1; // edi@1
2100 unsigned int v2; // eax@2
2101 int v3; // esi@3
2102 int v4; // ecx@10
2103 GUIButton *v5; // eax@11
2104 int v6; // edx@12
2105 int v7; // ecx@20
2106 char v8; // zf@21
2107 GUIButton *v9; // ecx@24
2108 int v10; // esi@24
2109 int v11; // edx@26
2110 int v12; // edx@28
2111 int v13; // esi@32
2112 GUIButton *v14; // eax@37
2113 int v15; // edx@38
2114 int v17; // ecx@50
2115 int v18; // edx@50
2116 GUIButton *v19; // ecx@54
2117 int v20; // esi@54
2118 int v21; // edx@56
2119 int v22; // ecx@59
2120 int v23; // edx@59
2121 int v24; // ecx@60
2122 int v25; // esi@63
2123 unsigned int v26; // [sp+Ch] [bp-14h]@1
2124 int v27; // [sp+10h] [bp-10h]@1
2125 int v28; // [sp+14h] [bp-Ch]@10
2126 int v29; // [sp+14h] [bp-Ch]@36
2127 unsigned int uClickX; // [sp+18h] [bp-8h]@10
2128 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10
2129
2130 v1 = 0;
2131 v26 = _this;
2132 v27 = uNumVisibleWindows;
2133 if ( uNumVisibleWindows < 0 )
2134 return 0;
2135 v2 = pMessageQueue_50CBD0->uNumMessages;
2136 while ( 1 )
2137 {
2138 v3 = pVisibleWindowsIdxs[v27] - 1;
2139 if ( pWindowList[v3].field_44 == v1 )
2140 goto LABEL_47;
2141 if ( v26 != 34 )
2142 break;
2143 if ( pWindowList[v3].field_30 != v1 )
2144 {
2145 pMouse->GetClickPos(&uClickX, &uClickY);
2146 v4 = pWindowList[v3].pStartingPosActiveItem;
2147 v29 = v4 + pWindowList[v3].pNumPresenceButton;
2148 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
2149 {
2150 while ( 1 )
2151 {
2152 v14 = pWindowList[v3].pControlsHead;
2153 if ( v4 > 0 )
2154 {
2155 v15 = v4;
2156 do
2157 {
2158 v14 = v14->pNext;
2159 --v15;
2160 }
2161 while ( v15 );
2162 }
2163 if ( (signed int)uClickX >= (signed int)v14->uX
2164 && (signed int)uClickX <= (signed int)v14->uZ
2165 && (signed int)uClickY >= (signed int)v14->uY
2166 && (signed int)uClickY <= (signed int)v14->uW )
2167 goto LABEL_66;
2168 ++v4;
2169 if ( v4 >= v29 )
2170 {
2171 LABEL_45:
2172 v1 = 0;
2173 goto LABEL_46;
2174 }
2175 }
2176 }
2177 goto LABEL_46;
2178 }
2179 LABEL_47:
2180 --v27;
2181 if ( v27 < 0 )
2182 return 0;
2183 }
2184 if ( v26 == 37 )
2185 {
2186 v12 = pWindowList[v3].field_34;
2187 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 )
2188 {
2189 v8 = pCurrentScreen == 21;
2190 pWindowList[v3].pCurrentPosActiveItem -= v12;
2191 if ( v8 )
2192 {
2193 pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
2194 v2 = pMessageQueue_50CBD0->uNumMessages;
2195 }
2196 }
2197 if ( pWindowList[v3].field_30 != v1 )
2198 goto LABEL_47;
2199 v9 = pWindowList[v3].pControlsHead;
2200 v13 = pWindowList[v3].pCurrentPosActiveItem;
2201 if ( v13 > (signed int)v1 )
2202 {
2203 do
2204 {
2205 v9 = v9->pNext;
2206 --v13;
2207 }
2208 while ( v13 );
2209 }
2210 LABEL_26:
2211 v11 = v9->uControlParam;
2212 if ( (signed int)v2 < 40 )
2213 {
2214 pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v9->uControlID;
2215 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11;
2216 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
2217 v2 = pMessageQueue_50CBD0->uNumMessages + 1;
2218 ++pMessageQueue_50CBD0->uNumMessages;
2219 }
2220 goto LABEL_47;
2221 }
2222 if ( v26 != 38 )
2223 {
2224 if ( v26 == 39 )
2225 {
2226 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34;
2227 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem )
2228 {
2229 v8 = pCurrentScreen == 21;
2230 pWindowList[v3].pCurrentPosActiveItem = v7;
2231 if ( v8 )
2232 {
2233 pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
2234 v2 = pMessageQueue_50CBD0->uNumMessages;
2235 }
2236 }
2237 if ( pWindowList[v3].field_30 != v1 )
2238 goto LABEL_47;
2239 v9 = pWindowList[v3].pControlsHead;
2240 v10 = pWindowList[v3].pCurrentPosActiveItem;
2241 if ( v10 > (signed int)v1 )
2242 {
2243 do
2244 {
2245 v9 = v9->pNext;
2246 --v10;
2247 }
2248 while ( v10 );
2249 }
2250 goto LABEL_26;
2251 }
2252 if ( v26 == 40 )
2253 {
2254 v17 = pWindowList[v3].pStartingPosActiveItem;
2255 v18 = pWindowList[v3].pCurrentPosActiveItem;
2256 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 )
2257 pWindowList[v3].pCurrentPosActiveItem = v17;
2258 else
2259 pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
2260 if ( pWindowList[v3].field_30 != v1 )
2261 return 1;
2262 v19 = pWindowList[v3].pControlsHead;
2263 v20 = pWindowList[v3].pCurrentPosActiveItem;
2264 if ( v20 > (signed int)v1 )
2265 {
2266 do
2267 {
2268 v19 = v19->pNext;
2269 --v20;
2270 }
2271 while ( v20 );
2272 }
2273 goto LABEL_56;
2274 }
2275 if ( v26 == 41 )
2276 {
2277 pMouse->GetClickPos(&uClickX, &uClickY);
2278 v4 = pWindowList[v3].pStartingPosActiveItem;
2279 v28 = v4 + pWindowList[v3].pNumPresenceButton;
2280 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
2281 {
2282 while ( 1 )
2283 {
2284 v5 = pWindowList[v3].pControlsHead;
2285 if ( v4 > 0 )
2286 {
2287 v6 = v4;
2288 do
2289 {
2290 v5 = v5->pNext;
2291 --v6;
2292 }
2293 while ( v6 );
2294 }
2295 if ( (signed int)uClickX >= (signed int)v5->uX
2296 && (signed int)uClickX <= (signed int)v5->uZ
2297 && (signed int)uClickY >= (signed int)v5->uY
2298 && (signed int)uClickY <= (signed int)v5->uW )
2299 break;
2300 ++v4;
2301 if ( v4 >= v28 )
2302 goto LABEL_45;
2303 }
2304 LABEL_66:
2305 pWindowList[v3].pCurrentPosActiveItem = v4;
2306 return 1;
2307 }
2308 LABEL_46:
2309 v2 = pMessageQueue_50CBD0->uNumMessages;
2310 goto LABEL_47;
2311 }
2312 goto LABEL_47;
2313 }
2314 v22 = pWindowList[v3].pCurrentPosActiveItem;
2315 v23 = pWindowList[v3].pStartingPosActiveItem;
2316 if ( v22 <= v23 )
2317 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
2318 else
2319 v24 = v22 - 1;
2320 v8 = pWindowList[v3].field_30 == v1;
2321 pWindowList[v3].pCurrentPosActiveItem = v24;
2322 if ( !v8 )
2323 return 1;
2324 v19 = pWindowList[v3].pControlsHead;
2325 v25 = pWindowList[v3].pCurrentPosActiveItem;
2326 if ( v25 > (signed int)v1 )
2327 {
2328 do
2329 {
2330 v19 = v19->pNext;
2331 --v25;
2332 }
2333 while ( v25 );
2334 }
2335 LABEL_56:
2336 v21 = v19->uControlParam;
2337 if ( (signed int)v2 < 40 )
2338 {
2339 pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v19->uControlID;
2340 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v21;
2341 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
2342 ++pMessageQueue_50CBD0->uNumMessages;
2343 }
2344 return 1;
2345 }
2346
2347 //----- (0041D20D) --------------------------------------------------------
2348 char __fastcall sub_41D20D_buff_remaining_time_string(int ecx0, GUIWindow *edx0, __int64 a3, GUIFont *a2)
2349 {
2350 unsigned int v4; // edi@1
2351 unsigned int v5; // esi@1
2352 unsigned int v6; // ebp@1
2353 unsigned int v7; // ebx@1
2354 signed __int64 v8; // ST34_8@1
2355 signed __int64 v9; // kr00_8@1
2356 char *v10; // eax@2
2357 char *v11; // eax@7
2358 char *v12; // eax@13
2359 char *v13; // eax@19
2360 int uY; // [sp+0h] [bp-20h]@1
2361 GUIWindow *a1; // [sp+4h] [bp-1Ch]@1
2362 signed __int64 v17; // [sp+10h] [bp-10h]@1
2363 signed __int64 v18; // [sp+18h] [bp-8h]@1
2364 unsigned int v19; // [sp+24h] [bp+4h]@1
2365
2366 a1 = edx0;
2367 uY = ecx0;
2368 v4 = (unsigned __int64)(signed __int64)((double)a3 * 0.234375) >> 32;
2369 v5 = (signed __int64)((double)a3 * 0.234375);
2370 v6 = (unsigned __int64)((signed __int64)((double)a3 * 0.234375) / 60) >> 32;
2371 v7 = (signed __int64)((double)a3 * 0.234375) / 60;
2372 v8 = (signed __int64)((double)a3 * 0.234375) / 60 / 60;
2373 v19 = (unsigned int)v8 / 0x18;
2374 v18 = (signed __int64)__PAIR__(v4, v5) % 60;
2375 v17 = (signed __int64)__PAIR__(v6, v7) % 60;
2376 v9 = v8 % 24;
2377 strcpy(pTmpBuf, "\r020");
2378 if ( (unsigned int)v8 / 0x18 )
2379 {
2380 v10 = pGlobalTXT_LocalizationStrings[57]; // Days
2381 if ( v19 <= 1 )
2382 v10 = pGlobalTXT_LocalizationStrings[56]; // Day
2383 sprintf(pTmpBuf2, "%d %s ", v19, v10);
2384 strcat(pTmpBuf, pTmpBuf2);
2385 }
2386 if ( v9 )
2387 {
2388 if ( v9 <= 1 )
2389 v11 = pGlobalTXT_LocalizationStrings[109];// Hour
2390 else
2391 v11 = pGlobalTXT_LocalizationStrings[110];// Hours
2392 sprintf(pTmpBuf2, "%d %s ", v9, v11);
2393 strcat(pTmpBuf, pTmpBuf2);
2394 }
2395 if ( v17 && !v19 )
2396 {
2397 if ( v17 <= 1 )
2398 v12 = pGlobalTXT_LocalizationStrings[437];// Minute
2399 else
2400 v12 = pGlobalTXT_LocalizationStrings[436];// Minutes
2401 sprintf(pTmpBuf2, "%d %s ", v17, v12);
2402 strcat(pTmpBuf, pTmpBuf2);
2403 }
2404 if ( v18 && !v9 )
2405 {
2406 if ( v18 <= 1 )
2407 v13 = pGlobalTXT_LocalizationStrings[439];// Second
2408 else
2409 v13 = pGlobalTXT_LocalizationStrings[438];// Seconds
2410 sprintf(pTmpBuf2, "%d %s ", v18, v13);
2411 strcat(pTmpBuf, pTmpBuf2);
2412 }
2413 return a1->DrawText(a2, 32, uY, 0, pTmpBuf, 0, 0, 0);
2414 }
2415
2416
2417 //----- (0041D895) --------------------------------------------------------
2418 void __thiscall GameUI_DrawItemInfo(ItemGen *ecx0)
2419 {
2420 ItemGen *v1; // esi@1
2421 unsigned int v2; // eax@3
2422 char *v3; // edi@5
2423 unsigned int v4; // eax@5
2424 unsigned int v5; // esi@5
2425 signed int v6; // eax@5
2426 int v7; // edx@5
2427 ItemGen *v8; // ecx@10
2428 unsigned int v9; // eax@12
2429 char v10; // zf@16
2430 ItemGen *v11; // eax@16
2431 ItemGen *v12; // eax@25
2432 unsigned int v13; // ecx@32
2433 unsigned int v14; // eax@32
2434 Render *v15; // edi@33
2435 const char *v16; // eax@34
2436 int v17; // eax@36
2437 int v18; // esi@37
2438 unsigned __int16 v19; // ax@37
2439 char v20; // al@40
2440 char v21; // al@44
2441 char v22; // al@48
2442 char v23; // al@51
2443 int v24; // eax@52
2444 int v25; // eax@57
2445 int v26; // eax@60
2446 int v27; // eax@67
2447 const char *v28; // edi@69
2448 int v29; // eax@70
2449 char *v30; // edi@78
2450 const char *v31; // eax@78
2451 int v32; // ecx@81
2452 unsigned int v33; // eax@81
2453 int v34; // esi@81
2454 const char *v35; // eax@85
2455 const char *v36; // eax@87
2456 unsigned int v37; // eax@109
2457 unsigned int v38; // eax@109
2458 int v39; // eax@113
2459 GUIFont *v40; // edx@113
2460 signed int v41; // [sp-20h] [bp-298h]@113
2461 int v42; // [sp-1Ch] [bp-294h]@113
2462 char *v43; // [sp-18h] [bp-290h]@46
2463 unsigned int v44; // [sp-18h] [bp-290h]@113
2464 int v45; // [sp-14h] [bp-28Ch]@46
2465 const char *v46; // [sp-14h] [bp-28Ch]@58
2466 char *v47; // [sp-14h] [bp-28Ch]@110
2467 char *v48; // [sp-10h] [bp-288h]@46
2468 const char *v49; // [sp-10h] [bp-288h]@56
2469 char *v50; // [sp-10h] [bp-288h]@58
2470 int v51; // [sp-10h] [bp-288h]@110
2471 const char *v52; // [sp-Ch] [bp-284h]@36
2472 int v53; // [sp-Ch] [bp-284h]@46
2473 char *v54; // [sp-Ch] [bp-284h]@56
2474 int v55; // [sp-Ch] [bp-284h]@58
2475 int v56; // [sp-Ch] [bp-284h]@110
2476 unsigned int v57; // [sp-8h] [bp-280h]@36
2477 int v58; // [sp-8h] [bp-280h]@46
2478 int v59; // [sp-8h] [bp-280h]@56
2479 int v60; // [sp-8h] [bp-280h]@58
2480 unsigned int v61; // [sp-8h] [bp-280h]@110
2481 char a1[100]; // [sp+8h] [bp-270h]@40
2482 char Dest[100]; // [sp+6Ch] [bp-20Ch]@40
2483 char v64[100]; // [sp+D0h] [bp-1A8h]@40
2484 char v65[120]; // [sp+134h] [bp-144h]@92
2485 char Source[40]; // [sp+1ACh] [bp-CCh]@49
2486 int v67; // [sp+1D4h] [bp-A4h]@91
2487 int v68; // [sp+1D8h] [bp-A0h]@106
2488 int v69; // [sp+1DCh] [bp-9Ch]@101
2489 int v70; // [sp+1E0h] [bp-98h]@97
2490 int v71; // [sp+1E8h] [bp-90h]@93
2491 int v72; // [sp+1ECh] [bp-8Ch]@91
2492 int var88; // [sp+1F0h] [bp-88h]@1
2493 Texture *v73; // [sp+1F4h] [bp-84h]@5
2494 unsigned int v75; // [sp+1F8h] [bp-80h]@5
2495 char *v76; // [sp+1FCh] [bp-7Ch]@5
2496 int v77; // [sp+200h] [bp-78h]@12
2497 int v78; // [sp+204h] [bp-74h]@5
2498 GUIWindow v79; // [sp+208h] [bp-70h]@2
2499 POINT a2; // [sp+25Ch] [bp-1Ch]@2
2500 int v81; // [sp+264h] [bp-14h]@5
2501 GUIFont *v82; // [sp+268h] [bp-10h]@1
2502 char *v83; // [sp+26Ch] [bp-Ch]@18
2503 char *Str; // [sp+270h] [bp-8h]@65
2504 ItemGen *_this; // [sp+274h] [bp-4h]@1
2505
2506 v1 = ecx0;
2507 _this = ecx0;
2508 var88 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
2509 v82 = pFontComic;
2510 if ( v1->uItemID )
2511 {
2512 v79.Hint = 0;
2513 v79.uFrameWidth = 384;
2514 v79.uFrameHeight = 180;
2515 v79.uFrameY = 40;
2516 if ( pMouse->GetCursorPos(&a2)->x <= 320 )
2517 v2 = pMouse->GetCursorPos(&a2)->x + 30;
2518 else
2519 v2 = pMouse->GetCursorPos(&a2)->x - v79.uFrameWidth - 30;
2520 v79.uFrameX = v2;
2521 v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName;
2522 v76 = v3;
2523 v4 = pIcons_LOD->LoadTexture(*(const char **)v3, TEXTURE_16BIT_PALETTE);
2524 v5 = v4;
2525 v4 *= 72;
2526 v75 = v4;
2527 v73 = (struct Texture *)((char *)pIcons_LOD->pTextures + v4);
2528 v6 = 100 - *(unsigned __int16 *)((char *)&pIcons_LOD->pTextures[0].uTextureWidth + v4);
2529 v7 = v73->uTextureHeight;
2530 v78 = v6;
2531 v81 = 144 - v7;
2532 if ( v6 > 0 )
2533 v78 = v6 >> 1;
2534 if ( v81 <= 0 )
2535 v81 = 0;
2536 else
2537 v81 >>= 1;
2538 v8 = _this;
2539 if ( !v3[46] )
2540 _this->uAttributes |= 1u;
2541 v9 = v8->uAttributes;
2542 v77 = 0;
2543 a2.y = v9 & 2;
2544 if ( pItemsTable->pItems[v8->uItemID].uEquipType == 18 )
2545 v77 = v8->uAdditionalValue;
2546 if ( uActiveCharacter )
2547 {
2548 if ( !(v9 & 1) )
2549 {
2550 v10 = pPlayers[uActiveCharacter]->CanIdentify(_this) == 1;
2551 v11 = _this;
2552 if ( v10 )
2553 _this->uAttributes |= 1u;
2554 v10 = (v11->uAttributes & 1) == 0;
2555 v83 = (char *)9;
2556 if ( v10 )
2557 {
2558 ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);
2559 }
2560 else
2561 {
2562 v83 = (char *)8;
2563 if ( _this->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
2564 v83 = (char *)7;
2565 }
2566 if ( dword_4E455C )
2567 {
2568 pPlayers[uActiveCharacter]->PlaySound((int)v83, 0);
2569 dword_4E455C = 0;
2570 }
2571 }
2572 _this->UpdateTempBonus(pParty->uTimePlayed);
2573 if ( a2.y )
2574 {
2575 v10 = pPlayers[uActiveCharacter]->CanRepair(_this) == 1;
2576 v12 = _this;
2577 if ( v10 )
2578 _this->uAttributes = _this->uAttributes & 0xFFFFFFFD | 1;
2579 v10 = (v12->uAttributes & 2) == 0;
2580 v83 = (char *)11;
2581 if ( v10 )
2582 v83 = (char *)10;
2583 else
2584 ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);
2585 if ( dword_4E455C )
2586 {
2587 pPlayers[uActiveCharacter]->PlaySound((int)v83, 0);
2588 dword_4E455C = 0;
2589 }
2590 }
2591 }
2592 v13 = _this->uAttributes;
2593 v14 = _this->uAttributes & 1;
2594 a2.y = _this->uAttributes & 1;
2595 if ( v13 & 2 )
2596 {
2597 v79.DrawMessageBox(0);
2598 //v15 = &;
2599 pRenderer->Clip(
2600 v79.uFrameX + 12,
2601 v79.uFrameY + 12,
2602 v79.uFrameX + v79.uFrameWidth - 12,
2603 v79.uFrameY + v79.uFrameHeight - 12);
2604 v79.uFrameWidth -= 24;
2605 v79.uFrameHeight -= 12;
2606 v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
2607 v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
2608 pRenderer->_4A6776(
2609 v79.uFrameX + v78,
2610 v81 + v79.uFrameY + 30,
2611 (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
2612 if ( a2.y )
2613 v16 = _this->GetIdentifiedName();
2614 else
2615 v16 = (const char *)*((int *)v76 + 2);
2616 v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
2617 v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &v79, 0, 0);
2618 v57 = 3;
2619 v52 = pGlobalTXT_LocalizationStrings[32];
2620 goto LABEL_37;
2621 }
2622 if ( !v14 )
2623 {
2624 v79.DrawMessageBox(0);
2625 v15 = pRenderer;
2626 pRenderer->Clip(
2627 v79.uFrameX + 12,
2628 v79.uFrameY + 12,
2629 v79.uFrameX + v79.uFrameWidth - 12,
2630 v79.uFrameY + v79.uFrameHeight - 12);
2631 v79.uFrameWidth -= 24;
2632 v79.uFrameHeight -= 12;
2633 v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
2634 v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
2635 pRenderer->DrawTextureTransparent(
2636 v79.uFrameX + v78,
2637 v81 + v79.uFrameY + 30,
2638 (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
2639 v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, *((const char **)v76 + 2), 3u);
2640 v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &v79, 0, 0);
2641 v57 = 3;
2642 v52 = pGlobalTXT_LocalizationStrings[232];
2643 LABEL_37:
2644 v18 = v17 >> 1;
2645 v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
2646 v79.DrawTitleText(pFontArrus, 0x64u, ((signed int)v79.uFrameHeight >> 1) - v18, v19, v52, v57);
2647 goto LABEL_116;
2648 }
2649 sprintf(a1, pGlobalTXT_LocalizationStrings[463], *((int *)v3 + 2));
2650 strcpy(Dest, "");
2651 strcpy(v64, "");
2652 v20 = v3[28];
2653 if ( (unsigned __int8)v20 <= 1u )
2654 {
2655 v58 = (unsigned __int8)v3[31];
2656 v53 = (unsigned __int8)v3[30];
2657 v48 = pGlobalTXT_LocalizationStrings[53];
2658 v45 = (unsigned __int8)v3[32];
2659 v43 = pGlobalTXT_LocalizationStrings[18];
2660 }
2661 else
2662 {
2663 if ( v20 != 2 )
2664 {
2665 if ( (unsigned __int8)v20 > 2u )
2666 {
2667 if ( (unsigned __int8)v20 <= 0xBu )
2668 {
2669 v21 = v3[30];
2670 if ( v21 )
2671 sprintf(
2672 Dest,
2673 "%s: +%d",
2674 pGlobalTXT_LocalizationStrings[11],
2675 (unsigned __int8)v21 + (unsigned __int8)v3[32]);
2676 }
2677 }
2678 goto LABEL_50;
2679 }
2680 v58 = (unsigned __int8)v3[31];
2681 v53 = (unsigned __int8)v3[30];
2682 v48 = pGlobalTXT_LocalizationStrings[53];
2683 v45 = (unsigned __int8)v3[32];
2684 v43 = pGlobalTXT_LocalizationStrings[203];
2685 }
2686 sprintf(Dest, "%s: +%d %s: %dd%d", v43, v45, v48, v53, v58);
2687 v22 = v3[32];
2688 if ( v22 )
2689 {
2690 sprintf(Source, " +%d", (unsigned __int8)v22);
2691 strcat(Dest, Source);
2692 }
2693 LABEL_50:
2694 if ( v77 )
2695 goto LABEL_65;
2696 v23 = v3[28];
2697 if ( v23 == 14 )
2698 {
2699 v24 = _this->_bonus_type;
2700 if ( v24 )
2701 goto LABEL_56;
2702 LABEL_65:
2703 v79.uFrameWidth -= 12;
2704 a2.y = 3;
2705 v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
2706 v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
2707 Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
2708 v83 = a1;
2709 do
2710 {
2711 if ( *v83 )
2712 {
2713 v27 = v82->CalcTextHeight(v83, &v79, 100, 0);
2714 Str += v27 + 3;
2715 }
2716 v83 += 100;
2717 --a2.y;
2718 }
2719 while ( a2.y );
2720 v28 = (const char *)*((int *)v3 + 3);
2721 if ( *v28 )
2722 {
2723 v29 = pFontSmallnum->CalcTextHeight(v28, &v79, 100, 0);
2724 Str += v29;
2725 }
2726 v79.uFrameHeight = v73->uTextureHeight + v81 + 54;
2727 if ( (signed int)Str > (signed int)v79.uFrameHeight )
2728 v79.uFrameHeight = (unsigned int)Str;
2729 if ( _this->uAttributes & 8 && (_this->uAdditionalValue || _this->_bonus_type) )
2730 v79.uFrameHeight += LOBYTE(v82->uFontHeight);
2731 v83 = 0;
2732 if ( LOBYTE(pFontArrus->uFontHeight) )
2733 {
2734 v79.uFrameWidth -= 24;
2735 v30 = (char *)LOBYTE(pFontArrus->uFontHeight);
2736 v31 = _this->GetIdentifiedName();
2737 if ( pFontArrus->CalcTextHeight(v31, &v79, 0, 0) / (signed int)v30 )
2738 v83 = v30;
2739 v79.uFrameWidth += 24;
2740 }
2741 v79.uFrameWidth += 12;
2742 v79.uFrameHeight += (unsigned int)v83;
2743 v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
2744 v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
2745 v79.DrawMessageBox(0);
2746 v15 = pRenderer;
2747 pRenderer->Clip(
2748 v79.uFrameX + 12,
2749 v79.uFrameY + 12,
2750 v79.uFrameX + v79.uFrameWidth - 12,
2751 v79.uFrameY + v79.uFrameHeight - 12);
2752 v79.uFrameWidth -= 12;
2753 v32 = v73->uTextureHeight;
2754 v33 = v79.uFrameHeight;
2755 v79.uFrameHeight -= 12;
2756 v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
2757 v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
2758 pRenderer->DrawTextureTransparent(
2759 v79.uFrameX + v78,
2760 v79.uFrameY + (signed int)(v33 - v32) / 2,
2761 (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
2762 a2.y = 3;
2763 v34 = (int)(v83 + 35);
2764 Str = a1;
2765 do
2766 {
2767 if ( *Str )
2768 {
2769 v79.DrawText(v82, 100, v34, 0, Str, 0, 0, 0);
2770 v34 += v82->CalcTextHeight(Str, &v79, 100, 0) + 3;
2771 }
2772 Str += 100;
2773 --a2.y;
2774 }
2775 while ( a2.y );
2776 v35 = (const char *)*((int *)v76 + 3);
2777 if ( *v35 )
2778 v79.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
2779 v79.uFrameX += 12;
2780 v79.uFrameWidth -= 24;
2781 v36 = _this->GetIdentifiedName();
2782 v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u);
2783 v79.uFrameWidth += 24;
2784 v79.uFrameX -= 12;
2785 if ( v77 )
2786 {
2787 sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);
2788 v40 = v82;
2789 v61 = 0;
2790 v56 = 0;
2791 v51 = 0;
2792 v47 = pTmpBuf;
2793 v44 = 0;
2794 v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
2795 v41 = 100;
2796 }
2797 else
2798 {
2799 if ( _this->uAttributes & 8 && (_this->uAdditionalValue || _this->_bonus_type) )
2800 {
2801 sub_493F79((stru351 *)&v67, _this->uExpireTime - pParty->uTimePlayed);
2802 strcpy(pTmpBuf, "Duration:");
2803 Str = (char *)(v72 - 1168);
2804 if ( v72 != 1168 )
2805 {
2806 sprintf(v65, " %d:yr", v72 - 1168);
2807 strcat(pTmpBuf, v65);
2808 }
2809 if ( (((v71 || Str) && ((sprintf(v65, " %d:mo", v71), strcat(pTmpBuf, v65), v71) || Str) || v70)
2810 && ((sprintf(v65, " %d:dy", v70), strcat(pTmpBuf, v65), v71) || Str || v70)
2811 || v69)
2812 && ((sprintf(v65, " %d:hr", v69), strcat(pTmpBuf, v65), v71) || Str || v70 || v69)
2813 || v68 )
2814 {
2815 sprintf(v65, " %d:mn", v68);
2816 strcat(pTmpBuf, v65);
2817 }
2818 v79.DrawText(v82, 100, v79.uFrameHeight - 2 * LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
2819 }
2820 v37 = _this->GetValue();
2821 sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
2822 v79.DrawText(v82, 100, v79.uFrameHeight - LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
2823 v38 = _this->uAttributes;
2824 if ( BYTE1(v38) & 1 )
2825 {
2826 v61 = 0;
2827 v56 = 0;
2828 v51 = 0;
2829 v47 = pGlobalTXT_LocalizationStrings[187];
2830 }
2831 else
2832 {
2833 if ( !(BYTE1(v38) & 2) )
2834 goto LABEL_116;
2835 v61 = 0;
2836 v56 = 0;
2837 v51 = 0;
2838 v47 = pGlobalTXT_LocalizationStrings[651];
2839 }
2840 LOWORD(v38) = LOWORD(pRenderer->uTargetRMask);
2841 v44 = v38;
2842 v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
2843 v39 = v82->GetLineWidth(pTmpBuf);
2844 v40 = v82;
2845 v41 = v39 + 132;
2846 }
2847 v79.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
2848 LABEL_116:
2849 pRenderer->ResetClip();
2850 if ( !areWeLoadingTexture )
2851 {
2852 v73->Release();
2853 pIcons_LOD->_40F9C5();
2854 }
2855 return;
2856 }
2857 if ( v23 == 13 )
2858 {
2859 v24 = pItemsTable->pItems[_this->uItemID].uDamageDice;
2860 LABEL_56:
2861 v59 = v24;
2862 v54 = pGlobalTXT_LocalizationStrings[449];
2863 v49 = "%s: %d";
2864 LABEL_64:
2865 sprintf(v64, v49, v54, v59);
2866 goto LABEL_65;
2867 }
2868 v25 = _this->_bonus_type;
2869 if ( v25 )
2870 {
2871 v60 = _this->_bonus_strength;
2872 v55 = *((int *)&pItemsTable->pItems[799].uDamageMod + 5 * v25);
2873 v50 = pGlobalTXT_LocalizationStrings[210];
2874 v46 = "%s: %s +%d";
2875 }
2876 else
2877 {
2878 v26 = _this->uAdditionalValue;
2879 if ( !v26 )
2880 {
2881 if ( _this->uNumCharges )
2882 {
2883 v59 = _this->uNumCharges;
2884 v54 = pGlobalTXT_LocalizationStrings[464];
2885 v49 = "%s: %lu";
2886 goto LABEL_64;
2887 }
2888 goto LABEL_65;
2889 }
2890 v60 = _this->_bonus_strength;
2891 v55 = *((int *)&pItemsTable->pEnchantments[23].pName + 7 * v26);
2892 v50 = pGlobalTXT_LocalizationStrings[210];
2893 v46 = "%s: %s";
2894 }
2895 sprintf(v64, v46, v50, v55, v60);
2896 goto LABEL_65;
2897 }
2898 }
2899 // 4E455C: using guessed type int dword_4E455C;
2900 // 506128: using guessed type int areWeLoadingTexture;
2901
2902 //----- (0041E360) --------------------------------------------------------
2903 char *__fastcall MonsterPopup_Draw(unsigned int uActorID, GUIWindow *edx0)
2904 {
2905 unsigned int v2; // esi@1
2906 Actor *v3; // esi@3
2907 int v4; // eax@3
2908 unsigned int v5; // ecx@3
2909 NPCData *v6; // eax@3
2910 unsigned __int16 v7; // cx@3
2911 int v8; // eax@4
2912 unsigned __int16 v9; // dx@4
2913 SpriteFrame *v10; // edi@17
2914 int v11; // esi@17
2915 unsigned int v12; // ecx@17
2916 Sprite *v13; // edi@18
2917 int v14; // ecx@18
2918 int v15; // edx@18
2919 int v16; // edx@18
2920 int v17; // eax@18
2921 unsigned int v18; // ecx@19
2922 unsigned int v19; // eax@21
2923 char *v20; // esi@28
2924 int v21; // edx@29
2925 unsigned __int16 *v22; // ecx@29
2926 int v23; // eax@29
2927 int v24; // eax@32
2928 int v25; // esi@32
2929 char *v26; // edx@34
2930 unsigned __int8 v27; // sf@36
2931 unsigned __int8 v28; // of@36
2932 int v29; // esi@40
2933 char *v30; // ecx@40
2934 int v31; // eax@40
2935 int v32; // esi@43
2936 unsigned __int16 v33; // ax@45
2937 int v34; // edx@45
2938 int v35; // eax@45
2939 int v36; // eax@49
2940 char *v37; // eax@52
2941 int v38; // eax@55
2942 unsigned __int16 v39; // ax@59
2943 SpellBuff *v40; // eax@60
2944 int v41; // edi@61
2945 unsigned int v42; // eax@61
2946 int v43; // eax@62
2947 int v44; // eax@63
2948 signed int v45; // edi@65
2949 unsigned __int16 v46; // ax@73
2950 Player *v47; // ecx@77
2951 unsigned int v48; // eax@85
2952 GUIFont *v49; // edi@90
2953 int v50; // edi@90
2954 SpellBuff *v51; // eax@91
2955 char *v52; // ecx@98
2956 char *v53; // ecx@101
2957 char *v54; // ST0C_4@118
2958 unsigned int v55; // eax@118
2959 GUIFont *v56; // edi@124
2960 unsigned __int8 v57; // al@128
2961 int v58; // eax@132
2962 Actor *v59; // ecx@133
2963 unsigned __int8 v60; // dl@138
2964 char *v61; // eax@145
2965 char *v62; // eax@147
2966 int v63; // eax@152
2967 char *result; // eax@152
2968 int v65; // eax@155
2969 const char *v66; // [sp-10h] [bp-1FCh]@121
2970 const char *v67; // [sp-10h] [bp-1FCh]@125
2971 const char *v68; // [sp-10h] [bp-1FCh]@142
2972 int v69; // [sp-Ch] [bp-1F8h]@121
2973 char *v70; // [sp-Ch] [bp-1F8h]@125
2974 char *v71; // [sp-Ch] [bp-1F8h]@142
2975 char *v72; // [sp-8h] [bp-1F4h]@54
2976 int v73; // [sp-8h] [bp-1F4h]@79
2977 int v74; // [sp-8h] [bp-1F4h]@121
2978 int v75; // [sp-8h] [bp-1F4h]@125
2979 int v76; // [sp-8h] [bp-1F4h]@142
2980 size_t v77; // [sp-4h] [bp-1F0h]@54
2981 unsigned int v78; // [sp-4h] [bp-1F0h]@121
2982 unsigned int v79; // [sp-4h] [bp-1F0h]@125
2983 char *v80; // [sp-4h] [bp-1F0h]@142
2984 char *v81; // [sp-4h] [bp-1F0h]@148
2985 DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18
2986 DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18
2987 RECT v84; // [sp+ECh] [bp-100h]@26
2988 char *v85; // [sp+FCh] [bp-F0h]@145
2989 char *v86; // [sp+100h] [bp-ECh]@145
2990 char *v87; // [sp+104h] [bp-E8h]@145
2991 char *v88; // [sp+108h] [bp-E4h]@145
2992 char *v89; // [sp+10Ch] [bp-E0h]@145
2993 char *v90; // [sp+110h] [bp-DCh]@145
2994 char *v91; // [sp+114h] [bp-D8h]@145
2995 char *v92; // [sp+118h] [bp-D4h]@145
2996 char *v93; // [sp+11Ch] [bp-D0h]@145
2997 char *v94; // [sp+120h] [bp-CCh]@145
2998 char *v95; // [sp+124h] [bp-C8h]@127
2999 char *v96; // [sp+128h] [bp-C4h]@127
3000 char *v97; // [sp+12Ch] [bp-C0h]@127
3001 char *v98; // [sp+130h] [bp-BCh]@127
3002 char *v99; // [sp+134h] [bp-B8h]@127
3003 char *v100; // [sp+138h] [bp-B4h]@127
3004 char *v101; // [sp+13Ch] [bp-B0h]@127
3005 char *v102; // [sp+140h] [bp-ACh]@127
3006 char *v103; // [sp+144h] [bp-A8h]@127
3007 char *v104; // [sp+148h] [bp-A4h]@127
3008 char *v105; // [sp+14Ch] [bp-A0h]@127
3009 RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3
3010 unsigned int v107; // [sp+1A0h] [bp-4Ch]@18
3011 unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34
3012 unsigned int v109; // [sp+1A8h] [bp-44h]@32
3013 LPVOID v110; // [sp+1ACh] [bp-40h]@28
3014 unsigned int v111; // [sp+1B0h] [bp-3Ch]@29
3015 char **v112; // [sp+1B4h] [bp-38h]@3
3016 IDirectDrawSurface *v222; // [sp+1B8h] [bp-34h]@18
3017 unsigned __int8 v114; // [sp+1BFh] [bp-2Dh]@133
3018 int v115; // [sp+1C0h] [bp-2Ch]@3
3019 unsigned int v116; // [sp+1C4h] [bp-28h]@18
3020 int i; // [sp+1C8h] [bp-24h]@18
3021 Player *a2; // [sp+1CCh] [bp-20h]@28
3022 int v119; // [sp+1D0h] [bp-1Ch]@18
3023 SpellBuff *v120; // [sp+1D4h] [bp-18h]@18
3024 Actor *v121; // [sp+1D8h] [bp-14h]@3
3025 int a5; // [sp+1DCh] [bp-10h]@3
3026 GUIWindow *a1; // [sp+1E0h] [bp-Ch]@1
3027 int v124; // [sp+1E4h] [bp-8h]@18
3028 char *a4; // [sp+1E8h] [bp-4h]@18
3029
3030 a1 = edx0;
3031 v2 = uActorID;
3032
3033 static Actor pMonsterInfoUI_Doll;
3034 /*if ( !(bMonsterInfoUI_bDollInitialized & 1) )
3035 {
3036 bMonsterInfoUI_bDollInitialized |= 1u;
3037 Actor::Actor(&pMonsterInfoUI_Doll);
3038 atexit(nullsub_3);
3039 }*/
3040 v106.uParentBillboardID = -1;
3041 v3 = &pActors[v2];
3042 v121 = v3;
3043 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xFFu, 0x9Bu);
3044 v5 = v3->uNPC_ID;
3045 a5 = v4;
3046 v6 = GetNPCData(v5);
3047 v7 = v3->pMonsterInfo.uID;
3048 v112 = (char **)v6;
3049 v115 = byte_4E2B70[((signed __int16)v7 - 1) / 3] - 40;
3050 if ( v7 == pMonsterInfoUI_Doll.pMonsterInfo.uID )
3051 {
3052 v9 = pMonsterInfoUI_Doll.uCurrentActionLength;
3053 }
3054 else
3055 {
3056 memcpy(&pMonsterInfoUI_Doll, v3, sizeof(pMonsterInfoUI_Doll));
3057 pMonsterInfoUI_Doll.uCurrentActionAnimation = 7;
3058 pMonsterInfoUI_Doll.uCurrentActionTime = 0;
3059 v8 = rand();
3060 v3 = v121;
3061 v9 = v8 % 256 + 128;
3062 pMonsterInfoUI_Doll.uCurrentActionLength = v8 % 256 + 128;
3063 }
3064 if ( (signed int)pMonsterInfoUI_Doll.uCurrentActionTime > (signed __int16)v9 )
3065 {
3066 pMonsterInfoUI_Doll.uCurrentActionTime = 0;
3067 if ( pMonsterInfoUI_Doll.uCurrentActionAnimation == 7 || pMonsterInfoUI_Doll.uCurrentActionAnimation == 2 )
3068 {
3069 pMonsterInfoUI_Doll.uCurrentActionAnimation = 0;
3070 pMonsterInfoUI_Doll.uCurrentActionLength = rand() % 128 + 128;
3071 }
3072 else
3073 {
3074 rand();
3075 pMonsterInfoUI_Doll.uCurrentActionAnimation = 7;
3076 if ( (pMonsterInfoUI_Doll.pMonsterInfo.uID < 115 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 186)
3077 && (pMonsterInfoUI_Doll.pMonsterInfo.uID < 232 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 249)
3078 && rand() % 30 < 100 )
3079 pMonsterInfoUI_Doll.uCurrentActionAnimation = 2;
3080 pMonsterInfoUI_Doll.uCurrentActionLength = 8
3081 * pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation]].uAnimLength;
3082 }
3083 }
3084 v10 = pSpriteFrameTable->GetFrame(
3085 v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation],
3086 pMonsterInfoUI_Doll.uCurrentActionTime);
3087 v11 = 40 * v10->pHwSpriteIDs[0] + 7218180;
3088 v106.pTarget = pRenderer->pTargetSurface;
3089 v106.pTargetZ = pRenderer->pActiveZBuffer;
3090 v106.uTargetPitch = pRenderer->uTargetSurfacePitch;
3091 v12 = a1->uFrameY + 52;
3092 v106.uViewportX = a1->uFrameX + 13;
3093 v106.uViewportY = v12;
3094 v106.uViewportW = v12 + 128;
3095 v106.uViewportZ = v106.uViewportX + 128;
3096 v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
3097 v106.field_10 = 65536;
3098 v106.field_14 = 65536;
3099 v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18);
3100 v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
3101 v106.sZValue = 0;
3102 v106.uFlags = 0;
3103 pRenderer->Clip_v2(0, 0, 0x27Fu, 0x1DFu);
3104 pRenderer->Line2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, a5);
3105 pRenderer->Line2D(
3106 v106.uViewportX + 129,
3107 v106.uViewportY - 1,
3108 v106.uViewportX + 129,
3109 v106.uViewportW + 1,
3110 a5);
3111 pRenderer->Line2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, a5);
3112 pRenderer->Line2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, a5);
3113 if ( pRenderer->pRenderD3D )
3114 {
3115 v13 = &pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]];
3116 v106.uScreenSpaceY = v115 + v106.uViewportY + v13->uBufferHeight;
3117 v222 = (IDirectDrawSurface *)v13->pTextureSurface;
3118 memset(&Dst, 0, 0x64u);
3119 Dst.dwSize = 100;
3120 Dst.dwFillColor = 0;
3121 memset(&pDesc, 0, 0x7Cu);
3122 pDesc.dwSize = 124;
3123 v222->GetSurfaceDesc((LPDDSURFACEDESC)&pDesc);
3124 v14 = v13->uBufferHeight;
3125 v120 = (SpellBuff *)v13->uBufferWidth;
3126 v107 = 0;
3127 v15 = v13->uAreaX;
3128 v119 = (signed int)v120 / 2;
3129 i = 0;
3130 a4 = (char *)(v106.uScreenSpaceX + v15 - (signed int)v120 / 2);
3131 v115 = v13->uAreaY;
3132 v16 = v13->uAreaWidth + (signed int)v120 / 2 + v15 - (int)v120;
3133 v124 = v106.uScreenSpaceY + v115 - v14;
3134 v17 = v13->uAreaHeight + v115 - v14;
3135 v116 = v106.uScreenSpaceX + v16;
3136 v119 = v106.uScreenSpaceY + v17;
3137 if ( (signed int)a4 < (signed int)v106.uViewportX )
3138 {
3139 v18 = v106.uViewportX - (int)a4;
3140 a4 = (char *)v106.uViewportX;
3141 v107 = v18;
3142 }
3143 if ( v124 < (signed int)v106.uViewportY )
3144 {
3145 v19 = v106.uViewportY - v124;
3146 v124 = v106.uViewportY;
3147 i = v19;
3148 }
3149 if ( (signed int)v116 > (signed int)v106.uViewportZ )
3150 v116 = v106.uViewportZ;
3151 if ( v119 > (signed int)v106.uViewportW )
3152 v119 = v106.uViewportW;
3153 pRenderer->FillRectFast(
3154 v106.uViewportX,
3155 v106.uViewportY,
3156 v106.uViewportZ - v106.uViewportX,
3157 v106.uViewportW - v106.uViewportY,
3158 pRenderer->uTargetBMask | pRenderer->uTargetGMask);
3159 pRenderer->FillRectFast(
3160 v106.uViewportX,
3161 v106.uViewportY,
3162 v106.uViewportZ - v106.uViewportX,
3163 v106.uViewportW - v106.uViewportY,
3164 pRenderer->uTargetBMask | pRenderer->uTargetGMask);
3165 v84.left = v106.uViewportX;
3166 v84.top = v106.uViewportY;
3167 v84.right = v106.uViewportZ;
3168 v84.bottom = v106.uViewportW;
3169 ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst));
3170 if ( pRenderer->uTargetGBits == 5 )
3171 {
3172 memset(&pDesc, 0, 0x7Cu);
3173 pDesc.dwSize = 124;
3174 if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, 1u) )
3175 goto LABEL_51;
3176 v20 = (char *)v124;
3177 v110 = pDesc.lpSurface;
3178 a2 = (Player *)v124;
3179 if ( v124 < v119 )
3180 {
3181 v111 = 2 * pRenderer->uTargetSurfacePitch;
3182 v21 = (int)a4;
3183 v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
3184 v23 = i - v124;
3185 v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
3186 v115 = i - v124;
3187 while ( 1 )
3188 {
3189 v124 = v21;
3190 if ( v21 < (signed int)v116 )
3191 {
3192 v24 = (int)&v20[v23];
3193 v25 = v107 - v21;
3194 v109 = v24;
3195 for ( i = v107 - v21; ; v25 = i )
3196 {
3197 v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight);
3198 v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth;
3199 *v22 = *((short *)v110 + (int)v26);
3200 ++v22;
3201 if ( v124 >= (signed int)v116 )
3202 break;
3203 }
3204 v23 = v115;
3205 }
3206 v22 = (unsigned __int16 *)((char *)v120 + v111);
3207 v20 = (char *)&a2->pConditions[0] + 1;
3208 v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119);
3209 v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0;
3210 a2 = (Player *)((char *)a2 + 1);
3211 v120 = (SpellBuff *)((char *)v120 + v111);
3212 if ( !(v27 ^ v28) )
3213 break;
3214 v21 = (int)a4;
3215 }
3216 }
3217 goto LABEL_37;
3218 }
3219 memset(&pDesc, 0, 0x7Cu);
3220 pDesc.dwSize = 124;
3221 if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, 1u) )
3222 {
3223 v108 = (unsigned __int16 *)pDesc.lpSurface;
3224 a2 = (Player *)v124;
3225 if ( v124 < v119 )
3226 {
3227 v109 = 2 * pRenderer->uTargetSurfacePitch;
3228 v29 = (int)a4;
3229 v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
3230 v31 = i - v124;
3231 v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
3232 v115 = i - v124;
3233 while ( 1 )
3234 {
3235 v124 = v29;
3236 if ( v29 < (signed int)v116 )
3237 {
3238 v32 = v107 - (int)a4;
3239 v111 = (unsigned int)((char *)a2 + v31);
3240 for ( i = v107 - (int)a4; ; v32 = i )
3241 {
3242 v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
3243 v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
3244 v34 = v33 & 0x1F | 2
3245 * (unsigned __int16)(v108[(int)((char *)v110
3246 + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
3247 v35 = v124;
3248 *(short *)v30 = v34;
3249 v30 += 2;
3250 if ( v35 >= (signed int)v116 )
3251 break;
3252 }
3253 v31 = v115;
3254 }
3255 a2 = (Player *)((char *)a2 + 1);
3256 v30 = (char *)v120 + v109;
3257 v120 = (SpellBuff *)((char *)v120 + v109);
3258 if ( (signed int)a2 >= v119 )
3259 break;
3260 v29 = (int)a4;
3261 }
3262 }
3263 LABEL_37:
3264 v222->Unlock(0);
3265 goto LABEL_51;
3266 }
3267 }
3268 else
3269 {
3270 pRenderer->FillRectFast(
3271 v106.uViewportX,
3272 v106.uViewportY,
3273 v106.uViewportZ - v106.uViewportX,
3274 v106.uViewportW - v106.uViewportY,
3275 0);
3276 v36 = v10->pHwSpriteIDs[0];
3277 if ( v36 >= 0 )
3278 pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0);
3279 }
3280 LABEL_51:
3281 if ( v121->uNPC_ID )
3282 {
3283 v37 = v112[6];
3284 if ( v37 )
3285 {
3286 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]);
3287 goto LABEL_59;
3288 }
3289 v77 = 2000;
3290 v72 = *v112;
3291 }
3292 else
3293 {
3294 v38 = v121->dword_000334_unique_name;
3295 v77 = 2000;
3296 if ( v38 )
3297 v72 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v38);
3298 else
3299 v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName;
3300 }
3301 strncpy(pTmpBuf, v72, v77);
3302 LABEL_59:
3303 v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
3304 a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
3305 Actor::DrawHealthBar(v121, a1);
3306 v119 = 0;
3307 pMonsterInfoUI_Doll.uCurrentActionTime += pMiscTimer->uTimeElapsed;
3308 v115 = 0;
3309 v116 = 0;
3310 i = 0;
3311 v112 = 0;
3312 if ( !uActiveCharacter )
3313 {
3314 v45 = 1;
3315 goto LABEL_84;
3316 }
3317 LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
3318 v120 = v40;
3319 if ( !v40 )
3320 goto LABEL_72;
3321 v41 = (unsigned __int8)v40 & 0x3F;
3322 v42 = SkillToMastery((unsigned __int16)v40) - 1;
3323 if ( !v42 )
3324 {
3325 if ( v41 + 10 >= v121->pMonsterInfo.uLevel )
3326 {
3327 v45 = 1;
3328 v119 = 1;
3329 goto LABEL_73;
3330 }
3331 goto LABEL_72;
3332 }
3333 v43 = v42 - 1;
3334 if ( !v43 )
3335 {
3336 if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel )
3337 {
3338 v45 = 1;
3339 v119 = 1;
3340 v116 = 1;
3341 goto LABEL_73;
3342 }
3343 goto LABEL_72;
3344 }
3345 v44 = v43 - 1;
3346 if ( !v44 )
3347 {
3348 if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel )
3349 {
3350 v45 = 1;
3351 v119 = 1;
3352 v116 = 1;
3353 i = 1;
3354 goto LABEL_73;
3355 }
3356 LABEL_72:
3357 v45 = 1;
3358 goto LABEL_73;
3359 }
3360 if ( v44 != 1 )
3361 goto LABEL_72;
3362 v45 = 1;
3363 v119 = 1;
3364 v116 = 1;
3365 i = 1;
3366 v112 = (char **)1;
3367 LABEL_73:
3368 v46 = v121->uAIState;
3369 if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 )
3370 {
3371 v47 = pPlayers[uActiveCharacter];
3372 if ( v119 | v116 | i | (unsigned int)v112 )
3373 {
3374 if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 )
3375 v73 = 105;
3376 else
3377 v73 = 104;
3378 }
3379 else
3380 {
3381 v73 = 106;
3382 }
3383 v47->PlaySound(v73, 0);
3384 }
3385 LABEL_84:
3386 a2 = pParty->pPlayers;
3387 do
3388 {
3389 LOBYTE(v48) = a2->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
3390 v111 = v48;
3391 v120 = (SpellBuff *)138;
3392 do
3393 {
3394 if ( (signed int)SkillToMastery(v111) >= 3 )
3395 v115 = v45;
3396 v120 = (SpellBuff *)((char *)v120 - 1);
3397 }
3398 while ( v120 );
3399 ++a2;
3400 }
3401 while ( (signed int)a2 < (signed int)pParty->pHirelings );
3402 v49 = pFontSmallnum;
3403 a2 = (Player *)pFontSmallnum;
3404 a1->DrawText(pFontSmallnum, 12, 196, a5, pGlobalTXT_LocalizationStrings[631], 0, 0, 0);
3405 v50 = LOBYTE(v49->uFontHeight) + 193;
3406 if ( !v115 )
3407 {
3408 v78 = 0;
3409 v74 = 0;
3410 v69 = 0;
3411 v66 = pGlobalTXT_LocalizationStrings[630];
3412 goto LABEL_123;
3413 }
3414 a4 = 0;
3415 v51 = &v121->pActorBuffs[1];
3416 v222 = 0;
3417 v120 = &v121->pActorBuffs[1];
3418 do
3419 {
3420 if ( (signed __int64)v51->uExpireTime > 0 )
3421 {
3422 switch ( (int)v51 )
3423 {
3424 case 0u:
3425 v124 = 60;
3426 a4 = pGlobalTXT_LocalizationStrings[591];
3427 break;
3428 case 1u:
3429 v124 = 82;
3430 a4 = pGlobalTXT_LocalizationStrings[649];
3431 break;
3432 case 2u:
3433 v124 = 92;
3434 a4 = pGlobalTXT_LocalizationStrings[592];
3435 break;
3436 case 3u:
3437 v124 = 63;
3438 a4 = pGlobalTXT_LocalizationStrings[4];
3439 break;
3440 case 4u:
3441 v52 = pGlobalTXT_LocalizationStrings[220];
3442 goto LABEL_100;
3443 case 5u:
3444 v52 = pGlobalTXT_LocalizationStrings[162];
3445 LABEL_100:
3446 a4 = v52;
3447 v124 = 81;
3448 break;
3449 case 6u:
3450 v53 = pGlobalTXT_LocalizationStrings[593];
3451 v124 = 35;
3452 goto LABEL_103;
3453 case 8u:
3454 v53 = pGlobalTXT_LocalizationStrings[608];
3455 v124 = 62;
3456 LABEL_103:
3457 a4 = v53;
3458 break;
3459 case 7u:
3460 case 9u:
3461 a4 = 0;
3462 v124 = 0;
3463 goto LABEL_119;
3464 case 0xAu:
3465 v124 = 47;
3466 a4 = pGlobalTXT_LocalizationStrings[221];
3467 break;
3468 case 0xBu:
3469 v124 = 66;
3470 a4 = pGlobalTXT_LocalizationStrings[607];
3471 break;
3472 case 0xCu:
3473 v124 = 85;
3474 a4 = pGlobalTXT_LocalizationStrings[610];
3475 break;
3476 case 0xDu:
3477 v124 = 86;
3478 a4 = pGlobalTXT_LocalizationStrings[609];
3479 break;
3480 case 0xEu:
3481 v124 = 17;
3482 a4 = pGlobalTXT_LocalizationStrings[279];
3483 break;
3484 case 0xFu:
3485 v124 = 38;
3486 a4 = pGlobalTXT_LocalizationStrings[442];
3487 break;
3488 case 0x10u:
3489 v124 = 46;
3490 a4 = pGlobalTXT_LocalizationStrings[443];
3491 break;
3492 case 0x11u:
3493 v124 = 51;
3494 a4 = pGlobalTXT_LocalizationStrings[440];
3495 break;
3496 case 0x12u:
3497 v124 = 5;
3498 a4 = pGlobalTXT_LocalizationStrings[441];
3499 break;
3500 case 0x13u:
3501 v124 = 95;
3502 a4 = pGlobalTXT_LocalizationStrings[229];
3503 break;
3504 case 0x14u:
3505 v124 = 73;
3506 a4 = pGlobalTXT_LocalizationStrings[228];
3507 break;
3508 default:
3509 a4 = 0;
3510 break;
3511 }
3512 if ( a4 )
3513 {
3514 v54 = a4;
3515 v55 = GetSpellColor(v124);
3516 a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0);
3517 v50 = v50 + BYTE5(a2->pConditions[0]) - 3;
3518 v51 = v120;
3519 }
3520 }
3521 LABEL_119:
3522 ++v51;
3523 v222 = (IDirectDrawSurface *)((char *)v222 + 1);
3524 v120 = v51;
3525
3526 __debugbreak(); // fix condition
3527 }
3528 //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 );
3529 while (true);
3530 if ( !a4 )
3531 {
3532 v78 = 0;
3533 v74 = 0;
3534 v69 = 0;
3535 v66 = pGlobalTXT_LocalizationStrings[153];
3536 LABEL_123:
3537 a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78);
3538 }
3539 v56 = pFontSmallnum;
3540 a4 = (char *)v106.uViewportY;
3541 if ( v119 )
3542 {
3543 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP);
3544 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3545 a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
3546 v79 = v121->pMonsterInfo.uAC;
3547 v75 = 0;
3548 v70 = pGlobalTXT_LocalizationStrings[12];
3549 v67 = "%s";
3550 }
3551 else
3552 {
3553 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);
3554 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3555 v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630];
3556 v75 = 0;
3557 v70 = pGlobalTXT_LocalizationStrings[12];
3558 a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
3559 v67 = "%s";
3560 }
3561 sprintf(pTmpBuf, v67, v70, v75, v79);
3562 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3563 a4 = &a4[LOBYTE(v56->uFontHeight) - 6] + LOBYTE(v56->uFontHeight);
3564 v95 = pGlobalTXT_LocalizationStrings[87];
3565 v96 = pGlobalTXT_LocalizationStrings[6];
3566 v97 = pGlobalTXT_LocalizationStrings[240];
3567 v98 = pGlobalTXT_LocalizationStrings[70];
3568 v99 = pGlobalTXT_LocalizationStrings[624];
3569 v100 = pGlobalTXT_LocalizationStrings[138];
3570 v101 = pGlobalTXT_LocalizationStrings[214];
3571 v102 = pGlobalTXT_LocalizationStrings[142];
3572 v103 = pGlobalTXT_LocalizationStrings[29];
3573 v104 = pGlobalTXT_LocalizationStrings[133];
3574 v105 = pGlobalTXT_LocalizationStrings[54];
3575 if ( v116 )
3576 {
3577 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]);
3578 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3579 a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
3580 v57 = v121->pMonsterInfo.uAttack1DamageBonus;
3581 if ( v57 )
3582 sprintf(
3583 pTmpBuf,
3584 "%s",
3585 pGlobalTXT_LocalizationStrings[53],
3586 0,
3587 v121->pMonsterInfo.uAttack1DamageDiceRolls,
3588 v121->pMonsterInfo.uAttack1DamageDiceSides,
3589 v57);
3590 else
3591 sprintf(
3592 pTmpBuf,
3593 "%s",
3594 pGlobalTXT_LocalizationStrings[53],
3595 0,
3596 v121->pMonsterInfo.uAttack1DamageDiceRolls,
3597 v121->pMonsterInfo.uAttack1DamageDiceSides);
3598 }
3599 else
3600 {
3601 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
3602 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3603 a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
3604 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
3605 }
3606 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3607 v58 = LOBYTE(v56->uFontHeight);
3608 a4 = &a4[v58 - 6] + v58;
3609 if ( !i )
3610 {
3611 v80 = pGlobalTXT_LocalizationStrings[630];
3612 v76 = 0;
3613 v71 = pGlobalTXT_LocalizationStrings[628];
3614 v68 = "%s";
3615 goto LABEL_144;
3616 }
3617 v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628];
3618 v59 = v121;
3619 v114 = v121->pMonsterInfo.uSpell1ID;
3620 if ( v114 && v121->pMonsterInfo.uSpell2ID )
3621 v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629];
3622 if ( v114 )
3623 {
3624 sprintf(pTmpBuf, "%s", v120, 0, pSpellStats->pInfos[v114].pShortName);
3625 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3626 v58 = LOBYTE(v56->uFontHeight);
3627 a4 = &a4[v58 - 3];
3628 v59 = v121;
3629 }
3630 v60 = v59->pMonsterInfo.uSpell2ID;
3631 if ( v60 )
3632 {
3633 __debugbreak();
3634 const char *fmt = "\xC\x25\x30\x35\x75\x9\x30\x36\x30\x25\x73\n";
3635 sprintf(pTmpBuf, fmt, 0, pSpellStats->pInfos[v60].pShortName);
3636 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3637 v58 = LOBYTE(v56->uFontHeight);
3638 a4 = &a4[v58 - 3];
3639 v59 = v121;
3640 }
3641 if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID )
3642 {
3643 v80 = pGlobalTXT_LocalizationStrings[153];
3644 v76 = 0;
3645 v71 = pGlobalTXT_LocalizationStrings[628];
3646 v68 = "%s";
3647 LABEL_144:
3648 sprintf(pTmpBuf, v68, v71, v76, v80);
3649 a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
3650 v58 = LOBYTE(v56->uFontHeight);
3651 a4 = &a4[v58 - 3];
3652 }
3653 a4 = &a4[v58 - 3];
3654 a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0);
3655 a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
3656 v85 = pGlobalTXT_LocalizationStrings[87];
3657 v86 = pGlobalTXT_LocalizationStrings[6];
3658 v87 = pGlobalTXT_LocalizationStrings[240];
3659 v88 = pGlobalTXT_LocalizationStrings[70];
3660 v89 = pGlobalTXT_LocalizationStrings[142];
3661 v90 = pGlobalTXT_LocalizationStrings[214];
3662 v91 = pGlobalTXT_LocalizationStrings[29];
3663 v92 = pGlobalTXT_LocalizationStrings[133];
3664 v93 = pGlobalTXT_LocalizationStrings[54];
3665 v94 = pGlobalTXT_LocalizationStrings[624];
3666 v96 = (char *)v121->pMonsterInfo.uResFire;
3667 v97 = (char *)v121->pMonsterInfo.uResAir;
3668 v98 = (char *)v121->pMonsterInfo.uResWater;
3669 v99 = (char *)v121->pMonsterInfo.uResEarth;
3670 v100 = (char *)v121->pMonsterInfo.uResMind;
3671 v101 = (char *)v121->pMonsterInfo.uResSpirit;
3672 v102 = (char *)v121->pMonsterInfo.uResBody;
3673 v103 = (char *)v121->pMonsterInfo.uResLight;
3674 v61 = (char *)v121->pMonsterInfo.uResPhysical;
3675 v104 = (char *)v121->pMonsterInfo.uResDark;
3676 v105 = v61;
3677 if ( v112 )
3678 {
3679 v124 = 0;
3680 do
3681 {
3682 v62 = (&v96)[v124];
3683 if ( v62 == (char *)200 )
3684 {
3685 v81 = pGlobalTXT_LocalizationStrings[625];
3686 }
3687 else
3688 {
3689 if ( v62 )
3690 v81 = pGlobalTXT_LocalizationStrings[627];
3691 else
3692 v81 = pGlobalTXT_LocalizationStrings[153];
3693 }
3694 sprintf(pTmpBuf, "%s", (&v85)[v124], 0, v81);
3695 a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
3696 v63 = LOBYTE(v56->uFontHeight);
3697 v124 += 4;
3698 result = &a4[v63 - 3];
3699 a4 = result;
3700 }
3701 while ( v124 < 40 );
3702 }
3703 else
3704 {
3705 i = 0;
3706 do
3707 {
3708 sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]);
3709 a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
3710 v65 = LOBYTE(v56->uFontHeight);
3711 ++i;
3712 result = &a4[v65 - 3];
3713 a4 = result;
3714 }
3715 while ( i < 10 );
3716 }
3717 if ( (signed __int64)pParty->pPartyBuffs[3].uExpireTime > 0 )
3718 {
3719 sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP);
3720 pFontSmallnum->GetLineWidth(pTmpBuf);
3721 result = a1->DrawTitleText(
3722 pFontSmallnum,
3723 0,
3724 a1->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12,
3725 0,
3726 pTmpBuf,
3727 3u);
3728 }
3729 return result;
3730 }
3731
3732
3733
3734 //----- (0041F54A) --------------------------------------------------------
3735 void __cdecl LoadActualSkyFrame()
3736 {
3737 if ( pTexture_RestUI_CurrentSkyFrame )
3738 pTexture_RestUI_CurrentSkyFrame->Release();
3739 if ( pTexture_RestUI_CurrentHourglassFrame )
3740 pTexture_RestUI_CurrentHourglassFrame->Release();
3741 pIcons_LOD->_40F9C5();
3742 sprintf(pTmpBuf, "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
3743 pTexture_RestUI_CurrentSkyFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
3744 }
3745
3746 //----- (0041F5BE) --------------------------------------------------------
3747 void __cdecl Sleep6Hours()
3748 {
3749 if ( _506F18_num_hours_to_sleep < 6 )
3750 {
3751 pParty->pPlayers[3].pConditions[2] = 0i64;
3752 pParty->pPlayers[2].pConditions[2] = 0i64;
3753 pParty->pPlayers[1].pConditions[2] = 0i64;
3754 pParty->pPlayers[0].pConditions[2] = 0i64;
3755 if ( _506F18_num_hours_to_sleep )
3756 {
3757 Rest(_506F18_num_hours_to_sleep);
3758 _506F18_num_hours_to_sleep = 0;
3759 LoadActualSkyFrame();
3760 }
3761 if ( dword_506F14 == 2 )
3762 {
3763 pGUIWindow_CurrentMenu->Release();
3764 pEventTimer->Resume();
3765 if ( pTexture_RestUI_CurrentSkyFrame )
3766 pTexture_RestUI_CurrentSkyFrame->Release();
3767 if ( pTexture_RestUI_CurrentHourglassFrame )
3768 pTexture_RestUI_CurrentHourglassFrame->Release();
3769 pTexture_RestUI_CurrentHourglassFrame = 0;
3770 pTexture_RestUI_CurrentSkyFrame = 0;
3771 pIcons_LOD->_4114F2();
3772 pIcons_LOD->_40F9C5();
3773 pCurrentScreen = 0;
3774 viewparams->bRedrawGameUI = 1;
3775 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3776 {
3777 pOutdoor->UpdateSunlightVectors();
3778 pOutdoor->UpdateFog();
3779 }
3780 }
3781 dword_506F14 = 0;
3782 }
3783 else
3784 {
3785 Rest(6u);
3786 _506F18_num_hours_to_sleep -= 6;
3787 LoadActualSkyFrame();
3788 }
3789 viewparams->bRedrawGameUI = 1;
3790 }
3791
3792 //----- (0041F6C1) --------------------------------------------------------
3793 void __cdecl RestUI_Initialize()
3794 {
3795 char *v0; // eax@10
3796
3797 if ( !dword_506F14 )
3798 pAudioPlayer->StopChannels(-1, -1);
3799 if ( pCurrentScreen )
3800 {
3801 pGUIWindow_CurrentMenu->Release();
3802 pCurrentScreen = 0;
3803 viewparams->bRedrawGameUI = 1;
3804 }
3805 pEventTimer->Pause();
3806 if ( dword_506F14 != 2 )
3807 GUIWindow::Create(518u, 450u, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0);
3808 _506F18_num_hours_to_sleep = 0;
3809 dword_506F14 = 0;
3810 uRestUI_FoodRequiredToRest = 2;
3811 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3812 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(
3813 pParty->vPosition.x,
3814 pParty->vPosition.y,
3815 pParty->vPosition.z);
3816 if ( sub_476387() )
3817 {
3818 v0 = (char *)&pParty->pPlayers[0].uClass;
3819 while ( *v0 != 31 )
3820 {
3821 v0 += 6972;
3822 if ( (signed int)v0 >= (signed int)((char *)&pParty->pPickedItem.uExpireTime + 5) )
3823 goto LABEL_15;
3824 }
3825 ++uRestUI_FoodRequiredToRest;
3826 }
3827 LABEL_15:
3828 if ( CheckHiredNPCSpeciality(0x1Du) )
3829 --uRestUI_FoodRequiredToRest;
3830 if ( CheckHiredNPCSpeciality(0x1Eu) )
3831 uRestUI_FoodRequiredToRest -= 2;
3832 if ( CheckHiredNPCSpeciality(0x30u) )
3833 --uRestUI_FoodRequiredToRest;
3834 if ( uRestUI_FoodRequiredToRest < 1 )
3835 uRestUI_FoodRequiredToRest = 1;
3836 if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 98) )
3837 uRestUI_FoodRequiredToRest = 0;
3838 ++pIcons_LOD->uTexturePacksCount;
3839 if ( !pIcons_LOD->uNumPrevLoadedFiles )
3840 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
3841 pCurrentScreen = 5;
3842 _507CD4_RestUI_hourglass_anim_controller = 0;
3843 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
3844 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
3845 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
3846 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
3847 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
3848 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
3849 LoadActualSkyFrame();
3850 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)16, 0, 0);
3851 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(
3852 280u,
3853 297u,
3854 154u,
3855 37u,
3856 1,
3857 0,
3858 0xA7u,
3859 0,
3860 0,
3861 "",
3862 (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0),
3863 0);
3864 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton(
3865 24u,
3866 154u,
3867 225u,
3868 37u,
3869 1,
3870 0,
3871 0x61u,
3872 0,
3873 0x52u,
3874 "",
3875 (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0),
3876 0);
3877 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(
3878 61u,
3879 232u,
3880 154u,
3881 33u,
3882 1,
3883 0,
3884 0x6Du,
3885 0,
3886 0x44u,
3887 "",
3888 (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0),
3889 0);
3890 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(
3891 61u,
3892 264u,
3893 154u,
3894 33u,
3895 1,
3896 0,
3897 0x60u,
3898 0,
3899 0x48u,
3900 "",
3901 (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0),
3902 0);
3903 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(
3904 61u,
3905 296u,
3906 154u,
3907 33u,
3908 1,
3909 0,
3910 0x5Fu,
3911 0,
3912 0x4Du,
3913 "",
3914 (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0),
3915 0);
3916 }
3917
3918 //----- (0041FA01) --------------------------------------------------------
3919 void __cdecl RestUI_Draw()
3920 {
3921 int v0; // esi@1
3922 Player **ppPlayers; // ecx@1
3923 Player *pPlayer; // eax@2
3924 unsigned int v3; // eax@15
3925 char v4; // al@17
3926 bool v5; // eax@21
3927 GUIButton Dst; // [sp+8h] [bp-DCh]@19
3928 //double v7; // [sp+C4h] [bp-20h]@17
3929 float v8; // [sp+CCh] [bp-18h]@17
3930 __int64 v9; // [sp+D0h] [bp-14h]@17
3931 unsigned int v10; // [sp+D8h] [bp-Ch]@9
3932 __int16 a9[2]; // [sp+DCh] [bp-8h]@1
3933 int a5; // [sp+E0h] [bp-4h]@1
3934
3935 v0 = 0;
3936 a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
3937 *(int *)a9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 0xD6u, 0xC1u);
3938 ppPlayers = &pPlayers[1];
3939 do
3940 {
3941 pPlayer = *ppPlayers;
3942 if ( !(*ppPlayers)->pConditions[14] && !pPlayer->pConditions[16] && pPlayer->sHealth > 0 )
3943 ++v0;
3944 ++ppPlayers;
3945 }
3946 while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
3947 if ( v0 )
3948 {
3949 pRenderer->DrawTextureIndexed(
3950 8u,
3951 8u,
3952 (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0));
3953 v10 = pParty->uCurrentHour;
3954 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
3955 if ( (signed int)pParty->uCurrentHour <= 12 )
3956 {
3957 if ( !v10 )
3958 v10 = 12;
3959 }
3960 else
3961 {
3962 v10 -= 12;
3963 }
3964 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame);
3965 if ( pTexture_RestUI_CurrentHourglassFrame )
3966 {
3967 pTexture_RestUI_CurrentHourglassFrame->Release();
3968 pIcons_LOD->_40F9C5();
3969 }
3970 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
3971 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
3972 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
3973 {
3974 v3 = 0;
3975 _507CD4_RestUI_hourglass_anim_controller = 0;
3976 }
3977 v9 = v3;
3978 v8 = (double)v3 * 0.001953125 * 120.0;
3979 //v7 = v8 + 6.7553994e15;
3980 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
3981 v4 = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
3982 byte_4E2BC8 = v4;
3983 if ( (unsigned __int8)(v4) >= 0x78u )
3984 {
3985 v4 = 1;
3986 byte_4E2BC8 = 1;
3987 }
3988 sprintf(pTmpBuf, "hglas%03d", (unsigned __int8)v4);
3989 pTexture_RestUI_CurrentHourglassFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
3990 pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame);
3991 memset(&Dst, 0, 0xBCu);
3992 Dst.uX = 24;
3993 Dst.uY = 154;
3994 Dst.uWidth = 171;
3995 Dst.uHeight = 37;
3996 Dst.uZ = 194;
3997 Dst.uW = 190;
3998 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
3999 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9);
4000 Dst.pParent = 0;
4001 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
4002 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
4003 pButton_RestUI_WaitUntilDawn->DrawLabel(
4004 pGlobalTXT_LocalizationStrings[237],
4005 pFontCreate,
4006 a5,
4007 *(int **)a9);
4008 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9);
4009 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9);
4010 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9);
4011 memset(&Dst, 0, 0xBCu);
4012 Dst.uX = 45;
4013 Dst.uY = 199;
4014 Dst.uWidth = 185;
4015 Dst.uHeight = 30;
4016 Dst.uZ = 229;
4017 Dst.uW = 228;
4018 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
4019 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9);
4020 Dst.pParent = 0;
4021 v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18;
4022 sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]);
4023 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
4024 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
4025 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
4026 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
4027 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
4028 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
4029 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
4030 if ( dword_506F14 )
4031 Sleep6Hours();
4032 }
4033 else
4034 {
4035 GUIWindow::Create(
4036 pButton_RestUI_Exit->uX,
4037 pButton_RestUI_Exit->uY,
4038 0,
4039 0,
4040 (enum WindowType)96,
4041 (int)pButton_RestUI_Exit,
4042 (int)pGlobalTXT_LocalizationStrings[81]);
4043 }
4044 }
4045 // 4E2BC8: using guessed type char byte_4E2BC8;
4046 // 506F14: using guessed type int dword_506F14;
4047 // 506F1C: using guessed type int dword_506F1C;
4048 // 50765C: using guessed type int uTextureID_RestUI_restmain;
4049 // 507CD4: using guessed type int 507CD4_RestUI_hourglass_anim_controller;
4050
4051 //----- (0041FE71) --------------------------------------------------------
4052 int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID)
4053 {
4054 int v3; // eax@1
4055 unsigned int v4; // eax@1
4056 Texture *v5; // ecx@1
4057 signed int v6; // eax@1
4058 signed int v7; // edi@3
4059 signed int v8; // eax@3
4060 int v9; // edi@3
4061 int v10; // ebx@5
4062 int v11; // esi@9
4063 int v12; // edx@10
4064 int v13; // ecx@11
4065 char *v14; // eax@12
4066 int v16; // [sp+Ch] [bp-Ch]@1
4067 signed int v17; // [sp+10h] [bp-8h]@1
4068 signed int v18; // [sp+14h] [bp-4h]@1
4069
4070 v17 = a1;
4071 v3 = pChests[uChestID].uChestBitmapID;
4072 v16 = pChestHeightsByType[v3];
4073 v18 = pChestWidthsByType[v3];
4074 v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE);
4075 v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
4076 v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
4077 if ( v6 < 14 )
4078 v6 = 14;
4079 v7 = v6 - 14;
4080 v8 = v5->uTextureHeight;
4081 v9 = (v7 >> 5) + 1;
4082 if ( v8 < 14 )
4083 v8 = 14;
4084 v10 = ((v8 - 14) >> 5) + 1;
4085 if ( !areWeLoadingTexture )
4086 {
4087 v5->Release();
4088 pIcons_LOD->_40F9C5();
4089 }
4090 if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 )
4091 {
4092 v11 = 0;
4093 if ( v10 <= 0 )
4094 return 1;
4095 v12 = 0;
4096 while ( 1 )
4097 {
4098 v13 = 0;
4099 if ( v9 > 0 )
4100 break;
4101 LABEL_15:
4102 v12 += v18;
4103 ++v11;
4104 if ( v11 >= v10 )
4105 return 1;
4106 }
4107 v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID];
4108 while ( !*(short *)v14 )
4109 {
4110 ++v13;
4111 v14 += 2;
4112 if ( v13 >= v9 )
4113 goto LABEL_15;
4114 }
4115 }
4116 return 0;
4117 }
4118 // 506128: using guessed type int areWeLoadingTexture;
4119
4120 //----- (0041FF64) --------------------------------------------------------
4121 int Chest::_41FF64(unsigned int uChestID)
4122 {
4123 unsigned int v1; // ecx@1
4124 signed int result; // eax@1
4125 int v3; // edx@1
4126 ItemGen *pItem; // ecx@2
4127
4128 v1 = uChestID;
4129 result = 0;
4130 v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID];
4131 if ( v3 <= 0 )
4132 {
4133 LABEL_5:
4134 result = -1;
4135 }
4136 else
4137 {
4138 pItem = pChests[v1].mm7__vector_pItems;
4139 while ( pItem->uItemID )
4140 {
4141 ++result;
4142 ++pItem;
4143 if ( result >= v3 )
4144 goto LABEL_5;
4145 }
4146 }
4147 return result;
4148 }
4149
4150 //----- (0041FFA2) --------------------------------------------------------
4151 int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID)
4152 {
4153 int v3; // eax@1
4154 ItemGen *v4; // edi@1
4155 int v5; // esi@1
4156 int result; // eax@11
4157 unsigned int v7; // eax@12
4158 int v8; // edx@12
4159 int v9; // ecx@12
4160 signed int v10; // eax@12
4161 signed int v11; // edi@14
4162 unsigned int v12; // esi@14
4163 int v13; // edi@16
4164 void *v14; // edi@21
4165 int v15; // edi@21
4166 int i; // ecx@21
4167 ItemGen *Src; // [sp+Ch] [bp-18h]@1
4168 signed int v18; // [sp+10h] [bp-14h]@2
4169 int v19; // [sp+14h] [bp-10h]@1
4170 int v20; // [sp+18h] [bp-Ch]@19
4171 signed int v21; // [sp+1Ch] [bp-8h]@1
4172 signed int v22; // [sp+20h] [bp-4h]@3
4173 int v23; // [sp+20h] [bp-4h]@19
4174
4175 v21 = 0;
4176 v3 = pChests[uChestID].uChestBitmapID;
4177 v4 = a2;
4178 v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3];
4179 Src = a2;
4180 v19 = pChestWidthsByType[v3];
4181 if ( a1 == -1 )
4182 {
4183 v18 = _41FF64(uChestID);
4184 if ( v18 == -1 )
4185 return 0;
4186 v22 = 0;
4187 if ( v5 > 0 )
4188 {
4189 while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) )
4190 {
4191 ++v22;
4192 if ( v22 >= v5 )
4193 goto LABEL_8;
4194 }
4195 v21 = v22;
4196 }
4197 LABEL_8:
4198 if ( v22 == v5 )
4199 {
4200 if ( uActiveCharacter )
4201 pPlayers[uActiveCharacter]->PlaySound(15, 0);
4202 return 0;
4203 }
4204 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
4205 HIWORD(v8) = 0;
4206 v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
4207 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4208 if ( v10 < 14 )
4209 v10 = 14;
4210 v11 = *(short *)(v9 + 26);
4211 v12 = ((v10 - 14) >> 5) + 1;
4212 if ( v11 < 14 )
4213 v11 = 14;
4214 v13 = ((v11 - 14) >> 5) + 1;
4215 if ( !areWeLoadingTexture )
4216 {
4217 ((Texture *)v9)->Release();
4218 pIcons_LOD->_40F9C5();
4219 }
4220 if ( v13 > 0 )
4221 {
4222 v23 = 0;
4223 v20 = v13;
4224 do
4225 {
4226 if ( (signed int)v12 > 0 )
4227 {
4228 v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID];
4229 LOWORD(v8) = -1 - v21;
4230 v8 <<= 16;
4231 LOWORD(v8) = -1 - v21;
4232 memset32(v14, v8, v12 >> 1);
4233 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
4234 for ( i = v12 & 1; i; --i )
4235 {
4236 *(short *)v15 = v8;
4237 v15 += 2;
4238 }
4239 }
4240 v23 += v19;
4241 --v20;
4242 }
4243 while ( v20 );
4244 }
4245 pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1;
4246 memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u);
4247 result = v21 + 1;
4248 }
4249 else
4250 {
4251 result = 1;
4252 }
4253 return result;
4254 }
4255 // 506128: using guessed type int areWeLoadingTexture;
4256
4257 //----- (0042013E) --------------------------------------------------------
4258 unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID)
4259 {
4260 int v3; // esi@1
4261 unsigned int v4; // ebx@1
4262 int uItemID; // edi@1
4263 int v6; // edx@4
4264 unsigned int v7; // eax@5
4265 Texture *v8; // ecx@5
4266 signed int v9; // eax@5
4267 signed int v10; // edi@7
4268 unsigned int v11; // ebx@7
4269 int v12; // edi@9
4270 int v13; // edx@12
4271 void *v14; // edi@14
4272 int v15; // edi@14
4273 int i; // ecx@14
4274 unsigned int result; // eax@18
4275 __int16 v18; // [sp+Ch] [bp-10h]@1
4276 int v19; // [sp+10h] [bp-Ch]@11
4277 int v20; // [sp+14h] [bp-8h]@12
4278 unsigned int v21; // [sp+18h] [bp-4h]@1
4279
4280 v3 = 5324 * uChestID;
4281 v21 = a1;
4282 v4 = 5324 * uChestID + 36 * uItemIdx;
4283 v18 = uItemIdx;
4284 uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4);
4285 pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4));
4286 if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) )
4287 {
4288 v6 = rand() % 21 + 10;
4289 *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6;
4290 *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6;
4291 }
4292 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
4293 v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
4294 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4295 if ( v9 < 14 )
4296 v9 = 14;
4297 v10 = v8->uTextureHeight;
4298 v11 = ((v9 - 14) >> 5) + 1;
4299 if ( v10 < 14 )
4300 v10 = 14;
4301 v12 = ((v10 - 14) >> 5) + 1;
4302 if ( !areWeLoadingTexture )
4303 {
4304 v8->Release();
4305 pIcons_LOD->_40F9C5();
4306 }
4307 v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)];
4308 if ( v12 > 0 )
4309 {
4310 v13 = 0;
4311 v20 = v12;
4312 do
4313 {
4314 if ( (signed int)v11 > 0 )
4315 {
4316 v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID];
4317 LOWORD(v3) = -1 - v21;
4318 v3 <<= 16;
4319 LOWORD(v3) = -1 - v21;
4320 memset32(v14, v3, v11 >> 1);
4321 v15 = (int)((char *)v14 + 4 * (v11 >> 1));
4322 for ( i = v11 & 1; i; --i )
4323 {
4324 *(short *)v15 = v3;
4325 v15 += 2;
4326 }
4327 }
4328 v13 += v19;
4329 --v20;
4330 }
4331 while ( v20 );
4332 }
4333 result = v21 + 2662 * uChestID;
4334 pChests[0].pInventoryIndices[result] = v18 + 1;
4335 return result;
4336 }
4337 // 506128: using guessed type int areWeLoadingTexture;
4338
4339 //----- (00420284) --------------------------------------------------------
4340 char *Chest::_420284(unsigned int uChestID)
4341 {
4342 int v1; // ebx@1
4343 unsigned int v2; // esi@1
4344 unsigned int v3; // esi@1
4345 int uChestArea; // edi@1
4346 int v5; // eax@2
4347 int v6; // ebx@11
4348 char *result; // eax@18
4349 char Dst[144]; // [sp+Ch] [bp-A0h]@1
4350 int v9; // [sp+9Ch] [bp-10h]@10
4351 unsigned int v10; // [sp+A0h] [bp-Ch]@1
4352 unsigned int v11; // [sp+A4h] [bp-8h]@8
4353 unsigned int *v12; // [sp+A8h] [bp-4h]@9
4354
4355 v1 = 0;
4356 v2 = uChestID;
4357 v10 = uChestID;
4358 pRenderer->ClearZBuffer(0, 479);
4359 v3 = v2;
4360 uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID];
4361 memset(Dst, 0, 0x90u);
4362 if ( uChestArea > 0 )
4363 {
4364 do
4365 {
4366 do
4367 v5 = (unsigned __int8)rand();
4368 while ( v5 >= uChestArea );
4369 while ( Dst[v5] )
4370 {
4371 ++v5;
4372 if ( v5 == uChestArea )
4373 v5 = 0;
4374 }
4375 Dst[v5] = v1++;
4376 }
4377 while ( v1 < uChestArea );
4378 }
4379 v11 = 0;
4380 if ( uChestArea > 0 )
4381 {
4382 v12 = &pChests[v3].mm7__vector_pItems[0].uAttributes;
4383 do
4384 {
4385 v9 = *(v12 - 5);
4386 if ( v9 )
4387 {
4388 v6 = 0;
4389 while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) )
4390 {
4391 ++v6;
4392 if ( v6 >= uChestArea )
4393 goto LABEL_17;
4394 }
4395 Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10);
4396 if ( pChests[v3].uFlags & 4 )
4397 *v12 |= 1u;
4398 }
4399 LABEL_17:
4400 ++v11;
4401 v12 += 9;
4402 }
4403 while ( (signed int)v11 < uChestArea );
4404 }
4405 result = (char *)&pChests[v3].uFlags;
4406 pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2;
4407 return result;
4408 }
4409 // 420284: using guessed type char Dst[144];
4410
4411 //----- (0042038D) --------------------------------------------------------
4412 void __cdecl sub_42038D()
4413 {
4414 POINT *v0; // esi@2
4415 int v1; // ecx@2
4416 const char *v2; // eax@3
4417 POINT v3; // [sp+0h] [bp-10h]@2
4418 POINT a2; // [sp+8h] [bp-8h]@1
4419
4420 if ( pMouse->GetCursorPos(&a2)->y < 350 )
4421 {
4422 v0 = pMouse->GetCursorPos(&a2);
4423 v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]];
4424 if ( v1 )
4425 {
4426 auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C
4427 + 18 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
4428 + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
4429 v2 = _w->GetDisplayName();
4430 sub_41C0B8_set_status_string(v2);
4431 }
4432 }
4433 }
4434
4435 //----- (0042041E) --------------------------------------------------------
4436 bool Chest::Open(unsigned int uChestID)
4437 {
4438 char *v1; // edi@5
4439 unsigned int v2; // eax@8
4440 GUIWindow *v3; // eax@15
4441 int v5; // edx@16
4442 int v6; // eax@16
4443 ODMFace *v7; // eax@19
4444 int v8; // edx@19
4445 int v9; // edi@19
4446 signed int v10; // ebx@19
4447 int v11; // ecx@19
4448 int v12; // eax@19
4449 BLVFace *v13; // eax@20
4450 int v14; // ebx@21
4451 int v15; // edi@21
4452 int v16; // ecx@22
4453 __int64 v17; // qax@22
4454 double v18; // st7@23
4455 double v19; // st6@23
4456 double v20; // st7@23
4457 int v21; // ecx@26
4458 char v22[12]; // ST4C_12@28
4459 unsigned int *v23; // edi@28
4460 unsigned __int16 v24; // di@28
4461 signed int v25; // ecx@28
4462 char *v26; // edx@29
4463 unsigned __int16 v27; // ax@32
4464 //LayingItem a1; // [sp+14h] [bp-B0h]@28
4465 int v29; // [sp+84h] [bp-40h]@16
4466 int v30; // [sp+88h] [bp-3Ch]@16
4467 int v31; // [sp+8Ch] [bp-38h]@16
4468 int v32; // [sp+90h] [bp-34h]@16
4469 float v33; // [sp+94h] [bp-30h]@23
4470 char *v34; // [sp+98h] [bp-2Ch]@5
4471 int v35; // [sp+9Ch] [bp-28h]@16
4472 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
4473 int a4; // [sp+ACh] [bp-18h]@1
4474 int v38; // [sp+B0h] [bp-14h]@21
4475 int sRotX; // [sp+B4h] [bp-10h]@23
4476 float v40; // [sp+B8h] [bp-Ch]@23
4477 float v41; // [sp+BCh] [bp-8h]@23
4478 int sRotY; // [sp+C0h] [bp-4h]@8
4479
4480 a4 = uChestID;
4481 if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 )
4482 return 0;
4483 ++pIcons_LOD->uTexturePacksCount;
4484 if ( !pIcons_LOD->uNumPrevLoadedFiles )
4485 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
4486 v1 = (char *)&pChests[uChestID].uFlags;
4487 v34 = v1;
4488 if ( !(*v1 & CHEST_ITEMS_PLACED) )
4489 Chest::_420284(uChestID);
4490 if ( !uActiveCharacter )
4491 return 0;
4492 *(float *)&sRotY = 0.0;
4493 v2 = pMapStats->GetMapInfo(pCurrentMapName);
4494 if ( !(*v1 & 1) || !v2 )
4495 goto LABEL_12;
4496 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].field_2D )
4497 {
4498 v29 = 811;
4499 v30 = 812;
4500 v31 = 813;
4501 v32 = 814;
4502 v5 = rand() % 4;
4503 v6 = dword_5B5920 >> 3;
4504 v35 = v5;
4505 if ( (dword_5B5920 & 7) == 5 )
4506 {
4507 v16 = v6;
4508 v14 = pLevelDecorations[v6].vPosition.x;
4509 v38 = pLevelDecorations[v6].vPosition.y;
4510 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight;
4511 v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1);
4512 }
4513 else
4514 {
4515 if ( (dword_5B5920 & 7) != 6 )
4516 goto LABEL_12;
4517 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
4518 {
4519 v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F];
4520 v8 = v7->pBoundingBox.y1;
4521 v9 = v7->pBoundingBox.z2;
4522 v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2;
4523 v11 = v7->pBoundingBox.y2;
4524 v12 = v7->pBoundingBox.z1;
4525 }
4526 else
4527 {
4528 v13 = &pIndoor->pFaces[v6];
4529 v8 = v13->pBounding.y1;
4530 v9 = v13->pBounding.z2;
4531 v10 = v13->pBounding.x1 + v13->pBounding.x2;
4532 v11 = v13->pBounding.y2;
4533 v12 = v13->pBounding.z1;
4534 }
4535 v14 = v10 >> 1;
4536 v38 = (v8 + v11) >> 1;
4537 v15 = (v12 + v9) >> 1;
4538 }
4539 v18 = (double)pParty->vPosition.x - (double)v14;
4540 *(float *)&a4 = v18;
4541 v19 = (double)pParty->vPosition.y - (double)v38;
4542 v33 = v19;
4543 v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15;
4544 *(float *)&sRotY = v19 * v19;
4545 *(float *)&sRotX = v18 * v18;
4546 v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY);
4547 v40 = v20;
4548 if ( v20 <= 1.0 )
4549 {
4550 *(float *)&sRotX = 0.0;
4551 *(float *)&sRotY = 0.0;
4552 }
4553 else
4554 {
4555 sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY);
4556 sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33);
4557 sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41);
4558 }
4559 v21 = 256;
4560 if ( v40 < 256.0 )
4561 v21 = (signed __int64)v40 / 4;
4562 *(int *)&v22[8] = v15;
4563 *(_QWORD *)v22 = __PAIR__(v38, v14);
4564 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y);
4565 v23 = (unsigned int *)(&v29 + v35);
4566 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0);
4567
4568 LayingItem a1; // [sp+14h] [bp-B0h]@28
4569 //LayingItem::LayingItem(&a1);
4570
4571 a1.stru_24.Reset();
4572 v24 = *(short *)v23;
4573 v25 = 0;
4574 a1.field_50 = 0;
4575 a1.field_4C = 0;
4576 a1.field_48 = 0;
4577 a1.field_54 = 0;
4578 a1.uItemType = v24;
4579 if ( (signed int)pObjectList->uNumObjects <= 0 )
4580 {
4581 LABEL_32:
4582 v27 = 0;
4583 }
4584 else
4585 {
4586 v26 = (char *)&pObjectList->pObjects->uObjectID;
4587 while ( v24 != *(short *)v26 )
4588 {
4589 ++v25;
4590 v26 += 56;
4591 if ( v25 >= (signed int)pObjectList->uNumObjects )
4592 goto LABEL_32;
4593 }
4594 v27 = v25;
4595 }
4596 a1.uObjectDescID = v27;
4597 a1.vPosition.y = pOut.z;
4598 a1.vPosition.x = pOut.x;
4599 a1.vPosition.z = pOut.y;
4600 a1.uSoundID = 0;
4601 a1.uAttributes = 48;
4602 a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y);
4603 a1.uSpriteFrameID = 0;
4604 a1.field_58 = 0;
4605 a1.field_5C = 0;
4606 a1.uFacing = 0;
4607 a1.Create(0, 0, 0, 0);
4608 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
4609 a1._438E35();
4610 *v34 &= 0xFEu;
4611 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 )
4612 {
4613 qword_A750D8 = 256i64;
4614 word_A750E0 = 5;
4615 word_A750E2 = uActiveCharacter;
4616 }
4617 pIcons_LOD->_4114F2();
4618 dword_507CD8 = 0;
4619 return 0;
4620 }
4621 *v1 &= 0xFEu;
4622 sRotY = 1;
4623 LABEL_12:
4624 pAudioPlayer->StopChannels(-1, -1);
4625 pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0);
4626 if ( *(float *)&sRotY != 0.0 )
4627 {
4628 if ( !dword_507CD8 )
4629 pPlayers[uActiveCharacter]->PlaySound(4, 0);
4630 }
4631 dword_507CD8 = 0;
4632 v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0);
4633 pGUIWindow_CurrentMenu = v3;
4634 pChestWindow = v3;
4635 pBtn_ExitCancel = v3->CreateButton(
4636 0x1D7u,
4637 0x1BDu,
4638 0xA9u,
4639 0x23u,
4640 1,
4641 0,
4642 0x71u,
4643 0,
4644 0,
4645 pGlobalTXT_LocalizationStrings[79],// Exit
4646 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
4647 0);
4648 pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
4649 pCurrentScreen = 10;
4650 pEventTimer->Pause();
4651 return 1;
4652 }
4653
4654 //----- (0042092D) --------------------------------------------------------
4655 void Chest::DrawChestUI(unsigned int uChestID)
4656 {
4657 Render *v1; // edi@1
4658 unsigned int v2; // ebx@1
4659 unsigned int v3; // ebx@1
4660 int v4; // eax@1
4661 unsigned int v5; // eax@1
4662 int v6; // ecx@3
4663 unsigned int v7; // eax@4
4664 Texture *v8; // esi@4
4665 signed int v9; // ecx@4
4666 signed int v10; // edx@4
4667 signed int v11; // eax@4
4668 int v12; // eax@6
4669 int v13; // eax@6
4670 unsigned int v14; // ST34_4@8
4671 int v15; // edi@8
4672 int *v16; // [sp+Ch] [bp-28h]@1
4673 int v17; // [sp+10h] [bp-24h]@4
4674 int v18; // [sp+14h] [bp-20h]@1
4675 signed int v19; // [sp+18h] [bp-1Ch]@1
4676 int v20; // [sp+1Ch] [bp-18h]@1
4677 signed int v21; // [sp+20h] [bp-14h]@1
4678 char *v22; // [sp+2Ch] [bp-8h]@2
4679 signed int v23; // [sp+30h] [bp-4h]@1
4680
4681 v1 = pRenderer;
4682 v2 = uChestID;
4683 v16 = pRenderer->pActiveZBuffer;
4684 pRenderer->ClearZBuffer(0, 479);
4685 v3 = v2;
4686 v4 = pChests[v3].uChestBitmapID;
4687 v20 = pChestSmthn1ByType[v4];
4688 v18 = pChestSmthn2ByType[v4];
4689 v21 = pChestWidthsByType[v4];
4690 v19 = pChestHeightsByType[v4];
4691 sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
4692 v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
4693 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
4694 v23 = 0;
4695 if ( v21 * v19 > 0 )
4696 {
4697 v22 = (char *)pChests[v3].pInventoryIndices;
4698 do
4699 {
4700 v6 = *(short *)v22;
4701 if ( v6 > 0 )
4702 {
4703 v17 = v18 + 32 * v23 / v19;
4704 v7 = pIcons_LOD->LoadTexture(
4705 pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
4706 TEXTURE_16BIT_PALETTE);
4707 v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0);
4708 v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4709 v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26);
4710 v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
4711 if ( v9 < 14 )
4712 v11 = 14;
4713 v12 = v11 - 14;
4714 LOBYTE(v12) = v12 & 0xE0;
4715 v13 = v12 + 32;
4716 if ( (signed int)v8->uTextureHeight < 14 )
4717 v10 = 14;
4718 v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1);
4719 v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1);
4720 pRenderer->DrawTextureTransparent(
4721 v14,
4722 v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1),
4723 v8);
4724 sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1);
4725 v1 = pRenderer;
4726 }
4727 ++v23;
4728 v22 += 2;
4729 }
4730 while ( v23 < v21 * v19 );
4731 }
4732 pRenderer->DrawTextureIndexed(
4733 pBtn_ExitCancel->uX,
4734 pBtn_ExitCancel->uY,
4735 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
4736 }
4737
4738 //----- (00420B13) --------------------------------------------------------
4739 void __fastcall sub_420B13(int a1, int a2)
4740 {
4741 void *v2; // eax@1
4742 ItemGen *v3; // ebx@1
4743 unsigned int v4; // eax@1
4744 Texture *v5; // ecx@1
4745 signed int v6; // eax@1
4746 signed int v7; // edi@3
4747 signed int v8; // eax@3
4748 int v9; // edi@3
4749 int v10; // eax@5
4750 int v11; // esi@8
4751 unsigned int v12; // ecx@10
4752 void *v13; // edi@10
4753 unsigned __int8 v14; // cf@10
4754 int v15; // edi@10
4755 int i; // ecx@10
4756 int v17; // [sp+Ch] [bp-14h]@1
4757 int v18; // [sp+10h] [bp-10h]@3
4758 int v19; // [sp+14h] [bp-Ch]@1
4759 void *v20; // [sp+18h] [bp-8h]@1
4760 int v21; // [sp+1Ch] [bp-4h]@5
4761 int v22; // [sp+1Ch] [bp-4h]@8
4762
4763 v19 = a2;
4764 v2 = pChestWindow->ptr_1C;
4765 v20 = v2;
4766 v2 = (void *)(5324 * (int)v2);
4767 v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
4768 v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
4769 v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
4770 v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
4771 v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
4772 if ( v6 < 14 )
4773 v6 = 14;
4774 v7 = v6 - 14;
4775 v8 = v5->uTextureHeight;
4776 v9 = (v7 >> 5) + 1;
4777 v18 = v9;
4778 if ( v8 < 14 )
4779 v8 = 14;
4780 v10 = ((v8 - 14) >> 5) + 1;
4781 v21 = v10;
4782 if ( !areWeLoadingTexture )
4783 {
4784 v5->Release();
4785 pIcons_LOD->_40F9C5();
4786 v10 = v21;
4787 }
4788 if ( v10 > 0 )
4789 {
4790 v11 = 0;
4791 v22 = v10;
4792 do
4793 {
4794 if ( v9 > 0 )
4795 {
4796 v12 = v9;
4797 v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
4798 v14 = v12 & 1;
4799 v12 >>= 1;
4800 memset(v13, 0, 4 * v12);
4801 v15 = (int)((char *)v13 + 4 * v12);
4802 for ( i = v14; i; --i )
4803 {
4804 *(short *)v15 = 0;
4805 v15 += 2;
4806 }
4807 v9 = v18;
4808 }
4809 v11 += v17;
4810 --v22;
4811 }
4812 while ( v22 );
4813 }
4814 v3->Reset();
4815 }
4816 // 506128: using guessed type int areWeLoadingTexture;
4817
4818 //----- (00420C05) --------------------------------------------------------
4819 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal)
4820 {
4821 unsigned int v2; // edi@1
4822 int v3; // ebp@1
4823 unsigned int v4; // esi@1
4824 int v5; // ecx@6
4825 NPCData *v6; // eax@6
4826 signed int v7; // edx@8
4827 signed int v8; // ebx@10
4828 char *v9; // edi@11
4829 signed int v10; // ecx@17
4830 int v11; // eax@21
4831 NPCData *v12; // ecx@21
4832 unsigned int v13; // ecx@23
4833 signed int v14; // [sp+Ch] [bp-4h]@6
4834
4835 v2 = 0;
4836 v3 = 0;
4837 v4 = uNumGold;
4838 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal )
4839 {
4840 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 )
4841 {
4842 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold!
4843 }
4844 else
4845 {
4846 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 )
4847 pTmpBuf2[0] = 0;
4848 }
4849 }
4850 else
4851 {
4852 v14 = 0;
4853 v5 = 0;
4854 v6 = pParty->pHirelings;
4855 do
4856 {
4857 if ( v6->pName )
4858 {
4859 v7 = v14++;
4860 pTmpBuf[v7] = v5;
4861 }
4862 ++v6;
4863 ++v5;
4864 }
4865 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
4866 v8 = 0;
4867 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
4868 {
4869 v9 = (char *)pNPCStats->pNewNPCData;
4870 do
4871 {
4872 if ( v9[8] & 0x80
4873 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName))
4874 && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) )
4875 {
4876 v10 = v14++;
4877 pTmpBuf[v10] = v8 + 2;
4878 }
4879 ++v8;
4880 v9 += 76;
4881 }
4882 while ( v8 < (signed int)pNPCStats->uNumNewNPCs );
4883 v2 = 0;
4884 }
4885 if ( v14 > 0 )
4886 {
4887 do
4888 {
4889 v11 = (unsigned __int8)pTmpBuf[v2];
4890 v12 = &pNPCStats->pNPCData[v11 + 499];
4891 if ( (unsigned __int8)pTmpBuf[v2] < 2u )
4892 v12 = &pParty->pHirelings[v11];
4893 v13 = v12->uProfession;
4894 if ( v13 )
4895 v3 += *(&pNPCStats->field_13A58 + 5 * v13);
4896 ++v2;
4897 }
4898 while ( (signed int)v2 < v14 );
4899 }
4900 if ( CheckHiredNPCSpeciality(0x1Fu) )
4901 v4 += (signed int)(10 * v4) / 100;
4902 if ( CheckHiredNPCSpeciality(0x20u) )
4903 v4 += (signed int)(20 * v4) / 100;
4904 if ( CheckHiredNPCSpeciality(0x2Du) )
4905 v4 += (signed int)(10 * v4) / 100;
4906 if ( v3 )
4907 {
4908 v3 = (signed int)(v4 * v3 / 100) / 100;
4909 if ( v3 < 1 )
4910 v3 = 1;
4911 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)!
4912 }
4913 else
4914 {
4915 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold!
4916 }
4917 v2 = 0;
4918 }
4919 pParty->uNumGold += v4 - v3;
4920 pUIAnim_Gold->uAnimTime = v2;
4921 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength;
4922 if ( pTmpBuf2[0] )
4923 ShowStatusBarString(pTmpBuf2, 2u);
4924 pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2);
4925 }
4926
4927 //----- (00420E01) --------------------------------------------------------
4928 void __cdecl sub_420E01()
4929 {
4930 void *v0; // edi@1
4931 POINT *v1; // esi@2
4932 int v2; // eax@2
4933 int v3; // ebx@4
4934 int v4; // esi@6
4935 int v5; // ecx@6
4936 //LayingItem v6; // [sp+Ch] [bp-80h]@1
4937 char v7; // [sp+7Ch] [bp-10h]@2
4938 POINT a2; // [sp+84h] [bp-8h]@2
4939
4940 LayingItem v6; // [sp+Ch] [bp-80h]@1
4941 //LayingItem::LayingItem(&v6);
4942
4943 v0 = pGUIWindow_CurrentMenu->ptr_1C;
4944 if ( pParty->pPickedItem.uItemID )
4945 {
4946 if ( Chest::_41FFA2(-1, &pParty->pPickedItem, (unsigned int)pGUIWindow_CurrentMenu->ptr_1C) )
4947 pMouse->RemoveHoldingItem();
4948 }
4949 else
4950 {
4951 v1 = pMouse->GetCursorPos(&a2);
4952 v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF;
4953 if ( v2 )
4954 {
4955 if ( v2 )
4956 v3 = v2 - 1;
4957 else
4958 v3 = -1;
4959 v4 = pChests[0].pInventoryIndices[v3 + 2662 * (int)v0] - 1;
4960 v5 = 5324 * (int)v0 + 36 * v4;
4961 if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 )
4962 {
4963 party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uAdditionalValue + v5), 0);
4964 viewparams->bRedrawGameUI = 1;
4965 }
4966 else
4967 {
4968 pParty->SetHoldingItem((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v5));
4969 }
4970 sub_420B13(v4, v3);
4971 }
4972 }
4973 }
4974
4975 //----- (00420EFF) --------------------------------------------------------
4976 void __cdecl GameUI_WritePointedObjectStatusString()
4977 {
4978 int v1; // ebx@6
4979 GUIWindow *v2; // edi@7
4980 GUIButton *i; // ecx@11
4981 Player *v4; // eax@19
4982 char v5; // cl@19
4983 unsigned int v6; // eax@19
4984 int v7; // ecx@19
4985 __int16 v8; // fps@23
4986 unsigned __int8 v9; // c0@23
4987 unsigned __int8 v10; // c3@23
4988 enum UIMessageType v11; // esi@24
4989 int v12; // edx@25
4990 char *v13; // ecx@28
4991 int v14; // eax@41
4992 ItemGen *v15; // ecx@44
4993 int v16; // ecx@46
4994 const char *v17; // eax@49
4995 signed int v18; // eax@55
4996 signed int v19; // ecx@63
4997 BLVFace *pFace; // eax@69
4998 __int16 v21; // ax@70
4999 const char *v22; // eax@72
5000 LevelDecoration *v23; // ecx@75
5001 LevelDecoration *v24; // esi@75
5002 __int16 v25; // ax@75
5003 const char *v26; // ecx@79
5004 Actor *pActor; // ecx@82
5005 char *v28; // esi@82
5006 int v29; // eax@82
5007 signed int v30; // ecx@88
5008 const char *v31; // eax@91
5009 __int16 v32; // fps@109
5010 unsigned __int8 v33; // c0@109
5011 unsigned __int8 v34; // c3@109
5012 enum UIMessageType v35; // esi@110
5013 int v36; // edx@111
5014 enum UIMessageType v37; // edx@117
5015 int v38; // ecx@118
5016 const char *v39; // [sp-8h] [bp-E8h]@20
5017 char *v40; // [sp-8h] [bp-E8h]@83
5018 int v41; // [sp-4h] [bp-E4h]@20
5019 char Str1[200]; // [sp+Ch] [bp-D4h]@129
5020 unsigned int pX; // [sp+D4h] [bp-Ch]@1
5021 unsigned int pY; // [sp+D8h] [bp-8h]@1
5022 unsigned int v45; // [sp+DCh] [bp-4h]@21
5023
5024 v13 = nullptr;
5025
5026 pMouse->uPointingObjectID = 0;
5027 pMouse->GetClickPos(&pX, &pY);
5028 if ( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 )
5029 return;
5030 if ( !pCurrentScreen )
5031 {
5032 if ( (signed int)pX > 467 || (signed int)pY > 351 )
5033 goto _click_on_game_ui;
5034 if ( pRenderer->pRenderD3D )
5035 {
5036 v18 = pGame->pVisInstance->get_picked_object_zbuf_val();
5037 if ( (signed int)pX < (signed int)pViewport->uScreenX
5038 || (signed int)pX > (signed int)pViewport->uScreenZ
5039 || (signed int)pY < (signed int)pViewport->uScreenY
5040 || (signed int)pY > (signed int)pViewport->uScreenW )
5041 v18 = -1;
5042 if ( v18 == -1 )
5043 goto LABEL_61;
5044 }
5045 else
5046 {
5047 v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
5048 }
5049 pMouse->uPointingObjectID = (unsigned __int16)v18;
5050 v19 = (signed int)(unsigned __int16)v18 >> 3;
5051 if ( (v18 & 7) == OBJECT_Item )
5052 {
5053 v30 = v19;
5054 if ( pObjectList->pObjects[pLayingItems[v30].uObjectDescID].uFlags & 0x10 )
5055 goto LABEL_73;
5056 if ( v18 >= (signed int)0x2000000u || pParty->pPickedItem.uItemID )
5057 {
5058 v22 = pLayingItems[v30].stru_24.GetDisplayName();
5059 LABEL_93:
5060 v26 = v22;
5061 goto LABEL_87;
5062 }
5063 v31 = pLayingItems[v30].stru_24.GetDisplayName();
5064 v28 = pTmpBuf;
5065 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s"
5066 }
5067 else
5068 {
5069 if ( (v18 & 7) != OBJECT_Actor )
5070 {
5071 if ( (v18 & 7) == OBJECT_Decoration )
5072 {
5073 v23 = &pLevelDecorations[v19];
5074 v24 = v23;
5075 v25 = v23->field_16_event_id;
5076 if ( !v25 )
5077 {
5078 if ( v23->IsInteractive() )
5079 v26 = pNPCTopics[stru_5E4C90._decor_events[v24->_idx_in_stru123 - 75] + 379].pTopic;
5080 else
5081 v26 = pDecorationList->pDecorations[v24->uDecorationDescID].field_20;
5082 goto LABEL_87;
5083 }
5084 v22 = _444732_GetEventHintString(v25);
5085 if ( !v22 )
5086 goto _return;
5087 goto LABEL_93;
5088 }
5089 if ( (v18 & 7) == 6 ) // bmodel
5090 {
5091 if ( v18 < (signed int)0x2000000u )
5092 {
5093 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
5094 {
5095 v21 = pOutdoor->pBModels[(signed int)(unsigned __int16)v18 >> 9].pFaces[v19 & 0x3F].sCogTriggeredID;
5096 goto LABEL_71;
5097 }
5098 pFace = &pIndoor->pFaces[v19];
5099 if ( BYTE3(pFace->uAttributes) & 6 )
5100 {
5101 v21 = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
5102 LABEL_71:
5103 if ( !v21 || (v22 = _444732_GetEventHintString(v21)) == 0 )
5104 goto LABEL_73;
5105 goto LABEL_93;
5106 }
5107 }
5108 LABEL_73:
5109 pMouse->uPointingObjectID = 0;
5110 goto LABEL_50;
5111 }
5112 LABEL_61:
5113 pMouse->uPointingObjectID = 0;
5114 goto _return;
5115 }
5116 if ( v18 >= 335544320 )
5117 goto LABEL_61;
5118 pActor = &pActors[v19];
5119 v28 = pTmpBuf;
5120 v29 = pActor->dword_000334_unique_name;
5121 if ( v29 )
5122 v40 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v29);
5123 else
5124 v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName;
5125 strncpy(pTmpBuf, v40, 0x7D0u);
5126 }
5127 v26 = v28;
5128 LABEL_87:
5129 sub_41C0B8_set_status_string(v26);
5130 goto _return;
5131 }
5132 v1 = uNumVisibleWindows;
5133 if ( uNumVisibleWindows <= 0 )
5134 {
5135 LABEL_38:
5136 if ( pCurrentScreen == 10 )
5137 {
5138 sub_42038D();
5139 goto _return;
5140 }
5141 if ( pCurrentScreen == 13 )
5142 {
5143 if ( dword_F8B19C != 2
5144 || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0)
5145 || v16 == -65536 )
5146 goto _return;
5147 v15 = (ItemGen *)((char *)&pParty->pPickedItem + 36 * (v16 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 4);
5148 LABEL_49:
5149 v17 = v15->GetDisplayName();
5150 sub_41C0B8_set_status_string(v17);
5151 LABEL_50:
5152 uLastPointedObjectID = 1;
5153 _return:
5154 if ( pMouse->uPointingObjectID == 0 )
5155 {
5156 if ( uLastPointedObjectID != 0 )
5157 {
5158 pStatusBarString[0] = 0;
5159 bForceDrawStatusBar = 1;
5160 }
5161 }
5162 uLastPointedObjectID = pMouse->uPointingObjectID;
5163 return;
5164 }
5165 if ( (signed int)pY < 350 )
5166 {
5167 v14 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
5168 if ( v14 == 0 || v14 == -65536 || (unsigned int)v14 >= 0x1388 )
5169 goto _return;
5170 v15 = (ItemGen *)&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v14 + 5];
5171 goto LABEL_49;
5172 }
5173 _click_on_game_ui:
5174 if ( (signed int)pX >= (signed int)pWindowList[0].uFrameX
5175 && (signed int)pX <= (signed int)pWindowList[0].uFrameZ
5176 && (signed int)pY >= (signed int)pWindowList[0].uFrameY
5177 && (signed int)pY <= (signed int)pWindowList[0].uFrameW )
5178 {
5179 for ( i = pWindowList[0].pControlsHead; i != (GUIButton *)0; i = i->pNext )
5180 {
5181 if ( i->uButtonType == 1 )
5182 {
5183 if ( (signed int)pX >= (signed int)i->uX
5184 && (signed int)pX <= (signed int)i->uZ
5185 && (signed int)pY >= (signed int)i->uY
5186 && (signed int)pY <= (signed int)i->uW )
5187 {
5188 v37 = (UIMessageType)i->field_1C;
5189 if ( v37 == 0 )
5190 goto LABEL_28;
5191 v38 = i->uControlParam;
5192 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
5193 {
5194 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = v37;
5195 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v38;
5196 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
5197 ++pMessageQueue_50CBD0->uNumMessages;
5198 }
5199 goto LABEL_131;
5200 }
5201 }
5202 else
5203 {
5204 if ( i->uButtonType == 2 )
5205 {
5206 v45 = pX - i->uX;
5207 v45 = pY - i->uY;
5208
5209 if (pX >= i->uX && pX <= i->uZ &&
5210 pY >= i->uY && pY <= i->uW)
5211 //if ( (double)(signed int)i->uWidth != 0.0 )
5212 //{
5213 // if ( (double)(signed int)i->uHeight != 0.0 )
5214 // {
5215 //UNDEF(v32);
5216 //if ( v33 | v34 )
5217 {
5218 v35 = (UIMessageType)i->field_1C;
5219 if ( v35 != 0 )
5220 {
5221 v36 = i->uControlParam;
5222 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
5223 {
5224 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = v35;
5225 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v36;
5226 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
5227 goto LABEL_27;
5228 }
5229 }
5230 goto LABEL_28;
5231 //}
5232 //}
5233 }
5234 }
5235 else
5236 {
5237 if ( i->uButtonType == 3
5238 && (signed int)pX >= (signed int)i->uX
5239 && (signed int)pX <= (signed int)i->uZ
5240 && (signed int)pY >= (signed int)i->uY
5241 && (signed int)pY <= (signed int)i->uW )
5242 goto LABEL_19;
5243 }
5244 }
5245 }
5246 }
5247 pMouse->uPointingObjectID = sub_46A99B();
5248 goto _return;
5249 }
5250 while ( 1 ) // some other fullscreen ui
5251 {
5252 v2 = &pWindowList[pVisibleWindowsIdxs[v1] - 1];
5253 if ( (signed int)pX >= (signed int)v2->uFrameX
5254 && (signed int)pX <= (signed int)v2->uFrameZ
5255 && (signed int)pY >= (signed int)v2->uFrameY
5256 && (signed int)pY <= (signed int)v2->uFrameW )
5257 {
5258 for ( i = v2->pControlsHead; ; i = i->pNext )
5259 {
5260 if ( !i )
5261 break;
5262 if ( i->uButtonType == 1 )
5263 {
5264 if ( (signed int)pX >= (signed int)i->uX
5265 && (signed int)pX <= (signed int)i->uZ
5266 && (signed int)pY >= (signed int)i->uY
5267 && (signed int)pY <= (signed int)i->uW )
5268 {
5269 LABEL_24:
5270 v11 = (UIMessageType)i->field_1C;
5271 if ( v11 )
5272 {
5273 v12 = i->uControlParam;
5274 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
5275 {
5276 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = v11;
5277 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
5278 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
5279 LABEL_27:
5280 ++pMessageQueue_50CBD0->uNumMessages;
5281 }
5282 }
5283 LABEL_28:
5284 v13 = i->pButtonName;
5285 _set_status_and_ret:
5286 sub_41C0B8_set_status_string(v13);
5287 LABEL_131:
5288 uLastPointedObjectID = 1;
5289 return;
5290 }
5291 }
5292 else
5293 {
5294 if ( i->uButtonType == 2 )
5295 {
5296 v45 = pX - i->uX;
5297 v45 = pY - i->uY;
5298 if ( (double)(signed int)i->uWidth != 0.0 )
5299 {
5300 if ( (double)(signed int)i->uHeight != 0.0 )
5301 {
5302 //UNDEF(v8);
5303 if ( v9 | v10 )
5304 goto LABEL_24;
5305 }
5306 }
5307 }
5308 else // click on skill
5309 {
5310 if ( i->uButtonType == 3
5311 && (signed int)pX >= (signed int)i->uX
5312 && (signed int)pX <= (signed int)i->uZ
5313 && (signed int)pY >= (signed int)i->uY
5314 && (signed int)pY <= (signed int)i->uW )
5315 {
5316 LABEL_19:
5317 v4 = pPlayers[uActiveCharacter];
5318 v5 = LOBYTE(v4->pActiveSkills[i->uControlParam]);
5319 v6 = v4->uSkillPoints;
5320 v7 = (v5 & 0x3F) + 1;
5321 if ( v6 < v7 )
5322 {
5323 v41 = v7 - v6;
5324 v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here"
5325 }
5326 else
5327 {
5328 v41 = v7;
5329 v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
5330 }
5331 sprintf(Str1, v39, v41);
5332 v13 = Str1;
5333 goto _set_status_and_ret;
5334 }
5335 }
5336 }
5337 }
5338 }
5339 if ( v2->uFrameHeight == 480 )
5340 break;
5341 --v1;
5342 if ( v1 <= 0 )
5343 {
5344 goto LABEL_38;
5345 }
5346 }
5347 }
5348
5349
5350 //----- (00421626) --------------------------------------------------------
5351 GUIWindow *GameUI_InitializeCharacterWindow(unsigned int _this)
5352 {
5353 unsigned int v1; // edi@1
5354 GUIWindow *v2; // edi@3
5355
5356 ++pIcons_LOD->uTexturePacksCount;
5357 v1 = _this;
5358 if ( !pIcons_LOD->uNumPrevLoadedFiles )
5359 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
5360 pEventTimer->Pause();
5361 pAudioPlayer->StopChannels(-1, -1);
5362 bRingsShownInCharScreen = 0;
5363 CharacterUI_LoadPaperdollTextures();
5364 pCurrentScreen = v1;
5365 v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
5366 pCharacterScreen_StatsBtn = v2->CreateButton(
5367 pViewport->uViewportX + 12,
5368 pViewport->uViewportY + 308,
5369 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
5370 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
5371 1,
5372 0,
5373 0x73u,
5374 0,
5375 0x53u,
5376 pGlobalTXT_LocalizationStrings[216],
5377 (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
5378 papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0,
5379 0);
5380 pCharacterScreen_SkillsBtn = v2->CreateButton(
5381 pViewport->uViewportX + 102,
5382 pViewport->uViewportY + 308,
5383 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
5384 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
5385 1,
5386 0,
5387 0x72u,
5388 0,
5389 0x4Bu,
5390 pGlobalTXT_LocalizationStrings[205],
5391 (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
5392 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0,
5393 0);
5394 pCharacterScreen_InventoryBtn = v2->CreateButton(
5395 pViewport->uViewportX + 192,
5396 pViewport->uViewportY + 308,
5397 (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
5398 (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
5399 1,
5400 0,
5401 0x74u,
5402 0,
5403 0x49u,
5404 pGlobalTXT_LocalizationStrings[120],
5405 (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
5406 papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0,
5407 0);
5408 pCharacterScreen_AwardsBtn = v2->CreateButton(
5409 pViewport->uViewportX + 282,
5410 pViewport->uViewportY + 308,
5411 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
5412 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
5413 1,
5414 0,
5415 0x75u,
5416 0,
5417 0x41u,
5418 pGlobalTXT_LocalizationStrings[22],
5419 (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
5420 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0,
5421 0);
5422 pCharacterScreen_ExitBtn = v2->CreateButton(
5423 pViewport->uViewportX + 371,
5424 pViewport->uViewportY + 308,
5425 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
5426 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
5427 1,
5428 0,
5429 0xA8u,
5430 0,
5431 0,
5432 pGlobalTXT_LocalizationStrings[79],
5433 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
5434 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
5435 0);
5436 v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
5437 pCharacterScreen_DetalizBtn = v2->CreateButton(
5438 0x258u,
5439 0x12Cu,
5440 0x1Eu,
5441 0x1Eu,
5442 1,
5443 0,
5444 0x55u,
5445 0,
5446 0,
5447 pGlobalTXT_LocalizationStrings[64],
5448 0);
5449 pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
5450 v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
5451 v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
5452 v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
5453 v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
5454 v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
5455 sub_419100();
5456 return v2;
5457 }
5458
5459
5460
5461 //----- (004219BE) --------------------------------------------------------
5462 GUIWindow *stru277::sub_4219BE()
5463 {
5464 int v1; // esi@1
5465 GUIWindow *v2; // ebx@1
5466
5467 auto a4 = this;
5468 v1 = (int)a4;
5469 pEventTimer->Pause();
5470 pAudioPlayer->StopChannels(-1, -1);
5471 bRingsShownInCharScreen = 0;
5472 CharacterUI_LoadPaperdollTextures();
5473 pCurrentScreen = 23;
5474 v2 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|WINDOW_Options), v1, 0);
5475 pCharacterScreen_ExitBtn = v2->CreateButton(
5476 394u,
5477 318u,
5478 75u,
5479 33u,
5480 1,
5481 0,
5482 0xA8u,
5483 0,
5484 0,
5485 pGlobalTXT_LocalizationStrings[79],
5486 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
5487 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
5488 0);
5489 v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
5490 pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
5491 v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
5492 v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
5493 v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
5494 v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
5495 return v2;
5496 }
5497
5498
5499 //----- (00421B2C) --------------------------------------------------------
5500 bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem()
5501 {
5502 unsigned int v0; // eax@2
5503 Texture *v1; // ebx@2
5504 int v2; // eax@3
5505 Player *v3; // esi@5
5506 int v4; // eax@6
5507 unsigned __int16 v5; // dx@11
5508 signed int v6; // eax@11
5509 char *v7; // edi@12
5510 __int16 v8; // ax@16
5511 LayingItem a1; // [sp+4h] [bp-78h]@11
5512 int v11; // [sp+74h] [bp-8h]@2
5513 int v12; // [sp+78h] [bp-4h]@5
5514
5515 if ( !pParty->pPickedItem.uItemID )
5516 return 1;
5517 v0 = pIcons_LOD->LoadTexture(
5518 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
5519 TEXTURE_16BIT_PALETTE);
5520 v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0);
5521 v11 = areWeLoadingTexture;
5522 if ( uActiveCharacter
5523 && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
5524 {
5525 memcpy(&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u);
5526 }
5527 else
5528 {
5529 v12 = 0;
5530 v3 = pParty->pPlayers;
5531 while ( 1 )
5532 {
5533 v4 = v3->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID);
5534 if ( v4 )
5535 break;
5536 ++v12;
5537 ++v3;
5538 if ( (signed int)v3 >= (signed int)pParty->pHirelings )
5539 goto LABEL_10;
5540 }
5541 memcpy(&pParty->pPlayers[v12].spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4 + 5], &pParty->pPickedItem, 0x24u);
5542 pMouse->RemoveHoldingItem();
5543 LABEL_10:
5544 if ( v12 != 4 )
5545 goto LABEL_18;
5546 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
5547 v6 = 0;
5548 a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
5549 if ( (signed int)pObjectList->uNumObjects <= 0 )
5550 {
5551 LABEL_15:
5552 LOWORD(v6) = 0;
5553 }
5554 else
5555 {
5556 v7 = (char *)&pObjectList->pObjects->uObjectID;
5557 while ( v5 != *(short *)v7 )
5558 {
5559 ++v6;
5560 v7 += 56;
5561 if ( v6 >= (signed int)pObjectList->uNumObjects )
5562 goto LABEL_15;
5563 }
5564 }
5565 a1.field_58 = 4;
5566 a1.uObjectDescID = v6;
5567 a1.vPosition.y = pParty->vPosition.y;
5568 a1.vPosition.x = pParty->vPosition.x;
5569 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
5570 a1.uSoundID = 0;
5571 a1.uFacing = 0;
5572 a1.uAttributes = 8;
5573 v8 = pIndoor->GetSector(
5574 pParty->vPosition.x,
5575 pParty->vPosition.y,
5576 pParty->sEyelevel + pParty->vPosition.z);
5577 a1.uSpriteFrameID = 0;
5578 a1.uSectorID = v8;
5579 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
5580 a1.Create(pParty->sRotationY, 184, 200, 0);
5581 }
5582 pMouse->RemoveHoldingItem();
5583 LABEL_18:
5584 if ( !v11 )
5585 {
5586 v1->Release();
5587 pIcons_LOD->_40F9C5();
5588 }
5589 return 1;
5590 }
5591
5592
5593 //----- (00421D00) --------------------------------------------------------
5594 void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID)
5595 {
5596 unsigned int v1; // esi@1
5597 int v2; // eax@2
5598 Player *v3; // ecx@2
5599 Player *v4; // ecx@5
5600 unsigned int v5; // [sp-4h] [bp-10h]@21
5601
5602 v1 = uPlayerID;
5603 if ( pParty->pPickedItem.uItemID )
5604 {
5605 v2 = pPlayers[uPlayerID]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID);
5606 v3 = pPlayers[v1];
5607 if ( v2 )
5608 {
5609 memcpy(&v3->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u);
5610 viewparams->bRedrawGameUI = 1;
5611 pMouse->RemoveHoldingItem();
5612 return;
5613 }
5614 if ( v3->CanAct() )
5615 {
5616 v4 = pPlayers[v1];
5617 }
5618 else
5619 {
5620 if ( !pPlayers[uActiveCharacter]->CanAct() )
5621 goto LABEL_9;
5622 v4 = pPlayers[uActiveCharacter];
5623 }
5624 v4->PlaySound(15, 0);
5625 }
5626 LABEL_9:
5627 if ( !pCurrentScreen )
5628 {
5629 viewparams->bRedrawGameUI = 1;
5630 if ( uActiveCharacter != v1 )
5631 goto LABEL_27;
5632 v5 = 7;
5633 LABEL_22:
5634 pGUIWindow_CurrentMenu = GameUI_InitializeCharacterWindow(v5);
5635 return;
5636 }
5637 if ( pCurrentScreen == 8 )
5638 return;
5639 if ( pCurrentScreen == 10 )
5640 {
5641 LABEL_23:
5642 viewparams->bRedrawGameUI = 1;
5643 if ( uActiveCharacter == v1 )
5644 {
5645 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
5646 pCurrentScreen = 15;
5647 goto LABEL_28;
5648 }
5649 LABEL_27:
5650 if ( pPlayers[v1]->uTimeToRecovery )
5651 return;
5652 goto LABEL_28;
5653 }
5654 if ( pCurrentScreen != 13 )
5655 {
5656 if ( pCurrentScreen == 14 )
5657 {
5658 LABEL_28:
5659 uActiveCharacter = v1;
5660 return;
5661 }
5662 if ( pCurrentScreen != 15 )
5663 {
5664 viewparams->bRedrawGameUI = 1;
5665 uActiveCharacter = v1;
5666 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 )
5667 sub_419100();
5668 return;
5669 }
5670 goto LABEL_23;
5671 }
5672 if ( ptr_507BC0->field_40 == 1 )
5673 return;
5674 viewparams->bRedrawGameUI = 1;
5675 if ( uActiveCharacter != v1 )
5676 goto LABEL_28;
5677 if ( dword_F8B19C == 2 || dword_F8B19C == 6 )
5678 {
5679 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
5680 v5 = 14;
5681 goto LABEL_22;
5682 }
5683 }
5684 // 4E28F8: using guessed type int pCurrentScreen;
5685 // F8B19C: using guessed type int dword_F8B19C;
5686
5687 //----- (00421EA6) --------------------------------------------------------
5688 void __cdecl sub_421EA6_OnInventoryLeftClick()
5689 {
5690 Player *v0; // ebx@1
5691 signed int v1; // eax@2
5692 signed int v2; // ecx@2
5693 int v3; // eax@2
5694 char v4; // sf@2
5695 int v5; // eax@2
5696 unsigned int v6; // eax@7
5697 unsigned int v7; // esi@12
5698 unsigned int v8; // eax@12
5699 unsigned int v9; // eax@16
5700 unsigned int v10; // eax@18
5701 ItemGen this_; // [sp+Ch] [bp-3Ch]@1
5702 POINT a2; // [sp+30h] [bp-18h]@4
5703 unsigned int v13; // [sp+38h] [bp-10h]@13
5704 unsigned int pY; // [sp+3Ch] [bp-Ch]@2
5705 unsigned int pX; // [sp+40h] [bp-8h]@2
5706 int a4; // [sp+44h] [bp-4h]@2
5707
5708 v0 = pPlayers[uActiveCharacter];
5709 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103
5710 || (pMouse->GetClickPos(&pX, &pY),
5711 v1 = pY - 17,
5712 v2 = pX - 14,
5713 pY = v1,
5714 pX = v2,
5715 v3 = 14 * (v1 >> 5),
5716 v2 >>= 5,
5717 v4 = v2 + v3 < 0,
5718 v5 = v2 + v3,
5719 a4 = v5,
5720 v4)
5721 || v5 > 126
5722 || pMouse->GetCursorPos(&a2)->x >= 462
5723 || pMouse->GetCursorPos(&a2)->x < 14 )
5724 return;
5725 if ( unk_50C9A0 )
5726 {
5727 v6 = v0->GetItemIDAtInventoryIndex(&a4);
5728 if ( v6 )
5729 {
5730 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
5731 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
5732 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
5733 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
5734 ptr_50C9A4 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5];
5735 unk_50C9A0 = 0;
5736 if ( pMessageQueue_50CBD0->uNumMessages )
5737 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5738 pMouse->SetCursorBitmap("MICON1");
5739 dword_50C9D0 = 113;
5740 dword_50C9D4 = 0;
5741 dword_50C9D8 = 256;
5742 }
5743 return;
5744 }
5745 if ( ptr_50C9A4 )
5746 return;
5747 v7 = pParty->pPickedItem.uItemID;
5748 v8 = v0->GetItemIDAtInventoryIndex(&a4);
5749 if ( !v7 )
5750 {
5751 if ( !v8 )
5752 return;
5753 memcpy(&pParty->pPickedItem, &v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5], sizeof(pParty->pPickedItem));
5754 v0->RemoveItemAtInventoryIndex(a4);
5755 v9 = pParty->pPickedItem.uItemID;
5756 goto LABEL_24;
5757 }
5758 v13 = v8;
5759 if ( v8 )
5760 {
5761 a2.y = (LONG)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
5762 memcpy(&this_, (const void *)a2.y, sizeof(this_));
5763 v0->RemoveItemAtInventoryIndex(a4);
5764 pX = v0->AddItem2(a4, &pParty->pPickedItem);
5765 if ( !pX )
5766 {
5767 pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem);
5768 if ( !pX )
5769 {
5770 v0->_49298B(&this_, v13 - 1, a4);
5771 memcpy((void *)a2.y, &this_, sizeof(ItemGen));
5772 return;
5773 }
5774 }
5775 v9 = this_.uItemID;
5776 memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
5777 LABEL_24:
5778 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
5779 return;
5780 }
5781 v10 = v0->AddItem(a4, v7);
5782 pX = v10;
5783 if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
5784 {
5785 memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], &pParty->pPickedItem, 0x24u);
5786 pMouse->RemoveHoldingItem();
5787 }
5788 }
5789
5790
5791 //----- (0042213C) --------------------------------------------------------
5792 void __cdecl OnGameViewportClick()
5793 {
5794 signed int v0; // ebx@2
5795 POINT *v1; // esi@3
5796 signed int v2; // eax@9
5797 BLVFace *v3; // eax@10
5798 unsigned int v4; // eax@11
5799 unsigned __int16 v5; // dx@14
5800 signed int v6; // eax@14
5801 char *v7; // esi@15
5802 int *v8; // eax@19
5803 int v9; // eax@19
5804 unsigned int v10; // eax@19
5805 int v11; // ecx@21
5806 ODMFace *v12; // eax@22
5807 LevelDecoration *v13; // esi@24
5808 __int16 v14; // ax@25
5809 int v15; // ecx@29
5810 signed int v16; // edx@30
5811 Actor *v17; // esi@30
5812 int v18; // ebx@47
5813 unsigned __int16 v19; // ax@50
5814 const char *v20; // eax@51
5815 signed int v21; // eax@58
5816 ItemGen *v22; // esi@62
5817 unsigned int v23; // eax@62
5818 LayingItem a1; // [sp+Ch] [bp-80h]@1
5819 POINT v25; // [sp+7Ch] [bp-10h]@3
5820 POINT a2; // [sp+84h] [bp-8h]@3
5821
5822 if ( pRenderer->pRenderD3D )
5823 {
5824 v0 = pGame->pVisInstance->get_picked_object_zbuf_val();
5825 }
5826 else
5827 {
5828 v1 = pMouse->GetCursorPos(&a2);
5829 v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]];
5830 }
5831 if ( (v0 & 7) == 2 )
5832 {
5833 a2.y = (signed int)(unsigned __int16)v0 >> 3;
5834 v21 = (signed int)(unsigned __int16)v0 >> 3;
5835 if ( !(pObjectList->pObjects[pLayingItems[v21].uObjectDescID].uFlags & 0x10)
5836 && a2.y < 1000
5837 && pLayingItems[v21].uObjectDescID
5838 && (unsigned int)v0 < 0x2000000 )
5839 {
5840 v22 = &pLayingItems[v21].stru_24;
5841 v23 = pLayingItems[v21].stru_24.uItemID;
5842 if ( pItemsTable->pItems[v23].uEquipType == 18 )
5843 {
5844 party_finds_gold(v22->uAdditionalValue, 0);
5845 viewparams->bRedrawGameUI = 1;
5846 }
5847 else
5848 {
5849 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName);
5850 ShowStatusBarString(pTmpBuf2, 2u);
5851 if ( v22->uItemID == 506 )
5852 _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
5853 if ( v22->uItemID == 455 )
5854 _449B7E_toggle_bit(pParty->_award_bits, 185, 1u);
5855 if ( !pParty->AddItem(v22) )
5856 pParty->SetHoldingItem(v22);
5857 }
5858 LayingItem::_42F933(a2.y);
5859 return;
5860 }
5861 goto LABEL_13;
5862 }
5863 if ( (v0 & 7) != 3 )
5864 {
5865 if ( (v0 & 7) == 5 )
5866 {
5867 v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
5868 if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 )
5869 goto LABEL_13;
5870 v14 = v13->field_16_event_id;
5871 if ( !v14 )
5872 {
5873 if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() )
5874 {
5875 v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380;
5876 _5C3420_pDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
5877 EventProcessor(v15, 0, 1);
5878 _5C3420_pDecoration = 0;
5879 }
5880 return;
5881 }
5882 v11 = v14;
5883 }
5884 else
5885 {
5886 if ( (v0 & 7) != 6 || (unsigned int)v0 >= 0x2000000 )
5887 goto LABEL_13;
5888 v2 = (signed int)(unsigned __int16)v0 >> 3;
5889 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
5890 {
5891 v3 = &pIndoor->pFaces[v2];
5892 if ( !(v3->uAttributes & 0x2000000) )
5893 {
5894 LABEL_11:
5895 v4 = pParty->pPickedItem.uItemID;
5896 if ( pParty->pPickedItem.uItemID )
5897 {
5898 LABEL_14:
5899 v5 = pItemsTable->pItems[v4].uSpriteID;
5900 v6 = 0;
5901 a1.uItemType = v5;
5902 if ( (signed int)pObjectList->uNumObjects <= 0 )
5903 {
5904 LABEL_18:
5905 LOWORD(v6) = 0;
5906 }
5907 else
5908 {
5909 v7 = (char *)&pObjectList->pObjects->uObjectID;
5910 while ( v5 != *(short *)v7 )
5911 {
5912 ++v6;
5913 v7 += 56;
5914 if ( v6 >= (signed int)pObjectList->uNumObjects )
5915 goto LABEL_18;
5916 }
5917 }
5918 a1.uObjectDescID = v6;
5919 a1.vPosition.y = pParty->vPosition.y;
5920 a1.field_58 = 4;
5921 a1.vPosition.x = pParty->vPosition.x;
5922 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
5923 a1.uSoundID = 0;
5924 a1.uFacing = 0;
5925 a1.uAttributes = 8;
5926 a1.uSectorID = pIndoor->GetSector(
5927 pParty->vPosition.x,
5928 pParty->vPosition.y,
5929 pParty->sEyelevel + pParty->vPosition.z);
5930 a1.uSpriteFrameID = 0;
5931 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
5932 v8 = (int *)pMouse->GetCursorPos(&v25);
5933 v9 = UnprojectX(*v8);
5934 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
5935 v10 = pIcons_LOD->LoadTexture(
5936 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
5937 TEXTURE_16BIT_PALETTE);
5938 if (v10 != -1)
5939 pIcons_LOD->pTextures[v10].Release();
5940 pMouse->RemoveHoldingItem();
5941 pIcons_LOD->_40F9C5();
5942 return;
5943 }
5944 ShowNothingHereStatus();
5945 LABEL_13:
5946 v4 = pParty->pPickedItem.uItemID;
5947 if ( !pParty->pPickedItem.uItemID )
5948 return;
5949 goto LABEL_14;
5950 }
5951 v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID;
5952 }
5953 else
5954 {
5955 v12 = &pOutdoor->pBModels[(signed int)(unsigned __int16)v0 >> 9].pFaces[v2 & 0x3F];
5956 if ( !(v12->uAttributes & 0x2000000) )
5957 goto LABEL_11;
5958 v11 = v12->sCogTriggeredID;
5959 }
5960 }
5961 EventProcessor(v11, (unsigned __int16)v0, 1);
5962 return;
5963 }
5964 v16 = (signed int)(unsigned __int16)v0 >> 3;
5965 a2.y = v16;
5966 v17 = &pActors[v16];
5967 if ( v17->uAIState == 5 )
5968 {
5969 if ( (unsigned int)v0 < 0x2000000 )
5970 {
5971 stru_50C198.LootActor(&pActors[v16]);
5972 return;
5973 }
5974 goto LABEL_13;
5975 }
5976 if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
5977 {
5978 if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) )
5979 {
5980 if ( (unsigned int)v0 >= 0x2000000 )
5981 goto LABEL_13;
5982 if ( !v17->CanAct() )
5983 return;
5984 v18 = a2.y;
5985 Actor::FaceObject(a2.y, 4u, 0, 0);
5986 if ( !v17->uNPC_ID )
5987 {
5988 v19 = pNPCStats->pGroups_copy[v17->uGroup];
5989 if ( v19 )
5990 {
5991 v20 = pNPCStats->pCatchPhrases[v19];
5992 if ( v20 )
5993 {
5994 pParty->uFlags |= 2u;
5995 strcpy(byte_5B0938, v20);
5996 sub_4451A8_press_any_key(0, 0, 0);
5997 }
5998 }
5999 return;
6000 }
6001 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
6002 return;
6003 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)161;
6004 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18;
6005 LABEL_42:
6006 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
6007 ++pMessageQueue_50CBD0->uNumMessages;
6008 return;
6009 }
6010 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
6011 {
6012 pTurnEngine->field_18 |= 8u;
6013 return;
6014 }
6015 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
6016 {
6017 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)23;
6018 goto LABEL_41;
6019 }
6020 }
6021 else
6022 {
6023 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
6024 {
6025 pParty->uFlags |= 8u;
6026 return;
6027 }
6028 if ( uActiveCharacter
6029 && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)
6030 && (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
6031 {
6032 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)25;
6033 LABEL_41:
6034 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
6035 goto LABEL_42;
6036 }
6037 }
6038 }
6039
6040 //----- (004226C2) --------------------------------------------------------
6041 bool __cdecl sub_4226C2()
6042 {
6043 if ( pCurrentScreen
6044 && pCurrentScreen != 4
6045 && pCurrentScreen != 17 )
6046 {
6047 if ( pCurrentScreen == 18 )
6048 return pVideoPlayer->pSmackerMovie != 0;
6049 if ( pCurrentScreen != 19 )
6050 return 1;
6051 }
6052 return 0;
6053 }
6054 // 4E28F8: using guessed type int pCurrentScreen;
6055
6056 //----- (004226EF) --------------------------------------------------------
6057 void __fastcall SetUserInterface(int a1, bool bReplace)
6058 {
6059 int v2; // ecx@2
6060 unsigned int v3; // eax@7
6061 unsigned __int16 v4; // dx@7
6062 unsigned __int16 v5; // cx@7
6063 unsigned __int16 v6; // [sp-4h] [bp-14h]@7
6064
6065 if ( a1 )
6066 {
6067 v2 = a1 - 1;
6068 if ( v2 )
6069 {
6070 if ( v2 != 1 )
6071 return;
6072 if ( bReplace )
6073 {
6074 pTexture_RightFrame->Reload("ib-r-C.pcx");
6075 pTexture_BottomFrame->Reload("ib-b-C.pcx");
6076 pTexture_TopFrame->Reload("ib-t-C.pcx");
6077 pTexture_LeftFrame->Reload("ib-l-C.pcx");
6078 pTexture_StatusBar->Reload("IB-Foot-c.pcx");
6079 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-C", 2);
6080 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-c", 2);
6081 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-C", 2);
6082 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-c", 2);
6083 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-c", 2);
6084 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-c", 2);
6085 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507990], "IB-NPCLD-C", 2);
6086 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50798C], "IB-NPCRD-C", 2);
6087 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507980], "ib-autout-C", 2);
6088 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507984], "ib-autin-C", 2);
6089 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50C98C], "IB-selec-C", 2);
6090 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50797C], "ib-m1d-c", 2);
6091 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507978], "ib-m2d-c", 2);
6092 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507974], "ib-m3d-c", 2);
6093 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507970], "ib-m4d-c", 2);
6094 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50796C], "isg-01-c", 2);
6095 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507968], "isg-02-c", 2);
6096 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507964], "isg-03-c", 2);
6097 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507960], "isg-04-c", 2);
6098 pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeC");
6099 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
6100 pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
6101 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
6102 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-c", 2);
6103 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2);
6104 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2);
6105 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
6106 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-c", 2);
6107 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-c", 2);
6108 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul-c", 2);
6109 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur-c", 2);
6110 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm-c", 2);
6111 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf-c", 2);
6112 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt-c", 2);
6113 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-c", 2);
6114 pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-c", 2);
6115 }
6116 else
6117 {
6118 pTexture_RightFrame->Load("ib-r-C.pcx", 0);
6119 pTexture_BottomFrame->Load("ib-b-c.pcx", 0);
6120 pTexture_TopFrame->Load("ib-t-C.pcx", 0);
6121 pTexture_LeftFrame->Load("ib-l-C.pcx", 0);
6122 pTexture_StatusBar->Load("IB-Foot-c.pcx", 0);
6123 uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-C", TEXTURE_16BIT_PALETTE);
6124 dword_5079D8 = pIcons_LOD->LoadTexture("ib-autmask-c", TEXTURE_16BIT_PALETTE);
6125 dword_5079B4 = pIcons_LOD->LoadTexture("IB-COMP-C", TEXTURE_16BIT_PALETTE);
6126 dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-c", TEXTURE_16BIT_PALETTE);
6127 dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-c", TEXTURE_16BIT_PALETTE);
6128 dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-c", TEXTURE_16BIT_PALETTE);
6129 uTextureID_507990 = pIcons_LOD->LoadTexture("IB-NPCLD-C", TEXTURE_16BIT_PALETTE);
6130 uTextureID_50798C = pIcons_LOD->LoadTexture("IB-NPCRD-C", TEXTURE_16BIT_PALETTE);
6131 uTextureID_507980 = pIcons_LOD->LoadTexture("ib-autout-C", TEXTURE_16BIT_PALETTE);
6132 uTextureID_507984 = pIcons_LOD->LoadTexture("ib-autin-C", TEXTURE_16BIT_PALETTE);
6133 dword_50C98C = pIcons_LOD->LoadTexture("IB-selec-C", TEXTURE_16BIT_PALETTE);
6134 uTextureID_50797C = pIcons_LOD->LoadTexture("ib-m1d-c", TEXTURE_16BIT_PALETTE);
6135 uTextureID_507978 = pIcons_LOD->LoadTexture("ib-m2d-c", TEXTURE_16BIT_PALETTE);
6136 dword_507974 = pIcons_LOD->LoadTexture("ib-m3d-c", TEXTURE_16BIT_PALETTE);
6137 uTextureID_507970 = pIcons_LOD->LoadTexture("ib-m4d-c", TEXTURE_16BIT_PALETTE);
6138 uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE);
6139 dword_50796C = pIcons_LOD->LoadTexture("isg-01-c", TEXTURE_16BIT_PALETTE);
6140 dword_507968 = pIcons_LOD->LoadTexture("isg-02-c", TEXTURE_16BIT_PALETTE);
6141 dword_507964 = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE);
6142 dword_507960 = pIcons_LOD->LoadTexture("isg-04-c", TEXTURE_16BIT_PALETTE);
6143 uTextureID_50795C = pIcons_LOD->LoadTexture("evtnpc-c", TEXTURE_16BIT_PALETTE);
6144 uTextureID_507958 = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
6145 pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeC");
6146 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
6147 pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
6148 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
6149 }
6150 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xC8u, 0, 0);
6151 v4 = 0;
6152 v6 = 0;
6153 v5 = 10;
6154 }
6155 else
6156 {
6157 if ( bReplace )
6158 {
6159 pTexture_RightFrame->Reload("ib-r-a.pcx");
6160 pTexture_BottomFrame->Reload("ib-b-a.pcx");
6161 pTexture_TopFrame->Reload("ib-t-a.pcx");
6162 pTexture_LeftFrame->Reload("ib-l-a.pcx");
6163 pTexture_StatusBar->Reload("IB-Foot-a.pcx");
6164 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-a", 2);
6165 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-a", 2);
6166 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-a", 2);
6167 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-a", 2);
6168 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-a", 2);
6169 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-a", 2);
6170 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507990], "IB-NPCLD-a", 2);
6171 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50798C], "IB-NPCRD-a", 2);
6172 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507980], "ib-autout-a", 2);
6173 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507984], "ib-autin-a", 2);
6174 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50C98C], "IB-selec-a", 2);
6175 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50797C], "ib-m1d-a", 2);
6176 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507978], "ib-m2d-a", 2);
6177 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507974], "ib-m3d-a", 2);
6178 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507970], "ib-m4d-a", 2);
6179 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50796C], "isg-01-a", 2);
6180 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507968], "isg-02-a", 2);
6181 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507964], "isg-03-a", 2);
6182 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507960], "isg-04-a", 2);
6183 pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeA");
6184 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
6185 pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
6186 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
6187 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-a", 2);
6188 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2);
6189 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2);
6190 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
6191 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll", 2);
6192 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr", 2);
6193 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul", 2);
6194 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur", 2);
6195 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm", 2);
6196 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf", 2);
6197 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt", 2);
6198 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top", 2);
6199 pIcons_LOD->ReloadTexture(pTexture_591428, "endcap", 2);
6200 }
6201 else
6202 {
6203 pTexture_RightFrame->Load("ib-r-A.pcx", 0);
6204 pTexture_BottomFrame->Load("ib-b-A.pcx", 0);
6205 pTexture_TopFrame->Load("ib-t-A.pcx", 0);
6206 pTexture_LeftFrame->Load("ib-l-A.pcx", 0);
6207 pTexture_StatusBar->Load("IB-Foot-a.pcx", 0);
6208 uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-A", TEXTURE_16BIT_PALETTE);
6209 dword_5079D8 = pIcons_LOD->LoadTexture("ib-autmask-a", TEXTURE_16BIT_PALETTE);
6210 dword_5079B4 = pIcons_LOD->LoadTexture("IB-COMP-A", TEXTURE_16BIT_PALETTE);
6211 dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-a", TEXTURE_16BIT_PALETTE);
6212 dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-a", TEXTURE_16BIT_PALETTE);
6213 dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-a", TEXTURE_16BIT_PALETTE);
6214 uTextureID_507990 = pIcons_LOD->LoadTexture("IB-NPCLD-A", TEXTURE_16BIT_PALETTE);
6215 uTextureID_50798C = pIcons_LOD->LoadTexture("IB-NPCRD-A", TEXTURE_16BIT_PALETTE);
6216 dword_50C98C = pIcons_LOD->LoadTexture("IB-selec-A", TEXTURE_16BIT_PALETTE);
6217 uTextureID_50797C = pIcons_LOD->LoadTexture("ib-m1d-a", TEXTURE_16BIT_PALETTE);
6218 uTextureID_507978 = pIcons_LOD->LoadTexture("ib-m2d-a", TEXTURE_16BIT_PALETTE);
6219 dword_507974 = pIcons_LOD->LoadTexture("ib-m3d-a", TEXTURE_16BIT_PALETTE);
6220 uTextureID_507970 = pIcons_LOD->LoadTexture("ib-m4d-a", TEXTURE_16BIT_PALETTE);
6221 uTextureID_507980 = pIcons_LOD->LoadTexture("ib-autout-a", TEXTURE_16BIT_PALETTE);
6222 uTextureID_507984 = pIcons_LOD->LoadTexture("ib-autin-a", TEXTURE_16BIT_PALETTE);
6223 uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE);
6224 dword_50796C = pIcons_LOD->LoadTexture("isg-01-a", TEXTURE_16BIT_PALETTE);
6225 dword_507968 = pIcons_LOD->LoadTexture("isg-02-a", TEXTURE_16BIT_PALETTE);
6226 dword_507964 = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE);
6227 dword_507960 = pIcons_LOD->LoadTexture("isg-04-a", TEXTURE_16BIT_PALETTE);
6228 uTextureID_50795C = pIcons_LOD->LoadTexture("evtnpc", TEXTURE_16BIT_PALETTE);
6229 uTextureID_507958 = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
6230 pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeA");
6231 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
6232 pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
6233 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
6234 uTextureID_Parchment = pIcons_LOD->LoadTexture("parchment", TEXTURE_16BIT_PALETTE);
6235 uTextureID_5076B4 = pIcons_LOD->LoadTexture("cornr_ll", TEXTURE_16BIT_PALETTE);
6236 uTextureID_5076B0 = pIcons_LOD->LoadTexture("cornr_lr", TEXTURE_16BIT_PALETTE);
6237 uTextureID_5076AC = pIcons_LOD->LoadTexture("cornr_ul", TEXTURE_16BIT_PALETTE);
6238 uTextureID_5076A8 = pIcons_LOD->LoadTexture("cornr_ur", TEXTURE_16BIT_PALETTE);
6239 uTextureID_5076A4 = pIcons_LOD->LoadTexture("edge_btm", TEXTURE_16BIT_PALETTE);
6240 uTextureID_5076A0 = pIcons_LOD->LoadTexture("edge_lf", TEXTURE_16BIT_PALETTE);
6241 uTextureID_50769C = pIcons_LOD->LoadTexture("edge_rt", TEXTURE_16BIT_PALETTE);
6242 uTextureID_507698 = pIcons_LOD->LoadTexture("edge_top", TEXTURE_16BIT_PALETTE);
6243 pTexture_591428 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("endcap", TEXTURE_16BIT_PALETTE)];
6244
6245 }
6246 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
6247 v4 = 214;
6248 v5 = 230;
6249 v6 = 193;
6250 }
6251 }
6252 else
6253 {
6254 if ( bReplace )
6255 {
6256 pTexture_RightFrame->Reload("ib-r-B.pcx");
6257 pTexture_BottomFrame->Reload("ib-b-B.pcx");
6258 pTexture_TopFrame->Reload("ib-t-B.pcx");
6259 pTexture_LeftFrame->Reload("ib-l-B.pcx");
6260 pTexture_StatusBar->Reload("IB-Foot-b.pcx");
6261 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-B", 2);
6262 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-b", 2);
6263 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-B", 2);
6264 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-b", 2);
6265 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-b", 2);
6266 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-b", 2);
6267 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507990], "IB-NPCLD-B", 2);
6268 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50798C], "IB-NPCRD-B", 2);
6269 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507980], "ib-autout-B", 2);
6270 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507984], "ib-autin-B", 2);
6271 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50C98C], "IB-selec-B", 2);
6272 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50797C], "ib-m1d-b", 2);
6273 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507978], "ib-m2d-b", 2);
6274 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507974], "ib-m3d-b", 2);
6275 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507970], "ib-m4d-b", 2);
6276 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_50796C], "isg-01-b", 2);
6277 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507968], "isg-02-b", 2);
6278 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507964], "isg-03-b", 2);
6279 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_507960], "isg-04-b", 2);
6280 pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeB");
6281 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
6282 pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchB");
6283 pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
6284 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-b", 2);
6285 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2);
6286 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2);
6287 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
6288 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-b", 2);
6289 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-b", 2);
6290 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul-b", 2);
6291 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur-b", 2);
6292 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm-b", 2);
6293 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf-b", 2);
6294 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt-b", 2);
6295 pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-b", 2);
6296 pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-b", 2);
6297 }
6298 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xC8u);
6299 v5 = 255;
6300 v4 = 225;
6301 v6 = 255;
6302 }
6303 uGameUIFontMain = v3;
6304 uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
6305 }
6306
6307
6308
6309 //----- (00423AEE) --------------------------------------------------------
6310 void __cdecl reset_some_strus_flt_2Cs()
6311 {
6312 float *v0; // eax@1
6313 signed int v1; // ecx@1
6314 signed int v2; // edx@1
6315 float *v3; // eax@3
6316 signed int v4; // edx@3
6317 float *v5; // eax@5
6318 signed int v6; // edx@5
6319 float *v7; // eax@7
6320 signed int v8; // edx@7
6321 float *v9; // eax@9
6322
6323 v0 = &array_50AC10[0].flt_2C;
6324 v1 = 50;
6325 v2 = 50;
6326 do
6327 {
6328 *v0 = 0.0;
6329 v0 += 12;
6330 --v2;
6331 }
6332 while ( v2 );
6333 v3 = &array_50A2B0[0].flt_2C;
6334 v4 = 50;
6335 do
6336 {
6337 *v3 = 0.0;
6338 v3 += 12;
6339 --v4;
6340 }
6341 while ( v4 );
6342 v5 = &array_509950[0].flt_2C;
6343 v6 = 50;
6344 do
6345 {
6346 *v5 = 0.0;
6347 v5 += 12;
6348 --v6;
6349 }
6350 while ( v6 );
6351 v7 = &array_508FF0[0].flt_2C;
6352 v8 = 50;
6353 do
6354 {
6355 *v7 = 0.0;
6356 v7 += 12;
6357 --v8;
6358 }
6359 while ( v8 );
6360 v9 = &array_508690[0].flt_2C;
6361 do
6362 {
6363 *v9 = 0.0;
6364 v9 += 12;
6365 --v1;
6366 }
6367 while ( v1 );
6368 }
6369
6370 //----- (00423B4A) --------------------------------------------------------
6371 void __cdecl sub_423B4A()
6372 {
6373 float *v0; // eax@1
6374 signed int v1; // ecx@1
6375
6376 v0 = &array_507D30[0].flt_2C;
6377 v1 = 50;
6378 do
6379 {
6380 *v0 = 0.0;
6381 v0 += 12;
6382 --v1;
6383 }
6384 while ( v1 );
6385 }
6386
6387 //----- (00423B5D) --------------------------------------------------------
6388 int __fastcall sub_423B5D(unsigned int uFaceID)
6389 {
6390 BLVFace *v1; // ebx@1
6391 Vec3_short_ *v2; // esi@1
6392 //int v3; // ST28_4@1
6393 __int16 v4; // ST2C_2@1
6394 //signed int v5; // esi@1
6395 //Vec3_short_ *v6; // eax@4
6396 //signed int v7; // edi@5
6397 //signed int v8; // eax@5
6398 //signed int i_; // ecx@10
6399 int v10; // eax@10
6400 int v11; // edx@11
6401 int v12; // ST28_4@12
6402 signed int v13; // edx@12
6403 signed __int64 v14; // qtt@12
6404 int *v15; // ebx@12
6405 int v16; // ST28_4@14
6406 signed int v17; // eax@14
6407 signed __int64 v18; // qtt@14
6408 signed int v19; // edx@15
6409 signed int v20; // edx@17
6410 signed int v21; // ebx@19
6411 signed int v22; // esi@20
6412 int v23; // edi@21
6413 int v24; // eax@21
6414 int v25; // eax@22
6415 int v26; // eax@22
6416 signed int v27; // ST30_4@24
6417 signed __int64 v28; // qtt@24
6418 int v29; // ST18_4@25
6419 int v30; // eax@26
6420 int v31; // eax@27
6421 int v32; // eax@27
6422 signed int v33; // ST30_4@29
6423 signed __int64 v34; // qtt@29
6424 int v35; // ST30_4@30
6425 signed int v36; // edi@31
6426 unsigned int v37; // eax@31
6427 bool v38; // edx@31
6428 int v39; // ecx@31
6429 int v40; // ecx@32
6430 int v41; // esi@32
6431 int v42; // eax@34
6432 signed int v43; // ebx@41
6433 unsigned int v44; // eax@41
6434 signed int v45; // ecx@42
6435 int v46; // esi@42
6436 int v47; // eax@44
6437 signed int v48; // edi@51
6438 unsigned int v49; // eax@51
6439 bool v50; // edx@51
6440 int v51; // ecx@51
6441 int v52; // ecx@52
6442 signed int v53; // esi@52
6443 int v54; // eax@54
6444 int v55; // ebx@61
6445 unsigned int v56; // eax@61
6446 signed int v57; // ecx@62
6447 int v58; // esi@62
6448 int v59; // eax@64
6449 char v61; // zf@72
6450 signed int v62; // edx@75
6451 int v63; // ecx@76
6452 int v64; // esi@76
6453 int v65; // ecx@83
6454 //signed int v66; // [sp+14h] [bp-14h]@3
6455 int v67; // [sp+14h] [bp-14h]@34
6456 int v68; // [sp+14h] [bp-14h]@44
6457 int v69; // [sp+14h] [bp-14h]@54
6458 int v70; // [sp+14h] [bp-14h]@64
6459 signed int v71; // [sp+14h] [bp-14h]@75
6460 bool thisa; // [sp+18h] [bp-10h]@9
6461 int thisb; // [sp+18h] [bp-10h]@12
6462 int thisc; // [sp+18h] [bp-10h]@20
6463 bool thisd; // [sp+18h] [bp-10h]@41
6464 bool thise; // [sp+18h] [bp-10h]@61
6465 int thisf; // [sp+18h] [bp-10h]@74
6466 signed int v79; // [sp+1Ch] [bp-Ch]@9
6467 int v80; // [sp+1Ch] [bp-Ch]@76
6468 bool v81; // [sp+20h] [bp-8h]@10
6469 bool v82; // [sp+20h] [bp-8h]@32
6470 bool v83; // [sp+20h] [bp-8h]@42
6471 bool v84; // [sp+20h] [bp-8h]@52
6472 bool v85; // [sp+20h] [bp-8h]@62
6473 //signed int i; // [sp+24h] [bp-4h]@9
6474 signed int ia; // [sp+24h] [bp-4h]@19
6475 signed int ib; // [sp+24h] [bp-4h]@31
6476 signed int ic; // [sp+24h] [bp-4h]@41
6477 signed int id; // [sp+24h] [bp-4h]@51
6478 signed int ie; // [sp+24h] [bp-4h]@61
6479
6480 v1 = &pIndoor->pFaces[uFaceID];
6481 //this = pGame->pIndoorCameraD3D;
6482 v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
6483 //v3 = *(_DWORD *)&v2->x;
6484 v4 = v2->z;
6485 //v5 = 0;
6486 if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
6487 + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
6488 + v1->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
6489 {
6490 dword_50B700 = 1;
6491 }
6492 else
6493 {
6494 dword_50B700 = 0;
6495 if ( !(v1->uAttributes & 1) )
6496 return 0;
6497 }
6498 //v66 = v1->uNumVertices;
6499 for (uint i = 0; i < v1->uNumVertices; ++i)
6500 {
6501 auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
6502 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
6503 v6->x,
6504 v6->y,
6505 v6->z,
6506 &_50B924_view_transformed_xs[i],
6507 &_50B834_view_transformed_zs[i],
6508 &_50B744_view_transformed_ys[i],
6509 0);
6510 }
6511
6512 //v7 = v1->uNumVertices;
6513 //v8 = 0;
6514 if (v1->uNumVertices <= 0)
6515 return 0;
6516
6517 bool bFound = false;
6518 for (uint i = 0; i < v1->uNumVertices; ++i)
6519 if (_50B924_view_transformed_xs[i] >= 0x80000u)
6520 {
6521 bFound = true;
6522 break;
6523 }
6524 if (!bFound)
6525 return 0;
6526
6527 v79 = 0;
6528 _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
6529 _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
6530 _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
6531 thisa = _50B924_view_transformed_xs[0] >= 0x80000u;
6532 //int i = 1;
6533 for (uint i = 1; i < v1->uNumVertices; ++i)
6534 {
6535 v10 = _50B924_view_transformed_xs[i];
6536 v81 = v10 >= (signed int)0x80000u;
6537 if ( thisa ^ v81 )
6538 {
6539 v11 = _50B924_view_transformed_xs[i - 1];
6540 if ( v10 >= (signed int)0x80000u )
6541 {
6542 v12 = v10 - v11;
6543 v13 = 0x80000 - v11;
6544 LODWORD(v14) = v13 << 16;
6545 HIDWORD(v14) = v13 >> 16;
6546 v15 = &_50B744_view_transformed_ys[i - 1];
6547 dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1])
6548 * v14
6549 / v12) >> 16)
6550 + _50B834_view_transformed_zs[i - 1];
6551 thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
6552 }
6553 else
6554 {
6555 v16 = v11 - v10;
6556 v17 = 0x80000 - v10;
6557 LODWORD(v18) = v17 << 16;
6558 HIDWORD(v18) = v17 >> 16;
6559 v15 = &_50B744_view_transformed_ys[i];
6560 dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i])
6561 * v18
6562 / v16) >> 16)
6563 + _50B834_view_transformed_zs[i];
6564 thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
6565 }
6566 v19 = v79++;
6567 //v7 = v66;
6568 dword_50B738[v19] = thisb + *v15;
6569 dword_50B918[v19] = 0x80000u;
6570 }
6571 if ( v81 )
6572 {
6573 v20 = v79++;
6574 dword_50B918[v20] = _50B924_view_transformed_xs[i];
6575 dword_50B828[v20] = _50B834_view_transformed_zs[i];
6576 dword_50B738[v20] = _50B744_view_transformed_ys[i];
6577 }
6578 //++i;
6579 thisa = v81;
6580 }
6581 ia = 0;
6582 v21 = v79;
6583 dword_50B918[v79] = dword_50B918[0];
6584 dword_50B828[v79] = dword_50B828[0];
6585 for ( dword_50B738[v79] = dword_50B738[0]; ia < v79; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v35 )
6586 {
6587 v22 = ia;
6588 thisc = abs(dword_50B918[ia]);
6589 if ( abs(dword_50B828[ia]) >> 13 <= thisc )
6590 {
6591 v27 = dword_50B828[v22];
6592 LODWORD(v28) = v27 << 16;
6593 HIDWORD(v28) = v27 >> 16;
6594 v26 = v28 / dword_50B918[v22];
6595 v23 = 0;
6596 }
6597 else
6598 {
6599 v23 = 0;
6600 v24 = 0;
6601 if ( dword_50B828[v22] >= 0 )
6602 {
6603 LOBYTE(v24) = dword_50B918[v22] >= 0;
6604 v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
6605 }
6606 else
6607 {
6608 LOBYTE(v24) = dword_50B918[v22] >= 0;
6609 v25 = v24 - 1;
6610 v26 = (v25 & 0x800000) - 0x400000;
6611 }
6612 }
6613 v29 = dword_50B738[v22];
6614 dword_50BAF4_xs[v22 + 1] = v26;
6615 if ( abs(v29) >> 13 <= thisc )
6616 {
6617 v33 = dword_50B738[v22];
6618 LODWORD(v34) = v33 << 16;
6619 HIDWORD(v34) = v33 >> 16;
6620 v32 = v34 / dword_50B918[v22];
6621 }
6622 else
6623 {
6624 v30 = 0;
6625 if ( dword_50B738[v22] >= v23 )
6626 {
6627 LOBYTE(v30) = dword_50B918[v22] >= v23;
6628 v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
6629 }
6630 else
6631 {
6632 LOBYTE(v30) = dword_50B918[v22] >= v23;
6633 v31 = v30 - 1;
6634 v32 = (v31 & 0x800000) - 0x400000;
6635 }
6636 }
6637 dword_50BA08[v22] = v32;
6638 dword_50BAF4_xs[v22 + 1] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
6639 * (signed __int64)dword_50BAF4_xs[v22 + 1]) >> 16;
6640 v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
6641 dword_50BAF4_xs[v22 + 1] = pBLVRenderParams->uViewportCenterX - dword_50BAF4_xs[v22 + 1];
6642 ++ia;
6643 }
6644 v36 = 0;
6645 dword_50BAF4_xs[v21 + 1] = dword_50BAF4_xs[1];
6646 dword_50BA08[v21] = dword_50BA08[0];
6647 v37 = pBLVRenderParams->uViewportX;
6648 v38 = dword_50BAF4_xs[1] < (signed int)pBLVRenderParams->uViewportX;
6649 LOBYTE(v38) = dword_50BAF4_xs[1] >= (signed int)pBLVRenderParams->uViewportX;
6650 v39 = 1;
6651 ib = 1;
6652 if ( v79 < 1 )
6653 return 0;
6654 do
6655 {
6656 v40 = v39;
6657 v41 = dword_50BAF4_xs[v40 + 1];
6658 v82 = v41 >= (signed int)v37;
6659 if ( v38 ^ v82 )
6660 {
6661 if ( v41 >= (signed int)v37 )
6662 {
6663 v67 = (signed int)(v37 - dword_50BAF4_xs[v40])
6664 * (signed __int64)(dword_50BA08[v40] - dword_50B9F8[v40 + 3])
6665 / (v41 - dword_50BAF4_xs[v40]);
6666 v42 = dword_50B9F8[v40 + 3];
6667 }
6668 else
6669 {
6670 v67 = (signed int)(v37 - v41)
6671 * (signed __int64)(dword_50B9F8[v40 + 3] - dword_50BA08[v40])
6672 / (dword_50BAF4_xs[v40] - v41);
6673 v42 = dword_50BA08[v40];
6674 }
6675 ++v36;
6676 dword_50B9F8[v36] = v67 + v42;
6677 v37 = pBLVRenderParams->uViewportX;
6678 dword_50BAE8_xs[v36] = pBLVRenderParams->uViewportX;
6679 }
6680 v38 = v82;
6681 if ( v82 )
6682 {
6683 dword_50BAE8_xs[v36 + 1] = dword_50BAF4_xs[v40 + 1];
6684 dword_50B9F8[v36++ + 1] = dword_50BA08[v40];
6685 }
6686 v39 = ib++ + 1;
6687 }
6688 while ( ib <= v79 );
6689
6690 if ( !v36
6691 || (v43 = 0,
6692 dword_50BAE8_xs[v36 + 1] = dword_50BAE8_xs[1],
6693 dword_50B9F8[v36 + 1] = dword_50B9F8[1],
6694 v44 = pBLVRenderParams->uViewportZ,
6695 thisd = dword_50BAE8_xs[1] <= (signed int)pBLVRenderParams->uViewportZ,
6696 ic = 1,
6697 v36 < 1) )
6698 return 0;
6699
6700 do
6701 {
6702 v45 = ic;
6703 v46 = dword_50BAE8_xs[ic + 1];
6704 v83 = v46 <= (signed int)v44;
6705 if ( thisd ^ v83 )
6706 {
6707 if ( v46 <= (signed int)v44 )
6708 {
6709 v68 = (signed int)(v44 - dword_50BAE8_xs[v45])
6710 * (signed __int64)(dword_50B9F8[v45 + 1] - dword_50B9F8[v45])
6711 / (v46 - dword_50BAE8_xs[v45]);
6712 v47 = dword_50B9F8[v45];
6713 }
6714 else
6715 {
6716 v68 = (signed int)(v44 - v46)
6717 * (signed __int64)(dword_50B9F8[v45] - dword_50B9F8[v45 + 1])
6718 / (dword_50BAE8_xs[v45] - v46);
6719 v47 = dword_50B9F8[v45 + 1];
6720 }
6721 ++v43;
6722 dword_50B9EC[v43] = v68 + v47;
6723 v44 = pBLVRenderParams->uViewportZ;
6724 dword_50BADC_xs[v43] = pBLVRenderParams->uViewportZ;
6725 }
6726 if ( v83 )
6727 {
6728 dword_50BAE0[v43] = dword_50BAE8_xs[v45 + 1];
6729 dword_50B9F0[v43++] = dword_50B9F8[v45 + 1];
6730 }
6731 ++ic;
6732 thisd = v83;
6733 }
6734 while ( ic <= v36 );
6735 if ( !v43
6736 || (v48 = 0,
6737 dword_50BAE0[v43] = dword_50BAE0[0],
6738 dword_50B9F0[v43] = dword_50B9F0[0],
6739 v49 = pBLVRenderParams->uViewportY,
6740 v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY,
6741 LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY,
6742 v51 = 1,
6743 id = 1,
6744 v43 < 1) )
6745 return 0;
6746 do
6747 {
6748 v52 = v51;
6749 v53 = dword_50B9F0[v52];
6750 v84 = v53 >= (signed int)v49;
6751 if ( v50 ^ v84 )
6752 {
6753 if ( v53 >= (signed int)v49 )
6754 {
6755 v69 = (signed int)(v49 - dword_50B9EC[v52])
6756 * (signed __int64)(dword_50BAE0[v52] - dword_50BADC_xs[v52])
6757 / (v53 - dword_50B9EC[v52]);
6758 v54 = dword_50BADC_xs[v52];
6759 }
6760 else
6761 {
6762 v69 = (signed int)(v49 - v53)
6763 * (signed __int64)(dword_50BADC_xs[v52] - dword_50BAE0[v52])
6764 / (dword_50B9EC[v52] - v53);
6765 v54 = dword_50BAE0[v52];
6766 }
6767 ++v48;
6768 dword_50BAD0[v48] = v69 + v54;
6769 v49 = pBLVRenderParams->uViewportY;
6770 dword_50B9E0_ys[v48] = pBLVRenderParams->uViewportY;
6771 }
6772 v50 = v84;
6773 if ( v84 )
6774 {
6775 dword_50BAD4[v48] = dword_50BAE0[v52];
6776 dword_50B9E0_ys[v48++ + 1] = dword_50B9F0[v52];
6777 }
6778 v51 = id++ + 1;
6779 }
6780 while ( id <= v43 );
6781 if ( !v48
6782 || (v55 = 0,
6783 dword_50BAD4[v48] = dword_50BAD4[0],
6784 dword_50B9E0_ys[v48 + 1] = dword_50B9E0_ys[1],
6785 v56 = pBLVRenderParams->uViewportW,
6786 thise = dword_50B9E0_ys[1] <= (signed int)pBLVRenderParams->uViewportW,
6787 ie = 1,
6788 v48 < 1) )
6789 return 0;
6790 do
6791 {
6792 v57 = ie;
6793 v58 = dword_50B9E0_ys[ie + 1];
6794 v85 = v58 <= (signed int)v56;
6795 if ( thise ^ v85 )
6796 {
6797 if ( v58 <= (signed int)v56 )
6798 {
6799 v70 = (signed int)(v56 - dword_50B9E0_ys[v57])
6800 * (signed __int64)(dword_50BAD4[v57] - dword_50BAD0[v57])
6801 / (v58 - dword_50B9E0_ys[v57]);
6802 v59 = dword_50BAD0[v57];
6803 }
6804 else
6805 {
6806 v70 = (signed int)(v56 - v58)
6807 * (signed __int64)(dword_50BAD0[v57] - dword_50BAD4[v57])
6808 / (dword_50B9E0_ys[v57] - v58);
6809 v59 = dword_50BAD4[v57];
6810 }
6811 ++v55;
6812 dword_50BAC4[v55] = v70 + v59;
6813 v56 = pBLVRenderParams->uViewportW;
6814 unk_50B9D4[v55] = pBLVRenderParams->uViewportW;
6815 }
6816 if ( v85 )
6817 {
6818 dword_50BAC8[v55] = dword_50BAD4[v57];
6819 dword_50B9D8_ys[v55++] = dword_50B9E0_ys[v57 + 1];
6820 }
6821 ++ie;
6822 thise = v85;
6823 }
6824 while ( ie <= v48 );
6825 if ( !v55 )
6826 return 0;
6827 v61 = pRenderer->pRenderD3D == 0;
6828 dword_50BAC8[v55] = dword_50BAC8[0];
6829 dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
6830 if ( v61 && v55 > 3 )
6831 {
6832 dword_50BAC8[v55 + 1] = dword_50BAC8[1];
6833 dword_50B9D8_ys[v55 + 1] = dword_50B9D8_ys[1];
6834 thisf = 2 * (dword_50B700 != 0) - 1;
6835 if ( v55 > 0 )
6836 {
6837 v62 = 1;
6838 v71 = 1;
6839 do
6840 {
6841 v63 = v62 - 1;
6842 v64 = v62 + 1;
6843 v80 = v62 + 1;
6844 if ( v62 - 1 >= v55 )
6845 v63 -= v55;
6846 if ( v62 >= v55 )
6847 v62 -= v55;
6848 if ( v64 >= v55 )
6849 v64 -= v55;
6850 if ( thisf
6851 * ((dword_50B9D8_ys[v64] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v62] - dword_50BAC8[v63])
6852 - (dword_50B9D8_ys[v62] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v64] - dword_50BAC8[v63])) < 0 )
6853 {
6854 v62 = v80;
6855 v71 = v80;
6856 }
6857 else
6858 {
6859 v62 = v71;
6860 v65 = v71;
6861 if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
6862 {
6863 memcpy(&dword_50B9D8_ys[v65], &dword_50B9D8_ys[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
6864 memcpy(&dword_50BAC8[v65], &dword_50BAC8[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
6865 }
6866 --v55;
6867 }
6868 }
6869 while ( v62 - 1 < v55 );
6870 }
6871 dword_50BAC8[v55] = dword_50BAC8[0];
6872 dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
6873 }
6874 return v55;
6875 }
6876
6877
6878 //----- (00424579) --------------------------------------------------------
6879 int __fastcall sub_424579(int uFaceID, stru320 *a2)
6880 {
6881 __debugbreak();
6882 return 0;
6883 /*BLVFace *v2; // eax@1
6884 Vec3_short_ *v3; // ebx@1
6885 Vec3_short_ *v4; // esi@1
6886 unsigned int v5; // esi@3
6887 int v7; // ST1C_4@5
6888 int v8; // ST1C_4@5
6889 int v9; // ST1C_4@5
6890 int v10; // ST1C_4@5
6891 int v11; // esi@5
6892 int v12; // ST1C_4@5
6893 unsigned int v15; // ecx@8
6894 unsigned int v19; // ecx@13
6895 signed int v20; // ecx@16
6896 signed int result; // eax@20
6897 signed int v24; // edx@22
6898 unsigned int v25; // [sp+Ch] [bp-1Ch]@3
6899 float v26; // [sp+14h] [bp-14h]@3
6900 float v27; // [sp+1Ch] [bp-Ch]@3
6901 float v28; // [sp+20h] [bp-8h]@3
6902 signed int v29; // [sp+24h] [bp-4h]@3
6903
6904 v2 = &pIndoor->pFaces[uFaceID];
6905 v3 = pIndoor->pVertices;
6906 v4 = &pIndoor->pVertices[*v2->pVertexIDs];
6907 if ( v2->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v4->x - pBLVRenderParams->vPartyPos.x)
6908 + v2->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v4->x >> 16) - pBLVRenderParams->vPartyPos.y)
6909 + v2->pFacePlane_old.vNormal.z * (v4->z - pBLVRenderParams->vPartyPos.z) < 0 )
6910 {
6911 dword_50B700 = 1;
6912 }
6913 else
6914 {
6915 dword_50B700 = 0;
6916 if ( !(v2->uAttributes & 1) )
6917 return 0;
6918 }
6919 v29 = 0;
6920 v5 = v2->uNumVertices;
6921 __asm { fld pBLVRenderParams->fCosineY }
6922 v28 = pBLVRenderParams->fSineY;
6923 v26 = pBLVRenderParams->fCosineNegX;
6924 v27 = pBLVRenderParams->fSineNegX;
6925 v25 = v5;
6926 if ( (signed int)v5 > 0 )
6927 {
6928 _ECX = (char *)&array_50AC10[0].vWorldPosition.z;
6929 do
6930 {
6931 v7 = v3[v2->pVertexIDs[v29]].x;
6932 __asm
6933 {
6934 fild [ebp+var_10]
6935 fstp dword ptr [ecx-8]
6936 }
6937 v8 = v3[v2->pVertexIDs[v29]].y;
6938 __asm
6939 {
6940 fild [ebp+var_10]
6941 fstp dword ptr [ecx-4]
6942 }
6943 v9 = v3[v2->pVertexIDs[v29]].z;
6944 __asm
6945 {
6946 fild [ebp+var_10]
6947 fstp dword ptr [ecx]
6948 }
6949 _ECX += 48;
6950 v10 = a2->pDeltaUV[0] + v2->pVertexUIDs[v29];
6951 __asm
6952 {
6953 fild [ebp+var_10]
6954 fstp dword ptr [ecx-14h]
6955 }
6956 v11 = a2->pDeltaUV[1] + v2->pVertexVIDs[v29++];
6957 v12 = v11;
6958 v5 = v25;
6959 __asm
6960 {
6961 fild [ebp+var_10]
6962 fstp dword ptr [ecx-10h]
6963 }
6964 }
6965 while ( v29 < (signed int)v25 );
6966 }
6967 _EDX = (char *)&array_50AC10[0].vWorldViewPosition;
6968 if ( pBLVRenderParams->sPartyRotX )
6969 {
6970 if ( (signed int)v5 > 0 )
6971 {
6972 __asm
6973 {
6974 fild pBLVRenderParams->vPartyPos.x
6975 fild pBLVRenderParams->vPartyPos.y
6976 fild pBLVRenderParams->vPartyPos.z
6977 }
6978 _EAX = (char *)&array_50AC10[0].vWorldPosition.z;
6979 v15 = v5;
6980 do
6981 {
6982 __asm
6983 {
6984 fld dword ptr [eax-8]
6985 fsub st, st(3)
6986 fld dword ptr [eax-4]
6987 fsub st, st(3)
6988 fld st(1)
6989 fmul st, st(6)
6990 fld st(1)
6991 fmul [ebp+var_8]
6992 fsubp st(1), st
6993 fstp [ebp+var_4]
6994 fld dword ptr [eax]
6995 fsub st, st(3)
6996 }
6997 _EAX += 48;
6998 --v15;
6999 __asm
7000 {
7001 fstp [ebp+var_10]
7002 fld [ebp+var_4]
7003 fmul [ebp+var_14]
7004 fld [ebp+var_10]
7005 fmul [ebp+var_C]
7006 fsubp st(1), st
7007 fstp dword ptr [eax-2Ch]
7008 fld st(1)
7009 fmul [ebp+var_8]
7010 fld st(1)
7011 fmul st, st(7)
7012 faddp st(1), st
7013 fstp dword ptr [eax-28h]
7014 fstp st
7015 fstp st
7016 fld [ebp+var_4]
7017 fmul [ebp+var_C]
7018 fld [ebp+var_10]
7019 fmul [ebp+var_14]
7020 faddp st(1), st
7021 fstp dword ptr [eax-24h]
7022 }
7023 }
7024 while ( v15 );
7025 LABEL_15:
7026 __asm
7027 {
7028 fstp st
7029 fstp st
7030 fstp st
7031 }
7032 goto LABEL_16;
7033 }
7034 }
7035 else
7036 {
7037 if ( (signed int)v5 > 0 )
7038 {
7039 __asm
7040 {
7041 fild pBLVRenderParams->vPartyPos.x
7042 fild pBLVRenderParams->vPartyPos.y
7043 fild pBLVRenderParams->vPartyPos.z
7044 }
7045 _EAX = (char *)&array_50AC10[0].vWorldViewPosition;
7046 v19 = v5;
7047 do
7048 {
7049 __asm
7050 {
7051 fld dword ptr [eax-0Ch]
7052 fsub st, st(3)
7053 fld dword ptr [eax-8]
7054 fsub st, st(3)
7055 fld st(1)
7056 fmul st, st(6)
7057 fld st(1)
7058 fmul [ebp+var_8]
7059 fsubp st(1), st
7060 fstp dword ptr [eax]
7061 fld st(1)
7062 fmul [ebp+var_8]
7063 fld st(1)
7064 fmul st, st(7)
7065 }
7066 _EAX += 48;
7067 --v19;
7068 __asm
7069 {
7070 faddp st(1), st
7071 fstp dword ptr [eax-2Ch]
7072 fstp st
7073 fstp st
7074 fld dword ptr [eax-34h]
7075 fsub st, st(1)
7076 fstp dword ptr [eax-28h]
7077 }
7078 }
7079 while ( v19 );
7080 goto LABEL_15;
7081 }
7082 }
7083 LABEL_16:
7084 v20 = 0;
7085 __asm { fstp st }
7086 if ( (signed int)v5 <= 0 )
7087 return 0;
7088 do
7089 {
7090 __asm
7091 {
7092 fld dword ptr [edx]
7093 fcomp ds:flt_4D8524
7094 fnstsw ax
7095 }
7096 if ( !(HIBYTE(_AX) & 1) )
7097 break;
7098 ++v20;
7099 _EDX += 48;
7100 }
7101 while ( v20 < (signed int)v5 );
7102 if ( v20 >= (signed int)v5 )
7103 return 0;
7104 result = sr_424CD7(v5);
7105 if ( result > 0 )
7106 {
7107 __asm { fild pBLVRenderParams->field_40 }
7108 _ECX = (char *)&array_507D30[0].vWorldViewPosition;
7109 v24 = result;
7110 __asm
7111 {
7112 fmul ds:flt_4D84A4
7113 fild pBLVRenderParams->uViewportCenterX
7114 fild pBLVRenderParams->uViewportCenterY
7115 }
7116 do
7117 {
7118 __asm
7119 {
7120 fld1
7121 fdiv dword ptr [ecx]
7122 }
7123 _ECX += 48;
7124 --v24;
7125 __asm
7126 {
7127 fld st
7128 fmul dword ptr [ecx-2Ch]
7129 fmul st, st(4)
7130 fsubr st, st(3)
7131 fstp dword ptr [ecx-24h]
7132 fmul dword ptr [ecx-28h]
7133 fmul st, st(3)
7134 fsubr st, st(1)
7135 fstp dword ptr [ecx-20h]
7136 }
7137 }
7138 while ( v24 );
7139 __asm
7140 {
7141 fstp st
7142 fstp st
7143 fstp st
7144 }
7145 }
7146 memcpy(&array_507D30[result], array_507D30, sizeof(array_507D30[result]));
7147 return result;*/
7148 }
7149
7150
7151 //----- (00424829) --------------------------------------------------------
7152 bool sub_424829(int a1, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int a4)
7153 {
7154 int v4; // edi@1
7155 BspRenderer_stru2 *v5; // ebx@1
7156 int v6; // eax@3
7157 int v7; // esi@5
7158 int v8; // edx@5
7159 int v9; // ecx@6
7160 int v10; // eax@12
7161 int v11; // edi@13
7162 int v12; // edx@18
7163 int v13; // eax@22
7164 int v14; // edi@28
7165 int v15; // ecx@29
7166 int v16; // edi@30
7167 int v17; // edx@35
7168 int v18; // eax@39
7169 int v19; // eax@44
7170 int v20; // ecx@44
7171 int v21; // edi@45
7172 int v22; // edi@46
7173 __int16 *v23; // ecx@47
7174 int v24; // edx@48
7175 int v25; // eax@50
7176 int v26; // eax@55
7177 signed int v27; // edi@55
7178 int v28; // edx@56
7179 int v29; // edx@57
7180 int v30; // eax@59
7181 int v31; // eax@64
7182 signed int v32; // edi@64
7183 int v33; // edx@65
7184 __int16 *v34; // eax@66
7185 __int16 v35; // dx@66
7186 __int16 v36; // dx@67
7187 __int16 v37; // di@67
7188 __int16 v38; // dx@67
7189 BspRenderer_stru2 *v39; // ecx@69
7190 int v40; // edx@69
7191 int v41; // edi@70
7192 __int16 *v42; // eax@76
7193 __int16 *v43; // eax@81
7194 __int16 *v45; // eax@87
7195 int v46; // edx@87
7196 __int16 v47; // cx@88
7197 int v48; // eax@93
7198 int v49; // esi@93
7199 __int16 *v50; // ecx@94
7200 int v51; // eax@95
7201 int v52; // eax@97
7202 int v53; // [sp+Ch] [bp-34h]@44
7203 int v54; // [sp+10h] [bp-30h]@0
7204 int v55; // [sp+14h] [bp-2Ch]@12
7205 __int16 *v56; // [sp+14h] [bp-2Ch]@47
7206 __int16 *v57; // [sp+14h] [bp-2Ch]@76
7207 __int16 *v58; // [sp+14h] [bp-2Ch]@81
7208 __int16 *v59; // [sp+14h] [bp-2Ch]@87
7209 BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
7210 int v61; // [sp+1Ch] [bp-24h]@29
7211 int v62; // [sp+20h] [bp-20h]@0
7212 signed int v63; // [sp+24h] [bp-1Ch]@3
7213 signed int v64; // [sp+28h] [bp-18h]@3
7214 int v65; // [sp+2Ch] [bp-14h]@5
7215 int v66; // [sp+2Ch] [bp-14h]@39
7216 int v67; // [sp+30h] [bp-10h]@22
7217 int v68; // [sp+34h] [bp-Ch]@12
7218 int v69; // [sp+34h] [bp-Ch]@29
7219 int v70; // [sp+34h] [bp-Ch]@46
7220 int v71; // [sp+34h] [bp-Ch]@75
7221 int v72; // [sp+34h] [bp-Ch]@80
7222 int v73; // [sp+38h] [bp-8h]@11
7223 int v74; // [sp+3Ch] [bp-4h]@1
7224 int a3a; // [sp+48h] [bp+8h]@76
7225 int a3b; // [sp+48h] [bp+8h]@87
7226
7227 v4 = a1;
7228 v5 = a2;
7229 v74 = a1;
7230 v60 = a2;
7231 if ( !a1
7232 || (!dword_50B700 ? (v64 = -1, v6 = 1, v63 = 1) : (v6 = 1, v63 = -1, v64 = 1),
7233 v7 = dword_50B9D8_ys[0],
7234 v65 = 0,
7235 v8 = dword_50B9D8_ys[0],
7236 a1 <= v6) )
7237 return 0;
7238 do
7239 {
7240 v9 = dword_50B9D8_ys[v6];
7241 if ( v9 >= v7 )
7242 {
7243 if ( v9 > v8 )
7244 v8 = dword_50B9D8_ys[v6];
7245 }
7246 else
7247 {
7248 v65 = v6;
7249 v7 = dword_50B9D8_ys[v6];
7250 }
7251 ++v6;
7252 }
7253 while ( v6 < v4 );
7254 v73 = v8;
7255 if ( v8 == v7 )
7256 return 0;
7257 v10 = v65;
7258 v68 = 0;
7259 v5->_viewport_space_y = v7;
7260 v5->_viewport_space_w = v8;
7261 v55 = v65;
7262 if ( v4 > 0 )
7263 {
7264 v11 = v65;
7265 do
7266 {
7267 v10 += v64;
7268 if ( v10 < v74 )
7269 {
7270 if ( v10 < 0 )
7271 v10 += v74;
7272 }
7273 else
7274 {
7275 v10 -= v74;
7276 }
7277 v12 = dword_50B9D8_ys[v10];
7278 if ( v12 <= dword_50B9D8_ys[v11] )
7279 {
7280 v55 = v10;
7281 v11 = v10;
7282 }
7283 if ( v12 == v73 )
7284 break;
7285 ++v68;
7286 }
7287 while ( v68 < v74 );
7288 }
7289 v13 = v55 + v64;
7290 v67 = v55 + v64;
7291 if ( v55 + v64 < v74 )
7292 {
7293 if ( v13 >= 0 )
7294 goto LABEL_27;
7295 v13 += v74;
7296 }
7297 else
7298 {
7299 v13 -= v74;
7300 }
7301 v67 = v13;
7302 LABEL_27:
7303 if ( dword_50B9D8_ys[v13] != dword_50B9D8_ys[v55] )
7304 {
7305 v14 = dword_50BAC8[v55];
7306 v62 = v14 << 16;
7307 v54 = ((dword_50BAC8[v13] - v14) << 16) / (dword_50B9D8_ys[v13] - dword_50B9D8_ys[v55]);
7308 v5->array_18[v7] = LOWORD(dword_50BAC8[v55]);
7309 }
7310 v15 = v65;
7311 v69 = 0;
7312 v61 = v65;
7313 if ( v74 > 0 )
7314 {
7315 v16 = v65;
7316 do
7317 {
7318 v15 += v63;
7319 if ( v15 < v74 )
7320 {
7321 if ( v15 < 0 )
7322 v15 += v74;
7323 }
7324 else
7325 {
7326 v15 -= v74;
7327 }
7328 v17 = dword_50B9D8_ys[v15];
7329 if ( v17 <= dword_50B9D8_ys[v16] )
7330 {
7331 v61 = v15;
7332 v16 = v15;
7333 }
7334 if ( v17 == v73 )
7335 break;
7336 ++v69;
7337 }
7338 while ( v69 < v74 );
7339 }
7340 v18 = v63 + v61;
7341 v66 = v63 + v61;
7342 if ( v63 + v61 < v74 )
7343 {
7344 if ( v18 >= 0 )
7345 goto LABEL_44;
7346 v18 += v74;
7347 }
7348 else
7349 {
7350 v18 -= v74;
7351 }
7352 v66 = v18;
7353 LABEL_44:
7354 v19 = v18;
7355 v20 = v61;
7356 v53 = dword_50B9D8_ys[v19] - dword_50B9D8_ys[v61];
7357 if ( dword_50B9D8_ys[v19] != dword_50B9D8_ys[v61] )
7358 {
7359 v21 = dword_50BAC8[v20];
7360 v5 = v60;
7361 v61 = v21 << 16;
7362 v53 = ((dword_50BAC8[v19] - v21) << 16) / v53;
7363 v60->array_3D8[v73] = LOWORD(dword_50BAC8[v20]);
7364 }
7365 v22 = v7;
7366 v70 = v7;
7367 if ( v7 <= v73 )
7368 {
7369 v56 = &v5->array_3D8[v7];
7370 v23 = &v5->array_18[v7];
7371 do
7372 {
7373 v24 = v67;
7374 if ( v22 < dword_50B9D8_ys[v67] || v22 == v73 )
7375 goto LABEL_57;
7376 v25 = v64 + v67;
7377 v67 = v25;
7378 if ( v25 < v74 )
7379 {
7380 if ( v25 >= 0 )
7381 goto LABEL_55;
7382 v25 += v74;
7383 }
7384 else
7385 {
7386 v25 -= v74;
7387 }
7388 v67 = v25;
7389 LABEL_55:
7390 v26 = v25;
7391 v27 = dword_50B9D8_ys[v26] - dword_50B9D8_ys[v24];
7392 if ( dword_50B9D8_ys[v26] - dword_50B9D8_ys[v24] > 0 )
7393 {
7394 v28 = dword_50BAC8[v24];
7395 v54 = ((dword_50BAC8[v26] - v28) << 16) / v27;
7396 v62 = v28 << 16;
7397 }
7398 LABEL_57:
7399 v29 = v66;
7400 if ( v70 >= dword_50B9D8_ys[v66] && v70 != v73 )
7401 {
7402 v30 = v63 + v66;
7403 v66 += v63;
7404 if ( v66 >= v74 )
7405 {
7406 v30 -= v74;
7407 goto LABEL_63;
7408 }
7409 if ( v30 < 0 )
7410 {
7411 v30 += v74;
7412 LABEL_63:
7413 v66 = v30;
7414 }
7415 v31 = v30;
7416 v32 = dword_50B9D8_ys[v31] - dword_50B9D8_ys[v29];
7417 if ( dword_50B9D8_ys[v31] - dword_50B9D8_ys[v29] > 0 )
7418 {
7419 v33 = dword_50BAC8[v29];
7420 v53 = ((dword_50BAC8[v31] - v33) << 16) / v32;
7421 v61 = v33 << 16;
7422 }
7423 }
7424 *(__int16 *)((char *)v56 + (int)(char *)v5->array_18 - (char *)v5->array_3D8) = HIWORD(v62);
7425 *v56 = HIWORD(v61);
7426 v34 = v23 + 480;
7427 v35 = v23[480];
7428 if ( *v23 > v35 )
7429 {
7430 v36 = *v23 ^ v35;
7431 v37 = *v34;
7432 *v23 = v36;
7433 v38 = v37 ^ v36;
7434 *v23 ^= v38;
7435 *v34 = v38;
7436 }
7437 ++v56;
7438 v62 += v54;
7439 v22 = v70 + 1;
7440 v61 += v53;
7441 ++v23;
7442 ++v70;
7443 }
7444 while ( v70 <= v73 );
7445 }
7446 v39 = a3;
7447 v40 = v73;
7448 if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) )
7449 return 0;
7450 if ( v7 < a3->_viewport_space_y )
7451 v7 = a3->_viewport_space_y;
7452 if ( v73 > v41 )
7453 {
7454 v40 = a3->_viewport_space_w;
7455 v73 = a3->_viewport_space_w;
7456 }
7457 v71 = v7;
7458 if ( v7 <= v40 )
7459 {
7460 a3a = (char *)v5 - (char *)a3;
7461 v57 = &v5->array_18[v7];
7462 v42 = &v39->array_3D8[v7];
7463 do
7464 {
7465 if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && *v57 <= *v42 )
7466 break;
7467 ++v57;
7468 ++v7;
7469 ++v71;
7470 ++v42;
7471 }
7472 while ( v71 <= v40 );
7473 }
7474 v72 = v40;
7475 if ( v40 < v7 )
7476 return 0;
7477 v58 = &v5->array_18[v40];
7478 v43 = &v39->array_3D8[v40];
7479 do
7480 {
7481 if ( *(__int16 *)((char *)v43 + (int)(char *)v5 - (char *)v39) >= *(v43 - 480) && *v58 <= *v43 )
7482 break;
7483 --v58;
7484 --v40;
7485 --v72;
7486 --v43;
7487 v73 = v40;
7488 }
7489 while ( v72 >= v7 );
7490 if ( v7 >= v40 )
7491 return 0;
7492 a3b = (char *)v39 - (char *)v5;
7493 v59 = &v39->array_3D8[v7];
7494 v45 = &v5->array_18[v7];
7495 v46 = v73 - v7 + 1;
7496 do
7497 {
7498 v47 = *(__int16 *)((char *)v45 + a3b);
7499 if ( *v45 < v47 )
7500 *v45 = v47;
7501 if ( v45[480] > *v59 )
7502 v45[480] = *v59;
7503 ++v59;
7504 ++v45;
7505 --v46;
7506 }
7507 while ( v46 );
7508 v5->_viewport_space_y = v7;
7509 v5->_viewport_space_w = v73;
7510 v5->field_8 = v5->array_18[v7];
7511 v48 = v5->array_3D8[v7];
7512 v5->field_10 = v7;
7513 v5->field_14 = v7;
7514 v49 = v7 + 1;
7515 v5->field_C = v48;
7516 if ( v49 <= v73 )
7517 {
7518 v50 = &v5->array_3D8[v49];
7519 do
7520 {
7521 v51 = *(v50 - 480);
7522 if ( v51 < v5->field_8 )
7523 {
7524 v5->field_8 = v51;
7525 v5->field_10 = v49;
7526 }
7527 v52 = *v50;
7528 if ( v52 > v5->field_C )
7529 {
7530 v5->field_C = v52;
7531 v5->field_14 = v49;
7532 }
7533 ++v49;
7534 ++v50;
7535 }
7536 while ( v49 <= v73 );
7537 }
7538 return 1;
7539 }
7540 // 50B700: using guessed type int dword_50B700;
7541
7542 //----- (00424CD7) --------------------------------------------------------
7543 signed int __fastcall sr_424CD7(unsigned int uVertexID)
7544 {
7545 unsigned int v1; // edx@1
7546 signed int v2; // edi@1
7547 char *v3; // esi@4
7548 char *v4; // ecx@4
7549 unsigned int v5; // eax@4
7550 char *v6; // edx@4
7551 double v7; // st6@10
7552 double v8; // st5@10
7553 double v9; // st6@11
7554 unsigned __int8 v10; // c2@15
7555 unsigned __int8 v11; // c3@15
7556 RenderVertexSoft *v12; // edi@22
7557 char *v13; // eax@22
7558 double v14; // st6@22
7559 signed int result; // eax@24
7560 unsigned int v16; // [sp+8h] [bp-28h]@4
7561 bool v17; // [sp+Ch] [bp-24h]@6
7562 char *v18; // [sp+10h] [bp-20h]@4
7563 char *v19; // [sp+14h] [bp-1Ch]@4
7564 signed int v20; // [sp+18h] [bp-18h]@1
7565 RenderVertexSoft *v21; // [sp+1Ch] [bp-14h]@4
7566 char *v22; // [sp+20h] [bp-10h]@4
7567 char *v23; // [sp+24h] [bp-Ch]@4
7568 char *v24; // [sp+28h] [bp-8h]@4
7569 char *v25; // [sp+2Ch] [bp-4h]@4
7570
7571 v1 = uVertexID;
7572 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID]));
7573 v2 = 0;
7574 v20 = 0;
7575 if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 )
7576 v2 = 1;
7577 if ( (signed int)(uVertexID + 1) <= 1 )
7578 return 0;
7579 v3 = (char *)&array_507D30[0].vWorldViewPosition.z;
7580 v4 = (char *)&array_507D30[0].vWorldViewPosition.y;
7581 v5 = v1;
7582 v23 = (char *)&array_507D30[0].flt_20;
7583 v21 = array_507D30;
7584 v18 = (char *)&array_507D30[0].vWorldViewPosition.z;
7585 v19 = (char *)&array_507D30[0].vWorldViewPosition.y;
7586 v22 = (char *)&array_507D30[0].vWorldViewPosition;
7587 v24 = (char *)&array_507D30[0].v;
7588 v25 = (char *)&array_507D30[0].u;
7589 v6 = (char *)&array_50AC10[0].v;
7590 v16 = v5;
7591 do
7592 {
7593 v17 = *((float *)v6 + 5) >= 8.0;
7594 if ( v2 != v17 )
7595 {
7596 if ( v17 )
7597 {
7598 v7 = (8.0 - *((float *)v6 - 7)) / (*((float *)v6 + 5) - *((float *)v6 - 7));
7599 *(float *)v4 = (*((float *)v6 + 6) - *((float *)v6 - 6)) * v7 + *((float *)v6 - 6);
7600 *(float *)v3 = (*((float *)v6 + 7) - *((float *)v6 - 5)) * v7 + *((float *)v6 - 5);
7601 *(float *)v25 = (*((float *)v6 + 11) - *((float *)v6 - 1)) * v7 + *((float *)v6 - 1);
7602 v8 = (*((float *)v6 + 12) - *(float *)v6) * v7 + *(float *)v6;
7603 }
7604 else
7605 {
7606 v9 = (8.0 - *((float *)v6 + 5)) / (*((float *)v6 - 7) - *((float *)v6 + 5));
7607 *(float *)v4 = (*((float *)v6 - 6) - *((float *)v6 + 6)) * v9 + *((float *)v6 + 6);
7608 *(float *)v3 = (*((float *)v6 - 5) - *((float *)v6 + 7)) * v9 + *((float *)v6 + 7);
7609 *(float *)v25 = (*((float *)v6 - 1) - *((float *)v6 + 11)) * v9 + *((float *)v6 + 11);
7610 v8 = (*(float *)v6 - *((float *)v6 + 12)) * v9 + *((float *)v6 + 12);
7611 }
7612 *(float *)v24 = v8;
7613 *(float *)v22 = 8.0;
7614 *(int *)v23 = 0x3E000000u;
7615 if ( v2 )
7616 {
7617 if ( 8.0 == *((float *)v6 - 7) && *(float *)v4 == *((float *)v6 - 6) )
7618 {
7619 v10 = 0;
7620 v11 = *(float *)v3 == *((float *)v6 - 5);
7621 goto LABEL_19;
7622 }
7623 }
7624 else
7625 {
7626 if ( 8.0 == *((float *)v6 + 5) && *(float *)v4 == *((float *)v6 + 6) )
7627 {
7628 v10 = 0;
7629 v11 = *(float *)v3 == *((float *)v6 + 7);
7630 LABEL_19:
7631 if ( v11 | v10 )
7632 goto LABEL_21;
7633 goto LABEL_20;
7634 }
7635 }
7636 LABEL_20:
7637 ++v21;
7638 v22 += 48;
7639 v24 += 48;
7640 v25 += 48;
7641 v4 += 48;
7642 v3 += 48;
7643 ++v20;
7644 v23 += 48;
7645 v19 = v4;
7646 v18 = v3;
7647 }
7648 LABEL_21:
7649 if ( v17 )
7650 {
7651 v12 = v21;
7652 v13 = v23;
7653 v19 += 48;
7654 v18 += 48;
7655 v14 = 1.0 / (*((float *)v6 + 5) + 0.0000001);
7656 ++v20;
7657 v25 += 48;
7658 v24 += 48;
7659 v22 += 48;
7660 ++v21;
7661 v23 += 48;
7662 memcpy(v12, v6 + 8, 0x30u);
7663 v4 = v19;
7664 v3 = v18;
7665 *(float *)v13 = v14;
7666 }
7667 v2 = v17;
7668 v6 += 48;
7669 --v16;
7670 }
7671 while ( v16 );
7672 result = v20;
7673 if ( v20 < 3 )
7674 return 0;
7675 return result;
7676 }