comparison mm7_5.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 98b091cbabf7
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include "mm7.h"
2
3 #include "MapInfo.h"
4 #include "Game.h"
5 #include "GUIWindow.h"
6 #include "GUIFont.h"
7 #include "GUIButton.h"
8 #include "GUIProgressBar.h"
9 #include "Party.h"
10 #include "AudioPlayer.h"
11 #include "Outdoor.h"
12 #include "IndoorCamera.h"
13 #include "Overlays.h"
14 #include "Monsters.h"
15 #include "Arcomage.h"
16 #include "LOD.h"
17 #include "Actor.h"
18 #include "Allocator.h"
19 #include "Events.h"
20 #include "Viewport.h"
21 #include "FrameTableInc.h"
22 #include "Math.h"
23 #include "LayingItem.h"
24 #include "ObjectList.h"
25 #include "Chest.h"
26 #include "PaletteManager.h"
27 #include "DecorationList.h"
28 #include "SaveLoad.h"
29 #include "stru123.h"
30 #include "Time.h"
31 #include "IconFrameTable.h"
32 #include "stru179.h"
33 #include "Awards.h"
34 #include "Autonotes.h"
35 #include "stru160.h"
36 #include "stru279.h"
37 #include "TurnEngine.h"
38 #include "stru277.h"
39 #include "Weather.h"
40 #include "stru272.h"
41 #include "stru298.h"
42 #include "StorylineTextTable.h"
43 #include "Events2D.h"
44 #include "Log.h"
45
46 #include "mm7_data.h"
47
48
49
50
51
52
53
54
55
56
57
58
59 static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually
60
61
62
63 //----- (004304E7) --------------------------------------------------------
64 void __cdecl GameUI_MsgProc()
65 {
66 signed int v0; // edi@6
67 char *v1; // esi@6
68 unsigned int v2; // edx@7
69 Actor *pActor; // ecx@13
70 int v4; // ecx@18
71 NPCData *pNPCData; // eax@18
72 int v6; // edx@20
73 int v7; // ecx@29
74 unsigned int v8; // edx@59
75 unsigned int v9; // ecx@60
76 unsigned int v10; // ecx@73
77 unsigned int v11; // eax@75
78 unsigned __int8 v12; // sf@75
79 unsigned __int8 v13; // of@75
80 int v14; // eax@98
81 unsigned int v15; // eax@102
82 unsigned __int8 v16; // al@104
83 unsigned __int8 v17; // al@105
84 int v18; // eax@106
85 float v19; // ST64_4@121
86 unsigned int v20; // ecx@121
87 float v21; // ST64_4@126
88 float v22; // ST64_4@127
89 unsigned int v23; // ecx@135
90 unsigned int v24; // ecx@149
91 unsigned int v25; // ecx@165
92 GUIWindow *pWindow; // eax@204
93 unsigned int v27; // edx@204
94 unsigned int v28; // ecx@204
95 GUIWindow *pWindow2; // ecx@248
96 int v30; // edx@258
97 const char *v31; // ecx@262
98 signed int v32; // eax@269
99 unsigned int v33; // eax@277
100 unsigned __int8 v34; // al@279
101 unsigned __int8 v35; // al@280
102 GUIWindow *pWindow3; // ecx@332
103 int v37; // eax@341
104 int v38; // eax@358
105 SHORT v39; // ax@365
106 signed int v40; // eax@365
107 char *v41; // eax@380
108 int v42; // eax@396
109 POINT *pPoint; // eax@397
110 signed int v44; // eax@398
111 int v45; // edx@398
112 signed int v46; // ecx@398
113 char v47; // zf@399
114 char v48; // zf@405
115 BLVFace *pBLVFace; // ecx@410
116 ODMFace *pODMFace; // ecx@412
117 void *v51; // ecx@415
118 void *v52; // eax@424
119 __int16 v53; // ax@431
120 int v54; // eax@432
121 int v55; // ecx@432
122 int v56; // edx@432
123 int v57; // eax@432
124 Player *pPlayer; // edx@442
125 unsigned int v59; // eax@445
126 signed int v60; // ST64_4@459
127 NPCData *pNPCData2; // eax@467
128 unsigned __int64 v62; // kr00_8@467
129 __int16 v63; // dx@479
130 unsigned int v64; // eax@486
131 int v65; // ecx@486
132 int v66; // eax@488
133 char *v67; // eax@489
134 __int16 v68; // dx@498
135 char *v69; // eax@512
136 int v70; // eax@525
137 int v71; // edi@527
138 NPCData *pNPCData3; // esi@527
139 char *v73; // ecx@533
140 signed int v74; // edi@535
141 int v75; // eax@535
142 int v76; // esi@535
143 int v77; // eax@537
144 Player *pPlayer2; // ecx@549
145 int v79; // ecx@550
146 unsigned int v80; // edx@550
147 signed int v81; // eax@552
148 POINT *pPoint2; // eax@553
149 signed int v83; // ecx@554
150 signed int v84; // ecx@554
151 GUIButton *pButton; // eax@578
152 unsigned int v86; // eax@583
153 const char *v87; // ecx@595
154 const char *v88; // ecx@596
155 unsigned int v89; // eax@598
156 unsigned int v90; // eax@602
157 int v91; // edx@605
158 int v92; // eax@605
159 int v93; // edx@605
160 int pPlayerNum; // edx@611
161 int v95; // eax@611
162 const char *v96; // ecx@621
163 unsigned int v97; // eax@624
164 int v98; // eax@636
165 unsigned __int8 v99; // al@643
166 Player *pPlayer3; // eax@648
167 int v101; // ecx@648
168 int v102; // edx@652
169 int v103; // eax@671
170 Player *pPlayer4; // ecx@718
171 int v105; // eax@718
172 Player *pPlayer5; // ST78_4@758
173 unsigned int v107; // eax@758
174 unsigned int v108; // eax@758
175 char *v109; // ST64_4@759
176 Player *v110; // ST78_4@759
177 int v111; // ST60_4@759
178 int v112; // ST5C_4@759
179 char *v113; // ST58_4@759
180 signed int v114; // eax@759
181 unsigned int v115; // eax@764
182 int v116; // eax@776
183 POINT *pPoint3; // eax@777
184 unsigned int v118; // eax@785
185 unsigned int v119; // ecx@786
186 unsigned int v120; // [sp-28h] [bp-624h]@86
187 unsigned int v121; // [sp-28h] [bp-624h]@711
188 unsigned int v122; // [sp-24h] [bp-620h]@86
189 unsigned int v123; // [sp-24h] [bp-620h]@711
190 unsigned int v124; // [sp-20h] [bp-61Ch]@86
191 unsigned int v125; // [sp-20h] [bp-61Ch]@711
192 unsigned int v126; // [sp-1Ch] [bp-618h]@86
193 int v127; // [sp-1Ch] [bp-618h]@107
194 unsigned int v128; // [sp-1Ch] [bp-618h]@711
195 int v129; // [sp-18h] [bp-614h]@86
196 signed int v130; // [sp-18h] [bp-614h]@107
197 int v131; // [sp-14h] [bp-610h]@86
198 unsigned int v132; // [sp-14h] [bp-610h]@107
199 unsigned int v133; // [sp-10h] [bp-60Ch]@60
200 unsigned int v134; // [sp-10h] [bp-60Ch]@86
201 signed int v135; // [sp-10h] [bp-60Ch]@107
202 unsigned int v136; // [sp-10h] [bp-60Ch]@121
203 unsigned int v137; // [sp-Ch] [bp-608h]@60
204 unsigned int v138; // [sp-Ch] [bp-608h]@86
205 signed int v139; // [sp-Ch] [bp-608h]@107
206 unsigned int v140; // [sp-Ch] [bp-608h]@121
207 enum WindowType pWindowType; // [sp-8h] [bp-604h]@56
208 enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60
209 unsigned __int8 v143; // [sp-8h] [bp-604h]@86
210 int v144; // [sp-8h] [bp-604h]@107
211 enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121
212 const char *v146; // [sp-8h] [bp-604h]@449
213 unsigned int v147; // [sp-8h] [bp-604h]@550
214 int v148; // [sp-4h] [bp-600h]@56
215 GUIButton *pButton2; // [sp-4h] [bp-600h]@59
216 const char *v150; // [sp-4h] [bp-600h]@86
217 unsigned int v151; // [sp-4h] [bp-600h]@107
218 int v152; // [sp-4h] [bp-600h]@121
219 int v153; // [sp-4h] [bp-600h]@135
220 int v154; // [sp-4h] [bp-600h]@149
221 int v155; // [sp-4h] [bp-600h]@165
222 int v156; // [sp-4h] [bp-600h]@204
223 const char *v157; // [sp-4h] [bp-600h]@444
224 unsigned int v158; // [sp-4h] [bp-600h]@449
225 __int16 v159; // [sp-4h] [bp-600h]@550
226 int v160; // [sp-4h] [bp-600h]@599
227 const char *v161; // [sp-4h] [bp-600h]@637
228 int v162; // [sp+0h] [bp-5FCh]@56
229 int v163; // [sp+0h] [bp-5FCh]@59
230 Texture *pTexture; // [sp+0h] [bp-5FCh]@86
231 int v165; // [sp+0h] [bp-5FCh]@107
232 int v166; // [sp+0h] [bp-5FCh]@121
233 int v167; // [sp+0h] [bp-5FCh]@135
234 int v168; // [sp+0h] [bp-5FCh]@149
235 int v169; // [sp+0h] [bp-5FCh]@165
236 int v170; // [sp+0h] [bp-5FCh]@204
237 signed int v171; // [sp+0h] [bp-5FCh]@259
238 KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287
239 char *v173; // [sp+0h] [bp-5FCh]@444
240 char *v174; // [sp+0h] [bp-5FCh]@449
241 int v175; // [sp+0h] [bp-5FCh]@550
242 int v176; // [sp+0h] [bp-5FCh]@599
243 const char *v177; // [sp+0h] [bp-5FCh]@629
244 char *v178; // [sp+0h] [bp-5FCh]@637
245 int v179; // [sp+4h] [bp-5F8h]@0
246 signed int _this; // [sp+14h] [bp-5E8h]@22
247 signed int thisa; // [sp+14h] [bp-5E8h]@251
248 signed int thisb; // [sp+14h] [bp-5E8h]@272
249 Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
250 Player *pPlayer8; // [sp+14h] [bp-5E8h]@377
251 char *thise; // [sp+14h] [bp-5E8h]@445
252 Player *pPlayer9; // [sp+14h] [bp-5E8h]@455
253 int thisg; // [sp+14h] [bp-5E8h]@467
254 int thish; // [sp+14h] [bp-5E8h]@528
255 signed int thisi; // [sp+14h] [bp-5E8h]@535
256 MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604
257 Player *pPlayer10; // [sp+14h] [bp-5E8h]@641
258 int thisl; // [sp+14h] [bp-5E8h]@648
259 int uMessageParam; // [sp+18h] [bp-5E4h]@7
260 int uAction; // [sp+1Ch] [bp-5E0h]@18
261 NPCData *pNPCData4; // [sp+20h] [bp-5DCh]@23
262 unsigned int uNumSeconds; // [sp+24h] [bp-5D8h]@18
263 char v197; // [sp+2Bh] [bp-5D1h]@101
264 enum UIMessageType uMessage; // [sp+2Ch] [bp-5D0h]@7
265 unsigned int v199; // [sp+30h] [bp-5CCh]@7
266 char *v200; // [sp+34h] [bp-5C8h]@518
267 POINT v201; // [sp+38h] [bp-5C4h]@553
268 POINT v202; // [sp+40h] [bp-5BCh]@141
269 POINT a2; // [sp+48h] [bp-5B4h]@127
270 POINT v204; // [sp+50h] [bp-5ACh]@777
271 POINT v205; // [sp+58h] [bp-5A4h]@171
272 POINT v206; // [sp+60h] [bp-59Ch]@553
273 POINT v207; // [sp+68h] [bp-594h]@155
274 POINT v208; // [sp+70h] [bp-58Ch]@397
275 POINT v209; // [sp+78h] [bp-584h]@777
276 POINT v210; // [sp+80h] [bp-57Ch]@397
277 POINT v211; // [sp+88h] [bp-574h]@704
278 __int64 v212; // [sp+90h] [bp-56Ch]@467
279 char v213; // [sp+98h] [bp-564h]@385
280 char pLevelName; // [sp+9Ch] [bp-560h]@380
281 char pOut; // [sp+BCh] [bp-540h]@370
282 FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524
283 int v217[9]; // [sp+158h] [bp-4A4h]@652
284 FrameTableTxtLine v218; // [sp+17Ch] [bp-480h]@524
285 char a1[64]; // [sp+1F8h] [bp-404h]@467
286 char Str2[128]; // [sp+238h] [bp-3C4h]@527
287 Actor actor; // [sp+2B8h] [bp-344h]@4
288
289 dword_50CDC8 = 0;
290 if ( !pEventTimer->bPaused )
291 {
292 pParty->sEyelevel = pParty->uDefaultEyelevel;
293 pParty->uPartyHeight = pParty->uDefaultPartyHeight;
294 }
295 if ( bDialogueUI_InitializeActor_NPC_ID )
296 {
297 //Actor::Actor(&actor);
298 memset(&actor, 0, 0x344u);
299 dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID;
300 actor.uNPC_ID = bDialogueUI_InitializeActor_NPC_ID;
301 actor.InitializeDialogue(0);
302 bDialogueUI_InitializeActor_NPC_ID = 0;
303 }
304 if ( pMessageQueue_50CBD0->uNumMessages )
305 {
306 v0 = 1;
307 v1 = "";
308 while ( 2 )
309 {
310 if ( !pMessageQueue_50CBD0->uNumMessages )
311 break;
312
313 pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199);
314 switch ( uMessage )
315 {
316 case UIMSG_ChangeGameState:
317 uGameState = v0;
318 goto _continue;
319 case UIMSG_PlayArcomage:
320 pVideoPlayer->_4BF5B2();
321 pArcomageGame->bGameInProgress = 1;
322 PrepareArcomage();
323 goto _continue;
324 case UIMSG_StartNPCDialogue:
325 if ( !uActiveCharacter )
326 goto _continue;
327 viewparams->field_48 = v0;
328 if ( pMessageQueue_50CBD0->uNumMessages )
329 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
330 dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID;
331 pActor = &pActors[uMessageParam];
332 goto _actor_init_dlg;
333 case UIMSG_Quit|0x2:
334 case 0x87:
335 if ( bNoNPCHiring != 1 && !pCurrentScreen )
336 {
337 if ( pMessageQueue_50CBD0->uNumMessages )
338 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
339 uAction = 0;
340 uNumSeconds = uMessage - 134;
341 v4 = 0;
342 pNPCData = pParty->pHirelings;
343 do
344 {
345 if ( pNPCData->pName )
346 {
347 v6 = uAction++;
348 pTmpBuf[v6] = v4;
349 }
350 ++pNPCData;
351 ++v4;
352 }
353 while ( (signed int)pNPCData < (signed int)&pParty->pPickedItem );
354 _this = 0;
355 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
356 {
357 pNPCData4 = pNPCStats->pNewNPCData;
358 do
359 {
360 if ( pNPCData4->uFlags & 0x80
361 && (!pParty->pHirelings[0].pName || strcmp(pNPCData4->pName, pParty->pHirelings[0].pName))
362 && (!pParty->pHirelings[1].pName || strcmp(pNPCData4->pName, pParty->pHirelings[1].pName)) )
363 {
364 v7 = uAction++;
365 pTmpBuf[v7] = _this + 2;
366 }
367 ++_this;
368 ++pNPCData4;
369 }
370 while ( _this < (signed int)pNPCStats->uNumNewNPCs );
371 }
372 if ( (signed int)(uNumSeconds + (unsigned __int8)pParty->field_709) < uAction )
373 {
374 //Actor::Actor(&actor);
375 memset(&actor, 0, 0x344u);
376 actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds;
377 pActor = &actor;
378 _actor_init_dlg:
379 pActor->InitializeDialogue(v0);
380 }
381 }
382 goto _continue;
383 case 0x51:
384 sub_4BDB56_buy_skill____();
385 goto _continue;
386 case UIMSG_AF:
387 sub_4B2001(uMessageParam);
388 goto _continue;
389 case 0x195:
390 sub_4BCACC_bounties(uMessageParam);
391 goto _continue;
392 case 0x88:
393 sub_4BC49B(uMessageParam);
394 goto _continue;
395 case 0x19A:
396 _4B4224_UpdateNPCTopics(uMessageParam);
397 goto _continue;
398 case UIMSG_StartNewGame:
399 if ( dword_6BE138 == 124 || uMessageParam )
400 {
401 pIcons_LOD->_40F9C5();
402 pIcons_LOD->_4114F2();
403 if ( pMessageQueue_50CBD0->uNumMessages )
404 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
405 pGUIWindow_CurrentMenu->Release();
406 uGameState = 4;
407 LABEL_188:
408 pCurrentScreen = 0;
409 viewparams->bRedrawGameUI = v0;
410 }
411 else
412 {
413 ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2u);// "Are you sure? Click again to start a New Game"
414 pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
415 dword_6BE138 = 124;
416 }
417 _release_tex_and_continue:
418 stru_506E40.Release();
419 goto _continue;
420 case UIMSG_Game_OpenLoadGameDialog:
421 pIcons_LOD->_40F9C5();
422 pIcons_LOD->_4114F2();
423 if ( pMessageQueue_50CBD0->uNumMessages )
424 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
425 pGUIWindow_CurrentMenu->Release();
426 pCurrentScreen = 12;
427 GameUI_DrawLoadMenu(v0);
428 goto _continue;
429 case UIMSG_Quit:
430 if ( dword_6BE138 == 132 || uMessageParam )
431 {
432 pIcons_LOD->_40F9C5();
433 pIcons_LOD->_4114F2();
434 if ( pMessageQueue_50CBD0->uNumMessages )
435 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
436 pGUIWindow_CurrentMenu->Release();
437 pCurrentScreen = 0;
438 viewparams->bRedrawGameUI = v0;
439 if ( !uMessageParam )
440 pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
441 uGameState = 7;
442 }
443 else
444 {
445 ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2u);// "Are you sure? Click again to quit"
446 pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
447 dword_6BE138 = 132;
448 }
449 goto _release_tex_and_continue;
450 case 0x80:
451 pIcons_LOD->_40F9C5();
452 pIcons_LOD->_4114F2();
453 pGUIWindow_CurrentMenu->Release();
454 pCurrentScreen = 2;
455 v162 = 0;
456 v148 = 0;
457 pWindowType = (WindowType)8;
458 goto LABEL_439;
459 case UIMSG_A2:
460 --dword_6A0C9C;
461 if ( dword_6A0C9C < 0 )
462 dword_6A0C9C = 0;
463 v163 = 0;
464 v8 = 199;
465 pButton2 = ptr_69BD5C;
466 //goto LABEL_60;
467 pWindowType1 = (WindowType)90;
468 v137 = 17;
469 v133 = 17;
470 v9 = 215;
471 goto LABEL_733;
472 case UIMSG_A3:
473 ++dword_6A0C9C;
474 if ( dword_6A0C9C >= uMessageParam )
475 dword_6A0C9C = uMessageParam - 1;
476 v163 = 0;
477 v8 = 323;
478 pButton2 = ptr_69BD58;
479 //LABEL_60:
480 pWindowType1 = (WindowType)90;
481 v137 = 17;
482 v133 = 17;
483 v9 = 215;
484 goto LABEL_733;
485 case UIMSG_A6:
486 v163 = 0;
487 v8 = 302;
488 pButton2 = ptr_69BD60;
489 v9 = 350;
490 pWindowType1 = (WindowType)96;
491 v137 = 42;
492 v133 = 106;
493 goto LABEL_733;
494 case UIMSG_A4:
495 v163 = 0;
496 v8 = 302;
497 pButton2 = ptr_69BD64;
498 v9 = 241;
499 pWindowType1 = (WindowType)94;
500 v137 = 42;
501 v133 = 106;
502 goto LABEL_733;
503 case UIMSG_A5:
504 if ( pGUIWindow_CurrentMenu->field_40 == v0 )
505 pKeyActionMap->_459ED1(0);
506 if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != dword_6A0C9C + uMessageParam )
507 {
508 v10 = dword_6A0C9C + uMessageParam;
509 if ( dword_6BE138 == dword_6A0C9C + uMessageParam )
510 {
511 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
512 {
513 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)164;
514 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
515 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
516 v11 = pMessageQueue_50CBD0->uNumMessages + 1;
517 v13 = __OFSUB__(pMessageQueue_50CBD0->uNumMessages + 1, 40);
518 v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
519 ++pMessageQueue_50CBD0->uNumMessages;
520 if ( v12 ^ v13 )
521 {
522 pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)82;
523 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
524 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
525 ++pMessageQueue_50CBD0->uNumMessages;
526 }
527 }
528 }
529 uLoadGameUI_SelectedSlot = v10;
530 dword_6BE138 = v10;
531 }
532 else
533 {
534 pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
535 if ( strcmp((const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, pGlobalTXT_LocalizationStrings[72]) )// "Empty"
536 strcpy((char *)pKeyActionMap->pPressedKeysBuffer, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
537 pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
538 }
539 goto _continue;
540 case UIMSG_LoadGame:
541 if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
542 {
543 LoadGame(uLoadGameUI_SelectedSlot);
544 uGameState = 3;
545 }
546 goto _release_tex_and_continue;
547 case UIMSG_SaveGame:
548 if ( pGUIWindow_CurrentMenu->field_40 == v0 )
549 {
550 pKeyActionMap->_459ED1(0);
551 strcpy(
552 (char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot,
553 (const char *)pKeyActionMap->pPressedKeysBuffer);
554 }
555 DoSavegame(uLoadGameUI_SelectedSlot);
556 goto _release_tex_and_continue;
557 case UIMSG_StartNewGame|0x2:
558 pGUIWindow_CurrentMenu->Release();
559 pCurrentScreen = 11;
560 GameUI_DrawSaveMenu();
561 goto _continue;
562 case UIMSG_Game_OpenOptionsDialog:
563 if ( pMessageQueue_50CBD0->uNumMessages )
564 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
565 pGUIWindow_CurrentMenu->Release();
566 viewparams->field_48 = v0;
567 pCurrentScreen = 2;
568 uTextureID_507C60 = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
569 uTextureID_507C6C = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
570 uTextureID_507C68 = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
571 uTextureID_507C70 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
572 uTextureID_507C74 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
573 uTextureID_507C64[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
574 pTextureIDs_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
575 pTextureIDs_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
576 pTextureIDs_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
577 pTextureIDs_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
578 pTextureIDs_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
579 pTextureIDs_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
580 pTextureIDs_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
581 pTextureIDs_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
582 pTextureIDs_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
583 pTextureIDs_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
584 uTextureID_507C84 = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
585 uTextureID_507CB0 = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
586 uTextureID_507CB8 = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
587 uTextureID_507CB4 = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
588 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
589 pGUIWindow_CurrentMenu->CreateButton(0x16u, 0x10Eu,
590 (uTextureID_507C6C != -1 ? pIcons_LOD->pTextures[uTextureID_507C6C].uTextureWidth : 24),
591 (uTextureID_507C6C != -1 ? pIcons_LOD->pTextures[uTextureID_507C6C].uTextureHeight : 26),
592 v0, 0, 0xB8u, 0x80u, 0, v1, 0);
593 pGUIWindow_CurrentMenu->CreateButton(0x5Du, 0x10Eu,
594 (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureWidth : 24),
595 (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureHeight : 26),
596 v0, 0, 0xB8u, 0x40u, 0, v1, 0);
597 pGUIWindow_CurrentMenu->CreateButton(0xA4u, 0x10Eu,
598 (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureWidth : 24),
599 (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureHeight : 26),
600 v0, 0, 0xB8u, 0, 0, v1, 0);
601 pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x12Fu,
602 (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureWidth : 24),
603 (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureHeight : 26),
604 v0, 0, 0xB9u, 0, 0, v1, 0);
605 pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x12Fu,
606 (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureWidth : 24),
607 (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureHeight : 26),
608 v0, 0, 0xBBu, 0, 0, v1, 0);
609 pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x145u,
610 (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureWidth : 24),
611 (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureHeight : 26),
612 v0, 0, 0xE1u, 0, 0, v1, 0);
613 pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x145u,
614 (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureWidth : 24),
615 (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureHeight : 26),
616 v0, 0, 0xE2u, 0, 0, v1, 0);
617 pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, 111, 4, 0, v1,
618 &pIcons_LOD->pTextures[uTextureID_507C70], 0);
619 pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xA2u, 0x10u, 0x10u, v0, 0, 0x6Fu, 5, 0, v1,
620 &pIcons_LOD->pTextures[uTextureID_507C74], 0);
621 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, 0x6Fu, 0, 0, v1, 0);
622 pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 4, 0, v1,
623 &pIcons_LOD->pTextures[uTextureID_507C70], 0);
624 pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 5, 0, v1,
625 &pIcons_LOD->pTextures[uTextureID_507C74], 0);
626 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, 0x70u, 0, 0, v1, 0);
627 pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 4, 0, v1,
628 &pIcons_LOD->pTextures[uTextureID_507C70], 0);
629 pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 5u, 0, v1,
630 &pIcons_LOD->pTextures[uTextureID_507C74], 0);
631 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, 0xBAu, 0, 0, v1, 0);
632 pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0,
633 pGlobalTXT_LocalizationStrings[619],// "Return to Game"
634 0);
635 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, 0x19Fu, 0, 0x4Bu, v1, 0);
636 pTexture = 0;
637 v150 = v1;
638 v143 = 86;
639 v138 = 0;
640 v134 = 421;
641 v131 = 0;
642 v129 = v0;
643 v126 = 40;
644 v124 = 214;
645 v122 = 194;
646 v120 = 19;
647 goto LABEL_117;
648 case UIMSG_OpenKeyMappingOptions:
649 if ( pMessageQueue_50CBD0->uNumMessages )
650 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
651 pGUIWindow_CurrentMenu->Release();
652 viewparams->field_48 = 1;
653 pCurrentScreen = 26;
654 uTextureID_507BF4 = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
655 uTextureID_507BF8 = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
656 uTextureID_507BFC = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
657 uTextureID_507C00 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
658 uTextureID_507C04 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
659 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_KeyMappingOptions, 0, 0);
660 pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, "", 0);
661 pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, "", 0);
662 pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, "", 0);
663 pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, "", 0);
664 pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, "", 0);
665 pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, "", 0);
666 pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, "", 0);
667 pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, "", 0);
668 pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, "", 0);
669 pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, "", 0);
670 pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, "", 0);
671 pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, "", 0);
672 pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, "", 0);
673 pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, "", 0);
674 pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, "", 0);
675 pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, "", 0);
676 pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, "", 0);
677 pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, "", 0);
678 pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, "", 0);
679 dword_506E68 = -1;
680 dword_506F08 = 1;
681 memset(word_506E6C, 0, 0x1Cu);
682 word_506E6C[14] = 0;
683 memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
684 goto LABEL_90;
685 default:
686 goto _continue;
687 case UIMSG_ResetKeyMapping|0x1:
688 if ( dword_506E68 != -1 )
689 goto LABEL_623;
690 v14 = uMessageParam;
691 if ( dword_506F08 != v0 )
692 v14 = uMessageParam + 14;
693 dword_506E68 = v14;
694 pKeyActionMap->_459E5A(0, v0, pGUIWindow_CurrentMenu);
695 goto _continue;
696 case UIMSG_ResetKeyMapping:
697 v197 = 1;
698 pKeyActionMap->SetDefaultMapping();
699 uAction = 0;
700 do
701 {
702 v15 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
703 if ( v15 != pPrevVirtualCidesMapping[uAction] )
704 {
705 if ( v197 )
706 {
707 v16 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
708 GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v16, v0);
709 v197 = 0;
710 }
711 else
712 {
713 v17 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
714 GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v17, 0);
715 }
716 }
717 pPrevVirtualCidesMapping[uAction] = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
718 v18 = uAction++;
719 v13 = __OFSUB__(uAction, 28);
720 v12 = uAction - 28 < 0;
721 *((char *)word_506E6C + v18) = 0;
722 }
723 while ( v12 ^ v13 );
724 v165 = 0;
725 v151 = 0;
726 v144 = 0;
727 v139 = 0;
728 v135 = -1;
729 v132 = 0;
730 v130 = 0;
731 v127 = 219;
732 goto _play_sound_and_continue;
733 case 0x1A0:
734 dword_506F08 = v0;
735 goto _continue;
736 case UIMSG_StartNPCDialogue|0x100:
737 dword_506F08 = 2;
738 goto _continue;
739 case UIMSG_OpenVideoOptions:
740 if ( pMessageQueue_50CBD0->uNumMessages )
741 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
742 pGUIWindow_CurrentMenu->Release();
743 viewparams->field_48 = v0;
744 pCurrentScreen = 28;
745 uTextureID_507C10 = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE);
746 uTextureID_507C14 = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE);
747 uTextureID_507C18 = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE);
748 uTextureID_507C1C = pIcons_LOD->LoadTexture("opvdH-tn", TEXTURE_16BIT_PALETTE);
749 uTextureID_507C20 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
750 uTextureID_507C24 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
751 pTextureIDs_GammaPositions[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
752 pTextureIDs_GammaPositions[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
753 pTextureIDs_GammaPositions[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
754 pTextureIDs_GammaPositions[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
755 pTextureIDs_GammaPositions[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
756 pTextureIDs_GammaPositions[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
757 pTextureIDs_GammaPositions[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
758 pTextureIDs_GammaPositions[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
759 pTextureIDs_GammaPositions[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
760 pTextureIDs_GammaPositions[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
761 uTextureID_507C50 = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE);
762 uTextureID_507C54 = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE);
763 uTextureID_507C58 = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE);
764 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_VideoOptions, 0, 0);
765 pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0, v1, 0);
766 if ( pRenderer->pRenderD3D )
767 {
768 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, v0, 0, 0x1A6u, 0, 0, v1, 0);
769 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, v0, 0, 0x1A7u, 0, 0, v1, 0);
770 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, v0, 0, 0x1A8u, 0, 0, v1, 0);
771 }
772 if ( !pRenderer->bWindowMode )
773 {
774 v0 = 1;
775 if ( GammaController::IsGammaSupported() )
776 {
777 pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, 0x1A9u, 4u, 0, v1,
778 &pIcons_LOD->pTextures[uTextureID_507C20], 0);
779 pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, 0x1A9u, 5u, 0, v1,
780 &pIcons_LOD->pTextures[uTextureID_507C24], 0);
781 pTexture = 0;
782 v150 = v1;
783 v143 = 0;
784 v138 = 0;
785 v134 = 425;
786 v131 = 0;
787 v129 = 1;
788 v126 = 18;
789 v124 = 170;
790 v122 = 162;
791 v120 = 42;
792 LABEL_117:
793 pGUIWindow_CurrentMenu->CreateButton(v120, v122, v124, v126, v129, v131, v134, v138, v143, v150, pTexture);
794 }
795 }
796 goto _continue;
797 case UIMSG_ToggleTint|0x1:
798 if ( uMessageParam == 4 )
799 {
800 --uGammaPos;
801 if ( (uGammaPos & 0x80000000u) != 0 )
802 {
803 uGammaPos = 0;
804 goto LABEL_128;
805 }
806 v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
807 pGame->pGammaController->Initialize(v19);
808 v166 = v0;
809 v152 = (int)pBtn_SliderLeft;
810 pWindowType2 = (WindowType)90;
811 v140 = 0;
812 v136 = 0;
813 v20 = 21;
814 goto LABEL_122;
815 }
816 if ( uMessageParam == 5 )
817 {
818 ++uGammaPos;
819 if ( (signed int)uGammaPos <= 9 )
820 {
821 v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
822 pGame->pGammaController->Initialize(v21);
823 v20 = 213;
824 v166 = v0;
825 v152 = (int)pBtn_SliderRight;
826 pWindowType2 = (WindowType)90;
827 v140 = 0;
828 v136 = 0;
829 LABEL_122:
830 GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
831 goto LABEL_128;
832 }
833 uGammaPos = 9;
834 }
835 else
836 {
837 uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17;
838 v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
839 pGame->pGammaController->Initialize(v22);
840 }
841 LABEL_128:
842 v165 = 0;
843 v151 = 0;
844 v144 = 0;
845 v139 = 0;
846 v135 = -1;
847 v132 = 0;
848 v130 = 0;
849 v127 = 21;
850 goto _play_sound_and_continue;
851 case UIMSG_ToggleBloodsplats:
852 pGame->ToggleFlags2(0x20u);
853 goto _continue;
854 case UIMSG_ToggleColoredLights:
855 pRenderer->bUseColoredLights = pRenderer->bUseColoredLights == 0;
856 goto _continue;
857 case UIMSG_ToggleTint:
858 pRenderer->bTinting = pRenderer->bTinting == 0;
859 goto _continue;
860 case UIMSG_ChangeMusicVolume:
861 if ( uMessageParam == 4 )
862 {
863 --uMusicVolimeMultiplier;
864 if ( (char)uMusicVolimeMultiplier < 1 )
865 uMusicVolimeMultiplier = 0;
866 v167 = v0;
867 v23 = 243;
868 v153 = (int)pBtn_SliderLeft;
869 LABEL_136:
870 GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
871 goto LABEL_143;
872 }
873 if ( uMessageParam == 5 )
874 {
875 ++uMusicVolimeMultiplier;
876 if ( (char)uMusicVolimeMultiplier > 9 )
877 uMusicVolimeMultiplier = 9;
878 v167 = v0;
879 v23 = 435;
880 v153 = (int)pBtn_SliderRight;
881 goto LABEL_136;
882 }
883 uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;
884 if ( (char)uMusicVolimeMultiplier > 9 )
885 uMusicVolimeMultiplier = 9;
886 LABEL_143:
887 if ( uMusicVolimeMultiplier )
888 pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0,
889 (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0), 0);
890 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
891 goto _continue;
892 case UIMSG_ChangeSoundVolume:
893 if ( uMessageParam == 4 )
894 {
895 --uSoundVolumeMultiplier;
896 if ( (char)uSoundVolumeMultiplier < 1 )
897 uSoundVolumeMultiplier = 0;
898 v168 = v0;
899 v24 = 243;
900 v154 = (int)pBtn_SliderLeft;
901 LABEL_150:
902 GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
903 goto LABEL_157;
904 }
905 if ( uMessageParam == 5 )
906 {
907 ++uSoundVolumeMultiplier;
908 if ( (char)uSoundVolumeMultiplier > 8 )
909 uSoundVolumeMultiplier = 9;
910 v168 = v0;
911 v24 = 435;
912 v154 = (int)pBtn_SliderRight;
913 goto LABEL_150;
914 }
915 uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17;
916 if ( (char)uSoundVolumeMultiplier > 8 )
917 uSoundVolumeMultiplier = 9;
918 LABEL_157:
919 pAudioPlayer->SetMasterVolume((signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
920 v165 = 0;
921 v151 = 0;
922 v144 = 0;
923 v139 = 0;
924 v135 = -1;
925 v132 = 0;
926 v130 = -1;
927 v127 = 218;
928 goto _play_sound_and_continue;
929 case UIMSG_ToggleFlipOnExit:
930 bFlipOnExit = bFlipOnExit == 0;
931 goto _continue;
932 case UIMSG_ToggleAlwaysRun:
933 bAlwaysRun = bAlwaysRun == 0;
934 goto _continue;
935 case UIMSG_ToggleWalkSound:
936 bWalkSound = bWalkSound == 0;
937 goto _continue;
938 case UIMSG_ToggleShowDamage:
939 bShowDamage = bShowDamage == 0;
940 goto _continue;
941 case UIMSG_ChangeVoiceVolume:
942 if ( uMessageParam == 4 )
943 {
944 --uVoicesVolumeMultiplier;
945 if ( (char)uVoicesVolumeMultiplier < 1 )
946 uVoicesVolumeMultiplier = 0;
947 v169 = v0;
948 v25 = 243;
949 v155 = (int)pBtn_SliderLeft;
950 LABEL_166:
951 GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
952 goto LABEL_173;
953 }
954 if ( uMessageParam == 5 )
955 {
956 ++uVoicesVolumeMultiplier;
957 if ( (char)uVoicesVolumeMultiplier > 8 )
958 uVoicesVolumeMultiplier = 9;
959 v169 = v0;
960 v25 = 435;
961 v155 = (int)pBtn_SliderRight;
962 goto LABEL_166;
963 }
964 uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17;
965 if ( (char)uVoicesVolumeMultiplier > 8 )
966 uVoicesVolumeMultiplier = 9;
967 LABEL_173:
968 if ( !uVoicesVolumeMultiplier )
969 goto _continue;
970 v165 = 0;
971 v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
972 v144 = 0;
973 v139 = 0;
974 v135 = -1;
975 v132 = 0;
976 v130 = -1;
977 v127 = 5788;
978 goto _play_sound_and_continue;
979 case UIMSG_SetTurnSpeed:
980 if ( uMessageParam )
981 pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
982 uTurnSpeed = uMessageParam;
983 goto _continue;
984 case UIMSG_SetGraphicsMode:
985 if ( !bUseLoResSprites )
986 {
987 byte_6BE388_graphicsmode = uMessageParam;
988 LABEL_184:
989 MM7Initialization();
990 goto _continue;
991 }
992 if ( uMessageParam )
993 {
994 if ( uMessageParam == 1 )
995 {
996 byte_6BE388_graphicsmode = 0;
997 }
998 else
999 {
1000 if ( uMessageParam != 2 )
1001 goto _continue;
1002 byte_6BE388_graphicsmode = 1;
1003 }
1004 goto LABEL_184;
1005 }
1006 ModalWindow(pNPCTopics[453].pText, 0);
1007 goto _continue;
1008 case UIMSG_SkillUp|0x2:
1009 pGUIWindow_CurrentMenu->Release();
1010 pEventTimer->Resume();
1011 goto LABEL_188;
1012 case UIMSG_OpenQuestBook:
1013 if ( pMessageQueue_50CBD0->uNumMessages )
1014 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1015 if ( pCurrentScreen )
1016 pGUIWindow_CurrentMenu->Release();
1017 pEventTimer->Pause();
1018 pAudioPlayer->StopChannels(-1, -1);
1019 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1020 pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, (enum WindowType)99, (int)pBtn_Quests, 0);
1021 bFlashQuestBook = 0;
1022 goto _continue;
1023 case UIMSG_OpenAutonotes:
1024 if ( pMessageQueue_50CBD0->uNumMessages )
1025 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1026 if ( pCurrentScreen )
1027 pGUIWindow_CurrentMenu->Release();
1028 pEventTimer->Pause();
1029 pAudioPlayer->StopChannels(-1, -1);
1030 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1031 pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, (enum WindowType)99, (int)pBtn_Autonotes, 0);
1032 bFlashAutonotesBook = 0;
1033 goto _continue;
1034 case UIMSG_OpenMapBook:
1035 if ( pMessageQueue_50CBD0->uNumMessages )
1036 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1037 if ( pCurrentScreen )
1038 pGUIWindow_CurrentMenu->Release();
1039 pEventTimer->Pause();
1040 viewparams->sPartyPosX = pParty->vPosition.x;
1041 viewparams->sPartyPosZ = pParty->vPosition.y;
1042 pAudioPlayer->StopChannels(-1, -1);
1043 pWindow = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1044 v27 = 353;
1045 v28 = 546;
1046 v170 = 0;
1047 v156 = (int)pBtn_Maps;
1048 goto LABEL_210;
1049 case UIMSG_OpenCalendar:
1050 if ( pMessageQueue_50CBD0->uNumMessages )
1051 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1052 if ( pCurrentScreen )
1053 pGUIWindow_CurrentMenu->Release();
1054 pEventTimer->Pause();
1055 pAudioPlayer->StopChannels(-1, -1);
1056 pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
1057 v27 = 354;
1058 v28 = 570;
1059 v170 = 0;
1060 v156 = (int)pBtn_Calendar;
1061 LABEL_210:
1062 pGUIWindow_CurrentMenu = pWindow;
1063 pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
1064 goto _continue;
1065 case UIMSG_OpenHistoryBook:
1066 if ( pMessageQueue_50CBD0->uNumMessages )
1067 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1068 if ( pCurrentScreen )
1069 pGUIWindow_CurrentMenu->Release();
1070 pEventTimer->Pause();
1071 pAudioPlayer->StopChannels(-1, -1);
1072 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
1073 pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)pBtn_History, 0);
1074 bFlashHistoryBook = 0;
1075 goto _continue;
1076 case UIMSG_CloseBook:
1077 back_to_game();
1078 if ( pMessageQueue_50CBD0->uNumMessages )
1079 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1080 if ( pCurrentScreen > 15 )
1081 {
1082 if ( pCurrentScreen >= 17 && (pCurrentScreen <= 18 || pCurrentScreen == 104) )
1083 {
1084 LABEL_229:
1085 if ( dword_50CDC8 )
1086 goto LABEL_232;
1087 sub_42FC15();
1088 goto LABEL_231;
1089 }
1090 }
1091 else
1092 {
1093 if ( pCurrentScreen >= 14 || pCurrentScreen == 4 || pCurrentScreen == 10 )
1094 goto LABEL_229;
1095 if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 )
1096 {
1097 sub_42FC15();
1098 dword_5C35C8 = 0;
1099 LABEL_231:
1100 uMessageParam = v0;
1101 goto LABEL_232;
1102 }
1103 }
1104 LABEL_232:
1105 if ( !ptr_507BDC )
1106 {
1107 pRenderer->ClearZBuffer(0, 479);
1108 viewparams->bRedrawGameUI = v0;
1109 viewparams->field_48 = v0;
1110 if ( pCurrentScreen )
1111 {
1112 if ( pCurrentScreen > 103 )
1113 {
1114 if ( pCurrentScreen == 104 )
1115 goto LABEL_321;
1116 }
1117 else
1118 {
1119 if ( pCurrentScreen < 100 )
1120 {
1121 switch ( pCurrentScreen )
1122 {
1123 case 23:
1124 pIcons_LOD->_4114F2();
1125 if ( some_active_character )
1126 {
1127 uActiveCharacter = some_active_character;
1128 uActiveCharacter = pParty->GetNextActiveCharacter();
1129 some_active_character = 0;
1130 if ( pParty->bTurnBasedModeOn )
1131 pTurnEngine->_40471C();
1132 dword_50C9D0 = 0;
1133 dword_50C9D4 = 0;
1134 dword_50C9D8 = 0;
1135 }
1136 if ( ptr_50C9A4 && ptr_50C9A4->uItemID )
1137 {
1138 LOBYTE(ptr_50C9A4->uAttributes) &= 0xFu;
1139 dword_50C9A8 = 0;
1140 ptr_50C9A4 = 0;
1141 }
1142 goto LABEL_322;
1143 case 3:
1144 pBooksWindow->Release();
1145 //crt_deconstruct_ptr_6A0118();
1146 pBooksWindow = 0;
1147 pEventTimer->Resume();
1148 goto LABEL_322;
1149 case 11:
1150 case 12:
1151 pIcons_LOD->_4114F2();
1152 //crt_deconstruct_ptr_6A0118();
1153 goto LABEL_291;
1154 case 15:
1155 pCurrentScreen = 10;
1156 goto _continue;
1157 case 10:
1158 pWindow2 = pChestWindow;
1159 goto LABEL_249;
1160 case 25:
1161 pWindow2 = ptr_507BC8;
1162 LABEL_249:
1163 pWindow2->Release();
1164 pIcons_LOD->_4114F2();
1165 pCurrentScreen = 0;
1166 viewparams->bRedrawGameUI = v0;
1167 pEventTimer->Resume();
1168 goto _continue;
1169 case 2:
1170 thisa = (signed int)&uTextureID_507C60;
1171 do
1172 {
1173 if ( *(int *)thisa )
1174 pIcons_LOD->pTextures[*(int *)thisa].Release();
1175 thisa += 4;
1176 }
1177 while ( thisa < (signed int)&dword_507CBC );
1178 memset(&uTextureID_507C60, 0, 0x5Cu);
1179 pIcons_LOD->_40F9C5();
1180 WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
1181 WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
1182 WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier);
1183 WriteWindowsRegistryInt("WalkSound", bWalkSound);
1184 WriteWindowsRegistryInt("ShowDamage", bShowDamage);
1185 WriteWindowsRegistryInt("graphicsmode", (unsigned __int8)byte_6BE388_graphicsmode);
1186 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun);
1187 WriteWindowsRegistryInt("FlipOnExit", bFlipOnExit);
1188 if ( !uTurnSpeed )
1189 {
1190 v171 = 3;
1191 goto LABEL_261;
1192 }
1193 if ( uTurnSpeed == 64 )
1194 {
1195 v171 = 2;
1196 LABEL_261:
1197 v30 = v171;
1198 goto LABEL_262;
1199 }
1200 if ( uTurnSpeed != 128 )
1201 goto LABEL_291;
1202 v30 = v0;
1203 LABEL_262:
1204 v31 = "TurnDelta";
1205 LABEL_263:
1206 WriteWindowsRegistryInt(v31, v30);
1207 LABEL_291:
1208 stru_506E40.Release();
1209 break;
1210 case 1:
1211 pIcons_LOD->_40F9C5();
1212 pIcons_LOD->_4114F2();
1213 pIcons_LOD->_40F9C5();
1214 pIcons_LOD->_4114F2();
1215 goto LABEL_291;
1216 case 28:
1217 if ( pRenderer->pRenderD3D )
1218 {
1219 WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights);
1220 WriteWindowsRegistryInt("Tinting", pRenderer->bTinting);
1221 WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
1222 }
1223 if ( pRenderer->bWindowMode )
1224 goto LABEL_291;
1225 v30 = uGammaPos;
1226 v31 = "GammaPos";
1227 goto LABEL_263;
1228 case 26:
1229 v197 = 1;
1230 v32 = 0;
1231 while ( *((char *)word_506E6C + v32) != 1 )
1232 {
1233 ++v32;
1234 if ( v32 >= 28 )
1235 {
1236 thisb = (signed int)&uTextureID_507BF4;
1237 do
1238 {
1239 if ( *(int *)thisb )
1240 pIcons_LOD->pTextures[*(int *)thisb].Release();
1241 thisb += 4;
1242 }
1243 while ( thisb < (signed int)&dword_507C08 );
1244 memset(&uTextureID_507BF4, 0, 0x14u);
1245 pIcons_LOD->_40F9C5();
1246 uAction = 0;
1247 do
1248 {
1249 v33 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1250 if ( v33 != pPrevVirtualCidesMapping[uAction] )
1251 {
1252 if ( v197 )
1253 {
1254 v34 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1255 GUI_ReplaceHotkey(v34, LOBYTE(pPrevVirtualCidesMapping[uAction]), v0);
1256 v197 = 0;
1257 }
1258 else
1259 {
1260 v35 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1261 GUI_ReplaceHotkey(v35, LOBYTE(pPrevVirtualCidesMapping[uAction]), 0);
1262 }
1263 }
1264 if ( uAction && uAction != 2 && uAction != 3 && uAction != v0 && uAction != 25 && uAction != 26 )
1265 pKeyToggleType = (KeyToggleType)v0;
1266 else
1267 pKeyToggleType = (KeyToggleType)0;
1268 pKeyActionMap->SetKeyMapping(uAction, pPrevVirtualCidesMapping[uAction], pKeyToggleType);
1269 ++uAction;
1270 }
1271 while ( uAction < 28 );
1272 pKeyActionMap->StoreMappings();
1273 goto LABEL_291;
1274 }
1275 }
1276 goto LABEL_623;
1277 case 5:
1278 if ( dword_506F14 )
1279 {
1280 Rest(_506F18_num_hours_to_sleep);
1281 pParty->pPlayers[3].pConditions[2] = 0i64;
1282 pParty->pPlayers[2].pConditions[2] = 0i64;
1283 pParty->pPlayers[1].pConditions[2] = 0i64;
1284 pParty->pPlayers[0].pConditions[2] = 0i64;
1285 }
1286 pTexture_RestUI_CurrentSkyFrame->Release();
1287 pTexture_RestUI_CurrentHourglassFrame->Release();
1288 pTexture_RestUI_CurrentHourglassFrame = 0;
1289 pTexture_RestUI_CurrentSkyFrame = 0;
1290 pIcons_LOD->_40F9C5();
1291 pIcons_LOD->_4114F2();
1292 _506F18_num_hours_to_sleep = 0;
1293 dword_506F14 = 0;
1294 dword_507B94 = v0;
1295 goto LABEL_322;
1296 case 14:
1297 pGUIWindow_CurrentMenu->Release();
1298 pCurrentScreen = 13;
1299 pIcons_LOD->_4114F2();
1300 goto _continue;
1301 case 13:
1302 if ( uDialogueType )
1303 uDialogueType = 0;
1304 if ( uGameState == 2 )
1305 {
1306 while ( sub_4BD8B5() )
1307 ;
1308 }
1309 else
1310 {
1311 if ( sub_4BD8B5() )
1312 goto _continue;
1313 }
1314 sub_4B1D27();
1315 pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 814, 0, -1, 0, 0, 0, 0);
1316 pVideoPlayer->Unload();
1317 pGUIWindow_CurrentMenu = ptr_507BC0;
1318 goto LABEL_322;
1319 case 18:
1320 if ( uCurrentHouse_Animation == 153 )
1321 HousePlaySomeSound(0x99u, 3);
1322 pVideoPlayer->Unload();
1323 goto LABEL_306;
1324 case 4:
1325 LABEL_306:
1326 if ( dword_5B65CC )
1327 {
1328 pParty->field_709 = 0;
1329 LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
1330 sub_44A56A();
1331 viewparams->bRedrawGameUI = v0;
1332 dword_5B65CC = 0;
1333 }
1334 goto LABEL_317;
1335 case 19:
1336 memset(GameUI_StatusBar_TimedString, 0, 0xC8u);
1337 sub_4452BB();
1338 goto LABEL_317;
1339 case 17:
1340 if ( pParty->vPosition.x < -22528 )
1341 pParty->vPosition.x = -22528;
1342 if ( pParty->vPosition.x > 22528 )
1343 pParty->vPosition.x = 22528;
1344 if ( pParty->vPosition.y < -22528 )
1345 pParty->vPosition.y = -22528;
1346 if ( pParty->vPosition.y > 22528 )
1347 pParty->vPosition.y = 22528;
1348 goto LABEL_317;
1349 case 16:
1350 pVideoPlayer->Unload();
1351 goto _continue;
1352 case 7:
1353 goto LABEL_319;
1354 default:
1355 goto LABEL_322;
1356 }
1357 goto LABEL_322;
1358 }
1359 LABEL_319:
1360 sub_4196A0();
1361 sub_419379();
1362 LABEL_321:
1363 pIcons_LOD->_4114F2();
1364 }
1365 LABEL_322:
1366 if ( pGUIWindow_Settings )
1367 {
1368 if ( pCurrentScreen == 7 )
1369 {
1370 pMouse->SetCursorBitmap("MICON2");
1371 }
1372 else
1373 {
1374 pGUIWindow_Settings->Release();
1375 pGUIWindow_Settings = 0;
1376 pMouse->SetCursorBitmap("MICON1");
1377 GameUI_StatusBar_TimedStringTimeLeft = 0;
1378 unk_50C9A0 = 0;
1379 back_to_game();
1380 }
1381 }
1382 if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
1383 uActiveCharacter = pParty->GetNextActiveCharacter();
1384 pGUIWindow_CurrentMenu->Release();
1385 if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
1386 ptr_507BC0 = 0;
1387 pGUIWindow_CurrentMenu = 0;
1388 pEventTimer->Resume();
1389 pCurrentScreen = 0;
1390 viewparams->bRedrawGameUI = v0;
1391 pIcons_LOD->_4355F7();
1392 goto _continue;
1393 }
1394 pWindow3 = pGUIWindow_Settings;
1395 if ( !pGUIWindow_Settings )//Draw Menu
1396 {
1397 dword_6BE138 = -1;
1398 GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_GameSettings, v0);
1399 pEventTimer->Pause();
1400 pAudioPlayer->StopChannels(-1, -1);
1401 ++pIcons_LOD->uTexturePacksCount;
1402 pCurrentScreen = v0;
1403 if ( !pIcons_LOD->uNumPrevLoadedFiles )
1404 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
1405 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)3, 0, 0);
1406 uTextureID_507944 = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
1407 uTextureID_507940 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
1408 uTextureID_50793C = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
1409 uTextureID_507938 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE);
1410 uTextureID_507934 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE);
1411 uTextureID_507930 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
1412 uTextureID_50792C = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
1413 pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, v0, 0, 0x7Cu, 0, 0x4Eu,
1414 pGlobalTXT_LocalizationStrings[614],// "New Game"
1415 (Texture *)(uTextureID_507940 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507940] : 0), 0);
1416 pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, v0, 0, 0x7Eu, 0, 0x53u,
1417 pGlobalTXT_LocalizationStrings[615],// "Save Game"
1418 (Texture *)(uTextureID_507938 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507938] : 0), 0);
1419 pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, v0, 0, 0x7Du, 0, 0x4Cu,
1420 pGlobalTXT_LocalizationStrings[616],// "Load Game"
1421 (Texture *)(uTextureID_50793C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50793C] : 0), 0);
1422 pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, v0, 0, 0x7Fu, 0, 0x43u,
1423 pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
1424 (Texture *)(uTextureID_507934 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507934] : 0), 0);
1425 pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, v0, 0, 0x84u, 0, 0x51u,
1426 pGlobalTXT_LocalizationStrings[618],// "Quit"
1427 (Texture *)(uTextureID_50792C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50792C] : 0), 0);
1428 pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, v0, 0, 0x7Bu, 0, 0x52u,
1429 pGlobalTXT_LocalizationStrings[619],// "Return to Game"
1430 (Texture *)(uTextureID_507930 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507930] : 0), 0);
1431 pGUIWindow_CurrentMenu->_41D08F(6, v0, 0, 0);
1432 viewparams->field_48 = v0;
1433 stru_506E40.Release();
1434 uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
1435 pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
1436 free((void *)uNumSeconds);
1437 stru_506E40._40E55E("gamma.pcx", 0);
1438 goto _continue;
1439 }
1440 goto LABEL_333;
1441 }
1442 sub_41426F();
1443 _continue:
1444 continue;
1445 case UIMSG_BC:
1446 if ( uMessageParam )
1447 {
1448 GUIWindow::Create(0x272u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCRight, 0);
1449 v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2;
1450 if ( (unsigned __int8)pParty->field_709 < v37 )
1451 {
1452 ++pParty->field_709;
1453 if ( (unsigned __int8)pParty->field_709 >= v37 )
1454 pParty->field_709 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + pParty->field_70A - 2;
1455 }
1456 }
1457 else
1458 {
1459 GUIWindow::Create(0x1D5u, 0xB3u, 0, 0, (enum WindowType)90, (int)pBtn_NPCLeft, 0);
1460 if ( pParty->field_709 )
1461 {
1462 --pParty->field_709;
1463 if ( pParty->field_709 < 1 )
1464 pParty->field_709 = 0;
1465 }
1466 }
1467 DrawHiredNPCs();
1468 goto _continue;
1469 case UIMSG_OpenRestUI|0x2:
1470 if ( pMessageQueue_50CBD0->uNumMessages )
1471 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1472 dword_50CDC8 = v0;
1473 sub_42FBDD();
1474 HousePlaySomeSound(uCurrentHouse_Animation, 2);
1475 pVideoPlayer->Unload();
1476 sub_44603D();
1477 viewparams->bRedrawGameUI = v0;
1478 if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz )
1479 {
1480 if ( dword_59117C_teleportx )
1481 {
1482 pParty->vPosition.x = dword_59117C_teleportx;
1483 _5B65A8_npcdata_uflags_or_other = dword_59117C_teleportx;
1484 }
1485 if ( dword_591178_teleporty )
1486 {
1487 pParty->vPosition.y = dword_591178_teleporty;
1488 _5B65AC_npcdata_fame_or_other = dword_591178_teleporty;
1489 }
1490 if ( dword_591174_teleportz )
1491 {
1492 pParty->vPosition.z = dword_591174_teleportz;
1493 _5B65B0_npcdata_rep_or_other = dword_591174_teleportz;
1494 pParty->uFallStartY = dword_591174_teleportz;
1495 }
1496 if ( dword_591170_teleport_directiony )
1497 {
1498 pParty->sRotationY = dword_591170_teleport_directiony;
1499 _5B65B4_npcdata_loword_house_or_other = dword_591170_teleport_directiony;
1500 }
1501 if ( dword_59116C_teleport_directionx )
1502 {
1503 pParty->sRotationX = dword_59116C_teleport_directionx;
1504 _5B65B8_npcdata_hiword_house_or_other = dword_59116C_teleport_directionx;
1505 v38 = dword_591168_teleport_speedz;
1506 pParty->uFallSpeed = dword_591168_teleport_speedz;
1507 dword_5B65BC = dword_591168_teleport_speedz;
1508 }
1509 else
1510 {
1511 v38 = dword_5B65BC;
1512 }
1513 if ( *dword_591164_teleport_map_name != 48 )
1514 {
1515 pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2;
1516 dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38;
1517 OnMapLeave();
1518 sub_44987B(dword_591164_teleport_map_name, 0);
1519 }
1520 }
1521 else
1522 {
1523 dword_597F18 = dword_5C341C;
1524 EventProcessor(dword_5C3418, 0, v0);
1525 }
1526 dword_597F18 = 0;
1527 if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
1528 pParty->uTimePlayed += 1474560i64;
1529 goto _continue;
1530 case 0x19C:
1531 sub_42FC15();
1532 pVideoPlayer->Unload();
1533 sub_44603D();
1534 dword_597F18 = 0;
1535 goto LABEL_422;
1536 case UIMSG_CycleCharacters:
1537 v39 = GetAsyncKeyState(VK_SHIFT);
1538 v40 = CycleCharacter(v39);
1539 goto LABEL_421;
1540 case UIMSG_LoadGame|0x8:
1541 if ( pMessageQueue_50CBD0->uNumMessages )
1542 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1543 dword_50CDC8 = v0;
1544 sub_42FBDD();
1545 pNPCData4 = (NPCData *)GetTravelTime();
1546 strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
1547 if ( bUnderwater != 1 && pParty->bFlying
1548 || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, &pOut, 20) != v0 )
1549 {
1550 viewparams->bRedrawGameUI = v0;
1551 LABEL_387:
1552 sub_42FC15();
1553 if ( pParty->vPosition.x < -22528 )
1554 pParty->vPosition.x = -22528;
1555 if ( pParty->vPosition.x > 22528 )
1556 pParty->vPosition.x = 22528;
1557 if ( pParty->vPosition.y < -22528 )
1558 pParty->vPosition.y = -22528;
1559 if ( pParty->vPosition.y > 22528 )
1560 pParty->vPosition.y = 22528;
1561 LABEL_317:
1562 sub_44603D();
1563 pCurrentScreen = 0;
1564 }
1565 else
1566 {
1567 pParty->field_6E4 = 0;
1568 pParty->field_6E0 = 0;
1569 pStru277->_427D48(v0);
1570 sub_44603D();
1571 pEventTimer->Pause();
1572 pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)2);
1573 ++pGameLoadingUI_ProgressBar->uProgressMax;
1574 SaveGame(v0, 0);
1575 pGameLoadingUI_ProgressBar->Progress();
1576 RestAndHeal(1440 * (signed int)pNPCData4);
1577 if ( pParty->uNumFoodRations )
1578 {
1579 pParty->RestAndHeal();
1580 if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 )
1581 {
1582 pPlayer7 = pParty->pPlayers;
1583 do
1584 {
1585 pPlayer7->SetCondition(v0, 0);
1586 ++pPlayer7;
1587 }
1588 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
1589 ++pParty->field_764;
1590 }
1591 Party::TakeFood((unsigned int)pNPCData4);
1592 }
1593 else
1594 {
1595 pPlayer8 = pParty->pPlayers;
1596 do
1597 {
1598 pPlayer8->SetCondition(v0, 0);
1599 ++pPlayer8;
1600 }
1601 while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings );
1602 ++pParty->field_764;
1603 }
1604 pPaletteManager->ResetNonLocked();
1605 pSpriteFrameTable->ResetSomeSpriteFlags();
1606 strcpy(pCurrentMapName, &pOut);
1607 strcpy(&pLevelName, pCurrentMapName);
1608 v41 = strtok(&pLevelName, ".");
1609 strcpy(&pLevelName, v41);
1610 Level_LoadEvtAndStr(&pLevelName);
1611 pDecalBuilder->Reset( 0);
1612 LoadLevel_InitializeLevelEvt();
1613 uLevelMapStatsID = pMapStats->GetMapInfo(pCurrentMapName);
1614 bUnderwater = 0;
1615 bNoNPCHiring = 0;
1616 pGame->uFlags2 &= 0xFFFFFFF7u;
1617 if ( Is_out15odm_underwater() )
1618 {
1619 bUnderwater = 1;
1620 pGame->uFlags2 |= 8u;
1621 }
1622 if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d47.blv") )
1623 bNoNPCHiring = 1;
1624 v0 = 1;
1625 PrepareToLoadODM(1u, (OutdoorCamera *)1);
1626 pAudioPlayer->SetMapEAX();
1627 bDialogueUI_InitializeActor_NPC_ID = 0;
1628 OnMapLoad();
1629 pOutdoor->SetFog();
1630 TeleportToStartingPoint(uLevel_StartingPointType);
1631 pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, (int *)&v213, 0);
1632 pParty->uFallStartY = pParty->vPosition.z;
1633 sub_461103();
1634 pEventTimer->Resume();
1635 viewparams->bRedrawGameUI = 1;
1636 pCurrentScreen = 0;
1637 pGameLoadingUI_ProgressBar->Release();
1638 }
1639 goto LABEL_422;
1640 case UIMSG_SaveGame|0x8:
1641 goto LABEL_387;
1642 case UIMSG_BE:
1643 if ( pRenderer->pRenderD3D )
1644 {
1645 LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val();
1646 }
1647 else
1648 {
1649 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210);
1650 pPoint = pMouse->GetCursorPos(&v208);
1651 v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]];
1652 }
1653 v44 = (unsigned __int16)v42;
1654 v45 = v44 & 7;
1655 uNumSeconds = v44;
1656 v46 = v44 >> 3;
1657 if ( v45 == 3 )
1658 {
1659 v47 = pActors[v46].uAIState == Dead;
1660 goto LABEL_400;
1661 }
1662 if ( v45 == 2 )
1663 {
1664 v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
1665 LABEL_400:
1666 if ( !v47 )
1667 goto _continue;
1668 goto LABEL_415;
1669 }
1670 if ( v45 == 5 )
1671 {
1672 v48 = pLevelDecorations[v46].field_16_event_id == 0;
1673 }
1674 else
1675 {
1676 if ( v45 != 6 )
1677 goto _continue;
1678 if ( uCurrentlyLoadedLevelType != v0 )
1679 {
1680 pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
1681 if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
1682 goto _continue;
1683 v44 = uNumSeconds;
1684 goto LABEL_415;
1685 }
1686 pBLVFace = &pIndoor->pFaces[v46];
1687 if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
1688 goto _continue;
1689 v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0;
1690 }
1691 if ( v48 )
1692 goto _continue;
1693 LABEL_415:
1694 v51 = pGUIWindow_Settings->ptr_1C;
1695 *((char *)v51 + 8) &= 0xBFu;
1696 LABEL_416:
1697 *((short *)v51 + 2) = uMessageParam;
1698 *((int *)v51 + 3) = v44;
1699 pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
1700 pWindow3 = pGUIWindow_Settings;
1701 LABEL_333:
1702 pWindow3->Release();
1703 pGUIWindow_Settings = 0;
1704 pMouse->SetCursorBitmap("MICON1");
1705 GameUI_StatusBar_TimedStringTimeLeft = 0;
1706 unk_50C9A0 = 0;
1707 back_to_game();
1708 goto _continue;
1709 case UIMSG_ChangeGameState|0x40:
1710 case 0x8D:
1711 case 0x8F:
1712 if ( pMessageQueue_50CBD0->uNumMessages )
1713 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1714 if ( unk_50C9A0 )
1715 {
1716 v40 = uMessageParam;
1717 LABEL_421:
1718 uActiveCharacter = v40;
1719 LABEL_422:
1720 viewparams->bRedrawGameUI = v0;
1721 }
1722 else
1723 {
1724 if ( pGUIWindow_Settings )
1725 {
1726 v52 = pGUIWindow_Settings->ptr_1C;
1727 switch ( uMessage )
1728 {
1729 case 69:
1730 *((char *)v52 + 8) &= 0xFDu;
1731 break;
1732 case 141:
1733 *((char *)v52 + 9) &= 0xFEu;
1734 break;
1735 case 143:
1736 *((char *)v52 + 9) &= 0xFDu;
1737 break;
1738 }
1739 *((short *)v52 + 2) = uMessageParam;
1740 pParty->pPlayers[*((short *)v52 + 1)].SetRecoveryTime(300);
1741 pGUIWindow_Settings->Release();
1742 pGUIWindow_Settings = 0;
1743 pEventTimer->Resume();
1744 pMouse->SetCursorBitmap("MICON1");
1745 GameUI_StatusBar_TimedStringTimeLeft = 0;
1746 unk_50C9A0 = 0;
1747 }
1748 }
1749 goto _continue;
1750 case UIMSG_BF:
1751 dword_50CDC8 = v0;
1752 sub_42FBDD();
1753 SaveGame(v0, 0);
1754 strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename);
1755 dword_6BE364_game_settings_1 |= v0;
1756 uGameState = 2;
1757 //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
1758 v53 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1]._quest_related;
1759 if ( v53 < 0 )
1760 {
1761 v54 = abs(v53) - 1;
1762 _5B65B8_npcdata_hiword_house_or_other = 0;
1763 dword_5B65BC = 0;
1764 v55 = dword_4E4560[v54];
1765 _5B65AC_npcdata_fame_or_other = dword_4E4578[v54];
1766 v56 = dword_4E4590[v54];
1767 v57 = dword_4E45A8[v54];
1768 _5B65A8_npcdata_uflags_or_other = v55;
1769 _5B65B4_npcdata_loword_house_or_other = v57;
1770 _5B65B0_npcdata_rep_or_other = v56;
1771 dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
1772 }
1773 sub_4BD8B5();
1774 goto LABEL_434;
1775 case UIMSG_C3:
1776 pAudioPlayer->StopChannels(-1, -1);
1777 v162 = uMessageParam;
1778 v148 = 195;
1779 goto LABEL_438;
1780 case UIMSG_B1:
1781 pAudioPlayer->StopChannels(-1, -1);
1782 v162 = 0;
1783 v148 = 177;
1784 LABEL_438:
1785 pWindowType = (WindowType)9;
1786 LABEL_439:
1787 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
1788 goto _continue;
1789 case UIMSG_B2:
1790 v165 = 0;
1791 v151 = 0;
1792 v144 = 0;
1793 v139 = 0;
1794 bRecallingBeacon = uMessageParam;
1795 v135 = -1;
1796 v132 = 0;
1797 v130 = 0;
1798 v127 = uMessageParam + 204;
1799 goto _play_sound_and_continue;
1800 case UIMSG_B4:
1801 if ( !pGUIWindow_CurrentMenu )
1802 goto _continue;
1803 pPlayer = pPlayers[_506348_current_lloyd_playerid + 1];
1804 uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
1805 if ( bRecallingBeacon )
1806 {
1807 if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) )
1808 goto _continue;
1809 v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
1810 v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s"
1811 goto _sprintex_2args_draw_status_and_continue;
1812 }
1813 v59 = pMapStats->GetMapInfo(pCurrentMapName);
1814 thise = "Not in Map Stats";
1815 if ( v59 )
1816 thise = pMapStats->pInfos[v59].pName;
1817 if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) || !v59 )
1818 {
1819 v173 = thise;
1820 v157 = pGlobalTXT_LocalizationStrings[476];// "Set to %s"
1821 goto _sprintex_2args_draw_status_and_continue;
1822 }
1823 v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
1824 v158 = (unsigned int)thise;
1825 v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
1826 _sprintex_draw_status_and_continue:
1827 sprintf(pTmpBuf, v146, v158, v174);
1828 goto _set_status_string_pTmpBuf_and_continue;
1829 case UIMSG_B5:
1830 dword_50CDC8 = v0;
1831 goto LABEL_453;
1832 case UIMSG_B3:
1833 pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
1834 pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
1835 if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
1836 goto _continue;
1837 byte_506360 = 1;
1838 pPlayer9->CanCastSpell(uRequiredMana);
1839 if ( pParty->bTurnBasedModeOn )
1840 {
1841 v60 = sRecoveryTime;
1842 pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime;
1843 pPlayer9->SetRecoveryTime(v60);
1844 pTurnEngine->_40471C();
1845 }
1846 else
1847 {
1848 pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
1849 }
1850 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
1851 if ( bRecallingBeacon )
1852 {
1853 if ( _strcmpi(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
1854 {
1855 SaveGame(v0, 0);
1856 OnMapLeave();
1857 strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]);
1858 dword_6BE364_game_settings_1 |= v0;
1859 uGameState = 2;
1860 _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags;
1861 _5B65AC_npcdata_fame_or_other = pNPCData4->fame;
1862 _5B65B0_npcdata_rep_or_other = pNPCData4->rep;
1863 _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->house);
1864 _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->house);
1865 dword_5B65C0 = v0;
1866 }
1867 else
1868 {
1869 pParty->vPosition.x = pNPCData4->uFlags;
1870 pParty->vPosition.y = pNPCData4->fame;
1871 pParty->vPosition.z = pNPCData4->rep;
1872 pParty->uFallStartY = pParty->vPosition.z;
1873 pParty->sRotationY = LOWORD(pNPCData4->house);
1874 pParty->sRotationX = HIWORD(pNPCData4->house);
1875 }
1876 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
1877 {
1878 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
1879 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
1880 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
1881 ++pMessageQueue_50CBD0->uNumMessages;
1882 }
1883 //crt_deconstruct_ptr_6A0118();
1884 pBooksWindow->Release();
1885 pGUIWindow_CurrentMenu->Release();
1886 pBooksWindow = 0;
1887 pGUIWindow_CurrentMenu = 0;
1888 }
1889 else
1890 {
1891 sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
1892 SaveScreenshot(a1);
1893 LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
1894 v212 = qword_506350 << 7;
1895 pNPCData2 = pNPCData4;
1896 thisg = 0;
1897 v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
1898 pNPCData4->pName = (char *)v62;
1899 pNPCData2->uPortraitID = HIDWORD(v62);
1900 pNPCData2->uFlags = pParty->vPosition.x;
1901 pNPCData2->fame = pParty->vPosition.y;
1902 pNPCData2->rep = pParty->vPosition.z;
1903 LOWORD(pNPCData2->house) = LOWORD(pParty->sRotationY);
1904 HIWORD(pNPCData2->house) = LOWORD(pParty->sRotationX);
1905 if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
1906 goto _continue;
1907 uAction = 0;
1908 while ( _strcmpi((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
1909 {
1910 ++thisg;
1911 uAction += 32;
1912 if ( thisg >= (signed int)pGames_LOD->uNumSubIndices / 2 )
1913 goto _continue;
1914 }
1915 HIWORD(pNPCData4->uProfession) = thisg;
1916 }
1917 goto _continue;
1918 case UIMSG_B7:
1919 if ( uMessageParam )
1920 {
1921 switch ( uMessageParam )
1922 {
1923 case 1:
1924 v63 = 208;
1925 break;
1926 case 2:
1927 v63 = 207;
1928 break;
1929 case 3:
1930 v63 = 211;
1931 break;
1932 case 4:
1933 v63 = 209;
1934 break;
1935 default:
1936 if ( uMessageParam != 5 )
1937 {
1938 LABEL_486:
1939 SaveGame(v0, 0);
1940 v64 = pMapStats->GetMapInfo(pCurrentMapName);
1941 v65 = uMessageParam;
1942 if ( v64 == stru_4ECBB8[uMessageParam].uMapInfoID )
1943 {
1944 pParty->vPosition.x = stru_4ECBB8[v65].pos.x;
1945 pParty->vPosition.y = stru_4ECBB8[v65].pos.y;
1946 pParty->vPosition.z = stru_4ECBB8[v65].pos.z;
1947 pParty->uFallStartY = pParty->vPosition.z;
1948 pParty->sRotationY = stru_4ECBB8[v65].rot_y;
1949 pParty->sRotationX = stru_4ECBB8[v65].rot_x;
1950 }
1951 else
1952 {
1953 SaveGame(v0, 0);
1954 OnMapLeave();
1955 dword_6BE364_game_settings_1 |= v0;
1956 uGameState = 2;
1957 strcpy(pCurrentMapName, pMapStats->pInfos[stru_4ECBB8[uMessageParam].uMapInfoID].pFilename);
1958 dword_5B65C0 = v0;
1959 _5B65A8_npcdata_uflags_or_other = stru_4ECBB8[uMessageParam].pos.x;
1960 _5B65AC_npcdata_fame_or_other = stru_4ECBB8[uMessageParam].pos.y;
1961 _5B65B0_npcdata_rep_or_other = stru_4ECBB8[uMessageParam].pos.z;
1962 v66 = stru_4ECBB8[uMessageParam].rot_x;
1963 _5B65B4_npcdata_loword_house_or_other = stru_4ECBB8[uMessageParam].rot_y;
1964 _5B65B8_npcdata_hiword_house_or_other = v66;
1965 InitializeActors();
1966 }
1967 v67 = pGUIWindow_CurrentMenu->Hint;
1968 if ( v67 )
1969 *((int *)v67 + 17) = v0;
1970 else
1971 pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
1972 LABEL_434:
1973 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
1974 {
1975 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
1976 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
1977 LABEL_771:
1978 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
1979 ++pMessageQueue_50CBD0->uNumMessages;
1980 }
1981 goto _continue;
1982 }
1983 v63 = 210;
1984 break;
1985 }
1986 }
1987 else
1988 {
1989 v63 = 206;
1990 }
1991 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v63) )
1992 return;
1993 goto LABEL_486;
1994 case UIMSG_B6:
1995 if ( uMessageParam )
1996 {
1997 switch ( uMessageParam )
1998 {
1999 case 1:
2000 v68 = 208;
2001 break;
2002 case 2:
2003 v68 = 207;
2004 break;
2005 case 3:
2006 v68 = 211;
2007 break;
2008 case 4:
2009 v68 = 209;
2010 break;
2011 default:
2012 if ( uMessageParam != 5 )
2013 goto LABEL_506;
2014 v68 = 210;
2015 break;
2016 }
2017 }
2018 else
2019 {
2020 v68 = 206;
2021 }
2022 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v68) )
2023 {
2024 pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
2025 goto _continue;
2026 }
2027 LABEL_506:
2028 if ( uMessageParam )
2029 {
2030 switch ( uMessageParam )
2031 {
2032 case 1:
2033 v69 = pMapStats->pInfos[4].pName;
2034 break;
2035 case 2:
2036 v69 = pMapStats->pInfos[3].pName;
2037 break;
2038 case 3:
2039 v69 = pMapStats->pInfos[10].pName;
2040 break;
2041 case 4:
2042 v69 = pMapStats->pInfos[7].pName;
2043 break;
2044 default:
2045 if ( uMessageParam != 5 )
2046 //goto LABEL_519;
2047 {
2048 v173 = v200;
2049 v157 = pGlobalTXT_LocalizationStrings[35];
2050 goto _sprintex_2args_draw_status_and_continue;
2051 }
2052 v69 = pMapStats->pInfos[8].pName;
2053 break;
2054 }
2055 }
2056 else
2057 {
2058 v69 = pMapStats->pInfos[21].pName;
2059 }
2060 v200 = v69;
2061 //LABEL_519:
2062 v173 = v200;
2063 v157 = pGlobalTXT_LocalizationStrings[35];
2064 goto _sprintex_2args_draw_status_and_continue;
2065 case UIMSG_ShowFinalWindow:
2066 sprintf(pFinalMessage, "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer."
2067 pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment."
2068 pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team."
2069 ModalWindow(pFinalMessage, 196);
2070 uGameState = GAME_STATE_FINAL_WINDOW;
2071 goto _continue;
2072 case UIMSG_C4:
2073 uGameState = 0;
2074 strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
2075 goto LABEL_524;
2076 case UIMSG_D5|0x8:
2077 LABEL_524:
2078 sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer);
2079 memcpy(&v216, texture_frame_table_txt_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216));
2080 if ( v216.field_0 == 1 )
2081 {
2082 pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubIndices / 2);
2083 v70 = atoi(v216.pProperties[0]);
2084 if ( v70 <= 0 || v70 >= 77 )
2085 {
2086 LABEL_90:
2087 v1 = "";
2088 LABEL_91:
2089 v0 = 1;
2090 goto _continue;
2091 }
2092 v71 = v70;
2093 strcpy(Str2, pMapStats->pInfos[v70].pFilename);
2094 pNPCData3 = 0;
2095 if ( (signed int)pNPCData4 > 0 )
2096 {
2097 thish = 0;
2098 do
2099 {
2100 if ( !_strcmpi((const char *)&pGames_LOD->pSubIndices[thish], Str2) )
2101 break;
2102 ++thish;
2103 pNPCData3 = (NPCData *)((char *)pNPCData3 + 1);
2104 }
2105 while ( (signed int)pNPCData3 < (signed int)pNPCData4 );
2106 if ( (signed int)pNPCData3 < (signed int)pNPCData4 )
2107 {
2108 strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[(int)pNPCData3]);
2109 dword_6BE364_game_settings_1 |= 1u;
2110 uGameState = 2;
2111 OnMapLeave();
2112 //goto LABEL_90;
2113 v1 = "";
2114 v0 = 1;
2115 goto _continue;
2116 }
2117 }
2118 sprintf(Str2, "No map found for %s", pMapStats->pInfos[v71].pName);
2119 v73 = Str2;
2120 }
2121 else
2122 {
2123 if ( v216.field_0 != 3 )
2124 goto LABEL_90;
2125 v74 = atoi(v216.pProperties[0]);
2126 thisi = atoi(v216.pProperties[1]);
2127 v75 = atoi(v216.pProperties[2]);
2128 v76 = v75;
2129 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
2130 {
2131 if ( pIndoor->GetSector(v74, thisi, v75) )
2132 {
2133 v77 = thisi;
2134 LABEL_544:
2135 pParty->vPosition.x = v74;
2136 pParty->vPosition.y = v77;
2137 pParty->vPosition.z = v76;
2138 pParty->uFallStartY = v76;
2139 goto LABEL_90;
2140 }
2141 }
2142 else
2143 {
2144 if ( v74 > -32768 )
2145 {
2146 if ( v74 < 32768 )
2147 {
2148 v77 = thisi;
2149 if ( thisi > -32768 )
2150 {
2151 if ( thisi < 32768 && v76 >= 0 && v76 < 10000 )
2152 goto LABEL_544;
2153 }
2154 }
2155 }
2156 }
2157 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
2158 v73 = "Can't jump to that location!";
2159 }
2160 ShowStatusBarString(v73, 6u);
2161 //goto LABEL_90;
2162 v1 = "";
2163 v0 = 1;
2164 goto _continue;
2165 case 0x19:
2166 if ( bUnderwater == 1 )
2167 goto LABEL_682;
2168 if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) )
2169 goto LABEL_90;
2170 v79 = pPlayer2->uQuickSpell;
2171 v175 = uActiveCharacter;
2172 v159 = 0;
2173 v147 = 0;
2174 v80 = uActiveCharacter - 1;
2175 goto LABEL_679;
2176 case 0x46:
2177 case UIMSG_Quit|0x8:
2178 if ( pRenderer->pRenderD3D )
2179 {
2180 v81 = pGame->pVisInstance->get_picked_object_zbuf_val();
2181 }
2182 else
2183 {
2184 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206);
2185 pPoint2 = pMouse->GetCursorPos(&v201);
2186 v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint2->y]];
2187 }
2188 v83 = v81;
2189 v44 = (unsigned __int16)v81;
2190 v84 = v83 >> 16;
2191 if ( (v44 & 7) != 3 || v84 >= 5120 )
2192 //goto LABEL_90;
2193 {
2194 v1 = "";
2195 v0 = 1;
2196 goto _continue;
2197 }
2198 v51 = pGUIWindow_Settings->ptr_1C;
2199 if ( uMessage == 70 )
2200 {
2201 *((char *)v51 + 8) &= 0xF7u;
2202 }
2203 else
2204 {
2205 if ( uMessage == 140 )
2206 *((char *)v51 + 9) &= 0xFEu;
2207 else
2208 *((char *)v51 + 9) &= 0xFDu;
2209 }
2210 goto LABEL_416;
2211 case 0x1C:
2212 if ( !uActiveCharacter || pCurrentScreen )
2213 //goto LABEL_90;
2214 {
2215 v1 = "";
2216 v0 = 1;
2217 goto _continue;
2218 }
2219 ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0);
2220 pCurrentScreen = 25;
2221 pEventTimer->Pause();
2222 goto _continue;
2223 case 0x1B:
2224 if ( !uActiveCharacter )
2225 //goto LABEL_90;
2226 {
2227 v1 = "";
2228 v0 = 1;
2229 goto _continue;
2230 }
2231 if ( pParty->bTurnBasedModeOn != v0 )
2232 goto LABEL_569;
2233 if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
2234 //goto LABEL_90;
2235 {
2236 v1 = "";
2237 v0 = 1;
2238 goto _continue;
2239 }
2240 if ( !(pTurnEngine->field_18 & 2) )
2241 {
2242 LABEL_569:
2243 if ( pActors[uMessageParam].uAIState == 5 )
2244 stru_50C198.LootActor(&pActors[uMessageParam]);
2245 else
2246 Actor::StealFrom(uMessageParam);
2247 }
2248 goto _continue;
2249 case 0x17:
2250 if ( !uActiveCharacter )
2251 //goto LABEL_90;
2252 {
2253 v1 = "";
2254 v0 = 1;
2255 goto _continue;
2256 }
2257 if ( pParty->bTurnBasedModeOn != v0 )
2258 goto LABEL_577;
2259 if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
2260 //goto LABEL_90;
2261 {
2262 v1 = "";
2263 v0 = 1;
2264 goto _continue;
2265 }
2266 if ( !(pTurnEngine->field_18 & 2) )
2267 LABEL_577:
2268 _42ECB5_PlayerAttacksActor();
2269 goto _continue;
2270 case UIMSG_A7:
2271 v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest"
2272 pButton = pButton_RestUI_Exit;
2273 pButton2 = pButton_RestUI_Exit;
2274 pWindowType1 = (WindowType)96;
2275 goto LABEL_731;
2276 case UIMSG_ShowStatus_Player|0x1:
2277 if ( dword_506F14 == 2 )
2278 goto LABEL_621;
2279 GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, (enum WindowType)90,
2280 (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
2281 dword_506F14 = v0;
2282 _506F18_num_hours_to_sleep = 5;
2283 goto _continue;
2284 case 0x60:
2285 if ( dword_506F14 == 2 )
2286 goto LABEL_621;
2287 GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, (enum WindowType)90,
2288 (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
2289 dword_506F14 = v0;
2290 _506F18_num_hours_to_sleep = 60;
2291 goto _continue;
2292 case UIMSG_OpenRestUI:
2293 dword_506F14 = 2;
2294 RestUI_Initialize();
2295 v86 = 60 * (sub_494820(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
2296 _506F18_num_hours_to_sleep = v86;
2297 if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
2298 _506F18_num_hours_to_sleep = v86 + 720;
2299 goto LABEL_615;
2300 case 0x68:
2301 if ( pMessageQueue_50CBD0->uNumMessages )
2302 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2303 if ( pCurrentScreen )
2304 goto _continue;
2305 if ( sub_42F4DA() )
2306 goto LABEL_594;
2307 if ( pParty->bTurnBasedModeOn == v0 )
2308 goto LABEL_595;
2309 if ( !(pParty->uFlags & 0x88) )
2310 {
2311 RestUI_Initialize();
2312 goto _continue;
2313 }
2314 LABEL_594:
2315 if ( pParty->bTurnBasedModeOn == v0 )
2316 {
2317 LABEL_595:
2318 v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
2319 goto _draw_status_string_and_continue;
2320 }
2321 v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
2322 if ( pParty->uFlags & 0x88 )
2323 v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
2324 ShowStatusBarString(v88, 2u);
2325 v89 = uActiveCharacter;
2326 if ( !uActiveCharacter )
2327 //goto LABEL_90;
2328 {
2329 v1 = "";
2330 v0 = 1;
2331 goto _continue;
2332 }
2333 v176 = 0;
2334 v160 = 13;
2335 goto LABEL_619;
2336 case 0x61:
2337 if ( dword_506F14 )
2338 goto LABEL_621;
2339 if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest )
2340 {
2341 ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
2342 if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() )
2343 {
2344 v89 = uActiveCharacter;
2345 v176 = 0;
2346 v160 = 108;
2347 LABEL_619:
2348 pPlayers[v89]->PlaySound(v160, v176);
2349 }
2350 }
2351 else
2352 {
2353 pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
2354 pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
2355 pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
2356 pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
2357 v90 = pMapStats->GetMapInfo(pCurrentMapName);
2358 if ( !v90 )
2359 v90 = rand() % (signed int)pMapStats->uNumMaps + 1;
2360 pMapInfo = &pMapStats->pInfos[v90];
2361 if ( rand() % 100 + 1 <= pMapInfo->field_30 )
2362 {
2363 v91 = rand() % 100;
2364 v92 = pMapInfo->field_31;
2365 v93 = v91 + 1;
2366 if ( v93 > v92 )
2367 pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->field_32) + 2);
2368 else
2369 pNPCData4 = (NPCData *)v0;
2370 if ( !sub_45063B(pMapInfo, (int)pNPCData4) )
2371 pNPCData4 = 0;
2372 if ( pNPCData4 )
2373 {
2374 pPlayerNum = rand() % 4;
2375 LODWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
2376 HIDWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
2377 v95 = rand();
2378 Rest(v95 % 6 + 60);
2379 _506F18_num_hours_to_sleep = 0;
2380 dword_506F14 = 0;
2381 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2382 {
2383 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2384 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
2385 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2386 ++pMessageQueue_50CBD0->uNumMessages;
2387 }
2388 ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!"
2389 v165 = 0;
2390 v151 = 0;
2391 v144 = 0;
2392 v139 = 0;
2393 v135 = -1;
2394 v132 = 0;
2395 v130 = 0;
2396 v127 = 227;
2397 goto _play_sound_and_continue;
2398 }
2399 }
2400 Party::TakeFood(uRestUI_FoodRequiredToRest);
2401 _506F18_num_hours_to_sleep = 480;
2402 LABEL_615:
2403 dword_506F14 = 2;
2404 pParty->RestAndHeal();
2405 pParty->field_764 = 0;
2406 pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
2407 pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
2408 pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
2409 pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
2410 }
2411 goto _continue;
2412 case UIMSG_ShowStatus_Funds|0x8:
2413 if ( dword_506F14 == 2 )
2414 {
2415 LABEL_621:
2416 v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
2417 goto LABEL_622;
2418 }
2419 GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, (enum WindowType)90,
2420 (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
2421 v97 = sub_494820(pParty->uCurrentHour);
2422 dword_506F14 = v0;
2423 _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
2424 goto _continue;
2425 case 0x4E:
2426 if ( dword_50654C && byte_506550 )
2427 {
2428 v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName;
2429 v157 = pGlobalTXT_LocalizationStrings[483];
2430 _sprintex_2args_draw_status_and_continue:
2431 sprintf(pTmpBuf, v157, v173);
2432 }
2433 else
2434 {
2435 if ( pPlayers[uActiveCharacter]->uQuickSpell )
2436 v177 = pGlobalTXT_LocalizationStrings[584];// "Click here to remove your Quick Spell"
2437 else
2438 v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
2439 strcpy(pTmpBuf, v177);
2440 }
2441 _set_status_string_pTmpBuf_and_continue:
2442 sub_41C0B8_set_status_string(pTmpBuf);
2443 goto _continue;
2444 case 0x4F:
2445 if ( !uActiveCharacter
2446 || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
2447 !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) )
2448 goto _continue;
2449 if ( sub_4637E0_is_there_popup_onscreen() )
2450 dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1;
2451 v98 = *(char *)(uNumSeconds + 6734);
2452 if ( dword_50654C - 1 == uMessageParam )
2453 {
2454 v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
2455 v161 = pGlobalTXT_LocalizationStrings[485];
2456 }
2457 else
2458 {
2459 v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
2460 v161 = pGlobalTXT_LocalizationStrings[486];
2461 }
2462 sprintf(pTmpBuf, v161, v178);
2463 sub_41C0B8_set_status_string(pTmpBuf);
2464 goto LABEL_91;
2465 case 0x58:
2466 GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
2467 if ( !uActiveCharacter )
2468 goto _continue;
2469 pPlayer10 = pPlayers[uActiveCharacter];
2470 if ( !byte_506550 || !dword_50654C )
2471 {
2472 v165 = 0;
2473 v151 = 0;
2474 v144 = 0;
2475 v139 = 0;
2476 v135 = -1;
2477 v132 = 0;
2478 pPlayer10->uQuickSpell = 0;
2479 v130 = 0;
2480 dword_50654C = 0;
2481 v127 = 203;
2482 goto _play_sound_and_continue;
2483 }
2484 v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage;
2485 pPlayers[uActiveCharacter]->uQuickSpell = v99;
2486 stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
2487 if ( uActiveCharacter )
2488 pPlayer10->PlaySound(12, 0);
2489 byte_506550 = 0;
2490 goto _continue;
2491 case 0x33:
2492 if ( !uActiveCharacter )
2493 goto _continue;
2494 pPlayer3 = pPlayers[uActiveCharacter];
2495 pNPCData4 = 0;
2496 uAction = 0;
2497 v101 = 0;
2498 thisl = (int)&pPlayer3->pActiveSkills[12];
2499 do
2500 {
2501 if ( *(short *)thisl )
2502 {
2503 if ( pPlayer3->pNumSpellBookPage == v101 )
2504 uAction = (int)pNPCData4;
2505 v102 = (int)pNPCData4;
2506 pNPCData4 = (NPCData *)((char *)pNPCData4 + 1);
2507 v217[v102] = v101;
2508 }
2509 thisl += 2;
2510 ++v101;
2511 }
2512 while ( v101 < 9 );
2513 if ( !pNPCData4 )
2514 goto LABEL_662;
2515 if ( GetAsyncKeyState(16) )
2516 {
2517 --uAction;
2518 if ( uAction < 0 )
2519 uAction = (int)((char *)pNPCData4 - 1);
2520 }
2521 else
2522 {
2523 ++uAction;
2524 if ( uAction >= (signed int)pNPCData4 )
2525 uAction = 0;
2526 }
2527 sub_41140B();
2528 pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
2529 goto LABEL_661;
2530 case UIMSG_SaveGame|0x4:
2531 if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
2532 goto _continue;
2533 sub_41140B();
2534 pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
2535 LABEL_661:
2536 pGUIWindow_CurrentMenu->_411621();
2537 LABEL_662:
2538 v165 = 0;
2539 v151 = 0;
2540 v144 = 0;
2541 v139 = 0;
2542 v135 = -1;
2543 v132 = 0;
2544 v130 = 0;
2545 v127 = rand() % 2 + 204;
2546 goto _play_sound_and_continue;
2547 case UIMSG_LoadGame|0x4:
2548 if ( pTurnEngine->field_4 != 3 )
2549 {
2550 if ( uActiveCharacter )
2551 {
2552 uNumSeconds = (unsigned int)pPlayers[uActiveCharacter];
2553 if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402) )
2554 {
2555 if ( dword_50654C - 1 == uMessageParam )
2556 {
2557 pGUIWindow_CurrentMenu->Release();
2558 pEventTimer->Resume();
2559 viewparams->bRedrawGameUI = v0;
2560 pCurrentScreen = 0;
2561 pIcons_LOD->_4114F2();
2562 v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734);
2563 if ( dword_50C9E8 < 40 )
2564 {
2565 dword_50C9EC[3 * dword_50C9E8] = 142;
2566 dword_50C9F0[3 * dword_50C9E8] = v103;
2567 *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = uActiveCharacter - 1;
2568 ++dword_50C9E8;
2569 }
2570 }
2571 else
2572 {
2573 byte_506550 = 1;
2574 dword_50654C = uMessageParam + 1;
2575 }
2576 }
2577 }
2578 }
2579 goto _continue;
2580 case 0x8E:
2581 if ( pTurnEngine->field_4 == 3 )
2582 goto _continue;
2583 v175 = 0;
2584 v159 = 0;
2585 v147 = 0;
2586 goto LABEL_678;
2587 case 0x92:
2588 if ( pTurnEngine->field_4 != 3 )
2589 {
2590 v175 = 0;
2591 v159 = v0;
2592 v147 = 133;
2593 LABEL_678:
2594 v80 = v199;
2595 v79 = uMessageParam;
2596 LABEL_679:
2597 _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
2598 }
2599 goto _continue;
2600 case 0x69:
2601 if ( pTurnEngine->field_4 == 3 )
2602 goto _continue;
2603 if ( bUnderwater == 1 )
2604 {
2605 LABEL_682:
2606 v96 = pGlobalTXT_LocalizationStrings[652];// "You can not do that while you are underwater!"
2607 LABEL_622:
2608 ShowStatusBarString(v96, 2u);
2609 LABEL_623:
2610 v165 = 0;
2611 v151 = 0;
2612 v144 = 0;
2613 v139 = 0;
2614 v135 = -1;
2615 v132 = 0;
2616 v130 = 0;
2617 v127 = 27;
2618 _play_sound_and_continue:
2619 pAudioPlayer->PlaySound((SoundID)v127, v130, v132, v135, v139, v144, v151, v165);
2620 }
2621 else
2622 {
2623 if ( pMessageQueue_50CBD0->uNumMessages )
2624 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2625 if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
2626 {
2627 if ( !pCurrentScreen )
2628 goto LABEL_693;
2629 if ( pCurrentScreen != 5
2630 && pCurrentScreen != 7
2631 && (pCurrentScreen <= 99
2632 || pCurrentScreen > 103) )
2633 {
2634 pGUIWindow_CurrentMenu->Release();
2635 LABEL_693:
2636 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
2637 pCurrentScreen = 8;
2638 pEventTimer->Pause();
2639 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
2640 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
2641 viewparams->field_48 = v0;
2642 goto _continue;
2643 }
2644 }
2645 }
2646 goto _continue;
2647 case 0x6A:
2648 if ( pMessageQueue_50CBD0->uNumMessages )
2649 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2650 if ( pCurrentScreen )
2651 pGUIWindow_CurrentMenu->Release();
2652 ++pIcons_LOD->uTexturePacksCount;
2653 if ( !pIcons_LOD->uNumPrevLoadedFiles )
2654 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
2655 GUIWindow::Create(0x230u, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_QuickReference, 0);
2656 viewparams->bRedrawGameUI = v0;
2657 pEventTimer->Pause();
2658 pAudioPlayer->StopChannels(-1, -1);
2659 pCurrentScreen = 104;
2660 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)12, 5, 0);
2661 papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
2662 pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, v0, 0, 0x71u, 0, 0,
2663 pGlobalTXT_LocalizationStrings[79],// "Exit"
2664 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0, v179);
2665 goto _continue;
2666 case 0x6B:
2667 if ( pCurrentScreen )
2668 {
2669 pGUIWindow_CurrentMenu->Release();
2670 pEventTimer->Resume();
2671 pCurrentScreen = 0;
2672 viewparams->bRedrawGameUI = v0;
2673 }
2674 stru_506E40.Release();
2675 uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
2676 pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
2677 free((void *)uNumSeconds);
2678 stru_506E40._40E55E("gamma.pcx", 0);
2679 GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
2680 LABEL_453:
2681 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
2682 goto _continue;
2683 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2684 goto LABEL_770;
2685 case UIMSG_C0:
2686 dword_50651C = v0;
2687 if ( pMouse->GetCursorPos(&v211)->y > 178 )
2688 dword_50651C = -1;
2689 goto _continue;
2690 case UIMSG_A9:
2691 GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
2692 LABEL_707:
2693 dword_506548 = v0;
2694 goto _continue;
2695 case UIMSG_AA:
2696 GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
2697 LABEL_709:
2698 dword_506544 = v0;
2699 goto _continue;
2700 case 0x55:
2701 bRingsShownInCharScreen ^= v0;
2702 GUIButton::_41D0D8(pCharacterScreen_DetalizBtn);
2703 GUIButton::_41D0D8(pCharacterScreen_DollBtn);
2704 if ( bRingsShownInCharScreen )
2705 {
2706 v128 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureHeight : 26);
2707 v125 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureWidth : 24);
2708 v123 = 445;
2709 v121 = 470;
2710 }
2711 else
2712 {
2713 v128 = 30;
2714 v125 = 30;
2715 v123 = 300;
2716 v121 = 600;
2717 }
2718 pCharacterScreen_DetalizBtn = pGUIWindow_CurrentMenu->CreateButton(v121, v123, v125, v128, v0, 0, 0x55u, 0, 0,
2719 pGlobalTXT_LocalizationStrings[64],// "Detail Toggle"
2720 0);
2721 pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, v0, 0, 0x85u, 0, 0, v1, 0);
2722 goto LABEL_422;
2723 case UIMSG_Quit|0x1:
2724 OnPaperdollLeftClick();
2725 goto _continue;
2726 case UIMSG_CloseBook|0x2:
2727 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
2728 sub_4196A0();
2729 sub_419379();
2730 pButton = pCharacterScreen_StatsBtn;
2731 goto LABEL_716;
2732 case UIMSG_ChangeMusicVolume|0x2:
2733 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
2734 sub_4196A0();
2735 sub_419379();
2736 sub_419401();
2737 pButton = pCharacterScreen_SkillsBtn;
2738 goto LABEL_716;
2739 case UIMSG_SkillUp:
2740 pPlayer4 = pPlayers[uActiveCharacter];
2741 v105 = (int)&pPlayer4->pActiveSkills[uMessageParam];
2742 LOWORD(v2) = *(short *)v105;
2743 uNumSeconds = v2;
2744 if ( pPlayer4->uSkillPoints < (v2 & 0x3F) + 1 )
2745 {
2746 v87 = pGlobalTXT_LocalizationStrings[488];// "You don't have enough skill points!"
2747 }
2748 else
2749 {
2750 if ( (uNumSeconds & 0x3F) < 0x3C )
2751 {
2752 *(short *)v105 = uNumSeconds + 1;
2753 pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F;
2754 pPlayer4->PlaySound(14, 0);
2755 v165 = 0;
2756 v151 = 0;
2757 v144 = 0;
2758 v139 = 0;
2759 v135 = -1;
2760 v132 = 0;
2761 v130 = 0;
2762 v127 = 20001;
2763 goto _play_sound_and_continue;
2764 }
2765 v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
2766 }
2767 _draw_status_string_and_continue:
2768 ShowStatusBarString(v87, 2u);
2769 goto _continue;
2770 case UIMSG_ChangeMusicVolume|0x4:
2771 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
2772 sub_419379();
2773 sub_4196A0();
2774 pButton = pCharacterScreen_InventoryBtn;
2775 LABEL_716:
2776 v163 = 0;
2777 pButton2 = pButton;
2778 pWindowType1 = (WindowType)91;
2779 goto LABEL_731;
2780 case UIMSG_A8:
2781 pButton = pCharacterScreen_ExitBtn;
2782 v163 = 0;
2783 pButton2 = pCharacterScreen_ExitBtn;
2784 pWindowType1 = (WindowType)97;
2785 goto LABEL_731;
2786 case UIMSG_CloseBook|0x4:
2787 sub_419379();
2788 sub_4196A0();
2789 sub_419220();
2790 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102;
2791 GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42),
2792 (int)pCharacterScreen_AwardsBtn, 0);
2793 sub_419100();
2794 goto _continue;
2795 case 71://0x47:
2796 switch ( uMessageParam )
2797 {
2798 default:
2799 goto _continue;
2800 case 11:
2801 goto LABEL_707;
2802 case 10:
2803 goto LABEL_709;
2804 case 0:
2805 pButton = pBtn_Book_1;
2806 dword_506544 = v0;
2807 break;
2808 case 1:
2809 pButton = pBtn_Book_2;
2810 dword_506548 = v0;
2811 break;
2812 case 2:
2813 dword_506540 = v0;
2814 if ( dword_506364 )
2815 goto _continue;
2816 pButton = pBtn_Book_3;
2817 break;
2818 case 3:
2819 dword_50653C = v0;
2820 if ( dword_506364 )
2821 goto _continue;
2822 pButton = pBtn_Book_4;
2823 break;
2824 case 4:
2825 dword_506538 = v0;
2826 if ( dword_506364 )
2827 goto _continue;
2828 pButton = pBtn_Book_5;
2829 break;
2830 case 5:
2831 dword_506534 = v0;
2832 if ( dword_506364 )
2833 goto _continue;
2834 pButton = pBtn_Book_6;
2835 break;
2836 case 6:
2837 pButton = pBtn_Autonotes_Misc;
2838 dword_506530 = v0;
2839 break;
2840 case 7:
2841 pButton = pBtn_Autonotes_Instructors;
2842 dword_50652C = v0;
2843 break;
2844 }
2845 v163 = v0;
2846 pButton2 = pButton;
2847 pWindowType1 = (WindowType)92;
2848 LABEL_731:
2849 v8 = pButton->uY;
2850 v9 = pButton->uX;
2851 goto LABEL_732;
2852 case UIMSG_SelectCharacter:
2853 if ( pMessageQueue_50CBD0->uNumMessages )
2854 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2855 GameUI_OnPlayerPortraitLeftClick(uMessageParam);
2856 goto _continue;
2857 case UIMSG_ShowStatus_Funds:
2858 v174 = (char *)pParty->uNumGoldInBank;
2859 v158 = pParty->uNumGold + pParty->uNumGoldInBank;
2860 v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
2861 goto _sprintex_draw_status_and_continue;
2862 case UIMSG_ShowStatus_DateTime:
2863 pNPCData4 = (NPCData *)pParty->uCurrentHour;
2864 if ( (signed int)pParty->uCurrentHour <= 12 )
2865 {
2866 if ( !pNPCData4 )
2867 pNPCData4 = (NPCData *)12;
2868 }
2869 else
2870 {
2871 pNPCData4 = (NPCData *)((char *)pNPCData4 - 12);
2872 }
2873 if ( pParty->uCurrentHour < 0xC || (uNumSeconds = v0, pParty->uCurrentHour >= 0x18) )
2874 uNumSeconds = 0;
2875 sprintf(pTmpBuf, "%d:%02d%s %s %d %s %d", pNPCData4, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7],
2876 7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear);
2877 goto _set_status_string_pTmpBuf_and_continue;
2878 case UIMSG_ShowStatus_Food:
2879 v173 = (char *)pParty->uNumFoodRations;
2880 v157 = pGlobalTXT_LocalizationStrings[501];// You have %lu food"
2881 goto _sprintex_2args_draw_status_and_continue;
2882 case UIMSG_ShowStatus_Player:
2883 pPlayer5 = pPlayers[uMessageParam];
2884 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->uClass]);// "%s the %s"
2885 strcat(pTmpBuf, ": ");
2886 v107 = pPlayer5->GetMajorConditionIdx();
2887 strcat(pTmpBuf, aCharacterConditionNames[v107]);
2888 sub_41C0B8_set_status_string(pTmpBuf);
2889 v108 = 8 * uMessageParam - 8;
2890 LOBYTE(v108) = v108 | 4;
2891 pMouse->uPointingObjectID = v108;
2892 goto _continue;
2893 case UIMSG_ShowStatus_ManaHP:
2894 v109 = pGlobalTXT_LocalizationStrings[212];// "Spell Points"
2895 v110 = pPlayers[uMessageParam];
2896 v111 = v110->GetMaxMana();
2897 v112 = v110->sMana;
2898 v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
2899 v114 = v110->GetMaxHealth();
2900 sprintf(pTmpBuf, "%d / %d %s %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
2901 goto _set_status_string_pTmpBuf_and_continue;
2902 case 0xC:
2903 if ( pCurrentScreen == 15 )
2904 goto LABEL_762;
2905 sub_420E01();
2906 goto _continue;
2907 case UIMSG_ChangeMusicVolume|0x8:
2908 LABEL_762:
2909 sub_421EA6_OnInventoryLeftClick();
2910 goto _continue;
2911 case 0xA:
2912 if ( !pRenderer->pRenderD3D )
2913 goto LABEL_772;
2914 v115 = pMessageQueue_50CBD0->uNumMessages;
2915 if ( !pMessageQueue_50CBD0->uNumMessages )
2916 goto LABEL_768;
2917 if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
2918 {
2919 v115 = v0;
2920 pMessageQueue_50CBD0->uNumMessages = v0;
2921 LABEL_769:
2922 pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
2923 LABEL_770:
2924 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
2925 goto LABEL_771;
2926 }
2927 v115 = 0;
2928 pMessageQueue_50CBD0->uNumMessages = 0;
2929 LABEL_768:
2930 if ( (signed int)v115 < 40 )
2931 goto LABEL_769;
2932 goto _continue;
2933 case 0xE:
2934 LABEL_772:
2935 if ( pMessageQueue_50CBD0->uNumMessages )
2936 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2937 OnGameViewportClick();
2938 goto _continue;
2939 case 0xF:
2940 if ( pRenderer->pRenderD3D )
2941 {
2942 LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
2943 }
2944 else
2945 {
2946 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209);
2947 pPoint3 = pMouse->GetCursorPos(&v204);
2948 v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]];
2949 }
2950 v163 = 0;
2951 pButton2 = (GUIButton *)(unsigned __int16)v116;
2952 pWindowType1 = (WindowType)15;
2953 goto LABEL_779;
2954 case 0x54:
2955 v163 = 0;
2956 pButton2 = (GUIButton *)uMessageParam;
2957 pWindowType1 = (WindowType)22;
2958 LABEL_779:
2959 v8 = 0;
2960 v9 = 0;
2961 LABEL_732:
2962 v137 = 0;
2963 v133 = 0;
2964 LABEL_733:
2965 GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
2966 goto _continue;
2967 case 0x194:
2968 if ( pMessageQueue_50CBD0->uNumMessages )
2969 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2970 OnPressSpace();
2971 goto _continue;
2972 case UIMSG_ChangeSoundVolume|0x100:
2973 if ( pCurrentScreen )
2974 goto _continue;
2975 pParty->uFlags |= 2u;
2976 GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A14, 0);
2977 uNumSeconds = 131072;
2978 v118 = 2 * viewparams->uMinimapZoom;
2979 ++viewparams->field_28;
2980 viewparams->uMinimapZoom *= 2;
2981 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
2982 {
2983 if ( (signed int)v118 > 4096 )
2984 {
2985 viewparams->uMinimapZoom = 4096;
2986 viewparams->field_28 = 12;
2987 }
2988 goto _continue;
2989 }
2990 v119 = 2048;
2991 if ( (signed int)v118 <= 2048 )
2992 goto LABEL_789;
2993 viewparams->field_28 = 11;
2994 goto LABEL_788;
2995 case UIMSG_ChangeMusicVolume|0x100:
2996 if ( pCurrentScreen )
2997 goto _continue;
2998 pParty->uFlags |= 2u;
2999 GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A18, 0);
3000 uNumSeconds = 32768;
3001 v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
3002 --viewparams->field_28;
3003 viewparams->uMinimapZoom = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
3004 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3005 {
3006 v119 = 512;
3007 if ( (signed int)v118 < 512 )
3008 {
3009 viewparams->field_28 = 9;
3010 LABEL_788:
3011 v118 = v119;
3012 viewparams->uMinimapZoom = v119;
3013 }
3014 LABEL_789:
3015 dword_576E2C = v118;
3016 dword_576E28 = viewparams->field_28;
3017 }
3018 else
3019 {
3020 if ( (signed int)v118 < 256 )
3021 {
3022 viewparams->uMinimapZoom = 256;
3023 viewparams->field_28 = 8;
3024 }
3025 }
3026 goto _continue;
3027 }
3028 }
3029 }
3030 pMessageQueue_50CBD0->uNumMessages = dword_50C9E8;
3031 memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
3032 dword_50C9E8 = 0;
3033 if ( dword_50C9DC )
3034 {
3035 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3036 {
3037 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC;
3038 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0;
3039 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3040 ++pMessageQueue_50CBD0->uNumMessages;
3041 }
3042 dword_50C9DC = 0;
3043 }
3044 else
3045 {
3046 if ( dword_50C9D0 > 0 )
3047 {
3048 dword_50C9D8 -= pEventTimer->uTimeElapsed;
3049 if ( dword_50C9D8 <= 0 )
3050 {
3051 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3052 {
3053 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0;
3054 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4;
3055 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3056 ++pMessageQueue_50CBD0->uNumMessages;
3057 }
3058 dword_50C9D0 = 0;
3059 dword_50C9D4 = 0;
3060 dword_50C9D8 = 0;
3061 }
3062 }
3063 }
3064 pStru277->_427E01_cast_spell();
3065 }
3066
3067
3068 //----- (004356FF) --------------------------------------------------------
3069 void __cdecl back_to_game()
3070 {
3071 dword_507BF0_is_there_popup_onscreen = 0;
3072 dword_4E455C = 1;
3073 dword_50CDCC = 0;
3074 if ( pGUIWindow_ScrollWindow )
3075 free_book_subwindow();
3076 if ( !pCurrentScreen && !pGUIWindow_Settings )
3077 pEventTimer->Resume();
3078 viewparams->bRedrawGameUI = 1;
3079 }
3080 //----- (00435748) --------------------------------------------------------
3081 void __cdecl GUI_MainMenuMessageProc()
3082 {
3083 //AudioPlayer *v0; // ebp@2
3084 char *v1; // ebx@2
3085 unsigned int v2; // ecx@18
3086 void *v3; // edi@21
3087 signed int v4; // eax@29
3088 int v5; // ecx@29
3089 enum PLAYER_SKILL_TYPE v6; // edi@37
3090 GUIWindow *pWindow; // eax@56
3091 unsigned int v8; // edx@56
3092 Player *pCurrentPlayer; // edi@57
3093 signed int v10; // eax@58
3094 GUIButton *pButton; // eax@59
3095 unsigned __int8 v12; // sf@62
3096 signed int v13; // eax@64
3097 unsigned int v14; // eax@66
3098 int v15; // edi@70
3099 char v16; // zf@73
3100 int v17; // eax@73
3101 int v19; // edi@116
3102 char v20; // dl@116
3103 unsigned int v21; // eax@116
3104 Player *v22; // ecx@116
3105 char *v23; // ebx@118
3106 int v24; // eax@118
3107 unsigned int v25; // eax@120
3108 unsigned int v26; // ecx@127
3109 unsigned int v27; // eax@129
3110 unsigned __int8 v28; // of@129
3111 SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36
3112 signed int v30; // [sp-28h] [bp-38h]@36
3113 unsigned int v31; // [sp-24h] [bp-34h]@36
3114 signed int v32; // [sp-20h] [bp-30h]@36
3115 signed int v34; // [sp-1Ch] [bp-2Ch]@36
3116 int v36; // [sp-18h] [bp-28h]@36
3117 unsigned int v38; // [sp-14h] [bp-24h]@36
3118 int v39; // [sp-14h] [bp-24h]@56
3119 signed int v40; // [sp-10h] [bp-20h]@15
3120 signed int v41; // [sp-10h] [bp-20h]@29
3121 int v42; // [sp-10h] [bp-20h]@36
3122 int v43; // [sp-10h] [bp-20h]@56
3123 int uNum; // [sp+4h] [bp-Ch]@3
3124 UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
3125 int pSex; // [sp+Ch] [bp-4h]@3
3126 Player *pPlayer;
3127
3128 if ( pMessageQueue_50CBD0->uNumMessages )
3129 {
3130 //v0 = pAudioPlayer;
3131 v1 = (char *)pParty->pPlayers;
3132 pPlayer = pParty->pPlayers;
3133 do
3134 {
3135 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &pSex);
3136 switch (pUIMessageType)
3137 {
3138 case UIMSG_MainMenu_ShowPartyCreationWnd:
3139 {
3140 GUIWindow::Create(495, 172, 0, 0, WINDOW_5A, (int)pMainMenu_BtnNew, 0);
3141 SetCurrentMenuID(MENU_NEWGAME);
3142 }
3143 continue;
3144 case UIMSG_MainMenu_ShowLoadWindow:
3145 {
3146 GUIWindow::Create(495, 227, 0, 0, WINDOW_5A, (int)pMainMenu_BtnLoad, 0);
3147 SetCurrentMenuID(MENU_SAVELOAD);
3148 }
3149 continue;
3150 case UIMSG_ShowCredits:
3151 {
3152 GUIWindow::Create(495, 282, 0, 0, WINDOW_5A, (int)pMainMenu_BtnCredits, 0);
3153 SetCurrentMenuID(MENU_CREDITS);
3154 }
3155 continue;
3156 case UIMSG_ExitToWindows:
3157 {
3158 GUIWindow::Create(495, 337, 0, 0, WINDOW_5A, (int)pMainMenu_BtnExit, 0);
3159 SetCurrentMenuID(MENU_FINISHED);
3160 }
3161 continue;
3162 case UIMSG_LoadGame:
3163 {
3164 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot])
3165 continue;
3166 SetCurrentMenuID(MENU_LOAD);
3167 }
3168 continue;
3169 }
3170 switch (pUIMessageType)
3171 {
3172 case UIMSG_A5: // WINDOW_5A
3173 {
3174 //main menu save/load wnd clicking on savegame lines
3175 if (pGUIWindow_CurrentMenu->field_40 == 1)
3176 pKeyActionMap->_459ED1(0);
3177 if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != uNum + dword_6A0C9C )
3178 {
3179 //load clicked line
3180 v26 = uNum + dword_6A0C9C;
3181 if ( dword_6BE138 == uNum + dword_6A0C9C )
3182 {
3183 pMessageQueue_50CBD0->SendMessage(UIMSG_A4, 0, 0);
3184 pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
3185 }
3186 uLoadGameUI_SelectedSlot = v26;
3187 dword_6BE138 = v26;
3188 }
3189 else
3190 {
3191 //typing in the line
3192 pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
3193 strcpy((char *)pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
3194 pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
3195 }
3196 }
3197 continue;
3198 case UIMSG_A4:
3199 {
3200 GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_5E, (int)ptr_69BD64, 0);
3201 }
3202 continue;
3203 }
3204 if ( (signed int)pUIMessageType > UIMSG_PlayerCreationRemoveDownSkill )
3205 {
3206 if ( pUIMessageType > UIMSG_A3 )
3207 {
3208 if ( pUIMessageType == UIMSG_A6 )
3209 {
3210 GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (WindowType)95, (int)ptr_69BD60, 0);
3211 continue;
3212 }
3213 if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
3214 {
3215 pPlayer = &pParty->pPlayers[uNum];
3216 v12 = (char)((int)pPlayer->uFace - 1) < 0;
3217 --pPlayer->uFace;
3218 if ( v12 )
3219 pPlayer->uFace = 19;
3220 pPlayer->uVoiceID = pPlayer->uFace;
3221 pPlayer->SetInitialStats();
3222 pPlayer->SetSexByVoice();
3223 pPlayer->RandomizeName();
3224 v25 = uNum;
3225 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
3226 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
3227 uPlayerCreationUI_SelectedCharacter = v25;
3228 GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0,
3229 (enum WindowType)92, (int)pCreationUI_BtnPressLeft[v25], 1);
3230 //v0 = pAudioPlayer;
3231 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0.0, 0);
3232 v22 = pPlayer;
3233 v22->PlaySound(102, 0);
3234 v1 = (char *)pParty->pPlayers;
3235 continue;
3236 }
3237 if ( pUIMessageType == UIMSG_SelectFacePlayerForward )
3238 {
3239 pPlayer = &pParty->pPlayers[uNum];
3240 v20 = (char)((int)pPlayer->uFace + 1) % 20;
3241 pPlayer->uFace = v20;
3242 pPlayer->uVoiceID = v20;
3243 pPlayer->SetInitialStats();
3244 pPlayer->SetSexByVoice();
3245 pPlayer->RandomizeName();
3246 v21 = uNum;
3247 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
3248 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
3249 uPlayerCreationUI_SelectedCharacter = v21;
3250 GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (enum WindowType)92,
3251 (int)pCreationUI_BtnPressRight[v21], 1);
3252 //v0 = pAudioPlayer;
3253 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3254 v22 = pPlayer;
3255 v22->PlaySound(102, 0);
3256 v1 = (char *)pParty->pPlayers;
3257 continue;
3258 }
3259 if ( pUIMessageType == UIMSG_AD )
3260 {
3261 GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
3262 SetCurrentMenuID(MENU_LOAD);
3263 continue;
3264 }
3265 if ( pUIMessageType != UIMSG_AE )
3266 continue;
3267 GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
3268 LABEL_114:
3269 v40 = 10;
3270 LABEL_89:
3271 v2 = v40;
3272 SetCurrentMenuID((MENU_STATE)v2);
3273 continue;
3274 }
3275 if ( pUIMessageType == UIMSG_A3 )
3276 {
3277 ++dword_6A0C9C;
3278 if ( dword_6A0C9C >= uNum )
3279 dword_6A0C9C = uNum - 1;
3280 if ( dword_6A0C9C < 1 )
3281 dword_6A0C9C = 0;
3282 pWindow = pGUIWindow_CurrentMenu;
3283 v43 = 0;
3284 v39 = (int)ptr_69BD58;
3285 v8 = pGUIWindow_CurrentMenu->uFrameY + 323;
3286 goto LABEL_105;
3287 }
3288 if ( pUIMessageType == UIMSG_6B )
3289 {
3290 if ( pCurrentScreen )
3291 {
3292 pGUIWindow_CurrentMenu->Release();
3293 pEventTimer->Resume();
3294 pCurrentScreen = 0;
3295 viewparams->bRedrawGameUI = 1;
3296 }
3297 GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
3298 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
3299 continue;
3300 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseBook;
3301 goto LABEL_93;
3302 }
3303 if ( pUIMessageType == UIMSG_CloseBook )
3304 {
3305 if ( ptr_507BDC )
3306 {
3307 sub_41426F();
3308 continue;
3309 }
3310 if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x40) )
3311 continue;
3312 v15 = 1;
3313 pVideoPlayer->bStopBeforeSchedule = 1;
3314 viewparams->bRedrawGameUI = 1;
3315 viewparams->field_48 = 1;
3316 if ( !GetCurrentMenuID() || GetCurrentMenuID() == 6 || GetCurrentMenuID() == 7 )
3317 {
3318 v17 = pCurrentScreen;
3319 LABEL_83:
3320 if ( v17 == 16 )
3321 pVideoPlayer->FastForwardToFrame(pVideoPlayer->field_40);
3322 if (GetCurrentMenuID() == MENU_7)
3323 {
3324 v40 = 6;
3325 goto LABEL_89;
3326 }
3327 if (GetCurrentMenuID() == MENU_Credits)
3328 {
3329 v40 = 11;
3330 goto LABEL_89;
3331 }
3332 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3333 {
3334 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)5;
3335 LABEL_93:
3336 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
3337 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3338 ++pMessageQueue_50CBD0->uNumMessages;
3339 continue;
3340 }
3341 continue;
3342 }
3343 v16 = GetCurrentMenuID() == 8;
3344 v17 = pCurrentScreen;
3345 if ( v16 && !pCurrentScreen )
3346 goto LABEL_83;
3347 if ( pCurrentScreen == 12 )
3348 {
3349 pIcons_LOD->_4114F2();
3350 //crt_deconstruct_ptr_6A0118();
3351 pTexture_PCX.Release();
3352 pTexture_PCX.Load("title.pcx", 0);
3353 SetCurrentMenuID(MENU_MAIN);
3354 v15 = 1;
3355 LABEL_81:
3356 pGUIWindow_CurrentMenu->Release();
3357 pGUIWindow2->Release();
3358 pGUIWindow2 = 0;
3359 pEventTimer->Resume();
3360 pCurrentScreen = 0;
3361 viewparams->bRedrawGameUI = v15;
3362 continue;
3363 }
3364 if ( pCurrentScreen == 16 )
3365 {
3366 pVideoPlayer->Unload();
3367 }
3368 else
3369 {
3370 if ( pCurrentScreen != 27 )
3371 goto LABEL_81;
3372 //VideoPlayer::dtor();
3373 }
3374 }
3375 else
3376 {
3377 if ( pUIMessageType == UIMSG_PlayerCreationSelectQuality )
3378 {
3379 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
3380 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
3381 uPlayerCreationUI_SelectedCharacter = uNum;
3382 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3383 continue;
3384 }
3385 if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )
3386 {
3387 pCurrentPlayer = &pPlayer[uNum];
3388 pSex = pCurrentPlayer->GetSexByVoice();
3389 do
3390 {
3391 v12 = (/*(*/pCurrentPlayer->uVoiceID-- - 1/*) & 0x80000000u */) != 0;
3392 if ( v12 )
3393 pCurrentPlayer->uVoiceID = 19;
3394 v13 = pCurrentPlayer->GetSexByVoice();
3395 }
3396 while ( v13 != pSex );
3397 pButton = pCreationUI_BtnPressLeft2[uNum];
3398 GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
3399 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3400 pCurrentPlayer->PlaySound(102, 0);
3401 continue;
3402 }
3403 if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
3404 {
3405 pCurrentPlayer = &pPlayer[uNum];
3406 pSex = pCurrentPlayer->GetSexByVoice();
3407 do
3408 {
3409 pCurrentPlayer->uVoiceID = (signed int)(pCurrentPlayer->uVoiceID + 1) % 20;
3410 v10 = pCurrentPlayer->GetSexByVoice();
3411 }
3412 while ( v10 != pSex );
3413 pButton = pCreationUI_BtnPressRight2[uNum];
3414 GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
3415 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3416 pCurrentPlayer->PlaySound(102, 0);
3417 continue;
3418 }
3419 if ( pUIMessageType == UIMSG_A2 )
3420 {
3421 --dword_6A0C9C;
3422 if ( dword_6A0C9C < 0 )
3423 dword_6A0C9C = 0;
3424 pWindow = pGUIWindow_CurrentMenu;
3425 v43 = 0;
3426 v39 = (int)ptr_69BD5C;
3427 v8 = pGUIWindow_CurrentMenu->uFrameY + 197;
3428 LABEL_105:
3429 GUIWindow::Create(pWindow->uFrameX + 215, v8, 0, 0, (WindowType)90, v39, v43);
3430 continue;
3431 }
3432 }
3433 }
3434 else
3435 {
3436 if ( pUIMessageType == UIMSG_PlayerCreationRemoveDownSkill )
3437 {
3438 uPlayerCreationUI_SelectedCharacter = uNum;
3439 v41 = 3;
3440 v1 = (char *)pParty->pPlayers;
3441 v5 = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7
3442 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
3443 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
3444 pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
3445 + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
3446 continue;
3447 }
3448 if ( (signed int)pUIMessageType > UIMSG_3C )
3449 {
3450 if ( pUIMessageType == UIMSG_PlayerCreationClickPlus )
3451 {
3452 GUIWindow::Create(613, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
3453 (&pPlayer[uPlayerCreationUI_SelectedCharacter])->IncreaseAttribute(
3454 (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
3455 pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0);
3456 continue;
3457 }
3458 if ( pUIMessageType == UIMSG_PlayerCreationClickMinus )
3459 {
3460 GUIWindow::Create(523, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
3461 (&pPlayer[uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
3462 (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
3463 pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0);
3464 continue;
3465 }
3466 if ( pUIMessageType == UIMSG_PlayerCreationSelectActiveSkill )
3467 {
3468 auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
3469 v6 = _t->GetSkillIdxByOrder(uNum + 4);
3470 if ( _t->GetSkillIdxByOrder(3) == 37 )
3471 pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
3472 pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
3473 continue;
3474 }
3475 if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
3476 {
3477 (&pPlayer[uPlayerCreationUI_SelectedCharacter])->Reset(uNum);
3478 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3479 continue;
3480 }
3481 if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
3482 {
3483 GUIWindow::Create(580, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
3484 if ( PlayerCreation_ComputeAttributeBonus() || !sub_4908DE() )
3485 GameUI_StatusBar_TimedStringTimeLeft = GetTickCount() + 4000;
3486 else
3487 uGameState = 6;
3488 continue;
3489 }
3490 if ( pUIMessageType == UIMSG_PlayerCreationClickReset )
3491 {
3492 GUIWindow::Create(527, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
3493 pParty->Reset();
3494 }
3495 else
3496 {
3497 if ( pUIMessageType == UIMSG_PlayerCreationRemoveUpSkill )
3498 {
3499 uPlayerCreationUI_SelectedCharacter = uNum;
3500 v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
3501 pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
3502 v41 = 2;
3503 v5 = v4 % 7 + pSex + 7 * uNum;
3504 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
3505 pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
3506 + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
3507 continue;
3508 }
3509 }
3510 }
3511 else
3512 {
3513 switch ( pUIMessageType )
3514 {
3515 case 60:
3516 pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
3517 v3 = (void *)uNum;
3518 uPlayerCreationUI_SelectedCharacter = uNum;
3519 pKeyActionMap->_459E5A(0, 15, pGUIWindow_CurrentMenu);
3520 pGUIWindow_CurrentMenu->ptr_1C = v3;
3521 break;
3522 case 5:
3523 uGameState = 1;
3524 break;
3525 case 17:
3526 pMouse->SetCursorBitmap("MICON2");
3527 break;
3528 default:
3529 if ( pUIMessageType == 58 )
3530 goto LABEL_114;
3531 break;
3532 }
3533 }
3534 }
3535 }
3536 while ( pMessageQueue_50CBD0->uNumMessages );
3537 }
3538 }
3539
3540 //----- (00436427) --------------------------------------------------------
3541 double __cdecl get_shading_dist_mist()
3542 {
3543 double result; // st7@2
3544
3545 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3546 result = (double)pOutdoorCamera->shading_dist_mist;
3547 else
3548 result = 16192.0;
3549 return result;
3550 }
3551
3552 //----- (0043643E) --------------------------------------------------------
3553 double __cdecl GetPickDepth()
3554 {
3555 double result; // st7@2
3556
3557 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3558 result = (double)pOutdoorCamera->uPickDepth;
3559 else
3560 result = 16192.0;
3561 return result;
3562 }
3563
3564 //----- (0043648F) --------------------------------------------------------
3565 void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
3566 {
3567 _this->flt_2C = 0.0;
3568
3569 _this->vWorldPosition.x = a2->x;
3570 _this->vWorldPosition.y = a2->y;
3571 _this->vWorldPosition.z = a2->z;
3572 }
3573
3574 //----- (004369DB) --------------------------------------------------------
3575 void Vec3_float_::Normalize()
3576 {
3577 Vec3_float_ *v1; // esi@1
3578 double v2; // st7@1
3579
3580 auto a1 = this;
3581 v1 = a1;
3582 v2 = 1.0 / sqrt(a1->x * a1->x + a1->y * a1->y + a1->z * a1->z);
3583 v1->x = v2 * v1->x;
3584 v1->y = v2 * v1->y;
3585 v1->z = v2 * v1->z;
3586 }
3587
3588
3589
3590
3591
3592
3593
3594 //----- (004382BC) --------------------------------------------------------
3595 __int16 __thiscall sub_4382BC(int _this)
3596 {
3597 LOG_DECOMPILATION_WARNING();
3598 return 0;
3599 /*__int16 result; // ax@4
3600 __int16 v14; // sp@11
3601 int v15; // [sp-4h] [bp-Ch]@0
3602 signed __int16 v16; // [sp+4h] [bp-4h]@1
3603 __int16 v17; // [sp+4h] [bp-4h]@8
3604 __int16 v18; // [sp+4h] [bp-4h]@11
3605
3606 v16 = 1;
3607 __asm { pushf }
3608 if ( v15 == (v15 ^ 0x200000) )
3609 v16 = 0;
3610 if ( v16 )
3611 {
3612 result = sub_43847A();
3613 }
3614 else
3615 {
3616 //UNDEF(_ZF);
3617 //UNDEF(_SF);
3618 //UNDEF(_OF);
3619 _CF = 0;
3620 if ( !_ZF )
3621 _CF = 1;
3622 __asm { pushfw }
3623 bProcessorIsNotIntel = (BYTE2(v15) & 1 ^ 1) & 1;
3624 _CF = 0;
3625 _OF = 0;
3626 _ZF = 0;
3627 _SF = 1;
3628 __asm { pushfw }
3629 v17 = 2;
3630 if ( (HIWORD(v15) | 0xF000) & 0xF000 )
3631 v17 = -1;
3632 __asm { popfw }
3633 result = v17;
3634 if ( v17 != 2 )
3635 {
3636 _CF = 0;
3637 _OF = 0;
3638 _ZF = v14 == 0;
3639 _SF = v14 < 0;
3640 __asm { pushf }
3641 v18 = 3;
3642 if ( v15 != (v15 ^ 0x40000) )
3643 v18 = -1;
3644 __asm { popf }
3645 result = v18;
3646 if ( v18 != 3 )
3647 result = 4;
3648 }
3649 }
3650 if ( bProcessorIsNotIntel )
3651 HIBYTE(result) |= 0x80u;
3652 return result;*/
3653 }
3654
3655 //----- (004383ED) --------------------------------------------------------
3656 int __cdecl sub_4383ED()
3657 {
3658 LOG_DECOMPILATION_WARNING();
3659 return 0;
3660 /*signed int v9; // eax@4
3661 int v16; // [sp-4h] [bp-38h]@0
3662 int v17[3]; // [sp+Ch] [bp-28h]@1
3663 char v18; // [sp+18h] [bp-1Ch]@1
3664 char v19; // [sp+19h] [bp-1Bh]@1
3665 int v20[4]; // [sp+1Ch] [bp-18h]@1
3666 int v21; // [sp+2Ch] [bp-8h]@1
3667 int v22; // [sp+30h] [bp-4h]@1
3668
3669 v17[0] = *(int *)"------------";
3670 v17[1] = *(int *)"--------";
3671 v17[2] = *(int *)"----";
3672 v18 = asc_4E4938[12];
3673 v19 = 0;
3674 v22 = 0;
3675 v20[0] = *(int *)"GenuineIntel";
3676 v20[1] = *(int *)"ineIntel";
3677 v20[2] = *(int *)"ntel";
3678 LOBYTE(v20[3]) = aGenuineintel[12];
3679 _CF = 0;
3680 _OF = 0;
3681 _ZF = 0;
3682 _SF = 0;
3683 v21 = 1;
3684 __asm { pushf }
3685 if ( v16 == (v16 ^ 0x200000) )
3686 v21 = 0;
3687 if ( (short)v21 )
3688 {
3689 _EAX = 0;
3690 __asm { cpuid }
3691 v17[0] = _EBX;
3692 v17[1] = _EDX;
3693 v17[2] = _ECX;
3694 v9 = 0;
3695 do
3696 {
3697 if ( *((char *)v17 + v9) != *((char *)v20 + v9) )
3698 bProcessorIsNotIntel = 1;
3699 ++v9;
3700 }
3701 while ( v9 < 12 );
3702 if ( v9 >= 1 )
3703 {
3704 _EAX = 1;
3705 __asm { cpuid }
3706 v22 = _EDX;
3707 }
3708 }
3709 return v22;*/
3710 }
3711
3712 //----- (0043847A) --------------------------------------------------------
3713 __int16 __cdecl sub_43847A()
3714 {
3715 __debugbreak();
3716 return 0;
3717 /*signed int v5; // eax@1
3718 char v12[12]; // [sp+Ch] [bp-28h]@1
3719 char v13; // [sp+18h] [bp-1Ch]@1
3720 char v14; // [sp+19h] [bp-1Bh]@1
3721 int v15[4]; // [sp+1Ch] [bp-18h]@1
3722 int v16; // [sp+2Eh] [bp-6h]@1
3723 char v17; // [sp+32h] [bp-2h]@6
3724 char v18; // [sp+33h] [bp-1h]@1
3725
3726 *(int *)v12 = *(int *)"------------";
3727 *(int *)&v12[4] = *(int *)"--------";
3728 *(int *)&v12[8] = *(int *)"----";
3729 v13 = asc_4E4938[12];
3730 v14 = 0;
3731 v18 = 0;
3732 v15[0] = *(int *)"GenuineIntel";
3733 v15[1] = *(int *)"ineIntel";
3734 v15[2] = *(int *)"ntel";
3735 v16 = 65535;
3736 LOBYTE(v15[3]) = aGenuineintel[12];
3737 _EAX = 0;
3738 __asm { cpuid }
3739 *(int *)v12 = _EBX;
3740 *(int *)&v12[4] = _EDX;
3741 *(int *)&v12[8] = _ECX;
3742 v5 = 0;
3743 do
3744 {
3745 if ( v12[v5] != *((char *)v15 + v5) )
3746 bProcessorIsNotIntel = 1;
3747 ++v5;
3748 }
3749 while ( v5 < 12 );
3750 if ( v5 >= 1 )
3751 {
3752 _EAX = 1;
3753 __asm { cpuid }
3754 v18 = _EAX & 0xF;
3755 LOBYTE(_EAX) = (unsigned __int8)(_EAX & 0xF0) >> 4;
3756 v17 = _EAX;
3757 LOWORD(v16) = ((_EAX & 0xF00u) >> 8) & 0xF;
3758 }
3759 return v16;*/
3760 }
3761
3762
3763
3764 //----- (004385B5) --------------------------------------------------------
3765 void stru11::CheckCPU()
3766 {
3767 LOG_DECOMPILATION_WARNING();
3768 /*
3769 int v5; // [sp-4h] [bp-10h]@0
3770 signed int v6; // [sp+4h] [bp-8h]@1
3771 signed int v7; // [sp+8h] [bp-4h]@1
3772
3773 _CF = 0;
3774 _OF = 0;
3775 _ZF = 1;
3776 _SF = 0;
3777 v7 = 0;
3778 __asm { pushf }
3779 v6 = 3;
3780 if ( v5 != (v5 ^ 0x40000) )
3781 {
3782 __asm { popf }
3783 v6 = 4;
3784 __asm { pushf }
3785 if ( v5 != (v5 ^ 0x200000) )
3786 {
3787 v7 = 1;
3788 v6 = 0;
3789 }
3790 }
3791 if ( v6 == 3 )
3792 {
3793 this->field_AC = 1;
3794 }
3795 else
3796 {
3797 if ( v6 == 4 )
3798 {
3799 this->field_AC = 2;
3800 }
3801 else
3802 {
3803 if ( v7 )
3804 {
3805 this->field_AC = 2;
3806 RunCPUID();
3807 }
3808 else
3809 {
3810 this->field_AC = 0;
3811 }
3812 }
3813 }*/
3814 }
3815
3816 //----- (00438659) --------------------------------------------------------
3817 void stru11::RunCPUID()
3818 {
3819 __debugbreak();
3820 /*stru11 *v6; // esi@1
3821 unsigned int uNumOps; // edi@1
3822 int uNumExtOps; // edi@16
3823 char pCyrixString[16]; // [sp+Ch] [bp-60h]@1
3824 char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1
3825 char pAMDString[16]; // [sp+2Ch] [bp-40h]@1
3826 char pIntelString[16]; // [sp+3Ch] [bp-30h]@1
3827 char pCPUString[16]; // [sp+4Ch] [bp-20h]@1
3828 stru11 *thisa; // [sp+5Ch] [bp-10h]@1
3829 char *v35; // [sp+60h] [bp-Ch]@1
3830 int v36; // [sp+64h] [bp-8h]@1
3831 int v37; // [sp+68h] [bp-4h]@1
3832
3833 thisa = this;
3834 *(int *)pIntelString = *(int *)"GenuineIntel";
3835 *(int *)&pIntelString[4] = *(int *)"ineIntel";
3836 *(int *)&pIntelString[8] = *(int *)"ntel";
3837 pIntelString[12] = aGenuineintel[12];
3838 *(int *)pAMDString = *(int *)"AuthenticAMD";
3839 *(int *)&pAMDString[4] = *(int *)"enticAMD";
3840 *(int *)&pAMDString[8] = *(int *)"cAMD";
3841 pAMDString[12] = aAuthenticamd[12];
3842 *(int *)pCyrixString = *(int *)"CyrixInstead";
3843 *(int *)&pCyrixString[4] = *(int *)"xInstead";
3844 *(int *)&pCyrixString[8] = *(int *)"tead";
3845 pCyrixString[12] = aCyrixinstead[12];
3846 *(int *)pCentaurString = *(int *)"CentaurHauls";
3847 *(int *)&pCentaurString[4] = *(int *)"aurHauls";
3848 *(int *)&pCentaurString[8] = *(int *)"auls";
3849 v37 = 0;
3850 v36 = 0;
3851 pCentaurString[12] = aCentaurhauls[12];
3852 v35 = pCPUString;
3853 pCPUString[12] = 0;
3854 _EAX = 0;
3855 __asm { cpuid }
3856 v37 = _EAX;
3857 *(int *)pCPUString = _EBX;
3858 *(int *)&pCPUString[4] = _EDX;
3859 *(int *)&pCPUString[8] = _ECX;
3860 v6 = thisa;
3861 uNumOps = _EAX;
3862 thisa->cpuid_00000000_ebx_vendorstr1 = _EBX;
3863 v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4];
3864 v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8];
3865 v6->cpuid_00000000_eax_numops = _EAX;
3866 strcpy(v6->pCPUString, pCPUString);
3867 if ( strcmp(pIntelString, pCPUString) )
3868 {
3869 if ( strcmp(pAMDString, pCPUString) )
3870 {
3871 if ( strcmp(pCyrixString, pCPUString) )
3872 {
3873 if ( strcmp(pCentaurString, pCPUString) )
3874 v6->uProcessorManufacturer = 0;
3875 else
3876 v6->uProcessorManufacturer = 4;
3877 }
3878 else
3879 {
3880 v6->uProcessorManufacturer = 3;
3881 }
3882 }
3883 else
3884 {
3885 v6->uProcessorManufacturer = 2;
3886 }
3887 }
3888 else
3889 {
3890 v6->uProcessorManufacturer = 1;
3891 }
3892 if ( uNumOps >= 1 )
3893 RunCPUID_op1();
3894 if ( uNumOps >= 2 )
3895 RunCPUID_op2();
3896 _EAX = 0x80000000u;
3897 __asm { cpuid }
3898 if ( !(_EAX & 0x80000000) )
3899 _EAX = 0x80000000u;
3900 v36 = _EAX;
3901 v6->cpuid_80000000_edx = _EAX;
3902 uNumExtOps = _EAX ^ 0x80000000;
3903 if ( (_EAX ^ 0x80000000u) >= 1 )
3904 {
3905 _EAX = 0x80000001u;
3906 __asm { cpuid }
3907 thisa = (stru11 *)_EAX;
3908 v35 = (char *)_EDX;
3909 v6->cpuid_80000001_eax = _EAX;
3910 v6->cpuid_80000001_edx = (int)v35;
3911 }
3912 if ( (unsigned int)uNumExtOps >= 4 )
3913 RunCPUID_ext2_3_4();
3914 if ( (unsigned int)uNumExtOps >= 5 )
3915 {
3916 _EAX = 0x80000005u;
3917 __asm { cpuid }
3918 thisa = (stru11 *)_EBX;
3919 v35 = (char *)_ECX;
3920 v36 = _EDX;
3921 v6->cpuid_80000005_ebx = _EBX;
3922 v6->cpuid_80000005_ecx = (int)v35;
3923 v6->cpuid_80000005_edx = v36;
3924 }
3925 if ( (unsigned int)uNumExtOps >= 6 )
3926 {
3927 _EAX = 0x80000006u;
3928 __asm { cpuid }
3929 v6->cpuid_80000006_ecx = _ECX;
3930 }*/
3931 }
3932
3933 //----- (00438821) --------------------------------------------------------
3934 void stru11::RunCPUID_op1()
3935 {
3936 __debugbreak();
3937 /*stru11 *v1; // esi@1
3938 unsigned int v7; // ecx@1
3939 int v8; // eax@3
3940 int v9; // eax@10
3941 signed int v10; // eax@11
3942 int v11; // ecx@11
3943 int v12; // eax@15
3944 signed int v13; // eax@19
3945 int v14; // ecx@19
3946 signed int v15; // eax@25
3947 int v16; // ecx@25
3948 signed int v17; // eax@34
3949 int v18; // ecx@34
3950
3951 v1 = this;
3952 _EAX = 1;
3953 __asm { cpuid }
3954 v7 = _EAX;
3955 v1->cpuid_00000001_edx = _EDX;
3956 v1->cpuid_00000001_eax = _EAX;
3957 if ( (_EAX & 0x3000) == 8192 )
3958 {
3959 LOBYTE(v1->cpuid_80000002_registers2[0]) = 1;
3960 v7 = 0;
3961 }
3962 v8 = (v7 >> 8) & 0xF;
3963 switch ( v8 )
3964 {
3965 case 4:
3966 v1->field_AC = 2;
3967 break;
3968 case 5:
3969 v1->field_AC = 15;
3970 break;
3971 case 6:
3972 v1->field_AC = 36;
3973 break;
3974 default:
3975 v1->field_AC = 49;
3976 break;
3977 }
3978 v9 = v1->uProcessorManufacturer;
3979 if ( v9 == 1 )
3980 {
3981 v10 = 0;
3982 v11 = v7 & 0x3FF0;
3983 while ( v11 != dword_4E4948[2 * v10] )
3984 {
3985 ++v10;
3986 if ( v10 >= 17 )
3987 return;
3988 }
3989 v12 = dword_4E494C[2 * v10];
3990 goto LABEL_39;
3991 }
3992 if ( v9 == 2 )
3993 {
3994 if ( (v7 & 0xF00) == dword_4E49D0[0] )
3995 {
3996 v12 = dword_4E49D4[0];
3997 }
3998 else
3999 {
4000 v13 = 1;
4001 v14 = v7 & 0x3FF0;
4002 while ( v14 != dword_4E49D0[2 * v13] )
4003 {
4004 ++v13;
4005 if ( v13 >= 9 )
4006 return;
4007 }
4008 v12 = dword_4E49D4[2 * v13];
4009 }
4010 goto LABEL_39;
4011 }
4012 if ( v9 != 3 )
4013 {
4014 if ( v9 != 4 )
4015 return;
4016 v17 = 0;
4017 v18 = v7 & 0x3FF0;
4018 while ( v18 != dword_4E4A40[2 * v17] )
4019 {
4020 ++v17;
4021 if ( v17 >= 2 )
4022 return;
4023 }
4024 v12 = dword_4E4A44[2 * v17];
4025 goto LABEL_39;
4026 }
4027 v15 = 1;
4028 v16 = v7 & 0x3FF0;
4029 while ( v16 != dword_4E4A18[2 * v15] )
4030 {
4031 ++v15;
4032 if ( v15 >= 5 )
4033 goto LABEL_30;
4034 }
4035 v1->field_AC = dword_4E4A1C[2 * v15];
4036 LABEL_30:
4037 v12 = 24;
4038 if ( v1->field_AC == 24 )
4039 {
4040 if ( _EDX != 1 )
4041 v12 = (((_EDX != 261) - 1) & 0xA) + 15;
4042 LABEL_39:
4043 v1->field_AC = v12;
4044 }*/
4045 }
4046
4047 //----- (00438992) --------------------------------------------------------
4048 void stru11::RunCPUID_op2()
4049 {
4050 __debugbreak();
4051 /*
4052 stru11 *v1; // edi@1
4053 int v7; // eax@1
4054 signed int v8; // ecx@2
4055 unsigned __int8 v9; // al@3
4056 signed int v10; // ecx@14
4057 unsigned __int8 v11; // al@15
4058 int v12; // [sp+Ch] [bp-14h]@1
4059 int v13; // [sp+10h] [bp-10h]@1
4060 int v14; // [sp+14h] [bp-Ch]@1
4061 int v15; // [sp+18h] [bp-8h]@1
4062 int *v16; // [sp+1Ch] [bp-4h]@1
4063
4064 v1 = this;
4065 v16 = &v12;
4066 _EAX = 2;
4067 __asm { cpuid }
4068 v12 = _EAX;
4069 v13 = _EBX;
4070 v14 = _ECX;
4071 v15 = _EDX;
4072 v1->cpuid_00000002_eax = _EAX;
4073 v1->cpuid_00000002_ebx = v13;
4074 v1->cpuid_00000002_ecx = v14;
4075 v1->cpuid_00000002_edx = v15;
4076 v7 = v1->field_AC;
4077 if ( v7 == 40 )
4078 {
4079 v8 = 0;
4080 while ( 1 )
4081 {
4082 v9 = *((char *)&v12 + v8);
4083 if ( v9 == 64 )
4084 {
4085 v1->field_AC = 43;
4086 return;
4087 }
4088 if ( v9 >= 0x41u && v9 <= 0x43u )
4089 {
4090 v1->field_AC = 41;
4091 return;
4092 }
4093 if ( v9 >= 0x44u && v9 <= 0x45u )
4094 break;
4095 ++v8;
4096 if ( v8 >= 16 )
4097 return;
4098 }
4099 v1->field_AC = 42;
4100 }
4101 else
4102 {
4103 if ( v7 == 45 )
4104 {
4105 v10 = 0;
4106 while ( 1 )
4107 {
4108 v11 = *((char *)&v12 + v10);
4109 if ( v11 >= 0x40u && v11 <= 0x43u )
4110 {
4111 v1->field_AC = 46;
4112 return;
4113 }
4114 if ( v11 >= 0x44u && v11 <= 0x45u )
4115 break;
4116 ++v10;
4117 if ( v10 >= 16 )
4118 return;
4119 }
4120 v1->field_AC = 47;
4121 }
4122 }*/
4123 }
4124
4125 //----- (00438A67) --------------------------------------------------------
4126 void stru11::RunCPUID_ext2_3_4()
4127 {
4128 __debugbreak();
4129 /*stru11 *v1; // edi@1
4130 stru11 *v17; // eax@1
4131 int v18[3][4]; // [sp+Ch] [bp-38h]@1
4132 stru11 *v19; // [sp+3Ch] [bp-8h]@1
4133
4134 v1 = this;
4135 v19 = this;
4136 _EAX = 0x80000002u;
4137 __asm { cpuid }
4138 v18[0][0] = _EAX;
4139 *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX);
4140 v18[0][3] = _EDX;
4141 _EAX = 0x80000003u;
4142 __asm { cpuid }
4143 v18[1][0] = _EAX;
4144 *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX);
4145 v18[1][3] = _EDX;
4146 _EAX = 0x80000004u;
4147 __asm { cpuid }
4148 v18[2][0] = _EAX;
4149 *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX);
4150 v18[2][3] = _EDX;
4151 v17 = v19;
4152 memcpy(v1->cpuid_80000002_registers, v18, 0x30u);
4153 memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/
4154 }
4155
4156
4157
4158 //----- (00438BDF) --------------------------------------------------------
4159 bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype)
4160 {
4161 unsigned __int8 v2; // zf@15
4162 char v3; // sf@15
4163 unsigned __int8 v4; // of@15
4164 bool result; // eax@33
4165
4166 switch ( eSupertype )
4167 {
4168 case MONSTER_SUPERTYPE_UNDEAD:
4169 if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3
4170 || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3
4171 || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3
4172 || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3
4173 || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3
4174 || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 )
4175 goto ret_true;
4176 if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 )
4177 goto ret_false;
4178 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3);
4179 v2 = uMonsterInfoID == MONSTER_GHOUL_3;
4180 v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0;
4181 goto false_if_outside;
4182 case MONSTER_SUPERTYPE_KREEGAN:
4183 if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 )
4184 goto ret_false;
4185 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3);
4186 v2 = uMonsterInfoID == MONSTER_DEVIL_3;
4187 v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0;
4188 goto false_if_outside;
4189 case MONSTER_SUPERTYPE_ELF:
4190 if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1
4191 && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3
4192 || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 )
4193 goto ret_true;
4194 if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 )
4195 goto ret_false;
4196 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3);
4197 v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3;
4198 v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0;
4199 goto false_if_outside;
4200 case MONSTER_SUPERTYPE_DRAGON:
4201 if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 )
4202 goto ret_false;
4203 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3);
4204 v2 = uMonsterInfoID == MONSTER_DRAGON_3;
4205 v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0;
4206 goto false_if_outside;
4207 case MONSTER_SUPERTYPE_WATER_ELEMENTAL:
4208 if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 )
4209 goto ret_false;
4210 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3);
4211 v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3;
4212 v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0;
4213 goto false_if_outside;
4214 case MONSTER_SUPERTYPE_TREANT:
4215 if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 )
4216 goto ret_false;
4217 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3);
4218 v2 = uMonsterInfoID == MONSTER_TREANT_3;
4219 v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0;
4220 goto false_if_outside;
4221 case MONSTER_SUPERTYPE_TITAN:
4222 if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 )
4223 goto ret_false;
4224 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3);
4225 v2 = uMonsterInfoID == MONSTER_TITAN_3;
4226 v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0;
4227 false_if_outside:
4228 if ( !((unsigned __int8)(v3 ^ v4) | v2) )
4229 goto ret_false;
4230 ret_true:
4231 result = 1;
4232 break;
4233 default:
4234 ret_false:
4235 result = 0;
4236 break;
4237 }
4238 return result;
4239 }
4240
4241
4242 //----- (00438F8F) --------------------------------------------------------
4243 void __cdecl _438F8F_area_of_effect__damage_evaluate()
4244 {
4245 int v0; // edx@1
4246 char *v1; // esi@2
4247 int v2; // ecx@3
4248 signed int v3; // eax@3
4249 LayingItem *v4; // eax@4
4250 signed int v5; // eax@4
4251 signed int v6; // eax@6
4252 unsigned int v7; // edi@6
4253 int v8; // eax@6
4254 __int16 v9; // bx@8
4255 int v10; // edi@8
4256 Vec3_int_ v11; // ST04_12@9
4257 int v12; // ST0C_4@10
4258 Actor *v13; // edi@11
4259 int v14; // edx@15
4260 int v15; // edx@15
4261 int v16; // ebx@15
4262 signed int v17; // eax@15
4263 int v18; // edi@15
4264 int v19; // edi@15
4265 Vec3_int_ v20; // ST04_12@16
4266 Vec3_int_ *v21; // eax@17
4267 unsigned int v22; // edx@17
4268 int v23; // edx@18
4269 int v24; // eax@18
4270 Vec3_int_ v25; // ST04_12@19
4271 unsigned int v26; // ebx@20
4272 char *v27; // edi@20
4273 char *v28; // edi@27
4274 int v29; // ebx@29
4275 int v30; // eax@29
4276 int v31; // edx@29
4277 int v32; // eax@29
4278 int v33; // ST24_4@29
4279 Vec3_int_ v34; // ST04_12@30
4280 Vec3_int_ *v35; // eax@31
4281 LayingItem *v36; // [sp+0h] [bp-28h]@0
4282 signed int v37; // [sp+4h] [bp-24h]@5
4283 int v38; // [sp+4h] [bp-24h]@15
4284 signed int v39; // [sp+8h] [bp-20h]@3
4285 int v40; // [sp+8h] [bp-20h]@15
4286 int v41; // [sp+Ch] [bp-1Ch]@5
4287 int v42; // [sp+Ch] [bp-1Ch]@15
4288 int v43; // [sp+10h] [bp-18h]@1
4289 int v44; // [sp+14h] [bp-14h]@15
4290 unsigned int uActorID; // [sp+18h] [bp-10h]@6
4291 Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2
4292 int a1; // [sp+20h] [bp-8h]@8
4293 int v48; // [sp+24h] [bp-4h]@8
4294
4295 v0 = 0;
4296 v43 = 0;
4297 if ( stru_50FE08.count > 0 )
4298 {
4299 pVelocity = &stru_50FE08.vec_4B4;
4300 v1 = (char *)stru_50FE08.pZs;
4301 do
4302 {
4303 v2 = *((short *)v1 - 300) & 7;
4304 v3 = (signed int)*((short *)v1 - 300) >> 3;
4305 v39 = (signed int)*((short *)v1 - 300) >> 3;
4306 if ( v2 == 2 )
4307 {
4308 v4 = &pLayingItems[v3];
4309 v36 = v4;
4310 v5 = v4->field_58;
4311 v2 = v5 & 7;
4312 v3 = v5 >> 3;
4313 }
4314 v41 = v2;
4315 v37 = v3;
4316 if ( stru_50FE08.field_3EC[v0] & 1 )
4317 {
4318 v6 = dword_4F6E08[v3];
4319 v7 = v6 >> 3;
4320 v8 = (v6 & 7) - 3;
4321 uActorID = v7;
4322 if ( v8 )
4323 {
4324 if ( v8 == 1 )
4325 {
4326 v9 = *(short *)v1;
4327 v10 = pParty->vPosition.y - *((short *)v1 - 100);
4328 a1 = pParty->vPosition.x - *((short *)v1 - 200);
4329 v48 = v10;
4330 if ( a1 * a1
4331 + v10 * v10
4332 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9))
4333 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
4334 {
4335 v11.z = *(short *)v1;
4336 v11.y = *((short *)v1 - 100);
4337 v11.x = *((short *)v1 - 200);
4338 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v11) )
4339 {
4340 v12 = stru_50C198.which_player_would_attack(&pActors[v39]);
4341 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
4342 }
4343 }
4344 }
4345 }
4346 else
4347 {
4348 v13 = &pActors[v7];
4349 if ( SHIDWORD(v13->pActorBuffs[6].uExpireTime) > 0
4350 || SHIDWORD(v13->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(v13->pActorBuffs[6].uExpireTime)
4351 || v13->CanAct() )
4352 {
4353 v14 = v13->vPosition.y;
4354 v40 = v13->vPosition.x;
4355 v38 = v14;
4356 v15 = v14 - *((short *)v1 - 100);
4357 v16 = *(short *)v1;
4358 v42 = v13->vPosition.z;
4359 a1 = v40 - *((short *)v1 - 200);
4360 v17 = v13->uActorHeight;
4361 v18 = v13->uActorRadius;
4362 v44 = v42;
4363 v19 = *((short *)v1 + 100) + v18;
4364 v48 = v15;
4365 if ( a1 * a1 + v15 * v15 + (v42 + (v17 >> 1) - v16) * (v42 + (v17 >> 1) - v16) < (unsigned int)(v19 * v19) )
4366 {
4367 v20.z = *(short *)v1;
4368 v20.y = *((short *)v1 - 100);
4369 v20.x = *((short *)v1 - 200);
4370 if ( sub_407A1C(v40, v38, v42 + 50, v20) )
4371 {
4372 Vec3_int_::Normalize(&a1, &v48, &v44);
4373 v21 = pVelocity;
4374 v22 = uActorID;
4375 pVelocity->x = a1;
4376 v21->y = v48;
4377 v21->z = v44;
4378 sub_43B1B0(*((short *)v1 - 300), v22, v21, stru_50FE08.field_450[v43]);
4379 }
4380 }
4381 }
4382 }
4383 }
4384 else
4385 {
4386 v23 = pParty->vPosition.y - *((short *)v1 - 100);
4387 v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
4388 a1 = pParty->vPosition.x - *((short *)v1 - 200);
4389 v48 = v23;
4390 if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
4391 {
4392 v25.z = *(short *)v1;
4393 v25.y = *((short *)v1 - 100);
4394 v25.x = *((short *)v1 - 200);
4395 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v25) )
4396 {
4397 v26 = 0;
4398 v27 = (char *)&pParty->pPlayers[0].pConditions[15];
4399 do
4400 {
4401 if ( !(*((int *)v27 - 1) | *((int *)v27 - 2)) && !*(_QWORD *)v27 && !*((_QWORD *)v27 + 1) )
4402 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v26);
4403 v27 += 6972;
4404 ++v26;
4405 }
4406 while ( (signed int)v27 < (signed int)&pParty->pHirelings[1].evtb );
4407 }
4408 }
4409 uActorID = 0;
4410 if ( (signed int)uNumActors > 0 )
4411 {
4412 v28 = (char *)&pActors[0].vPosition.z;
4413 do
4414 {
4415 if ( ((Actor *)(v28 - 146))->CanAct() )
4416 {
4417 v29 = *(short *)v1;
4418 v30 = *((short *)v28 - 1) - *((short *)v1 - 100);
4419 a1 = *((short *)v28 - 2) - *((short *)v1 - 200);
4420 v31 = *(short *)v28;
4421 v48 = v30;
4422 v44 = v31;
4423 v32 = ((signed int)*((short *)v28 - 4) >> 1) - v29;
4424 v33 = *((short *)v28 - 5) + *((short *)v1 + 100);
4425 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) )
4426 {
4427 v34.z = *(short *)v1;
4428 v34.y = *((short *)v1 - 100);
4429 v34.x = *((short *)v1 - 200);
4430 if ( sub_407A1C(*((short *)v28 - 2), *((short *)v28 - 1), *(short *)v28 + 50, v34) )
4431 {
4432 Vec3_int_::Normalize(&a1, &v48, &v44);
4433 v35 = pVelocity;
4434 pVelocity->x = a1;
4435 v35->y = v48;
4436 v35->z = v44;
4437 switch ( v41 )
4438 {
4439 case 4:
4440 DamageMonsterFromParty(*((short *)v1 - 300), uActorID, v35);
4441 break;
4442 case 3:
4443 if ( v36 && pActors[v37].GetActorsRelation((Actor *)(v28 - 146)) )
4444 sub_43B1B0(*((short *)v1 - 300), uActorID, pVelocity, v36->field_61);
4445 break;
4446 case 2:
4447 sub_43B057(*((short *)v1 - 300), uActorID, v35);
4448 break;
4449 }
4450 }
4451 }
4452 }
4453 ++uActorID;
4454 v28 += 836;
4455 }
4456 while ( (signed int)uActorID < (signed int)uNumActors );
4457 }
4458 }
4459 ++pVelocity;
4460 v0 = v43 + 1;
4461 v1 += 2;
4462 ++v43;
4463 }
4464 while ( v43 < stru_50FE08.count );
4465 }
4466 stru_50FE08.count = 0;
4467 }
4468 // 50FE08: using guessed type stru298 stru_50FE08;
4469
4470 //----- (00439474) --------------------------------------------------------
4471 bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
4472 {
4473 signed int v3; // eax@1
4474 LayingItem *v4; // ebx@1
4475 int v5; // edx@3
4476 bool uPlayerID; // eax@3
4477 Player *pPlayer; // edi@4
4478 Actor *pMonster; // esi@7
4479 LayingItem *v9; // ebx@12
4480 int v10; // eax@12
4481 int v11; // ebx@12
4482 unsigned int v12; // ecx@12
4483 int v13; // edx@15
4484 int v14; // edx@17
4485 int v15; // eax@24
4486 unsigned __int16 v16; // cx@25
4487 int v17; // eax@29
4488 int v18; // eax@38
4489 unsigned __int8 v19; // zf@38
4490 unsigned __int8 v20; // sf@38
4491 int v21; // edx@44
4492 int v22; // eax@44
4493 unsigned __int8 v23; // zf@44
4494 unsigned __int8 v24; // sf@44
4495 int v25; // edx@51
4496 int v26; // ecx@51
4497 signed int v27; // eax@51
4498 int v28; // eax@53
4499 signed int v29; // eax@76
4500 signed int v30; // eax@84
4501 signed int v31; // eax@92
4502 int v32; // eax@94
4503 int v33; // eax@100
4504 int v34; // eax@104
4505 signed int v35; // eax@104
4506 double v36; // st7@104
4507 float v37; // ST08_4@104
4508 float v38; // ST04_4@104
4509 float v39; // ST00_4@104
4510 int v40; // ebx@107
4511 unsigned int v41; // ebx@109
4512 signed __int64 v42; // qax@125
4513 unsigned __int16 v43; // ax@132
4514 char v44; // bl@132
4515 unsigned __int16 v45; // ax@132
4516 unsigned __int64 v46; // [sp+Ch] [bp-60h]@6
4517 const char *v47; // [sp+14h] [bp-58h]@104
4518 char *pPlayerName; // [sp+18h] [bp-54h]@12
4519 char *pMonsterName; // [sp+1Ch] [bp-50h]@6
4520 int v50; // [sp+20h] [bp-4Ch]@6
4521 unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6
4522 int v52; // [sp+34h] [bp-38h]@12
4523 int v53; // [sp+38h] [bp-34h]@10
4524 int v54; // [sp+3Ch] [bp-30h]@1
4525 int v55; // [sp+40h] [bp-2Ch]@12
4526 signed int a4; // [sp+44h] [bp-28h]@1
4527 PlayerEquipment *v57; // [sp+48h] [bp-24h]@10
4528 int v58; // [sp+4Ch] [bp-20h]@10
4529 int v59; // [sp+50h] [bp-1Ch]@1
4530 unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
4531 int v61; // [sp+58h] [bp-14h]@1
4532 int v62; // [sp+5Ch] [bp-10h]@1
4533 int uDamageAmount; // [sp+60h] [bp-Ch]@1
4534 int a2; // [sp+64h] [bp-8h]@27
4535 int a3; // [sp+6Bh] [bp-1h]@6
4536
4537 v3 = a1;
4538 v4 = 0;
4539 uActorID_Monster_ = uActorID_Monster;
4540 v54 = a1;
4541 uDamageAmount = 0;
4542 a4 = 0;
4543 v61 = 0;
4544 v59 = 0;
4545 v62 = 0;
4546 if ( (a1 & 7) == 2 )
4547 {
4548 v4 = &pLayingItems[a1 >> 3];
4549 uDamageAmount = (int)v4;
4550 v61 = v4->field_60_distance_related_prolly_lod;
4551 v3 = v4->field_58;
4552 v54 = v4->field_58;
4553 }
4554 v5 = v3 & 7;
4555 uPlayerID = v3 >> 3;
4556 if ( v5 != 4 )
4557 return uPlayerID;
4558 pPlayer = &pParty->pPlayers[uPlayerID];
4559 if ( uPlayerID < 0 && uPlayerID > 3 )
4560 {
4561 MessageBoxW(nullptr, L"Invalid player in damageMonsterFromParty!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Damage.cpp:457", 0);
4562 }
4563 pMonster = &pActors[uActorID_Monster_];
4564 uPlayerID = pMonster->IsAlive();
4565 if ( uPlayerID )
4566 return uPlayerID;
4567 BYTE1(pMonster->uAttributes) |= 0xC0u;
4568 if ( pMonster->uAIState == Fleeing )
4569 pMonster->uAttributes |= 0x20000u;
4570 v58 = 0;
4571 v53 = 0;
4572 v57 = 0;
4573 if ( !v4 )
4574 {
4575 v51 = (unsigned __int64 *)pPlayer->pEquipment.uMainHand;
4576 v59 = 1;
4577 if ( pPlayer->HasItemEquipped(EQUIP_TWO_HANDED) )
4578 {
4579 v55 = pItemsTable->pItems[*(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)v51 + 5]].uSkillType;
4580 v28 = SkillToMastery(pPlayer->pActiveSkills[v55]);
4581 uDamageAmount = v28;
4582 if ( v55 )
4583 {
4584 if ( v55 == 6 )
4585 {
4586 if ( v28 >= 3 )
4587 {
4588 LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
4589 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4590 if ( rand() % 100 < (unsigned __int8)v51 )
4591 v58 = 1;
4592 }
4593 if ( uDamageAmount >= 4 )
4594 {
4595 LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
4596 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4597 if ( rand() % 100 < (unsigned __int8)v51 )
4598 v53 = 1;
4599 }
4600 }
4601 }
4602 else
4603 {
4604 if ( uDamageAmount >= 3 )
4605 {
4606 LOBYTE(v51) = pPlayer->GetActualSkillLevel((PLAYER_SKILL_TYPE)0) & 0x3F;
4607 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4608 if ( rand() % 100 < (unsigned __int8)v51 )
4609 v58 = 1;
4610 }
4611 }
4612 }
4613 v50 = pMonster->pMonsterInfo.uID;
4614 a2 = 4;
4615 v27 = pPlayer->CalculateMeleeDamageTo(0, 0, v50);
4616 goto LABEL_65;
4617 }
4618 v19 = v4->field_48 == 99;
4619 v61 = v4->field_60_distance_related_prolly_lod;
4620 if ( !v19 )
4621 {
4622 v9 = (LayingItem *)uDamageAmount;
4623 v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4);
4624 v55 = abs(v50);
4625 pMonsterName = (char *)(pParty->vPosition.y - v9->vPosition.y);
4626 v51 = (unsigned __int64 *)abs((int)pMonsterName);
4627 pPlayerName = (char *)(pParty->vPosition.z - v9->vPosition.z);
4628 v52 = abs((int)pPlayerName);
4629 v61 = v55;
4630 v10 = v55;
4631 v11 = (int)v51;
4632 v12 = v52;
4633 if ( v55 < (signed int)v51 )
4634 {
4635 v10 = (int)v51;
4636 v11 = v55;
4637 }
4638 if ( v10 < v52 )
4639 {
4640 v13 = v10;
4641 v10 = v52;
4642 v12 = v13;
4643 }
4644 if ( v11 < (signed int)v12 )
4645 {
4646 v14 = v12;
4647 v12 = v11;
4648 v11 = v14;
4649 }
4650 uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
4651 v61 = uPlayerID;
4652 if ( uPlayerID >= 2560 )
4653 {
4654 if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
4655 return uPlayerID;
4656 v61 = 2;
4657 }
4658 else
4659 {
4660 v61 = 1;
4661 }
4662 v4 = (LayingItem *)uDamageAmount;
4663 }
4664 v15 = v4->field_48;
4665 if ( v15 == 102 )
4666 {
4667 v16 = pPlayer->pActiveSkills[7];
4668 v61 = 1;
4669 if ( (signed int)SkillToMastery(v16) >= 3 )
4670 a4 = pPlayer->pActiveSkills[7] & 0x3F;
4671 a2 = 4;
4672 uDamageAmount = pPlayer->CalculateMeleeDamageTo(1, 1, 0);
4673 goto LABEL_67;
4674 }
4675 if ( v15 != 100 )
4676 {
4677 if ( v15 == 101 )
4678 {
4679 a2 = 0;
4680 v18 = pPlayer->CalculateRangedDamageTo(0);
4681 v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
4682 v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
4683 uDamageAmount = v18;
4684 if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
4685 uDamageAmount >>= 1;
4686 v59 = 1;
4687 goto LABEL_67;
4688 }
4689 if ( v15 == 39 )
4690 {
4691 a4 = 5 * v4->field_4C;
4692 a2 = pPlayer->GetSpellSchool(0x27u);
4693 v21 = v4->field_4C;
4694 v50 = pMonster->sCurrentHP;
4695 pMonsterName = (char *)v4->field_50;
4696 v22 = _43AFE3_calc_spell_damage(39, v21, (signed int)pMonsterName, v50);
4697 v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
4698 v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
4699 uDamageAmount = v22;
4700 if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
4701 uDamageAmount >>= 1;
4702 v59 = 0;
4703 LABEL_67:
4704 if ( !stru_50C198.PlayerHitOrMiss(pPlayer, pMonster, v61, a4) )
4705 {
4706 LABEL_68:
4707 LOWORD(uPlayerID) = pPlayer->PlaySound(52, 0);
4708 return uPlayerID;
4709 }
4710 goto LABEL_69;
4711 }
4712 if ( v15 == 34 )
4713 {
4714 uDamageAmount = 0;
4715 a2 = 4;
4716 v58 = 1;
4717 goto LABEL_67;
4718 }
4719 v50 = v4->field_48;
4720 a2 = pPlayer->GetSpellSchool(v50);
4721 v25 = v4->field_4C;
4722 v26 = v4->field_48;
4723 v50 = pMonster->sCurrentHP;
4724 pMonsterName = (char *)v4->field_50;
4725 v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50);
4726 v59 = 0;
4727 v57 = (PlayerEquipment *)1;
4728 LABEL_65:
4729 uDamageAmount = v27;
4730 goto LABEL_66;
4731 }
4732 v50 = pMonster->word_000086_some_monster_id;
4733 a2 = 4;
4734 v17 = pPlayer->CalculateRangedDamageTo(v50);
4735 v19 = v4->stru_24.uItemID == 0;
4736 uDamageAmount = v17;
4737 if ( !v19 && v4->stru_24.uAdditionalValue == 3 )
4738 {
4739 a2 = 0;
4740 v57 = (PlayerEquipment *)1;
4741 }
4742 if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0
4743 && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
4744 uDamageAmount >>= 1;
4745 v59 = 1;
4746 LABEL_66:
4747 if ( !v57 )
4748 goto LABEL_67;
4749 LABEL_69:
4750 if ( pPlayer->pConditions[1] )
4751 uDamageAmount >>= 1;
4752 if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
4753 uDamageAmount = 0;
4754 v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount);
4755 if ( !v4 && pPlayer->IsUnarmed() && (signed __int64)pPlayer->pPlayerBuffs[6].uExpireTime > 0 )
4756 {
4757 v50 = pPlayer->pPlayerBuffs[6].uPower;
4758 v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50);
4759 v61 += v29;
4760 }
4761 uDamageAmount = v61;
4762 if ( v59 )
4763 {
4764 if ( v4 )
4765 {
4766 a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62);
4767 if ( v62 && pMonster->sCurrentHP > 0 )
4768 {
4769 pPlayer->sHealth += v61 / 5;
4770 if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
4771 pPlayer->sHealth = pPlayer->GetMaxHealth();
4772 v62 = 0;
4773 }
4774 v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
4775 uDamageAmount = v61 + v30;
4776 }
4777 else
4778 {
4779 v59 = 0;
4780 v57 = &pPlayer->pEquipment;
4781 do
4782 {
4783 if ( pPlayer->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
4784 {
4785 auto _s = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v57->uOffHand + 5];
4786 a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
4787 if ( v62 && pMonster->sCurrentHP > 0 )
4788 {
4789 pPlayer->sHealth += v61 / 5;
4790 if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
4791 pPlayer->sHealth = pPlayer->GetMaxHealth();
4792 v62 = 0;
4793 }
4794 v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
4795 uDamageAmount += v31;
4796 }
4797 ++v59;
4798 v57 = (PlayerEquipment *)((char *)v57 + 4);
4799 }
4800 while ( v59 <= 1 );
4801 }
4802 }
4803 v32 = uDamageAmount;
4804 pMonster->sCurrentHP -= uDamageAmount;
4805 if ( !v32 && !v58 )
4806 goto LABEL_68;
4807 if ( pMonster->sCurrentHP > 0 )
4808 {
4809 Actor::_4030AD(uActorID_Monster_, v54, 0);
4810 Actor::_43AC45(uActorID_Monster_, 1);
4811 if ( bShowDamage )
4812 {
4813 v50 = uDamageAmount;
4814 pMonsterName = (char *)pMonster;
4815 pPlayerName = pPlayer->pName;
4816 if ( v4 )
4817 v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points"
4818 else
4819 v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage"
4820 sprintf(pTmpBuf, v47, pPlayerName, pMonsterName, v50);
4821 ShowStatusBarString(pTmpBuf, 2u);
4822 }
4823 v41 = 0;
4824 }
4825 else
4826 {
4827 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 )
4828 {
4829 v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius;
4830 v55 = v33;
4831 if ( pRenderer->pRenderD3D )
4832 {
4833 if ( pGame->uFlags2 & 0x20 )
4834 {
4835 v50 = 0;
4836 pMonsterName = 0;
4837 v34 = pMonster->vPosition.z;
4838 *(float *)&pPlayerName = (double)v55;
4839 v51 = (unsigned __int64 *)v34;
4840 *(float *)&v47 = 0.0;
4841 v35 = pMonster->vPosition.y;
4842 *((float *)&v46 + 1) = 0.0;
4843 *(float *)&v46 = 1.0;
4844 v36 = (double)(signed int)v51;
4845 v51 = (unsigned __int64 *)v35;
4846 v37 = v36;
4847 v51 = (unsigned __int64 *)pMonster->vPosition.x;
4848 v38 = (double)v35;
4849 v39 = (double)(signed int)v51;
4850 pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0);
4851 }
4852 }
4853 }
4854 Actor::Die(uActorID_Monster_);
4855 Actor::_438CF3(uActorID_Monster_);
4856 Actor::_43AC45(uActorID_Monster_, 1);
4857 if ( pMonster->pMonsterInfo.uExp )
4858 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
4859 v40 = 51;
4860 if ( rand() % 100 < 20 )
4861 v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
4862 pPlayer->PlaySound(v40, 0);
4863 v41 = 0;
4864 if ( bShowDamage )
4865 {
4866 v50 = (int)pMonster;
4867 pMonsterName = (char *)uDamageAmount;
4868 pPlayerName = pPlayer->pName; // "%s inflicts %lu points killing %s"
4869 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[175], pPlayer->pName, uDamageAmount, pMonster);
4870 ShowStatusBarString(pTmpBuf, 2u);
4871 }
4872 }
4873 if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41
4874 && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41
4875 || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41)
4876 && uDamageAmount != v41 )
4877 pPlayer->ReceiveDamage(uDamageAmount, a2);
4878 v50 = 24;
4879 v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP;
4880 if ( (pPlayer->_48EA46_calc_special_bonus_by_items(24) || v58 != v41)
4881 && stru_50C198.GetMagicalResistance(pMonster, 3u) )
4882 {
4883 LODWORD(v42) = 20;
4884 v59 = 10;
4885 if ( pParty->bTurnBasedModeOn == v41 )
4886 v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666);
4887 pMonster->pMonsterInfo.uRecoveryTime += v42;
4888 if ( bShowDamage != v41 )
4889 {
4890 v50 = (int)pMonster;
4891 pMonsterName = pPlayer->pName; // "%s stuns %s"
4892 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[635], pPlayer->pName, pMonster);
4893 ShowStatusBarString(pTmpBuf, 2u);
4894 }
4895 }
4896 if ( v53 != v41 )
4897 {
4898 if ( pMonster->CanAct() )
4899 {
4900 if ( stru_50C198.GetMagicalResistance(pMonster, 3u) )
4901 {
4902 LOBYTE(v43) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE);
4903 v44 = v43;
4904 v45 = SkillToMastery(v43);
4905 v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F));
4906 v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v51 * 0.033333335);
4907 pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0);
4908 if ( bShowDamage )
4909 {
4910 v50 = (int)pMonster;
4911 pMonsterName = pPlayer->pName; // "%s paralyzes %s"
4912 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[636], pPlayer->pName, pMonster);
4913 ShowStatusBarString(pTmpBuf, 2u);
4914 }
4915 }
4916 }
4917 }
4918 if ( v59 > 10 )
4919 v59 = 10;
4920 if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
4921 {
4922 pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16;
4923 pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16;
4924 pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16;
4925 pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x);
4926 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
4927 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
4928 }
4929 return Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
4930 }
4931 // 4D864C: using guessed type char byte_4D864C;
4932
4933
4934 //----- (00439FCB) --------------------------------------------------------
4935 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4)
4936 {
4937 signed int v4; // esi@1
4938 unsigned int v5; // ecx@1
4939 Player *v6; // ebx@3
4940 Actor *v7; // esi@3
4941 unsigned int v8; // eax@4
4942 char *v9; // eax@5
4943 signed int v10; // eax@6
4944 int v11; // edx@8
4945 int v12; // edx@9
4946 int v13; // edx@10
4947 int v14; // edx@16
4948 int v15; // edx@17
4949 int v16; // edx@18
4950 enum SoundID v17; // eax@24
4951 int v18; // eax@26
4952 unsigned __int8 v19; // zf@26
4953 unsigned __int8 v20; // sf@26
4954 unsigned __int16 v21; // ax@29
4955 signed int v22; // edi@36
4956 int v23; // eax@38
4957 signed int v24; // eax@44
4958 unsigned __int16 v25; // cx@47
4959 signed int v26; // eax@49
4960 int v27; // eax@54
4961 float v28; // ST18_4@58
4962 double v29; // st7@58
4963 float v30; // ST08_4@58
4964 double v31; // st7@58
4965 float v32; // ST04_4@58
4966 float v33; // ST00_4@58
4967 int v34; // edi@61
4968 int v35; // eax@70
4969 double v36; // st7@70
4970 LayingItem *v37; // ebx@77
4971 int v38; // edi@77
4972 int v39; // esi@77
4973 int v40; // eax@77
4974 int v41; // eax@77
4975 int v42; // eax@78
4976 char *v43; // eax@81
4977 Actor *v44; // esi@82
4978 char *v45; // edi@84
4979 unsigned __int16 v46; // ax@84
4980 int v47; // ebx@105
4981 int v48; // eax@107
4982 unsigned __int16 v49; // ax@116
4983 int v50; // ebx@123
4984 unsigned __int16 v51; // ax@124
4985 char v52; // bl@124
4986 int v53; // eax@128
4987 signed int v54; // eax@134
4988 unsigned __int16 v55; // cx@137
4989 signed int v56; // eax@139
4990 int v57; // eax@144
4991 float v58; // ST18_4@148
4992 double v59; // st7@148
4993 float v60; // ST08_4@148
4994 double v61; // st7@148
4995 float v62; // ST04_4@148
4996 float v63; // ST00_4@148
4997 int v64; // ebx@151
4998 int v65; // eax@161
4999 double v66; // st7@161
5000 signed int v67; // ecx@164
5001 signed int v68; // eax@170
5002 int v69; // ecx@170
5003 int v70; // eax@171
5004 enum SoundID v71; // [sp+20h] [bp-34h]@12
5005 int v72; // [sp+30h] [bp-24h]@164
5006 double v73; // [sp+40h] [bp-14h]@72
5007 signed int v74; // [sp+44h] [bp-10h]@1
5008 unsigned int v75; // [sp+48h] [bp-Ch]@3
5009 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
5010 int v77; // [sp+50h] [bp-4h]@26
5011 signed int a4a; // [sp+60h] [bp+Ch]@162
5012 Player *a4b; // [sp+60h] [bp+Ch]@168
5013
5014 v4 = (signed int)uObjID >> 3;
5015 v5 = (uObjID & 7) - 2;
5016 v74 = a2;
5017 uActorID = v4;
5018 if ( v5 )
5019 {
5020 if ( v5 != 1
5021 || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4],
5022 v75 = v6->sHealth,
5023 !stru_50C198.ActorHitOrMiss(v7, v6)) )
5024 return;
5025 v8 = v6->pEquipment.uBody;
5026 if ( !v8
5027 || (v9 = (char *)v6 + 36 * v8, v9[516] & 2)
5028 || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10)
5029 || v10 > 11 )
5030 {
5031 v14 = rand() % 4;
5032 if ( !v14 )
5033 {
5034 v71 = (SoundID)108;
5035 goto LABEL_24;
5036 }
5037 v15 = v14 - 1;
5038 if ( !v15 )
5039 {
5040 v71 = (SoundID)109;
5041 goto LABEL_24;
5042 }
5043 v16 = v15 - 1;
5044 if ( !v16 )
5045 {
5046 v71 = (SoundID)110;
5047 goto LABEL_24;
5048 }
5049 if ( v16 == 1 )
5050 {
5051 v71 = (SoundID)44;
5052 goto LABEL_24;
5053 }
5054 }
5055 else
5056 {
5057 v11 = rand() % 4;
5058 if ( !v11 )
5059 {
5060 v71 = (SoundID)105;
5061 goto LABEL_24;
5062 }
5063 v12 = v11 - 1;
5064 if ( !v12 )
5065 {
5066 v71 = (SoundID)106;
5067 goto LABEL_24;
5068 }
5069 v13 = v12 - 1;
5070 if ( !v13 )
5071 {
5072 v71 = (SoundID)107;
5073 goto LABEL_24;
5074 }
5075 if ( v13 == 1 )
5076 {
5077 v71 = (SoundID)45;
5078 LABEL_24:
5079 v17 = v71;
5080 goto LABEL_26;
5081 }
5082 }
5083 v17 = (SoundID)a4;
5084 LABEL_26:
5085 pAudioPlayer->PlaySound(v17, (8 * a4 + 80) | 4, 0, -1, 0, 0, 0, 0);
5086 v18 = Actor::_43B3E0_CalcDamage(v7, v74);
5087 v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0;
5088 v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0;
5089 v77 = v18;
5090 if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) )
5091 {
5092 v21 = v7->pActorBuffs[3].uPower;
5093 if ( v21 )
5094 v77 /= (signed int)v21;
5095 }
5096 if ( v74 )
5097 {
5098 if ( v74 == 1 )
5099 {
5100 v22 = v7->pMonsterInfo.uAttack2Type;
5101 }
5102 else
5103 {
5104 if ( v74 == 2 )
5105 {
5106 v23 = v7->pMonsterInfo.uSpell1ID;
5107 }
5108 else
5109 {
5110 if ( v74 != 3 )
5111 {
5112 if ( v74 == 4 )
5113 v22 = v7->pMonsterInfo.field_3C_some_special_attack;
5114 else
5115 v22 = 4;
5116 goto LABEL_43;
5117 }
5118 v23 = v7->pMonsterInfo.uSpell2ID;
5119 }
5120 v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool);
5121 }
5122 }
5123 else
5124 {
5125 v22 = v7->pMonsterInfo.uAttack1Type;
5126 }
5127 LABEL_43:
5128 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
5129 {
5130 v24 = v6->ReceiveDamage(v77, v22);
5131 if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0
5132 && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) )
5133 {
5134 v25 = v7->uAIState;
5135 if ( v25 != 5 )
5136 {
5137 if ( v25 != 4 )
5138 {
5139 v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24);
5140 v7->sCurrentHP -= v26;
5141 if ( v26 )
5142 {
5143 if ( v7->sCurrentHP >= 1 )
5144 {
5145 Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
5146 Actor::_43AC45(uActorID, 1);
5147 }
5148 else
5149 {
5150 if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 )
5151 {
5152 v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius;
5153 v74 = v27;
5154 if ( pRenderer->pRenderD3D )
5155 {
5156 if ( pGame->uFlags2 & 0x20 )
5157 {
5158 v28 = (double)v74;
5159 v74 = v7->vPosition.z;
5160 v29 = (double)v74;
5161 v74 = v7->vPosition.y;
5162 v30 = v29;
5163 v31 = (double)v74;
5164 v74 = v7->vPosition.x;
5165 v32 = v31;
5166 v33 = (double)v74;
5167 pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0);
5168 }
5169 }
5170 }
5171 Actor::Die(uActorID);
5172 Actor::_438CF3(uActorID);
5173 Actor::_43AC45(uActorID, 1);
5174 if ( v7->pMonsterInfo.uExp )
5175 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
5176 v34 = 51;
5177 if ( rand() % 100 < 20 )
5178 v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
5179 v6->PlaySound(v34, 0);
5180 }
5181 }
5182 }
5183 }
5184 }
5185 if ( !(dword_6BE368_debug_settings_2 & 0x10)
5186 && v7->pMonsterInfo.uSpecialAttack
5187 && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType )
5188 v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7);
5189 }
5190 if ( !pParty->bTurnBasedModeOn )
5191 {
5192 v35 = v6->GetActualEndurance();
5193 v36 = (double)(20 - v6->_48EA1B_get_static_effect(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
5194 v6->SetRecoveryTime((signed __int64)v36);
5195 }
5196 if ( v77 )
5197 {
5198 v73 = (double)(signed int)v75;
5199 if ( (double)v6->GetMaxHealth() * 0.25 < v73 )
5200 {
5201 if ( v6->sHealth > 0 )
5202 {
5203 if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
5204 v6->PlaySound(48, 0);
5205 }
5206 }
5207 }
5208 viewparams->bRedrawGameUI = 1;
5209 return;
5210 }
5211 v37 = &pLayingItems[uActorID];
5212 v38 = v37->field_58 & 7;
5213 v39 = v37->field_58 >> 3;
5214 v40 = v37->field_58 & 7;
5215 uActorID = v37->field_58 >> 3;
5216 v41 = v40 - 2;
5217 if ( !v41 )
5218 goto LABEL_80;
5219 v42 = v41 - 1;
5220 if ( !v42 )
5221 {
5222 v44 = &pActors[v39];
5223 if ( a4 == -1 )
5224 a4 = stru_50C198.which_player_would_attack(v44);
5225 v45 = (char *)&pParty->pPlayers[a4];
5226 v77 = Actor::_43B3E0_CalcDamage(v44, v74);
5227 v46 = v37->uItemType;
5228 if ( v37->uItemType == 545 )
5229 {
5230 LOBYTE(v51) = ((Player *)v45)->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5231 v52 = v51;
5232 if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) )
5233 {
5234 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[637], v45 + 168);
5235 ShowStatusBarString(pTmpBuf, 2u);
5236 ((Player *)v45)->PlaySound(6, 0);
5237 return;
5238 }
5239 }
5240 else
5241 {
5242 if ( v46 != 555
5243 && v46 != 510
5244 && v46 != 500
5245 && v46 != 515
5246 && v46 != 505
5247 && v46 != 530
5248 && v46 != 525
5249 && v46 != 520
5250 && v46 != 535
5251 && v46 != 540 )
5252 goto LABEL_115;
5253 }
5254 if ( !stru_50C198.ActorHitOrMiss(v44, (Player *)v45) )
5255 return;
5256 if ( *((_QWORD *)v45 + 782) > 0i64 )
5257 v77 >>= 1;
5258 if ( ((Player *)v45)->HasEnchantedItemEquipped(36) )
5259 v77 >>= 1;
5260 if ( ((Player *)v45)->HasEnchantedItemEquipped(69) )
5261 v77 >>= 1;
5262 if ( ((Player *)v45)->HasItemEquipped(EQUIP_ARMOUR)
5263 && *(int *)&v45[36 * *((int *)v45 + 1621) + 496] == 504 )
5264 v77 >>= 1;
5265 v75 = 0;
5266 v47 = (int)(v45 + 6472);
5267 do
5268 {
5269 if ( ((Player *)v45)->HasItemEquipped((ITEM_EQUIP_TYPE)v75) )
5270 {
5271 v48 = *(int *)&v45[36 * *(int *)v47 + 496];
5272 if ( v48 == 520 )
5273 v77 >>= 1;
5274 if ( v48 == 531 )
5275 v77 >>= 1;
5276 if ( ((Player *)v45)->GetEquippedItemEquipType(v75) == 4 && SkillToMastery(*((short *)v45 + 140)) == 4 )
5277 v77 >>= 1;
5278 }
5279 ++v75;
5280 v47 += 4;
5281 }
5282 while ( (signed int)v75 <= 1 );
5283 LABEL_115:
5284 if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 )
5285 {
5286 v49 = v44->pActorBuffs[3].uPower;
5287 if ( v49 )
5288 v77 /= (signed int)v49;
5289 }
5290 if ( !v74 )
5291 {
5292 v50 = v44->pMonsterInfo.uAttack1Type;
5293 goto LABEL_133;
5294 }
5295 if ( v74 == 1 )
5296 {
5297 v50 = v44->pMonsterInfo.uAttack2Type;
5298 goto LABEL_133;
5299 }
5300 if ( v74 == 2 )
5301 {
5302 v53 = v44->pMonsterInfo.uSpell1ID;
5303 }
5304 else
5305 {
5306 if ( v74 != 3 )
5307 {
5308 if ( v74 == 4 )
5309 v50 = v44->pMonsterInfo.field_3C_some_special_attack;
5310 else
5311 v50 = 4;
5312 LABEL_133:
5313 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
5314 {
5315 v54 = ((Player *)v45)->ReceiveDamage(v77, v50);
5316 if ( *((int *)v45 + 1553) >= 0 )
5317 {
5318 if ( *((int *)v45 + 1553) > 0 || *((int *)v45 + 1552) )
5319 {
5320 v55 = v44->uAIState;
5321 if ( v55 != 5 )
5322 {
5323 if ( v55 != 4 )
5324 {
5325 v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54);
5326 v44->sCurrentHP -= v56;
5327 if ( v56 )
5328 {
5329 if ( v44->sCurrentHP >= 1 )
5330 {
5331 Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
5332 Actor::_43AC45(uActorID, 1);
5333 }
5334 else
5335 {
5336 if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 )
5337 {
5338 v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius;
5339 v75 = v57;
5340 if ( pRenderer->pRenderD3D )
5341 {
5342 if ( pGame->uFlags2 & 0x20 )
5343 {
5344 v58 = (double)(signed int)v75;
5345 v75 = v44->vPosition.z;
5346 v59 = (double)(signed int)v75;
5347 v75 = v44->vPosition.y;
5348 v60 = v59;
5349 v61 = (double)(signed int)v75;
5350 v75 = v44->vPosition.x;
5351 v62 = v61;
5352 v63 = (double)(signed int)v75;
5353 pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0);
5354 }
5355 }
5356 }
5357 Actor::Die(uActorID);
5358 Actor::_438CF3(uActorID);
5359 Actor::_43AC45(uActorID, 1);
5360 if ( v44->pMonsterInfo.uExp )
5361 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
5362 v64 = 51;
5363 if ( rand() % 100 < 20 )
5364 v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
5365 ((Player *)v45)->PlaySound(v64, 0);
5366 }
5367 }
5368 }
5369 }
5370 }
5371 }
5372 }
5373 if ( !v74
5374 && !(dword_6BE368_debug_settings_2 & 0x10)
5375 && v44->pMonsterInfo.uSpecialAttack
5376 && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType )
5377 ((Player *)v45)->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44);
5378 if ( !pParty->bTurnBasedModeOn )
5379 {
5380 v65 = ((Player *)v45)->GetActualEndurance();
5381 v66 = (double)(20 - ((Player *)v45)->_48EA1B_get_static_effect(v65))
5382 * flt_6BE3A4_debug_recmod1
5383 * 2.133333333333333;
5384 ((Player *)v45)->SetRecoveryTime((signed __int64)v66);
5385 }
5386 return;
5387 }
5388 v53 = v44->pMonsterInfo.uSpell2ID;
5389 }
5390 v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool);
5391 goto LABEL_133;
5392 }
5393 if ( v42 != 1 )
5394 return;
5395 LABEL_80:
5396 if ( a4 != -1 )
5397 {
5398 v43 = (char *)&pParty->pPlayers[a4];
5399 LABEL_168:
5400 a4b = (Player *)v43;
5401 if ( v38 != 4 || v37->field_48 != 100 )
5402 {
5403 v70 = ((Player *)v43)->GetMaxHealth();
5404 v68 = _43AFE3_calc_spell_damage(v37->field_48, v37->field_4C, v37->field_50, v70);
5405 v69 = LOBYTE(pSpellStats->pInfos[v37->field_48].uSchool);
5406 }
5407 else
5408 {
5409 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
5410 v69 = 0;
5411 }
5412 a4b->ReceiveDamage(v68, v69);
5413 if ( v38 == 4 && !qword_A750D8 )
5414 {
5415 qword_A750D8 = 256i64;
5416 word_A750E0 = 44;
5417 word_A750E2 = uActorID + 1;
5418 }
5419 return;
5420 }
5421 v74 = 0;
5422 a4a = 1;
5423 do
5424 {
5425 if ( pPlayers[a4a]->CanAct() )
5426 {
5427 v67 = v74++;
5428 *(&v72 + v67) = a4a;
5429 }
5430 ++a4a;
5431 }
5432 while ( a4a <= 4 );
5433 if ( v74 )
5434 {
5435 v43 = &stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
5436 goto LABEL_168;
5437 }
5438 }
5439
5440
5441 //----- (0043A97E) --------------------------------------------------------
5442 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
5443 {
5444 unsigned int v2; // esi@1
5445 unsigned int v3; // ebx@1
5446 int v4; // edi@1
5447 int v5; // edx@1
5448 unsigned int v6; // [sp+10h] [bp-4h]@1
5449
5450 v6 = uLayingItemID;
5451 v2 = uLayingItemID;
5452 v3 = a2 >> 3;
5453 v4 = pLayingItems[uLayingItemID].field_58 & 7;
5454 v5 = (a2 & 7) - 3;
5455 if ( v5 )
5456 {
5457 if ( v5 == 1 )
5458 {
5459 layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
5460 layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
5461 layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
5462 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
5463 DamagePlayerFromMonster(8 * v6 | 2, pLayingItems[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu);
5464 }
5465 }
5466 else
5467 {
5468 layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
5469 layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
5470 layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
5471 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
5472 switch ( v4 )
5473 {
5474 case OBJECT_Actor:
5475 sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pLayingItems[v2].field_61);
5476 break;
5477 case OBJECT_Player:
5478 DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
5479 break;
5480 case OBJECT_Item:
5481 sub_43B057(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
5482 break;
5483 }
5484 }
5485 }
5486
5487 //----- (0043AA99) --------------------------------------------------------
5488 void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz)
5489 {
5490 int v7; // ebx@1
5491 int v8; // ST14_4@1
5492 int v9; // edi@1
5493 int anglea; // [sp+20h] [bp+8h]@1
5494
5495 v7 = sRotX;
5496 v8 = sDepth;
5497 v9 = sRotY;
5498 anglea = (unsigned __int64)(stru_5C6E00->SinCos(sRotX) * (signed __int64)sDepth) >> 16;
5499 *outx = v.x + ((unsigned __int64)(stru_5C6E00->SinCos(v9) * (signed __int64)anglea) >> 16);
5500 *outy = v.y
5501 + ((unsigned __int64)(stru_5C6E00->SinCos(v9 - stru_5C6E00->uIntegerHalfPi)
5502 * (signed __int64)anglea) >> 16);
5503 *outz = v.z
5504 + ((unsigned __int64)(stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v8) >> 16);
5505 }
5506
5507 //----- (0043AB61) --------------------------------------------------------
5508 void Vec3_int_::Normalize(int *x, int *y, int *z)
5509 {
5510 int *v3; // edi@1
5511 int *v4; // esi@1
5512 signed int v5; // eax@1
5513
5514 v3 = x;
5515 v4 = y;
5516 v5 = sub_452A9E(*y * *y + *z * *z + *x * *x);
5517 *v3 *= 65536 / (v5 | 1);
5518 *v4 *= 65536 / (v5 | 1);
5519 *z *= 65536 / (v5 | 1);
5520 }
5521
5522
5523
5524
5525 //----- (0043AE12) --------------------------------------------------------
5526 double __fastcall sub_43AE12(signed int a1)
5527 {
5528 signed int v1; // ST00_4@1
5529 signed int v2; // ecx@1
5530 double v3; // st7@1
5531 double result; // st7@6
5532
5533 v1 = a1;
5534 v2 = 0;
5535 v3 = (double)v1;
5536 do
5537 {
5538 if ( v3 < flt_4E4A80[v2 + 5] )
5539 break;
5540 ++v2;
5541 }
5542 while ( v2 < 5 );
5543 if ( v2 <= 0 || v2 >= 5 )
5544 {
5545 if ( v2 )
5546 result = flt_4E4A80[4];
5547 else
5548 result = flt_4E4A80[0];
5549 }
5550 else
5551 {
5552 result = (flt_4E4A80[v2] - *(float *)&aAuthenticamd[4 * v2 + 12])
5553 * (v3 - flt_4E4A80[v2 + 4])
5554 / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4])
5555 + flt_4E4A80[v2];
5556 }
5557 return result;
5558 }
5559
5560 //----- (0043AFE3) --------------------------------------------------------
5561 int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4)
5562 {
5563 int result; // eax@1
5564 unsigned int v5; // [sp-4h] [bp-8h]@9
5565
5566 result = 0;
5567 if ( a1 == 7 )
5568 {
5569 if ( a3 <= 0 )
5570 return result;
5571 if ( a3 <= 2 )
5572 {
5573 v5 = 6;
5574 }
5575 else
5576 {
5577 if ( a3 == 3 )
5578 {
5579 v5 = 8;
5580 }
5581 else
5582 {
5583 if ( a3 != 4 )
5584 return result;
5585 v5 = 10;
5586 }
5587 }
5588 result = GetDiceResult(a2, v5);
5589 }
5590 else
5591 {
5592 if ( a1 == 44 )
5593 result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100;
5594 else
5595 result = *((char *)&pSpellDatas[0].field_10 + 20 * a1)
5596 + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1));
5597 }
5598 return result;
5599 }
5600
5601 //----- (0043B057) --------------------------------------------------------
5602 void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity)
5603 {
5604 Actor *pActor; // esi@1
5605 LayingItem *v4; // eax@3
5606 int v5; // ecx@3
5607 int v6; // eax@4
5608 int v7; // edi@4
5609 unsigned int uActorIDa; // [sp+8h] [bp-8h]@1
5610 unsigned int a2; // [sp+Ch] [bp-4h]@1
5611 int a2a; // [sp+Ch] [bp-4h]@8
5612
5613 uActorIDa = uActorID;
5614 pActor = &pActors[uActorID];
5615 a2 = uObjID;
5616 if ( !pActors[uActorID].IsAlive() )
5617 {
5618 if ( (a2 & 7) == 2 )
5619 {
5620 v4 = &pLayingItems[(signed int)a2 >> 3];
5621 v5 = v4->field_48;
5622 if ( v5 )
5623 {
5624 v6 = _43AFE3_calc_spell_damage(v5, v4->field_4C, v4->field_50, pActor->sCurrentHP);
5625 v7 = stru_50C198.CalcMagicalDamageToActor(pActor, 0, v6);
5626 pActor->sCurrentHP -= v7;
5627 if ( v7 )
5628 {
5629 if ( pActor->sCurrentHP > 0 )
5630 Actor::_4030AD(uActorIDa, a2, 0);
5631 else
5632 Actor::Die(uActorIDa);
5633 a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP;
5634 if ( 20 * v7 / (signed int)pActor->pMonsterInfo.uHP > 10 )
5635 a2a = 10;
5636 if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
5637 {
5638 pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16;
5639 pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16;
5640 pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16;
5641 pActor->vVelocity.x = 50 * LOWORD(pVelocity->x);
5642 pActor->vVelocity.y = 50 * LOWORD(pVelocity->y);
5643 pActor->vVelocity.z = 50 * LOWORD(pVelocity->z);
5644 }
5645 Actor::AddBloodsplatOnDamageOverlay(uActorIDa, 1, v7);
5646 }
5647 else
5648 {
5649 Actor::_4030AD(uActorIDa, a2, 0);
5650 }
5651 }
5652 }
5653 }
5654 }
5655
5656 //----- (0043B1B0) --------------------------------------------------------
5657 __int16 __fastcall sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4)
5658 {
5659 int v4; // ebx@1
5660 LayingItem *v5; // eax@2
5661 bool v6; // eax@3
5662 Actor *v7; // esi@4
5663 Actor *v8; // edi@4
5664 char v9; // zf@5
5665 __int64 v10; // qax@8
5666 signed __int16 v11; // cx@9
5667 signed int v12; // ecx@20
5668 int v13; // ecx@22
5669 int v14; // edi@30
5670 unsigned int uActorID; // [sp+Ch] [bp-8h]@1
5671 signed int v17; // [sp+10h] [bp-4h]@1
5672 int v18; // [sp+20h] [bp+Ch]@34
5673
5674 v4 = 0;
5675 uActorID = a2;
5676 v17 = a1;
5677 if ( (a1 & 7) == 2 )
5678 {
5679 v5 = &pLayingItems[a1 >> 3];
5680 v4 = v5->field_60_distance_related_prolly_lod;
5681 v17 = v5->field_58;
5682 }
5683 LOWORD(v6) = v17 & 7;
5684 if ( v6 == 3 )
5685 {
5686 v7 = &pActors[a2];
5687 v8 = &pActors[v17 >> 3];
5688 v6 = pActors[a2].IsAlive();
5689 if ( !v6 )
5690 {
5691 v9 = v7->uAIState == 7;
5692 v7->uLastCharacterIDToHit = v17;
5693 if ( v9 )
5694 BYTE2(v7->uAttributes) |= 2u;
5695 v6 = stru_50C198._4273BB(v8, v7, v4, 0);
5696 if ( v6 )
5697 {
5698 v10 = (unsigned int)Actor::_43B3E0_CalcDamage(v8, a4);
5699 if ( (signed __int64)v8->pActorBuffs[3].uExpireTime > 0 )
5700 {
5701 v11 = v8->pActorBuffs[3].uPower;
5702 if ( v11 )
5703 v10 = (signed int)v10 / (unsigned __int16)v11;
5704 }
5705 if ( SHIDWORD(v7->pActorBuffs[5].uExpireTime) >= SHIDWORD(v10)
5706 && (SHIDWORD(v7->pActorBuffs[5].uExpireTime) > SHIDWORD(v10)
5707 || LODWORD(v7->pActorBuffs[5].uExpireTime) > HIDWORD(v10)) )
5708 LODWORD(v10) = 0;
5709 if ( a4 != HIDWORD(v10) )
5710 {
5711 if ( a4 - HIDWORD(v10) == 1 )
5712 {
5713 v12 = v8->pMonsterInfo.uAttack2Type;
5714 if ( SHIDWORD(v7->pActorBuffs[15].uExpireTime) >= SHIDWORD(v10)
5715 && (SHIDWORD(v7->pActorBuffs[15].uExpireTime) > SHIDWORD(v10)
5716 || LODWORD(v7->pActorBuffs[15].uExpireTime) > HIDWORD(v10)) )
5717 LODWORD(v10) = (signed int)v10 >> 1;
5718 goto LABEL_30;
5719 }
5720 if ( a4 - HIDWORD(v10) == 2 )
5721 {
5722 v13 = v7->pMonsterInfo.uSpell1ID;
5723 }
5724 else
5725 {
5726 if ( a4 - HIDWORD(v10) != 3 )
5727 {
5728 if ( a4 - HIDWORD(v10) == 4 )
5729 v12 = v8->pMonsterInfo.field_3C_some_special_attack;
5730 else
5731 v12 = 4;
5732 LABEL_30:
5733 v14 = stru_50C198.CalcMagicalDamageToActor(v7, v12, v10);
5734 v7->sCurrentHP -= v14;
5735 if ( v14 )
5736 {
5737 if ( v7->sCurrentHP > 0 )
5738 Actor::_4030AD(uActorID, v17, 0);
5739 else
5740 Actor::Die(uActorID);
5741 Actor::_43AC45(uActorID, 0);
5742 v18 = 20 * v14 / (signed int)v7->pMonsterInfo.uHP;
5743 if ( 20 * v14 / (signed int)v7->pMonsterInfo.uHP > 10 )
5744 v18 = 10;
5745 if ( !MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
5746 {
5747 pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16;
5748 pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16;
5749 pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16;
5750 v7->vVelocity.x = 50 * LOWORD(pVelocity->x);
5751 v7->vVelocity.y = 50 * LOWORD(pVelocity->y);
5752 v7->vVelocity.z = 50 * LOWORD(pVelocity->z);
5753 }
5754 LOWORD(v6) = Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14);
5755 }
5756 else
5757 {
5758 LOWORD(v6) = Actor::_4030AD(uActorID, v17, 0);
5759 }
5760 return v6;
5761 }
5762 v13 = v7->pMonsterInfo.uSpell2ID;
5763 }
5764 v12 = LOBYTE(pSpellStats->pInfos[v13].uSchool);
5765 goto LABEL_30;
5766 }
5767 v12 = v8->pMonsterInfo.uAttack1Type;
5768 goto LABEL_30;
5769 }
5770 }
5771 }
5772 return v6;
5773 }
5774
5775
5776 //----- (0043BCA7) --------------------------------------------------------
5777 int __cdecl CharacterUI_LoadPaperdollTextures()
5778 {
5779 int v0; // edi@7
5780 enum CHARACTER_RACE v1; // ebx@7
5781 signed int v2; // eax@7
5782 int v3; // ebx@10
5783 Player *v4; // edi@12
5784 unsigned __int8 v5; // cl@12
5785 int v6; // edi@16
5786 unsigned int v7; // eax@16
5787 Player *v8; // ebx@16
5788 char *v9; // ebx@16
5789 char v10; // al@16
5790 signed int v11; // edi@21
5791 Player *v12; // ebx@23
5792 Player *v13; // edi@29
5793 int v14; // ebp@29
5794 stru331 *v15; // edi@65
5795 signed int v16; // ebx@66
5796 unsigned int v17; // eax@67
5797 unsigned int *v18; // ecx@67
5798 unsigned int *v19; // ebx@68
5799 int v20; // edi@73
5800 int v21; // ebp@73
5801 unsigned int v22; // eax@76
5802 int v23; // ecx@76
5803 unsigned int v24; // eax@78
5804 int v25; // ecx@78
5805 int v26; // ebx@79
5806 unsigned int v27; // eax@80
5807 int v28; // ecx@80
5808 int result; // eax@83
5809 int v30; // [sp+10h] [bp-28h]@5
5810 signed int v31; // [sp+10h] [bp-28h]@68
5811 signed int v32; // [sp+10h] [bp-28h]@75
5812 signed int v33; // [sp+10h] [bp-28h]@77
5813 int v34; // [sp+10h] [bp-28h]@79
5814 char *v35; // [sp+14h] [bp-24h]@65
5815 int v36; // [sp+14h] [bp-24h]@75
5816 int v37; // [sp+14h] [bp-24h]@77
5817 signed int v38; // [sp+14h] [bp-24h]@79
5818 unsigned int *v39; // [sp+18h] [bp-20h]@66
5819 int *v40; // [sp+18h] [bp-20h]@73
5820 unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73
5821 int v42; // [sp+20h] [bp-18h]@6
5822 int v43; // [sp+20h] [bp-18h]@73
5823 char pContainer[128]; // [sp+24h] [bp-14h]@12
5824
5825 uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
5826 if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
5827 uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
5828 uTextureID_507B04 = uTextureID_right_panel;
5829 v30 = 0;
5830 uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
5831 uTextureID_5118C8 = uTextureID_506438;
5832 do
5833 {
5834 v42 = v30 + 1;
5835 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v30 + 1) )
5836 {
5837 v0 = v30;
5838 v1 = pPlayers[v30 + 1]->GetRace();
5839 v2 = pPlayers[v30 + 1]->GetSexByVoice();
5840 if ( v1 && v1 != 1 && v1 != 2 )
5841 v3 = (v2 != 0) + 3;
5842 else
5843 v3 = (v2 != 0) + 1;
5844 wsprintfA(pContainer, "pc23v%dBod", v3);
5845 papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5846 wsprintfA(pContainer, "pc23v%dlad", v3);
5847 papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5848 wsprintfA(pContainer, "pc23v%dlau", v3);
5849 papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5850 wsprintfA(pContainer, "pc23v%drh", v3);
5851 papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5852 wsprintfA(pContainer, "pc23v%dlh", v3);
5853 papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5854 wsprintfA(pContainer, "pc23v%dlhu", v3);
5855 papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5856 v4 = pPlayers[v0 + 1];
5857 v5 = v4->uFace;
5858 if ( v5 == 12 || v5 == 13 )
5859 papredoll_dbrds[(char)v5] = 0;
5860 papredoll_flying_feet[v4->uFace] = 0;
5861 IsPlayerWearingWatersuit[v30 + 1] = 1;
5862 }
5863 else
5864 {
5865 v6 = v30;
5866 papredoll_dbods[v30] = pIcons_LOD->LoadTexture(
5867 dbod_texnames_by_face[pPlayers[v30 + 1]->uFace],
5868 TEXTURE_16BIT_PALETTE);
5869 papredoll_dlads[v30] = pIcons_LOD->LoadTexture(
5870 dlad_texnames_by_face[pPlayers[v30 + 1]->uFace],
5871 TEXTURE_16BIT_PALETTE);
5872 papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(
5873 dlau_texnames_by_face[pPlayers[v30 + 1]->uFace],
5874 TEXTURE_16BIT_PALETTE);
5875 papredoll_drhs[v30] = pIcons_LOD->LoadTexture(
5876 drh_texnames_by_face[pPlayers[v30 + 1]->uFace],
5877 TEXTURE_16BIT_PALETTE);
5878 papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(
5879 dlh_texnames_by_face[pPlayers[v30 + 1]->uFace],
5880 TEXTURE_16BIT_PALETTE);
5881 v7 = pIcons_LOD->LoadTexture(
5882 dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace],
5883 TEXTURE_16BIT_PALETTE);
5884 v8 = pPlayers[v30 + 1];
5885 papredoll_dlhus[v30] = v7;
5886 v9 = (char *)&v8->uFace;
5887 v10 = *v9;
5888 if ( *v9 == 12 || v10 == 13 )
5889 {
5890 wsprintfA(pContainer, "pc%02dbrd", v10 + 1);
5891 v9 = (char *)&pPlayers[v6 + 1]->uFace;
5892 papredoll_dbrds[*v9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5893 }
5894 wsprintfA(pContainer, "item281pc%02d", *v9 + 1);
5895 papredoll_flying_feet[pPlayers[v6 + 1]->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5896 IsPlayerWearingWatersuit[v30 + 1] = 0;
5897 }
5898 ++v30;
5899 }
5900 while ( v42 < 4 );
5901 uTextureID_ar_up_up = pIcons_LOD->LoadTexture("ar_up_up", TEXTURE_16BIT_PALETTE);
5902 uTextureID_ar_up_dn = pIcons_LOD->LoadTexture("ar_up_dn", TEXTURE_16BIT_PALETTE);
5903 uTextureID_ar_dn_up = pIcons_LOD->LoadTexture("ar_dn_up", TEXTURE_16BIT_PALETTE);
5904 uTextureID_ar_dn_dn = pIcons_LOD->LoadTexture("ar_dn_dn", TEXTURE_16BIT_PALETTE);
5905 papredoll_dbrds[9] = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
5906 papredoll_dbrds[7] = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
5907 papredoll_dbrds[5] = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
5908 papredoll_dbrds[3] = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
5909 papredoll_dbrds[1] = pIcons_LOD->LoadTexture("ib-cd5-d", TEXTURE_16BIT_PALETTE);
5910 v11 = 0;
5911 do
5912 {
5913 byte_5111C0[v11] = 0;
5914 if ( pParty->pPickedItem.uItemID != v11 + 66 )
5915 {
5916 v12 = pParty->pPlayers;
5917 while ( !sub_43EE15_player_has_item(v11 + 66, v12, 0) )
5918 {
5919 ++v12;
5920 if ( (signed int)v12 >= (signed int)pParty->pHirelings )
5921 goto LABEL_28;
5922 }
5923 }
5924 byte_5111C0[v11] = 1;
5925 LABEL_28:
5926 ++v11;
5927 }
5928 while ( v11 < 54 );
5929 *(int *)byte_5111F6 = 0;
5930 *(int *)&byte_5111F6[4] = 0;
5931 *(int *)&byte_5111F6[8] = 0;
5932 *(int *)&byte_5111F6[12] = 0;
5933 *(int *)&byte_5111F6[16] = 0;
5934 v13 = pParty->pPlayers;
5935 v14 = 1;
5936 do
5937 {
5938 if ( sub_43EE15_player_has_item(0x204u, v13, 1) )
5939 byte_5111F6[2] = 1;
5940 if ( sub_43EE15_player_has_item(0x1F8u, v13, 1) )
5941 byte_5111F6[0] = 1;
5942 if ( sub_43EE15_player_has_item(0x1F9u, v13, 1) )
5943 byte_5111F6[1] = 1;
5944 if ( sub_43EE15_player_has_item(0x215u, v13, 1) )
5945 byte_5111F6[16] = 1;
5946 if ( sub_43EE15_player_has_item(0x200u, v13, 1) )
5947 byte_5111F6[3] = 1;
5948 if ( sub_43EE15_player_has_item(0x209u, v13, 1) )
5949 byte_5111F6[4] = 1;
5950 if ( sub_43EE15_player_has_item(0x20Au, v13, 1) )
5951 byte_5111F6[5] = 1;
5952 if ( sub_43EE15_player_has_item(0x20Bu, v13, 1) )
5953 byte_5111F6[6] = 1;
5954 if ( sub_43EE15_player_has_item(0x214u, v13, 1) )
5955 byte_5111F6[7] = 1;
5956 if ( sub_43EE15_player_has_item(0x220u, v13, 1) )
5957 byte_5111F6[8] = 1;
5958 if ( sub_43EE15_player_has_item(0x20Cu, v13, 1) )
5959 byte_5111F6[9] = 1;
5960 if ( sub_43EE15_player_has_item(0x217u, v13, 1) )
5961 byte_5111F6[10] = 1;
5962 if ( sub_43EE15_player_has_item(0x20Du, v13, 1) )
5963 byte_5111F6[11] = 1;
5964 if ( sub_43EE15_player_has_item(0x212u, v13, 1) )
5965 byte_5111F6[12] = 1;
5966 if ( sub_43EE15_player_has_item(0x223u, v13, 1) )
5967 byte_5111F6[13] = 1;
5968 if ( sub_43EE15_player_has_item(0x224u, v13, 1) )
5969 byte_5111F6[14] = 1;
5970 if ( sub_43EE15_player_has_item(0x226u, v13, 1) )
5971 byte_5111F6[15] = 1;
5972 ++v13;
5973 }
5974 while ( (signed int)v13 < (signed int)pParty->pHirelings );
5975 v15 = &stru_511698.field_2C;
5976 v35 = (char *)&stru_511718.field_18;
5977 do
5978 {
5979 v16 = 0;
5980 v39 = (unsigned int *)(v35 - 24);
5981 do
5982 {
5983 _43C91D_FormItemTextureFilename(pContainer, v16 + 100, v14, 0);
5984 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5985 ++v16;
5986 v18 = v39;
5987 ++v39;
5988 *v18 = v17;
5989 }
5990 while ( v16 < 5 );
5991 _43C91D_FormItemTextureFilename(pContainer, 535, v14, 0);
5992 v31 = 0;
5993 v19 = (unsigned int *)((char *)v15 - 44);
5994 *(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5995 do
5996 {
5997 _43C91D_FormItemTextureFilename(pContainer, v31++ + 89, v14, 0);
5998 *v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
5999 ++v19;
6000 }
6001 while ( v31 < 11 );
6002 _43C91D_FormItemTextureFilename(pContainer, 521, v14, 0);
6003 v15->field_0 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6004 _43C91D_FormItemTextureFilename(pContainer, 522, v14, 0);
6005 v15->field_4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6006 _43C91D_FormItemTextureFilename(pContainer, 523, v14, 0);
6007 v15->field_8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6008 _43C91D_FormItemTextureFilename(pContainer, 532, v14, 0);
6009 v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6010 _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0);
6011 v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6012 if ( _43ED6F_check_party_races(true) )
6013 papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE);
6014 v35 += 28;
6015 ++v14;
6016 ++v15;
6017 }
6018 while ( v14 - 1 < 2 );
6019 v43 = 0;
6020 v20 = 1;
6021 v40 = &dword_511638[0][5];
6022 v21 = (int)paperdoll_array_511290[0][13];
6023 v41 = (unsigned int *)&stru_511718.texid1;
6024 do
6025 {
6026 if ( sub_43EDB9_get_some_race_sex_relation_2(v20 - 1) )
6027 {
6028 _43C91D_FormItemTextureFilename(pContainer, 524, v20, 0);
6029 v32 = 66;
6030 *v41 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6031 v36 = v21 - 152;
6032 do
6033 {
6034 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 0);
6035 *(int *)(v36 - 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6036 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 1);
6037 *(int *)v36 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6038 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 2);
6039 v22 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6040 v23 = v36;
6041 v36 += 12;
6042 ++v32;
6043 *(int *)(v23 + 4) = v22;
6044 }
6045 while ( v32 - 66 < 13 );
6046 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 0);
6047 *(int *)v21 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6048 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 1);
6049 *(int *)(v21 + 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6050 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 2);
6051 *(int *)(v21 + 8) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6052 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 0);
6053 *(int *)(v21 + 12) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6054 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 1);
6055 *(int *)(v21 + 16) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6056 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 2);
6057 *(int *)(v21 + 20) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6058 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 0);
6059 *(int *)(v21 + 24) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6060 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 1);
6061 *(int *)(v21 + 28) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6062 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 2);
6063 *(int *)(v21 + 32) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6064 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 0);
6065 *(int *)(v21 + 36) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6066 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 1);
6067 *(int *)(v21 + 40) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6068 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 2);
6069 *(int *)(v21 + 44) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6070 v33 = 0;
6071 v37 = (int)(v40 - 5);
6072 do
6073 {
6074 _43C91D_FormItemTextureFilename(pContainer, v33 + 115, v20, 0);
6075 v24 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6076 ++v33;
6077 v25 = v37;
6078 v37 += 4;
6079 *(int *)v25 = v24;
6080 }
6081 while ( v33 < 5 );
6082 _43C91D_FormItemTextureFilename(pContainer, 512, v20, 0);
6083 v26 = v43;
6084 v38 = 105;
6085 v34 = v43;
6086 *v40 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6087 do
6088 {
6089 _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
6090 *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(
6091 pContainer,
6092 TEXTURE_16BIT_PALETTE);
6093 _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1);
6094 v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6095 v28 = v34;
6096 v34 += 4;
6097 ++v38;
6098 *(int *)((char *)dword_511788 + v28) = v27;
6099 }
6100 while ( v38 - 105 < 5 );
6101 _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0);
6102 *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(
6103 pContainer,
6104 TEXTURE_16BIT_PALETTE);
6105 _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
6106 *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(
6107 pContainer,
6108 TEXTURE_16BIT_PALETTE);
6109 _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0);
6110 *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(
6111 pContainer,
6112 TEXTURE_16BIT_PALETTE);
6113 _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
6114 *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(
6115 pContainer,
6116 TEXTURE_16BIT_PALETTE);
6117 _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0);
6118 *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(
6119 pContainer,
6120 TEXTURE_16BIT_PALETTE);
6121 _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
6122 *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(
6123 pContainer,
6124 TEXTURE_16BIT_PALETTE);
6125 _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1);
6126 *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(
6127 pContainer,
6128 TEXTURE_16BIT_PALETTE);
6129 _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
6130 *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(
6131 pContainer,
6132 TEXTURE_16BIT_PALETTE);
6133 _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1);
6134 *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(
6135 pContainer,
6136 TEXTURE_16BIT_PALETTE);
6137 _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
6138 *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(
6139 pContainer,
6140 TEXTURE_16BIT_PALETTE);
6141 }
6142 else
6143 {
6144 v26 = v43;
6145 }
6146 v41 += 7;
6147 v40 += 6;
6148 v21 += 204;
6149 ++v20;
6150 result = v20 - 1;
6151 v43 = v26 + 40;
6152 }
6153 while ( v20 - 1 < 4 );
6154 return result;
6155 }
6156
6157
6158
6159 //----- (0043C91D) --------------------------------------------------------
6160 int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4)
6161 {
6162 int result; // eax@2
6163 char v5; // zf@3
6164 const char *v6; // [sp-Ch] [bp-18h]@88
6165 signed int v7; // [sp-8h] [bp-14h]@61
6166 int v8; // [sp-4h] [bp-10h]@61
6167 signed int v9; // [sp-4h] [bp-10h]@69
6168
6169 result = 0; //BUG fn is void
6170 if ( a2 <= 500 )
6171 {
6172 //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
6173 v5 = byte_5111C0[(a2 - 100) + 32 + 2] == 0;
6174 LABEL_21:
6175 if ( v5 )
6176 return result;
6177 result = 516;
6178 if ( a2 < 66 || a2 > 78 )
6179 {
6180 if ( a2 == 516 )
6181 goto LABEL_79;
6182 if ( a2 != 504 && a2 != 505 && a2 != 533 )
6183 {
6184 if ( (a2 < 100 || a2 > 104) && a2 != 524 && a2 != 535 )
6185 {
6186 if ( a2 >= 115 && a2 <= 119 || a2 == 512 )
6187 {
6188 if ( a2 == 512 )
6189 a2 = 312;
6190 goto LABEL_87;
6191 }
6192 if ( (a2 < 89 || a2 > 99) && a2 != 521 && a2 != 522 && a2 != 523 && a2 != 532 && a2 != 544 )
6193 {
6194 result = 525;
6195 if ( (a2 < 105 || a2 > 109) && a2 != 525 && a2 != 530 && a2 != 547 && a2 != 548 && a2 != 550 )
6196 return result;
6197 switch ( a2 )
6198 {
6199 case 525:
6200 a2 = 325;
6201 break;
6202 case 530:
6203 a2 = 330;
6204 break;
6205 case 547:
6206 a2 = 347;
6207 break;
6208 case 548:
6209 a2 = 348;
6210 break;
6211 case 550:
6212 a2 = 350;
6213 break;
6214 }
6215 v8 = a3;
6216 v7 = a2;
6217 if ( !a4 )
6218 goto LABEL_88;
6219 LABEL_91:
6220 v6 = "item%3.3dv%da1";
6221 return sprintf(a1, v6, v7, v8);
6222 }
6223 if ( a2 == 521 )
6224 {
6225 a2 = 239;
6226 goto LABEL_87;
6227 }
6228 if ( a2 == 522 )
6229 {
6230 a2 = 240;
6231 goto LABEL_87;
6232 }
6233 if ( a2 == 523 )
6234 {
6235 a2 = 241;
6236 goto LABEL_87;
6237 }
6238 if ( a2 != 532 )
6239 {
6240 if ( a2 == 544 )
6241 a2 = 344;
6242 goto LABEL_87;
6243 }
6244 v9 = 93;
6245 goto LABEL_70;
6246 }
6247 if ( a2 == 524 )
6248 {
6249 a2 = 324;
6250 goto LABEL_87;
6251 }
6252 if ( a2 == 535 )
6253 {
6254 v9 = 104;
6255 LABEL_70:
6256 a2 = v9;
6257 }
6258 LABEL_87:
6259 v8 = a3;
6260 v7 = a2;
6261 LABEL_88:
6262 v6 = "item%3.3dv%d";
6263 return sprintf(a1, v6, v7, v8);
6264 }
6265 }
6266 if ( a2 != 516 )
6267 {
6268 switch ( a2 )
6269 {
6270 case 504:
6271 a2 = 235;
6272 break;
6273 case 505:
6274 a2 = 236;
6275 break;
6276 case 533:
6277 a2 = 73;
6278 break;
6279 }
6280 LABEL_86:
6281 if ( a4 )
6282 {
6283 if ( a4 != 1 )
6284 {
6285 if ( a4 != 2 )
6286 return result;
6287 v8 = a3;
6288 v7 = a2;
6289 v6 = "item%3.3dv%da2";
6290 return sprintf(a1, v6, v7, v8);
6291 }
6292 v8 = a3;
6293 v7 = a2;
6294 goto LABEL_91;
6295 }
6296 goto LABEL_87;
6297 }
6298 LABEL_79:
6299 a2 = 234;
6300 goto LABEL_86;
6301 }
6302 result = a2 - 504;
6303 switch ( a2 )
6304 {
6305 case 516:
6306 v5 = byte_5111F6[2] == 0;
6307 goto LABEL_21;
6308 case 505:
6309 v5 = byte_5111F6[1] == 0;
6310 goto LABEL_21;
6311 case 504:
6312 v5 = byte_5111F6[0] == 0;
6313 goto LABEL_21;
6314 case 533:
6315 v5 = byte_5111F6[16] == 0;
6316 goto LABEL_21;
6317 case 512:
6318 v5 = byte_5111F6[3] == 0;
6319 goto LABEL_21;
6320 case 521:
6321 v5 = byte_5111F6[4] == 0;
6322 goto LABEL_21;
6323 case 522:
6324 v5 = byte_5111F6[5] == 0;
6325 goto LABEL_21;
6326 case 523:
6327 v5 = byte_5111F6[6] == 0;
6328 goto LABEL_21;
6329 case 532:
6330 v5 = byte_5111F6[7] == 0;
6331 goto LABEL_21;
6332 case 544:
6333 v5 = byte_5111F6[8] == 0;
6334 goto LABEL_21;
6335 case 524:
6336 v5 = byte_5111F6[9] == 0;
6337 goto LABEL_21;
6338 case 535:
6339 v5 = byte_5111F6[10] == 0;
6340 goto LABEL_21;
6341 case 525:
6342 v5 = byte_5111F6[11] == 0;
6343 goto LABEL_21;
6344 case 530:
6345 v5 = byte_5111F6[12] == 0;
6346 goto LABEL_21;
6347 case 547:
6348 v5 = byte_5111F6[13] == 0;
6349 goto LABEL_21;
6350 case 548:
6351 v5 = byte_5111F6[14] == 0;
6352 goto LABEL_21;
6353 case 550:
6354 v5 = byte_5111F6[15] == 0;
6355 goto LABEL_21;
6356 default:
6357 return result;
6358 }
6359 return result;
6360 }
6361
6362 //----- (0043CC7C) --------------------------------------------------------
6363 void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID)
6364 {
6365 Player **ppPlayer; // esi@1
6366 Player *pPlayer; // ebx@1
6367 enum CHARACTER_RACE v3; // edi@1
6368 signed int v4; // eax@1
6369 int v5; // edi@4
6370 unsigned int v6; // ecx@9
6371 int v7; // ecx@10
6372 unsigned int v8; // eax@14
6373 int v9; // eax@15
6374 int v10; // edx@15
6375 int v11; // ecx@15
6376 int v12; // eax@15
6377 unsigned int v13; // edi@15
6378 unsigned int v14; // ebx@18
6379 int v15; // ecx@18
6380 Texture *v16; // ebp@27
6381 double v17; // st7@29
6382 int v18; // edi@30
6383 char *v19; // eax@30
6384 Texture *v20; // edi@31
6385 unsigned int v21; // eax@37
6386 int v22; // edi@38
6387 int v23; // eax@38
6388 int v24; // ebx@38
6389 int v25; // eax@38
6390 LODFile_IconsBitmaps *v26; // ecx@42
6391 Texture *v27; // edi@51
6392 double v28; // st7@51
6393 char v29; // zf@54
6394 char *v30; // eax@54
6395 unsigned int v31; // eax@59
6396 int v32; // edx@60
6397 int v33; // eax@65
6398 int v34; // eax@74
6399 int v35; // ebx@74
6400 unsigned int v36; // ecx@74
6401 int v37; // eax@74
6402 LODFile_IconsBitmaps *v38; // ecx@78
6403 Texture *v39; // edi@85
6404 double v40; // st7@87
6405 int v41; // edi@88
6406 Texture *v42; // edi@89
6407 unsigned int v43; // eax@93
6408 int v44; // edx@94
6409 int v45; // eax@98
6410 int v46; // eax@106
6411 int v47; // ecx@106
6412 int v48; // ebx@106
6413 int v49; // eax@106
6414 LODFile_IconsBitmaps *v50; // ecx@110
6415 Texture *v51; // edi@117
6416 double v52; // st7@119
6417 int v53; // edi@120
6418 Texture *v54; // edi@121
6419 char *v55; // eax@122
6420 unsigned int v56; // eax@127
6421 int v57; // edi@128
6422 int v58; // ecx@128
6423 int v59; // ebx@129
6424 int v60; // ecx@132
6425 int v61; // eax@134
6426 int v62; // ecx@136
6427 Texture *v63; // edi@145
6428 double v64; // st7@147
6429 int v65; // edi@148
6430 char *v66; // eax@148
6431 Texture *v67; // edi@149
6432 Player *v68; // ebx@155
6433 unsigned int v69; // edx@155
6434 int v70; // edx@156
6435 unsigned int v71; // eax@160
6436 int v72; // edi@161
6437 int v73; // edx@163
6438 int v74; // ecx@168
6439 unsigned int v75; // ebx@170
6440 int v76; // ecx@172
6441 Texture *v77; // edi@181
6442 double v78; // st7@183
6443 int v79; // edi@184
6444 char *v80; // eax@184
6445 Texture *v81; // edi@185
6446 unsigned int v82; // eax@192
6447 int v83; // eax@193
6448 int v84; // eax@197
6449 int v85; // eax@197
6450 int v86; // ecx@197
6451 int v87; // eax@197
6452 int v88; // eax@198
6453 int v89; // eax@199
6454 int v90; // edi@201
6455 int v91; // edi@213
6456 int v92; // ebx@213
6457 int v93; // edi@214
6458 int v94; // ebx@214
6459 int v95; // eax@214
6460 char *v96; // edi@226
6461 double v97; // st7@228
6462 int v98; // edi@229
6463 char *v99; // eax@229
6464 Render *v100; // ecx@229
6465 Texture *v101; // edi@230
6466 int v102; // edi@236
6467 int v103; // eax@237
6468 int v104; // ecx@237
6469 int v105; // edx@237
6470 int v106; // edx@238
6471 int v107; // edx@239
6472 int v108; // edx@240
6473 int v109; // edi@250
6474 char *v110; // edx@250
6475 unsigned int v111; // eax@259
6476 int v112; // eax@260
6477 int v113; // eax@260
6478 int v114; // eax@265
6479 int v115; // eax@274
6480 int v116; // ebx@274
6481 unsigned int v117; // edi@274
6482 double v118; // st7@286
6483 int v119; // edi@287
6484 char *v120; // eax@287
6485 Texture *v121; // edi@288
6486 unsigned int v122; // edi@295
6487 int v123; // ebx@297
6488 int v124; // edi@298
6489 int v125; // ecx@303
6490 int v126; // eax@312
6491 unsigned int v127; // ebx@314
6492 int v128; // ecx@316
6493 Texture *v129; // edi@325
6494 double v130; // st7@327
6495 int v131; // edi@328
6496 char *v132; // eax@328
6497 Texture *v133; // edi@329
6498 unsigned int v134; // eax@335
6499 int v135; // eax@336
6500 int v136; // edx@336
6501 int v137; // eax@336
6502 unsigned int v138; // ebx@339
6503 int v139; // ecx@339
6504 Texture *v140; // edi@348
6505 double v141; // st7@350
6506 int v142; // edi@351
6507 char *v143; // eax@351
6508 Texture *v144; // edi@352
6509 unsigned int v145; // eax@358
6510 int v146; // eax@359
6511 int v147; // ecx@359
6512 int v148; // eax@359
6513 int v149; // edx@359
6514 int v150; // ebx@362
6515 int v151; // ecx@363
6516 int v152; // ecx@364
6517 unsigned int v153; // eax@370
6518 unsigned int v154; // edi@370
6519 int v155; // eax@370
6520 LODFile_IconsBitmaps *v156; // ecx@374
6521 Texture *v157; // ebp@381
6522 double v158; // st7@383
6523 Texture *v159; // edi@385
6524 char *v160; // eax@386
6525 unsigned int v161; // eax@393
6526 int v162; // eax@394
6527 unsigned int v163; // [sp-Ch] [bp-58h]@230
6528 unsigned int v164; // [sp-Ch] [bp-58h]@233
6529 signed int v165; // [sp-Ch] [bp-58h]@235
6530 char *v166; // [sp-8h] [bp-54h]@16
6531 const char *v167; // [sp-8h] [bp-54h]@23
6532 const char *v168; // [sp-8h] [bp-54h]@43
6533 const char *v169; // [sp-8h] [bp-54h]@79
6534 const char *v170; // [sp-8h] [bp-54h]@111
6535 const char *v171; // [sp-8h] [bp-54h]@141
6536 const char *v172; // [sp-8h] [bp-54h]@177
6537 const char *v173; // [sp-8h] [bp-54h]@222
6538 int v174; // [sp-8h] [bp-54h]@228
6539 unsigned int v175; // [sp-8h] [bp-54h]@230
6540 unsigned int v176; // [sp-8h] [bp-54h]@233
6541 signed int v177; // [sp-8h] [bp-54h]@235
6542 const char *v178; // [sp-8h] [bp-54h]@242
6543 const char *v179; // [sp-8h] [bp-54h]@280
6544 const char *v180; // [sp-8h] [bp-54h]@321
6545 char *v181; // [sp-8h] [bp-54h]@337
6546 const char *v182; // [sp-8h] [bp-54h]@344
6547 const char *v183; // [sp-8h] [bp-54h]@375
6548 signed int v184; // [sp-4h] [bp-50h]@66
6549 signed int v185; // [sp-4h] [bp-50h]@99
6550 signed int v186; // [sp-4h] [bp-50h]@202
6551 int v187; // [sp-4h] [bp-50h]@228
6552 Texture *v188; // [sp-4h] [bp-50h]@230
6553 Texture *v189; // [sp-4h] [bp-50h]@233
6554 Texture *v190; // [sp-4h] [bp-50h]@235
6555 signed int v191; // [sp-4h] [bp-50h]@266
6556 signed int v192; // [sp-4h] [bp-50h]@304
6557 unsigned int a3; // [sp+10h] [bp-3Ch]@7
6558 int a3a; // [sp+10h] [bp-3Ch]@15
6559 int a3b; // [sp+10h] [bp-3Ch]@38
6560 unsigned int a3c; // [sp+10h] [bp-3Ch]@74
6561 unsigned int a3d; // [sp+10h] [bp-3Ch]@106
6562 int a3e; // [sp+10h] [bp-3Ch]@129
6563 int a3f; // [sp+10h] [bp-3Ch]@168
6564 unsigned int a3g; // [sp+10h] [bp-3Ch]@216
6565 unsigned int a3h; // [sp+10h] [bp-3Ch]@274
6566 int a3i; // [sp+10h] [bp-3Ch]@312
6567 int a3j; // [sp+10h] [bp-3Ch]@336
6568 int a3k; // [sp+10h] [bp-3Ch]@362
6569 signed int a2; // [sp+14h] [bp-38h]@7
6570 unsigned int a2a; // [sp+14h] [bp-38h]@15
6571 Texture *a2b; // [sp+14h] [bp-38h]@49
6572 int a2c; // [sp+14h] [bp-38h]@74
6573 int a2d; // [sp+14h] [bp-38h]@106
6574 int a2e; // [sp+14h] [bp-38h]@129
6575 int a2f; // [sp+14h] [bp-38h]@168
6576 int a2g; // [sp+14h] [bp-38h]@214
6577 int a2h; // [sp+14h] [bp-38h]@274
6578 Texture *a2i; // [sp+14h] [bp-38h]@284
6579 int a2j; // [sp+14h] [bp-38h]@312
6580 int a2k; // [sp+14h] [bp-38h]@336
6581 Player *v217; // [sp+18h] [bp-34h]@1
6582 int v218; // [sp+1Ch] [bp-30h]@15
6583 int v219; // [sp+1Ch] [bp-30h]@60
6584 int v220; // [sp+1Ch] [bp-30h]@94
6585 int v221; // [sp+1Ch] [bp-30h]@128
6586 int v222; // [sp+1Ch] [bp-30h]@161
6587 int v223; // [sp+1Ch] [bp-30h]@213
6588 char v224; // [sp+1Ch] [bp-30h]@237
6589 int v225; // [sp+1Ch] [bp-30h]@260
6590 int v226; // [sp+1Ch] [bp-30h]@298
6591 int v227; // [sp+1Ch] [bp-30h]@336
6592 int v228; // [sp+1Ch] [bp-30h]@359
6593 int v229; // [sp+20h] [bp-2Ch]@15
6594 int v230; // [sp+20h] [bp-2Ch]@38
6595 int v231; // [sp+20h] [bp-2Ch]@60
6596 int v232; // [sp+20h] [bp-2Ch]@94
6597 int v233; // [sp+20h] [bp-2Ch]@128
6598 int v234; // [sp+20h] [bp-2Ch]@161
6599 int v235; // [sp+20h] [bp-2Ch]@197
6600 int v236; // [sp+20h] [bp-2Ch]@260
6601 int v237; // [sp+20h] [bp-2Ch]@298
6602 int v238; // [sp+20h] [bp-2Ch]@336
6603 int v239; // [sp+24h] [bp-28h]@6
6604 int v240; // [sp+28h] [bp-24h]@7
6605 unsigned int v241; // [sp+2Ch] [bp-20h]@38
6606 int v242; // [sp+2Ch] [bp-20h]@197
6607 unsigned int v243; // [sp+2Ch] [bp-20h]@370
6608 int v244; // [sp+34h] [bp-18h]@6
6609 signed int v245; // [sp+34h] [bp-18h]@361
6610 unsigned int uPlayerID_; // [sp+38h] [bp-14h]@1
6611 int uPlayerID_a; // [sp+38h] [bp-14h]@9
6612 signed int v248; // [sp+40h] [bp-Ch]@4
6613 int v249; // [sp+40h] [bp-Ch]@358
6614 signed int v250; // [sp+44h] [bp-8h]@1
6615
6616 ppPlayer = &pPlayers[uPlayerID];
6617 pPlayer = *ppPlayer;
6618 uPlayerID_ = uPlayerID;
6619 v217 = *ppPlayer;
6620 pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
6621 v3 = pPlayer->GetRace();
6622 v4 = pPlayer->GetSexByVoice();
6623 v250 = v4;
6624 if ( v3 && v3 != 1 && v3 != 2 )
6625 {
6626 v248 = 1;
6627 v5 = (v4 != 0) + 2;
6628 }
6629 else
6630 {
6631 v248 = 0;
6632 v5 = v4 != 0;
6633 }
6634 v239 = v5;
6635 v244 = (*ppPlayer)->uFace;
6636 pRenderer->ResetClip();
6637 pRenderer->DrawTextureIndexed(
6638 0x1D3u,
6639 0,
6640 (Texture *)(uTextureID_BACKDOLL != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BACKDOLL] : 0));
6641 if ( !IsPlayerWearingWatersuit[uPlayerID_] )
6642 {
6643 v21 = pPlayer->pEquipment.uBow;
6644 if ( !v21 )
6645 goto LABEL_59;
6646 v230 = pPlayer->pEquipment.uBow;
6647 v22 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v21 + 5];
6648 v23 = *(int *)v22;
6649 v24 = papredoll_4E4C28 + array_4E4C30[v239].equip_x - pItemsTable->pItems[v23].uEquipX;
6650 a3b = paperdoll_4E4C2C + array_4E4C30[v239].equip_y - pItemsTable->pItems[v23].uEquipY;
6651 v241 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v23].pIconName, TEXTURE_16BIT_PALETTE);
6652 v25 = *(int *)(v22 + 20);
6653 if ( !(*(int *)(v22 + 20) & 0xF0) )
6654 {
6655 if ( v25 & 2 )
6656 {
6657 v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
6658 pRenderer->_4A6776(v24, a3b, v27);
6659 }
6660 else
6661 {
6662 v29 = (v25 & 1) == 0;
6663 v30 = (char *)&pIcons_LOD->pTextures[v241];
6664 if ( v29 )
6665 {
6666 v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
6667 pRenderer->DrawTransparentGreenShade(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
6668 }
6669 else
6670 {
6671 v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
6672 pRenderer->DrawTextureTransparent(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
6673 }
6674 }
6675 LABEL_57:
6676 if ( !bRingsShownInCharScreen )
6677 pRenderer->_4A612A(v24, a3b, v27, v230);
6678 LABEL_59:
6679 v31 = v217->pEquipment.uCloak;
6680 if ( !v31 )
6681 goto LABEL_93;
6682 v231 = v217->pEquipment.uCloak;
6683 v32 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v31 + 5];
6684 v219 = v32;
6685 if ( *(int *)v32 != 525 )
6686 {
6687 switch ( *(int *)v32 )
6688 {
6689 case 0x212:
6690 v184 = 6;
6691 break;
6692 case 0x223:
6693 v184 = 7;
6694 break;
6695 case 0x224:
6696 v184 = 8;
6697 break;
6698 default:
6699 if ( *(int *)v32 != 550 )
6700 {
6701 v33 = *(int *)v32 - 105;
6702 LABEL_72:
6703 if ( v33 < 0 || v33 >= 10 )
6704 goto LABEL_93;
6705 LABEL_74:
6706 v34 = v33 + 10 * v239;
6707 v35 = paperdoll_array_511828[0][v34];
6708 a2c = papredoll_4E4C28 + paperdoll_array_4E5570[0][v34][0];// TODO indexing
6709 v36 = paperdoll_4E4C2C + paperdoll_array_4E5570[0][v34][1];
6710 v37 = *(int *)(v32 + 20);
6711 a3c = v36;
6712 if ( !(v37 & 0xF0) )
6713 {
6714 v41 = v35 + 1;
6715 if ( v37 & 2 )
6716 {
6717 v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
6718 pRenderer->_4A6776(a2c, v36, v42);
6719 }
6720 else
6721 {
6722 v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
6723 pRenderer->DrawTextureTransparent(a2c, v36, v42);
6724 }
6725 if ( !bRingsShownInCharScreen )
6726 pRenderer->_4A612A(a2c, a3c, v42, v231);
6727 LABEL_93:
6728 v240 = 4 * uPlayerID_ - 4;
6729 pRenderer->DrawTextureTransparent(
6730 papredoll_4E4C28,
6731 paperdoll_4E4C2C,
6732 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
6733 v43 = v217->pEquipment.uBody;
6734 if ( !v43 )
6735 goto LABEL_127;
6736 v232 = v217->pEquipment.uBody;
6737 v44 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v43 + 5];
6738 v220 = v44;
6739 if ( *(int *)v44 != 504 )
6740 {
6741 if ( *(int *)v44 == 505 )
6742 {
6743 v185 = 14;
6744 }
6745 else
6746 {
6747 if ( *(int *)v44 == 516 )
6748 {
6749 v185 = 13;
6750 }
6751 else
6752 {
6753 if ( *(int *)v44 != 533 )
6754 {
6755 v45 = *(int *)v44 - 66;
6756 LABEL_104:
6757 if ( v45 < 0 || v45 >= 17 )
6758 goto LABEL_127;
6759 LABEL_106:
6760 v46 = 17 * v239 + v45;
6761 a2d = papredoll_4E4C28 + paperdoll_array_4E4E30[0][v46][0];// TODO indexing
6762 v47 = paperdoll_4E4C2C + paperdoll_array_4E4E30[0][v46][1];
6763 v48 = paperdoll_array_511290[0][v46][0];
6764 v49 = *(int *)(v44 + 20);
6765 a3d = v47;
6766 if ( !(v49 & 0xF0) )
6767 {
6768 v53 = v48 + 1;
6769 if ( v49 & 2 )
6770 {
6771 v54 = (Texture *)(v53 != 0 ? (int)&pIcons_LOD->pTextures[v48] : 0);
6772 pRenderer->_4A6776(a2d, v47, v54);
6773 }
6774 else
6775 {
6776 v29 = (v49 & 1) == 0;
6777 v55 = (char *)&pIcons_LOD->pTextures[v48];
6778 if ( v29 )
6779 {
6780 v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
6781 pRenderer->DrawTransparentGreenShade(a2d, v47, v54);
6782 }
6783 else
6784 {
6785 v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
6786 pRenderer->DrawTextureTransparent(a2d, v47, v54);
6787 }
6788 }
6789 if ( !bRingsShownInCharScreen )
6790 pRenderer->_4A612A(a2d, a3d, v54, v232);
6791 LABEL_127:
6792 v56 = v217->pEquipment.field_20;
6793 if ( !v56 )
6794 goto LABEL_155;
6795 v233 = v217->pEquipment.field_20;
6796 v57 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v56 + 5];
6797 v221 = v57;
6798 v58 = *(int *)v57;
6799 if ( *(int *)v57 == 529 )
6800 {
6801 a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][1];
6802 a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][0];
6803 v59 = papredoll_flying_feet[v244];
6804 }
6805 else
6806 {
6807 if ( v58 == 512 )
6808 {
6809 a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][3];
6810 a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][2];
6811 v59 = dword_511638[v239][5];
6812 }
6813 else
6814 {
6815 v60 = v58 - 115;
6816 if ( v60 < 0 || v60 >= 5 )
6817 {
6818 a2e = 0;
6819 a3e = 0;
6820 v59 = dword_511638[v239][0];
6821 }
6822 else
6823 {
6824 v61 = v60 + 7 * v239;
6825 a3e = paperdoll_4E4C2C + dword_4E5490[0][v61][1];
6826 a2e = papredoll_4E4C28 + dword_4E5490[0][v61][0];
6827 v59 = dword_511638[0][v60 + 6 * v239];
6828 }
6829 }
6830 }
6831 v62 = *(int *)(v57 + 20);
6832 if ( !(*(int *)(v57 + 20) & 0xF0) )
6833 {
6834 v65 = v59 + 1;
6835 v66 = (char *)&pIcons_LOD->pTextures[v59];
6836 if ( v62 & 2 )
6837 {
6838 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
6839 pRenderer->_4A6776(a2e, a3e, v67);
6840 }
6841 else
6842 {
6843 if ( v62 & 1 )
6844 {
6845 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
6846 pRenderer->DrawTextureTransparent(a2e, a3e, v67);
6847 }
6848 else
6849 {
6850 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
6851 pRenderer->DrawTransparentGreenShade(a2e, a3e, v67);
6852 }
6853 }
6854 if ( !bRingsShownInCharScreen )
6855 pRenderer->_4A612A(a2e, a3e, v67, v233);
6856 LABEL_155:
6857 v68 = v217;
6858 v69 = v217->pEquipment.uMainHand;
6859 uPlayerID_a = 2 * v239;
6860 if ( !v69
6861 || (v70 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
6862 pItemsTable->pItems[v70].uEquipType != 1)
6863 && (pItemsTable->pItems[v70].uSkillType != 4 || v217->pEquipment.uOffHand) )
6864 pRenderer->DrawTextureTransparent(
6865 papredoll_4E4C28 + dword_4E5AE0[2 * v239],
6866 paperdoll_4E4C2C + dword_4E5AE0[2 * v239 + 1],
6867 (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
6868 v71 = v217->pEquipment.uBelt;
6869 if ( v71 )
6870 {
6871 v234 = v217->pEquipment.uBelt;
6872 v72 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v71 + 5];
6873 v222 = v72;
6874 if ( *(int *)v72 == 524 )
6875 {
6876 v73 = 5;
6877 }
6878 else
6879 {
6880 if ( *(int *)v72 == 535 )
6881 {
6882 v73 = 6;
6883 goto LABEL_168;
6884 }
6885 v73 = *(int *)v72 - 100;
6886 }
6887 if ( v73 >= 0 && v73 < 7 )
6888 {
6889 LABEL_168:
6890 v74 = 7 * v239 + v73;
6891 a2f = papredoll_4E4C28 + dword_4E57F0[0][v74][0];
6892 a3f = paperdoll_4E4C2C + dword_4E57F0[0][v74][1];
6893 if ( v248 != 1 || v73 == 5 )
6894 v75 = stru_511718.texids[v74];
6895 else
6896 v75 = stru_511718.texids[v73 + 7 * (v239 - 2)];
6897 v76 = *(int *)&v217->field_1F5[36 * v71 + 15];
6898 if ( !(*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) )
6899 {
6900 v79 = v75 + 1;
6901 v80 = (char *)&pIcons_LOD->pTextures[v75];
6902 if ( v76 & 2 )
6903 {
6904 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
6905 pRenderer->_4A6776(a2f, a3f, v81);
6906 }
6907 else
6908 {
6909 if ( v76 & 1 )
6910 {
6911 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
6912 pRenderer->DrawTextureTransparent(a2f, a3f, v81);
6913 }
6914 else
6915 {
6916 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
6917 pRenderer->DrawTransparentGreenShade(a2f, a3f, v81);
6918 }
6919 }
6920 if ( !bRingsShownInCharScreen )
6921 pRenderer->_4A612A(a2f, a3f, v81, v234);
6922 goto LABEL_191;
6923 }
6924 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) != 16 )
6925 {
6926 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 32 )
6927 {
6928 v172 = "sp28a";
6929 goto LABEL_181;
6930 }
6931 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 64 )
6932 {
6933 v172 = "sp30a";
6934 goto LABEL_181;
6935 }
6936 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 128 )
6937 {
6938 v172 = "sp91a";
6939 LABEL_181:
6940 v77 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v172, TEXTURE_16BIT_PALETTE)];
6941 dword_50C9A8 -= pEventTimer->uTimeElapsed;
6942 if ( dword_50C9A8 <= 0 )
6943 {
6944 dword_50C9A8 = 0;
6945 *(char *)(v222 + 20) &= 0xFu;
6946 ptr_50C9A4 = 0;
6947 }
6948 v78 = (double)GetTickCount() * 0.1;
6949 pRenderer->_4A63E6(
6950 a2f,
6951 a3f,
6952 (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0),
6953 v77,
6954 (signed __int64)v78,
6955 0,
6956 255);
6957 LABEL_191:
6958 v68 = v217;
6959 goto LABEL_192;
6960 }
6961 }
6962 v172 = "sptext01";
6963 goto LABEL_181;
6964 }
6965 }
6966 LABEL_192:
6967 v82 = v68->pEquipment.uMainHand;
6968 if ( v82 )
6969 {
6970 v83 = *(int *)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v82 + 5];
6971 if ( pItemsTable->pItems[v83].uEquipType == 1
6972 || pItemsTable->pItems[v83].uSkillType == 4 && !v68->pEquipment.uOffHand )
6973 pRenderer->DrawTextureTransparent(
6974 papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
6975 paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
6976 (Texture *)(*(unsigned int *)((char *)papredoll_dlaus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlaus + v240)] : 0));
6977 }
6978 v84 = v68->pEquipment.uBody;
6979 v235 = v84;
6980 v85 = (int)((char *)v68 + 36 * v84);
6981 v242 = v85;
6982 v86 = *(int *)(v85 + 496);
6983 v87 = *(int *)(v85 + 496) - 504;
6984 if ( v87 )
6985 {
6986 v88 = v87 - 1;
6987 if ( v88 )
6988 {
6989 v89 = v88 - 11;
6990 if ( v89 )
6991 {
6992 if ( v89 != 17 )
6993 {
6994 v90 = v86 - 66;
6995 LABEL_207:
6996 if ( v90 < 0 || v90 > 17 )
6997 {
6998 LABEL_259:
6999 v111 = v68->pEquipment.uCloak;
7000 if ( !v111 )
7001 goto LABEL_293;
7002 v236 = v68->pEquipment.uCloak;
7003 v112 = (int)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v111 + 5];
7004 v225 = v112;
7005 v113 = *(int *)v112;
7006 if ( v113 != 525 )
7007 {
7008 switch ( v113 )
7009 {
7010 case 530:
7011 v191 = 6;
7012 break;
7013 case 547:
7014 v191 = 7;
7015 break;
7016 case 548:
7017 v191 = 8;
7018 break;
7019 default:
7020 if ( v113 != 550 )
7021 {
7022 v114 = v113 - 105;
7023 LABEL_272:
7024 if ( v114 < 0 || v114 >= 10 )
7025 goto LABEL_293;
7026 LABEL_274:
7027 v115 = v114 + 10 * v239;
7028 v116 = dword_511788[v115];
7029 v115 *= 8;
7030 v117 = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
7031 a2h = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
7032 a3h = paperdoll_4E4C2C + *(int *)((char *)&dword_4E56B4 + v115);
7033 if ( v116 == pIcons_LOD->FindTextureByName("pending") )
7034 {
7035 LABEL_292:
7036 v68 = v217;
7037 LABEL_293:
7038 if ( v244 == 12 || v244 == 13 )
7039 {
7040 v122 = papredoll_dbrds[v244];
7041 if ( v122 != pIcons_LOD->FindTextureByName("Pending") )
7042 pRenderer->DrawTextureTransparent(
7043 papredoll_4E4C28 + dword_4E5AD0[2 * v244 - 24],
7044 paperdoll_4E4C2C + dword_4E5AD4[2 * v244 - 24],
7045 (Texture *)(v122 != -1 ? (int)&pIcons_LOD->pTextures[v122] : 0));
7046 }
7047 v123 = v68->pEquipment.uHelm;
7048 if ( !v123 )
7049 goto LABEL_335;
7050 v237 = v123;
7051 v124 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v123 + 5];
7052 v226 = v124;
7053 if ( *(int *)v124 != 521 )
7054 {
7055 switch ( *(int *)v124 )
7056 {
7057 case 0x20A:
7058 v192 = 12;
7059 break;
7060 case 0x20B:
7061 v192 = 13;
7062 break;
7063 case 0x214:
7064 v192 = 14;
7065 break;
7066 default:
7067 if ( *(int *)v124 != 544 )
7068 {
7069 v125 = *(int *)v124 - 89;
7070 LABEL_310:
7071 if ( v125 < 0 || v125 >= 16 )
7072 goto LABEL_335;
7073 goto LABEL_312;
7074 }
7075 v192 = 15;
7076 break;
7077 }
7078 v125 = v192;
7079 LABEL_312:
7080 v126 = 2 * (v125 + 16 * v239);
7081 a2j = papredoll_4E4C28 + dword_4E58D0[v126];
7082 a3i = paperdoll_4E4C2C + dword_4E58D4[v126];
7083 if ( v248 != 1 || *(int *)v124 != 92 )
7084 v127 = stru_511698.texids[v125 + 16 * v250];
7085 else
7086 v127 = papredoll_dbrds[11];
7087 v128 = *(int *)(v124 + 20);
7088 if ( *(int *)(v124 + 20) & 0xF0 )
7089 {
7090 if ( (*(int *)(v124 + 20) & 0xF0) != 16 )
7091 {
7092 if ( (*(int *)(v124 + 20) & 0xF0) == 32 )
7093 {
7094 v180 = "sp28a";
7095 goto LABEL_325;
7096 }
7097 if ( (*(int *)(v124 + 20) & 0xF0) == 64 )
7098 {
7099 v180 = "sp30a";
7100 goto LABEL_325;
7101 }
7102 if ( (*(int *)(v124 + 20) & 0xF0) == 128 )
7103 {
7104 v180 = "sp91a";
7105 LABEL_325:
7106 v129 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v180, TEXTURE_16BIT_PALETTE)];
7107 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7108 if ( dword_50C9A8 <= 0 )
7109 {
7110 dword_50C9A8 = 0;
7111 *(char *)(v226 + 20) &= 0xFu;
7112 ptr_50C9A4 = 0;
7113 }
7114 v130 = (double)GetTickCount() * 0.1;
7115 pRenderer->_4A63E6(
7116 a2j,
7117 a3i,
7118 (Texture *)(v127 != -1 ? (int)&pIcons_LOD->pTextures[v127] : 0),
7119 v129,
7120 (signed __int64)v130,
7121 0,
7122 255);
7123 goto LABEL_335;
7124 }
7125 }
7126 v180 = "sptext01";
7127 goto LABEL_325;
7128 }
7129 v131 = v127 + 1;
7130 v132 = (char *)&pIcons_LOD->pTextures[v127];
7131 if ( v128 & 2 )
7132 {
7133 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7134 pRenderer->_4A6776(a2j, a3i, v133);
7135 }
7136 else
7137 {
7138 if ( v128 & 1 )
7139 {
7140 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7141 pRenderer->DrawTextureTransparent(a2j, a3i, v133);
7142 }
7143 else
7144 {
7145 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7146 pRenderer->DrawTransparentGreenShade(a2j, a3i, v133);
7147 }
7148 }
7149 if ( !bRingsShownInCharScreen )
7150 pRenderer->_4A612A(a2j, a3i, v133, v237);
7151 LABEL_335:
7152 v134 = v217->pEquipment.uMainHand;
7153 if ( !v134 )
7154 goto LABEL_358;
7155 v238 = v217->pEquipment.uMainHand;
7156 v135 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v134 + 5];
7157 v227 = v135;
7158 v136 = *(int *)v135;
7159 v137 = *(int *)v135;
7160 a2k = papredoll_4E4C28
7161 + array_4E4C30[v239].field_8
7162 - pItemsTable->pItems[v137].uEquipX;
7163 a3j = paperdoll_4E4C2C
7164 + array_4E4C30[v239].field_C
7165 - pItemsTable->pItems[v137].uEquipY;
7166 if ( v136 == 64 )
7167 v181 = "item64v1";
7168 else
7169 v181 = pItemsTable->pItems[v137].pIconName;
7170 v138 = pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE);
7171 v139 = *(int *)(v227 + 20);
7172 if ( !(*(int *)(v227 + 20) & 0xF0) )
7173 {
7174 v142 = v138 + 1;
7175 v143 = (char *)&pIcons_LOD->pTextures[v138];
7176 if ( v139 & 2 )
7177 {
7178 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7179 pRenderer->_4A6776(a2k, a3j, v144);
7180 }
7181 else
7182 {
7183 if ( v139 & 1 )
7184 {
7185 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7186 pRenderer->DrawTextureTransparent(a2k, a3j, v144);
7187 }
7188 else
7189 {
7190 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7191 pRenderer->DrawTransparentGreenShade(a2k, a3j, v144);
7192 }
7193 }
7194 if ( !bRingsShownInCharScreen )
7195 pRenderer->_4A612A(a2k, a3j, v144, v238);
7196 LABEL_358:
7197 v145 = v217->pEquipment.uOffHand;
7198 v249 = v217->pEquipment.uOffHand;
7199 if ( !v145 )
7200 goto LABEL_393;
7201 v146 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v145 + 5];
7202 v228 = v146;
7203 v147 = *(int *)v146;
7204 v148 = *(int *)v146;
7205 v149 = pItemsTable->pItems[v148].uSkillType;
7206 if ( v149 != 2 && v149 != 1 )
7207 {
7208 v245 = 0;
7209 LABEL_362:
7210 v150 = papredoll_4E4C28
7211 + array_4E4C30[v239].field_0
7212 - pItemsTable->pItems[v148].uEquipX;
7213 a3k = paperdoll_4E4C2C
7214 + LODWORD(array_4E4C30[v239].field_4)
7215 - pItemsTable->pItems[v148].uEquipY;
7216 goto LABEL_370;
7217 }
7218 v151 = v147 - 400;
7219 v245 = 1;
7220 if ( v151 )
7221 {
7222 v152 = v151 - 3;
7223 if ( v152 )
7224 {
7225 if ( v152 != 12 )
7226 goto LABEL_362;
7227 v150 = 595;
7228 a3k = 33;
7229 LABEL_370:
7230 v153 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v148].pIconName, TEXTURE_16BIT_PALETTE);
7231 v154 = v153;
7232 v243 = v153;
7233 v155 = *(int *)(v228 + 20);
7234 if ( !(*(int *)(v228 + 20) & 0xF0) )
7235 {
7236 if ( v155 & 2 )
7237 {
7238 v159 = (Texture *)(v243 != -1 ? (int)&pIcons_LOD->pTextures[v243] : 0);
7239 pRenderer->_4A6776(v150, a3k, v159);
7240 }
7241 else
7242 {
7243 v29 = (v155 & 1) == 0;
7244 v160 = (char *)&pIcons_LOD->pTextures[v243];
7245 if ( v29 )
7246 {
7247 v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
7248 pRenderer->DrawTransparentGreenShade(
7249 v150,
7250 a3k,
7251 (Texture *)(v243 != -1 ? (int)v160 : 0));
7252 }
7253 else
7254 {
7255 v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
7256 pRenderer->DrawTextureTransparent(
7257 v150,
7258 a3k,
7259 (Texture *)(v243 != -1 ? (int)v160 : 0));
7260 }
7261 }
7262 if ( !bRingsShownInCharScreen )
7263 pRenderer->_4A612A(v150, a3k, v159, v249);
7264 goto LABEL_391;
7265 }
7266 if ( (*(int *)(v228 + 20) & 0xF0) != 16 )
7267 {
7268 if ( (*(int *)(v228 + 20) & 0xF0) == 32 )
7269 {
7270 v183 = "sp28a";
7271 }
7272 else
7273 {
7274 if ( (*(int *)(v228 + 20) & 0xF0) != 64 )
7275 {
7276 v156 = pIcons_LOD;
7277 if ( (*(int *)(v228 + 20) & 0xF0) == 128 )
7278 {
7279 v183 = "sp91a";
7280 LABEL_381:
7281 v157 = &pIcons_LOD->pTextures[v156->LoadTexture(
7282 v183,
7283 TEXTURE_16BIT_PALETTE)];
7284 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7285 if ( dword_50C9A8 <= 0 )
7286 {
7287 dword_50C9A8 = 0;
7288 *(char *)(v228 + 20) &= 0xFu;
7289 ptr_50C9A4 = 0;
7290 }
7291 v158 = (double)GetTickCount() * 0.1;
7292 pRenderer->_4A63E6(
7293 v150,
7294 a3k,
7295 (Texture *)(v154 != -1 ? (int)&pIcons_LOD->pTextures[v154] : 0),
7296 v157,
7297 (signed __int64)v158,
7298 0,
7299 255);
7300 LABEL_391:
7301 if ( v245 )
7302 pRenderer->DrawTextureTransparent(
7303 papredoll_4E4C28
7304 + pPaperdollLeftEmptyHand[uPlayerID_a],
7305 paperdoll_4E4C2C
7306 + pPaperdollLeftEmptyHand[uPlayerID_a + 1],
7307 (Texture *)(*(unsigned int *)((char *)papredoll_dlhs
7308 + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhs + v240)] : 0));
7309 goto LABEL_393;
7310 }
7311 LABEL_380:
7312 v183 = "sptext01";
7313 goto LABEL_381;
7314 }
7315 v183 = "sp30a";
7316 }
7317 v156 = pIcons_LOD;
7318 goto LABEL_381;
7319 }
7320 v156 = pIcons_LOD;
7321 goto LABEL_380;
7322 }
7323 a3k = 28;
7324 }
7325 else
7326 {
7327 a3k = 86;
7328 }
7329 v150 = 596;
7330 goto LABEL_370;
7331 }
7332 if ( (*(int *)(v227 + 20) & 0xF0) != 16 )
7333 {
7334 if ( (*(int *)(v227 + 20) & 0xF0) == 32 )
7335 {
7336 v182 = "sp28a";
7337 goto LABEL_348;
7338 }
7339 if ( (*(int *)(v227 + 20) & 0xF0) == 64 )
7340 {
7341 v182 = "sp30a";
7342 goto LABEL_348;
7343 }
7344 if ( (*(int *)(v227 + 20) & 0xF0) == 128 )
7345 {
7346 v182 = "sp91a";
7347 LABEL_348:
7348 v140 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v182, TEXTURE_16BIT_PALETTE)];
7349 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7350 if ( dword_50C9A8 <= 0 )
7351 {
7352 dword_50C9A8 = 0;
7353 *(char *)(v227 + 20) &= 0xFu;
7354 ptr_50C9A4 = 0;
7355 }
7356 v141 = (double)GetTickCount() * 0.1;
7357 pRenderer->_4A63E6(
7358 a2k,
7359 a3j,
7360 (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0),
7361 v140,
7362 (signed __int64)v141,
7363 0,
7364 255);
7365 goto LABEL_358;
7366 }
7367 }
7368 v182 = "sptext01";
7369 goto LABEL_348;
7370 }
7371 v125 = 11;
7372 goto LABEL_310;
7373 }
7374 if ( !(*(int *)(v225 + 20) & 0xF0) )
7375 {
7376 v119 = v116 + 1;
7377 v120 = (char *)&pIcons_LOD->pTextures[v116];
7378 if ( *(int *)(v225 + 20) & 2 )
7379 {
7380 v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
7381 pRenderer->_4A6776(a2h, a3h, v121);
7382 }
7383 else
7384 {
7385 v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
7386 pRenderer->DrawTextureTransparent(a2h, a3h, v121);
7387 }
7388 if ( !bRingsShownInCharScreen )
7389 pRenderer->_4A612A(a2h, a3h, v121, v236);
7390 goto LABEL_292;
7391 }
7392 if ( (*(int *)(v225 + 20) & 0xF0) != 16 )
7393 {
7394 if ( (*(int *)(v225 + 20) & 0xF0) == 32 )
7395 {
7396 v179 = "sp28a";
7397 goto LABEL_284;
7398 }
7399 if ( (*(int *)(v225 + 20) & 0xF0) == 64 )
7400 {
7401 v179 = "sp30a";
7402 goto LABEL_284;
7403 }
7404 if ( (*(int *)(v225 + 20) & 0xF0) == 128 )
7405 {
7406 v179 = "sp91a";
7407 LABEL_284:
7408 a2i = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v179, TEXTURE_16BIT_PALETTE)];
7409 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7410 if ( dword_50C9A8 <= 0 )
7411 {
7412 dword_50C9A8 = 0;
7413 *(char *)(v225 + 20) &= 0xFu;
7414 ptr_50C9A4 = 0;
7415 }
7416 v118 = (double)GetTickCount() * 0.1;
7417 pRenderer->_4A63E6(
7418 v117,
7419 a3h,
7420 (Texture *)(v116 != -1 ? (int)&pIcons_LOD->pTextures[v116] : 0),
7421 a2i,
7422 (signed __int64)v118,
7423 0,
7424 255);
7425 goto LABEL_292;
7426 }
7427 }
7428 v179 = "sptext01";
7429 goto LABEL_284;
7430 }
7431 v191 = 9;
7432 break;
7433 }
7434 v114 = v191;
7435 goto LABEL_274;
7436 }
7437 v114 = 5;
7438 goto LABEL_272;
7439 }
7440 LABEL_209:
7441 if ( v68->pEquipment.uMainHand
7442 && (v68->GetEquippedItemEquipType(1u) == 1
7443 || v68->GetEquippedItemSkillType(EQUIP_TWO_HANDED) == 4
7444 && !v68->pEquipment.uOffHand) )
7445 {
7446 v91 = 17 * v239 + v90;
7447 v92 = v91;
7448 v223 = paperdoll_array_511290[0][v91][2];
7449 if ( v223 == pIcons_LOD->FindTextureByName("pending") )
7450 {
7451 v93 = 2 * v91;
7452 v94 = paperdoll_array_511290[0][v92][1];
7453 a2g = papredoll_4E4C28 + dword_4E5050[v93];
7454 v95 = dword_4E5050[v93 + 1];
7455 }
7456 else
7457 {
7458 v94 = v223;
7459 a2g = papredoll_4E4C28 + dword_4E5270[2 * v91];
7460 v95 = dword_4E5270[2 * v91 + 1];
7461 }
7462 a3g = paperdoll_4E4C2C + v95;
7463 if ( v94 == pIcons_LOD->FindTextureByName("pending") )
7464 goto LABEL_258;
7465 if ( *(int *)(v242 + 516) & 0xF0 )
7466 {
7467 if ( (*(int *)(v242 + 516) & 0xF0) != 16 )
7468 {
7469 if ( (*(int *)(v242 + 516) & 0xF0) == 32 )
7470 {
7471 v173 = "sp28a";
7472 goto LABEL_226;
7473 }
7474 if ( (*(int *)(v242 + 516) & 0xF0) == 64 )
7475 {
7476 v173 = "sp30a";
7477 goto LABEL_226;
7478 }
7479 if ( (*(int *)(v242 + 516) & 0xF0) == 128 )
7480 {
7481 v173 = "sp91a";
7482 LABEL_226:
7483 v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v173, TEXTURE_16BIT_PALETTE)];
7484 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7485 if ( dword_50C9A8 <= 0 )
7486 {
7487 dword_50C9A8 = 0;
7488 *(char *)(v242 + 516) &= 0xFu;
7489 ptr_50C9A4 = 0;
7490 }
7491 v187 = 255;
7492 v174 = 0;
7493 v97 = (double)GetTickCount();
7494 LABEL_249:
7495 pRenderer->_4A63E6(
7496 a2g,
7497 a3g,
7498 (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0),
7499 (Texture *)v96,
7500 (signed __int64)(v97 * 0.1),
7501 v174,
7502 v187);
7503 goto LABEL_258;
7504 }
7505 }
7506 v173 = "sptext01";
7507 goto LABEL_226;
7508 }
7509 v98 = v94 + 1;
7510 v99 = (char *)&pIcons_LOD->pTextures[v94];
7511 v100 = pRenderer;
7512 if ( *(int *)(v242 + 516) & 2 )
7513 {
7514 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7515 v188 = v101;
7516 v175 = a3g;
7517 v163 = a2g;
7518 LABEL_231:
7519 v100->_4A6776(v163, v175, v188);
7520 goto LABEL_256;
7521 }
7522 if ( *(char *)(v242 + 516) & 1 )
7523 {
7524 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7525 v189 = v101;
7526 v176 = a3g;
7527 v164 = a2g;
7528 LABEL_234:
7529 pRenderer->DrawTextureTransparent(v164, v176, v189);
7530 goto LABEL_256;
7531 }
7532 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7533 v190 = v101;
7534 v177 = a3g;
7535 v165 = a2g;
7536 goto LABEL_255;
7537 }
7538 v102 = 17 * v239 + v90;
7539 v94 = paperdoll_array_511290[0][v102][1];
7540 if ( v94 == pIcons_LOD->FindTextureByName("pending") )
7541 {
7542 LABEL_258:
7543 v68 = v217;
7544 goto LABEL_259;
7545 }
7546 v103 = papredoll_4E4C28 + dword_4E5050[2 * v102];
7547 v104 = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
7548 v224 = *(int *)(v242 + 516);
7549 v105 = *(int *)(v242 + 516) & 0xF0;
7550 a2g = papredoll_4E4C28 + dword_4E5050[2 * v102];
7551 a3g = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
7552 if ( !v105 )
7553 {
7554 v109 = v94 + 1;
7555 v110 = (char *)&pIcons_LOD->pTextures[v94];
7556 if ( v224 & 2 )
7557 {
7558 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7559 v188 = v101;
7560 v175 = v104;
7561 v163 = v103;
7562 v100 = pRenderer;
7563 goto LABEL_231;
7564 }
7565 if ( v224 & 1 )
7566 {
7567 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7568 v189 = v101;
7569 v176 = v104;
7570 v164 = v103;
7571 v100 = pRenderer;
7572 goto LABEL_234;
7573 }
7574 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7575 v190 = v101;
7576 v177 = v104;
7577 v165 = v103;
7578 v100 = pRenderer;
7579 LABEL_255:
7580 pRenderer->DrawTransparentGreenShade(v165, v177, v190);
7581 LABEL_256:
7582 if ( !bRingsShownInCharScreen )
7583 pRenderer->_4A612A(a2g, a3g, v101, v235);
7584 goto LABEL_258;
7585 }
7586 v106 = v105 - 16;
7587 if ( v106 )
7588 {
7589 v107 = v106 - 16;
7590 if ( !v107 )
7591 {
7592 v178 = "sp28a";
7593 goto LABEL_246;
7594 }
7595 v108 = v107 - 32;
7596 if ( !v108 )
7597 {
7598 v178 = "sp30a";
7599 goto LABEL_246;
7600 }
7601 if ( v108 == 64 )
7602 {
7603 v178 = "sp91a";
7604 LABEL_246:
7605 v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v178, TEXTURE_16BIT_PALETTE)];
7606 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7607 if ( dword_50C9A8 <= 0 )
7608 {
7609 dword_50C9A8 = 0;
7610 *(char *)(v242 + 516) &= 0xFu;
7611 ptr_50C9A4 = 0;
7612 }
7613 v187 = 255;
7614 v174 = 0;
7615 v97 = (double)GetTickCount();
7616 goto LABEL_249;
7617 }
7618 }
7619 v178 = "sptext01";
7620 goto LABEL_246;
7621 }
7622 v186 = 16;
7623 }
7624 else
7625 {
7626 v186 = 13;
7627 }
7628 }
7629 else
7630 {
7631 v186 = 14;
7632 }
7633 v90 = v186;
7634 goto LABEL_209;
7635 }
7636 v90 = 15;
7637 goto LABEL_207;
7638 }
7639 if ( (*(int *)(v57 + 20) & 0xF0) != 16 )
7640 {
7641 if ( (*(int *)(v57 + 20) & 0xF0) == 32 )
7642 {
7643 v171 = "sp28a";
7644 goto LABEL_145;
7645 }
7646 if ( (*(int *)(v57 + 20) & 0xF0) == 64 )
7647 {
7648 v171 = "sp30a";
7649 goto LABEL_145;
7650 }
7651 if ( (*(int *)(v57 + 20) & 0xF0) == 128 )
7652 {
7653 v171 = "sp91a";
7654 LABEL_145:
7655 v63 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v171, TEXTURE_16BIT_PALETTE)];
7656 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7657 if ( dword_50C9A8 <= 0 )
7658 {
7659 dword_50C9A8 = 0;
7660 *(char *)(v221 + 20) &= 0xFu;
7661 ptr_50C9A4 = 0;
7662 }
7663 v64 = (double)GetTickCount() * 0.1;
7664 pRenderer->_4A63E6(
7665 a2e,
7666 a3e,
7667 (Texture *)(v59 != -1 ? (int)&pIcons_LOD->pTextures[v59] : 0),
7668 v63,
7669 (signed __int64)v64,
7670 0,
7671 255);
7672 goto LABEL_155;
7673 }
7674 }
7675 v171 = "sptext01";
7676 goto LABEL_145;
7677 }
7678 if ( (*(int *)(v44 + 20) & 0xF0) != 16 )
7679 {
7680 if ( (*(int *)(v44 + 20) & 0xF0) == 32 )
7681 {
7682 v170 = "sp28a";
7683 }
7684 else
7685 {
7686 if ( (*(int *)(v44 + 20) & 0xF0) != 64 )
7687 {
7688 v50 = pIcons_LOD;
7689 if ( (*(int *)(v44 + 20) & 0xF0) == 128 )
7690 {
7691 v170 = "sp91a";
7692 LABEL_117:
7693 v51 = &pIcons_LOD->pTextures[v50->LoadTexture(v170, TEXTURE_16BIT_PALETTE)];
7694 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7695 if ( dword_50C9A8 <= 0 )
7696 {
7697 dword_50C9A8 = 0;
7698 *(char *)(v220 + 20) &= 0xFu;
7699 ptr_50C9A4 = 0;
7700 }
7701 v52 = (double)GetTickCount() * 0.1;
7702 pRenderer->_4A63E6(
7703 a2d,
7704 a3d,
7705 (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0),
7706 v51,
7707 (signed __int64)v52,
7708 0,
7709 255);
7710 goto LABEL_127;
7711 }
7712 LABEL_116:
7713 v170 = "sptext01";
7714 goto LABEL_117;
7715 }
7716 v170 = "sp30a";
7717 }
7718 v50 = pIcons_LOD;
7719 goto LABEL_117;
7720 }
7721 v50 = pIcons_LOD;
7722 goto LABEL_116;
7723 }
7724 v185 = 16;
7725 }
7726 }
7727 v45 = v185;
7728 goto LABEL_106;
7729 }
7730 v45 = 15;
7731 goto LABEL_104;
7732 }
7733 if ( (*(int *)(v32 + 20) & 0xF0) != 16 )
7734 {
7735 if ( (*(int *)(v32 + 20) & 0xF0) == 32 )
7736 {
7737 v169 = "sp28a";
7738 }
7739 else
7740 {
7741 if ( (*(int *)(v32 + 20) & 0xF0) != 64 )
7742 {
7743 v38 = pIcons_LOD;
7744 if ( (*(int *)(v32 + 20) & 0xF0) == 128 )
7745 {
7746 v169 = "sp91a";
7747 LABEL_85:
7748 v39 = &pIcons_LOD->pTextures[v38->LoadTexture(v169, TEXTURE_16BIT_PALETTE)];
7749 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7750 if ( dword_50C9A8 <= 0 )
7751 {
7752 dword_50C9A8 = 0;
7753 *(char *)(v219 + 20) &= 0xFu;
7754 ptr_50C9A4 = 0;
7755 }
7756 v40 = (double)GetTickCount() * 0.1;
7757 pRenderer->_4A63E6(
7758 a2c,
7759 a3c,
7760 (Texture *)(v35 != -1 ? (int)&pIcons_LOD->pTextures[v35] : 0),
7761 v39,
7762 (signed __int64)v40,
7763 0,
7764 255);
7765 goto LABEL_93;
7766 }
7767 LABEL_84:
7768 v169 = "sptext01";
7769 goto LABEL_85;
7770 }
7771 v169 = "sp30a";
7772 }
7773 v38 = pIcons_LOD;
7774 goto LABEL_85;
7775 }
7776 v38 = pIcons_LOD;
7777 goto LABEL_84;
7778 }
7779 v184 = 9;
7780 break;
7781 }
7782 v33 = v184;
7783 goto LABEL_74;
7784 }
7785 v33 = 5;
7786 goto LABEL_72;
7787 }
7788 if ( (*(int *)(v22 + 20) & 0xF0) != 16 )
7789 {
7790 if ( (*(int *)(v22 + 20) & 0xF0) == 32 )
7791 {
7792 v168 = "sp28a";
7793 }
7794 else
7795 {
7796 if ( (*(int *)(v22 + 20) & 0xF0) != 64 )
7797 {
7798 v26 = pIcons_LOD;
7799 if ( (*(int *)(v22 + 20) & 0xF0) == 128 )
7800 {
7801 v168 = "sp91a";
7802 LABEL_49:
7803 a2b = &pIcons_LOD->pTextures[v26->LoadTexture(v168, TEXTURE_16BIT_PALETTE)];
7804 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7805 if ( dword_50C9A8 <= 0 )
7806 {
7807 dword_50C9A8 = 0;
7808 *(char *)(v22 + 20) &= 0xFu;
7809 ptr_50C9A4 = 0;
7810 }
7811 v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
7812 v28 = (double)GetTickCount() * 0.1;
7813 pRenderer->_4A63E6(v24, a3b, v27, a2b, (signed __int64)v28, 0, 255);
7814 goto LABEL_57;
7815 }
7816 LABEL_48:
7817 v168 = "sptext01";
7818 goto LABEL_49;
7819 }
7820 v168 = "sp30a";
7821 }
7822 v26 = pIcons_LOD;
7823 goto LABEL_49;
7824 }
7825 v26 = pIcons_LOD;
7826 goto LABEL_48;
7827 }
7828 a3 = paperdoll_4E4C2C;
7829 a2 = papredoll_4E4C28;
7830 v240 = 4 * uPlayerID_ - 4;
7831 pRenderer->DrawTextureTransparent(
7832 papredoll_4E4C28,
7833 paperdoll_4E4C2C,
7834 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
7835 //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
7836 // * *(unsigned int *)((char *)papredoll_dbods
7837 // + v240)
7838 // + 7145548 : 0));
7839 if ( !bRingsShownInCharScreen )
7840 pRenderer->_4A612A(
7841 a2,
7842 a3,
7843 //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
7844 // * *(unsigned int *)((char *)papredoll_dbods
7845 // + v240)
7846 // + 7145548 : 0),
7847 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0),
7848 pPlayer->pEquipment.uBody);
7849 uPlayerID_a = 2 * v5;
7850 v6 = pPlayer->pEquipment.uMainHand;
7851 if ( !v6
7852 || (v7 = *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5], pItemsTable->pItems[v7].uEquipType != 1)
7853 && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayer->pEquipment.uOffHand) )
7854 pRenderer->DrawTextureTransparent(
7855 papredoll_4E4C28 + dword_4E5AE0[2 * v5],
7856 paperdoll_4E4C2C + dword_4E5AE0[2 * v5 + 1],
7857 (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
7858 //(Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? 72
7859 // * *(unsigned int *)((char *)papredoll_dlads
7860 // + v240)
7861 // + 7145548 : 0));
7862 v8 = pPlayer->pEquipment.uMainHand;
7863 if ( v8 )
7864 {
7865 v229 = pPlayer->pEquipment.uMainHand;
7866 v9 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
7867 v10 = v5 << 7;
7868 v218 = v9;
7869 v11 = *(int *)v9;
7870 v12 = *(int *)v9;
7871 v13 = papredoll_4E4C28 + array_4E4C30[v5].field_8 - pItemsTable->pItems[v12].uEquipX;
7872 a2a = v13;
7873 a3a = paperdoll_4E4C2C + *(int *)((char *)&array_4E4C30[0].field_C + v10) - pItemsTable->pItems[v12].uEquipY;
7874 if ( v11 == 64 )
7875 v166 = "item64v1";
7876 else
7877 v166 = pItemsTable->pItems[v12].pIconName;
7878 v14 = pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE);
7879 v15 = *(int *)(v218 + 20);
7880 if ( *(int *)(v218 + 20) & 0xF0 )
7881 {
7882 if ( (*(int *)(v218 + 20) & 0xF0) != 16 )
7883 {
7884 if ( (*(int *)(v218 + 20) & 0xF0) == 32 )
7885 {
7886 v167 = "sp28a";
7887 goto LABEL_27;
7888 }
7889 if ( (*(int *)(v218 + 20) & 0xF0) == 64 )
7890 {
7891 v167 = "sp30a";
7892 goto LABEL_27;
7893 }
7894 if ( (*(int *)(v218 + 20) & 0xF0) == 128 )
7895 {
7896 v167 = "sp91a";
7897 LABEL_27:
7898 //v16 = (Texture *)(72 * pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE) + 7145548);
7899 v16 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE)];
7900
7901 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7902 if ( dword_50C9A8 <= 0 )
7903 {
7904 dword_50C9A8 = 0;
7905 *(char *)(v218 + 20) &= 0xFu;
7906 ptr_50C9A4 = 0;
7907 }
7908 v17 = (double)GetTickCount() * 0.1;
7909 pRenderer->_4A63E6(
7910 v13,
7911 a3a,
7912 (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0),
7913 v16,
7914 (signed __int64)v17,
7915 0,
7916 255);
7917 goto LABEL_393;
7918 }
7919 }
7920 v167 = "sptext01";
7921 goto LABEL_27;
7922 }
7923 v18 = v14 + 1;
7924 v19 = (char *)&pIcons_LOD->pTextures[v14];
7925 if ( v15 & 2 )
7926 {
7927 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
7928 pRenderer->_4A6776(a2a, a3a, v20);
7929 }
7930 else
7931 {
7932 if ( v15 & 1 )
7933 {
7934 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
7935 pRenderer->DrawTextureTransparent(a2a, a3a, v20);
7936 }
7937 else
7938 {
7939 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
7940 pRenderer->DrawTransparentGreenShade(a2a, a3a, v20);
7941 }
7942 }
7943 if ( !bRingsShownInCharScreen )
7944 pRenderer->_4A612A(a2a, a3a, v20, v229);
7945 }
7946 LABEL_393:
7947 pRenderer->DrawTextureTransparent(
7948 papredoll_4E4C28 + pPaperdollRightHand[uPlayerID_a],
7949 paperdoll_4E4C2C + pPaperdollRightHand[uPlayerID_a + 1],
7950 (Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_drhs + v240)] : 0));
7951 //(Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? 72
7952 // * *(unsigned int *)((char *)papredoll_drhs + v240)
7953 // + 7145548 : 0));
7954 v161 = v217->pEquipment.uMainHand;
7955 if ( v161 )
7956 {
7957 v162 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v161 + 5];
7958 if ( pItemsTable->pItems[v162].uEquipType == 1
7959 || pItemsTable->pItems[v162].uSkillType == 4 && !v217->pEquipment.uOffHand )
7960 pRenderer->DrawTextureTransparent(
7961 papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
7962 paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
7963 (Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhus + v240)] : 0));
7964 //(Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? 72
7965 // * *(unsigned int *)((char *)papredoll_dlhus
7966 // + v240)
7967 // + 7145548 : 0));
7968 }
7969 if ( !bRingsShownInCharScreen )
7970 pRenderer->DrawTextureTransparent(
7971 0x25Bu,
7972 0x12Bu,
7973 (Texture *)(uTextureID_MAGNIF_B != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_MAGNIF_B] : 0));
7974 pRenderer->DrawTextureTransparent(
7975 0x1D4u,
7976 0,
7977 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
7978 }
7979
7980
7981 //----- (0043E825) --------------------------------------------------------
7982 void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID)
7983 {
7984 unsigned int v1; // ebx@1
7985 Player *pPlayer; // edi@1
7986 int v3; // ecx@1
7987 int v4; // edi@3
7988 unsigned int v5; // ebx@3
7989 int v6; // eax@3
7990 LODFile_IconsBitmaps *v7; // ecx@7
7991 double v8; // st7@16
7992 int v9; // edi@17
7993 Texture *v10; // edi@18
7994 unsigned __int8 v11; // zf@19
7995 Texture *v12; // eax@19
7996 char v13; // sf@24
7997 unsigned __int8 v14; // of@24
7998 unsigned int v15; // eax@25
7999 unsigned int v16; // ebx@26
8000 int v17; // eax@26
8001 LODFile_IconsBitmaps *v18; // ecx@30
8002 double v19; // st7@39
8003 int v20; // edi@40
8004 int v21; // eax@41
8005 signed int v22; // ebx@41
8006 Texture *v23; // edi@41
8007 int v24; // eax@42
8008 char *v25; // eax@42
8009 unsigned int v26; // eax@46
8010 int v27; // edi@47
8011 unsigned int v28; // ebx@47
8012 int v29; // eax@47
8013 LODFile_IconsBitmaps *v30; // ecx@51
8014 Texture *v31; // esi@58
8015 double v32; // st7@60
8016 int v33; // esi@61
8017 int v34; // esi@62
8018 Texture *v35; // eax@63
8019 const char *v36; // [sp-8h] [bp-38h]@8
8020 const char *v37; // [sp-8h] [bp-38h]@31
8021 const char *v38; // [sp-8h] [bp-38h]@52
8022 int v39; // [sp+10h] [bp-20h]@3
8023 Texture *v40; // [sp+10h] [bp-20h]@14
8024 int v41; // [sp+10h] [bp-20h]@26
8025 Texture *v42; // [sp+10h] [bp-20h]@37
8026 int v43; // [sp+10h] [bp-20h]@47
8027 unsigned int a3; // [sp+14h] [bp-1Ch]@3
8028 unsigned int a2; // [sp+18h] [bp-18h]@3
8029 int v46; // [sp+1Ch] [bp-14h]@1
8030 Player *v47; // [sp+20h] [bp-10h]@1
8031 int v48; // [sp+24h] [bp-Ch]@1
8032 int v49; // [sp+24h] [bp-Ch]@26
8033
8034 v1 = uPlayerID;
8035 pPlayer = pPlayers[uPlayerID];
8036 v47 = pPlayers[uPlayerID];
8037 pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
8038 CharacterUI_DrawPaperdoll(v1);
8039 pRenderer->DrawTextureTransparent(
8040 0x1D9u,
8041 0,
8042 (Texture *)(uTextureID_BACKHAND != -1 ? &pIcons_LOD->pTextures[uTextureID_BACKHAND] : 0));
8043 pRenderer->DrawTextureTransparent(
8044 0x1D4u,
8045 0,
8046 (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0));
8047 pRenderer->DrawTextureIndexed(
8048 pCharacterScreen_DetalizBtn->uX,
8049 pCharacterScreen_DetalizBtn->uY,
8050 (Texture *)(uTextureID_5118C8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5118C8] : 0));
8051 v3 = 0;
8052 v46 = (int)&pPlayer->pEquipment.field_28;
8053 v48 = 0;
8054 do
8055 {
8056 if ( !*(int *)v46 )
8057 goto LABEL_24;
8058 v39 = *(int *)v46;
8059 v4 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v46 + 5];
8060 a3 = *(int *)((char *)dword_4E5C34 + v3);
8061 a2 = *(int *)((char *)dword_4E5C1C + v3);
8062 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v4].pIconName, TEXTURE_16BIT_PALETTE);
8063 v6 = *(int *)(v4 + 20);
8064 if ( *(int *)(v4 + 20) & 0xF0 )
8065 {
8066 if ( (*(int *)(v4 + 20) & 0xF0) != 16 )
8067 {
8068 if ( (*(int *)(v4 + 20) & 0xF0) == 32 )
8069 {
8070 v36 = "sp28a";
8071 }
8072 else
8073 {
8074 if ( (*(int *)(v4 + 20) & 0xF0) != 64 )
8075 {
8076 v7 = pIcons_LOD;
8077 if ( (*(int *)(v4 + 20) & 0xF0) == 128 )
8078 {
8079 v36 = "sp91a";
8080 LABEL_14:
8081 v40 = &pIcons_LOD->pTextures[v7->LoadTexture(v36, TEXTURE_16BIT_PALETTE)];
8082 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8083 if ( dword_50C9A8 <= 0 )
8084 {
8085 dword_50C9A8 = 0;
8086 *(char *)(v4 + 20) &= 0xFu;
8087 ptr_50C9A4 = 0;
8088 }
8089 v8 = (double)GetTickCount() * 0.1;
8090 pRenderer->_4A63E6(
8091 a2,
8092 a3,
8093 (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0),
8094 v40,
8095 (signed __int64)v8,
8096 0,
8097 255);
8098 goto LABEL_23;
8099 }
8100 LABEL_13:
8101 v36 = "sptext01";
8102 goto LABEL_14;
8103 }
8104 v36 = "sp30a";
8105 }
8106 v7 = pIcons_LOD;
8107 goto LABEL_14;
8108 }
8109 v7 = pIcons_LOD;
8110 goto LABEL_13;
8111 }
8112 v9 = v5 + 1;
8113 if ( v6 & 2 )
8114 {
8115 v10 = (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[v5] : 0);
8116 pRenderer->_4A6776(a2, a3, v10);
8117 }
8118 else
8119 {
8120 v11 = (v6 & 1) == 0;
8121 v12 = &pIcons_LOD->pTextures[v5];
8122 if ( v11 )
8123 {
8124 v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
8125 pRenderer->DrawTransparentGreenShade(a2, a3, v10);
8126 }
8127 else
8128 {
8129 v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
8130 pRenderer->DrawTextureTransparent(a2, a3, v10);
8131 }
8132 }
8133 pRenderer->_4A601E(a2, a3, v10, v39);
8134 LABEL_23:
8135 pPlayer = v47;
8136 LABEL_24:
8137 v46 += 4;
8138 v3 = v48 + 4;
8139 v14 = __OFSUB__(v48 + 4, 20);
8140 v11 = v48 == 16;
8141 v13 = v48 - 16 < 0;
8142 v48 += 4;
8143 }
8144 while ( (unsigned __int8)(v13 ^ v14) | v11 );
8145 v15 = pPlayer->pEquipment.field_24;
8146 if ( !v15 )
8147 goto LABEL_46;
8148 v41 = pPlayer->pEquipment.field_24;
8149 v49 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5];
8150 v16 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v49].pIconName, TEXTURE_16BIT_PALETTE);
8151 v17 = *(int *)(v49 + 20);
8152 if ( !(*(int *)(v49 + 20) & 0xF0) )
8153 {
8154 v20 = v16 + 1;
8155 if ( v17 & 2 )
8156 {
8157 v21 = 9 * v16;
8158 v22 = 493;
8159 v23 = (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0);
8160 pRenderer->_4A6776(0x1EDu, 0x5Bu, v23);
8161 }
8162 else
8163 {
8164 v11 = (v17 & 1) == 0;
8165 v24 = 9 * v16;
8166 v22 = 493;
8167 v25 = (char *)&pIcons_LOD->pTextures[8 * v24 / 0x48u];
8168 if ( v11 )
8169 {
8170 v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
8171 pRenderer->DrawTransparentGreenShade(493, 91, v23);
8172 }
8173 else
8174 {
8175 v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
8176 pRenderer->DrawTextureTransparent(0x1EDu, 0x5Bu, v23);
8177 }
8178 }
8179 pRenderer->_4A601E(v22, 91, v23, v41);
8180 pPlayer = v47;
8181 goto LABEL_46;
8182 }
8183 if ( (*(int *)(v49 + 20) & 0xF0) == 16 )
8184 {
8185 v18 = pIcons_LOD;
8186 goto LABEL_36;
8187 }
8188 if ( (*(int *)(v49 + 20) & 0xF0) == 32 )
8189 {
8190 v37 = "sp28a";
8191 goto LABEL_34;
8192 }
8193 if ( (*(int *)(v49 + 20) & 0xF0) == 64 )
8194 {
8195 v37 = "sp30a";
8196 LABEL_34:
8197 v18 = pIcons_LOD;
8198 goto LABEL_37;
8199 }
8200 v18 = pIcons_LOD;
8201 if ( (*(int *)(v49 + 20) & 0xF0) == 128 )
8202 {
8203 v37 = "sp91a";
8204 goto LABEL_37;
8205 }
8206 LABEL_36:
8207 v37 = "sptext01";
8208 LABEL_37:
8209 v42 = &pIcons_LOD->pTextures[v18->LoadTexture(v37, TEXTURE_16BIT_PALETTE)];
8210 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8211 if ( dword_50C9A8 <= 0 )
8212 {
8213 dword_50C9A8 = 0;
8214 *(char *)(v49 + 20) &= 0xFu;
8215 ptr_50C9A4 = 0;
8216 }
8217 v19 = (double)GetTickCount() * 0.1;
8218 pRenderer->_4A63E6(
8219 0x1EDu,
8220 0x5Bu,
8221 (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0),
8222 v42,
8223 (signed __int64)v19,
8224 0,
8225 255);
8226 LABEL_46:
8227 v26 = pPlayer->pEquipment.field_1C;
8228 if ( !v26 )
8229 return;
8230 v43 = pPlayer->pEquipment.field_1C;
8231 v27 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v26 + 5];
8232 v28 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v27].pIconName, TEXTURE_16BIT_PALETTE);
8233 v29 = *(int *)(v27 + 20);
8234 if ( !(*(int *)(v27 + 20) & 0xF0) )
8235 {
8236 v33 = v28 + 1;
8237 if ( v29 & 2 )
8238 {
8239 v34 = v33 != 0 ? (int)&pIcons_LOD->pTextures[v28] : 0;
8240 pRenderer->_4A6776(0x24Au, 0x58u, (Texture *)v34);
8241 }
8242 else
8243 {
8244 v11 = (v29 & 1) == 0;
8245 v35 = &pIcons_LOD->pTextures[v28];
8246 if ( v11 )
8247 {
8248 v34 = v33 != 0 ? (int)v35 : 0;
8249 pRenderer->DrawTransparentGreenShade(586, 88, (Texture *)v34);
8250 }
8251 else
8252 {
8253 v34 = v33 != 0 ? (int)v35 : 0;
8254 pRenderer->DrawTextureTransparent(0x24Au, 0x58u, (Texture *)v34);
8255 }
8256 }
8257 pRenderer->_4A601E(586, 88, (Texture *)v34, v43);
8258 return;
8259 }
8260 if ( (*(int *)(v27 + 20) & 0xF0) == 16 )
8261 {
8262 v30 = pIcons_LOD;
8263 goto LABEL_57;
8264 }
8265 if ( (*(int *)(v27 + 20) & 0xF0) == 32 )
8266 {
8267 v38 = "sp28a";
8268 goto LABEL_55;
8269 }
8270 if ( (*(int *)(v27 + 20) & 0xF0) == 64 )
8271 {
8272 v38 = "sp30a";
8273 LABEL_55:
8274 v30 = pIcons_LOD;
8275 goto LABEL_58;
8276 }
8277 v30 = pIcons_LOD;
8278 if ( (*(int *)(v27 + 20) & 0xF0) == 128 )
8279 {
8280 v38 = "sp91a";
8281 goto LABEL_58;
8282 }
8283 LABEL_57:
8284 v38 = "sptext01";
8285 LABEL_58:
8286 v31 = &pIcons_LOD->pTextures[v30->LoadTexture(v38, TEXTURE_16BIT_PALETTE)];
8287 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8288 if ( dword_50C9A8 <= 0 )
8289 {
8290 dword_50C9A8 = 0;
8291 *(char *)(v27 + 20) &= 0xFu;
8292 ptr_50C9A4 = 0;
8293 }
8294 v32 = (double)GetTickCount() * 0.1;
8295 pRenderer->_4A63E6(
8296 0x24Au,
8297 0x58u,
8298 (Texture *)(v28 != -1 ? (int)&pIcons_LOD->pTextures[v28] : 0),
8299 v31,
8300 (signed __int64)v32,
8301 0,
8302 255);
8303 }
8304
8305
8306 //----- (0043ED6F) --------------------------------------------------------
8307 bool _43ED6F_check_party_races(bool a1)
8308 {
8309 bool v6; // zf@5
8310
8311 for (uint i = 0; i < 4; ++i)
8312 {
8313 auto player = pParty->pPlayers + i;
8314 auto race = player->GetRace();
8315
8316 if (race != CHARACTER_RACE_HUMAN &&
8317 race != CHARACTER_RACE_ELF &&
8318 race != CHARACTER_RACE_GOBLIN)
8319 v6 = a1 == 1;
8320 else
8321 v6 = !a1;
8322
8323 if (v6)
8324 return true;
8325 }
8326 return false;
8327 }
8328 // A750D8: using guessed type __int64 qword_A750D8;
8329
8330 //----- (0043EDB9) --------------------------------------------------------
8331 bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this)
8332 {
8333 unsigned int v1; // ebp@1
8334 Player **v2; // ebx@1
8335 Player *v3; // esi@2
8336 enum CHARACTER_RACE v4; // edi@2
8337 bool result; // eax@2
8338 char v6; // zf@7
8339
8340 v1 = _this;
8341 v2 = &pPlayers[1];
8342 while ( 1 )
8343 {
8344 v3 = *v2;
8345 v4 = v3->GetRace();
8346 result = v3->GetSexByVoice();
8347 if ( !v4 )
8348 break;
8349 if ( v4 == 1 || v4 == 2 )
8350 break;
8351 if ( !result && v1 == 2 )
8352 goto LABEL_15;
8353 v6 = v1 == 3;
8354 LABEL_11:
8355 if ( v6 )
8356 goto LABEL_15;
8357 ++v2;
8358 if ( (signed int)v2 >= (signed int)&qword_A750D8 )
8359 {
8360 LOBYTE(result) = 0;
8361 return result;
8362 }
8363 }
8364 if ( result || v1 )
8365 {
8366 v6 = v1 == 1;
8367 goto LABEL_11;
8368 }
8369 LABEL_15:
8370 LOBYTE(result) = 1;
8371 return result;
8372 }
8373 // A750D8: using guessed type __int64 qword_A750D8;
8374
8375 //----- (0043EE15) --------------------------------------------------------
8376 bool __fastcall sub_43EE15_player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
8377 {
8378 bool result; // eax@0
8379 signed int v4; // edi@3
8380 int *v5; // esi@3
8381 signed int v6; // edi@7
8382 bool *v7; // esi@7
8383
8384 if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
8385 {
8386 v4 = 0;
8387 v5 = pPlayer->pInventoryIndices;
8388 while ( 1 )
8389 {
8390 if ( *v5 )
8391 {
8392 result = 9 * *v5;
8393 if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v5 + 5] == uItemID )
8394 break;
8395 }
8396 ++v4;
8397 ++v5;
8398 if ( v4 >= 126 )
8399 {
8400 v6 = 0;
8401 v7 = (bool *)&pPlayer->pEquipment;
8402 while ( 1 )
8403 {
8404 result = *v7;
8405 if ( *v7 )
8406 {
8407 result *= 9;
8408 if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] == uItemID )
8409 break;
8410 }
8411 ++v6;
8412 ++v7;
8413 if ( v6 >= 16 )
8414 {
8415 LOBYTE(result) = 0;
8416 return result;
8417 }
8418 }
8419 break;
8420 }
8421 }
8422 }
8423 LOBYTE(result) = 1;
8424 return result;
8425 }
8426
8427 //----- (0043EE77) --------------------------------------------------------
8428 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
8429 {
8430 bool result; // eax@0
8431 Player *v2; // edx@3
8432 int v3; // ecx@3
8433 Player **pPlayers; // esi@8
8434 unsigned int v5; // ecx@8
8435 Player *v6; // edx@9
8436
8437 if ( a1 < 1 || a1 > 4 )
8438 {
8439 if ( !a1 )
8440 {
8441 pPlayers = &::pPlayers[1];
8442 v5 = 604;
8443 while ( 1 )
8444 {
8445 result = sub_43EE15_player_has_item(v5, *pPlayers, 0);
8446 if ( !result )
8447 break;
8448 result = v6->pEquipment.uBody;
8449 if ( !result )
8450 break;
8451 result *= 9;
8452 if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
8453 break;
8454 ++pPlayers;
8455 if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
8456 goto LABEL_13;
8457 }
8458 }
8459 goto LABEL_6;
8460 }
8461 result = sub_43EE15_player_has_item(604u, ::pPlayers[a1], 0);
8462 if ( !result
8463 || (result = v2->pEquipment.uBody) == 0
8464 || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
8465 {
8466 LABEL_6:
8467 LOBYTE(result) = 0;
8468 return result;
8469 }
8470 LABEL_13:
8471 LOBYTE(result) = 1;
8472 return result;
8473 }
8474 // A750D8: using guessed type __int64 qword_A750D8;
8475
8476 //----- (0043EF2B) --------------------------------------------------------
8477 void __fastcall WetsuitOn(unsigned int uPlayerID)
8478 {
8479 unsigned int v1; // ebx@1
8480 Player **v2; // esi@2
8481 enum CHARACTER_RACE v3; // edi@2
8482 signed int v4; // eax@2
8483 int v5; // ecx@5
8484 unsigned __int8 v6; // al@7
8485 char pContainer[20]; // [sp+4h] [bp-1Ch]@7
8486 unsigned int v8; // [sp+18h] [bp-8h]@1
8487 int v9; // [sp+1Ch] [bp-4h]@7
8488
8489 v1 = uPlayerID - 1;
8490 v8 = uPlayerID;
8491 if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
8492 {
8493 v2 = &pPlayers[uPlayerID];
8494 v3 = (*v2)->GetRace();
8495 v4 = (*v2)->GetSexByVoice();
8496 if ( v3 && v3 != 1 && v3 != 2 )
8497 v5 = (v4 != 0) + 3;
8498 else
8499 v5 = (v4 != 0) + 1;
8500 v9 = v5;
8501 wsprintfA(pContainer, "pc23v%dBod", v5);
8502 papredoll_dbods[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8503 wsprintfA(pContainer, "pc23v%dlad", v9);
8504 papredoll_dlads[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8505 wsprintfA(pContainer, "pc23v%dlau", v9);
8506 papredoll_dlaus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8507 wsprintfA(pContainer, "pc23v%drh", v9);
8508 papredoll_drhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8509 wsprintfA(pContainer, "pc23v%dlh", v9);
8510 papredoll_dlhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8511 wsprintfA(pContainer, "pc23v%dlhu", v9);
8512 papredoll_dlhus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8513 v6 = pPlayers[v1 + 1]->uFace;
8514 if ( v6 == 12 || v6 == 13 )
8515 papredoll_dbrds[pPlayers[v8]->uFace] = 0;
8516 papredoll_flying_feet[pPlayers[v8]->uFace] = 0;
8517 IsPlayerWearingWatersuit[v8] = 1;
8518 }
8519 }
8520
8521 //----- (0043F0BD) --------------------------------------------------------
8522 unsigned int __fastcall WetsuitOff(unsigned int uPlayerID)
8523 {
8524 unsigned int result; // eax@1
8525 Player **v2; // edi@2
8526 unsigned int v3; // ebx@2
8527 int v4; // ebx@2
8528 char v5; // al@2
8529 char pContainer[20]; // [sp+0h] [bp-18h]@4
8530 unsigned int v7; // [sp+14h] [bp-4h]@1
8531
8532 result = uPlayerID - 1;
8533 v7 = uPlayerID;
8534 if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
8535 {
8536 v2 = &pPlayers[uPlayerID];
8537 v3 = uPlayerID - 1;
8538 papredoll_dbods[v3] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8539 papredoll_dlads[v3] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8540 papredoll_dlaus[v3] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8541 papredoll_drhs[v3] = pIcons_LOD->LoadTexture(drh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8542 papredoll_dlhs[v3] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8543 papredoll_dlhus[v3] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8544 v4 = (int)&(*v2)->uFace;
8545 v5 = *(char *)v4;
8546 if ( *(char *)v4 == 12 || v5 == 13 )
8547 {
8548 wsprintfA(pContainer, "pc%02dbrd", v5 + 1);
8549 v4 = (int)&(*v2)->uFace;
8550 papredoll_dbrds[*(char *)v4] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8551 }
8552 wsprintfA(pContainer, "item281pc%02d", *(char *)v4 + 1);
8553 papredoll_flying_feet[(*v2)->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8554 result = v7;
8555 IsPlayerWearingWatersuit[v7] = 0;
8556 }
8557 return result;
8558 }
8559
8560
8561 //----- (0043F333) --------------------------------------------------------
8562 void BspRenderer::MakeVisibleSectorList()
8563 {
8564 int v6; // ebx@3
8565
8566 uNumVisibleNotEmptySectors = 0;
8567 for (uint i = 0; i < std__vector_000FA8; ++i)
8568 {
8569 v6 = 0;
8570 if (!uNumVisibleNotEmptySectors)
8571 {
8572 LABEL_7:
8573 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
8574 }
8575 else
8576 {
8577 while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
8578 {
8579 ++v6;
8580 if ( v6 >= uNumVisibleNotEmptySectors)
8581 {
8582 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
8583 continue;
8584 }
8585 }
8586 }
8587 }
8588 }
8589
8590
8591 //----- (0043F515) --------------------------------------------------------
8592 void MessWithBillboards_BLV()
8593 {
8594 for (uint i = 0; i < uNumBillboardsToDraw; ++i)
8595 {
8596 auto p = pBillboardRenderList + i;
8597
8598 if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
8599 p->uPaletteSubindex = 0;
8600 else
8601 p->uPaletteSubindex = _43F55F_get_billboard_light_level(p, -1);
8602 }
8603 }
8604
8605 //----- (0043F55F) --------------------------------------------------------
8606 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
8607 {
8608 signed int v3; // ecx@2
8609
8610 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
8611 {
8612 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
8613 }
8614 else
8615 {
8616 if ( uBaseLightLevel == -1 )
8617 v3 = a1->uPaletteSubindex;
8618 else
8619 v3 = uBaseLightLevel;
8620 }
8621 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->some_x, a1->some_y, a1->some_z);
8622 }
8623
8624 //----- (0043F5C8) --------------------------------------------------------
8625 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
8626 {
8627 int v5; // esi@1
8628 signed int v6; // edi@1
8629 int v8; // eax@6
8630 int v9; // ebx@6
8631 unsigned int v10; // ecx@6
8632 unsigned int v11; // edx@9
8633 unsigned int v12; // edx@11
8634 signed int v13; // ecx@12
8635 BLVLightMM7 *v16; // esi@20
8636 int v17; // ebx@21
8637 int v18; // eax@24
8638 int v19; // ebx@24
8639 unsigned int v20; // ecx@24
8640 int v21; // edx@25
8641 unsigned int v22; // edx@27
8642 unsigned int v23; // edx@29
8643 signed int v24; // ecx@30
8644 int v26; // ebx@35
8645 int v27; // eax@38
8646 int v28; // ebx@38
8647 unsigned int v29; // ecx@38
8648 int v30; // edx@39
8649 unsigned int v31; // edx@41
8650 unsigned int v32; // edx@43
8651 signed int v33; // ecx@44
8652 int v37; // [sp+Ch] [bp-18h]@37
8653 int v38; // [sp+10h] [bp-14h]@5
8654 int v39; // [sp+10h] [bp-14h]@23
8655 int v40; // [sp+10h] [bp-14h]@36
8656 int v42; // [sp+14h] [bp-10h]@22
8657 unsigned int v43; // [sp+18h] [bp-Ch]@12
8658 unsigned int v44; // [sp+18h] [bp-Ch]@30
8659 unsigned int v45; // [sp+18h] [bp-Ch]@44
8660
8661 v6 = uBaseLightLevel;
8662 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
8663 {
8664 auto p = pMobileLightsStack->pLights + i;
8665
8666 auto distX = abs(p->vPosition.x - x);
8667 if ( distX <= p->uRadius)
8668 {
8669 auto distY = abs(p->vPosition.y - y);
8670 if ( distY <= p->uRadius)
8671 {
8672 auto distZ = abs(p->vPosition.z - z);
8673 if ( distZ <= p->uRadius)
8674 {
8675 v8 = distX;
8676 v9 = distY;
8677 v10 = distZ;
8678 if (distX < distY)
8679 {
8680 v8 = distY;
8681 v9 = distX;
8682 }
8683 if ( v8 < distZ )
8684 {
8685 v11 = v8;
8686 v8 = distZ;
8687 v10 = v11;
8688 }
8689 if ( v9 < (signed int)v10 )
8690 {
8691 v12 = v10;
8692 v10 = v9;
8693 v9 = v12;
8694 }
8695 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
8696 v13 = p->uRadius;
8697 if ( (signed int)v43 < v13 )
8698 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
8699 }
8700 }
8701 }
8702 }
8703
8704 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
8705 {
8706 auto pSector = pIndoor->pSectors + uSectorID;
8707
8708 for (uint i = 0; i < pSector->uNumLights; ++i)
8709 {
8710 v16 = pIndoor->pLights + pSector->pLights[i];
8711 if (~v16->uAtributes & 8)
8712 {
8713 v17 = abs(v16->vPosition.x - x);
8714 if ( v17 <= v16->uRadius )
8715 {
8716 v42 = abs(v16->vPosition.y - y);
8717 if ( v42 <= v16->uRadius )
8718 {
8719 v39 = abs(v16->vPosition.z - z);
8720 if ( v39 <= v16->uRadius )
8721 {
8722 v18 = v17;
8723 v19 = v42;
8724 v20 = v39;
8725 if ( v18 < v42 )
8726 {
8727 v21 = v18;
8728 v18 = v42;
8729 v19 = v21;
8730 }
8731 if ( v18 < v39 )
8732 {
8733 v22 = v18;
8734 v18 = v39;
8735 v20 = v22;
8736 }
8737 if ( v19 < (signed int)v20 )
8738 {
8739 v23 = v20;
8740 v20 = v19;
8741 v19 = v23;
8742 }
8743 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
8744 v24 = v16->uRadius;
8745 if ( (signed int)v44 < v24 )
8746 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
8747 }
8748 }
8749 }
8750 }
8751 }
8752 }
8753
8754 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
8755 {
8756 auto p = pStationaryLightsStack->pLights + i;
8757 v26 = abs(p->vPosition.x - x);
8758 if ( v26 <= p->uRadius)
8759 {
8760 v40 = abs(p->vPosition.y - y);
8761 if ( v40 <= p->uRadius)
8762 {
8763 v37 = abs(p->vPosition.z - z);
8764 if ( v37 <= p->uRadius)
8765 {
8766 v27 = v26;
8767 v28 = v40;
8768 v29 = v37;
8769 if ( v27 < v40 )
8770 {
8771 v30 = v27;
8772 v27 = v40;
8773 v28 = v30;
8774 }
8775 if ( v27 < v37 )
8776 {
8777 v31 = v27;
8778 v27 = v37;
8779 v29 = v31;
8780 }
8781 if ( v28 < (signed int)v29 )
8782 {
8783 v32 = v29;
8784 v29 = v28;
8785 v28 = v32;
8786 }
8787 v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
8788 v33 = p->uRadius;
8789 if ( (signed int)v45 < v33 )
8790 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
8791 }
8792 }
8793 }
8794 }
8795
8796 if ( v6 <= 31 )
8797 {
8798 if ( v6 < 0 )
8799 v6 = 0;
8800 }
8801 else
8802 {
8803 v6 = 31;
8804 }
8805 return v6;
8806 }
8807
8808 //----- (00406051) --------------------------------------------------------
8809 __int16 stru262_TurnBased::StartTurn()
8810 {
8811 stru262_TurnBased *v1; // esi@1
8812 int v2; // ecx@1
8813 int v3; // ebx@1
8814 char *v4; // edi@1
8815 int v5; // eax@4
8816 int v6; // eax@12
8817 char *v7; // eax@15
8818 TurnBased_QueueElem *v8; // edi@17
8819 unsigned int v9; // edx@23
8820 char *v10; // eax@26
8821 int v11; // eax@30
8822 int v12; // ebx@30
8823 char *v13; // edi@31
8824 int v15; // [sp+Ch] [bp-10h]@5
8825 TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3
8826 int v17; // [sp+14h] [bp-8h]@2
8827 int v18; // [sp+14h] [bp-8h]@16
8828 signed int v19; // [sp+18h] [bp-4h]@1
8829 int v20; // [sp+18h] [bp-4h]@14
8830
8831 v1 = this;
8832 v2 = 0;
8833 v19 = 0;
8834 v3 = v1->uActorQueueSize;
8835 v1->field_1C = 0;
8836 v4 = (char *)&v1->pQueue[v3].field_4;
8837 do
8838 {
8839 v17 = v2;
8840 if ( v1->uActorQueueSize <= v2 )
8841 goto LABEL_11;
8842 v16 = v1->pQueue;
8843 while ( 1 )
8844 {
8845 v5 = v16->uPackedID;
8846 if ( (v16->uPackedID & 7) == 4 )
8847 break;
8848 LABEL_8:
8849 ++v17;
8850 ++v16;
8851 if ( v17 >= v1->uActorQueueSize )
8852 goto LABEL_11;
8853 }
8854 v15 = v5 >> 3;
8855 if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 )
8856 {
8857 v2 = 0;
8858 goto LABEL_8;
8859 }
8860 v2 = 0;
8861 LABEL_11:
8862 if ( v17 == v1->uActorQueueSize )
8863 {
8864 *(int *)v4 = 100;
8865 v6 = 8 * v19;
8866 LOBYTE(v6) = 8 * v19 | 4;
8867 *((int *)v4 + 2) = v2;
8868 *((int *)v4 - 1) = v6;
8869 *((int *)v4 + 1) = v2;
8870 ++v3;
8871 v4 += 16;
8872 }
8873 ++v19;
8874 }
8875 while ( v19 < 4 );
8876 v1->uActorQueueSize = v3;
8877 v20 = v2;
8878 if ( ai_arrays_size > v2 )
8879 {
8880 v7 = (char *)&v1->pQueue[v3].field_4;
8881 do
8882 {
8883 v18 = v2;
8884 if ( v1->uActorQueueSize > v2 )
8885 {
8886 v8 = v1->pQueue;
8887 do
8888 {
8889 if ( (v8->uPackedID & 7) == 3 && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 )
8890 break;
8891 ++v18;
8892 ++v8;
8893 }
8894 while ( v18 < v1->uActorQueueSize );
8895 v2 = 0;
8896 }
8897 if ( v18 == v1->uActorQueueSize )
8898 {
8899 v9 = ai_array_4F7DB0_actor_ids[v20];
8900 *(int *)v7 = 1;
8901 *((int *)v7 + 2) = v2;
8902 *((int *)v7 - 1) = 8 * v9 | 3;
8903 *((int *)v7 + 1) = v2;
8904 ++v3;
8905 v7 += 16;
8906 }
8907 ++v20;
8908 }
8909 while ( v20 < ai_arrays_size );
8910 }
8911 ++v1->field_0;
8912 v1->uActorQueueSize = v3;
8913 v1->field_10 = 100;
8914 if ( v3 > 0 )
8915 {
8916 v10 = (char *)&v1->pQueue[0].field_4;
8917 do
8918 {
8919 if ( *(int *)v10 <= 0 )
8920 *(int *)v10 = 100;
8921 ++v2;
8922 v10 += 16;
8923 }
8924 while ( v2 < v1->uActorQueueSize );
8925 }
8926 LOWORD(v11) = v1->_4063A1();
8927 v12 = 0;
8928 if ( v1->uActorQueueSize > 0 )
8929 {
8930 v13 = (char *)&v1->pQueue[0].field_4;
8931 do
8932 {
8933 v11 = *((int *)v13 - 1) & 7;
8934 if ( (char)v11 == 4 )
8935 break;
8936 if ( *(int *)v13 > 0 )
8937 break;
8938 LOWORD(v11) = v1->_40680F(v12++);
8939 v13 += 16;
8940 }
8941 while ( v12 < v1->uActorQueueSize );
8942 }
8943 return v11;
8944 }
8945 // 4F75D8: using guessed type int ai_arrays_size;
8946
8947 //----- (004061CA) --------------------------------------------------------
8948 void stru262_TurnBased::NextTurn()
8949 {
8950 stru262_TurnBased *v1; // esi@1
8951 TurnBased_QueueElem *v2; // ebp@1
8952 int v3; // ebx@1
8953 int v4; // edi@7
8954 Actor *v5; // eax@9
8955 int v6; // ecx@9
8956 signed int v7; // ebx@17
8957 int v8; // ebp@27
8958 TurnBased_QueueElem *v9; // edi@28
8959 int v10; // ecx@30
8960 unsigned __int16 v11; // ax@30
8961 signed int v12; // edx@35
8962 signed int v13; // [sp+10h] [bp-4h]@7
8963
8964 v1 = this;
8965 _404544();
8966 v2 = v1->pQueue;
8967 v3 = 0;
8968 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
8969 uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1;
8970 else
8971 uActiveCharacter = 0;
8972 viewparams->bRedrawGameUI = 1;
8973 if ( v1->field_1C )
8974 {
8975 pTurnEngine->field_18 |= 2u;
8976 return;
8977 }
8978 pTurnEngine->field_18 &= 0xFFFFFFFDu;
8979 if ( v1->pQueue[0].field_4 <= 0 )
8980 return;
8981 v4 = 0;
8982 v13 = 0;
8983 if ( v1->uActorQueueSize <= 0 )
8984 goto LABEL_27;
8985 do
8986 {
8987 if ( (v2->uPackedID & 7) != 4 )
8988 {
8989 v5 = &pActors[v2->uPackedID >> 3];
8990 LOWORD(v6) = v5->uAIState;
8991 if ( (short)v6 == 4
8992 || (short)v6 == 8
8993 || (short)v6 == 2
8994 || (short)v6 == 3
8995 || (short)v6 == 12
8996 || (short)v6 == 13
8997 || (short)v6 == 18
8998 || (short)v6 == 17 )
8999 {
9000 v7 = v5->uCurrentActionLength;
9001 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
9002 if ( (signed int)v5->uCurrentActionTime < v7 )
9003 {
9004 v13 = 1;
9005 LABEL_19:
9006 v3 = 0;
9007 goto LABEL_20;
9008 }
9009 v6 = (signed __int16)v6;
9010 if ( (signed __int16)v6 == 4 )
9011 {
9012 v3 = 0;
9013 v5->uAIState = Dead;
9014 v5->uCurrentActionTime = 0;
9015 v5->uCurrentActionLength = 0;
9016 v5->UpdateAnimation();
9017 }
9018 else
9019 {
9020 if ( v6 != 8 )
9021 goto LABEL_19;
9022 v3 = 0;
9023 Actor::_403F58(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0);
9024 }
9025 }
9026 }
9027 LABEL_20:
9028 ++v4;
9029 ++v2;
9030 }
9031 while ( v4 < v1->uActorQueueSize );
9032 if ( v13 != v3 )
9033 {
9034 v1->field_18 |= 1u;
9035 return;
9036 }
9037 LABEL_27:
9038 v1->field_18 &= 0xFFFFFFFEu;
9039 v8 = 0;
9040 if ( v1->uActorQueueSize > v3 )
9041 {
9042 v9 = v1->pQueue;
9043 do
9044 {
9045 if ( (v9->uPackedID & 7) != 4 )
9046 {
9047 v10 = v9->uPackedID >> 3;
9048 v11 = pActors[v10].uAIState;
9049 if ( v11 != 5 )
9050 {
9051 if ( v11 != 4 && v11 != 11 && v11 != 19 )
9052 {
9053 if ( v11 != 17 )
9054 {
9055 v12 = dword_4F6E08[v10];
9056 v9->uActionLength = v3;
9057 Actor::_403F58(v10, v12, 32, (AIDirection *)v3);
9058 }
9059 }
9060 }
9061 }
9062 ++v8;
9063 ++v9;
9064 }
9065 while ( v8 < v1->uActorQueueSize );
9066 }
9067 v1->field_4 = 3;
9068 pParty->uTimePlayed += __PAIR__(v3, 213);
9069 _494035_timed_effects__water_walking_damage__etc();
9070 v1->uActionPointsLeft = 130;
9071 }
9072
9073 //----- (004063A1) --------------------------------------------------------
9074 int stru262_TurnBased::_4063A1()
9075 {
9076 stru262_TurnBased *v1; // esi@1
9077 int v2; // ebp@1
9078 signed int result; // eax@1
9079 int v4; // edx@1
9080 int v5; // edx@3
9081 int v6; // edi@4
9082 int v7; // ecx@5
9083 Actor *v8; // ecx@11
9084 unsigned __int16 v9; // dx@12
9085 int v10; // edi@16
9086 int v11; // edx@17
9087 char v12; // zf@18
9088
9089 v1 = this;
9090 _404544();
9091 v2 = (int)&v1->pQueue[0].field_4;
9092 result = 1;
9093 viewparams->bRedrawGameUI = 1;
9094 v4 = v1->pQueue[0].field_4;
9095 if ( v4 )
9096 {
9097 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
9098 {
9099 v5 = v1->uActorQueueSize;
9100 while ( 1 )
9101 {
9102 v6 = 0;
9103 if ( v5 > 0 )
9104 {
9105 v7 = (int)&v1->pQueue[0].field_4;
9106 do
9107 {
9108 --*(int *)v7;
9109 v5 = v1->uActorQueueSize;
9110 ++v6;
9111 v7 += 16;
9112 }
9113 while ( v6 < v5 );
9114 }
9115 --v1->field_10;
9116 if ( v1->field_10 <= 0 )
9117 break;
9118 if ( !*(int *)v2 )
9119 goto LABEL_9;
9120 }
9121 LABEL_24:
9122 result = 1;
9123 }
9124 else
9125 {
9126 v8 = &pActors[v1->pQueue[0].uPackedID >> 3];
9127 if ( v4 > 0 )
9128 {
9129 do
9130 {
9131 v9 = v8->uAIState;
9132 if ( v9 == 5 )
9133 break;
9134 if ( v9 == 4 || v9 == 19 || v9 == 11 )
9135 break;
9136 v10 = 0;
9137 if ( v1->uActorQueueSize > 0 )
9138 {
9139 v11 = (int)&v1->pQueue[0].field_4;
9140 do
9141 {
9142 v12 = (*(int *)v11)-- == 1;
9143 if ( v12 )
9144 *(int *)(v11 + 4) = 0;
9145 ++v10;
9146 v11 += 16;
9147 }
9148 while ( v10 < v1->uActorQueueSize );
9149 }
9150 --v1->field_10;
9151 if ( v1->field_10 <= 0 )
9152 goto LABEL_24;
9153 }
9154 while ( *(int *)v2 > 0 );
9155 }
9156 LABEL_9:
9157 result = 0;
9158 }
9159 }
9160 return result;
9161 }
9162
9163 //----- (00406457) --------------------------------------------------------
9164 int stru262_TurnBased::_406457(int a2)
9165 {
9166 stru262_TurnBased *v2; // esi@1
9167 signed int v3; // eax@1
9168 signed int v4; // ecx@2
9169 char *v5; // edx@2
9170 signed int v6; // eax@2
9171 int result; // eax@11
9172 int v8; // edx@13
9173 int v9; // ecx@14
9174 char v10; // zf@15
9175
9176 v2 = this;
9177 v3 = *(&this->field_0 + 4 * (a2 + 2));
9178 if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == 4 )
9179 {
9180 v4 = v3 >> 3;
9181 v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3];
9182 v6 = *(int *)v5;
9183 if ( *(int *)v5 )
9184 *(int *)v5 = 0;
9185 else
9186 v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
9187 if ( v6 < 30 )
9188 v6 = 30;
9189 }
9190 else
9191 {
9192 v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime;
9193 }
9194 v2->pQueue[a2].field_4 = v6;
9195 v2->_404544();
9196 if ( (v2->pQueue[0].uPackedID & 7) == 4 )
9197 uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1;
9198 else
9199 uActiveCharacter = 0;
9200 result = (int)&v2->pQueue[0].field_4;
9201 viewparams->bRedrawGameUI = 1;
9202 while ( *(int *)result > 0 )
9203 {
9204 if ( v2->field_10 <= 0 )
9205 break;
9206 v8 = 0;
9207 if ( v2->uActorQueueSize > 0 )
9208 {
9209 v9 = (int)&v2->pQueue[0].field_4;
9210 do
9211 {
9212 v10 = (*(int *)v9)-- == 1;
9213 if ( v10 )
9214 *(int *)(v9 + 4) = 0;
9215 ++v8;
9216 v9 += 16;
9217 }
9218 while ( v8 < v2->uActorQueueSize );
9219 }
9220 --v2->field_10;
9221 if ( v2->field_10 <= 0 )
9222 break;
9223 }
9224 return result;
9225 }
9226
9227 //----- (0040652A) --------------------------------------------------------
9228 void stru262_TurnBased::_40652A()
9229 {
9230 char *v1; // edx@2
9231 Actor *v2; // eax@5
9232 unsigned __int16 v3; // si@5
9233 unsigned int v4; // esi@8
9234 int v5; // [sp+Ch] [bp-4h]@1
9235
9236 v5 = 0;
9237 if ( this->uActorQueueSize > 0 )
9238 {
9239 v1 = (char *)&this->pQueue[0].field_4;
9240 do
9241 {
9242 if ( !*(int *)v1 )
9243 {
9244 if ( (*(v1 - 4) & 7) == 4 )
9245 return;
9246 v2 = &pActors[*((int *)v1 - 1) >> 3];
9247 v3 = v2->uAIState;
9248 if ( !v3 || v3 == 9 || v3 == 7 )
9249 {
9250 v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime;
9251 *(int *)v1 = v4;
9252 if ( (signed __int64)v2->pActorBuffs[7].uExpireTime > 0 )
9253 *(int *)v1 = 2 * v4;
9254 }
9255 }
9256 ++v5;
9257 v1 += 16;
9258 }
9259 while ( v5 < this->uActorQueueSize );
9260 }
9261 }
9262
9263 //----- (004065B0) --------------------------------------------------------
9264 __int16 stru262_TurnBased::_4065B0()
9265 {
9266 stru262_TurnBased *v1; // esi@1
9267 signed int v2; // eax@1
9268 int v3; // ebx@6
9269 int v4; // edi@7
9270 unsigned int v5; // edi@14
9271
9272 v1 = this;
9273 LOWORD(v2) = _404544();
9274 if ( v1->pQueue[0].field_4 <= 0
9275 || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != 4) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2),
9276 viewparams->bRedrawGameUI = 1,
9277 v1->pQueue[0].field_4 <= 0) )
9278 {
9279 v3 = 0;
9280 if ( v1->uActorQueueSize > 0 )
9281 {
9282 v4 = (int)v1->pQueue;
9283 do
9284 {
9285 v2 = *(int *)v4;
9286 if ( (*(char *)v4 & 7) == 4 || *(int *)(v4 + 4) > 0 )
9287 break;
9288 if ( *(int *)(v4 + 8) <= 0 )
9289 {
9290 LOWORD(v2) = v2 & 3;
9291 if ( (char)v2 == 3 )
9292 LOWORD(v2) = v1->_40680F(v3);
9293 }
9294 ++v3;
9295 v4 += 16;
9296 }
9297 while ( v3 < v1->uActorQueueSize );
9298 }
9299 }
9300 v5 = 0;
9301 if ( v1->uActorQueueSize > 0 )
9302 {
9303 do
9304 LOWORD(v2) = v1->_406648(v5++);
9305 while ( (signed int)v5 < v1->uActorQueueSize );
9306 }
9307 return v2;
9308 }
9309
9310 //----- (00406648) --------------------------------------------------------
9311 __int16 stru262_TurnBased::_406648(unsigned int a2)
9312 {
9313 TurnBased_QueueElem *v1; // ecx@1
9314 int v3; // eax@1
9315 unsigned int v4; // ebx@2
9316 Actor *v5; // esi@2
9317 signed int v6; // edi@5
9318 int v7; // ecx@6
9319 int v8; // eax@6
9320 int v9; // eax@7
9321 int v10; // eax@8
9322 int v11; // eax@9
9323 int v12; // eax@10
9324 int v13; // eax@11
9325 int v14; // eax@14
9326 unsigned int v15; // ecx@14
9327 unsigned int v16; // edx@14
9328 int v17; // eax@17
9329 int v18; // eax@20
9330 char v19; // al@24
9331 unsigned int v21; // [sp-8h] [bp-50h]@16
9332 int v22; // [sp-8h] [bp-50h]@17
9333 AIDirection *v23; // [sp-4h] [bp-4Ch]@14
9334 unsigned int v24; // [sp-4h] [bp-4Ch]@17
9335 char v25; // [sp-4h] [bp-4Ch]@20
9336 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
9337 AIDirection a4; // [sp+28h] [bp-20h]@2
9338 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
9339 unsigned int a2a; // [sp+50h] [bp+8h]@2
9340
9341 v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
9342 v28 = v1;
9343 v3 = v1->uPackedID;
9344 if ( (v1->uPackedID & 7) != 4 )
9345 {
9346 v4 = v3 >> 3; // turn based only stuff
9347 a2a = dword_4F6E08[v3 >> 3];
9348 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3));
9349 memcpy(&a4, &a3, sizeof(a4));
9350 v5 = &pActors[v3 >> 3];
9351 LOWORD(v3) = v5->uAIState;
9352 if ( (short)v3 != Dead )
9353 {
9354 if ( (short)v3 != Disabled )
9355 {
9356 if ( (short)v3 != Removed )
9357 {
9358 v6 = v5->uCurrentActionLength;
9359 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
9360 if ( (signed int)v5->uCurrentActionTime >= v6 )
9361 {
9362 v7 = (signed __int16)v3;
9363 v8 = (signed __int16)v3 - 2;
9364 if ( !v8 )
9365 {
9366 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
9367 stru_50FE08.Add(
9368 v28->uPackedID,
9369 5120,
9370 v5->vPosition.x,
9371 v5->vPosition.y,
9372 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
9373 v19,
9374 1);
9375 goto LABEL_25;
9376 }
9377 v9 = v8 - 1;
9378 if ( v9 )
9379 {
9380 v10 = v9 - 1;
9381 if ( !v10 )
9382 goto LABEL_21;
9383 v11 = v10 - 4;
9384 if ( !v11 )
9385 goto LABEL_25;
9386 v12 = v11 - 4;
9387 if ( v12 )
9388 {
9389 v13 = v12 - 1;
9390 if ( v13 )
9391 {
9392 if ( v13 != Dead )
9393 {
9394 if ( v7 != 4 )
9395 {
9396 v14 = rand();
9397 v15 = v4;
9398 v23 = &a4;
9399 v16 = a2a;
9400 if ( !(v14 % 2) )
9401 {
9402 LOWORD(v3) = Actor::_402F87(v4, a2a, &a4);
9403 return v3;
9404 }
9405 v21 = 64;
9406 LABEL_26:
9407 LOWORD(v3) = Actor::_403EB6(v15, v16, v21, v23);
9408 return v3;
9409 }
9410 LABEL_21:
9411 v5->uCurrentActionTime = 0;
9412 v5->uCurrentActionLength = 0;
9413 v5->uAIState = Dead;
9414 return pActors[v4].UpdateAnimation();
9415 }
9416 v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
9417 v22 = 3;
9418 v17 = v5->pMonsterInfo.uSpell2ID;
9419 }
9420 else
9421 {
9422 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
9423 v22 = 2;
9424 v17 = v5->pMonsterInfo.uSpell1ID;
9425 }
9426 Actor::_404AC7(v4, &a4, v17, v22, v24);
9427 LABEL_25:
9428 v16 = a2a;
9429 v23 = &a4;
9430 v21 = 0;
9431 v15 = v4;
9432 goto LABEL_26;
9433 }
9434 v18 = v5->pMonsterInfo.uMissleAttack2Type;
9435 v25 = 1;
9436 }
9437 else
9438 {
9439 v18 = v5->pMonsterInfo.uMissleAttack1Type;
9440 v25 = 0;
9441 }
9442 Actor::_404874(v4, &a4, v18, v25);
9443 goto LABEL_25;
9444 }
9445 }
9446 }
9447 }
9448 }
9449 return v3;
9450 }
9451 // 50FE08: using guessed type stru298 stru_50FE08;
9452
9453 //----- (0040680F) --------------------------------------------------------
9454 __int16 stru262_TurnBased::_40680F(int a2)
9455 {
9456 TurnBased_QueueElem *v2; // eax@1
9457 TurnBased_QueueElem *v3; // eax@1
9458 TurnBased_QueueElem *v4; // edi@2
9459 Actor *v5; // ebx@2
9460 unsigned int *v6; // esi@7
9461 AIDirection *v7; // esi@10
9462 int v8; // eax@10
9463 unsigned int v9; // ecx@10
9464 signed int v10; // eax@13
9465 unsigned __int8 v11; // sf@19
9466 unsigned __int8 v12; // of@19
9467 int v13; // esi@29
9468 bool v14; // eax@29
9469 unsigned __int8 v15; // cl@33
9470 AIDirection a3; // [sp+Ch] [bp-44h]@10
9471 AIDirection v18; // [sp+28h] [bp-28h]@10
9472 int a2a; // [sp+44h] [bp-Ch]@2
9473 unsigned int v20; // [sp+48h] [bp-8h]@10
9474 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
9475 signed int v22; // [sp+58h] [bp+8h]@10
9476
9477 v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
9478 v21 = v2;
9479 v2->uActionLength = 0;
9480 v3 = (TurnBased_QueueElem *)v2->uPackedID;
9481 if ( (unsigned __int8)v3 & 3 )
9482 {
9483 v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3);
9484 v4 = v3;
9485 a2a = (int)v3;
9486 v5 = &pActors[(int)v3];
9487 LOWORD(v3) = v5->uAIState;
9488 if ( (short)v3 != 5 )
9489 {
9490 if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
9491 {
9492 v6 = (unsigned int *)&dword_4F6E08[(int)v4];
9493 Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u);
9494 if ( v5->pMonsterInfo.uHostilityType && !*v6 )
9495 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
9496 v22 = *v6;
9497 v7 = Actor::GetDirectionInfo(8 * (int)v4 | 3, *v6, &a3, 0);
9498 v8 = v5->uActorRadius;
9499 memcpy(&a3, v7, sizeof(a3));
9500 memcpy(&v18, &a3, sizeof(v18));
9501 v9 = a3.uDistance - v8;
9502 v20 = a3.uDistance - v8;
9503 if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
9504 {
9505 v9 = 0;
9506 v20 = 0;
9507 }
9508 if ( (v22 & 7) == 3 )
9509 v10 = (unsigned __int8)*(&byte_5C8D1A[89
9510 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1)
9511 / 3]
9512 + (v5->pMonsterInfo.uID - 1) / 3);
9513 else
9514 v10 = 4;
9515 if ( v10 == 1 )
9516 {
9517 if ( (double)(signed int)v20 < 307.2 )
9518 goto LABEL_25;
9519 }
9520 else
9521 {
9522 if ( v10 == 2 )
9523 {
9524 v12 = __OFSUB__(v9, 1024);
9525 v11 = ((v9 - 1024) & 0x80000000u) != 0;
9526 }
9527 else
9528 {
9529 if ( v10 == 3 )
9530 {
9531 v12 = __OFSUB__(v9, 2560);
9532 v11 = ((v9 - 2560) & 0x80000000u) != 0;
9533 }
9534 else
9535 {
9536 if ( v10 != 4 )
9537 goto LABEL_26;
9538 v12 = __OFSUB__(v9, 5120);
9539 v11 = ((v9 - 5120) & 0x80000000u) != 0;
9540 }
9541 }
9542 if ( v11 ^ v12 )
9543 {
9544 LABEL_25:
9545 v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
9546 goto LABEL_26;
9547 }
9548 }
9549 LABEL_26:
9550 if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
9551 {
9552 v13 = a2a;
9553 goto LABEL_47;
9554 }
9555 v13 = a2a;
9556 v14 = stru_50C198.special_ability_use_check(v5, a2a);
9557 if ( v14 == 1 )
9558 {
9559 if ( v5->pMonsterInfo.uMissleAttack2Type )
9560 {
9561 Actor::_40368B(v13, v22, &v18);
9562 goto LABEL_43;
9563 }
9564 }
9565 else
9566 {
9567 if ( v14 > 1 && v14 <= 3 )
9568 {
9569 if ( v14 == 2 )
9570 v15 = v5->pMonsterInfo.uSpell1ID;
9571 else
9572 v15 = v5->pMonsterInfo.uSpell2ID;
9573 if ( v15 )
9574 {
9575 if ( v14 == 2 )
9576 Actor::_403854(v13, v22, &v18);
9577 else
9578 Actor::_403A60(v13, v22, &v18);
9579 goto LABEL_43;
9580 }
9581 goto LABEL_44;
9582 }
9583 if ( v5->pMonsterInfo.uMissleAttack1Type )
9584 {
9585 Actor::_403476(v13, v22, &v18);
9586 LABEL_43:
9587 v3 = v21;
9588 v21->field_C = 1;
9589 LABEL_48:
9590 v3->uActionLength = v5->uCurrentActionLength;
9591 return (signed __int16)v3;
9592 }
9593 }
9594 LABEL_44:
9595 if ( (double)(signed int)v20 < 307.2 )
9596 {
9597 Actor::_403C6C(v13, v22, &v18);
9598 v3 = v21;
9599 v21->field_C = 3;
9600 goto LABEL_48;
9601 }
9602 LABEL_47:
9603 Actor::_403EB6(v13, v22, 0x40u, &v18);
9604 v3 = v21;
9605 v21->field_C = 0;
9606 goto LABEL_48;
9607 }
9608 }
9609 }
9610 return (signed __int16)v3;
9611 }
9612
9613 //----- (00406A63) --------------------------------------------------------
9614 void stru262_TurnBased::_406A63()
9615 {
9616 stru262_TurnBased *v1; // ebx@1
9617 int v2; // esi@1
9618 unsigned __int8 v3; // zf@1
9619 unsigned __int8 v4; // sf@1
9620 signed int v5; // ecx@4
9621 AIDirection a3; // [sp+8h] [bp-44h]@5
9622 AIDirection v7; // [sp+24h] [bp-28h]@5
9623 unsigned int v8; // [sp+40h] [bp-Ch]@5
9624 signed int a2; // [sp+44h] [bp-8h]@1
9625 TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
9626
9627 v1 = this;
9628 v2 = 0;
9629 this->field_8 = 64;
9630 dword_50C994 = 0;
9631 uActiveCharacter = 0;
9632 v3 = this->uActorQueueSize == 0;
9633 v4 = this->uActorQueueSize < 0;
9634 a2 = 0;
9635 if ( !(v4 | v3) )
9636 {
9637 v10 = this->pQueue;
9638 while ( 1 )
9639 {
9640 v5 = v10->uPackedID;
9641 if ( (v10->uPackedID & 7) == 3 )
9642 {
9643 v8 = dword_4F6E08[v5 >> 3];
9644 memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
9645 if ( !v1->_406D10(a2) )
9646 Actor::_403EB6(v10->uPackedID >> 3, v8, 0x20u, &v7);
9647 }
9648 ++a2;
9649 ++v10;
9650 if ( a2 >= v1->uActorQueueSize )
9651 break;
9652 v2 = 0;
9653 }
9654 }
9655 }
9656 // 50C994: using guessed type int dword_50C994;
9657
9658 //----- (00406AFE) --------------------------------------------------------
9659 void stru262_TurnBased::_406AFE()
9660 {
9661 stru262_TurnBased *v1; // edi@1
9662 TurnBased_QueueElem *v2; // ebx@2
9663 int v3; // esi@4
9664 int v4; // ecx@5
9665 AIDirection a3; // [sp+4h] [bp-48h]@5
9666 AIDirection v6; // [sp+20h] [bp-2Ch]@5
9667 stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1
9668 unsigned int v8; // [sp+40h] [bp-Ch]@4
9669 unsigned int v9; // [sp+44h] [bp-8h]@5
9670 int v10; // [sp+48h] [bp-4h]@1
9671
9672 v10 = 0;
9673 v1 = this;
9674 v7 = this;
9675 if ( this->uActorQueueSize > 0 )
9676 {
9677 v2 = this->pQueue;
9678 do
9679 {
9680 if ( (v2->uPackedID & 7) == 3 )
9681 {
9682 v3 = v2->uPackedID >> 3;
9683 v8 = v3;
9684 if ( pActors[v3].CanAct() )
9685 {
9686 v4 = v2->uPackedID;
9687 v9 = dword_4F6E08[v3];
9688 memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
9689 Actor::_403EB6(v8, v9, 0x20u, &v6);
9690 v2->field_C = 0;
9691 v2->uActionLength = 0;
9692 v1 = v7;
9693 }
9694 }
9695 ++v10;
9696 ++v2;
9697 }
9698 while ( v10 < v1->uActorQueueSize );
9699 }
9700 v1->field_4 = 2;
9701 v1->field_8 = 100;
9702 }
9703
9704 //----- (00406B9F) --------------------------------------------------------
9705 int stru262_TurnBased::_406B9F()
9706 {
9707 signed int result; // eax@1
9708 unsigned __int8 v2; // zf@1
9709 unsigned __int8 v3; // sf@1
9710 int v4; // esi@4
9711 unsigned int v5; // esi@5
9712 Actor *v6; // ebx@5
9713 unsigned __int16 v7; // cx@15
9714 AIDirection a3; // [sp+0h] [bp-50h]@15
9715 AIDirection v9; // [sp+1Ch] [bp-34h]@15
9716 signed int a1; // [sp+38h] [bp-18h]@4
9717 stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
9718 unsigned int v12; // [sp+40h] [bp-10h]@5
9719 unsigned int v13; // [sp+44h] [bp-Ch]@8
9720 TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
9721 signed int a2; // [sp+4Ch] [bp-4h]@1
9722
9723 result = 0;
9724 thisa = this;
9725 v2 = this->uActorQueueSize == 0;
9726 v3 = this->uActorQueueSize < 0;
9727 a2 = 0;
9728 if ( !(v3 | v2) )
9729 {
9730 v14 = this->pQueue;
9731 while ( 1 )
9732 {
9733 v4 = v14->uPackedID;
9734 a1 = v14->uPackedID;
9735 if ( (a1 & 7) != 4 )
9736 {
9737 v5 = v4 >> 3;
9738 v12 = v5;
9739 v6 = &pActors[v5];
9740 if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
9741 || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
9742 v13 = result;
9743 else
9744 v13 = 1;
9745 if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
9746 && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
9747 result = 1;
9748 if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) )
9749 {
9750 v13 = dword_4F6E08[v5];
9751 memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
9752 v7 = v6->uAIState;
9753 if ( v7 == 6 || v7 == 1 )
9754 {
9755 if ( (double)(signed int)v9.uDistance < 307.2 )
9756 goto LABEL_26;
9757 }
9758 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
9759 if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
9760 {
9761 if ( v7 == 4 )
9762 {
9763 v6->uCurrentActionTime = 0;
9764 v6->uCurrentActionLength = 0;
9765 v6->uAIState = Dead;
9766 v6->UpdateAnimation();
9767 }
9768 if ( !thisa->_406D10(a2) )
9769 LABEL_26:
9770 Actor::_403EB6(v12, v13, 0x20u, &v9);
9771 }
9772 }
9773 }
9774 ++a2;
9775 result = (signed int)thisa;
9776 ++v14;
9777 if ( a2 >= thisa->uActorQueueSize )
9778 break;
9779 result = 0;
9780 }
9781 }
9782 return result;
9783 }
9784
9785 //----- (00406D10) --------------------------------------------------------
9786 bool stru262_TurnBased::_406D10(signed int a2)
9787 {
9788 int v2; // ecx@1
9789 int v3; // ecx@2
9790 Actor *v4; // ebx@2
9791 unsigned __int16 v5; // dx@2
9792 int *v6; // esi@7
9793 TurnBased_QueueElem *v7; // edi@7
9794 int v8; // eax@7
9795 AIDirection *v9; // esi@10
9796 int v10; // eax@10
9797 unsigned int v11; // ecx@10
9798 unsigned __int8 v12; // al@12
9799 unsigned __int8 v13; // sf@16
9800 unsigned __int8 v14; // of@16
9801 unsigned int v15; // edx@22
9802 unsigned int v16; // ecx@23
9803 TurnBased_QueueElem *v17; // eax@25
9804 double v18; // st7@33
9805 double v19; // st6@33
9806 int v21; // [sp-8h] [bp-5Ch]@23
9807 int v22; // [sp-8h] [bp-5Ch]@26
9808 AIDirection *v23; // [sp-4h] [bp-58h]@23
9809 int v24; // [sp-4h] [bp-58h]@26
9810 AIDirection a3; // [sp+Ch] [bp-48h]@10
9811 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
9812 int v27; // [sp+44h] [bp-10h]@33
9813 unsigned int v28; // [sp+48h] [bp-Ch]@10
9814 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
9815 unsigned int uActorID; // [sp+50h] [bp-4h]@2
9816 unsigned int a2a; // [sp+5Ch] [bp+8h]@7
9817
9818 v2 = *(&this->field_0 + 4 * (a2 + 2));
9819 if ( (v2 & 7) == 4 )
9820 return 0;
9821 v3 = v2 >> 3;
9822 uActorID = v3;
9823 v4 = &pActors[v3];
9824 v5 = v4->uAIState;
9825 if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 )
9826 return 1;
9827 v6 = &dword_4F6E08[v3];
9828 v7 = &pTurnEngine->pQueue[a2];
9829 v8 = *v6;
9830 v29 = &pTurnEngine->pQueue[a2];
9831 a2a = v8;
9832 Actor::_401221(v3, &dword_4F6E08[v3], 1u);
9833 if ( v4->pMonsterInfo.uHostilityType && !*v6 )
9834 v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
9835 v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
9836 v10 = v4->uActorRadius;
9837 memcpy(&a3, v9, sizeof(a3));
9838 memcpy(&pDir, &a3, sizeof(pDir));
9839 v11 = a3.uDistance - v10;
9840 v28 = a3.uDistance - v10;
9841 if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
9842 {
9843 v11 = 0;
9844 v28 = 0;
9845 }
9846 v12 = v4->pMonsterInfo.uHostilityType;
9847 if ( v12 == 1 )
9848 {
9849 if ( (double)(signed int)v28 >= 307.2 )
9850 goto LABEL_21;
9851 LABEL_20:
9852 v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
9853 goto LABEL_21;
9854 }
9855 if ( v12 == 2 )
9856 {
9857 v14 = __OFSUB__(v11, 1024);
9858 v13 = ((v11 - 1024) & 0x80000000u) != 0;
9859 }
9860 else
9861 {
9862 if ( v12 != 3 )
9863 goto LABEL_21;
9864 v14 = __OFSUB__(v11, 2560);
9865 v13 = ((v11 - 2560) & 0x80000000u) != 0;
9866 }
9867 if ( v13 ^ v14 )
9868 goto LABEL_20;
9869 LABEL_21:
9870 if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
9871 {
9872 v15 = a2a;
9873 if ( (signed int)v11 < 10240 )
9874 {
9875 v23 = &pDir;
9876 v16 = uActorID;
9877 v21 = 0;
9878 goto LABEL_24;
9879 }
9880 v24 = 0;
9881 v22 = 1024;
9882 goto LABEL_58;
9883 }
9884 if ( v4->pMonsterInfo.uHostilityType != 4 )
9885 goto LABEL_46;
9886 if ( !(v4->uAttributes & 0x020000) || v4->pMonsterInfo.uAIType == 1 )
9887 {
9888 if ( v4->pMonsterInfo.uAIType == 1 )
9889 goto LABEL_36;
9890 if ( v4->pMonsterInfo.uAIType == 2 )
9891 {
9892 v27 = v4->sCurrentHP;
9893 v18 = (double)v27;
9894 v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.2;
9895 goto LABEL_34;
9896 }
9897 if ( v4->pMonsterInfo.uAIType == 3 )
9898 {
9899 v27 = v4->sCurrentHP;
9900 v18 = (double)v27;
9901 v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.1;
9902 LABEL_34:
9903 if ( v19 > v18 && (signed int)v11 < 10240 )
9904 {
9905 LABEL_36:
9906 v16 = uActorID;
9907 v15 = a2a;
9908 v23 = 0;
9909 v21 = 32;
9910 if ( v4->pMonsterInfo.uMovementType == 5 )
9911 {
9912 Actor::_403EB6(uActorID, a2a, 0x20u, 0);
9913 goto LABEL_25;
9914 }
9915 LABEL_24:
9916 Actor::_402968(v16, v15, v21, v23);
9917 LABEL_25:
9918 v17 = v29;
9919 v29->field_C = 4;
9920 LABEL_60:
9921 v17->uActionLength = v4->uCurrentActionLength;
9922 return 1;
9923 }
9924 goto LABEL_39;
9925 }
9926 }
9927 LABEL_39:
9928 if ( (double)(signed int)v28 < 307.2 )
9929 return 0;
9930 if ( (signed int)v11 < 5120 )
9931 {
9932 if ( v4->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
9933 Actor::_402AD7(uActorID, a2a, uActorID, 32, &pDir);
9934 else
9935 Actor::_40281C(uActorID, a2a, 32, &pDir, 307);
9936 goto LABEL_59;
9937 }
9938 LABEL_46:
9939 if ( !v4->pMonsterInfo.uMovementType )
9940 {
9941 v24 = 32;
9942 v22 = 1024;
9943 goto LABEL_57;
9944 }
9945 if ( v4->pMonsterInfo.uMovementType == 1 )
9946 {
9947 v24 = 32;
9948 v22 = 2560;
9949 goto LABEL_57;
9950 }
9951 if ( v4->pMonsterInfo.uMovementType == 2 )
9952 {
9953 v24 = 32;
9954 v22 = 5120;
9955 LABEL_57:
9956 v15 = a2a;
9957 LABEL_58:
9958 Actor::_4032B2(uActorID, v15, v22, v24);
9959 LABEL_59:
9960 v17 = v29;
9961 v29->field_C = 2;
9962 goto LABEL_60;
9963 }
9964 if ( v4->pMonsterInfo.uMovementType == 4 )
9965 {
9966 Actor::_4032B2(uActorID, a2a, 10240, 32);
9967 goto LABEL_53;
9968 }
9969 if ( v4->pMonsterInfo.uMovementType == 5 )
9970 {
9971 Actor::_403EB6(uActorID, a2a, 0x20u, 0);
9972 LABEL_53:
9973 v17 = v29;
9974 v29->field_C = 2;
9975 goto LABEL_60;
9976 }
9977 return 1;
9978 }
9979
9980 //----- (00406FA8) --------------------------------------------------------
9981 void stru262_TurnBased::_406FA8()
9982 {
9983 unsigned __int8 v1; // zf@1
9984 unsigned __int8 v2; // sf@1
9985 TurnBased_QueueElem *v3; // edi@2
9986 int v4; // eax@4
9987 Actor *v5; // ebx@4
9988 unsigned __int16 v6; // cx@4
9989 unsigned int *v7; // edx@8
9990 unsigned int v8; // esi@8
9991 unsigned __int8 v9; // of@13
9992 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
9993 AIDirection v11; // [sp+28h] [bp-50h]@8
9994 AIDirection a4; // [sp+44h] [bp-34h]@8
9995 stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
9996 TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
9997 int uActorID; // [sp+68h] [bp-10h]@4
9998 unsigned int a2; // [sp+6Ch] [bp-Ch]@8
9999 int v17; // [sp+70h] [bp-8h]@1
10000 unsigned int v18; // [sp+74h] [bp-4h]@2
10001
10002 v17 = 0;
10003 v1 = this->uActorQueueSize == 0;
10004 v2 = this->uActorQueueSize < 0;
10005 v13 = this;
10006 if ( !(v2 | v1) )
10007 {
10008 v3 = this->pQueue;
10009 v18 = (char *)&pTurnEngine - (char *)this;
10010 v14 = this->pQueue;
10011 do
10012 {
10013 if ( (v3->uPackedID & 7) != 4 )
10014 {
10015 v4 = v3->uPackedID >> 3;
10016 uActorID = v4;
10017 v5 = &pActors[v4];
10018 v6 = v5->uAIState;
10019 if ( v6 != 5 )
10020 {
10021 if ( v6 != 11 )
10022 {
10023 if ( v6 != 19 )
10024 {
10025 if ( v6 != 17 )
10026 {
10027 v7 = (unsigned int *)&dword_4F6E08[v4];
10028 a2 = *v7;
10029 v8 = a2;
10030 Actor::_401221(v4, (int *)v7, 1u);
10031 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
10032 memcpy(&a4, &v11, sizeof(a4));
10033 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
10034 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
10035 {
10036 if (v5->uAIState == Dying)
10037 {
10038 v5->uCurrentActionTime = 0;
10039 v5->uCurrentActionLength = 0;
10040 v5->uAIState = Dead;
10041 v5->UpdateAnimation();
10042 return;
10043 }
10044 if ( rand() % 2 )
10045 Actor::_403EB6(uActorID, a2, 0x40u, &a4);
10046 else
10047 Actor::_402F87(uActorID, a2, &a4);
10048 }
10049 }
10050 }
10051 }
10052 }
10053 }
10054 ++v17;
10055 v3 = v14 + 1;
10056 v9 = __OFSUB__(v17, v13->uActorQueueSize);
10057 v2 = v17 - v13->uActorQueueSize < 0;
10058 ++v14;
10059 }
10060 while ( v2 ^ v9 );
10061 }
10062 }
10063
10064 //----- (004070EF) --------------------------------------------------------
10065 bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID)
10066 {
10067 signed int v2; // eax@1
10068 unsigned int v3; // ecx@1
10069 signed int v4; // esi@1
10070 int v5; // ecx@2
10071 signed int v6; // eax@4
10072 int v7; // eax@4
10073 float v8; // ST24_4@5
10074 double v9; // ST18_8@5
10075 signed int v10; // eax@6
10076 int v11; // ecx@6
10077 signed int v12; // eax@7
10078 int v13; // esi@7
10079 int v14; // esi@8
10080 int v15; // esi@9
10081 signed int v16; // eax@11
10082 int v17; // edi@11
10083 int v18; // esi@11
10084 int v19; // eax@13
10085 float v20; // ST24_4@14
10086 double v21; // ST18_8@14
10087 signed int v22; // eax@15
10088 int v23; // ebx@16
10089 signed int v24; // ecx@16
10090 int v25; // eax@18
10091 int v26; // eax@28
10092 BLVSector *v27; // edx@31
10093 int v28; // ecx@31
10094 BLVFace *v29; // ebx@32
10095 Vec3_short_ *v30; // esi@32
10096 int v31; // eax@32
10097 int v32; // ST50_4@44
10098 int v33; // ST54_4@44
10099 int v34; // eax@44
10100 char v35; // zf@44
10101 int v36; // edi@44
10102 int v37; // eax@45
10103 signed int v38; // esi@45
10104 int v39; // ST4C_4@49
10105 signed __int64 v40; // qtt@50
10106 __int16 v42; // bx@58
10107 int v43; // [sp-8h] [bp-70h]@11
10108 int v44; // [sp-4h] [bp-6Ch]@11
10109 int v45; // [sp+Ch] [bp-5Ch]@32
10110 __int16 v46; // [sp+10h] [bp-58h]@32
10111 int v47; // [sp+18h] [bp-50h]@20
10112 int v48; // [sp+1Ch] [bp-4Ch]@20
10113 int v49; // [sp+20h] [bp-48h]@20
10114 int v50; // [sp+24h] [bp-44h]@16
10115 signed int v51; // [sp+24h] [bp-44h]@27
10116 signed int v52; // [sp+28h] [bp-40h]@26
10117 signed int v53; // [sp+2Ch] [bp-3Ch]@23
10118 signed int v54; // [sp+30h] [bp-38h]@22
10119 signed int v55; // [sp+34h] [bp-34h]@21
10120 signed int v56; // [sp+38h] [bp-30h]@20
10121 signed int v57; // [sp+3Ch] [bp-2Ch]@28
10122 int v58; // [sp+44h] [bp-24h]@50
10123 int v59; // [sp+48h] [bp-20h]@44
10124 int v60; // [sp+50h] [bp-18h]@11
10125 signed int v61; // [sp+50h] [bp-18h]@31
10126 int v62; // [sp+54h] [bp-14h]@16
10127 int v63; // [sp+58h] [bp-10h]@4
10128 int v64; // [sp+5Ch] [bp-Ch]@4
10129 int v65; // [sp+60h] [bp-8h]@4
10130 int v66; // [sp+64h] [bp-4h]@7
10131
10132 v2 = (signed int)uObjID >> 3;
10133 v3 = (uObjID & 7) - 2;
10134 v4 = uObj2ID;
10135 if ( v3 )
10136 {
10137 v5 = v3 - 1;
10138 if ( v5 )
10139 {
10140 if ( v5 != 2 )
10141 return 0;
10142 v6 = v2;
10143 v63 = pLevelDecorations[v6].vPosition.x;
10144 v64 = pLevelDecorations[v6].vPosition.y;
10145 v65 = pLevelDecorations[v6].vPosition.z;
10146 v7 = pIndoor->GetSector(v63, v64, v65);
10147 }
10148 else
10149 {
10150 v63 = pActors[v2].vPosition.x;
10151 v64 = pActors[v2].vPosition.y;
10152 v8 = (double)pActors[v2].uActorHeight * 0.69999999;
10153 v9 = v8 + 6.7553994e15;
10154 v65 = LODWORD(v9) + pActors[v2].vPosition.z;
10155 v7 = pActors[v2].uSectorID;
10156 }
10157 }
10158 else
10159 {
10160 v10 = v2;
10161 v63 = pLayingItems[v10].vPosition.x;
10162 v64 = pLayingItems[v10].vPosition.y;
10163 v11 = pLayingItems[v10].vPosition.z;
10164 v7 = pLayingItems[v10].uSectorID;
10165 v65 = v11;
10166 }
10167 v66 = v7;
10168 v12 = v4 >> 3;
10169 v13 = (v4 & 7) - 2;
10170 if ( v13 )
10171 {
10172 v14 = v13 - 1;
10173 if ( v14 )
10174 {
10175 v15 = v14 - 1;
10176 if ( v15 )
10177 {
10178 if ( v15 != 1 )
10179 return 0;
10180 v16 = v12;
10181 v17 = pLevelDecorations[v16].vPosition.z;
10182 v18 = pLevelDecorations[v16].vPosition.x;
10183 v44 = pLevelDecorations[v16].vPosition.z;
10184 v60 = pLevelDecorations[v16].vPosition.y;
10185 v43 = pLevelDecorations[v16].vPosition.y;
10186 }
10187 else
10188 {
10189 v18 = pParty->vPosition.x;
10190 v17 = pParty->sEyelevel + pParty->vPosition.z;
10191 v60 = pParty->vPosition.y;
10192 v44 = pParty->sEyelevel + pParty->vPosition.z;
10193 v43 = pParty->vPosition.y;
10194 }
10195 v19 = pIndoor->GetSector(v18, v43, v44);
10196 }
10197 else
10198 {
10199 v60 = pActors[v12].vPosition.y;
10200 v18 = pActors[v12].vPosition.x;
10201 v20 = (double)pActors[v12].uActorHeight * 0.69999999;
10202 v21 = v20 + 6.7553994e15;
10203 v17 = LODWORD(v21) + pActors[v12].vPosition.z;
10204 v19 = pActors[v12].uSectorID;
10205 }
10206 }
10207 else
10208 {
10209 v22 = v12;
10210 v18 = pLayingItems[v22].vPosition.x;
10211 v17 = pLayingItems[v22].vPosition.z;
10212 v60 = pLayingItems[v22].vPosition.y;
10213 v19 = pLayingItems[v22].uSectorID;
10214 }
10215 v62 = v19;
10216 v23 = v18 - v63;
10217 v50 = v17 - v65;
10218 v24 = sub_452A9E(v23 * v23 + (v60 - v64) * (v60 - v64) + v50 * v50);
10219 if ( v24 > 5120 )
10220 return 0;
10221 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
10222 return 1;
10223 v25 = 65536;
10224 if ( v24 )
10225 v25 = 65536 / v24;
10226 v49 = v23 * v25;
10227 v47 = v50 * v25;
10228 v48 = (v60 - v64) * v25;
10229 v56 = v63;
10230 if ( v63 < v18 )
10231 {
10232 v55 = v18;
10233 }
10234 else
10235 {
10236 v56 = v18;
10237 v55 = v63;
10238 }
10239 v54 = v64;
10240 if ( v64 < v60 )
10241 {
10242 v53 = v60;
10243 }
10244 else
10245 {
10246 v54 = v60;
10247 v53 = v64;
10248 }
10249 v52 = v65;
10250 if ( v65 < v17 )
10251 {
10252 v51 = v17;
10253 }
10254 else
10255 {
10256 v52 = v17;
10257 v51 = v65;
10258 }
10259 v57 = 0;
10260 v26 = v66;
10261 while ( 2 )
10262 {
10263 if ( v26 == v62 )
10264 return 1;
10265 if ( v57 >= 30 || (v27 = pIndoor->pSectors, v28 = v66, v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) )
10266 break;
10267 while ( 1 )
10268 {
10269 v29 = &pIndoor->pFaces[v27[v28].pPortals[v61]];
10270 v30 = &pIndoor->pVertices[*v29->pVertexIDs];
10271 v45 = *(int *)&v30->x;
10272 v46 = v30->z;
10273 v31 = v29->pFacePlane_old.vNormal.z * (v46 - v65)
10274 + v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - v64)
10275 + v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - v63);
10276 if ( v66 != v29->uSectorID )
10277 v31 = -v31;
10278 if ( v31 >= 0 && (signed __int16)v45 != v63 && SHIWORD(v45) != v64 && v46 != v65
10279 || v56 > v29->pBounding.x2
10280 || v55 < v29->pBounding.x1
10281 || v54 > v29->pBounding.y2
10282 || v53 < v29->pBounding.y1
10283 || v52 > v29->pBounding.z2
10284 || v51 < v29->pBounding.z1 )
10285 goto LABEL_54;
10286 v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16;
10287 v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16;
10288 v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16;
10289 v35 = v32 + v33 + v34 == 0;
10290 v36 = v32 + v33 + v34;
10291 v59 = v32 + v33 + v34;
10292 if ( v35 )
10293 goto LABEL_53;
10294 v37 = v65 * v29->pFacePlane_old.vNormal.z;
10295 v38 = -(v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y);
10296 if ( v36 <= 0 )
10297 break;
10298 if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y <= 0 )
10299 goto LABEL_49;
10300 LABEL_53:
10301 v27 = pIndoor->pSectors;
10302 LABEL_54:
10303 ++v61;
10304 if ( v61 >= v27[v28].uNumPortals )
10305 goto LABEL_55;
10306 }
10307 if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y < 0 )
10308 goto LABEL_53;
10309 LABEL_49:
10310 v39 = abs(-(v29->pFacePlane_old.dist
10311 + v37
10312 + v63 * v29->pFacePlane_old.vNormal.x
10313 + v64 * v29->pFacePlane_old.vNormal.y)) >> 14;
10314 if ( v39 > abs(v36)
10315 || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0)
10316 || !sub_4075DB(
10317 v63 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16),
10318 v64 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16),
10319 v65 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16),
10320 v29) )
10321 {
10322 v28 = v66;
10323 goto LABEL_53;
10324 }
10325 if ( v29->uSectorID == v66 )
10326 v42 = v29->uBackSectorID;
10327 else
10328 v42 = v29->uSectorID;
10329 v26 = v42;
10330 if ( v42 != v66 )
10331 {
10332 ++v57;
10333 v66 = v42;
10334 continue;
10335 }
10336 break;
10337 }
10338 LABEL_55:
10339 if ( v66 != v62 )
10340 return 0;
10341 return 1;
10342 }
10343
10344 //----- (004075DB) --------------------------------------------------------
10345 bool __fastcall sub_4075DB(int a1, int a2, int a3, BLVFace *a4)
10346 {
10347 BLVFace *v4; // eax@1
10348 unsigned int v5; // esi@1
10349 signed int v6; // esi@2
10350 char v7; // zf@2
10351 int v8; // edi@2
10352 Vec3_short_ *v9; // ecx@3
10353 int v10; // edx@4
10354 signed int v11; // esi@7
10355 Vec3_short_ *v12; // ecx@8
10356 int v13; // edx@9
10357 signed int v14; // esi@11
10358 Vec3_short_ *v15; // ecx@12
10359 int v16; // edx@13
10360 int v17; // eax@14
10361 bool v18; // esi@14
10362 int v19; // ecx@14
10363 int v20; // ecx@16
10364 int v21; // edx@16
10365 int v22; // eax@17
10366 signed int v23; // ebx@18
10367 int v24; // esi@20
10368 signed int v25; // eax@22
10369 signed __int64 v26; // qtt@22
10370 bool result; // eax@25
10371 int v28; // [sp+8h] [bp-14h]@14
10372 int v29; // [sp+10h] [bp-Ch]@14
10373 signed int a3a; // [sp+24h] [bp+8h]@14
10374 int a4a; // [sp+28h] [bp+Ch]@2
10375
10376 v4 = a4;
10377 v5 = a4->uAttributes;
10378 if ( v5 & 0x100 )
10379 {
10380 v6 = 0;
10381 v7 = a4->uNumVertices == 0;
10382 a4a = a1;
10383 v8 = a2;
10384 if ( !v7 )
10385 {
10386 v9 = pIndoor->pVertices;
10387 do
10388 {
10389 dword_4F5D98_xs[v6] = v9[v4->pVertexIDs[v6]].x;
10390 v10 = v4->pVertexIDs[v6++];
10391 dword_4F5CC4_ys[v6] = v9[v10].y;
10392 }
10393 while ( v6 < v4->uNumVertices );
10394 }
10395 }
10396 else
10397 {
10398 v8 = a3;
10399 if ( v5 & 0x200 )
10400 {
10401 v11 = 0;
10402 v7 = a4->uNumVertices == 0;
10403 a4a = a1;
10404 if ( !v7 )
10405 {
10406 v12 = pIndoor->pVertices;
10407 do
10408 {
10409 dword_4F5D98_xs[v11] = v12[v4->pVertexIDs[v11]].x;
10410 v13 = v4->pVertexIDs[v11++];
10411 dword_4F5CC4_ys[v11] = v12[v13].z;
10412 }
10413 while ( v11 < v4->uNumVertices );
10414 }
10415 }
10416 else
10417 {
10418 v14 = 0;
10419 v7 = a4->uNumVertices == 0;
10420 a4a = a2;
10421 if ( !v7 )
10422 {
10423 v15 = pIndoor->pVertices;
10424 do
10425 {
10426 dword_4F5D98_xs[v14] = v15[v4->pVertexIDs[v14]].y;
10427 v16 = v4->pVertexIDs[v14++];
10428 dword_4F5CC4_ys[v14] = v15[v16].z;
10429 }
10430 while ( v14 < v4->uNumVertices );
10431 }
10432 }
10433 }
10434 v17 = v4->uNumVertices;
10435 a3a = 0;
10436 dword_4F5D98_xs[v17] = dword_4F5D98_xs[0];
10437 dword_4F5CC4_ys[v17 + 1] = dword_4F5CC4_ys[1];
10438 v28 = v17;
10439 v18 = dword_4F5CC4_ys[1] >= v8;
10440 v19 = 0;
10441 v29 = 0;
10442 if ( v17 <= 0 )
10443 goto LABEL_29;
10444 do
10445 {
10446 if ( a3a >= 2 )
10447 break;
10448 v20 = v19;
10449 v21 = dword_4F5CC4_ys[v20 + 2];
10450 if ( v18 ^ v21 >= v8 )
10451 {
10452 v22 = dword_4F5D98_xs[v20 + 1];
10453 if ( v22 >= a4a )
10454 v23 = 0;
10455 else
10456 v23 = 2;
10457 v24 = v23 | dword_4F5D98_xs[v20] < a4a;
10458 if ( v24 != 3 )
10459 {
10460 if ( !v24
10461 || (v25 = v22 - dword_4F5D98_xs[v20],
10462 LODWORD(v26) = v25 << 16,
10463 HIDWORD(v26) = v25 >> 16,
10464 dword_4F5D98_xs[v20]
10465 + ((signed int)(((unsigned __int64)(v26
10466 / (v21 - dword_4F5CC4_ys[v20 + 1])
10467 * ((v8 - dword_4F5CC4_ys[v20 + 1]) << 16)) >> 16)
10468 + 32768) >> 16) >= a4a) )
10469 ++a3a;
10470 }
10471 }
10472 v18 = v21 >= v8;
10473 v19 = v29++ + 1;
10474 }
10475 while ( v29 < v28 );
10476 result = 1;
10477 if ( a3a != 1 )
10478 LABEL_29:
10479 result = 0;
10480 return result;
10481 }
10482
10483 //----- (004077F1) --------------------------------------------------------
10484 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *a4, BSPVertexBuffer *a5)
10485 {
10486 ODMFace *v5; // eax@1
10487 unsigned int v6; // esi@1
10488 signed int v7; // edi@1
10489 char v8; // zf@2
10490 unsigned __int16 *v9; // edx@3
10491 int v10; // ecx@4
10492 unsigned __int16 *v11; // edx@8
10493 int v12; // ecx@9
10494 int v13; // edx@12
10495 int v14; // ecx@13
10496 int v15; // esi@14
10497 bool v16; // edi@14
10498 int v17; // ecx@16
10499 int v18; // edx@16
10500 int v19; // eax@17
10501 signed int v20; // ebx@18
10502 int v21; // edi@20
10503 signed int v22; // eax@22
10504 signed __int64 v23; // qtt@22
10505 bool result; // eax@25
10506 int v25; // [sp+14h] [bp-8h]@14
10507 int a4a; // [sp+28h] [bp+Ch]@2
10508 signed int a5a; // [sp+2Ch] [bp+10h]@14
10509
10510 v5 = a4;
10511 v6 = a4->uAttributes;
10512 v7 = 0;
10513 if ( v6 & 0x100 )
10514 {
10515 v8 = a4->uNumVertices == 0;
10516 a4a = a1;
10517 a3 = a2;
10518 if ( !v8 )
10519 {
10520 v9 = v5->pVertexIDs;
10521 do
10522 {
10523 ++v7;
10524 dword_4F5BF4_xs[v7] = a5->pVertices[*v9].x;
10525 v10 = *v9;
10526 ++v9;
10527 dword_4F5B24_ys[v7] = a5->pVertices[v10].y;
10528 }
10529 while ( v7 < v5->uNumVertices );
10530 }
10531 }
10532 else
10533 {
10534 if ( v6 & 0x200 )
10535 {
10536 v8 = a4->uNumVertices == 0;
10537 a4a = a1;
10538 if ( !v8 )
10539 {
10540 v11 = v5->pVertexIDs;
10541 do
10542 {
10543 ++v7;
10544 dword_4F5BF4_xs[v7] = a5->pVertices[*v11].x;
10545 v12 = *v11;
10546 ++v11;
10547 dword_4F5B24_ys[v7] = a5->pVertices[v12].z;
10548 }
10549 while ( v7 < v5->uNumVertices );
10550 }
10551 }
10552 else
10553 {
10554 v8 = a4->uNumVertices == 0;
10555 a4a = a2;
10556 if ( !v8 )
10557 {
10558 v13 = (int)v5->pVertexIDs;
10559 do
10560 {
10561 ++v7;
10562 dword_4F5BF4_xs[v7] = a5->pVertices[*(short *)v13].y;
10563 v14 = *(short *)v13;
10564 v13 += 2;
10565 dword_4F5B24_ys[v7] = a5->pVertices[v14].z;
10566 }
10567 while ( v7 < v5->uNumVertices );
10568 }
10569 }
10570 }
10571 v15 = v5->uNumVertices;
10572 a5a = 0;
10573 dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1];
10574 dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1];
10575 v25 = 0;
10576 v16 = dword_4F5B24_ys[1] >= a3;
10577 if ( v15 <= 0 )
10578 goto LABEL_29;
10579 do
10580 {
10581 if ( a5a >= 2 )
10582 break;
10583 v17 = v25;
10584 v18 = dword_4F5B24_ys[v25 + 2];
10585 if ( v16 ^ v18 >= a3 )
10586 {
10587 v19 = dword_4F5BF4_xs[v17 + 2];
10588 if ( v19 >= a4a )
10589 v20 = 0;
10590 else
10591 v20 = 2;
10592 v21 = v20 | dword_4F5BF4_xs[v17 + 1] < a4a;
10593 if ( v21 != 3 )
10594 {
10595 if ( !v21
10596 || (v22 = v19 - dword_4F5BF4_xs[v17 + 1],
10597 LODWORD(v23) = v22 << 16,
10598 HIDWORD(v23) = v22 >> 16,
10599 dword_4F5BF4_xs[v17 + 1]
10600 + ((signed int)(((unsigned __int64)(v23
10601 / (v18 - dword_4F5B24_ys[v17 + 1])
10602 * ((a3 - dword_4F5B24_ys[v17 + 1]) << 16)) >> 16)
10603 + 32768) >> 16) >= a4a) )
10604 ++a5a;
10605 }
10606 }
10607 ++v25;
10608 v16 = v18 >= a3;
10609 }
10610 while ( v25 < v15 );
10611 result = 1;
10612 if ( a5a != 1 )
10613 LABEL_29:
10614 result = 0;
10615 return result;
10616 }
10617
10618 //----- (00407A1C) --------------------------------------------------------
10619 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
10620 {
10621 unsigned int v4; // esi@1
10622 Vec3_int_ v5; // ST08_12@2
10623 int v6; // edi@2
10624 int v7; // ebx@2
10625 int v8; // esi@2
10626 signed int v9; // ecx@2
10627 int v10; // eax@2
10628 int v11; // ecx@4
10629 int v12; // eax@4
10630 int v13; // ebx@4
10631 int v14; // edx@6
10632 char *v15; // edi@16
10633 ODMFace *v16; // esi@19
10634 int v17; // ST34_4@25
10635 int v18; // ST38_4@25
10636 int v19; // eax@25
10637 char v20; // zf@25
10638 int v21; // ebx@25
10639 int v22; // eax@26
10640 signed int v23; // edi@26
10641 int v24; // ST34_4@30
10642 signed __int64 v25; // qtt@31
10643 int v26; // eax@31
10644 Vec3_int_ v27; // ST08_12@37
10645 Vec3_int_ v28; // ST08_12@37
10646 int v29; // edi@37
10647 int v30; // ebx@37
10648 int v31; // esi@37
10649 signed int v32; // ecx@37
10650 int v33; // eax@37
10651 int v34; // ecx@39
10652 int v35; // eax@39
10653 int v36; // ebx@39
10654 int v37; // edx@41
10655 char *v38; // edi@51
10656 ODMFace *v39; // esi@54
10657 int v40; // ebx@60
10658 int v41; // eax@61
10659 signed int v42; // edi@61
10660 signed __int64 v43; // qtt@66
10661 int v44; // eax@66
10662 Vec3_int_ v45; // ST08_12@73
10663 int v46; // edi@73
10664 int v47; // ebx@73
10665 int v48; // esi@73
10666 signed int v49; // ecx@73
10667 int v50; // eax@73
10668 int v51; // edx@75
10669 int v52; // ecx@75
10670 int v53; // eax@75
10671 int v54; // ebx@75
10672 int v55; // edi@77
10673 int v56; // ecx@77
10674 int v57; // eax@81
10675 int v58; // esi@81
10676 int v59; // eax@90
10677 BLVSector *v60; // edx@90
10678 int v61; // ecx@90
10679 BLVFace *v62; // esi@91
10680 int v63; // ST34_4@98
10681 int v64; // ST30_4@98
10682 int v65; // eax@98
10683 int v66; // ebx@98
10684 int v67; // eax@99
10685 signed int v68; // edi@99
10686 int v69; // ST2C_4@103
10687 signed __int64 v70; // qtt@104
10688 int v71; // eax@104
10689 Vec3_int_ v72; // ST08_12@111
10690 Vec3_int_ v73; // ST08_12@111
10691 int v74; // edi@111
10692 int v75; // ebx@111
10693 int v76; // esi@111
10694 signed int v77; // ecx@111
10695 int v78; // eax@111
10696 int v79; // edx@113
10697 int v80; // ecx@113
10698 int v81; // eax@113
10699 int v82; // ebx@113
10700 int v83; // edi@115
10701 int v84; // ecx@115
10702 int v85; // eax@119
10703 int v86; // esi@119
10704 int v87; // ecx@128
10705 BLVSector *v88; // eax@128
10706 int v89; // ecx@128
10707 BLVFace *v90; // esi@129
10708 int v91; // ebx@136
10709 int v92; // eax@137
10710 signed int v93; // edi@137
10711 signed __int64 v94; // qtt@142
10712 int v95; // eax@142
10713 Vec3_int_ v97; // [sp-18h] [bp-94h]@1
10714 int v98; // [sp-Ch] [bp-88h]@88
10715 int v99; // [sp-Ch] [bp-88h]@126
10716 int v100; // [sp-8h] [bp-84h]@88
10717 int v101; // [sp-8h] [bp-84h]@126
10718 int v102; // [sp-4h] [bp-80h]@88
10719 int v103; // [sp-4h] [bp-80h]@126
10720 int v104; // [sp+Ch] [bp-70h]@13
10721 int v105; // [sp+Ch] [bp-70h]@48
10722 int v106; // [sp+10h] [bp-6Ch]@18
10723 int v107; // [sp+10h] [bp-6Ch]@98
10724 int v108; // [sp+10h] [bp-6Ch]@104
10725 int v109; // [sp+18h] [bp-64h]@25
10726 int v110; // [sp+18h] [bp-64h]@31
10727 int i; // [sp+18h] [bp-64h]@90
10728 int v112; // [sp+18h] [bp-64h]@128
10729 signed int v113; // [sp+20h] [bp-5Ch]@1
10730 signed int v114; // [sp+24h] [bp-58h]@1
10731 unsigned __int64 a4; // [sp+28h] [bp-54h]@1
10732 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
10733 int v117; // [sp+34h] [bp-48h]@4
10734 int v118; // [sp+34h] [bp-48h]@39
10735 int v119; // [sp+34h] [bp-48h]@75
10736 int v120; // [sp+34h] [bp-48h]@113
10737 int v121; // [sp+38h] [bp-44h]@4
10738 int v122; // [sp+38h] [bp-44h]@39
10739 int v123; // [sp+38h] [bp-44h]@76
10740 int v124; // [sp+38h] [bp-44h]@114
10741 int v125; // [sp+3Ch] [bp-40h]@4
10742 int v126; // [sp+3Ch] [bp-40h]@39
10743 int v127; // [sp+3Ch] [bp-40h]@77
10744 int v128; // [sp+3Ch] [bp-40h]@115
10745 int v129; // [sp+40h] [bp-3Ch]@11
10746 int v130; // [sp+40h] [bp-3Ch]@46
10747 int v131; // [sp+40h] [bp-3Ch]@78
10748 int v132; // [sp+40h] [bp-3Ch]@116
10749 int v133; // [sp+44h] [bp-38h]@10
10750 int v134; // [sp+44h] [bp-38h]@45
10751 int v135; // [sp+44h] [bp-38h]@81
10752 int v136; // [sp+44h] [bp-38h]@119
10753 int v137; // [sp+48h] [bp-34h]@7
10754 int v138; // [sp+48h] [bp-34h]@42
10755 int v139; // [sp+48h] [bp-34h]@82
10756 int v140; // [sp+48h] [bp-34h]@120
10757 int v141; // [sp+4Ch] [bp-30h]@6
10758 int v142; // [sp+4Ch] [bp-30h]@41
10759 int v143; // [sp+4Ch] [bp-30h]@75
10760 int v144; // [sp+4Ch] [bp-30h]@113
10761 int v145; // [sp+50h] [bp-2Ch]@5
10762 int v146; // [sp+50h] [bp-2Ch]@40
10763 int v147; // [sp+50h] [bp-2Ch]@75
10764 int v148; // [sp+50h] [bp-2Ch]@113
10765 int v149; // [sp+54h] [bp-28h]@4
10766 int v150; // [sp+54h] [bp-28h]@39
10767 int v151; // [sp+54h] [bp-28h]@75
10768 int v152; // [sp+54h] [bp-28h]@113
10769 int sDepth; // [sp+58h] [bp-24h]@17
10770 int sDeptha; // [sp+58h] [bp-24h]@52
10771 int sDepthb; // [sp+58h] [bp-24h]@90
10772 char *a5; // [sp+5Ch] [bp-20h]@16
10773 char *a5a; // [sp+5Ch] [bp-20h]@51
10774 signed int a5b; // [sp+5Ch] [bp-20h]@83
10775 signed int a5c; // [sp+5Ch] [bp-20h]@121
10776 signed int v160; // [sp+60h] [bp-1Ch]@12
10777 signed int v161; // [sp+60h] [bp-1Ch]@47
10778 int v162; // [sp+60h] [bp-1Ch]@128
10779 int v163; // [sp+64h] [bp-18h]@2
10780 int outx; // [sp+68h] [bp-14h]@2
10781 int outy; // [sp+6Ch] [bp-10h]@2
10782 int outz; // [sp+70h] [bp-Ch]@2
10783 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2
10784 int ya; // [sp+84h] [bp+8h]@60
10785 int yb; // [sp+84h] [bp+8h]@136
10786 int ve; // [sp+88h] [bp+Ch]@60
10787 int va; // [sp+88h] [bp+Ch]@60
10788 int vb; // [sp+88h] [bp+Ch]@66
10789 int vf; // [sp+88h] [bp+Ch]@136
10790 int vc; // [sp+88h] [bp+Ch]@136
10791 int vd; // [sp+88h] [bp+Ch]@142
10792 int v_4; // [sp+8Ch] [bp+10h]@60
10793 int v_4a; // [sp+8Ch] [bp+10h]@65
10794 int v_4b; // [sp+8Ch] [bp+10h]@136
10795 int v_4c; // [sp+8Ch] [bp+10h]@141
10796 int v_8; // [sp+90h] [bp+14h]@53
10797
10798 a4 = __PAIR__(z, x);
10799 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
10800 v114 = 0;
10801 v97.z = y;
10802 v113 = 0;
10803 a4_8 = v4;
10804 *(_QWORD *)&v97.x = a4;
10805 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
10806 {
10807 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
10808 v45.z = v.z;
10809 *(_QWORD *)&v45.x = *(_QWORD *)&v;
10810 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163);
10811 v46 = outy - pOut.y;
10812 v47 = v163 - outz;
10813 v48 = outx - pOut.x;
10814 v49 = sub_452A9E(v48 * v48 + v46 * v46 + v47 * v47);
10815 v50 = 65536;
10816 if ( v49 )
10817 v50 = 65536 / v49;
10818 v51 = outx;
10819 v143 = v48 * v50;
10820 v52 = v46 * v50;
10821 v53 = v47 * v50;
10822 v54 = pOut.x;
10823 v147 = v52;
10824 v151 = v53;
10825 v119 = pOut.x;
10826 if ( pOut.x < outx )
10827 {
10828 v123 = outx;
10829 }
10830 else
10831 {
10832 v119 = outx;
10833 v123 = pOut.x;
10834 }
10835 v55 = pOut.y;
10836 v56 = outy;
10837 v127 = pOut.y;
10838 if ( pOut.y < outy )
10839 {
10840 v131 = outy;
10841 }
10842 else
10843 {
10844 v127 = outy;
10845 v131 = pOut.y;
10846 }
10847 v57 = v163;
10848 v58 = outz;
10849 v135 = outz;
10850 if ( outz < v163 )
10851 {
10852 v139 = v163;
10853 }
10854 else
10855 {
10856 v135 = v163;
10857 v139 = outz;
10858 }
10859 a5b = 0;
10860 while ( !v114 )
10861 {
10862 if ( a5b )
10863 {
10864 v102 = v58;
10865 v100 = v55;
10866 v98 = v54;
10867 }
10868 else
10869 {
10870 v102 = v57;
10871 v100 = v56;
10872 v98 = v51;
10873 }
10874 v59 = pIndoor->GetSector(v98, v100, v102);
10875 v60 = pIndoor->pSectors;
10876 v61 = 116 * v59;
10877 sDepthb = 0;
10878 for ( i = 116 * v59;
10879 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
10880 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
10881 ++sDepthb )
10882 {
10883 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
10884 if ( v62->uAttributes & 1
10885 || v119 > v62->pBounding.x2
10886 || v123 < v62->pBounding.x1
10887 || v127 > v62->pBounding.y2
10888 || v131 < v62->pBounding.y1
10889 || v135 > v62->pBounding.z2
10890 || v139 < v62->pBounding.z1
10891 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16,
10892 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16,
10893 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16,
10894 v20 = v63 + v64 + v65 == 0,
10895 v66 = v63 + v64 + v65,
10896 v107 = v63 + v64 + v65,
10897 v20) )
10898 goto LABEL_107;
10899 v67 = outz * v62->pFacePlane_old.vNormal.z;
10900 v68 = -(v62->pFacePlane_old.dist
10901 + v67
10902 + pOut.y * v62->pFacePlane_old.vNormal.y
10903 + pOut.x * v62->pFacePlane_old.vNormal.x);
10904 if ( v66 <= 0 )
10905 {
10906 if ( v62->pFacePlane_old.dist
10907 + v67
10908 + pOut.y * v62->pFacePlane_old.vNormal.y
10909 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 )
10910 goto LABEL_107;
10911 }
10912 else
10913 {
10914 if ( v62->pFacePlane_old.dist
10915 + v67
10916 + pOut.y * v62->pFacePlane_old.vNormal.y
10917 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 )
10918 goto LABEL_107;
10919 }
10920 v69 = abs(-(v62->pFacePlane_old.dist
10921 + v67
10922 + pOut.y * v62->pFacePlane_old.vNormal.y
10923 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14;
10924 if ( v69 <= abs(v66) )
10925 {
10926 LODWORD(v70) = v68 << 16;
10927 HIDWORD(v70) = v68 >> 16;
10928 v71 = v70 / v107;
10929 v108 = v70 / v107;
10930 if ( v71 >= 0 )
10931 {
10932 if ( sub_4075DB(
10933 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16),
10934 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16),
10935 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16),
10936 v62) )
10937 {
10938 v114 = 1;
10939 break;
10940 }
10941 }
10942 }
10943 v61 = i;
10944 LABEL_107:
10945 v60 = pIndoor->pSectors;
10946 }
10947 ++a5b;
10948 if ( a5b >= 2 )
10949 break;
10950 v57 = v163;
10951 v56 = outy;
10952 v51 = outx;
10953 v58 = outz;
10954 v55 = pOut.y;
10955 v54 = pOut.x;
10956 }
10957 v72.z = y;
10958 *(_QWORD *)&v72.x = a4;
10959 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
10960 v73.z = v.z;
10961 *(_QWORD *)&v73.x = *(_QWORD *)&v;
10962 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
10963 v74 = outy - pOut.y;
10964 v75 = v163 - outz;
10965 v76 = outx - pOut.x;
10966 v77 = sub_452A9E(v76 * v76 + v74 * v74 + v75 * v75);
10967 v78 = 65536;
10968 if ( v77 )
10969 v78 = 65536 / v77;
10970 v79 = outx;
10971 v144 = v76 * v78;
10972 v80 = v74 * v78;
10973 v81 = v75 * v78;
10974 v82 = pOut.x;
10975 v148 = v80;
10976 v152 = v81;
10977 v120 = pOut.x;
10978 if ( pOut.x < outx )
10979 {
10980 v124 = outx;
10981 }
10982 else
10983 {
10984 v120 = outx;
10985 v124 = pOut.x;
10986 }
10987 v83 = pOut.y;
10988 v84 = outy;
10989 v128 = pOut.y;
10990 if ( pOut.y < outy )
10991 {
10992 v132 = outy;
10993 }
10994 else
10995 {
10996 v128 = outy;
10997 v132 = pOut.y;
10998 }
10999 v85 = v163;
11000 v86 = outz;
11001 v136 = outz;
11002 if ( outz < v163 )
11003 {
11004 v140 = v163;
11005 }
11006 else
11007 {
11008 v136 = v163;
11009 v140 = outz;
11010 }
11011 a5c = 0;
11012 while ( 1 )
11013 {
11014 if ( v113 )
11015 return !v114 || !v113;
11016 if ( a5c )
11017 {
11018 v103 = v86;
11019 v101 = v83;
11020 v99 = v82;
11021 }
11022 else
11023 {
11024 v103 = v85;
11025 v101 = v84;
11026 v99 = v79;
11027 }
11028 v87 = pIndoor->GetSector(v99, v101, v103);
11029 v88 = pIndoor->pSectors;
11030 v89 = 116 * v87;
11031 v162 = 0;
11032 v112 = v89;
11033 if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
11034 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
11035 break;
11036 LABEL_148:
11037 ++a5c;
11038 if ( a5c >= 2 )
11039 return !v114 || !v113;
11040 v85 = v163;
11041 v84 = outy;
11042 v79 = outx;
11043 v86 = outz;
11044 v83 = pOut.y;
11045 v82 = pOut.x;
11046 }
11047 while ( 1 )
11048 {
11049 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
11050 if ( v90->uAttributes & 1
11051 || v120 > v90->pBounding.x2
11052 || v124 < v90->pBounding.x1
11053 || v128 > v90->pBounding.y2
11054 || v132 < v90->pBounding.y1
11055 || v136 > v90->pBounding.z2
11056 || v140 < v90->pBounding.z1
11057 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16,
11058 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16,
11059 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16,
11060 v20 = yb + vf + v_4b == 0,
11061 v91 = yb + vf + v_4b,
11062 vc = yb + vf + v_4b,
11063 v20) )
11064 goto LABEL_145;
11065 v92 = outz * v90->pFacePlane_old.vNormal.z;
11066 v93 = -(v90->pFacePlane_old.dist
11067 + v92
11068 + pOut.y * v90->pFacePlane_old.vNormal.y
11069 + pOut.x * v90->pFacePlane_old.vNormal.x);
11070 if ( v91 <= 0 )
11071 {
11072 if ( v90->pFacePlane_old.dist
11073 + v92
11074 + pOut.y * v90->pFacePlane_old.vNormal.y
11075 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 )
11076 goto LABEL_145;
11077 }
11078 else
11079 {
11080 if ( v90->pFacePlane_old.dist
11081 + v92
11082 + pOut.y * v90->pFacePlane_old.vNormal.y
11083 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 )
11084 goto LABEL_145;
11085 }
11086 v_4c = abs(-(v90->pFacePlane_old.dist
11087 + v92
11088 + pOut.y * v90->pFacePlane_old.vNormal.y
11089 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14;
11090 if ( v_4c <= abs(v91) )
11091 {
11092 LODWORD(v94) = v93 << 16;
11093 HIDWORD(v94) = v93 >> 16;
11094 v95 = v94 / vc;
11095 vd = v94 / vc;
11096 if ( v95 >= 0 )
11097 {
11098 if ( sub_4075DB(
11099 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16),
11100 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16),
11101 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16),
11102 v90) )
11103 {
11104 v113 = 1;
11105 goto LABEL_148;
11106 }
11107 }
11108 }
11109 v89 = v112;
11110 LABEL_145:
11111 v88 = pIndoor->pSectors;
11112 ++v162;
11113 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
11114 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
11115 goto LABEL_148;
11116 }
11117 }
11118 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
11119 v5.z = v.z;
11120 *(_QWORD *)&v5.x = *(_QWORD *)&v;
11121 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163);
11122 v6 = outy - pOut.y;
11123 v7 = v163 - outz;
11124 v8 = outx - pOut.x;
11125 v9 = sub_452A9E(v8 * v8 + v6 * v6 + v7 * v7);
11126 v10 = 65536;
11127 if ( v9 )
11128 v10 = 65536 / v9;
11129 v125 = v8 * v10;
11130 v11 = v10;
11131 v12 = v7 * v10;
11132 v13 = pOut.x;
11133 v117 = v12;
11134 v121 = v6 * v11;
11135 v149 = pOut.x;
11136 if ( pOut.x < outx )
11137 {
11138 v145 = outx;
11139 }
11140 else
11141 {
11142 v149 = outx;
11143 v145 = pOut.x;
11144 }
11145 v14 = outy;
11146 v141 = pOut.y;
11147 if ( pOut.y < outy )
11148 {
11149 v137 = outy;
11150 }
11151 else
11152 {
11153 v141 = outy;
11154 v137 = pOut.y;
11155 }
11156 v133 = outz;
11157 if ( outz < v163 )
11158 {
11159 v129 = v163;
11160 }
11161 else
11162 {
11163 v133 = v163;
11164 v129 = outz;
11165 }
11166 v160 = 0;
11167 if ( (signed int)pOutdoor->uNumBModels > 0 )
11168 {
11169 v104 = 0;
11170 while ( 1 )
11171 {
11172 v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
11173 a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
11174 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
11175 {
11176 sDepth = 0;
11177 if ( *((int *)v15 + 2) > 0 )
11178 break;
11179 }
11180 LABEL_36:
11181 ++v160;
11182 ++v104;
11183 if ( v160 >= (signed int)pOutdoor->uNumBModels )
11184 goto LABEL_37;
11185 v14 = outy;
11186 v13 = pOut.x;
11187 }
11188 v106 = 0;
11189 while ( 1 )
11190 {
11191 v16 = (ODMFace *)(v106 + *((int *)a5 + 4));
11192 if ( v149 > v16->pBoundingBox.x2
11193 || v145 < v16->pBoundingBox.x1
11194 || v141 > v16->pBoundingBox.y2
11195 || v137 < v16->pBoundingBox.y1
11196 || v133 > v16->pBoundingBox.z2
11197 || v129 < v16->pBoundingBox.z1
11198 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16,
11199 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16,
11200 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16,
11201 v20 = v17 + v18 + v19 == 0,
11202 v21 = v17 + v18 + v19,
11203 v109 = v17 + v18 + v19,
11204 v20) )
11205 goto LABEL_33;
11206 v22 = pOut.y * v16->pFacePlane.vNormal.y;
11207 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x);
11208 if ( v21 <= 0 )
11209 {
11210 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 )
11211 goto LABEL_33;
11212 }
11213 else
11214 {
11215 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 )
11216 goto LABEL_33;
11217 }
11218 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14;
11219 if ( v24 <= abs(v21) )
11220 {
11221 LODWORD(v25) = v23 << 16;
11222 HIDWORD(v25) = v23 >> 16;
11223 v26 = v25 / v109;
11224 v110 = v25 / v109;
11225 if ( v26 >= 0 )
11226 {
11227 if ( sub_4077F1(
11228 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16),
11229 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16),
11230 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16),
11231 v16,
11232 (BSPVertexBuffer *)a5) )
11233 {
11234 v114 = 1;
11235 goto LABEL_36;
11236 }
11237 }
11238 }
11239 LABEL_33:
11240 ++sDepth;
11241 v106 += 308;
11242 if ( sDepth >= *((int *)a5 + 2) )
11243 goto LABEL_36;
11244 }
11245 }
11246 LABEL_37:
11247 v27.z = y;
11248 *(_QWORD *)&v27.x = a4;
11249 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
11250 v28.z = v.z;
11251 *(_QWORD *)&v28.x = *(_QWORD *)&v;
11252 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
11253 v29 = outy - pOut.y;
11254 v30 = v163 - outz;
11255 v31 = outx - pOut.x;
11256 v32 = sub_452A9E(v31 * v31 + v29 * v29 + v30 * v30);
11257 v33 = 65536;
11258 if ( v32 )
11259 v33 = 65536 / v32;
11260 v126 = v31 * v33;
11261 v34 = v33;
11262 v35 = v30 * v33;
11263 v36 = pOut.x;
11264 v118 = v35;
11265 v122 = v29 * v34;
11266 v150 = pOut.x;
11267 if ( pOut.x < outx )
11268 {
11269 v146 = outx;
11270 }
11271 else
11272 {
11273 v150 = outx;
11274 v146 = pOut.x;
11275 }
11276 v37 = outy;
11277 v142 = pOut.y;
11278 if ( pOut.y < outy )
11279 {
11280 v138 = outy;
11281 }
11282 else
11283 {
11284 v142 = outy;
11285 v138 = pOut.y;
11286 }
11287 v134 = outz;
11288 if ( outz < v163 )
11289 {
11290 v130 = v163;
11291 }
11292 else
11293 {
11294 v134 = v163;
11295 v130 = outz;
11296 }
11297 v161 = 0;
11298 if ( (signed int)pOutdoor->uNumBModels > 0 )
11299 {
11300 v105 = 0;
11301 while ( 1 )
11302 {
11303 v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
11304 a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
11305 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
11306 {
11307 sDeptha = 0;
11308 if ( *((int *)v38 + 2) > 0 )
11309 break;
11310 }
11311 LABEL_71:
11312 ++v161;
11313 ++v105;
11314 if ( v161 >= (signed int)pOutdoor->uNumBModels )
11315 return !v114 || !v113;
11316 v37 = outy;
11317 v36 = pOut.x;
11318 }
11319 v_8 = 0;
11320 while ( 1 )
11321 {
11322 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4));
11323 if ( v150 > v39->pBoundingBox.x2
11324 || v146 < v39->pBoundingBox.x1
11325 || v142 > v39->pBoundingBox.y2
11326 || v138 < v39->pBoundingBox.y1
11327 || v134 > v39->pBoundingBox.z2
11328 || v130 < v39->pBoundingBox.z1
11329 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16,
11330 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16,
11331 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16,
11332 v20 = ya + ve + v_4 == 0,
11333 v40 = ya + ve + v_4,
11334 va = ya + ve + v_4,
11335 v20) )
11336 goto LABEL_68;
11337 v41 = pOut.y * v39->pFacePlane.vNormal.y;
11338 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x);
11339 if ( v40 <= 0 )
11340 {
11341 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 )
11342 goto LABEL_68;
11343 }
11344 else
11345 {
11346 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 )
11347 goto LABEL_68;
11348 }
11349 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14;
11350 if ( v_4a <= abs(v40) )
11351 {
11352 LODWORD(v43) = v42 << 16;
11353 HIDWORD(v43) = v42 >> 16;
11354 v44 = v43 / va;
11355 vb = v43 / va;
11356 if ( v44 >= 0 )
11357 {
11358 if ( sub_4077F1(
11359 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16),
11360 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16),
11361 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16),
11362 v39,
11363 (BSPVertexBuffer *)a5a) )
11364 {
11365 v113 = 1;
11366 goto LABEL_71;
11367 }
11368 }
11369 }
11370 LABEL_68:
11371 ++sDeptha;
11372 v_8 += 308;
11373 if ( sDeptha >= *((int *)a5a + 2) )
11374 goto LABEL_71;
11375 }
11376 }
11377 return !v114 || !v113;
11378 }
11379
11380
11381 //----- (00408768) --------------------------------------------------------
11382 void InitializeActors()
11383 {
11384 signed int v5; // [sp+Ch] [bp-10h]@1
11385 signed int v6; // [sp+10h] [bp-Ch]@1
11386 signed int v7; // [sp+14h] [bp-8h]@1
11387 signed int v8; // [sp+18h] [bp-4h]@1
11388
11389 v8 = 0;
11390 v6 = 0;
11391 v7 = 0;
11392 v5 = 0;
11393 if ( !_strcmpi(pCurrentMapName, "d25.blv") )
11394 v8 = 1;
11395 if ( !_strcmpi(pCurrentMapName, "d26.blv") )
11396 v6 = 1;
11397 if (_449B57_test_bit(pParty->_award_bits, 99))
11398 v7 = 1;
11399 if (_449B57_test_bit(pParty->_award_bits, 100))
11400 v5 = 1;
11401 for (uint i = 0; i < uNumActors; ++i)
11402 {
11403 auto actor = pActors + i;
11404
11405 if (actor->CanAct() || actor->uAIState == Disabled)
11406 {
11407 actor->vPosition.x = actor->vInitialPosition.x;
11408 actor->vPosition.y = actor->vInitialPosition.y;
11409 actor->vPosition.z = actor->vInitialPosition.z;
11410 actor->sCurrentHP = actor->pMonsterInfo.uHP;
11411 if (actor->uAIState != Disabled)
11412 Actor::_403EB6(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0);
11413 }
11414
11415 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
11416
11417 if (!v8 || v7)
11418 if (!v6 || v5)
11419 if (actor->_438B9B())
11420 BYTE2(actor->uAttributes) &= 0xF7u;
11421
11422 BYTE2(actor->uAttributes) &= 0x7Fu;
11423 if (BYTE2(actor->uAttributes) & 0x40)
11424 Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1);
11425 }
11426 }
11427
11428 //----- (00408896) --------------------------------------------------------
11429 void InitializeLayingItems()
11430 {
11431 for (uint i = 0; i < uNumLayingItems; ++i)
11432 {
11433 auto item = pLayingItems + i;
11434
11435 if (item->uItemType &&
11436 (item->uSoundID & 8 || pObjectList->pObjects[item->uItemType].uFlags & 0x10))
11437 LayingItem::_42F933(i);
11438 }
11439
11440 for (uint i = 0; i < 100; ++i)
11441 array_5118E8.pElements[i].field_C_time_left = 0;
11442 }
11443
11444 //----- (004088E9) --------------------------------------------------------
11445 signed int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6)
11446 {
11447 int v6; // esi@1
11448 int v7; // edi@1
11449 int v8; // eax@1
11450 signed int result; // eax@1
11451 int v10; // [sp+Ch] [bp-4h]@1
11452 int v11; // [sp+18h] [bp+8h]@1
11453
11454 v6 = a1;
11455 v10 = a2;
11456 v7 = a3 - a1;
11457 v11 = abs(a3 - a1);
11458 v8 = abs(a4 - v10);
11459 result = sub_452A9E(v11 * v11 + v8 * v8);
11460 if ( result )
11461 result = abs((v7 * (v10 - a6) - (a4 - v10) * (v6 - a5)) / result);
11462 return result;
11463 }
11464
11465
11466 //----- (00408A27) --------------------------------------------------------
11467 unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors)
11468 {
11469 unsigned int *v1; // esi@1
11470 int v2; // eax@1
11471 unsigned int v3; // ebp@1
11472 signed int v4; // ebx@1
11473 Actor *v5; // edi@2
11474 unsigned int v6; // eax@3
11475 int v8; // [sp+Ch] [bp-4h]@1
11476
11477 v1 = pTotalActors;
11478 v2 = GetAlertStatus();
11479 v3 = 0;
11480 v4 = 0;
11481 *v1 = 0;
11482 v8 = v2;
11483 if ( (signed int)uNumActors > 0 )
11484 {
11485 v5 = pActors;
11486 do
11487 {
11488 v6 = v5->uAttributes;
11489 if ( (v6 & 0x100000) == v8 )
11490 {
11491 ++*v1;
11492 if ( v5->IsAlive() == 1 )
11493 ++v3;
11494 }
11495 ++v4;
11496 ++v5;
11497 }
11498 while ( v4 < (signed int)uNumActors );
11499 }
11500 return v3;
11501 }
11502
11503 //----- (00408A7E) --------------------------------------------------------
11504 unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
11505 {
11506 unsigned int *v2; // esi@1
11507 signed int v3; // ebx@1
11508 char *v4; // edi@2
11509 int v5; // eax@3
11510 int v7; // [sp+8h] [bp-Ch]@1
11511 int v8; // [sp+Ch] [bp-8h]@1
11512 unsigned int v9; // [sp+10h] [bp-4h]@1
11513
11514 v7 = uMonsterID;
11515 v2 = pTotalActors;
11516 v3 = 0;
11517 v8 = GetAlertStatus();
11518 *v2 = 0;
11519 v9 = 0;
11520 if ( (signed int)uNumActors > 0 )
11521 {
11522 v4 = (char *)&pActors[0].pMonsterInfo.uID;
11523 do
11524 {
11525 v5 = *((int *)v4 - 15); // actor::attributes
11526 if ( (v5 & 0x100000) == v8 )
11527 {
11528 if ( *(short *)v4 - 1 == v7 )
11529 {
11530 ++*v2;
11531 if ( ((Actor *)(v4 - 96))->IsAlive() == 1 )
11532 ++v9;
11533 }
11534 }
11535 ++v3;
11536 v4 += 836;
11537 }
11538 while ( v3 < (signed int)uNumActors );
11539 }
11540 return v9;
11541 }
11542
11543 //----- (00408AE7) --------------------------------------------------------
11544 unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup)
11545 {
11546 unsigned int *v2; // esi@1
11547 signed int v3; // ebx@1
11548 char *v4; // edi@2
11549 int v5; // eax@3
11550 unsigned int v7; // [sp+8h] [bp-Ch]@1
11551 int v8; // [sp+Ch] [bp-8h]@1
11552 unsigned int v9; // [sp+10h] [bp-4h]@1
11553
11554 v7 = uGroup;
11555 v2 = pTotalActors;
11556 v3 = 0;
11557 v8 = GetAlertStatus();
11558 *v2 = 0;
11559 v9 = 0;
11560 if ( (signed int)uNumActors > 0 )
11561 {
11562 v4 = (char *)&pActors[0].uGroup;
11563 do
11564 {
11565 v5 = *((int *)v4 - 168);
11566 if ( (v5 & 0x100000) == v8 )
11567 {
11568 if ( *(int *)v4 == v7 )
11569 {
11570 ++*v2;
11571 if ( ((Actor *)(v4 - 708))->IsAlive() == 1 )
11572 ++v9;
11573 }
11574 }
11575 ++v3;
11576 v4 += 836;
11577 }
11578 while ( v3 < (signed int)uNumActors );
11579 }
11580 return v9;
11581 }
11582
11583 //----- (00408B54) --------------------------------------------------------
11584 unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
11585 {
11586 unsigned int v2; // edi@1
11587 unsigned int *v3; // esi@1
11588 int v4; // eax@1
11589 unsigned int v5; // ebx@1
11590 unsigned int v6; // edx@1
11591
11592 v2 = a2;
11593 v3 = pTotalActors;
11594 v4 = GetAlertStatus();
11595 v5 = 0;
11596 *v3 = 0;
11597 v6 = pActors[v2].uAttributes;
11598 if ( (v6 & 0x100000) == v4 )
11599 {
11600 *v3 = 1;
11601 if ( pActors[v2].IsAlive() == 1 )
11602 v5 = 1;
11603 }
11604 return v5;
11605 }
11606
11607
11608 //----- (00409BE8) --------------------------------------------------------
11609 void __cdecl sub_409BE8()
11610 {
11611 void *v0; // eax@1
11612 stru348 *v1; // eax@1
11613 int v2; // ecx@1
11614 int v3; // eax@1
11615
11616 v0 = ptr_507BC0->ptr_1C;
11617 dword_4E1874 = 5;
11618 v1 = &stru_4E1890[(int)((char *)v0 - 108)];
11619 amuint_4E1860 = v1->field_4;
11620 amuint_4E1864 = v1->field_6;
11621 amuint_4E1868 = v1->field_8 - 1;
11622 amuint_4E186C = v1->field_A - 1;
11623 amuint_4E1870 = v1->field_C - 1;
11624 amuint_505884 = v1->field_E;
11625 amuint_505888 = v1->field_10;
11626 amuint_50588C = v1->field_12;
11627 dword_4E1878 = 1;
11628 dword_4E187C = 1;
11629 dword_4E1880 = 1;
11630 dword_4E1884 = v1->field_0;
11631 v2 = v1->field_2;
11632 v3 = v1->field_14;
11633 dword_4E1888 = v2;
11634 dword_4DF3A4 = v3;
11635 }
11636 // 4DF3A4: using guessed type int dword_4DF3A4;
11637 // 4E1860: using guessed type int amuint_4E1860;
11638 // 4E1864: using guessed type int amuint_4E1864;
11639 // 4E1868: using guessed type int amuint_4E1868;
11640 // 4E186C: using guessed type int amuint_4E186C;
11641 // 4E1870: using guessed type int amuint_4E1870;
11642 // 4E1874: using guessed type int dword_4E1874;
11643 // 4E1878: using guessed type int dword_4E1878;
11644 // 4E187C: using guessed type int dword_4E187C;
11645 // 4E1880: using guessed type int dword_4E1880;
11646 // 4E1884: using guessed type int dword_4E1884;
11647 // 4E1888: using guessed type int dword_4E1888;
11648 // 505884: using guessed type int amuint_505884;
11649 // 505888: using guessed type int amuint_505888;
11650 // 50588C: using guessed type int amuint_50588C;
11651
11652
11653
11654
11655
11656
11657
11658 //----- (0040D75D) --------------------------------------------------------
11659 char __fastcall pPrimaryWindow_draws_text(int a1, const char *pText, int *pXY)
11660 {
11661 const char *v3; // ST0C_4@1
11662 __int64 v4; // qax@1
11663
11664 v3 = pText;
11665 v4 = LOBYTE(pFontComic->uFontHeight) - 3;
11666 return pPrimaryWindow->DrawText(
11667 pFontComic,
11668 *pXY,
11669 pXY[1] - (((signed int)v4 - HIDWORD(v4)) >> 1) + 3,
11670 0,
11671 v3,
11672 0,
11673 0,
11674 0);
11675 }
11676
11677
11678
11679 //----- (0040DB27) --------------------------------------------------------
11680 void __fastcall DrawRect(Vec4_int_ *pXYZW, unsigned __int16 uColor, char bSolidFill)
11681 {
11682 Vec4_int_ *v3; // esi@1
11683 unsigned __int16 v4; // bp@1
11684 unsigned int i; // ebx@3
11685
11686 v3 = pXYZW;
11687 v4 = uColor;
11688 pRenderer->BeginScene();
11689 pRenderer->Clip_v2(0, 0, 639u, 479u);
11690 if ( bSolidFill )
11691 {
11692 for ( i = v3->y; (signed int)i <= v3->w; ++i )
11693 pRenderer->Line2D(v3->x, i, v3->z, i, v4);
11694 }
11695 else
11696 {
11697 pRenderer->Line2D(v3->x, v3->y, v3->z, v3->y, v4);
11698 pRenderer->Line2D(v3->z, v3->y, v3->z, v3->w, v4);
11699 pRenderer->Line2D(v3->z, v3->w, v3->x, v3->w, v4);
11700 pRenderer->Line2D(v3->x, v3->w, v3->x, v3->y, v4);
11701 }
11702 pRenderer->EndScene();
11703 }
11704
11705
11706
11707
11708 //----- (0040DDB1) --------------------------------------------------------
11709 int __fastcall rand_interval(int a, int b)
11710 {
11711 return a + rand() % (b - a + 1);
11712 }
11713
11714 //----- (0040DEB4) --------------------------------------------------------
11715 char *__fastcall inv_strcat(const char *Source, char *Dest)
11716 {
11717 return strcat(Dest, Source);
11718 }
11719
11720 //----- (0040DEBE) --------------------------------------------------------
11721 char *__fastcall inv_strcpy(const char *Source, char *Dest)
11722 {
11723 return strcpy(Dest, Source);
11724 }
11725
11726 //----- (0040DEC8) --------------------------------------------------------
11727 void __fastcall intToString(int val, char *pOut)
11728 {
11729 sprintf(pOut, "%d", val);
11730 }
11731
11732 //----- (0040DEDB) --------------------------------------------------------
11733 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
11734 {
11735 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
11736 }
11737
11738 //----- (0040DEF3) --------------------------------------------------------
11739 unsigned int __fastcall GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b)
11740 {
11741 return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
11742 }
11743
11744 //----- (0040DF3D) --------------------------------------------------------
11745 void __cdecl CallRenderPresent()
11746 {
11747 pRenderer->Present();
11748 }
11749
11750
11751 //----- (0040DFA7) --------------------------------------------------------
11752 int __stdcall retzero_sub_40DFA7(int a1)
11753 {
11754 return 0;
11755 }
11756 // 40DFA7: using guessed type int __stdcall retzero_sub_40DFA7(int);
11757
11758 //----- (0040DFD1) --------------------------------------------------------
11759 void stru272::_40DFD1()
11760 {
11761 stru272 *v1; // esi@1
11762 stru272_stru0 *v2; // eax@1
11763
11764 v1 = this;
11765 v2 = (stru272_stru0 *)malloc(0x5Cu);
11766 v1->ptr_0 = v2;
11767 v2->field_0 = 0x67707274u;
11768 v1->ptr_0->field_8 = 0;
11769 v1->ptr_0->field_30 = 0.0;
11770 v1->ptr_0->field_58 = 0;
11771 v1->ptr_0->field_59 = 0;
11772 }
11773
11774 //----- (0040DFFE) --------------------------------------------------------
11775 int stru272_stru0::_40DFFE()
11776 {
11777 signed int result; // eax@2
11778
11779 if ( this->field_0 == 0x67707274 )
11780 {
11781 this->field_0 = 0x78787878u;
11782 free(this);
11783 result = 0;
11784 }
11785 else
11786 {
11787 result = 2;
11788 }
11789 return result;
11790 }
11791
11792 //----- (0040E01A) --------------------------------------------------------
11793 int stru272_stru0::_40E01A(int a2)
11794 {
11795 signed int result; // eax@2
11796
11797 auto a1 = this;
11798 if ( a1->field_0 == 0x67707274 )
11799 {
11800 a1->field_4 = *(int *)(a2 + 32);
11801 a1->field_C = *(int *)a2 << 16;
11802 a1->field_10 = *(int *)(a2 + 4) << 16;
11803 a1->field_14 = *(int *)(a2 + 8) << 16;
11804 a1->field_18 = *(int *)(a2 + 12) << 16;
11805 a1->field_1C = *(int *)(a2 + 16);
11806 a1->field_20 = *(int *)(a2 + 20);
11807 a1->field_24 = *(int *)(a2 + 24);
11808 a1->field_28 = *(float *)(a2 + 28) * 65536.0;
11809 LODWORD(a1->field_2C) = *(int *)(a2 + 36);
11810 a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0);
11811 a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0);
11812 a1->field_3C = *(int *)(a2 + 48);
11813 a1->field_40 = *(int *)(a2 + 52);
11814 a1->field_54 = *(int *)(a2 + 56);
11815 a1->field_59 = 1;
11816 result = 0;
11817 }
11818 else
11819 {
11820 result = 2;
11821 }
11822 return result;
11823 }
11824
11825 //----- (0040E0F5) --------------------------------------------------------
11826 int stru272_stru0::_40E0F5(char a2, char a3)
11827 {
11828 signed int result; // eax@2
11829 int v4; // edx@7
11830 int v5; // eax@7
11831
11832 auto a1 = this;
11833 if ( a1->field_0 == 0x67707274 )
11834 {
11835 if ( a2 )
11836 {
11837 a1->field_8 = 0;
11838 a1->field_30 = 0.0;
11839 }
11840 if ( a1->field_59 && a3 )
11841 {
11842 v4 = a1->field_4;
11843 v5 = a1->field_54;
11844 do
11845 {
11846 *(int *)v5 = 0;
11847 v5 += 28;
11848 --v4;
11849 }
11850 while ( v4 );
11851 a1->field_58 = 0;
11852 }
11853 result = 0;
11854 }
11855 else
11856 {
11857 result = 2;
11858 }
11859 return result;
11860 }
11861
11862 //----- (0040E133) --------------------------------------------------------
11863 int stru272_stru0::_40E133()
11864 {
11865 stru272_stru0 *v1; // edi@1
11866 int v3; // ST18_4@3
11867 double v4; // st7@3
11868 double v5; // st6@4
11869 char v6; // bl@8
11870 int v7; // esi@8
11871 int v8; // ecx@10
11872 signed int v9; // eax@10
11873 int v10; // ecx@10
11874 signed int v11; // eax@10
11875 signed int v12; // edx@12
11876 signed int v13; // edx@12
11877 int v14; // [sp+8h] [bp-10h]@8
11878 int v15; // [sp+Ch] [bp-Ch]@8
11879 float v16; // [sp+14h] [bp-4h]@3
11880
11881 v1 = this;
11882 if ( this->field_0 != 0x67707274 )
11883 return 2;
11884 v3 = this->field_8;
11885 v16 = this->field_30;
11886 v4 = (double)v3;
11887 if ( v3 > 0 )
11888 {
11889 v5 = v16 + this->field_2C;
11890 v16 = v5;
11891 if ( v5 > v4 )
11892 v16 = v4;
11893 }
11894 if ( v16 >= 1.0 || this->field_58 )
11895 {
11896 v6 = 0;
11897 v7 = this->field_54;
11898 v14 = (signed __int64)this->field_28;
11899 v15 = this->field_4;
11900 while ( *(int *)v7 <= 0 )
11901 {
11902 if ( v16 >= 1.0 )
11903 {
11904 *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1);
11905 *(int *)(v7 + 20) = (rand() % 17 - 8) << 16;
11906 *(int *)(v7 + 24) = (rand() % 17 - 8) << 16;
11907 v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1);
11908 *(int *)(v7 + 12) = v12;
11909 *(int *)(v7 + 4) = v12 >> 16;
11910 v16 = v16 - 1.0;
11911 v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1);
11912 *(int *)(v7 + 16) = v13;
11913 *(int *)(v7 + 8) = v13 >> 16;
11914 --v1->field_8;
11915 goto LABEL_13;
11916 }
11917 LABEL_14:
11918 v7 += 28;
11919 --v15;
11920 if ( !v15 )
11921 {
11922 v1->field_58 = v6;
11923 v1->field_30 = v16;
11924 return 0;
11925 }
11926 }
11927 v8 = *(int *)(v7 + 20);
11928 --*(int *)v7;
11929 v9 = v8 + *(int *)(v7 + 12);
11930 v10 = v14 + *(int *)(v7 + 24);
11931 *(int *)(v7 + 12) = v9;
11932 *(int *)(v7 + 4) = v9 >> 16;
11933 v11 = v10 + *(int *)(v7 + 16);
11934 *(int *)(v7 + 24) = v10;
11935 *(int *)(v7 + 16) = v11;
11936 *(int *)(v7 + 8) = v11 >> 16;
11937 LABEL_13:
11938 v6 = 1;
11939 goto LABEL_14;
11940 }
11941 return 0;
11942 }
11943
11944 //----- (0040E2A7) --------------------------------------------------------
11945 int stru272_stru0::_40E2A7()
11946 {
11947 int result; // eax@2
11948
11949 if ( this->field_0 == 0x67707274 )
11950 {
11951 if ( this->field_8 <= 0 )
11952 result = this->field_58 != 0 ? 2 : 0;
11953 else
11954 result = 1;
11955 }
11956 else
11957 {
11958 result = 3;
11959 }
11960 return result;
11961 }
11962
11963
11964
11965
11966
11967
11968
11969 //----- (0040F82D) --------------------------------------------------------
11970 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue)
11971 {
11972 ZBuffer_DoFill(pZBuffer, (Texture *)(uTextureId != -1 ? 72 * uTextureId + 0x6D084C : 0), iZValue);
11973 }
11974
11975 //----- (0040F845) --------------------------------------------------------
11976 __int16 __fastcall sub_40F845(int a1, int a2, int a3, int a4, int a5, __int16 a6, int a7)
11977 {
11978 int v7; // edi@1
11979 int v8; // esi@1
11980 int v9; // ecx@2
11981 int v10; // eax@3
11982
11983 v7 = a1;
11984 v8 = a2;
11985 do
11986 {
11987 v9 = a3;
11988 do
11989 {
11990 v10 = *(char *)v8++;
11991 if ( (char)v10 )
11992 {
11993 if ( (char)v10 == 1 )
11994 {
11995 LOWORD(v10) = *(short *)(a5 + 2 * v10);
11996 *(short *)v7 = v10;
11997 }
11998 else
11999 {
12000 LOWORD(v10) = a6;
12001 *(short *)v7 = a6;
12002 }
12003 }
12004 v7 += 2;
12005 --v9;
12006 }
12007 while ( v9 );
12008 v7 = a7 + v7 - a3 - a3;
12009 --a4;
12010 }
12011 while ( a4 );
12012 return v10;
12013 }
12014
12015 //----- (0040F89C) --------------------------------------------------------
12016 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue)
12017 {
12018 void *v3; // eax@3
12019 void *v4; // esi@5
12020 int *v5; // edi@5
12021 int v6; // eax@5
12022 int v7; // ecx@6
12023 Texture *v8; // [sp+Ch] [bp-14h]@1
12024 int *v9; // [sp+10h] [bp-10h]@1
12025 int v10; // [sp+14h] [bp-Ch]@1
12026 int v11; // [sp+18h] [bp-8h]@1
12027 void *v12; // [sp+1Ch] [bp-4h]@5
12028
12029 v10 = pTex->uTextureWidth;
12030 v8 = pTex;
12031 v9 = pZBuffer;
12032 v11 = pTex->uTextureHeight;
12033 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize )
12034 v3 = pTex->UnzipPalette();
12035 else
12036 v3 = pTex->pLevelOfDetail0;
12037 v12 = v3;
12038 v4 = v3;
12039 v5 = v9;
12040 v6 = 0;
12041 do
12042 {
12043 v7 = v10;
12044 do
12045 {
12046 LOBYTE(v6) = *(char *)v4;
12047 v4 = (char *)v4 + 1;
12048 if ( v6 )
12049 *v5 = uZValue;
12050 ++v5;
12051 --v7;
12052 }
12053 while ( v7 );
12054 v5 += 640 - v10;
12055 --v11;
12056 }
12057 while ( v11 );
12058 if ( pIcons_LOD->dword_011BA4 )
12059 {
12060 if ( v8->uDecompressedSize )
12061 free(v12);
12062 }
12063 }
12064
12065
12066 //----- (0040F92A) --------------------------------------------------------
12067 void __fastcall sub_40F92A(int *pZBuffer, Texture *a2, int a3)
12068 {
12069 Texture *v3; // esi@1
12070 void *v4; // eax@3
12071 int *v5; // edi@5
12072 int v6; // ecx@6
12073 int *v7; // [sp+Ch] [bp-10h]@1
12074 int v8; // [sp+10h] [bp-Ch]@1
12075 int v9; // [sp+18h] [bp-4h]@1
12076
12077 v3 = a2;
12078 v7 = pZBuffer;
12079 v8 = a2->uTextureWidth;
12080 v9 = a2->uTextureHeight;
12081 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize )
12082 v4 = a2->UnzipPalette();
12083 else
12084 v4 = a2->pLevelOfDetail0;
12085 v5 = v7;
12086 do
12087 {
12088 v6 = v8;
12089 do
12090 {
12091 *v5 = a3;
12092 ++v5;
12093 --v6;
12094 }
12095 while ( v6 );
12096 v5 += 640 - v8;
12097 --v9;
12098 }
12099 while ( v9 );
12100 if ( pIcons_LOD->dword_011BA4 )
12101 {
12102 if ( v3->uDecompressedSize )
12103 free(v4);
12104 }
12105 }
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120 //----- (00410AF5) --------------------------------------------------------
12121 void __cdecl SetMoonPhaseNames()
12122 {
12123 aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
12124 aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
12125 aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
12126 aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
12127 aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
12128 }
12129
12130 //----- (00410B28) --------------------------------------------------------
12131 void __thiscall DrawSpellDescriptionPopup(void *_this)
12132 {
12133 Player *v1; // edi@1
12134 SpellInfo *v2; // esi@1
12135 unsigned int v3; // eax@2
12136 int v4; // eax@4
12137 LONG v5; // ecx@4
12138 int v6; // eax@10
12139 char *v7; // ST44_4@12
12140 unsigned __int16 v8; // ax@12
12141 GUIWindow a1; // [sp+Ch] [bp-68h]@4
12142 void *v10; // [sp+60h] [bp-14h]@1
12143 POINT a2; // [sp+64h] [bp-10h]@1
12144 int v12; // [sp+6Ch] [bp-8h]@4
12145 int v13; // [sp+70h] [bp-4h]@4
12146
12147 v1 = pPlayers[uActiveCharacter];
12148 v10 = _this;
12149 v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->pNumSpellBookPage) + 1];
12150 if ( pMouse->GetCursorPos(&a2)->y <= 250 )
12151 v3 = pMouse->GetCursorPos(&a2)->y + 30;
12152 else
12153 v3 = 30;
12154 a1.uFrameY = v3;
12155 a1.uFrameWidth = 328;
12156 a1.uFrameHeight = 68;
12157 a1.uFrameX = 90;
12158 a1.uFrameZ = 417;
12159 a1.uFrameW = v3 + 67;
12160 a1.Hint = 0;
12161 a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);
12162 v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);
12163 v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);
12164 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);
12165 v5 = a2.y;
12166 if ( v13 > a2.y )
12167 v5 = v13;
12168 if ( v12 > v5 )
12169 v5 = v12;
12170 if ( v4 > v5 )
12171 v5 = v4;
12172 sprintf(
12173 pTmpBuf2,
12174 "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s",
12175 v2->pDescription,
12176 pGlobalTXT_LocalizationStrings[431],
12177 v5 + 3,
12178 v5 + 10,
12179 v2->pBasicSkillDesc,
12180 pGlobalTXT_LocalizationStrings[433],
12181 v5 + 3,
12182 v5 + 10,
12183 v2->pExpertSkillDesc,
12184 pGlobalTXT_LocalizationStrings[432],
12185 v5 + 3,
12186 v5 + 10,
12187 v2->pMasterSkillDesc,
12188 pGlobalTXT_LocalizationStrings[96],
12189 v5 + 3,
12190 v5 + 10,
12191 v2->pGrandmasterSkillDesc);
12192 v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0);
12193 a1.uFrameHeight += v6;
12194 if ( (signed int)a1.uFrameHeight < 150 )
12195 a1.uFrameHeight = 150;
12196 a1.uFrameWidth = 460;
12197 a1.DrawMessageBox(0);
12198 a1.uFrameWidth -= 12;
12199 a1.uFrameHeight -= 12;
12200 v7 = v2->pName;
12201 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
12202 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
12203 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
12204 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
12205 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
12206 a1.uFrameWidth = 108;
12207 a1.uFrameZ = a1.uFrameX + 107;
12208 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->pNumSpellBookPage + 12], 3u);
12209 sprintf(
12210 pTmpBuf,
12211 "%s\n%d",
12212 pGlobalTXT_LocalizationStrings[522],
12213 *(&pSpellDatas[0].field_14
12214 + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->pNumSpellBookPage + 12]) >> 6)
12215 + 10 * (int)((char *)v10 + 11 * v1->pNumSpellBookPage)));
12216 a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
12217 dword_507B00_spell_info_to_draw_in_popup = 0;
12218 }
12219 // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup;
12220
12221 //----- (00410D99) --------------------------------------------------------
12222 signed int __fastcall sub_410D99_get_map_index(int a1)
12223 {
12224 int v1; // edi@1
12225 signed int v2; // ebp@1
12226 const char **v3; // esi@2
12227 char *v4; // ebx@2
12228
12229 v1 = a1;
12230 v2 = 1;
12231 if ( _strcmpi(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
12232 {
12233 v3 = (const char **)&pMapStats->pInfos[1].pFilename;
12234 v4 = (char *)&pMapStats->pInfos[1].pFilename;
12235 do
12236 {
12237 if ( !*(int *)v4 )
12238 break;
12239 v3 += 17;
12240 ++v2;
12241 v4 = (char *)v3;
12242 }
12243 while ( _strcmpi(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
12244 }
12245 return v2;
12246 }
12247
12248 //----- (00410DEC) --------------------------------------------------------
12249 unsigned int __cdecl DrawLloydBeaconsScreen()
12250 {
12251 Player *v0; // esi@1
12252 char *v1; // eax@1
12253 unsigned __int16 v2; // ax@6
12254 unsigned int result; // eax@11
12255 unsigned int v4; // esi@13
12256 unsigned int v5; // ecx@13
12257 char v6; // zf@13
12258 LloydBeacon *v7; // esi@14
12259 int v8; // eax@14
12260 unsigned __int64 v9; // kr08_8@14
12261 unsigned int v10; // esi@14
12262 unsigned int v11; // eax@14
12263 char *v12; // eax@19
12264 char *v13; // ecx@22
12265 int v14; // eax@27
12266 unsigned int v15; // [sp-10h] [bp-98h]@25
12267 unsigned __int16 v16; // [sp-Ch] [bp-94h]@25
12268 int v17; // [sp-8h] [bp-90h]@21
12269 char *v18; // [sp-8h] [bp-90h]@25
12270 Texture *v19; // [sp-4h] [bp-8Ch]@4
12271 char *v20; // [sp-4h] [bp-8Ch]@21
12272 unsigned int v21; // [sp-4h] [bp-8Ch]@25
12273 GUIWindow v22; // [sp+Ch] [bp-7Ch]@1
12274 unsigned int v23; // [sp+64h] [bp-24h]@14
12275 __int64 v24; // [sp+68h] [bp-20h]@14
12276 unsigned int v25; // [sp+70h] [bp-18h]@13
12277 char *Str; // [sp+74h] [bp-14h]@14
12278 int v27; // [sp+78h] [bp-10h]@11
12279 LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
12280 RGBTexture *v29; // [sp+80h] [bp-8h]@12
12281 int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
12282
12283 v0 = &pParty->pPlayers[_506348_current_lloyd_playerid];
12284 pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
12285 v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon
12286 v22.uFrameX = 8;
12287 v22.uFrameY = 8;
12288 v22.uFrameWidth = 428;
12289 v22.uFrameHeight = 344;
12290 v22.uFrameZ = 435;
12291 v22.uFrameW = 351;
12292 if ( !bRecallingBeacon )
12293 v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon
12294 sprintf(pTmpBuf, "%s", v1);
12295 v22.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf, 3u);
12296 if ( bRecallingBeacon )
12297 {
12298 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
12299 v19 = pTex_tab_an_6a__zoom_off;
12300 }
12301 else
12302 {
12303 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
12304 v19 = pTex_tab_an_6b__zoom_on;
12305 }
12306 pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
12307 v2 = v0->pActiveSkills[14];
12308 uNumMaxBeacons = 1;
12309 if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
12310 {
12311 uNumMaxBeacons = 5;
12312 }
12313 else
12314 {
12315 if ( v2 & 0x40 )
12316 uNumMaxBeacons = 3;
12317 }
12318 result = 0;
12319 v27 = 0;
12320 if ( uNumMaxBeacons > 0 )
12321 {
12322 v29 = pSavegameThumbnails;
12323 v28 = v0->pInstalledBeacons;
12324 while ( 1 )
12325 {
12326 v22.uFrameWidth = 92;
12327 v4 = result;
12328 v22.uFrameHeight = 68;
12329 v5 = pLloydsBeaconsPreviewXs[result];
12330 v22.uFrameY = pLloydsBeaconsPreviewYs[result];
12331 v25 = v22.uFrameY;
12332 v22.uFrameX = v5;
12333 v22.uFrameW = v22.uFrameY + 67;
12334 v6 = v29->pPixels == 0;
12335 v22.uFrameZ = v5 + 91;
12336 if ( !v6 )
12337 break;
12338 if ( !bRecallingBeacon )
12339 {
12340 pRenderer->DrawTextureTransparent(
12341 pLloydsBeacons_SomeXs[v4],
12342 pLloydsBeacons_SomeYs[v4],
12343 pTexture_CurrentBook);
12344 v21 = 3;
12345 v18 = pGlobalTXT_LocalizationStrings[19];
12346 v16 = 1;
12347 v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &v22, 0, 0);
12348 v15 = (signed int)v22.uFrameHeight / 2 - v14 / 2;
12349 goto LABEL_28;
12350 }
12351 LABEL_29:
12352 ++v29;
12353 ++v28;
12354 result = v27++ + 1;
12355 if ( v27 >= uNumMaxBeacons )
12356 goto LABEL_30;
12357 }
12358 pRenderer->DrawTextureTransparent(
12359 pLloydsBeacons_SomeXs[v4],
12360 pLloydsBeacons_SomeYs[v4],
12361 pTexture_CurrentBook);
12362 pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
12363 v7 = v28;
12364 Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
12365 v8 = pSpellFont->CalcTextHeight(Str, &v22, 0, 0);
12366 v22.uFrameY += -6 - v8;
12367 v22.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
12368 v9 = v7->uBeaconTime - pParty->uTimePlayed;
12369 LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
12370 HIDWORD(v24) = HIDWORD(v9);
12371 v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
12372 v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
12373 v11 = v10 / 0x18;
12374 if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
12375 {
12376 v13 = pGlobalTXT_LocalizationStrings[57]; // Days
12377 if ( v11 > 1 )
12378 {
12379 LABEL_24:
12380 v20 = v13;
12381 v17 = v11 + 1;
12382 LABEL_25:
12383 sprintf(pTmpBuf, "%lu %s", v17, v20);
12384 v21 = 3;
12385 v18 = pTmpBuf;
12386 v16 = 1;
12387 v22.uFrameY = v25 + v22.uFrameHeight + 4;
12388 v15 = 0;
12389 LABEL_28:
12390 v22.DrawTitleText(pSpellFont, 0, v15, v16, v18, v21);
12391 goto LABEL_29;
12392 }
12393 }
12394 else
12395 {
12396 if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
12397 {
12398 if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
12399 v12 = pGlobalTXT_LocalizationStrings[109];// Hour
12400 else
12401 v12 = pGlobalTXT_LocalizationStrings[110];// Hours
12402 v20 = v12;
12403 v17 = v10 + 1;
12404 goto LABEL_25;
12405 }
12406 }
12407 v13 = pGlobalTXT_LocalizationStrings[56]; // Day
12408 goto LABEL_24;
12409 }
12410 LABEL_30:
12411 if ( byte_506360 )
12412 {
12413 result = pMessageQueue_50CBD0->uNumMessages;
12414 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12415 {
12416 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)181;
12417 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
12418 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
12419 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
12420 ++pMessageQueue_50CBD0->uNumMessages;
12421 }
12422 }
12423 return result;
12424 }
12425
12426
12427 //----- (00411150) --------------------------------------------------------
12428 char *__cdecl DrawTownPortalScreen()
12429 {
12430 signed int v0; // edi@1
12431 __int16 v1; // dx@8
12432 POINT *v2; // edi@17
12433 int v3; // edi@17
12434 __int16 v4; // dx@24
12435 GUIWindow v6; // [sp+Ch] [bp-64h]@1
12436 POINT v7; // [sp+60h] [bp-10h]@17
12437 POINT a2; // [sp+68h] [bp-8h]@17
12438
12439 pRenderer->ClearZBuffer(0, 479);
12440 pRenderer->DrawTextureTransparent(8u, 8u, pTexture_CurrentBook);
12441 pRenderer->DrawTextureTransparent(
12442 0x1D7u,
12443 0x1BDu,
12444 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
12445 v6.uFrameX = 8;
12446 v6.uFrameY = 8;
12447 v6.uFrameWidth = 460;
12448 v6.uFrameHeight = 344;
12449 v6.uFrameZ = 467;
12450 v6.uFrameW = 351;
12451 v0 = 0;
12452 do
12453 {
12454 if ( !v0 )
12455 {
12456 v1 = 206;
12457 LABEL_14:
12458 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v1) )
12459 goto LABEL_16;
12460 goto LABEL_15;
12461 }
12462 if ( v0 == 1 )
12463 {
12464 v1 = 208;
12465 goto LABEL_14;
12466 }
12467 if ( v0 == 2 )
12468 {
12469 v1 = 207;
12470 goto LABEL_14;
12471 }
12472 if ( v0 == 3 )
12473 {
12474 v1 = 211;
12475 goto LABEL_14;
12476 }
12477 if ( v0 == 4 )
12478 {
12479 v1 = 209;
12480 goto LABEL_14;
12481 }
12482 if ( v0 == 5 )
12483 {
12484 v1 = 210;
12485 goto LABEL_14;
12486 }
12487 LABEL_15:
12488 pRenderer->_4A612A(
12489 pTownPortalBook_xs[v0],
12490 pTownPortalBook_ys[v0],
12491 *(&pTexture_TownPortalHarmn + v0),
12492 v0 + 1);
12493 LABEL_16:
12494 ++v0;
12495 }
12496 while ( v0 < 6 );
12497 v2 = pMouse->GetCursorPos(&a2);
12498 v3 = pRenderer->pActiveZBuffer[v2->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF;
12499 if ( !v3 ) // Town Portal
12500 return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
12501 if ( v3 == 1 )
12502 {
12503 v4 = 206;
12504 LABEL_30:
12505 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, v4) )
12506 goto LABEL_31;
12507 return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
12508 }
12509 if ( v3 == 2 )
12510 {
12511 v4 = 208;
12512 goto LABEL_30;
12513 }
12514 if ( v3 == 3 )
12515 {
12516 v4 = 207;
12517 goto LABEL_30;
12518 }
12519 if ( v3 == 4 )
12520 {
12521 v4 = 211;
12522 goto LABEL_30;
12523 }
12524 if ( v3 == 5 )
12525 {
12526 v4 = 209;
12527 goto LABEL_30;
12528 }
12529 if ( v3 == 6 )
12530 {
12531 v4 = 210;
12532 goto LABEL_30;
12533 }
12534 LABEL_31:
12535 pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3));
12536 return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
12537 }
12538 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
12539
12540 //----- (00411300) --------------------------------------------------------
12541 Texture *__fastcall LoadSpellbook(unsigned int uID)
12542 {
12543 unsigned int v1; // esi@1
12544 Player *pPlayer; // ecx@1
12545 char v3; // al@1
12546 int v4; // edi@5
12547 Texture *result; // eax@6
12548 char *v6; // edi@7
12549 unsigned int v7; // eax@7
12550 unsigned __int8 v8; // sf@8
12551 unsigned __int8 v9; // of@8
12552 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
12553 Texture *v11; // [sp+20h] [bp-8h]@5
12554 int v12; // [sp+24h] [bp-4h]@5
12555
12556 byte_506550 = 0;
12557 v1 = uID;
12558 pPlayer = pPlayers[uActiveCharacter];
12559 v3 = pPlayer->uQuickSpell;
12560 if ( v3 && (unsigned __int8)v3 / 11 == v1 )
12561 dword_50654C = (unsigned __int8)v3 - 11 * v1;
12562 else
12563 dword_50654C = 0;
12564 v4 = 1;
12565 v12 = 1;
12566 v11 = (Texture *)&pPlayer->field_152[11 * v1 + 63];
12567 do
12568 {
12569 result = v11;
12570 if ( v11->pName[v4] )
12571 {
12572 v6 = &byte_4E2430[12 * v1] + v4;
12573 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
12574 v7 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
12575 dword_506408[v12] = 72 * v7 + 7145548;
12576 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
12577 result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
12578 dword_5063D8[v12] = result;
12579 }
12580 v4 = v12 + 1;
12581 v9 = __OFSUB__(v12 + 1, 12);
12582 v8 = v12++ - 11 < 0;
12583 }
12584 while ( v8 ^ v9 );
12585 return result;
12586 }
12587 // 4E1D18: using guessed type char *spellbook_texture_filename_suffices[8];
12588 // 506408: using guessed type int dword_506408[];
12589 // 50654C: using guessed type int dword_50654C;
12590 // 506550: using guessed type char byte_506550;
12591
12592 //----- (0041140B) --------------------------------------------------------
12593 GUIWindow *__cdecl sub_41140B()
12594 {
12595 signed int v0; // esi@1
12596 GUIButton *v1; // eax@3
12597 GUIButton *v2; // esi@4
12598 GUIWindow *result; // eax@5
12599
12600 v0 = 0;
12601 do
12602 {
12603 dword_506404[v0]->Release();
12604 dword_506434[v0]->Release();
12605 --v0;
12606 }
12607 while ( v0 >= -11 );
12608 pIcons_LOD->_40F9C5();
12609 v1 = pGUIWindow_CurrentMenu->pControlsHead;
12610 if ( v1 )
12611 {
12612 do
12613 {
12614 v2 = v1->pNext;
12615 pAllocator->FreeChunk(v1);
12616 v1 = v2;
12617 }
12618 while ( v2 );
12619 }
12620 pGUIWindow_CurrentMenu->pControlsHead = 0;
12621 pGUIWindow_CurrentMenu->pControlsTail = 0;
12622 result = pGUIWindow_CurrentMenu;
12623 pGUIWindow_CurrentMenu->uNumControls = 0;
12624 return result;
12625 }
12626
12627 //----- (00411473) --------------------------------------------------------
12628 void __cdecl sub_411473()
12629 {
12630 Texture **v0; // esi@1
12631 Texture **v1; // edi@1
12632 Texture *v2; // ecx@2
12633 Texture *v3; // ecx@2
12634
12635 pTexture_pagemask->Release();
12636 pTexture_506448->Release();
12637 pTexture_50643C->Release();
12638 v0 = &pTextures_tabs[0][1];
12639 v1 = pTextures_5064A0;
12640 do
12641 {
12642 (*v1)->Release();
12643 v2 = (Texture *)*((int *)v0 - 1);
12644 *v1 = 0;
12645 v2->Release();
12646 v3 = *(Texture **)v0;
12647 *((int *)v0 - 1) = 0;
12648 v3->Release();
12649 *(int *)v0 = 0;
12650 ++v1;
12651 v0 += 8;
12652 }
12653 while ( (signed int)v1 < (signed int)&pTextures_5064A0[9] );
12654 pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
12655 pIcons_LOD->_4114F2();
12656 }
12657
12658
12659 //----- (00411597) --------------------------------------------------------
12660 void __cdecl OnCloseSpellook()
12661 {
12662 pAllocator->FreeChunk(pSpellFont);
12663 pSpellFont = 0;
12664 pAllocator->FreeChunk(pBookFont);
12665 pBookFont = 0;
12666 pAllocator->FreeChunk(pBook2Font);
12667 pBook2Font = 0;
12668 pAllocator->FreeChunk(pAutonoteFont);
12669 pAutonoteFont = 0;
12670 pTexture_mapbordr->Release();
12671 pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
12672 pIcons_LOD->_4114F2();
12673 dword_506364 = 0;
12674 }
12675 // 506364: using guessed type int dword_506364;
12676
12677
12678
12679
12680
12681
12682
12683 //----- (00412AF9) --------------------------------------------------------
12684 void __cdecl sub_412AF9()
12685 {
12686 int v0; // ecx@1
12687
12688 v0 = 0;
12689 if ( uActiveCharacter )
12690 v0 = *((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
12691 pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
12692 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
12693 pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
12694 }
12695
12696 //----- (00412B58) --------------------------------------------------------
12697 void __cdecl sub_412B58()
12698 {
12699 Player *v0; // ebx@1
12700 int v1; // ebp@1
12701 unsigned int v2; // eax@1
12702 Texture *v3; // edi@1
12703 int v4; // esi@1
12704 Texture *v5; // eax@3
12705 Texture *v6; // edx@5
12706 int v7; // eax@8
12707 int v8; // eax@11
12708 POINT *v9; // esi@13
12709 int v10; // eax@13
12710 Texture *v11; // edx@14
12711 int v12; // eax@15
12712 signed int v13; // ecx@18
12713 unsigned int v14; // esi@18
12714 unsigned int v15; // edi@18
12715 Texture *v16; // eax@21
12716 unsigned int v17; // [sp-Ch] [bp-2Ch]@8
12717 unsigned int v18; // [sp-Ch] [bp-2Ch]@15
12718 unsigned int v19; // [sp-8h] [bp-28h]@8
12719 unsigned int v20; // [sp-8h] [bp-28h]@15
12720 Texture *v21; // [sp-4h] [bp-24h]@15
12721 signed int v22; // [sp-4h] [bp-24h]@22
12722 int v23[2]; // [sp+10h] [bp-10h]@5
12723 POINT a2; // [sp+18h] [bp-8h]@13
12724
12725 sub_412AF9();
12726 v0 = pPlayers[uActiveCharacter];
12727 v1 = 11 * v0->pNumSpellBookPage;
12728 v2 = pIcons_LOD->FindTextureByName("Pending");
12729 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
12730 pRenderer->ClearZBuffer(0, 479);
12731 v4 = 1;
12732 if ( __OFSUB__(v1, v1 + 11) ^ 1 )
12733 {
12734 do
12735 {
12736 if ( *(&v0->field_152[v1 + 63] + v4) )
12737 {
12738 v5 = (Texture *)dword_506408[v4];
12739 if ( v5 != v3 )
12740 {
12741 if ( dword_50654C == v4 )
12742 {
12743 v6 = dword_5063D8[v4];
12744 v23[0] = (int)dword_5063D8[v4];
12745 }
12746 else
12747 {
12748 v23[0] = dword_506408[v4];
12749 v6 = v5;
12750 }
12751 if ( v6->pLevelOfDetail0 )
12752 {
12753 v7 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage + v4]));
12754 v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
12755 v17 = pViewport->uViewportX + dword_4E20D0[v7];
12756 if ( BYTE1(v6->pBits) & 2 )
12757 pRenderer->DrawTextureTransparent(v17, v19, v6);
12758 else
12759 pRenderer->DrawTextureIndexed(v17, v19, v6);
12760 v8 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v4));
12761 pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], (Texture *)v23[0], v4);
12762 }
12763 }
12764 }
12765 ++v4;
12766 }
12767 while ( v4 + v1 - 1 < v1 + 11 );
12768 }
12769 v9 = pMouse->GetCursorPos(&a2);
12770 v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)v23)->y]] & 0xFFFF;
12771 if ( v10 )
12772 {
12773 v11 = dword_5063D8[v10];
12774 if ( v11->pLevelOfDetail0 )
12775 {
12776 v21 = dword_5063D8[v10];
12777 v12 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v10));
12778 v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
12779 v18 = pViewport->uViewportX + dword_4E20D0[v12];
12780 if ( BYTE1(v11->pBits) & 2 )
12781 pRenderer->DrawTextureTransparent(v18, v20, v21);
12782 else
12783 pRenderer->DrawTextureIndexed(v18, v20, v21);
12784 }
12785 }
12786 v13 = 0;
12787 a2.x = (LONG)&v0->pActiveSkills[12];
12788 v14 = (unsigned int)&v0->pActiveSkills[12];
12789 v15 = (unsigned int)&v0->pActiveSkills[12];
12790 v23[0] = 0;
12791 do
12792 {
12793 if ( *(short *)a2.x )
12794 {
12795 if ( v0->pNumSpellBookPage == v13 )
12796 {
12797 v16 = pTextures_tabs[v13][1];
12798 switch ( v13 )
12799 {
12800 case 0:
12801 v14 = 406;
12802 v22 = 9;
12803 goto LABEL_27;
12804 case 1:
12805 v14 = 406;
12806 goto LABEL_38;
12807 case 2:
12808 v14 = 406;
12809 v22 = 84;
12810 goto LABEL_27;
12811 case 3:
12812 v14 = 406;
12813 goto LABEL_26;
12814 case 4:
12815 v14 = 407;
12816 goto LABEL_29;
12817 case 5:
12818 v15 = 196;
12819 goto LABEL_34;
12820 case 6:
12821 v15 = 234;
12822 goto LABEL_34;
12823 case 7:
12824 v15 = 272;
12825 goto LABEL_34;
12826 case 8:
12827 v15 = 309;
12828 LABEL_34:
12829 v14 = 405;
12830 break;
12831 default:
12832 break;
12833 }
12834 }
12835 else
12836 {
12837 v16 = pTextures_tabs[v13][0];
12838 switch ( v13 )
12839 {
12840 case 0:
12841 v14 = 415;
12842 v22 = 10;
12843 goto LABEL_27;
12844 case 1:
12845 v14 = 415;
12846 LABEL_38:
12847 v22 = 46;
12848 goto LABEL_27;
12849 case 2:
12850 v14 = 415;
12851 v22 = 83;
12852 goto LABEL_27;
12853 case 3:
12854 v14 = 415;
12855 LABEL_26:
12856 v22 = 121;
12857 LABEL_27:
12858 v15 = v22;
12859 break;
12860 case 4:
12861 v14 = 415;
12862 LABEL_29:
12863 v15 = 158;
12864 break;
12865 case 5:
12866 v15 = 196;
12867 goto LABEL_46;
12868 case 6:
12869 v15 = 234;
12870 goto LABEL_46;
12871 case 7:
12872 v15 = 271;
12873 goto LABEL_46;
12874 case 8:
12875 v15 = 307;
12876 LABEL_46:
12877 v14 = 416;
12878 break;
12879 default:
12880 break;
12881 }
12882 }
12883 pRenderer->DrawTextureTransparent(v14, v15, v16);
12884 v13 = v23[0];
12885 }
12886 a2.x += 2;
12887 ++v13;
12888 v23[0] = v13;
12889 }
12890 while ( v13 < 9 );
12891 }
12892 // 506408: using guessed type int dword_506408[];
12893 // 50654C: using guessed type int dword_50654C;
12894
12895 //----- (00412E85) --------------------------------------------------------
12896 char __cdecl sub_412E85()
12897 {
12898 unsigned int v0; // eax@3
12899 unsigned int v1; // eax@7
12900 int v2; // eax@10
12901 const char *v3; // eax@10
12902 signed int v4; // ecx@12
12903 int v5; // ecx@14
12904 int v6; // eax@21
12905 int v7; // esi@21
12906 char *v8; // eax@21
12907 int v9; // eax@22
12908 unsigned int v11; // [sp-8h] [bp-64h]@3
12909 unsigned int v12; // [sp-8h] [bp-64h]@7
12910 Texture *v13; // [sp-4h] [bp-60h]@3
12911 Texture *v14; // [sp-4h] [bp-60h]@7
12912 GUIWindow a1; // [sp+8h] [bp-54h]@10
12913
12914 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[11]);
12915 if ( dword_506548 || !dword_506528 )
12916 {
12917 v13 = pTex_tab_an_6a__zoom_off;
12918 v11 = pViewport->uViewportY + 2;
12919 v0 = pViewport->uViewportX + 407;
12920 }
12921 else
12922 {
12923 v13 = pTex_tab_an_6b__zoom_on;
12924 v11 = pViewport->uViewportY + 1;
12925 v0 = pViewport->uViewportX + 398;
12926 }
12927 pRenderer->DrawTextureTransparent(v0, v11, v13);
12928 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
12929 {
12930 v14 = pTex_tab_an_7a__zoot_off;
12931 v12 = pViewport->uViewportY + 38;
12932 v1 = pViewport->uViewportX + 407;
12933 }
12934 else
12935 {
12936 v14 = pTex_tab_an_7b__zoot_on;
12937 v12 = pViewport->uViewportY + 38;
12938 v1 = pViewport->uViewportX + 398;
12939 }
12940 pRenderer->DrawTextureTransparent(v1, v12, v14);
12941 if ( !byte_5C6D50[dword_506528] )
12942 {
12943 v2 = pStru179->field_0[dword_506528];
12944 a1.uFrameWidth = 460;
12945 a1.uFrameX = 8;
12946 a1.uFrameY = 8;
12947 a1.uFrameHeight = 344;
12948 v3 = (const char *)pStorylineText->field_4[3 * v2];
12949 a1.uFrameZ = 467;
12950 a1.uFrameW = 351;
12951 if ( v3 )
12952 a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, v3, 3u);
12953 }
12954 a1.uFrameX = 48;
12955 a1.uFrameY = 70;
12956 a1.uFrameWidth = 360;
12957 a1.uFrameHeight = 264;
12958 v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
12959 a1.uFrameZ = 407;
12960 a1.uFrameHeight = v4 * 264 / v4;
12961 a1.uFrameW = a1.uFrameHeight + 69;
12962 if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
12963 {
12964 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
12965 v5 = dword_50651C++;
12966 dword_506528 += dword_506520;
12967 byte_506130[v5] = dword_506520;
12968 }
12969 if ( dword_506548 && dword_50651C )
12970 {
12971 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
12972 --dword_50651C;
12973 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
12974 }
12975 if ( !dword_506520 || dword_506528 < 1 )
12976 {
12977 dword_506528 = 0;
12978 dword_50651C = 0;
12979 }
12980 dword_506544 = 0;
12981 v6 = pStru179->field_0[dword_506528];
12982 dword_506548 = 0;
12983 dword_506520 = 0;
12984 v7 = *(&pStorylineText->field_0 + 3 * v6);
12985 v8 = sub_495461(
12986 *((char **)&pStorylineText->field_0 + 3 * v6),
12987 uActiveCharacter - 1,
12988 0,
12989 0,
12990 0,
12991 (__int64 *)&pParty->field_3C.field_440[2 * v6 + 42]);
12992 if ( v7 )
12993 {
12994 v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
12995 LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
12996 ++dword_506520;
12997 }
12998 return (char)v8;
12999 }
13000
13001
13002 //----- (00413126) --------------------------------------------------------
13003 void __cdecl DrawSpellbook_Quests()
13004 {
13005 unsigned int v0; // eax@3
13006 unsigned int v1; // eax@7
13007 int v2; // ecx@11
13008 int v3; // ebx@16
13009 int v4; // eax@19
13010 const char *v5; // edi@19
13011 int v6; // eax@19
13012 unsigned int v7; // edi@19
13013 unsigned int v8; // [sp-8h] [bp-68h]@3
13014 unsigned int v9; // [sp-8h] [bp-68h]@7
13015 Texture *v10; // [sp-4h] [bp-64h]@3
13016 Texture *v11; // [sp-4h] [bp-64h]@7
13017 GUIWindow a1; // [sp+Ch] [bp-54h]@9
13018
13019 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_CurrentBook);
13020 if ( dword_506548 || !dword_506528 )
13021 {
13022 v10 = pTex_tab_an_6a__zoom_off;
13023 v8 = pViewport->uViewportY + 2;
13024 v0 = pViewport->uViewportX + 407;
13025 }
13026 else
13027 {
13028 v10 = pTex_tab_an_6b__zoom_on;
13029 v8 = pViewport->uViewportY + 1;
13030 v0 = pViewport->uViewportX + 398;
13031 }
13032 pRenderer->DrawTextureTransparent(v0, v8, v10);
13033 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
13034 {
13035 v11 = pTex_tab_an_7a__zoot_off;
13036 v9 = pViewport->uViewportY + 38;
13037 v1 = pViewport->uViewportX + 407;
13038 }
13039 else
13040 {
13041 v11 = pTex_tab_an_7b__zoot_on;
13042 v9 = pViewport->uViewportY + 38;
13043 v1 = pViewport->uViewportX + 398;
13044 }
13045 pRenderer->DrawTextureTransparent(v1, v9, v11);
13046 a1.uFrameWidth = 460;
13047 a1.uFrameHeight = 344;
13048 a1.uFrameX = 8;
13049 a1.uFrameY = 8;
13050 a1.uFrameZ = 467;
13051 a1.uFrameW = 351;
13052 a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[174], 3u);
13053 a1.uFrameX = 48;
13054 a1.uFrameY = 70;
13055 a1.uFrameWidth = 360;
13056 a1.uFrameHeight = 264;
13057 a1.uFrameZ = 407;
13058 a1.uFrameW = 333;
13059 if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
13060 {
13061 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13062 v2 = dword_50651C++;
13063 dword_506528 += dword_506520;
13064 byte_506130[v2] = dword_506520;
13065 }
13066 if ( dword_506548 && dword_50651C )
13067 {
13068 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13069 --dword_50651C;
13070 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
13071 }
13072 if ( !dword_506520 || (v3 = dword_506528, dword_506528 < 1) )
13073 {
13074 v3 = 0;
13075 dword_50651C = 0;
13076 dword_506528 = 0;
13077 }
13078 dword_506544 = 0;
13079 dword_506548 = 0;
13080 dword_506520 = 0;
13081 while ( v3 < dword_506524 )
13082 {
13083 v4 = pStru179->field_0[v3];
13084 ++dword_506520;
13085 v5 = (&dword_722F10)[4 * v4];
13086 a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_722F10)[4 * v4], 0, 0, 0);
13087 v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
13088 v7 = a1.uFrameY + v6;
13089 if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight )
13090 break;
13091 pRenderer->DrawTextureTransparent(0x64u, v7 + 12, pTextures_5064A0[10]);
13092 ++v3;
13093 a1.uFrameY = v7 + 24;
13094 }
13095 }
13096
13097
13098 //----- (0041338E) --------------------------------------------------------
13099 void __cdecl DrawSpellbook_Autonotes()
13100 {
13101 unsigned int v0; // eax@3
13102 unsigned int v1; // eax@7
13103 signed int v2; // ebp@11
13104 unsigned int v3; // eax@18
13105 unsigned int v4; // eax@24
13106 unsigned int v5; // eax@30
13107 unsigned int v6; // eax@36
13108 unsigned int v7; // eax@42
13109 signed int v8; // ebp@47
13110 int v9; // eax@52
13111 int v10; // eax@56
13112 int v11; // edx@57
13113 int v12; // ebp@64
13114 int v13; // eax@65
13115 const char *v14; // edi@65
13116 int v15; // eax@65
13117 unsigned int v16; // edi@65
13118 unsigned int v17; // [sp-8h] [bp-70h]@3
13119 unsigned int v18; // [sp-8h] [bp-70h]@7
13120 unsigned int v19; // [sp-8h] [bp-70h]@18
13121 unsigned int v20; // [sp-8h] [bp-70h]@24
13122 unsigned int v21; // [sp-8h] [bp-70h]@30
13123 unsigned int v22; // [sp-8h] [bp-70h]@36
13124 unsigned int v23; // [sp-8h] [bp-70h]@42
13125 Texture *v24; // [sp-4h] [bp-6Ch]@3
13126 Texture *v25; // [sp-4h] [bp-6Ch]@7
13127 Texture *v26; // [sp-4h] [bp-6Ch]@18
13128 Texture *v27; // [sp-4h] [bp-6Ch]@24
13129 Texture *v28; // [sp-4h] [bp-6Ch]@30
13130 Texture *v29; // [sp-4h] [bp-6Ch]@36
13131 Texture *v30; // [sp-4h] [bp-6Ch]@42
13132 signed __int16 v31; // [sp+10h] [bp-58h]@1
13133 char *v32; // [sp+10h] [bp-58h]@49
13134 GUIWindow a1; // [sp+14h] [bp-54h]@46
13135
13136 v31 = 0;
13137 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_AutonotesBook);
13138 if ( dword_506548 || !dword_506528 )
13139 {
13140 v24 = pTex_tab_an_6a__zoom_off;
13141 v17 = pViewport->uViewportY + 2;
13142 v0 = pViewport->uViewportX + 407;
13143 }
13144 else
13145 {
13146 v24 = pTex_tab_an_6b__zoom_on;
13147 v17 = pViewport->uViewportY + 1;
13148 v0 = pViewport->uViewportX + 398;
13149 }
13150 pRenderer->DrawTextureTransparent(v0, v17, v24);
13151 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
13152 {
13153 v25 = pTex_tab_an_7a__zoot_off;
13154 v18 = pViewport->uViewportY + 38;
13155 v1 = pViewport->uViewportX + 407;
13156 }
13157 else
13158 {
13159 v25 = pTex_tab_an_7b__zoot_on;
13160 v18 = pViewport->uViewportY + 38;
13161 v1 = pViewport->uViewportX + 398;
13162 }
13163 pRenderer->DrawTextureTransparent(v1, v18, v25);
13164 if ( !dword_506540 )
13165 {
13166 if ( dword_506568 )
13167 {
13168 pRenderer->DrawTextureTransparent(
13169 pViewport->uViewportX + 408,
13170 pViewport->uViewportY + 113,
13171 pTexture_506390);
13172 v2 = 1;
13173 goto LABEL_16;
13174 }
13175 goto LABEL_14;
13176 }
13177 if ( !dword_506568 )
13178 {
13179 LABEL_14:
13180 v2 = 1;
13181 goto LABEL_15;
13182 }
13183 v2 = 1;
13184 v31 = 1;
13185 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13186 LABEL_15:
13187 dword_506568 = 0;
13188 pRenderer->DrawTextureTransparent(pViewport->uViewportX + 398, pViewport->uViewportY + 113, pTexture_506394);
13189 LABEL_16:
13190 if ( dword_50653C )
13191 {
13192 if ( dword_506568 != v2 )
13193 {
13194 v31 = v2;
13195 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13196 }
13197 }
13198 else
13199 {
13200 if ( dword_506568 != v2 )
13201 {
13202 v26 = pTexture_506388;
13203 v19 = pViewport->uViewportY + 150;
13204 v3 = pViewport->uViewportX + 408;
13205 goto LABEL_22;
13206 }
13207 }
13208 v26 = pTexture_50638C;
13209 dword_506568 = v2;
13210 v19 = pViewport->uViewportY + 150;
13211 v3 = pViewport->uViewportX + 399;
13212 LABEL_22:
13213 pRenderer->DrawTextureTransparent(v3, v19, v26);
13214 if ( dword_506538 )
13215 {
13216 if ( dword_506568 != 2 )
13217 {
13218 v31 = v2;
13219 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13220 }
13221 }
13222 else
13223 {
13224 if ( dword_506568 != 2 )
13225 {
13226 v27 = pTexture_506380;
13227 v20 = pViewport->uViewportY + 188;
13228 v4 = pViewport->uViewportX + 408;
13229 goto LABEL_28;
13230 }
13231 }
13232 v27 = pTexture_506384;
13233 dword_506568 = 2;
13234 v20 = pViewport->uViewportY + 188;
13235 v4 = pViewport->uViewportX + 397;
13236 LABEL_28:
13237 pRenderer->DrawTextureTransparent(v4, v20, v27);
13238 if ( dword_506534 )
13239 {
13240 if ( dword_506568 != 3 )
13241 {
13242 v31 = v2;
13243 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13244 }
13245 }
13246 else
13247 {
13248 if ( dword_506568 != 3 )
13249 {
13250 v28 = pTexture_506378;
13251 v21 = pViewport->uViewportY + 226;
13252 v5 = pViewport->uViewportX + 408;
13253 goto LABEL_34;
13254 }
13255 }
13256 v28 = pTexture_50637C;
13257 dword_506568 = 3;
13258 v21 = pViewport->uViewportY + 226;
13259 v5 = pViewport->uViewportX + 397;
13260 LABEL_34:
13261 pRenderer->DrawTextureTransparent(v5, v21, v28);
13262 if ( dword_506530 )
13263 {
13264 if ( dword_506568 != 4 )
13265 {
13266 v31 = v2;
13267 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13268 }
13269 }
13270 else
13271 {
13272 if ( dword_506568 != 4 )
13273 {
13274 v29 = pTexture_506370;
13275 v22 = pViewport->uViewportY + 263;
13276 v6 = pViewport->uViewportX + 408;
13277 goto LABEL_40;
13278 }
13279 }
13280 v29 = pTexture_506374;
13281 dword_506568 = 4;
13282 v22 = pViewport->uViewportY + 264;
13283 v6 = pViewport->uViewportX + 397;
13284 LABEL_40:
13285 pRenderer->DrawTextureTransparent(v6, v22, v29);
13286 if ( dword_50652C )
13287 {
13288 if ( dword_506568 != 5 )
13289 {
13290 v31 = v2;
13291 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13292 }
13293 }
13294 else
13295 {
13296 if ( dword_506568 != 5 )
13297 {
13298 v30 = pTexture_506368;
13299 v23 = pViewport->uViewportY + 302;
13300 v7 = pViewport->uViewportX + 408;
13301 goto LABEL_46;
13302 }
13303 }
13304 v30 = pTexture_50636C;
13305 dword_506568 = 5;
13306 v23 = pViewport->uViewportY + 302;
13307 v7 = pViewport->uViewportX + 397;
13308 LABEL_46:
13309 pRenderer->DrawTextureTransparent(v7, v23, v30);
13310 a1.uFrameWidth = 460;
13311 a1.uFrameHeight = 344;
13312 a1.uFrameX = 8;
13313 a1.uFrameY = 8;
13314 a1.uFrameZ = 467;
13315 a1.uFrameW = 467;
13316 a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[154], 3u);
13317 a1.uFrameX = 48;
13318 a1.uFrameY = 70;
13319 a1.uFrameWidth = 360;
13320 a1.uFrameHeight = 264;
13321 a1.uFrameZ = 407;
13322 a1.uFrameW = 333;
13323 if ( v31 )
13324 {
13325 dword_506524 = 0;
13326 dword_506528 = 0;
13327 dword_50651C = 0;
13328 dword_506520 = 0;
13329 v8 = 0;
13330 do
13331 {
13332 if ( dword_72371C[2 * v8] == dword_506568 )
13333 {
13334 v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8];
13335 if ( (short)v8 )
13336 {
13337 if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
13338 {
13339 v9 = dword_506520++;
13340 pStru179->field_0[v9] = (signed __int16)v8;
13341 }
13342 }
13343 }
13344 ++v8;
13345 }
13346 while ( v8 < 196 );
13347 dword_506524 = dword_506520;
13348 }
13349 else
13350 {
13351 if ( dword_506544 )
13352 {
13353 v10 = dword_506520 + dword_506528;
13354 if ( dword_506520 + dword_506528 < dword_506524 )
13355 {
13356 v11 = dword_50651C++;
13357 byte_506130[v11] = dword_506520;
13358 dword_506528 = v10;
13359 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13360 }
13361 }
13362 if ( dword_506548 && dword_50651C )
13363 {
13364 --dword_50651C;
13365 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
13366 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13367 }
13368 if ( !dword_506520 || dword_506528 < 1 )
13369 {
13370 dword_506528 = 0;
13371 dword_50651C = 0;
13372 }
13373 }
13374 v12 = dword_506528;
13375 dword_50652C = 0;
13376 dword_506544 = 0;
13377 dword_506548 = 0;
13378 dword_506520 = 0;
13379 dword_506530 = 0;
13380 dword_506534 = 0;
13381 dword_506538 = 0;
13382 dword_50653C = 0;
13383 dword_506540 = 0;
13384 while ( v12 < dword_506524 )
13385 {
13386 v13 = pStru179->field_0[v12];
13387 ++dword_506520;
13388 v14 = (&dword_723718_autonote_related)[8 * v13];
13389 a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
13390 v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0);
13391 v16 = a1.uFrameY + v15;
13392 if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight )
13393 break;
13394 pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pTextures_5064A0[10]);
13395 ++v12;
13396 a1.uFrameY = v16 + 24;
13397 }
13398 }
13399
13400
13401 //----- (00413980) --------------------------------------------------------
13402 char *__cdecl DrawSpellbook_Map()
13403 {
13404 unsigned int v0; // eax@3
13405 unsigned int v1; // eax@7
13406 unsigned int v2; // eax@10
13407 unsigned int v3; // eax@13
13408 unsigned int v4; // eax@16
13409 unsigned int v5; // eax@19
13410 int v6; // eax@31
13411 unsigned int v7; // eax@35
13412 unsigned int v9; // [sp-8h] [bp-E0h]@3
13413 unsigned int v10; // [sp-8h] [bp-E0h]@7
13414 unsigned int v11; // [sp-8h] [bp-E0h]@10
13415 unsigned int v12; // [sp-8h] [bp-E0h]@13
13416 unsigned int v13; // [sp-8h] [bp-E0h]@16
13417 unsigned int v14; // [sp-8h] [bp-E0h]@19
13418 Texture *v15; // [sp-4h] [bp-DCh]@3
13419 Texture *v16; // [sp-4h] [bp-DCh]@7
13420 Texture *v17; // [sp-4h] [bp-DCh]@10
13421 Texture *v18; // [sp-4h] [bp-DCh]@13
13422 Texture *v19; // [sp-4h] [bp-DCh]@16
13423 Texture *v20; // [sp-4h] [bp-DCh]@19
13424 char Str[120]; // [sp+Ch] [bp-CCh]@37
13425 GUIWindow v22; // [sp+84h] [bp-54h]@35
13426
13427 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[12]);
13428 if ( dword_506548 || viewparams->field_2C / 128 >= 12 )
13429 {
13430 v15 = pTex_tab_an_6a__zoom_off;
13431 v9 = pViewport->uViewportY + 2;
13432 v0 = pViewport->uViewportX + 408;
13433 }
13434 else
13435 {
13436 v15 = pTex_tab_an_6b__zoom_on;
13437 v9 = pViewport->uViewportY + 1;
13438 v0 = pViewport->uViewportX + 398;
13439 }
13440 pRenderer->DrawTextureTransparent(v0, v9, v15);
13441 if ( dword_506544 || viewparams->field_2C / 128 <= 3 )
13442 {
13443 v16 = pTex_tab_an_7a__zoot_off;
13444 v10 = pViewport->uViewportY + 38;
13445 v1 = pViewport->uViewportX + 408;
13446 }
13447 else
13448 {
13449 v16 = pTex_tab_an_7b__zoot_on;
13450 v10 = pViewport->uViewportY + 38;
13451 v1 = pViewport->uViewportX + 398;
13452 }
13453 pRenderer->DrawTextureTransparent(v1, v10, v16);
13454 if ( dword_506540 )
13455 {
13456 v17 = pTexture_506390;
13457 v11 = pViewport->uViewportY + 113;
13458 v2 = pViewport->uViewportX + 408;
13459 }
13460 else
13461 {
13462 v17 = pTexture_506394;
13463 v11 = pViewport->uViewportY + 113;
13464 v2 = pViewport->uViewportX + 398;
13465 }
13466 pRenderer->DrawTextureTransparent(v2, v11, v17);
13467 if ( dword_50653C )
13468 {
13469 v18 = pTexture_506388;
13470 v12 = pViewport->uViewportX + 150;
13471 v3 = pViewport->uViewportY + 408;
13472 }
13473 else
13474 {
13475 v18 = pTexture_50638C;
13476 v12 = pViewport->uViewportX + 150;
13477 v3 = pViewport->uViewportY + 399;
13478 }
13479 pRenderer->DrawTextureTransparent(v3, v12, v18);
13480 if ( dword_506538 )
13481 {
13482 v19 = pTexture_506380;
13483 v13 = pViewport->uViewportY + 188;
13484 v4 = pViewport->uViewportX + 408;
13485 }
13486 else
13487 {
13488 v19 = pTexture_506384;
13489 v13 = pViewport->uViewportY + 188;
13490 v4 = pViewport->uViewportX + 397;
13491 }
13492 pRenderer->DrawTextureTransparent(v4, v13, v19);
13493 if ( dword_506534 )
13494 {
13495 v20 = pTexture_506378;
13496 v14 = pViewport->uViewportY + 226;
13497 v5 = pViewport->uViewportX + 408;
13498 }
13499 else
13500 {
13501 v20 = pTexture_50637C;
13502 v14 = pViewport->uViewportY + 226;
13503 v5 = pViewport->uViewportX + 397;
13504 }
13505 pRenderer->DrawTextureTransparent(v5, v14, v20);
13506 if ( dword_506544 )
13507 viewparams->_443291();
13508 if ( dword_506548 )
13509 viewparams->_443249();
13510 if ( dword_506540 )
13511 viewparams->_443219();
13512 if ( dword_50653C )
13513 viewparams->_443231();
13514 if ( dword_506538 )
13515 viewparams->_44323D();
13516 v6 = dword_506534;
13517 if ( dword_506534 )
13518 {
13519 viewparams->_443225();
13520 v6 = dword_506534;
13521 }
13522 if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | v6 )
13523 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13524 dword_506548 = 0;
13525 dword_506544 = 0;
13526 dword_506534 = 0;
13527 dword_506538 = 0;
13528 dword_50653C = 0;
13529 dword_506540 = 0;
13530 DrawSpellbook_Map_sub(0x61u, 0x31u, 0x169u, 313, 0);
13531 pRenderer->DrawTextureTransparent(0x4Bu, 0x16u, pTexture_mapbordr);
13532 v22.uFrameWidth = 460;
13533 v22.uFrameHeight = 344;
13534 v22.uFrameX = 8;
13535 v22.uFrameY = 8;
13536 v22.uFrameZ = 467;
13537 v22.uFrameW = 467;
13538 v7 = pMapStats->GetMapInfo(pCurrentMapName);
13539 if ( v7 )
13540 v22.DrawTitleText(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
13541 v22.uFrameX = 0;
13542 sprintf(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y);
13543 return v22.DrawTitleText(pFontComic, 0, 0x140u, 0, Str, 0);
13544 }
13545
13546
13547 //----- (00413CC6) --------------------------------------------------------
13548 void __thiscall DrawSpellbook(unsigned int uBook)
13549 {
13550 unsigned int v1; // esi@1
13551
13552 v1 = uBook;
13553 pRenderer->DrawTextureIndexed(
13554 471u,
13555 445u,
13556 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
13557 switch ( v1 )
13558 {
13559 case 0xB1u:
13560 DrawLloydBeaconsScreen();
13561 break;
13562 case 0xC3u:
13563 DrawTownPortalScreen();
13564 break;
13565 case 0xC8u:
13566 DrawSpellbook_Quests();
13567 break;
13568 case 0xC9u:
13569 DrawSpellbook_Autonotes();
13570 break;
13571 case 0xCAu:
13572 DrawSpellbook_Map();
13573 break;
13574 case 0xCBu:
13575 DrawSpellbook_Calendar();
13576 break;
13577 case 0xE0u:
13578 sub_412E85();
13579 break;
13580 }
13581 }
13582
13583 //----- (00413D3C) --------------------------------------------------------
13584 char *__cdecl GetDayPart()
13585 {
13586 if ( pParty->uCurrentHour > 4 )
13587 {
13588 if ( pParty->uCurrentHour == 5 )
13589 return pGlobalTXT_LocalizationStrings[55];
13590 if ( pParty->uCurrentHour == 20 )
13591 return pGlobalTXT_LocalizationStrings[566];
13592 if ( pParty->uCurrentHour <= 0x14 || pParty->uCurrentHour > 0x17 )
13593 return pGlobalTXT_LocalizationStrings[56];
13594 }
13595 return pGlobalTXT_LocalizationStrings[567];
13596 }
13597
13598 //----- (00413D6F) --------------------------------------------------------
13599 char __cdecl DrawSpellbook_Calendar()
13600 {
13601 unsigned int v0; // esi@1
13602 char *v1; // eax@5
13603 int v2; // ecx@5
13604 char *v3; // eax@6
13605 GUIWindow a1; // [sp+Ch] [bp-60h]@5
13606 unsigned int v6; // [sp+60h] [bp-Ch]@1
13607 int v7; // [sp+64h] [bp-8h]@1
13608 int a5; // [sp+68h] [bp-4h]@1
13609
13610 v0 = pParty->uCurrentHour;
13611 v6 = pMapStats->GetMapInfo(pCurrentMapName);
13612 a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
13613 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[13]);
13614 v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
13615 if ( (signed int)v0 <= 12 )
13616 {
13617 if ( !v0 )
13618 v0 = 12;
13619 }
13620 else
13621 {
13622 v0 -= 12;
13623 }
13624 a1.uFrameX = 8;
13625 a1.uFrameY = 8;
13626 a1.uFrameWidth = 460;
13627 a1.uFrameHeight = 344;
13628 a1.uFrameZ = 467;
13629 a1.uFrameW = 467;
13630 a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[186], 3u);
13631 v1 = GetDayPart();
13632 sprintf(
13633 pTmpBuf,
13634 "%s\t100:\t110%d:%02d %s - %s",
13635 pGlobalTXT_LocalizationStrings[526],
13636 v0,
13637 pParty->uCurrentMinute,
13638 aAMPMNames[v2],
13639 v1);
13640 a1.DrawText(pBookFont, 70, 55, a5, pTmpBuf, 0, 0, 0);
13641 sprintf(
13642 pTmpBuf,
13643 "%s\t100:\t110%d - %s",
13644 pGlobalTXT_LocalizationStrings[56],
13645 pParty->uDaysPlayed + 1,
13646 aDayNames[pParty->uDaysPlayed % 7]);
13647 a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, a5, pTmpBuf, 0, 0, 0);
13648 sprintf(
13649 pTmpBuf,
13650 "%s\t100:\t110%d - %s",
13651 pGlobalTXT_LocalizationStrings[146],
13652 pParty->uCurrentMonth + 1,
13653 aMonthNames[pParty->uCurrentMonth]);
13654 a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, a5, pTmpBuf, 0, 0, 0);
13655 sprintf(pTmpBuf, "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
13656 a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, a5, pTmpBuf, 0, 0, 0);
13657 sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[v7]);
13658 a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, a5, pTmpBuf, 0, 0, 0);
13659 if ( v6 )
13660 v3 = pMapStats->pInfos[v6].pName;
13661 else
13662 v3 = "Unknown";
13663 sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3);
13664 return a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, a5, pTmpBuf, 0, 0, 0);
13665 }
13666
13667 //----- (00413FF1) --------------------------------------------------------
13668 void __cdecl SetMonthNames()
13669 {
13670 aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
13671 aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
13672 aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
13673 aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
13674 aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
13675 aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
13676 aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
13677 aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
13678 aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
13679 aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
13680 aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
13681 aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
13682 }
13683
13684 //----- (0041406F) --------------------------------------------------------
13685 void __cdecl SetDayNames()
13686 {
13687 aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
13688 aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
13689 aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
13690 aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
13691 aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
13692 aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
13693 aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
13694 }
13695
13696 //----- (004140BB) --------------------------------------------------------
13697 void __cdecl SetSpellSchoolNames()
13698 {
13699 aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
13700 aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
13701 aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
13702 aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
13703 aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
13704 aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
13705 aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
13706 aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
13707 aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
13708 }
13709
13710 //----- (0041411B) --------------------------------------------------------
13711 void __cdecl SetAttributeNames()
13712 {
13713 aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
13714 aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
13715 aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
13716 aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
13717 aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
13718 aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
13719 aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
13720 }
13721
13722 //----- (00414162) --------------------------------------------------------
13723 void __cdecl uGameUIFontMain_initialize()
13724 {
13725 uGameUIFontMain = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
13726 }
13727
13728 //----- (00414174) --------------------------------------------------------
13729 void __cdecl uGameUIFontShadow_initialize()
13730 {
13731 uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 214u, 193u);
13732 }
13733
13734
13735
13736
13737
13738 //----- (004141CA) --------------------------------------------------------
13739 GUIWindow *__fastcall ModalWindow(const char *pStr, int a4)
13740 {
13741 const char *v2; // edi@1
13742 int v3; // esi@1
13743 GUIWindow *result; // eax@1
13744
13745 v2 = pStr;
13746 v3 = a4;
13747 pEventTimer->Pause();
13748 dword_506F0C[0] = pCurrentScreen;
13749 result = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, v3, (int)v2);
13750 ptr_507BDC = result;
13751 pCurrentScreen = 22;
13752 return result;
13753 }
13754 // 4E28F8: using guessed type int pCurrentScreen;
13755
13756 //----- (0041420D) --------------------------------------------------------
13757 void __cdecl sub_41420D_press_esc()
13758 {
13759 GUIWindow v0; // [sp+4h] [bp-54h]@1
13760
13761 sprintf(pTmpBuf2, "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape
13762 v0.Hint = pTmpBuf2;
13763 v0.uFrameWidth = 400;
13764 v0.uFrameHeight = 100;
13765 v0.uFrameX = 120;
13766 v0.uFrameY = 140;
13767 v0.uFrameZ = 519;
13768 v0.uFrameW = 239;
13769 v0.DrawMessageBox(0);
13770 }
13771
13772 //----- (0041426F) --------------------------------------------------------
13773 void __cdecl sub_41426F()
13774 {
13775 GUIWindow *v0; // ecx@1
13776
13777 v0 = ptr_507BDC;
13778 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
13779 {
13780 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C;
13781 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
13782 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
13783 ++pMessageQueue_50CBD0->uNumMessages;
13784 }
13785 v0->Release();
13786 ptr_507BDC = 0;
13787 pCurrentScreen = dword_506F0C[0];
13788 pEventTimer->Resume();
13789 }
13790 // 4E28F8: using guessed type int pCurrentScreen;
13791
13792 //----- (004142D3) --------------------------------------------------------
13793 char __cdecl GameMenuUI_DrawKeyBindings()
13794 {
13795 unsigned int v0; // ebp@1
13796 int v1; // ecx@2
13797 unsigned int v2; // eax@6
13798 GUIWindow *v3; // edx@6
13799 signed int v4; // ecx@7
13800 signed int v5; // eax@8
13801 const char *v6; // ST0C_4@16
13802 unsigned int v7; // eax@16
13803 const char *v8; // ST0C_4@16
13804 unsigned int v9; // eax@16
13805 const char *v10; // ST0C_4@16
13806 unsigned int v11; // eax@16
13807 const char *v12; // ST0C_4@16
13808 unsigned int v13; // eax@16
13809 const char *v14; // ST0C_4@16
13810 unsigned int v15; // eax@16
13811 const char *v16; // ST0C_4@16
13812 unsigned int v17; // eax@16
13813 const char *v18; // ST0C_4@16
13814 unsigned int v19; // eax@16
13815 const char *v20; // ST0C_4@16
13816 unsigned int v21; // eax@16
13817 signed int v22; // ebp@16
13818 const char *v23; // ST0C_4@16
13819 unsigned int v24; // eax@16
13820 const char *v25; // ST0C_4@16
13821 unsigned int v26; // eax@16
13822 const char *v27; // ST0C_4@16
13823 unsigned int v28; // eax@16
13824 const char *v29; // ST0C_4@16
13825 unsigned int v30; // eax@16
13826 const char *v31; // ST0C_4@16
13827 unsigned int v32; // eax@16
13828 const char *v33; // ST0C_4@17
13829 unsigned int v34; // eax@17
13830 const char *v35; // ST0C_4@17
13831 unsigned int v36; // eax@17
13832 const char *v37; // ST0C_4@17
13833 unsigned int v38; // eax@17
13834 const char *v39; // ST0C_4@17
13835 unsigned int v40; // eax@17
13836 const char *v41; // ST0C_4@17
13837 unsigned int v42; // eax@17
13838 const char *v43; // ST0C_4@17
13839 unsigned int v44; // eax@17
13840 const char *v45; // ST0C_4@17
13841 unsigned int v46; // eax@17
13842 const char *v47; // ST0C_4@17
13843 unsigned int v48; // eax@17
13844 const char *v49; // ST0C_4@17
13845 unsigned int v50; // eax@17
13846 const char *v51; // ST0C_4@17
13847 unsigned int v52; // eax@17
13848 const char *v53; // ST0C_4@17
13849 unsigned int v54; // eax@17
13850 const char *v55; // ST0C_4@17
13851 unsigned int v56; // eax@17
13852 const char *v57; // ST0C_4@17
13853 unsigned int v58; // eax@17
13854 unsigned int v59; // eax@18
13855 int v61; // [sp-14h] [bp-28h]@16
13856 const char *v62; // [sp-10h] [bp-24h]@16
13857 int v63; // [sp-Ch] [bp-20h]@16
13858 int v64; // [sp-8h] [bp-1Ch]@16
13859 unsigned int v65; // [sp-4h] [bp-18h]@16
13860 unsigned int a5; // [sp+10h] [bp-4h]@1
13861
13862 v0 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
13863 a5 = v0;
13864 if ( byte_4E28FC )
13865 {
13866 v1 = dword_507C0C + 15;
13867 dword_507C0C = v1;
13868 if ( v1 == 255 )
13869 byte_4E28FC = 0;
13870 }
13871 else
13872 {
13873 v1 = dword_507C0C - 15;
13874 dword_507C0C = v1;
13875 if ( v1 == 15 )
13876 byte_4E28FC = 1;
13877 }
13878 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, 0, 0);
13879 v3 = pGUIWindow_CurrentMenu;
13880 dword_507C08 = v2;
13881 if ( pGUIWindow_CurrentMenu->field_40 == 2 )
13882 {
13883 pPrevVirtualCidesMapping[dword_506E68] = pKeyActionMap->pPressedKeysBuffer[0];
13884 memset(word_506E6C, 0, 0x1Cu);
13885 v4 = 0;
13886 do
13887 {
13888 v5 = 0;
13889 do
13890 {
13891 if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] )
13892 {
13893 *((char *)word_506E6C + v4) = 1;
13894 *((char *)word_506E6C + v5) = 1;
13895 }
13896 ++v5;
13897 }
13898 while ( v5 < 28 );
13899 ++v4;
13900 }
13901 while ( v4 < 28 );
13902 dword_506E68 = -1;
13903 v3->field_40 = 0;
13904 }
13905 pRenderer->DrawTextureIndexed(
13906 8u,
13907 8u,
13908 (Texture *)(uTextureID_507BF4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507BF4] : 0));
13909 if ( dword_506F08 == 1 )
13910 {
13911 pRenderer->DrawTextureIndexed(
13912 0x13u,
13913 0x12Eu,
13914 (Texture *)(uTextureID_507C00 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C00] : 0));
13915 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
13916 v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
13917 v7 = sub_414D24(0);
13918 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v7, v6, 0, 0, 0);
13919 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2D50, 0, 0, 0);
13920 v8 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]);
13921 v9 = sub_414D24(1);
13922 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v9, v8, 0, 0, 0);
13923 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2D48, 0, 0, 0);
13924 v10 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]);
13925 v11 = sub_414D24(2);
13926 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v11, v10, 0, 0, 0);
13927 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2D40, 0, 0, 0);
13928 v12 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]);
13929 v13 = sub_414D24(3);
13930 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v13, v12, 0, 0, 0);
13931 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2D38, 0, 0, 0);
13932 v14 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]);
13933 v15 = sub_414D24(4);
13934 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v15, v14, 0, 0, 0);
13935 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2D30, 0, 0, 0);
13936 v16 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]);
13937 v17 = sub_414D24(5);
13938 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v17, v16, 0, 0, 0);
13939 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2D28, 0, 0, 0);
13940 v18 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]);
13941 v19 = sub_414D24(6);
13942 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v19, v18, 0, 0, 0);
13943 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2D1C, 0, 0, 0);
13944 v20 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]);
13945 v21 = sub_414D24(7);
13946 v22 = 350;
13947 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v21, v20, 0, 0, 0);
13948 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2D14, 0, 0, 0);
13949 v23 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]);
13950 v24 = sub_414D24(8);
13951 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v24, v23, 0, 0, 0);
13952 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2D0C, 0, 0, 0);
13953 v25 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]);
13954 v26 = sub_414D24(9);
13955 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v26, v25, 0, 0, 0);
13956 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2D04, 0, 0, 0);
13957 v27 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]);
13958 v28 = sub_414D24(10);
13959 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v28, v27, 0, 0, 0);
13960 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2CFC, 0, 0, 0);
13961 v29 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]);
13962 v30 = sub_414D24(11);
13963 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v30, v29, 0, 0, 0);
13964 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2CF0, 0, 0, 0);
13965 v31 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]);
13966 v32 = sub_414D24(12);
13967 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v32, v31, 0, 0, 0);
13968 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2CE8, 0, 0, 0);
13969 v65 = 0;
13970 v64 = 0;
13971 v63 = 0;
13972 v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
13973 v61 = 13;
13974 }
13975 else
13976 {
13977 pRenderer->DrawTextureIndexed(
13978 0x7Fu,
13979 0x12Eu,
13980 (Texture *)(uTextureID_507C04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C04] : 0));
13981 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
13982 v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
13983 v34 = sub_414D24(14);
13984 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v34, v33, 0, 0, 0);
13985 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2CD4, 0, 0, 0);
13986 v35 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]);
13987 v36 = sub_414D24(15);
13988 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v36, v35, 0, 0, 0);
13989 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2CC8, 0, 0, 0);
13990 v37 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]);
13991 v38 = sub_414D24(16);
13992 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v38, v37, 0, 0, 0);
13993 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2CBC, 0, 0, 0);
13994 v39 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]);
13995 v40 = sub_414D24(17);
13996 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v40, v39, 0, 0, 0);
13997 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2CB0, 0, 0, 0);
13998 v41 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]);
13999 v42 = sub_414D24(18);
14000 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v42, v41, 0, 0, 0);
14001 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2CA4, 0, 0, 0);
14002 v43 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]);
14003 v44 = sub_414D24(19);
14004 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v44, v43, 0, 0, 0);
14005 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2C9C, 0, 0, 0);
14006 v45 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]);
14007 v46 = sub_414D24(20);
14008 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v46, v45, 0, 0, 0);
14009 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2C90, 0, 0, 0);
14010 v47 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]);
14011 v48 = sub_414D24(21);
14012 v22 = 350;
14013 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v48, v47, 0, 0, 0);
14014 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2C84, 0, 0, 0);
14015 v49 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]);
14016 v50 = sub_414D24(22);
14017 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v50, v49, 0, 0, 0);
14018 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2C7C, 0, 0, 0);
14019 v51 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]);
14020 v52 = sub_414D24(23);
14021 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v52, v51, 0, 0, 0);
14022 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2C70, 0, 0, 0);
14023 v53 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]);
14024 v54 = sub_414D24(24);
14025 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v54, v53, 0, 0, 0);
14026 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2C68, 0, 0, 0);
14027 v55 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]);
14028 v56 = sub_414D24(25);
14029 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v56, v55, 0, 0, 0);
14030 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2C5C, 0, 0, 0);
14031 v57 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]);
14032 v58 = sub_414D24(26);
14033 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v58, v57, 0, 0, 0);
14034 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2C54, 0, 0, 0);
14035 v65 = 0;
14036 v64 = 0;
14037 v63 = 0;
14038 v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
14039 v61 = 27;
14040 }
14041 v59 = sub_414D24(v61);
14042 return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, v63, v64, v65);
14043 }
14044
14045
14046 //----- (00414D24) --------------------------------------------------------
14047 unsigned int __thiscall sub_414D24(int _this)
14048 {
14049 int v1; // esi@1
14050 unsigned int v2; // edi@1
14051 unsigned int v3; // ebx@1
14052 unsigned int result; // eax@1
14053
14054 v1 = _this;
14055 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
14056 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFu, 0, 0);
14057 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14058 if ( dword_506E68 == v1 )
14059 {
14060 if ( GetTickCount() % 0x3E8 <= 0x1F4 )
14061 result = v3;
14062 else
14063 result = v2;
14064 }
14065 else
14066 {
14067 if ( *((char *)word_506E6C + v1) )
14068 result = dword_507C08;
14069 }
14070 return result;
14071 }
14072 // 506E68: using guessed type int dword_506E68;
14073 // 506E6C: using guessed type __int16 word_506E6C[18];
14074 // 507C08: using guessed type int dword_507C08;
14075
14076 //----- (00414D9A) --------------------------------------------------------
14077 void __cdecl GameMenuUI_DrawVideoOptions()
14078 {
14079 const char *v0; // ST0C_4@3
14080 unsigned __int16 v1; // ax@3
14081 int v2; // eax@10
14082 GUIWindow v3; // [sp+8h] [bp-54h]@3
14083
14084 pRenderer->DrawTextureIndexed(
14085 8u,
14086 8u,
14087 (Texture *)(uTextureID_507C10 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C10] : 0));
14088 if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
14089 {
14090 pRenderer->DrawTextureIndexed(
14091 17 * uGammaPos + 42,
14092 162u,
14093 (Texture *)(pTextureIDs_GammaPositions[uGammaPos] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_GammaPositions[uGammaPos]] : 0));
14094 pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
14095 v3.uFrameX = 22;
14096 v0 = pGlobalTXT_LocalizationStrings[226];
14097 v3.uFrameY = 190;
14098 v3.uFrameWidth = 211;
14099 v3.uFrameHeight = 79;
14100 v3.uFrameZ = 232;
14101 v3.uFrameW = 268;
14102 v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
14103 v3.DrawTitleText(pFontSmallnum, 0, 0, v1, v0, 3u);
14104 }
14105 if ( !pRenderer->pRenderD3D )
14106 {
14107 pRenderer->DrawTextureIndexed(
14108 0x14u,
14109 0x119u,
14110 (Texture *)(uTextureID_507C50 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C50] : 0));
14111 pRenderer->DrawTextureIndexed(
14112 0x14u,
14113 0x12Fu,
14114 (Texture *)(uTextureID_507C54 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C54] : 0));
14115 v2 = uTextureID_507C58;
14116 goto LABEL_12;
14117 }
14118 if ( pGame->uFlags2 & 0x20 )
14119 pRenderer->DrawTextureIndexed(
14120 0x14u,
14121 0x119u,
14122 (Texture *)(uTextureID_507C14 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C14] : 0));
14123 if ( pRenderer->bUseColoredLights )
14124 pRenderer->DrawTextureIndexed(
14125 0x14u,
14126 0x12Fu,
14127 (Texture *)(uTextureID_507C18 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C18] : 0));
14128 if ( pRenderer->bTinting )
14129 {
14130 v2 = uTextureID_507C1C;
14131 LABEL_12:
14132 pRenderer->DrawTextureIndexed(0x14u, 0x145u, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
14133 }
14134 }
14135
14136
14137
14138 //----- (00414F82) --------------------------------------------------------
14139 void __cdecl sub_414F82_DrawGameOptions()
14140 {
14141 signed int v0; // eax@1
14142
14143 pRenderer->DrawTextureIndexed(
14144 8u,
14145 8u,
14146 (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0));
14147 pRenderer->DrawTextureIndexed(
14148 8u,
14149 0x84u,
14150 (Texture *)(uTextureID_507C60 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C60] : 0));
14151 v0 = 0;
14152 if ( uTurnSpeed == 128 )
14153 {
14154 v0 = 2;
14155 }
14156 else
14157 {
14158 if ( uTurnSpeed == 64 )
14159 v0 = 1;
14160 }
14161 pRenderer->DrawTextureIndexed(
14162 dword_4E2910[v0],
14163 0x10Eu,
14164 (Texture *)(uTextureID_507C64[v0] != -1 ? &pIcons_LOD->pTextures[uTextureID_507C64[v0]] : 0));
14165 if ( bWalkSound )
14166 pRenderer->DrawTextureIndexed(
14167 0x14u,
14168 0x12Fu,
14169 (Texture *)(uTextureID_507CB4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB4] : 0));
14170 if ( bShowDamage )
14171 pRenderer->DrawTextureIndexed(
14172 0x80u,
14173 0x12Fu,
14174 (Texture *)(uTextureID_507CB8 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB8] : 0));
14175 if ( bFlipOnExit )
14176 pRenderer->DrawTextureIndexed(
14177 0x80u,
14178 0x145u,
14179 (Texture *)(uTextureID_507C84 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C84] : 0));
14180 if ( bAlwaysRun )
14181 pRenderer->DrawTextureIndexed(
14182 0x14u,
14183 0x145u,
14184 (Texture *)(uTextureID_507CB0 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB0] : 0));
14185 pRenderer->DrawTextureIndexed(
14186 17 * (char)uSoundVolumeMultiplier + 265,
14187 0xA2u,
14188 (Texture *)(pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier]] : 0));
14189 pRenderer->DrawTextureIndexed(
14190 17 * (char)uMusicVolimeMultiplier + 265,
14191 0xD8u,
14192 (Texture *)(pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier]] : 0));
14193 pRenderer->DrawTextureIndexed(
14194 17 * (char)uVoicesVolumeMultiplier + 265,
14195 0x10Eu,
14196 (Texture *)(pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier]] : 0));
14197 }
14198
14199
14200
14201
14202 //----- (004151D9) --------------------------------------------------------
14203 void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
14204 {
14205 unsigned int v4; // ebx@1
14206 Texture *v5; // edi@1
14207 signed int uTileWidth; // ecx@1
14208 int v7; // eax@5
14209 int v8; // ecx@10
14210 unsigned int v9; // ebx@14
14211 int v10; // [sp+10h] [bp-28h]@5
14212 signed int uTileHeight; // [sp+18h] [bp-20h]@1
14213 int v12; // [sp+1Ch] [bp-1Ch]@7
14214 int v13; // [sp+20h] [bp-18h]@1
14215 int a5; // [sp+24h] [bp-14h]@5
14216 unsigned int a5a; // [sp+24h] [bp-14h]@11
14217 unsigned int a4; // [sp+28h] [bp-10h]@1
14218 int uNumXTiles; // [sp+2Ch] [bp-Ch]@3
14219 unsigned int uNumXTilesa; // [sp+2Ch] [bp-Ch]@6
14220 unsigned int uNumXTilesb; // [sp+2Ch] [bp-Ch]@11
14221 unsigned int a2a; // [sp+30h] [bp-8h]@1
14222 unsigned int v21; // [sp+34h] [bp-4h]@5
14223 unsigned int v22; // [sp+34h] [bp-4h]@11
14224
14225 v4 = uY;
14226 a2a = uX;
14227 a4 = uX + uWidth;
14228 pRenderer->Clip(uX, v4, uX + uWidth, v4 + uHeight);
14229 v5 = (Texture *)(uTextureID_Parchment != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Parchment] : 0);
14230 uTileWidth = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
14231 v13 = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
14232 uTileHeight = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26);
14233 if ( (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24)
14234 && (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26) )
14235 {
14236 uNumXTiles = (signed int)uWidth / uTileWidth;
14237 if ( (signed int)uWidth % uTileWidth )
14238 ++uNumXTiles;
14239 a5 = 0;
14240 v21 = v4;
14241 v7 = uNumXTiles + 1;
14242 v10 = uNumXTiles + 1;
14243 do
14244 {
14245 uNumXTilesa = a2a - v13;
14246 if ( v7 > 0 )
14247 {
14248 v12 = v7;
14249 do
14250 {
14251 uNumXTilesa += v13;
14252 pRenderer->DrawTextureIndexed(uNumXTilesa, v21, v5);
14253 --v12;
14254 }
14255 while ( v12 );
14256 v7 = v10;
14257 }
14258 v21 += uTileHeight;
14259 v8 = a5++;
14260 }
14261 while ( v8 < (signed int)uHeight / uTileHeight );
14262 a5a = v4 + uHeight - 32;
14263 pRenderer->DrawTextureTransparent(
14264 a2a,
14265 v4,
14266 (Texture *)(uTextureID_5076AC != -1 ? &pIcons_LOD->pTextures[uTextureID_5076AC] : 0));
14267 pRenderer->DrawTextureTransparent(
14268 a2a,
14269 a5a,
14270 (Texture *)(uTextureID_5076B4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076B4] : 0));
14271 pRenderer->DrawTextureTransparent(
14272 a4 - 32,
14273 v4,
14274 (Texture *)(uTextureID_5076A8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A8] : 0));
14275 pRenderer->DrawTextureTransparent(
14276 a4 - 32,
14277 a5a,
14278 (Texture *)(uTextureID_5076B0 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_5076B0] : 0));
14279 uNumXTilesb = a2a + 32;
14280 v22 = v4 + uHeight - 10;
14281 if ( (signed int)uWidth > 64 )
14282 {
14283 pRenderer->Clip(a2a + 32, v4, a4 - 32, v4 + uHeight);
14284 pRenderer->DrawTextureTransparent(
14285 uNumXTilesb,
14286 v4,
14287 (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
14288 pRenderer->DrawTextureTransparent(
14289 uNumXTilesb,
14290 v22,
14291 (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
14292 if ( (signed int)uWidth > 512 )
14293 {
14294 pRenderer->DrawTextureTransparent(
14295 a2a + 544,
14296 v4,
14297 (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
14298 pRenderer->DrawTextureTransparent(
14299 a2a + 544,
14300 v22,
14301 (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
14302 }
14303 }
14304 v9 = v4 + 32;
14305 if ( (signed int)uHeight > 64 )
14306 {
14307 pRenderer->Clip(a2a, v9, a4, a5a);
14308 pRenderer->DrawTextureTransparent(
14309 a2a,
14310 v9,
14311 (Texture *)(uTextureID_5076A0 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A0] : 0));
14312 pRenderer->DrawTextureTransparent(
14313 a4 - 10,
14314 v9,
14315 (Texture *)(uTextureID_50769C != -1 ? &pIcons_LOD->pTextures[uTextureID_50769C] : 0));
14316 }
14317 pRenderer->ResetClip();
14318 }
14319 }
14320
14321
14322 //----- (00415485) --------------------------------------------------------
14323 char *__cdecl DrawCopyrightWindow()
14324 {
14325 GUIWindow Dst; // [sp+8h] [bp-54h]@1
14326
14327 memset(&Dst, 0, 0x54u);
14328 Dst.uFrameWidth = 624;
14329 Dst.uFrameHeight = 256;
14330 Dst.uFrameX = 8;
14331 Dst.uFrameY = 30; // c 1999 The 3DO Company.
14332 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
14333 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
14334 + 24;
14335 Dst.uFrameY = 470 - Dst.uFrameHeight;
14336 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
14337 Dst.uFrameW = 469;
14338 Dst.DrawMessageBox(0);
14339 Dst.uFrameWidth -= 24;
14340 Dst.uFrameX += 12;
14341 Dst.uFrameY += 12;
14342 Dst.uFrameHeight -= 12;
14343 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
14344 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
14345 return Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[157], 3u);
14346 }
14347
14348
14349
14350
14351 //----- (004156F0) --------------------------------------------------------
14352 void __cdecl GUI_UpdateWindows()
14353 {
14354 GUIWindow *pWindow; // esi@4
14355 unsigned int pWindowType; // eax@4
14356 int v2; // eax@10
14357 int v3; // eax@11
14358 int v4; // eax@12
14359 int v5; // eax@20
14360 int v6; // eax@21
14361 int v7; // eax@29
14362 int v8; // eax@30
14363 int v9; // eax@31
14364 void *v10; // eax@41
14365 int v11; // ecx@42
14366 int v12; // eax@48
14367 int v13; // eax@49
14368 int v14; // eax@57
14369 int v15; // eax@58
14370 int v16; // eax@59
14371 int v17; // eax@60
14372 int v18; // eax@61
14373 int v19; // eax@62
14374 void *v20; // ebp@66
14375 char *pHint; // edx@66
14376 GUIButton *pButtonPtr_1C; // ebp@79
14377 char *v23; // edx@80
14378 char v24; // zf@81
14379 //unsigned int v25; // eax@91
14380 int v26; // eax@98
14381 unsigned int v27; // ebp@106
14382 GUIWindow *pGUIWindow2; // ecx@109
14383 unsigned int v29; // eax@111
14384 GUIFont *pGUIFont; // ST1C_4@115
14385 int v31; // eax@115
14386 void *v32; // ebp@118
14387 int v33; // eax@119
14388 int v34; // eax@120
14389 int v35; // eax@121
14390 int v36; // eax@122
14391 int v37; // eax@123
14392 int v38; // eax@124
14393 int v39; // eax@129
14394 //char *v40; // edx@138
14395 unsigned int pNumMessages; // eax@142
14396 GUIButton *pGUIButton; // ebp@146
14397 //char *v43; // edx@146
14398 unsigned int pX; // [sp-1Ch] [bp-124h]@17
14399 unsigned int pY; // [sp-18h] [bp-120h]@17
14400 Texture *pTexture; // [sp-14h] [bp-11Ch]@17
14401 Texture *pTexture2; // [sp-14h] [bp-11Ch]@86
14402 int i; // [sp+0h] [bp-108h]@3
14403 ItemGen pItemGen; // [sp+4h] [bp-104h]@98
14404 GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133
14405 ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129
14406
14407 if (GetCurrentMenuID() != MENU_CREATEPARTY)
14408 sub_41CD4F(34);
14409 for ( i = 1; i <= uNumVisibleWindows; ++i )
14410 {
14411 //v0 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[i]];
14412 pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
14413 pWindowType = pWindow->eWindowType;
14414 switch (pWindow->eWindowType)
14415 {
14416 case WINDOW_MainMenu_Load:
14417 GameUI_MainMenu_DrawLoad();
14418 continue;
14419 case WINDOW_5E: // window that initiates savegame loading
14420 {
14421 if (pWindow->Hint != (char *)1)
14422 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14423 auto pGUIButton3 = (GUIButton *)pWindow->ptr_1C;
14424 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton3->pTextures[0]);
14425 pHint = pWindow->Hint;
14426 viewparams->bRedrawGameUI = 1;
14427 if ( pHint && pHint != (char *)1 )
14428 pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0);
14429 pWindow->Release();
14430 if (pCurrentScreen == 11)//îêíî ñîõðàíåíèÿ èãðû
14431 pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0);
14432 else
14433 pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
14434 }
14435 continue;
14436 }
14437 if ( (signed int)pWindowType > 70 )
14438 {
14439 if ( (signed int)pWindowType > 95 )
14440 {
14441 v33 = pWindowType - 96;
14442 if ( !v33 )
14443 {
14444 if ( pWindow->Hint != (char *)1 )
14445 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14446 pGUIButton = (GUIButton *)pWindow->ptr_1C;
14447 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]);
14448 pHint = pWindow->Hint;
14449 viewparams->bRedrawGameUI = 1;
14450 if ( pHint && pHint != (char *)1 )
14451 pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
14452 pWindow->Release();
14453 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
14454 continue;
14455 pNumMessages = pMessageQueue_50CBD0->uNumMessages;
14456 //LABEL_151:
14457 pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
14458 //LABEL_152:
14459 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14460 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14461 ++pMessageQueue_50CBD0->uNumMessages;
14462 continue;
14463 }
14464 v34 = v33 - 1;
14465 if ( v34 )
14466 {
14467 v35 = v34 - 1;
14468 if ( v35 )
14469 {
14470 v36 = v35 - 1;
14471 if ( v36 )
14472 {
14473 v37 = v36 - 4;
14474 if ( v37 )
14475 {
14476 v38 = v37 - 2;
14477 if ( v38 )
14478 {
14479 if ( v38 == 1 )
14480 GameMenuUI_DrawVideoOptions();
14481 }
14482 else
14483 {
14484 GameMenuUI_DrawKeyBindings();
14485 }
14486 }
14487 else
14488 {
14489 pWindow->DrawMessageBox(0);
14490 pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
14491 pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
14492 if ( !pKeyActionMap->field_204 )
14493 {
14494 ItemGen2.Reset();
14495 pWindow->Release();
14496 pEventTimer->Resume();
14497 pCurrentScreen = 0;
14498 viewparams->bRedrawGameUI = 1;
14499 v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
14500 if ( v39 > 0 )
14501 {
14502 if ( v39 < 800 )
14503 SpawnActor(v39);
14504 }
14505 }
14506 }
14507 continue;
14508 }
14509 pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);
14510 pY = pWindow->uFrameY;
14511 pX = pWindow->uFrameX;
14512 //LABEL_18:
14513 pRenderer->DrawTextureIndexed(pX, pY, pTexture);
14514 //LABEL_114:
14515 viewparams->bRedrawGameUI = 1;
14516 continue;
14517 }
14518 memset(&GUIButton2, 0, 0xBCu);
14519 GUIButton2.uZ = 197;
14520 GUIButton2.uW = 197;
14521 GUIButton2.uX = 27;
14522 GUIButton2.uY = 161;
14523 GUIButton2.uWidth = 171;
14524 GUIButton2.uHeight = 37;
14525 GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
14526 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14527 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
14528 viewparams->bRedrawGameUI = 1;
14529 GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Îòäûõ è ëå÷åíèå 8 ÷àñîâ
14530 GUIButton2.pParent = 0;
14531 //goto LABEL_134;
14532 pGUIWindow2 = pWindow;
14533 //goto LABEL_110;
14534 pGUIWindow2->Release();
14535 continue;
14536 }
14537 if ( pWindow->Hint != (char *)1 )
14538 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14539 v32 = pWindow->ptr_1C;
14540 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
14541 goto LABEL_138;
14542 }
14543 if ( pWindowType == 95 )
14544 {
14545 if ( pWindow->Hint != (char *)1 )
14546 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14547 v32 = pWindow->ptr_1C;
14548 pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15));
14549 LABEL_138:
14550 pHint = pWindow->Hint;
14551 viewparams->bRedrawGameUI = 1;
14552 if ( pHint && pHint != (char *)1 )
14553 ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
14554 pWindow->Release();
14555 LABEL_142:
14556 pNumMessages = pMessageQueue_50CBD0->uNumMessages;
14557 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
14558 //goto LABEL_151;
14559 {
14560 pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
14561 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14562 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14563 ++pMessageQueue_50CBD0->uNumMessages;
14564 continue;
14565 }
14566 continue;
14567 }
14568 v14 = pWindowType - 80;
14569 if ( v14 )
14570 {
14571 v15 = v14 - 9;
14572 if ( !v15 )
14573 {
14574 pWindow->DrawMessageBox(0);
14575 pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
14576 pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
14577 if ( !pKeyActionMap->field_204 )
14578 {
14579 pItemGen.Reset();
14580 pWindow->Release();
14581 pEventTimer->Resume();
14582 pCurrentScreen = 0;
14583 viewparams->bRedrawGameUI = 1;
14584 v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
14585 if ( v26 > 0 )
14586 {
14587 if ( v26 < 800 )
14588 {
14589 pItemGen.uAttributes |= 1u;
14590 pItemGen.uItemID = v26;
14591 if ( pItemsTable->pItems[v26].uEquipType == 12 )
14592 {
14593 pItemGen.uNumCharges = rand() % 6 + pItemsTable->pItems[pItemGen.uItemID].uDamageMod + 1;
14594 pItemGen.uMaxCharges = LOBYTE(pItemGen.uNumCharges);
14595 }
14596 else
14597 {
14598 if ( v26 >= 221 && v26 < 271 )
14599 pItemGen._bonus_type = rand() % 10 + 1;
14600 }
14601 pItemsTable->SetSpecialBonus(&pItemGen);
14602 pParty->SetHoldingItem(&pItemGen);
14603 }
14604 }
14605 }
14606 continue;
14607 }
14608 v16 = v15 - 1;
14609 if ( !v16 )
14610 {
14611 if ( pWindow->Hint != (char *)1 )
14612 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14613 pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
14614 if ( (pButtonPtr_1C->uX /*& 0x80000000u*/) == 0 )
14615 {
14616 if ( (signed int)pButtonPtr_1C->uX <= 640 )
14617 {
14618 //v25 = pButtonPtr_1C->uY;
14619 if ( (pButtonPtr_1C->uY /*& 0x80000000u*/) == 0 )
14620 {
14621 if ( (signed int)pButtonPtr_1C->uY <= 480 )
14622 {
14623 pTexture2 = pButtonPtr_1C->pTextures[0];
14624 goto LABEL_94;
14625 }
14626 }
14627 }
14628 }
14629 v23 = pWindow->Hint;
14630 viewparams->bRedrawGameUI = 1;
14631 if ( v23 )
14632 {
14633 v24 = v23 == (char *)1;
14634 goto LABEL_82;
14635 }
14636 //LABEL_134:
14637 pGUIWindow2 = pWindow;
14638 //goto LABEL_110;
14639 pGUIWindow2->Release();
14640 continue;
14641 }
14642 v17 = v16 - 1;
14643 if ( !v17 )
14644 {
14645 if ( pWindow->Hint != (char *)1 )
14646 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14647 pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
14648 pTexture2 = pButtonPtr_1C->pTextures[1];
14649 LABEL_94:
14650 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
14651 LABEL_80:
14652 v23 = pWindow->Hint;
14653 viewparams->bRedrawGameUI = 1;
14654 if ( v23 )
14655 {
14656 v24 = v23 == (char *)1;
14657 LABEL_82:
14658 if ( !v24 )
14659 pButtonPtr_1C->DrawLabel(v23, pFontCreate, 0, 0);
14660 }
14661 //goto LABEL_134;
14662 pGUIWindow2 = pWindow;
14663 //goto LABEL_110;
14664 pGUIWindow2->Release();
14665 continue;
14666 }
14667 v18 = v17 - 1;
14668 if ( !v18 )
14669 {
14670 if ( pWindow->Hint != (char *)1 )
14671 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14672 pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
14673 pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButtonPtr_1C->pTextures[0]);
14674 goto LABEL_80;
14675 }
14676 v19 = v18 - 1;
14677 if ( !v19 )
14678 {
14679 if ( pWindow->Hint != (char *)1 )
14680 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14681 pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16));
14682 viewparams->bRedrawGameUI = 1;
14683 //goto LABEL_134;
14684 pGUIWindow2 = pWindow;
14685 //goto LABEL_110;
14686 pGUIWindow2->Release();
14687 continue;
14688 }
14689 }
14690 else
14691 {
14692 v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14693 if ( ptr_507BD0->field_40 == 1 )
14694 {
14695 ptr_507BD0->DrawMessageBox(0);
14696 ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
14697 pGUIFont = pFontCreate;
14698 v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
14699 ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pGUIFont);
14700 continue;
14701 }
14702 if ( ptr_507BD0->field_40 == 2 )
14703 {
14704 v29 = pMessageQueue_50CBD0->uNumMessages;
14705 pWindow->field_40 = 0;
14706 if ( (signed int)v29 < 40 )
14707 {
14708 pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
14709 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14710 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14711 ++pMessageQueue_50CBD0->uNumMessages;
14712 }
14713 pEventTimer->Resume();
14714 ptr_507BD0->Release();
14715 pCurrentScreen = 0;
14716 //goto LABEL_114;
14717 viewparams->bRedrawGameUI = 1;
14718 continue;
14719 }
14720 if ( ptr_507BD0->field_40 == 3 )
14721 {
14722 pWindow->field_40 = 0;
14723 pEventTimer->Resume();
14724 pGUIWindow2 = ptr_507BD0;
14725 //LABEL_110:
14726 pGUIWindow2->Release();
14727 continue;
14728 }
14729 }
14730 }
14731 else
14732 {
14733 if ( pWindowType == 70 )
14734 {
14735 sub_41420D_press_esc();
14736 continue;
14737 }
14738 if ( (signed int)pWindowType > 18 )
14739 {
14740 if ( (signed int)pWindowType > 25 )
14741 {
14742 v12 = pWindowType - 26;
14743 if ( v12 )
14744 {
14745 v13 = v12 - 4;
14746 if ( v13 )
14747 {
14748 if ( v13 == 1 )
14749 {
14750 pRenderer->ClearZBuffer(0, 479);
14751 draw_leather();
14752 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
14753 CharacterUI_DrawPaperdoll(uActiveCharacter);
14754 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
14755 (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
14756 }
14757 }
14758 else
14759 {
14760 sub_467FB6();
14761 }
14762 }
14763 else
14764 {
14765 TransitionUI_Draw();
14766 }
14767 continue;
14768 }
14769 if ( pWindowType != 25 )
14770 {
14771 v7 = pWindowType - 19;
14772 if ( v7 )
14773 {
14774 v8 = v7 - 1;
14775 if ( v8 )
14776 {
14777 v9 = v8 - 3;
14778 if ( v9 )
14779 {
14780 //if ( v9 == 1 )
14781 // sub_4606F7();
14782 }
14783 else
14784 {
14785 sub_4606FE();
14786 }
14787 }
14788 else
14789 {
14790 if ( pCurrentScreen == 10 )
14791 {
14792 Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
14793 }
14794 else
14795 {
14796 if ( pCurrentScreen == 15 )
14797 {
14798 pRenderer->ClearZBuffer(0, 479);
14799 draw_leather();
14800 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
14801 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
14802 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
14803 }
14804 }
14805 }
14806 }
14807 else
14808 {
14809 DrawBranchlessDialogueUI();
14810 }
14811 continue;
14812 }
14813 pWindowList[pVisibleWindowsIdxs[i] - 1]._4B3157();
14814 if ( !ptr_507BC0 )
14815 continue;
14816 v10 = ptr_507BC0->ptr_1C;
14817 if ( (signed int)v10 >= 53 )
14818 continue;
14819 v11 = pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1];
14820 if ( !__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * (_DWORD)v10])
14821 || v11 < SHIDWORD(pParty->uTimePlayed)
14822 || v11 <= SHIDWORD(pParty->uTimePlayed)
14823 && (unsigned int)pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] <= LODWORD(pParty->uTimePlayed) )
14824 {
14825 if ( (signed int)v10 < 53 )
14826 {
14827 pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] = 0;
14828 pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1] = 0;
14829 }
14830 continue;
14831 }
14832 goto LABEL_142;
14833 }
14834 if ( pWindowType == 18 )
14835 {
14836 sub_412B58();
14837 }
14838 else
14839 {
14840 if ( (signed int)pWindowType > 10 )
14841 {
14842 v5 = pWindowType - 12;
14843 if ( v5 )
14844 {
14845 v6 = v5 - 4;
14846 if ( v6 )
14847 {
14848 if ( v6 == 1 )
14849 TravelUI_Draw();
14850 }
14851 else
14852 {
14853 RestUI_Draw();
14854 }
14855 }
14856 else
14857 {
14858 QuickRefDraw();
14859 }
14860 continue;
14861 }
14862 if ( pWindowType != 10 )
14863 {
14864 v2 = pWindowType - 3;
14865 if ( v2 )
14866 {
14867 v3 = v2 - 1;
14868 if ( v3 )
14869 {
14870 v4 = v3 - 2;
14871 if ( v4 )
14872 {
14873 if ( v4 == 3 )
14874 DrawSpellbook((unsigned int)pWindow->ptr_1C);
14875 }
14876 else
14877 {
14878 sub_414F82_DrawGameOptions();
14879 }
14880 }
14881 else
14882 {
14883 CharacterUI_CharacterScreen_Draw(uActiveCharacter);
14884 }
14885 continue;
14886 }
14887 pTexture = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);
14888 pY = pViewport->uViewportY;
14889 pX = pViewport->uViewportX;
14890 //goto LABEL_18;
14891 pRenderer->DrawTextureIndexed(pX, pY, pTexture);
14892 viewparams->bRedrawGameUI = 1;
14893 continue;
14894 }
14895 DrawDialogueUI();
14896 }
14897 }
14898 }
14899 if ( GetCurrentMenuID() == -1 )
14900 GameUI_DrawFoodAndGold();
14901 if ( sub_4637E0_is_there_popup_onscreen() )
14902 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
14903 }
14904
14905 //----- (00416196) --------------------------------------------------------
14906 void __cdecl identify_item()
14907 {
14908 Player *v0; // esi@2
14909 POINT *v1; // edi@2
14910 signed int v2; // ecx@5
14911 signed int v3; // eax@5
14912 int v4; // eax@5
14913 char v5; // sf@5
14914 int v6; // eax@5
14915 int v7; // eax@7
14916 unsigned __int16 v8; // ax@10
14917 int v9; // edi@10
14918 int v10; // eax@10
14919 int v11; // edx@13
14920 LONG v12; // edx@23
14921 signed int v13; // edx@23
14922 int v14; // edx@25
14923 unsigned int v15; // edi@25
14924 signed int v16; // edx@27
14925 int v17; // eax@54
14926 unsigned int v18; // edx@57
14927 int v19; // eax@65
14928 int v20; // edi@67
14929 int v21; // eax@72
14930 int v22; // ecx@74
14931 int v23; // edx@78
14932 int v24; // eax@79
14933 int v25; // eax@80
14934 int v26; // eax@84
14935 ItemGen *v27; // esi@98
14936 unsigned int v28; // eax@98
14937 ItemGen *v29; // edi@98
14938 unsigned int v30; // ecx@103
14939 double v31; // st7@112
14940 unsigned __int64 v32; // qax@113
14941 unsigned int v33; // ecx@117
14942 int v34; // eax@126
14943 unsigned int v35; // ecx@127
14944 double v36; // st7@132
14945 signed __int64 v37; // qax@135
14946 unsigned int v38; // eax@138
14947 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
14948 int *v40; // [sp-Ch] [bp-9Ch]@83
14949 int *v41; // [sp-8h] [bp-98h]@83
14950 int *v42; // [sp-4h] [bp-94h]@83
14951 GUIWindow v43; // [sp+Ch] [bp-84h]@137
14952 unsigned int pY; // [sp+60h] [bp-30h]@2
14953 int v45; // [sp+64h] [bp-2Ch]@10
14954 unsigned int pX; // [sp+68h] [bp-28h]@2
14955 int v47; // [sp+6Ch] [bp-24h]@25
14956 POINT y; // [sp+70h] [bp-20h]@2
14957 POINT a2; // [sp+78h] [bp-18h]@2
14958 Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
14959 unsigned int v51; // [sp+8Ch] [bp-4h]@23
14960
14961 if ( dword_50CDCC )
14962 return;
14963 v0 = pPlayers[uActiveCharacter];
14964 v1 = pMouse->GetCursorPos(&a2);
14965 pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF;
14966 pMouse->GetClickPos(&pX, &pY);
14967 if ( !pOut.z )
14968 {
14969 if ( (signed int)pX <= 13
14970 || (signed int)pX >= 462
14971 || (v2 = pX - 14,
14972 v3 = pY - 17,
14973 pX = v2,
14974 pY = v3,
14975 v4 = 14 * (v3 >> 5),
14976 v2 >>= 5,
14977 v5 = v2 + v4 < 0,
14978 v6 = v2 + v4,
14979 pOut.z = v6,
14980 v5)
14981 || v6 > 126
14982 || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 )
14983 return;
14984 pOut.z = v7;
14985 }
14986 if ( !v0->CanAct() )
14987 {
14988 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]);
14989 v43.Hint = pTmpBuf;
14990 v43.uFrameWidth = 384;
14991 v43.uFrameHeight = 180;
14992 v43.uFrameY = 40;
14993 if ( pMouse->GetCursorPos(&a2)->x <= 320 )
14994 v38 = pMouse->GetCursorPos(&a2)->x + 30;
14995 else
14996 v38 = pMouse->GetCursorPos(&a2)->x - 414;
14997 v43.uFrameX = v38;
14998 v43.DrawMessageBox(0);
14999 return;
15000 }
15001 --pOut.z;
15002 LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
15003 v9 = v8 & 0x3F;
15004 v45 = v8 & 0x3F;
15005 pOut.y = SkillToMastery(v8);
15006 v10 = pOut.z;
15007 if ( pParty->pPickedItem.uItemID == 220 )
15008 {
15009 LABEL_116:
15010 GameUI_DrawItemInfo(&v0->pInventoryItems[v10]);
15011 return;
15012 }
15013 if ( (signed int)pParty->pPickedItem.uItemID < 200
15014 || (signed int)pParty->pPickedItem.uItemID > 219
15015 || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) )
15016 {
15017 if ( (signed int)pParty->pPickedItem.uItemID < 221
15018 || (signed int)pParty->pPickedItem.uItemID > 271
15019 || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221)
15020 || v13 > 271 )
15021 {
15022 if ( pParty->pPickedItem.uItemID != 236
15023 && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250)
15024 && pParty->pPickedItem.uItemID != 263
15025 && pParty->pPickedItem.uItemID != 233 )
15026 goto LABEL_116;
15027 v27 = &v0->pInventoryItems[pOut.z];
15028 v28 = v27->uItemID;
15029 v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
15030 v29 = (ItemGen *)(1800 * pParty->pPickedItem._bonus_type);
15031 if ( pParty->pPickedItem.uItemID != 233 )
15032 {
15033 if ( pParty->pPickedItem.uItemID == 236 )
15034 {
15035 v35 = v27->uAttributes;
15036 if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
15037 goto LABEL_92;
15038 LOWORD(v35) = v35 | 0x210;
15039 v27->uAttributes = v35;
15040 }
15041 else
15042 {
15043 if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
15044 goto LABEL_92;
15045 if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
15046 {
15047 v27->UpdateTempBonus(pParty->uTimePlayed);
15048 v33 = v27->uItemID;
15049 if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65
15050 || (pOut.y = v27->uAttributes, pOut.y & 2)
15051 || v27->uAdditionalValue
15052 || v27->_bonus_type
15053 || v51 && v51 != 1 && v51 != 2
15054 || (signed int)v33 >= 500 )
15055 goto LABEL_92;
15056 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
15057 a2.y = (int)v29 << 7;
15058 v31 = (double)(signed int)((int)v29 << 7);
15059 v27->uAdditionalValue = v34;
15060 }
15061 else
15062 {
15063 if ( pParty->pPickedItem.uItemID != 263
15064 || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64)
15065 && (signed int)v30 <= 65
15066 || (pOut.y = v27->uAttributes, pOut.y & 2)
15067 || v27->uAdditionalValue
15068 || v27->_bonus_type
15069 || v51 && v51 != 1 && v51 != 2
15070 || (signed int)v30 >= 500 )
15071 goto LABEL_92;
15072 a2.y = (int)v29 << 7;
15073 v27->uAdditionalValue = 40;
15074 v31 = (double)a2.y;
15075 }
15076 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
15077 LODWORD(v27->uExpireTime) = v32;
15078 LODWORD(v32) = pOut.y;
15079 LOBYTE(v32) = LOBYTE(pOut.y) | 0x18;
15080 HIDWORD(v27->uExpireTime) = HIDWORD(v32);
15081 v27->uAttributes = v32;
15082 }
15083 dword_50C9A8 = 256;
15084 goto LABEL_92;
15085 }
15086 v36 = (70.0 - (double)pParty->pPickedItem._bonus_type) * 0.01;
15087 if ( v36 < 0.0 )
15088 v36 = 0.0;
15089 if ( v51 != 12 )
15090 {
15091 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
15092 return;
15093 }
15094 a2.y = v27->uMaxCharges;
15095 v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
15096 v27->uMaxCharges = v37;
15097 v27->uNumCharges = (unsigned __int8)v37;
15098 goto LABEL_92;
15099 }
15100 v14 = v13 - 222;
15101 v15 = pParty->pPickedItem.uItemID - 222;
15102 v47 = v14;
15103 y.y = 0;
15104 if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 )
15105 {
15106 v16 = 5;
15107 }
15108 else
15109 {
15110 v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388];
15111 v10 = pOut.z;
15112 }
15113 v51 = v16;
15114 if ( v45 )
15115 {
15116 if ( v16 < 225 || v16 > 227 )
15117 {
15118 if ( v16 < 228 || v16 > 239 )
15119 {
15120 if ( v16 < 240 || v16 > 261 )
15121 {
15122 if ( v16 >= 262 && pOut.y != 4 )
15123 {
15124 LABEL_53:
15125 v51 = 4;
15126 goto LABEL_54;
15127 }
15128 }
15129 else
15130 {
15131 if ( pOut.y <= 2 )
15132 {
15133 LABEL_38:
15134 v51 = 3;
15135 goto LABEL_54;
15136 }
15137 }
15138 }
15139 else
15140 {
15141 if ( pOut.y == 1 )
15142 {
15143 LABEL_35:
15144 v51 = 2;
15145 goto LABEL_54;
15146 }
15147 }
15148 }
15149 }
15150 else
15151 {
15152 if ( v16 >= 225 && v16 <= 227 )
15153 {
15154 v51 = 1;
15155 goto LABEL_54;
15156 }
15157 if ( v16 >= 228 && v16 <= 239 )
15158 goto LABEL_35;
15159 if ( v16 >= 240 && v16 <= 261 )
15160 goto LABEL_38;
15161 if ( v16 >= 262 )
15162 goto LABEL_53;
15163 }
15164 LABEL_54:
15165 pOut.y = 0;
15166 pOut.x = v10 + 1;
15167 v17 = (int)v0->pInventoryIndices;
15168 while ( *(int *)v17 != pOut.x )
15169 {
15170 ++pOut.y;
15171 v17 += 4;
15172 if ( pOut.y >= 126 )
15173 {
15174 v18 = y.y;
15175 goto LABEL_59;
15176 }
15177 }
15178 v18 = pOut.y;
15179 LABEL_59:
15180 if ( !v51 )
15181 {
15182 LABEL_115:
15183 v10 = pOut.z;
15184 goto LABEL_116;
15185 }
15186 if ( v51 == 1 )
15187 {
15188 v0->RemoveItemAtInventoryIndex(v18);
15189 v26 = rand();
15190 v0->ReceiveDamage(v26 % 11 + 10, 0);
15191 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
15192 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15193 {
15194 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
15195 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
15196 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15197 ++pMessageQueue_50CBD0->uNumMessages;
15198 }
15199 v42 = (int *)&a2.y;
15200 v41 = (int *)&y.y;
15201 v40 = (int *)&pOut;
15202 v39.z = pParty->vPosition.z + pParty->sEyelevel;
15203 }
15204 else
15205 {
15206 if ( v51 == 2 )
15207 {
15208 v0->RemoveItemAtInventoryIndex(v18);
15209 v25 = rand();
15210 v0->ReceiveDamage(v25 % 71 + 30, 0);
15211 v23 = 1;
15212 }
15213 else
15214 {
15215 if ( v51 == 3 )
15216 {
15217 v0->RemoveItemAtInventoryIndex(v18);
15218 v24 = rand();
15219 v0->ReceiveDamage(v24 % 201 + 50, 0);
15220 v23 = 5;
15221 }
15222 else
15223 {
15224 if ( v51 != 4 )
15225 {
15226 if ( v51 != 5 )
15227 {
15228 v19 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
15229 if ( v19 )
15230 *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
15231 v20 = v47 + 50 * v15;
15232 v0->pInventoryItems[pOut.z].uItemID = v51;
15233 v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type
15234 + v0->pInventoryItems[pOut.z]._bonus_type)
15235 / 2;
15236 v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->field_10168[2 * v20 + 388]);
15237 LABEL_74:
15238 v22 = (int)((char *)v0 + 36 * pOut.z);
15239 if ( !BYTE2(pItemsTable->pItems[*(int *)(v22 + 532) + 1].uItemID) )
15240 *(int *)(v22 + 552) |= 1u;
15241 if ( !dword_4E455C )
15242 goto LABEL_92;
15243 v0->PlaySound(16, 0);
15244 goto LABEL_91;
15245 }
15246 if ( v45 )
15247 {
15248 if ( *(int *)(a2.y + 532) == 221 )
15249 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
15250 else
15251 *(int *)(a2.y + 536) = pParty->pPickedItem._bonus_type;
15252 v21 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
15253 if ( v21 )
15254 *(int *)&v0->field_1F5[36 * v21 + 15] = 1;
15255 goto LABEL_74;
15256 }
15257 goto LABEL_115;
15258 }
15259 v0->RemoveItemAtInventoryIndex(v18);
15260 v0->SetCondition(0x10u, 0);
15261 v23 = 0;
15262 }
15263 }
15264 v0->_4160CA(v23);
15265 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
15266 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15267 {
15268 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
15269 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
15270 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15271 ++pMessageQueue_50CBD0->uNumMessages;
15272 }
15273 v42 = (int *)&a2.y;
15274 v41 = (int *)&y.y;
15275 v40 = (int *)&pOut;
15276 v39.z = pParty->vPosition.z + pParty->sEyelevel;
15277 }
15278 *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
15279 Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
15280 sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0);
15281 if ( dword_4E455C )
15282 {
15283 if ( v0->CanAct() )
15284 v0->PlaySound(17, 0);
15285 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
15286 LABEL_91:
15287 dword_4E455C = 0;
15288 }
15289 LABEL_92:
15290 pMouse->RemoveHoldingItem();
15291 dword_50CDCC = 1;
15292 return;
15293 }
15294 *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
15295 switch ( pParty->pPickedItem.uItemID )
15296 {
15297 case 0xC8u:
15298 case 0xC9u:
15299 case 0xCAu:
15300 case 0xCBu:
15301 case 0xCCu:
15302 v0->pInventoryItems[pOut.z].uItemID = 222;
15303 break;
15304 case 0xCDu:
15305 case 0xCEu:
15306 case 0xCFu:
15307 case 0xD0u:
15308 case 0xD1u:
15309 v0->pInventoryItems[pOut.z].uItemID = 223;
15310 break;
15311 case 0xD2u:
15312 case 0xD3u:
15313 case 0xD4u:
15314 case 0xD5u:
15315 case 0xD6u:
15316 v0->pInventoryItems[pOut.z].uItemID = 224;
15317 break;
15318 case 0xD7u:
15319 case 0xD8u:
15320 case 0xD9u:
15321 case 0xDAu:
15322 case 0xDBu:
15323 v0->pInventoryItems[pOut.z].uItemID = 221;
15324 break;
15325 default:
15326 break;
15327 }
15328 pMouse->RemoveHoldingItem();
15329 dword_50CDCC = 1;
15330 if ( dword_4E455C )
15331 {
15332 v0->PlaySound(16, 0);
15333 dword_4E455C = 0;
15334 }
15335 }
15336
15337
15338 //----- (00416B01) --------------------------------------------------------
15339 void __thiscall sub_416B01(void *_this)
15340 {
15341 int v1; // edi@2
15342 int v2; // ecx@2
15343 NPCData *v3; // eax@2
15344 NPCData *v4; // esi@7
15345 NPCData *v5; // eax@16
15346 NPCData *v6; // esi@16
15347 const CHAR *v7; // eax@18
15348 unsigned int v8; // eax@25
15349 unsigned int v9; // eax@25
15350 const char *v10; // ST14_4@26
15351 char *v11; // esi@26
15352 const char *v12; // ST18_4@27
15353 unsigned __int16 v13; // ax@28
15354 char *v14; // eax@28
15355 GUIWindow a1; // [sp+Ch] [bp-60h]@23
15356 int a2; // [sp+60h] [bp-Ch]@16
15357 void *v17; // [sp+64h] [bp-8h]@1
15358 LPCSTR lpsz; // [sp+68h] [bp-4h]@6
15359
15360 v17 = _this;
15361 if ( bNoNPCHiring != 1 )
15362 {
15363 v1 = 0;
15364 v2 = 0;
15365 v3 = pParty->pHirelings;
15366 do
15367 {
15368 if ( v3->pName )
15369 pTmpBuf[v1++] = v2;
15370 ++v3;
15371 ++v2;
15372 }
15373 while ( (signed int)v3 < (signed int)&pParty->pPickedItem );
15374 lpsz = 0;
15375 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
15376 {
15377 v4 = pNPCStats->pNewNPCData;
15378 do
15379 {
15380 if ( v4->uFlags & 0x80
15381 && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName))
15382 && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) )
15383 pTmpBuf[v1++] = (char)lpsz + 2;
15384 ++lpsz;
15385 ++v4;
15386 }
15387 while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );
15388 }
15389 if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
15390 {
15391 uDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
15392 v5 = GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&a2);
15393 v6 = v5;
15394 if ( v5 )
15395 {
15396 if ( a2 == 57 )
15397 v7 = pNPCTopics[512].pText;
15398 else
15399 v7 = (const CHAR *)*(&pNPCStats->field_13A5C + 5 * v5->uProfession);
15400 lpsz = v7;
15401 if ( !v7 )
15402 {
15403 lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
15404 if ( !lpsz )
15405 lpsz = "";
15406 }
15407 a1.Hint = 0;
15408 a1.uFrameX = 38;
15409 a1.uFrameY = 60;
15410 a1.uFrameWidth = 276;
15411 a1.uFrameZ = 313;
15412 a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0)
15413 + 2 * LOBYTE(pFontArrus->uFontHeight)
15414 + 24;
15415 if ( (signed int)a1.uFrameHeight < 130 )
15416 a1.uFrameHeight = 130;
15417 a1.uFrameWidth = 400;
15418 a1.uFrameZ = a1.uFrameX + 399;
15419 a1.DrawMessageBox(0);
15420 sprintf(pTmpBuf2, "NPC%03d", v6->uPortraitID);
15421 v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE);
15422 pRenderer->DrawTextureIndexed(
15423 a1.uFrameX + 22,
15424 a1.uFrameY + 36,
15425 (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
15426 v9 = v6->uProfession;
15427 if ( v9 )
15428 {
15429 v10 = v6->pName;
15430 v11 = pTmpBuf;
15431 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]);
15432 }
15433 else
15434 {
15435 v12 = v6->pName;
15436 v11 = pTmpBuf;
15437 strcpy(pTmpBuf, v12);
15438 }
15439 v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
15440 a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u);
15441 a1.uFrameWidth -= 24;
15442 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
15443 v14 = sub_495461((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0);
15444 a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0);
15445 }
15446 }
15447 }
15448 }
15449
15450
15451 //----- (00416D62) --------------------------------------------------------
15452 void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(Vec2_int_ *_this)
15453 {
15454 signed int pPlayerNum; // eax@12
15455 char *v2; // eax@32
15456 void *v3; // ecx@52
15457 unsigned int v4; // eax@59
15458 int v5; // esi@62
15459 signed int v6; // esi@64
15460 signed int v7; // esi@69
15461 ItemGen *v8; // ecx@70
15462 unsigned int v9; // eax@72
15463 unsigned int v10; // eax@76
15464 char v11; // zf@83
15465 GUIButton *pButton; // esi@84
15466 unsigned int v13; // ecx@85
15467 char *pStr; // edi@85
15468 signed int pControlID; // eax@92
15469 int v16; // eax@95
15470 int v17; // eax@96
15471 enum PLAYER_SKILL_TYPE v18; // eax@98
15472 char *pStr2; // eax@99
15473 unsigned int v20; // eax@108
15474 unsigned int pSkillId; // eax@109
15475 const char *pSkillInfo; // eax@111
15476 //char *v23; // ebx@112
15477 char *pHint; // edx@113
15478 unsigned int pColor; // eax@113
15479 GUIWindow pWindow; // [sp+4h] [bp-74h]@32
15480 double v27; // [sp+58h] [bp-20h]@33
15481 struct tagPOINT Point; // [sp+60h] [bp-18h]@6
15482 char *v29; // [sp+68h] [bp-10h]@33
15483 float v30; // [sp+6Ch] [bp-Ch]@33
15484 unsigned int pX; // [sp+70h] [bp-8h]@3
15485 unsigned int pY; // [sp+74h] [bp-4h]@3
15486
15487 if ( pCurrentScreen == 16 )//îêíî âèäåî ðîëèêà
15488 return;
15489 if ( _this )
15490 {
15491 pX = _this->x;
15492 pY = _this->y;
15493 }
15494 else
15495 {
15496 pMouse->GetClickPos(&pX, &pY);
15497 }
15498 if ( pRenderer->bWindowMode )
15499 {
15500 GetCursorPos(&Point);
15501 ScreenToClient(hWnd, &Point);
15502 if ( Point.x < 1 || Point.y < 1 || Point.x > 638 || Point.y > 478 )
15503 {
15504 back_to_game();
15505 return;
15506 }
15507 }
15508 if ( pParty->pPickedItem.uItemID )//íàæàòèå íà ïîðòðåò ïåðñà ïðàâîé êíîïêîé ìûøè ñ ðàñòâîðîì
15509 {
15510 //v1 = 0;
15511 //do
15512 for ( pPlayerNum = 0; pPlayerNum < 4; ++pPlayerNum)
15513 {
15514 if ( (signed int)pX > RightClickPortraitXmin[pPlayerNum] && (signed int)pX < RightClickPortraitXmax[pPlayerNum]
15515 && (signed int)pY > 375 && (signed int)pY < 466 )
15516 {
15517 pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(pPlayerNum + 1, 1);
15518 return;
15519 }
15520 //++v1;
15521 }
15522 //while ( v1 < 4 );
15523 }
15524 pEventTimer->Pause();
15525 if ( pCurrentScreen <= 10 )
15526 {
15527 if ( pCurrentScreen == 10 )//îêíî ÿùèêà
15528 {
15529 __debugbreak();
15530 if ( !pPlayers[uActiveCharacter]->CanAct() )
15531 {
15532 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s íå â ñîñòîÿíèè %s
15533 pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Îïîçíàòü ïðåäìåòû
15534 pWindow.Hint = pTmpBuf;
15535 pWindow.uFrameWidth = 384;
15536 pWindow.uFrameHeight = 180;
15537 pWindow.uFrameY = 40;
15538 if ( (signed int)pX <= 320 )
15539 v10 = pX + 30;
15540 else
15541 v10 = pX - 414;
15542 pWindow.uFrameX = v10;
15543 pWindow.DrawMessageBox(0);
15544 goto LABEL_132;
15545 }
15546 v9 = pX + pSRZBufferLineOffsets[pY];
15547 if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) )
15548 goto LABEL_132;
15549 v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
15550 + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
15551 }
15552 else
15553 {
15554 if ( pCurrentScreen )
15555 {
15556 if ( pCurrentScreen != 3 )
15557 {
15558 if ( pCurrentScreen != 7 )
15559 {
15560 if ( pCurrentScreen == 8 )//îêíî êíèãè çàêëîâ
15561 {
15562 if ( dword_507B00_spell_info_to_draw_in_popup )
15563 DrawSpellDescriptionPopup((void *)(dword_507B00_spell_info_to_draw_in_popup - 1));
15564 }
15565 goto LABEL_132;
15566 }
15567 LABEL_119:
15568 if ( (signed int)pX > 467 && pCurrentScreen != 14 )
15569 {
15570 identify_item();
15571 goto LABEL_132;
15572 }
15573 if ( (signed int)pY >= 345 )
15574 goto LABEL_132;
15575 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats
15576 {
15577 CharacterUI_StatsTab_ShowHint();
15578 goto LABEL_132;
15579 }
15580 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills
15581 {
15582 CharacterUI_SkillsTab_ShowHint();
15583 goto LABEL_132;
15584 }
15585 v11 = pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103;//2DEvent - CharacerScreenInventory
15586 if ( !v11 )
15587 goto LABEL_132;
15588 identify_item();
15589 goto LABEL_132;
15590 }
15591 if ( !dword_506364
15592 || (signed int)pX < (signed int)pViewport->uViewportX
15593 || (signed int)pX > (signed int)pViewport->uViewportZ
15594 || (signed int)pY < (signed int)pViewport->uViewportY
15595 || (signed int)pY > (signed int)pViewport->uViewportW
15596 || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) )
15597 goto LABEL_132;
15598 v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
15599 v27 = v30 + 6.7553994e15;
15600 v29 = (char *)LODWORD(v27);
15601 pWindow.uFrameWidth = LODWORD(v27);
15602 pWindow.uFrameX = pX + 5;
15603 pWindow.uFrameY = pY + 5;
15604 pWindow.uFrameHeight = 64;
15605 pAudioPlayer->StopChannels(-1, -1);
15606 pWindow.DrawMessageBox(0);
15607 goto LABEL_132;
15608 }
15609 if (GetCurrentMenuID() > 0)
15610 goto LABEL_132;
15611
15612 if ( (signed int)pY > (signed int)pViewport->uViewportW )
15613 {
15614 pWindow.ptr_1C = (void *)((signed int)pX / 118);
15615 if ( (signed int)pX / 118 < 4 )
15616 {
15617 pWindow.Hint = 0;
15618 pWindow.uFrameWidth = 400;
15619 pWindow.uFrameHeight = 200;
15620 pWindow.uFrameX = 38;
15621 pWindow.uFrameY = 60;
15622 pAudioPlayer->StopChannels(-1, -1);
15623 pWindow.DrawQuickCharRecord();
15624 }
15625 goto LABEL_132;
15626 }
15627 if ( (signed int)pX > (signed int)pViewport->uViewportZ )
15628 {
15629 if ( (signed int)pY >= 130 )
15630 {
15631 if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
15632 {
15633 pWindow.Hint = 0;
15634 pWindow.uFrameWidth = 400;
15635 pWindow.uFrameHeight = 200;
15636 pWindow.uFrameX = 38;
15637 pWindow.uFrameY = 60;
15638 pAudioPlayer->StopChannels(-1, -1);
15639 pWindow._41D73D_draw_buff_tooltip();
15640 goto LABEL_132;
15641 }
15642 if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
15643 {
15644 if ( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 )
15645 goto LABEL_132;
15646 pAudioPlayer->StopChannels(-1, -1);
15647 v3 = (void *)1;
15648 }
15649 else
15650 {
15651 pAudioPlayer->StopChannels(-1, -1);
15652 v3 = 0;
15653 }
15654 sub_416B01(v3);
15655 goto LABEL_132;
15656 }
15657 pWindow.Hint = _4443D5_GetMinimapRightClickText();
15658 pWindow.uFrameWidth = 256;
15659 pWindow.uFrameX = 130;
15660 pWindow.uFrameY = 140;
15661 pWindow.uFrameHeight = 64;
15662 pAudioPlayer->StopChannels(-1, -1);
15663 pWindow.DrawMessageBox(0);
15664 goto LABEL_132;
15665 }
15666 pWindow.Hint = 0;
15667 pWindow.uFrameWidth = 320;
15668 pWindow.uFrameHeight = 320;
15669 v4 = pX - 350;
15670 if ( (signed int)pX <= 320 )
15671 v4 = pX + 30;
15672 pWindow.uFrameX = v4;
15673 pWindow.uFrameY = 40;
15674 if ( pRenderer->pRenderD3D )
15675 LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
15676 else
15677 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
15678 v6 = (unsigned __int16)v5;
15679 if ( (v6 & 7) != 2 )
15680 {
15681 if ( (v6 & 7) == 3 )
15682 {
15683 if ( pRenderer->uNumSceneBegins )
15684 {
15685 pWindow.DrawMessageBox(1);
15686 MonsterPopup_Draw(v6 >> 3, &pWindow);
15687 }
15688 else
15689 {
15690 pRenderer->BeginScene();
15691 pWindow.DrawMessageBox(1);
15692 MonsterPopup_Draw(v6 >> 3, &pWindow);
15693 pRenderer->EndScene();
15694 }
15695 }
15696 goto LABEL_132;
15697 }
15698 v7 = v6 >> 3;
15699 if ( pObjectList->pObjects[pLayingItems[v7].uObjectDescID].uFlags & 0x10 )
15700 goto LABEL_132;
15701 v8 = &pLayingItems[v7].stru_24;
15702 }
15703 GameUI_DrawItemInfo(v8);
15704 goto LABEL_132;
15705 }
15706 if ( pCurrentScreen == 13 )//îêíî äîìà
15707 {
15708 if ( (signed int)pY < 345 && (signed int)pX < 469 )
15709 sub_4B1A2D();
15710 goto LABEL_132;
15711 }
15712 if ( pCurrentScreen <= 13 )
15713 goto LABEL_132;
15714 if ( pCurrentScreen <= 15 )
15715 goto LABEL_119;
15716 if ( pCurrentScreen != 21 )
15717 {
15718 v11 = pCurrentScreen == 23;
15719 if ( !v11 )
15720 goto LABEL_132;
15721 identify_item();
15722 goto LABEL_132;
15723 }
15724 pWindow.Hint = 0;
15725 pStr = 0;
15726 for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext)
15727 {
15728 if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ
15729 && (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW )
15730 {
15731 pControlID = pButton->uControlID;
15732 switch ( pControlID )
15733 {
15734 case 0: //stats info
15735 pWindow.Hint = pAttributeDescriptions[(signed int)pButton->uControlParam % 7];
15736 pStr = aAttributeNames[(signed int)pButton->uControlParam % 7];
15737 break;
15738 case 62: //Plus button info
15739 pStr = pGlobalTXT_LocalizationStrings[670];//Äîáàâèòü
15740 pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Äîáàâëÿåò î÷êî ê âûäåëåííîìó íàâûêó, çàáèðàÿ åãî èç íàêîïèòåëÿ î÷êîâ"
15741 break;
15742 case 63: //Minus button info
15743 pStr = pGlobalTXT_LocalizationStrings[668];//Âû÷åñòü
15744 pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Âû÷èòàåò î÷êî èç âûäåëåííîãî íàâûêà, âîçâðàùàÿ åãî â íàêîïèòåëü î÷êîâ"
15745 break;
15746 case 64: //Available skill button info
15747 v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->uControlParam + 4);
15748 pStr = pSkillNames[v18];
15749 pWindow.Hint = pSkillDesc[v18];
15750 break;
15751 case 65: //Available Class Info
15752 pWindow.Hint = pClassDescriptions[pButton->uControlParam];
15753 pStr = pClassNames[pButton->uControlParam];
15754 break;
15755 case 66: //OK Info
15756 pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Ùåëêíèòå çäåñü äëÿ óòâåðæäåíèÿ ñîñòàâà îòðÿäà è ïðîäîëæåíèÿ èãðû.
15757 pStr = pGlobalTXT_LocalizationStrings[665];//Êíîïêà ÎÊ
15758 break;
15759 case 67: //Clear info
15760 pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Ñáðàñûâàåò âñå ïàðàìåòðû è íàâûêè îòðÿäà.
15761 pStr = pGlobalTXT_LocalizationStrings[667];//Êíîïêà Î÷èñòèòü
15762 break;
15763 case 118: // Character info
15764 pStr = pParty->pPlayers[pButton->uControlParam].pName;
15765 pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->uControlParam].uClass];
15766 break;
15767 }
15768 if ( pControlID > 68 && pControlID <= 75 ) //Sellected skills info
15769 {
15770 pSkillId = pParty->pPlayers[pButton->uControlParam].GetSkillIdxByOrder(pControlID - 72);
15771 pY = 0;
15772 if ( (signed int)pSkillId < 37 )
15773 {
15774 pSkillInfo = CharacterUI_GetSkillDescText(pButton->uControlParam, (enum PLAYER_SKILL_TYPE)pSkillId);
15775 strcpy(pTmpBuf2, pSkillInfo);
15776 pWindow.Hint = pTmpBuf2;
15777 pStr = pSkillNames[pSkillId];
15778 }
15779 }
15780 }
15781 }
15782 if ( pWindow.Hint )
15783 {
15784 pHint = pWindow.Hint;
15785 pWindow.Hint = 0;
15786 pWindow.uFrameWidth = 384;
15787 pWindow.uFrameHeight = 256;
15788 pWindow.uFrameX = 128;
15789 pWindow.uFrameY = 40;
15790 pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
15791 pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
15792 pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
15793 pWindow.DrawMessageBox(0);
15794 pWindow.uFrameX += 12;
15795 pWindow.uFrameWidth -= 24;
15796 pWindow.uFrameY += 12;
15797 pWindow.uFrameHeight -= 12;
15798 pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
15799 pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
15800 pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
15801 sprintf(pTmpBuf, pStr, pColor, format_4E2D80);//sprintfex äîëæåí áûòü - íå ðàáîòàåò sprintfex(pTmpBuf, format_4E2D80, v25, pStr)
15802 pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
15803 pWindow.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, pHint, 0, 0, 0);
15804 }
15805 LABEL_132:
15806 dword_507BF0_is_there_popup_onscreen = 1;
15807 viewparams->bRedrawGameUI = 1;
15808 }
15809
15810 //----- (004175C0) --------------------------------------------------------
15811 void __thiscall UI_OnMouseLeftClick(int *pXY)
15812 {
15813 int *pXY_; // esi@1
15814 signed int y; // eax@7
15815 signed int x; // ecx@7
15816 unsigned int v4; // eax@11
15817 signed int v5; // eax@17
15818 signed int v6; // esi@19
15819 int v7; // esi@30
15820 GUIWindow *v8; // edx@31
15821 GUIButton *i; // esi@37
15822 signed int v10; // eax@50
15823 int v11; // ecx@52
15824 unsigned int pX; // [sp+14h] [bp-8h]@7
15825 unsigned int pY; // [sp+18h] [bp-4h]@7
15826
15827 pXY_ = pXY;
15828 if ( pCurrentScreen == 16
15829 || sub_4637E0_is_there_popup_onscreen() )
15830 return;
15831 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
15832 {
15833 sub_4452BB();
15834 return;
15835 }
15836 if ( pXY_ )
15837 {
15838 x = *pXY_;
15839 y = pXY_[1];
15840 pX = *pXY_;
15841 pY = y;
15842 }
15843 else
15844 {
15845 pMouse->GetClickPos(&pX, &pY);
15846 y = pY;
15847 x = pX;
15848 }
15849 if ( pCurrentScreen
15850 || !dword_507B98_ctrl_pressed )
15851 goto LABEL_30;
15852 v4 = GetCurrentMenuID();
15853 x = pX;
15854 if ( (v4 & 0x80000000u) == 0
15855 || (signed int)pX < (signed int)pViewport->uViewportX
15856 || (signed int)pX > (signed int)pViewport->uViewportZ )
15857 {
15858 y = pY;
15859 LABEL_30:
15860 v7 = uNumVisibleWindows;
15861 if ( uNumVisibleWindows < 0 )
15862 return;
15863 while ( 1 )
15864 {
15865 //v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]];
15866 v8 = &pWindowList[pVisibleWindowsIdxs[v7] - 1];
15867 if ( x >= (signed int)v8->uFrameX )
15868 {
15869 if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW )
15870 break;
15871 }
15872 --v7;
15873 if ( v7 < 0 )
15874 return;
15875 }
15876 for ( i = v8->pControlsHead; ; i = i->pNext )
15877 {
15878 if ( !i )
15879 return;
15880 if ( i->uButtonType == 1 )
15881 goto LABEL_41;
15882 if ( i->uButtonType != 2 )
15883 break;
15884 if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth )
15885 goto LABEL_50;
15886 y = pY;
15887 x = pX;
15888 LABEL_45:
15889 ;
15890 }
15891 if ( i->uButtonType != 3 )
15892 goto LABEL_45;
15893 LABEL_41:
15894 if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW )
15895 {
15896 LABEL_50:
15897 i->field_2C = 1;
15898 v10 = pMessageQueue_50CBD0->uNumMessages;
15899 if ( pMessageQueue_50CBD0->uNumMessages )
15900 {
15901 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
15902 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
15903 }
15904 //v11 = i->uControlParam;
15905 pMessageQueue_50CBD0->SendMessage((UIMessageType)i->uControlID, i->uControlParam, 0);
15906 return;
15907 }
15908 goto LABEL_45;
15909 }
15910 y = pY;
15911 if ( (signed int)pY < (signed int)pViewport->uViewportY || (signed int)pY > (signed int)pViewport->uViewportW )
15912 goto LABEL_30;
15913 if ( pRenderer->pRenderD3D )
15914 v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
15915 else
15916 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
15917 v6 = (unsigned __int16)v5;
15918 if ( (v5 & 7) == 3
15919 && uActiveCharacter
15920 && v5 < 33554432
15921 && pPlayers[uActiveCharacter]->CanAct()
15922 && pPlayers[uActiveCharacter]->CanSteal() )
15923 {
15924 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15925 {
15926 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)27;
15927 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
15928 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15929 ++pMessageQueue_50CBD0->uNumMessages;
15930 }
15931 if ( pParty->bTurnBasedModeOn == 1 )
15932 {
15933 if ( pTurnEngine->field_4 == 3 )
15934 pTurnEngine->field_18 |= 8u;
15935 }
15936 }
15937 }
15938
15939
15940
15941 //----- (00417871) --------------------------------------------------------
15942 void __thiscall sub_417871(int *pXY)
15943 {
15944 POINT v1; // [sp+0h] [bp-18h]@5
15945 POINT a2; // [sp+8h] [bp-10h]@5
15946 unsigned int pY; // [sp+10h] [bp-8h]@3
15947 unsigned int pX; // [sp+14h] [bp-4h]@3
15948
15949 if ( !pRenderer->pRenderD3D )
15950 {
15951 if ( pXY )
15952 {
15953 pX = *pXY;
15954 pY = pXY[1];
15955 }
15956 else
15957 {
15958 pMouse->GetClickPos(&pX, &pY);
15959 }
15960 pMouse->GetCursorPos(&a2);
15961 pMouse->GetCursorPos(&v1);
15962 }
15963 }
15964
15965 //----- (004178C4) --------------------------------------------------------
15966 void __cdecl sub_4178C4()
15967 {
15968 if ( pArcomageGame->bGameInProgress == 1 )
15969 {
15970 if (pAsyncMouse)
15971 pArcomageGame->stru1.field_0 = 7;
15972 }
15973 }
15974
15975 //----- (004178E1) --------------------------------------------------------
15976 void __cdecl sub_4178E1()
15977 {
15978 if ( pArcomageGame->bGameInProgress == 1 )
15979 {
15980 if (pAsyncMouse)
15981 pArcomageGame->stru1.field_0 = 8;
15982 }
15983 }
15984
15985 //----- (004178FE) --------------------------------------------------------
15986 unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2)
15987 {
15988 unsigned __int16 v2; // dx@2
15989 unsigned __int16 v3; // cx@2
15990 int v5; // eax@5
15991 unsigned __int16 v6; // [sp-4h] [bp-8h]@2
15992
15993 if ( a1 <= a2 )
15994 {
15995 if ( a1 == a2 )
15996 return 0;
15997 v5 = 100 * a1 / a2;
15998 v3 = 255;
15999 if ( v5 >= 25 )
16000 {
16001 v6 = 100;
16002 v2 = 255;
16003 }
16004 else
16005 {
16006 v6 = 0;
16007 v2 = 0;
16008 }
16009 }
16010 else
16011 {
16012 v6 = 0;
16013 v2 = 255;
16014 v3 = 0;
16015 }
16016 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
16017 }
16018
16019 //----- (00417939) --------------------------------------------------------
16020 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx)
16021 {
16022 unsigned int v1; // ebx@1
16023 signed int v2; // edi@1
16024 unsigned int v3; // esi@1
16025 unsigned int v4; // eax@1
16026 unsigned int v6; // [sp+Ch] [bp-4h]@1
16027
16028 v1 = uConditionIdx;
16029 v2 = 65535;
16030 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
16031 v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
16032 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
16033 switch ( v1 )
16034 {
16035 case 0u:
16036 case 1u:
16037 case 3u:
16038 case 4u:
16039 case 5u:
16040 case 6u:
16041 case 7u:
16042 v2 = v4;
16043 break;
16044 case 2u:
16045 case 8u:
16046 case 9u:
16047 case 0xCu:
16048 case 0xDu:
16049 v2 = v3;
16050 break;
16051 case 0xAu:
16052 case 0xBu:
16053 case 0xEu:
16054 case 0xFu:
16055 case 0x10u:
16056 v2 = v6;
16057 break;
16058 default:
16059 return v2;
16060 }
16061 return v2;
16062 }
16063
16064 //----- (004179BC) --------------------------------------------------------
16065 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2)
16066 {
16067 const char *v2; // ebx@1
16068 const char *v3; // edi@1
16069 unsigned int v4; // eax@1
16070 GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1
16071 POINT v6; // [sp+60h] [bp-8h]@1
16072
16073 v2 = a2;
16074 v3 = a1;
16075 memset(&Dst, 0, 0x54u);
16076 Dst.uFrameWidth = 384;
16077 Dst.uFrameHeight = 256;
16078 Dst.uFrameX = 128;
16079 Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30;
16080 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
16081 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
16082 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
16083 Dst.DrawMessageBox(0);
16084 Dst.uFrameX += 12;
16085 Dst.uFrameWidth -= 24;
16086 Dst.uFrameY += 12;
16087 Dst.uFrameHeight -= 12;
16088 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
16089 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
16090 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
16091 sprintf(pTmpBuf, format_4E2D80, v4, v3);
16092 Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
16093 return Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
16094 }
16095
16096 //----- (00417AD4) --------------------------------------------------------
16097 unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3)
16098 {
16099 enum PLAYER_SKILL_TYPE v3; // ebx@1
16100 signed int v4; // edi@1
16101 unsigned int v5; // ecx@1
16102 int v6; // edx@1
16103 int v7; // eax@7
16104 int v8; // eax@10
16105 unsigned __int8 v9; // sf@10
16106 unsigned __int8 v10; // of@10
16107 int v11; // eax@11
16108 int v12; // eax@14
16109 unsigned int yellow; // [sp+Ch] [bp-Ch]@1
16110 unsigned int red; // [sp+10h] [bp-8h]@1
16111 unsigned int white; // [sp+14h] [bp-4h]@1
16112
16113 v3 = uPlayerSkillType;
16114 v4 = uPlayerClass;
16115 white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16116 red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
16117 yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0);
16118 v5 = 0;
16119 v6 = v4 % 4;
16120 if ( !(v4 % 4) )
16121 {
16122 v11 = 37 * v4 + v3;
16123 if ( byte_4ED970_skill_learn_ability_by_class_table[0][v11] >= a3 )
16124 goto LABEL_8;
16125 if ( byte_4ED970_skill_learn_ability_by_class_table[1][v11] < a3
16126 && byte_4ED970_skill_learn_ability_by_class_table[2][v11] < a3 )
16127 {
16128 v12 = byte_4ED970_skill_learn_ability_by_class_table[3][v11];
16129 v10 = __OFSUB__(v12, a3);
16130 v9 = v12 - a3 < 0;
16131 LABEL_15:
16132 v5 = red;
16133 if ( v9 ^ v10 )
16134 return v5;
16135 }
16136 return yellow;
16137 }
16138 if ( v6 == 1 )
16139 {
16140 v7 = 37 * v4 + v3;
16141 if ( byte_4ED970_skill_learn_ability_by_class_table[0][v7] >= a3 )
16142 goto LABEL_8;
16143 if ( byte_4ED970_skill_learn_ability_by_class_table[1][v7] < a3 )
16144 {
16145 v8 = byte_4ED970_skill_learn_ability_by_class_table[2][v7];
16146 v10 = __OFSUB__(v8, a3);
16147 v9 = v8 - a3 < 0;
16148 goto LABEL_15;
16149 }
16150 return yellow;
16151 }
16152 if ( v6 > 1 && v6 <= 3 )
16153 {
16154 if ( byte_4ED970_skill_learn_ability_by_class_table[v4][v3] < a3 )
16155 return red;
16156 LABEL_8:
16157 v5 = white;
16158 }
16159 return v5;
16160 }
16161
16162 //----- (00417BB5) --------------------------------------------------------
16163 const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, enum PLAYER_SKILL_TYPE uPlayerSkillType)
16164 {
16165 enum PLAYER_SKILL_TYPE v2; // esi@1
16166 unsigned int v3; // ebx@1
16167 int v4; // edi@1
16168 int v5; // eax@1
16169 Player *pPlayer; // ebx@7
16170 char v7; // al@7
16171 char v8; // cl@7
16172 unsigned int v9; // eax@8
16173 unsigned int v10; // eax@8
16174 unsigned int v11; // eax@8
16175 enum PLAYER_SKILL_TYPE v12; // edi@8
16176 unsigned int v13; // eax@8
16177 unsigned int v14; // eax@8
16178 enum PLAYER_SKILL_TYPE v15; // esi@8
16179 int v16; // edi@8
16180 char v17; // al@8
16181 int v18; // ST5C_4@8
16182 int v19; // ST4C_4@8
16183 int v20; // ST3C_4@8
16184 int v21; // ST2C_4@8
16185 int v22; // ST1C_4@8
16186 char *v23; // esi@8
16187 unsigned int v24; // eax@9
16188 unsigned int v25; // eax@9
16189 unsigned int v26; // eax@9
16190 unsigned int v27; // ecx@9
16191 enum PLAYER_SKILL_TYPE v28; // ebx@9
16192 unsigned int v29; // eax@9
16193 char a2[1200]; // [sp+Ch] [bp-538h]@7
16194 char Source[120]; // [sp+4BCh] [bp-88h]@7
16195 unsigned __int16 *v33; // [sp+534h] [bp-10h]@1
16196 int v34; // [sp+538h] [bp-Ch]@1
16197 unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1
16198 enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1
16199
16200 v2 = uPlayerSkillType;
16201 v3 = uPlayerID;
16202 v36 = uPlayerSkillType;
16203 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal
16204 v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert
16205 v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master
16206 v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);// Grand
16207 v35 = (unsigned __int16 *)v4;
16208 if ( v34 > v4 )
16209 v35 = (unsigned __int16 *)v34;
16210 if ( (signed int)v33 > (signed int)v35 )
16211 v35 = v33;
16212 if ( v5 > (signed int)v35 )
16213 v35 = (unsigned __int16 *)v5;
16214 pPlayer = &pParty->pPlayers[v3];
16215 v33 = &pPlayer->pActiveSkills[v2];
16216 v7 = pPlayer->GetActualSkillLevel(v2);
16217 v8 = LOBYTE(pPlayer->pActiveSkills[v2]);
16218 a2[0] = 0;
16219 Source[0] = 0;
16220 if ( (v8 & 0x3F) == (v7 & 0x3F) )
16221 {
16222 strcpy(a2, "%s\n\n");
16223 v24 = sub_417AD4(pPlayer->uClass, v2, 1);
16224 sprintf(Source, format_4E2DC8, v24);
16225 strcat(a2, Source);
16226 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16227 v25 = sub_417AD4(pPlayer->uClass, v36, 2);
16228 sprintf(Source, format_4E2DC8, v25);
16229 strcat(a2, Source);
16230 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16231 v26 = sub_417AD4(pPlayer->uClass, v36, 3);
16232 sprintf(Source, format_4E2DC8, v26);
16233 strcat(a2, Source);
16234 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16235 v27 = pPlayer->uClass;
16236 v28 = v36;
16237 v29 = sub_417AD4(v27, v36, 4);
16238 sprintf(Source, format_4E2DC8, v29);
16239 strcat(a2, Source);
16240 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16241
16242 v23 = static_sub_417BB5_out_string;
16243 sprintf(
16244 static_sub_417BB5_out_string,
16245 a2,
16246 pSkillDesc[v28],
16247 pGlobalTXT_LocalizationStrings[431], // Normal
16248 (char *)v35 + 3,
16249 v35 + 5,
16250 pNormalSkillDesc[v28],
16251 pGlobalTXT_LocalizationStrings[433], // Expert
16252 (char *)v35 + 3,
16253 v35 + 5,
16254 pExpertSkillDesc[v28],
16255 pGlobalTXT_LocalizationStrings[432], // Master
16256 (char *)v35 + 3,
16257 v35 + 5,
16258 pMasterSkillDesc[v28],
16259 pGlobalTXT_LocalizationStrings[96], // Grand
16260 (char *)v35 + 3,
16261 v35 + 5,
16262 pGrandSkillDesc[v28]);
16263 }
16264 else
16265 {
16266 strcpy(a2, "%s\n\n");
16267 v9 = sub_417AD4(pPlayer->uClass, v2, 1);
16268 sprintf(Source, format_4E2DC8, v9);
16269 strcat(a2, Source);
16270 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16271 v10 = sub_417AD4(pPlayer->uClass, v36, 2);
16272 sprintf(Source, format_4E2DC8, v10);
16273 strcat(a2, Source);
16274 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16275 v11 = sub_417AD4(pPlayer->uClass, v36, 3);
16276 sprintf(Source, format_4E2DC8, v11);
16277 strcat(a2, Source);
16278 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16279 v12 = v36;
16280 v13 = sub_417AD4(pPlayer->uClass, v36, 4);
16281 sprintf(Source, format_4E2DC8, v13);
16282 strcat(a2, Source);
16283 strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
16284 v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16285 sprintf(Source, format_4E2DC8, v14);
16286 strcat(a2, Source);
16287 strcat(a2, "%s: +%d");
16288 v15 = v12;
16289 v16 = (int)(v35 + 5);
16290 v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4);
16291 v34 = (int)((char *)v35 + 3);
16292 v17 = pPlayer->GetActualSkillLevel(v36);
16293 v18 = *(int *)((char *)pGrandSkillDesc + v15);
16294 v19 = *(int *)((char *)pMasterSkillDesc + v15);
16295 v20 = *(int *)((char *)pExpertSkillDesc + v15);
16296 v21 = *(int *)((char *)pNormalSkillDesc + v15);
16297 v22 = *(int *)((char *)pSkillDesc + v15);
16298 v23 = static_sub_417BB5_out_string;
16299 sprintf(
16300 static_sub_417BB5_out_string,
16301 a2,
16302 v22,
16303 pGlobalTXT_LocalizationStrings[431],
16304 v34,
16305 v16,
16306 v21,
16307 pGlobalTXT_LocalizationStrings[433],
16308 v34,
16309 v16,
16310 v20,
16311 pGlobalTXT_LocalizationStrings[432],
16312 v34,
16313 v16,
16314 v19,
16315 pGlobalTXT_LocalizationStrings[96],
16316 v34,
16317 v16,
16318 v18,
16319 pGlobalTXT_LocalizationStrings[623],
16320 (v17 & 0x3F) - (*(char *)v33 & 0x3F));
16321 }
16322 return v23;
16323 }
16324
16325 //----- (00417FE5) --------------------------------------------------------
16326 char __cdecl CharacterUI_SkillsTab_ShowHint()
16327 {
16328 unsigned int v0; // ecx@1
16329 unsigned int v1; // eax@1
16330 GUIButton *i; // esi@6
16331 const char *v3; // eax@12
16332 unsigned int pX; // [sp+4h] [bp-8h]@1
16333 unsigned int pY; // [sp+8h] [bp-4h]@1
16334
16335 pMouse->GetClickPos(&pX, &pY);
16336 v0 = pX;
16337 v1 = pY;
16338 if ( (signed int)pX < 24 || (signed int)pX > 455 || (signed int)pY < 18 || (signed int)pY > 36 )
16339 {
16340 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
16341 {
16342 if ( i->uControlID == 121
16343 && (signed int)v0 >= (signed int)i->uX
16344 && (signed int)v0 <= (signed int)i->uZ
16345 && (signed int)v1 >= (signed int)i->uY
16346 && (signed int)v1 <= (signed int)i->uW )
16347 {
16348 v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (enum PLAYER_SKILL_TYPE)i->uControlParam);
16349 sub_4179BC_draw_tooltip(pSkillNames[i->uControlParam], v3);
16350 v1 = pY;
16351 v0 = pX;
16352 }
16353 }
16354 }
16355 else
16356 {
16357 LOBYTE(v1) = sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription);
16358 }
16359 return v1;
16360 }
16361
16362 //----- (00418083) --------------------------------------------------------
16363 char __cdecl CharacterUI_StatsTab_ShowHint()
16364 {
16365 LONG _x; // esi@1
16366 Player *_y; // eax@1
16367 int v2; // edi@1
16368 __int16 *v3; // ecx@1
16369 LONG v4; // edx@2
16370 signed int v5; // edx@4
16371 char *v6; // ecx@9
16372 char *v7; // ebx@9
16373 unsigned int v8; // ebx@15
16374 unsigned __int64 v9; // kr00_8@15
16375 char *v10; // ST2C_4@15
16376 signed int v11; // eax@15
16377 char *v12; // ecx@17
16378 char *v13; // eax@20
16379 Player *v14; // esi@28
16380 int v15; // ebx@28
16381 int v16; // eax@33
16382 POINT a2; // [sp+Ch] [bp-24h]@1
16383 __int64 v19; // [sp+14h] [bp-1Ch]@15
16384 char *v20; // [sp+1Ch] [bp-14h]@13
16385 Player *v21; // [sp+20h] [bp-10h]@13
16386 unsigned int v22; // [sp+24h] [bp-Ch]@15
16387 int *v23; // [sp+28h] [bp-8h]@13
16388 const char *v24; // [sp+2Ch] [bp-4h]@10
16389
16390 _x = pMouse->GetCursorPos(&a2)->x;
16391 _y = (Player *)pMouse->GetCursorPos(&a2)->y;
16392 v2 = 0;
16393 v3 = &array_4E2940[0].field_2;
16394 while ( 1 )
16395 {
16396 v4 = *(v3 - 1);
16397 if ( _x >= v4 )
16398 {
16399 if ( _x <= v4 + v3[1] )
16400 {
16401 v5 = *v3;
16402 if ( (signed int)_y >= v5 )
16403 {
16404 if ( (signed int)_y <= v5 + v3[2] )
16405 break;
16406 }
16407 }
16408 }
16409 v3 += 4;
16410 ++v2;
16411 if ( (signed int)v3 >= (signed int)&off_4E2A12 )
16412 return (char)_y;
16413 }
16414 switch ( v2 )
16415 {
16416 case 0:
16417 case 1:
16418 case 2:
16419 case 3:
16420 case 4:
16421 case 5:
16422 case 6:
16423 LOBYTE(_y) = 4 * v2;
16424 v6 = aAttributeNames[v2];
16425 v7 = pAttributeDescriptions[v2];
16426 goto LABEL_46;
16427 case 7:
16428 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[108]);
16429 v7 = pHealthPointsAttributeDescription;
16430 v24 = pGlobalTXT_LocalizationStrings[108];
16431 goto LABEL_47;
16432 case 8:
16433 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[212]);
16434 v7 = pSpellPointsAttributeDescription;
16435 v24 = pGlobalTXT_LocalizationStrings[212];
16436 goto LABEL_47;
16437 case 9:
16438 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[12]);
16439 v7 = pArmourClassAttributeDescription;
16440 v24 = pGlobalTXT_LocalizationStrings[12];
16441 goto LABEL_47;
16442 case 10:
16443 v24 = pGlobalTXT_LocalizationStrings[47];
16444 strcpy(pTmpBuf2, pPlayerConditionAttributeDescription);
16445 v7 = pTmpBuf2;
16446 v20 = pTmpBuf2;
16447 strcat(pTmpBuf2, "\n");
16448
16449 extern unsigned int pConditionImportancyTable[18];
16450 v23 = (int *)pConditionImportancyTable;
16451 _y = pPlayers[uActiveCharacter];
16452 v21 = pPlayers[uActiveCharacter];
16453 do
16454 {
16455 if ( _y->pConditions[*v23] )
16456 {
16457 strcat(pTmpBuf2, " \n");
16458 v8 = *v23;
16459 v9 = pParty->uTimePlayed - v21->pConditions[*v23];
16460 a2.x = LODWORD(pParty->uTimePlayed) - LODWORD(v21->pConditions[*v23]);
16461 a2.y = HIDWORD(v9);
16462 v19 = (signed __int64)((double)*(signed __int64 *)&a2 * 0.234375) / 60 / 60;
16463 v22 = (unsigned int)v19 / 0x18;
16464 v10 = aCharacterConditionNames[v8];
16465 v19 %= 24i64;
16466 v11 = GetConditionDrawColor(v8);
16467 sprintf(pTmpBuf, &byte_4E2DE8, v11, v10);
16468 strcat(pTmpBuf2, pTmpBuf);
16469 if ( v19 && v19 <= 1 )
16470 v12 = pGlobalTXT_LocalizationStrings[109];
16471 else
16472 v12 = pGlobalTXT_LocalizationStrings[110];
16473 if ( !v22 || (v13 = pGlobalTXT_LocalizationStrings[56], v22 > 1) )
16474 v13 = pGlobalTXT_LocalizationStrings[57];
16475 sprintf(pTmpBuf, "%lu %s, %lu %s", v22, v13, v19, v12);
16476 strcat(pTmpBuf2, pTmpBuf);
16477 v7 = v20;
16478 _y = v21;
16479 }
16480 ++v23;
16481 }
16482 while ( (signed int)v23 < (signed int)&unk_4EDF40 );
16483 goto LABEL_47;
16484 case 11:
16485 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[172]);
16486 v7 = pFastSpellAttributeDescription;
16487 v24 = pGlobalTXT_LocalizationStrings[172];
16488 goto LABEL_47;
16489 case 12:
16490 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[5]);
16491 v7 = pPlayerAgeAttributeDescription;
16492 v24 = pGlobalTXT_LocalizationStrings[5];
16493 goto LABEL_47;
16494 case 13:
16495 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[131]);
16496 v7 = pPlayerLevelAttributeDescription;
16497 v24 = pGlobalTXT_LocalizationStrings[131];
16498 goto LABEL_47;
16499 case 14:
16500 v14 = pPlayers[uActiveCharacter];
16501 v24 = pGlobalTXT_LocalizationStrings[83];
16502 v15 = v14->uLevel;
16503 do
16504 {
16505 if ( (signed __int64)v14->uExperience < (unsigned int)sub_4B46F8(v15) )
16506 break;
16507 ++v15;
16508 }
16509 while ( v15 <= 10000 );
16510 pTmpBuf[0] = 0;
16511 pTmpBuf2[0] = 0;
16512 if ( v15 > v14->uLevel )
16513 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[147], v15);
16514 v16 = sub_4B46F8(v15) - LODWORD(v14->uExperience);
16515 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[538], v16, v15 + 1);
16516 strcat(pTmpBuf, "\n");
16517 strcat(pTmpBuf, pTmpBuf2);
16518 LOBYTE(_y) = sprintf(pTmpBuf2, "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf);
16519 v7 = pTmpBuf2;
16520 goto LABEL_47;
16521 case 15:
16522 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[587]);
16523 v7 = pAttackBonusAttributeDescription;
16524 v24 = pGlobalTXT_LocalizationStrings[587];
16525 goto LABEL_47;
16526 case 16:
16527 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[588]);
16528 v7 = pAttackDamageAttributeDescription;
16529 v24 = pGlobalTXT_LocalizationStrings[588];
16530 goto LABEL_47;
16531 case 17:
16532 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[589]);
16533 v7 = pMissleBonusAttributeDescription;
16534 v24 = pGlobalTXT_LocalizationStrings[589];
16535 goto LABEL_47;
16536 case 18:
16537 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[590]);
16538 v7 = pMissleDamageAttributeDescription;
16539 v24 = pGlobalTXT_LocalizationStrings[590];
16540 goto LABEL_47;
16541 case 19:
16542 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[87]);
16543 v7 = pFireResistanceAttributeDescription;
16544 v24 = pGlobalTXT_LocalizationStrings[87];
16545 goto LABEL_47;
16546 case 20:
16547 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[6]);
16548 v7 = pAirResistanceAttributeDescription;
16549 v24 = pGlobalTXT_LocalizationStrings[6];
16550 goto LABEL_47;
16551 case 21:
16552 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[240]);
16553 v7 = pWaterResistanceAttributeDescription;
16554 v24 = pGlobalTXT_LocalizationStrings[240];
16555 goto LABEL_47;
16556 case 22:
16557 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[70]);
16558 v7 = pEarthResistanceAttributeDescription;
16559 v24 = pGlobalTXT_LocalizationStrings[70];
16560 goto LABEL_47;
16561 case 23:
16562 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[142]);
16563 v7 = pMindResistanceAttributeDescription;
16564 v24 = pGlobalTXT_LocalizationStrings[142];
16565 goto LABEL_47;
16566 case 24:
16567 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[29]);
16568 v7 = pBodyResistanceAttributeDescription;
16569 v24 = pGlobalTXT_LocalizationStrings[29];
16570 goto LABEL_47;
16571 case 25:
16572 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[207]);
16573 v7 = pSkillPointsAttributeDescription;
16574 v24 = pGlobalTXT_LocalizationStrings[207];
16575 goto LABEL_47;
16576 case 26:
16577 _y = (Player *)(4 * pPlayers[uActiveCharacter]->uClass);
16578 v6 = *(char **)((char *)_y->pConditions + (int)pClassNames);
16579 v7 = *(char **)((char *)_y->pConditions + (int)pClassDescriptions);
16580 LABEL_46:
16581 v24 = v6;
16582 LABEL_47:
16583 if ( v24 && v7 )
16584 LOBYTE(_y) = sub_4179BC_draw_tooltip(v24, v7);
16585 break;
16586 default:
16587 return (char)_y;
16588 }
16589 return (char)_y;
16590 }
16591
16592 //----- (00418511) --------------------------------------------------------
16593 char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
16594 {
16595 Player *pPlayer; // edi@1
16596 unsigned int v2; // eax@1
16597 unsigned int v3; // eax@1
16598 unsigned int v4; // eax@2
16599 int v5; // ST20_4@4
16600 int v6; // ST1C_4@4
16601 int v7; // ebp@4
16602 int v8; // eax@4
16603 unsigned int v9; // eax@4
16604 int v10; // ST34_4@4
16605 int v11; // ST20_4@4
16606 int v12; // ST1C_4@4
16607 int v13; // ebp@4
16608 int v14; // eax@4
16609 unsigned int v15; // eax@4
16610 int v16; // ST34_4@4
16611 int v17; // ST20_4@4
16612 int v18; // ST1C_4@4
16613 int v19; // ebp@4
16614 int v20; // eax@4
16615 unsigned int v21; // eax@4
16616 int v22; // ST34_4@4
16617 int v23; // ST20_4@4
16618 int v24; // ST1C_4@4
16619 int v25; // ebp@4
16620 int v26; // eax@4
16621 unsigned int v27; // eax@4
16622 int v28; // ST34_4@4
16623 int v29; // ST20_4@4
16624 int v30; // ST1C_4@4
16625 int v31; // ebp@4
16626 int v32; // eax@4
16627 unsigned int v33; // eax@4
16628 int v34; // ST34_4@4
16629 int v35; // ST20_4@4
16630 int v36; // ST1C_4@4
16631 int v37; // ebp@4
16632 int v38; // eax@4
16633 unsigned int v39; // eax@4
16634 int v40; // ST34_4@4
16635 int v41; // ST20_4@4
16636 int v42; // ST1C_4@4
16637 int v43; // ebp@4
16638 int v44; // eax@4
16639 unsigned int v45; // eax@4
16640 int v46; // ebp@4
16641 signed int v47; // ST20_4@6
16642 int v48; // ST1C_4@6
16643 signed int v49; // eax@6
16644 unsigned int v50; // eax@6
16645 int v51; // ST20_4@8
16646 int v52; // ST1C_4@8
16647 int v53; // eax@8
16648 unsigned int v54; // eax@8
16649 int v55; // ST34_4@8
16650 int v56; // ST20_4@8
16651 int v57; // ST1C_4@8
16652 int v58; // ebp@8
16653 int v59; // eax@8
16654 unsigned int v60; // eax@8
16655 unsigned int v61; // ebp@8
16656 unsigned int v62; // eax@8
16657 char *v63; // ST20_4@8
16658 signed int v64; // eax@8
16659 unsigned int v65; // ebp@8
16660 unsigned __int8 v66; // al@8
16661 char *v67; // eax@9
16662 unsigned int v68; // ST20_4@11
16663 unsigned int v69; // ST1C_4@11
16664 signed int v70; // ebp@11
16665 signed int v71; // eax@11
16666 unsigned int v72; // eax@11
16667 int v73; // ST20_4@13
16668 int v74; // ST1C_4@13
16669 int v75; // ebp@13
16670 int v76; // eax@13
16671 unsigned int v77; // eax@13
16672 char *v78; // ecx@14
16673 int v79; // ST20_4@16
16674 char *v80; // ST40_4@16
16675 unsigned int v81; // eax@16
16676 int v82; // ST34_4@16
16677 int v83; // eax@16
16678 int v84; // ST34_4@16
16679 char *v85; // eax@16
16680 int v86; // ST34_4@16
16681 int v87; // eax@16
16682 int v88; // ST34_4@16
16683 char *v89; // eax@16
16684 int v90; // eax@16
16685 int v91; // ST20_4@19
16686 unsigned int v92; // eax@19
16687 int v93; // eax@19
16688 int v94; // ST20_4@22
16689 unsigned int v95; // eax@22
16690 int v96; // eax@22
16691 int v97; // ST20_4@25
16692 unsigned int v98; // eax@25
16693 int v99; // eax@25
16694 int v100; // ST20_4@27
16695 unsigned int v101; // eax@27
16696 int v102; // eax@27
16697 int v103; // ST20_4@30
16698 unsigned int v104; // eax@30
16699 char *v105; // ST20_4@32
16700 unsigned int v106; // eax@32
16701 int v107; // eax@33
16702 int v108; // ST20_4@36
16703 unsigned int v109; // eax@36
16704 char *v110; // ST20_4@38
16705 unsigned int v111; // eax@38
16706 int uY; // [sp+10h] [bp-10h]@6
16707 int uYa; // [sp+10h] [bp-10h]@11
16708 int uYb; // [sp+10h] [bp-10h]@13
16709 int uYc; // [sp+10h] [bp-10h]@16
16710 int uYd; // [sp+10h] [bp-10h]@19
16711 int uYe; // [sp+10h] [bp-10h]@22
16712 int uYf; // [sp+10h] [bp-10h]@25
16713 int uYg; // [sp+10h] [bp-10h]@27
16714 int uYh; // [sp+10h] [bp-10h]@33
16715 const char *a2; // [sp+14h] [bp-Ch]@4
16716 const char *a2a; // [sp+14h] [bp-Ch]@6
16717 const char *a2b; // [sp+14h] [bp-Ch]@11
16718 const char *a2c; // [sp+14h] [bp-Ch]@16
16719 const char *a2d; // [sp+14h] [bp-Ch]@19
16720 const char *a2e; // [sp+14h] [bp-Ch]@22
16721 const char *a2f; // [sp+14h] [bp-Ch]@25
16722 const char *a2g; // [sp+14h] [bp-Ch]@27
16723 const char *a2h; // [sp+14h] [bp-Ch]@33
16724 int v131; // [sp+18h] [bp-8h]@16
16725 int v132; // [sp+18h] [bp-8h]@19
16726 int v133; // [sp+18h] [bp-8h]@22
16727 int v134; // [sp+18h] [bp-8h]@25
16728 int v135; // [sp+18h] [bp-8h]@27
16729 int v136; // [sp+18h] [bp-8h]@33
16730 int v137; // [sp+1Ch] [bp-4h]@27
16731 int v138; // [sp+1Ch] [bp-4h]@33
16732
16733 pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * uPlayerID + 40552];
16734 v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
16735 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
16736 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
16737 sprintf(pTmpBuf, format_4E2DC8, v3);
16738 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
16739 strcat(pTmpBuf, pTmpBuf2);
16740 if ( pPlayer->uSkillPoints )
16741 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
16742 else
16743 v4 = 0xFFFFu;
16744 sprintf(pTmpBuf2, "\xC" "00000\xD" "180%s: \xC%05d%d\xC" "00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
16745 strcat(pTmpBuf, pTmpBuf2);
16746 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
16747 v5 = pPlayer->GetBaseStrength();
16748 v6 = pPlayer->GetActualMight();
16749 v7 = pPlayer->GetBaseStrength();
16750 v8 = pPlayer->GetActualMight();
16751 v9 = UI_GetHealthManaStringColor(v8, v7);
16752 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);
16753 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
16754 v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
16755 v11 = pPlayer->GetBaseIntelligence();
16756 v12 = pPlayer->GetActualIntelligence();
16757 v13 = pPlayer->GetBaseIntelligence();
16758 v14 = pPlayer->GetActualIntelligence();
16759 v15 = UI_GetHealthManaStringColor(v14, v13);
16760 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);
16761 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
16762 v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
16763 v17 = pPlayer->GetBaseWillpower();
16764 v18 = pPlayer->GetActualWillpower();
16765 v19 = pPlayer->GetBaseWillpower();
16766 v20 = pPlayer->GetActualWillpower();
16767 v21 = UI_GetHealthManaStringColor(v20, v19);
16768 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);
16769 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
16770 v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
16771 v23 = pPlayer->GetBaseEndurance();
16772 v24 = pPlayer->GetActualEndurance();
16773 v25 = pPlayer->GetBaseEndurance();
16774 v26 = pPlayer->GetActualEndurance();
16775 v27 = UI_GetHealthManaStringColor(v26, v25);
16776 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);
16777 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
16778 v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
16779 v29 = pPlayer->GetBaseAccuracy();
16780 v30 = pPlayer->GetActualAccuracy();
16781 v31 = pPlayer->GetBaseAccuracy();
16782 v32 = pPlayer->GetActualAccuracy();
16783 v33 = UI_GetHealthManaStringColor(v32, v31);
16784 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
16785 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
16786 v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
16787 v35 = pPlayer->GetBaseSpeed();
16788 v36 = pPlayer->GetActualSpeed();
16789 v37 = pPlayer->GetBaseSpeed();
16790 v38 = pPlayer->GetActualSpeed();
16791 v39 = UI_GetHealthManaStringColor(v38, v37);
16792 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
16793 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
16794 v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
16795 v41 = pPlayer->GetBaseLuck();
16796 v42 = pPlayer->GetActualLuck();
16797 v43 = pPlayer->GetBaseLuck();
16798 v44 = pPlayer->GetActualLuck();
16799 v45 = UI_GetHealthManaStringColor(v44, v43);
16800 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
16801 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
16802 a2 = "%s";
16803 v46 = v40 + 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
16804 if ( pPlayer->GetMaxHealth() >= 1000 )
16805 a2 = (const char *)&unk_4E2EB8;
16806 v47 = pPlayer->GetMaxHealth();
16807 v48 = pPlayer->sHealth;
16808 v49 = pPlayer->GetMaxHealth();
16809 v50 = UI_GetHealthManaStringColor(pPlayer->sHealth, v49);
16810 sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
16811 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
16812 a2a = "%s";
16813 uY = LOBYTE(pFontArrus->uFontHeight) + v46 - 2;
16814 if ( pPlayer->GetMaxMana() >= 1000 )
16815 a2a = (const char *)&unk_4E2EB8;
16816 v51 = pPlayer->GetMaxMana();
16817 v52 = pPlayer->sMana;
16818 v53 = pPlayer->GetMaxMana();
16819 v54 = UI_GetHealthManaStringColor(pPlayer->sMana, v53);
16820 sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
16821 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
16822 v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
16823 v56 = pPlayer->GetBaseAC();
16824 v57 = pPlayer->GetActualAC();
16825 v58 = pPlayer->GetBaseAC();
16826 v59 = pPlayer->GetActualAC();
16827 v60 = UI_GetHealthManaStringColor(v59, v58);
16828 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
16829 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
16830 v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
16831 v62 = pPlayer->GetMajorConditionIdx();
16832 v63 = aCharacterConditionNames[v62];
16833 v64 = GetConditionDrawColor(v62);
16834 sprintf(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[47], v64, v63);
16835 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v61, 0, pTmpBuf, 226, 0);
16836 v65 = LOBYTE(pFontArrus->uFontHeight) + v61 - 1;
16837 v66 = pPlayer->uQuickSpell;
16838 if ( v66 )
16839 v67 = pSpellStats->pInfos[v66].pShortName;
16840 else
16841 v67 = pGlobalTXT_LocalizationStrings[153];
16842 sprintf(pTmpBuf, "%s: %s", pGlobalTXT_LocalizationStrings[172], v67);
16843 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v65, 0, pTmpBuf, 226, 0);
16844 v68 = pPlayer->GetBaseAge();
16845 v69 = pPlayer->GetActualAge();
16846 v70 = pPlayer->GetBaseAge();
16847 v71 = pPlayer->GetActualAge();
16848 v72 = UI_GetHealthManaStringColor(v71, v70);
16849 sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
16850 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
16851 a2b = "%s";
16852 uYa = LOBYTE(pFontArrus->uFontHeight) + 48;
16853 if ( pPlayer->GetBaseLevel() > 99 )
16854 a2b = format_4E2E68;
16855 v73 = pPlayer->GetBaseLevel();
16856 v74 = pPlayer->GetActualLevel();
16857 v75 = pPlayer->GetBaseLevel();
16858 v76 = pPlayer->GetActualLevel();
16859 v77 = UI_GetHealthManaStringColor(v76, v75);
16860 sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
16861 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
16862 uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
16863 if ( (signed __int64)pPlayer->uExperience <= 9999999 )
16864 v78 = pGlobalTXT_LocalizationStrings[83];
16865 else
16866 v78 = pGlobalTXT_LocalizationStrings[17];
16867 v79 = LODWORD(pPlayer->uExperience);
16868 v80 = v78;
16869 v81 = pPlayer->GetExperienceDisplayColor();
16870 sprintf(pTmpBuf, "%s\r180", v80, v81, v79);
16871 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYb, 0, pTmpBuf, 0, 0, 0);
16872 v82 = uYb + 2 * LOBYTE(pFontArrus->uFontHeight);
16873 v83 = pPlayer->GetActualAttack(0);
16874 sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83);
16875 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v82, 0, pTmpBuf, 0, 0, 0);
16876 v84 = v82 + LOBYTE(pFontArrus->uFontHeight) - 2;
16877 v85 = pPlayer->GetMeleeDamageString();
16878 sprintf(pTmpBuf, "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85);
16879 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v84, 0, pTmpBuf, 0, 0, 0);
16880 v86 = v84 + LOBYTE(pFontArrus->uFontHeight) - 2;
16881 v87 = pPlayer->GetRangedAttack();
16882 sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87);
16883 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v86, 0, pTmpBuf, 0, 0, 0);
16884 v88 = v86 + LOBYTE(pFontArrus->uFontHeight) - 2;
16885 v89 = pPlayer->GetRangedDamageString();
16886 sprintf(pTmpBuf, "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89);
16887 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v88, 0, pTmpBuf, 0, 0, 0);
16888 a2c = format_4E2E10;
16889 uYc = v88 + 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
16890 v131 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
16891 v90 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
16892 if ( v131 > 99 || v90 > 99 )
16893 a2c = format_4E2E68;
16894 v91 = v90;
16895 v92 = UI_GetHealthManaStringColor(v131, v90);
16896 sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
16897 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
16898 a2d = format_4E2E10;
16899 uYd = uYc + LOBYTE(pFontArrus->uFontHeight) - 2;
16900 v132 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
16901 v93 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
16902 if ( v132 > 99 || v93 > 99 )
16903 a2d = format_4E2E68;
16904 v94 = v93;
16905 v95 = UI_GetHealthManaStringColor(v132, v93);
16906 sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
16907 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
16908 a2e = format_4E2E10;
16909 uYe = uYd + LOBYTE(pFontArrus->uFontHeight) - 2;
16910 v133 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
16911 v96 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
16912 if ( v133 > 99 || v96 > 99 )
16913 a2e = format_4E2E68;
16914 v97 = v96;
16915 v98 = UI_GetHealthManaStringColor(v133, v96);
16916 sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
16917 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
16918 a2f = format_4E2E10;
16919 uYf = uYe + LOBYTE(pFontArrus->uFontHeight) - 2;
16920 v134 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
16921 v99 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
16922 if ( v134 > 99 )
16923 a2f = format_4E2E68;
16924 v100 = v99;
16925 v101 = UI_GetHealthManaStringColor(v134, v99);
16926 sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
16927 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
16928 a2g = format_4E2E10;
16929 uYg = uYf + LOBYTE(pFontArrus->uFontHeight) - 2;
16930 v135 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
16931 v102 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
16932 v137 = v102;
16933 if ( v135 > 99 || v102 > 99 )
16934 a2g = format_4E2E68;
16935 v103 = v102;
16936 v104 = UI_GetHealthManaStringColor(v135, v102);
16937 sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
16938 if ( pPlayer->uClass == 35 && v137 == 200 )
16939 {
16940 v105 = pGlobalTXT_LocalizationStrings[625];
16941 v106 = UI_GetHealthManaStringColor(v135, 200);
16942 sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
16943 }
16944 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
16945 a2h = format_4E2E10;
16946 uYh = uYg + LOBYTE(pFontArrus->uFontHeight) - 2;
16947 v136 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
16948 v107 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
16949 v138 = v107;
16950 if ( v136 > 99 || v107 > 99 )
16951 a2h = format_4E2E68;
16952 v108 = v107;
16953 v109 = UI_GetHealthManaStringColor(v136, v107);
16954 sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
16955 if ( pPlayer->uClass == 35 && v138 == 200 )
16956 {
16957 v110 = pGlobalTXT_LocalizationStrings[625];
16958 v111 = UI_GetHealthManaStringColor(v136, 200);
16959 sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
16960 }
16961 return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
16962 }
16963
16964 //----- (00419100) --------------------------------------------------------
16965 int __cdecl sub_419100()
16966 {
16967 Player *v0; // esi@1
16968 int v1; // ebx@1
16969 unsigned __int8 *v2; // esi@1
16970 int v3; // eax@4
16971 int result; // eax@6
16972 int v5; // esi@6
16973 unsigned __int8 v6; // zf@6
16974 unsigned __int8 v7; // sf@6
16975 int v8; // edx@7
16976 int v9; // ecx@7
16977 unsigned __int8 v10; // of@7
16978 stru179 *v11; // edi@9
16979 int v12; // edx@11
16980 int v13; // [sp+Ch] [bp-8h]@2
16981 signed int v14; // [sp+Ch] [bp-8h]@9
16982 int i; // [sp+10h] [bp-4h]@10
16983
16984 v0 = pPlayers[uActiveCharacter];
16985 memset(&pStru179, 0, 0xFA0u);
16986 memset(pTmpBuf2, 0, 0x7D0u);
16987 v1 = 0;
16988 dword_506544 = 0;
16989 dword_506548 = 0;
16990 dword_506520 = 0;
16991 dword_50651C = 0;
16992 dword_506528 = 0;
16993 v2 = (unsigned __int8 *)v0->field_152;
16994 do
16995 {
16996 v13 = dword_723E80_award_related[2 * v1];
16997 if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 )
16998 {
16999 v3 = dword_506520++;
17000 pStru179->field_0[v3] = v1;
17001 }
17002 ++v1;
17003 }
17004 while ( v1 < 105 );
17005 result = dword_506520;
17006 v5 = 0;
17007 v6 = dword_506520 == 0;
17008 v7 = dword_506520 < 0;
17009 dword_506524 = dword_506520;
17010 dword_506520 = 0;
17011 if ( !(v7 | v6) )
17012 {
17013 do
17014 {
17015 v8 = rand() % 16;
17016 result = dword_506524;
17017 v9 = dword_506524 + v5++;
17018 v10 = __OFSUB__(v5, dword_506524);
17019 v7 = v5 - dword_506524 < 0;
17020 pStru179->field_0[v9] = v8;
17021 }
17022 while ( v7 ^ v10 );
17023 if ( result > 0 )
17024 {
17025 v14 = 1;
17026 v11 = pStru179;
17027 do
17028 {
17029 for ( i = v14; i < result; ++i )
17030 {
17031 v12 = pStru179->field_0[i];
17032 if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] )
17033 {
17034 pStru179->field_0[i] = v11->field_0[0];
17035 v11->field_0[0] = v12;
17036 }
17037 }
17038 ++v14;
17039 v11 = (stru179 *)((char *)v11 + 4);
17040 }
17041 while ( v14 - 1 < result );
17042 }
17043 }
17044 return result;
17045 }
17046
17047
17048 //----- (00419220) --------------------------------------------------------
17049 void __cdecl sub_419220()
17050 {
17051 GUIButton *i; // eax@2
17052
17053 if ( !dword_507CBC )
17054 {
17055 dword_507CBC = 1;
17056 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17057 {
17058 if ( i->uControlID == 120 )
17059 {
17060 dword_50698C = i->uX;
17061 dword_506988 = i->uY;
17062 dword_506984 = i->uZ;
17063 dword_506980 = i->uW;
17064 i->uW = 0;
17065 i->uZ = 0;
17066 i->uY = 0;
17067 i->uX = 0;
17068 }
17069 }
17070 pBtn_Up = pGUIWindow_CurrentMenu->CreateButton(
17071 0x1B6u,
17072 0x2Eu,
17073 (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureWidth : 24),
17074 (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureHeight : 26),
17075 1,
17076 0,
17077 0xA9u,
17078 0,
17079 0,
17080 "",
17081 (Texture *)(uTextureID_ar_up_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_up] : 0),
17082 uTextureID_ar_up_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_dn] : 0,
17083 0);
17084 pBtn_Down = pGUIWindow_CurrentMenu->CreateButton(
17085 0x1B6u,
17086 0x124u,
17087 (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureWidth : 24),
17088 (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureHeight : 26),
17089 1,
17090 0,
17091 0xAAu,
17092 0,
17093 0,
17094 "",
17095 (Texture *)(uTextureID_ar_dn_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_up] : 0),
17096 uTextureID_ar_dn_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_dn] : 0,
17097 0);
17098 ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(
17099 0x1B8u,
17100 0x3Eu,
17101 0x10u,
17102 0xE8u,
17103 1,
17104 0,
17105 0xC0u,
17106 0,
17107 0,
17108 "",
17109 0);
17110 }
17111 }
17112
17113
17114
17115 //----- (00419379) --------------------------------------------------------
17116 void __cdecl sub_419379()
17117 {
17118 GUIButton *i; // esi@2
17119
17120 if ( dword_507CBC )
17121 {
17122 dword_507CBC = 0;
17123 GUIButton::_41D0D8(ptr_507BA4);
17124 GUIButton::_41D0D8(pBtn_Up);
17125 GUIButton::_41D0D8(pBtn_Down);
17126 pBtn_Down = 0;
17127 pBtn_Up = 0;
17128 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17129 {
17130 if ( i->uControlID == 120 )
17131 {
17132 i->uX = dword_50698C;
17133 i->uY = dword_506988;
17134 i->uZ = dword_506984;
17135 i->uW = dword_506980;
17136 pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
17137 }
17138 }
17139 }
17140 }
17141
17142
17143 //----- (00419401) --------------------------------------------------------
17144 void __cdecl sub_419401()
17145 {
17146 unsigned int v0; // ecx@3
17147 GUIButton *i; // eax@3
17148 GUIFont *v2; // eax@8
17149 unsigned int v3; // esi@8
17150 int v4; // eax@10
17151 unsigned int v5; // esi@14
17152 int v6; // eax@17
17153 unsigned int v7; // esi@19
17154 int v8; // eax@21
17155 unsigned int v9; // esi@25
17156 int v10; // eax@27
17157 int a2; // [sp+10h] [bp-14h]@1
17158 int v12; // [sp+14h] [bp-10h]@8
17159 int v13; // [sp+14h] [bp-10h]@19
17160 unsigned int *v14; // [sp+18h] [bp-Ch]@8
17161 unsigned int *v15; // [sp+18h] [bp-Ch]@14
17162 unsigned int *v16; // [sp+18h] [bp-Ch]@19
17163 unsigned int *v17; // [sp+18h] [bp-Ch]@25
17164 char *v18; // [sp+1Ch] [bp-8h]@8
17165 int a5; // [sp+20h] [bp-4h]@8
17166
17167 a2 = 0;
17168 if ( dword_507CC0 )
17169 sub_4196A0();
17170 v0 = uActiveCharacter;
17171 dword_507CC0 = uActiveCharacter;
17172 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17173 {
17174 if ( i->uControlID == 120 )
17175 {
17176 dword_50698C = i->uX;
17177 dword_506988 = i->uY;
17178 dword_506984 = i->uZ;
17179 dword_506980 = i->uW;
17180 i->uW = 0;
17181 i->uZ = 0;
17182 i->uY = 0;
17183 i->uX = 0;
17184 v0 = uActiveCharacter;
17185 }
17186 }
17187 v12 = 0;
17188 a5 = pGUIWindow_CurrentMenu->uNumControls;
17189 v18 = &stru_AA1058[3].pSounds[6972 * v0 + 40552];
17190 v2 = pFontLucida;
17191 v14 = (unsigned int *)dword_4E2A2C;
17192 v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
17193 do
17194 {
17195 if ( v18[2 * *v14 + 264] & 0x3F )
17196 {
17197 v4 = LOBYTE(v2->uFontHeight);
17198 v3 = v3 + v4 - 3;
17199 ++a2;
17200 ++v12;
17201 pGUIWindow_CurrentMenu->CreateButton(
17202 0x18u,
17203 v3,
17204 0xCCu,
17205 v4 - 3,
17206 3,
17207 *v14 | 0x8000,
17208 0x79u,
17209 *v14,
17210 0,
17211 "",
17212 0);
17213 v2 = pFontLucida;
17214 }
17215 ++v14;
17216 }
17217 while ( (signed int)v14 < (signed int)dword_4E2A50 );
17218 if ( !v12 )
17219 v3 = v3 + LOBYTE(v2->uFontHeight) - 3;
17220 v15 = (unsigned int *)_4E2A80_skills;
17221 v5 = v3 + 2 * LOBYTE(v2->uFontHeight) - 6;
17222 do
17223 {
17224 if ( v18[2 * *v15 + 264] & 0x3F && a2 < 15 )
17225 {
17226 v6 = LOBYTE(v2->uFontHeight);
17227 v5 = v5 + v6 - 3;
17228 ++a2;
17229 pGUIWindow_CurrentMenu->CreateButton(
17230 0x18u,
17231 v5,
17232 0xCCu,
17233 v6 - 3,
17234 3,
17235 *v15 | 0x8000,
17236 0x79u,
17237 *v15,
17238 0,
17239 "",
17240 0);
17241 v2 = pFontLucida;
17242 }
17243 ++v15;
17244 }
17245 while ( (signed int)v15 < (signed int)pAwardsTextColors );
17246 v13 = 0;
17247 v16 = (unsigned int *)dword_4E2A18;
17248 v7 = 2 * LOBYTE(v2->uFontHeight) + 13;
17249 do
17250 {
17251 if ( v18[2 * *v16 + 264] & 0x3F )
17252 {
17253 v8 = LOBYTE(v2->uFontHeight);
17254 v7 = v7 + v8 - 3;
17255 ++a2;
17256 ++v13;
17257 pGUIWindow_CurrentMenu->CreateButton(
17258 0xF6u,
17259 v7,
17260 0xCCu,
17261 v8 - 3,
17262 3,
17263 *v16 | 0x8000,
17264 0x79u,
17265 *v16,
17266 0,
17267 "",
17268 0);
17269 v2 = pFontLucida;
17270 }
17271 ++v16;
17272 }
17273 while ( (signed int)v16 < (signed int)dword_4E2A2C );
17274 if ( !v13 )
17275 v7 = v7 + LOBYTE(v2->uFontHeight) - 3;
17276 v17 = (unsigned int *)dword_4E2A50;
17277 v9 = v7 + 2 * LOBYTE(v2->uFontHeight) - 6;
17278 do
17279 {
17280 if ( v18[2 * *v17 + 264] & 0x3F )
17281 {
17282 v10 = LOBYTE(v2->uFontHeight);
17283 v9 = v9 + v10 - 3;
17284 ++a2;
17285 pGUIWindow_CurrentMenu->CreateButton(
17286 0xF6u,
17287 v9,
17288 0xCCu,
17289 v10 - 3,
17290 3,
17291 *v17 | 0x8000,
17292 0x79u,
17293 *v17,
17294 0,
17295 "",
17296 0);
17297 v2 = pFontLucida;
17298 }
17299 ++v17;
17300 }
17301 while ( (signed int)v17 < (signed int)_4E2A80_skills );
17302 if ( a2 )
17303 pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
17304 }