comparison mm7_5.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 2ca04ccb612a
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
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 *v3; // ecx@13
70 int v4; // ecx@18
71 NPCData *v5; // 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 *v26; // eax@204
93 unsigned int v27; // edx@204
94 unsigned int v28; // ecx@204
95 GUIWindow *v29; // 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 *v36; // 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 *v43; // 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 *v49; // ecx@410
116 ODMFace *v50; // 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 *v58; // edx@442
125 unsigned int v59; // eax@445
126 signed int v60; // ST64_4@459
127 NPCData *v61; // 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 *v72; // 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 *v78; // ecx@549
145 int v79; // ecx@550
146 unsigned int v80; // edx@550
147 signed int v81; // eax@552
148 POINT *v82; // eax@553
149 signed int v83; // ecx@554
150 signed int v84; // ecx@554
151 GUIButton *v85; // 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 v94; // 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 *v100; // eax@648
167 int v101; // ecx@648
168 int v102; // edx@652
169 int v103; // eax@671
170 Player *v104; // ecx@718
171 int v105; // eax@718
172 Player *v106; // 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 *v117; // 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 v141; // [sp-8h] [bp-604h]@56
208 enum WindowType v142; // [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 v145; // [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 *v149; // [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 *v164; // [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 v172; // [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 *thisc; // [sp+14h] [bp-5E8h]@373
250 Player *thisd; // [sp+14h] [bp-5E8h]@377
251 char *thise; // [sp+14h] [bp-5E8h]@445
252 Player *thisf; // [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 *thisj; // [sp+14h] [bp-5E8h]@604
257 Player *thisk; // [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 *v195; // [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 = nullstring;
308 while ( 2 )
309 {
310 pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199);
311 switch ( uMessage )
312 {
313 case UIMSG_ChangeGameState:
314 uGameState = v0;
315 goto _continue;
316 case UIMSG_PlayArcomage:
317 pVideoPlayer->_4BF5B2();
318 pArcomageGame->bGameInProgress = 1;
319 PrepareArcomage();
320 goto _continue;
321 case UIMSG_StartNPCDialogue:
322 if ( !uActiveCharacter )
323 goto _continue;
324 viewparams->field_48 = v0;
325 if ( pMessageQueue_50CBD0->uNumMessages )
326 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
327 dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID;
328 v3 = &pActors[uMessageParam];
329 goto _actor_init_dlg;
330 case UIMSG_Quit|0x2:
331 case 0x87:
332 if ( bNoNPCHiring != 1
333 && !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
334 {
335 if ( pMessageQueue_50CBD0->uNumMessages )
336 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
337 uAction = 0;
338 uNumSeconds = uMessage - 134;
339 v4 = 0;
340 v5 = pParty->pHirelings;
341 do
342 {
343 if ( v5->pName )
344 {
345 v6 = uAction++;
346 pTmpBuf[v6] = v4;
347 }
348 ++v5;
349 ++v4;
350 }
351 while ( (signed int)v5 < (signed int)&pParty->pPickedItem );
352 _this = 0;
353 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
354 {
355 v195 = pNPCStats->pNewNPCData;
356 do
357 {
358 if ( v195->uFlags & 0x80
359 && (!pParty->pHirelings[0].pName || strcmp(v195->pName, pParty->pHirelings[0].pName))
360 && (!pParty->pHirelings[1].pName || strcmp(v195->pName, pParty->pHirelings[1].pName)) )
361 {
362 v7 = uAction++;
363 pTmpBuf[v7] = _this + 2;
364 }
365 ++_this;
366 ++v195;
367 }
368 while ( _this < (signed int)pNPCStats->uNumNewNPCs );
369 }
370 if ( (signed int)(uNumSeconds + (unsigned __int8)pParty->field_709) < uAction )
371 {
372 //Actor::Actor(&actor);
373 memset(&actor, 0, 0x344u);
374 actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds;
375 v3 = &actor;
376 _actor_init_dlg:
377 v3->InitializeDialogue(v0);
378 }
379 }
380 goto _continue;
381 case 0x51:
382 sub_4BDB56_buy_skill____();
383 goto _continue;
384 case UIMSG_AF:
385 sub_4B2001(uMessageParam);
386 goto _continue;
387 case 0x195:
388 sub_4BCACC_bounties(uMessageParam);
389 goto _continue;
390 case 0x88:
391 sub_4BC49B(uMessageParam);
392 goto _continue;
393 case 0x19A:
394 _4B4224_UpdateNPCTopics(uMessageParam);
395 goto _continue;
396 case UIMSG_StartNewGame:
397 if ( dword_6BE138 == 124 || uMessageParam )
398 {
399 pIcons_LOD->_40F9C5();
400 pIcons_LOD->_4114F2();
401 if ( pMessageQueue_50CBD0->uNumMessages )
402 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
403 pGUIWindow_CurrentMenu->Release();
404 uGameState = 4;
405 LABEL_188:
406 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
407 viewparams->bRedrawGameUI = v0;
408 }
409 else
410 {
411 ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2u);// "Are you sure? Click again to start a New Game"
412 pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
413 dword_6BE138 = 124;
414 }
415 _release_tex_and_continue:
416 stru_506E40.Release();
417 goto _continue;
418 case UIMSG_Game_OpenLoadGameDialog:
419 pIcons_LOD->_40F9C5();
420 pIcons_LOD->_4114F2();
421 if ( pMessageQueue_50CBD0->uNumMessages )
422 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
423 pGUIWindow_CurrentMenu->Release();
424 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 12;
425 GameUI_DrawLoadMenu(v0);
426 goto _continue;
427 case UIMSG_Quit:
428 if ( dword_6BE138 == 132 || uMessageParam )
429 {
430 pIcons_LOD->_40F9C5();
431 pIcons_LOD->_4114F2();
432 if ( pMessageQueue_50CBD0->uNumMessages )
433 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
434 pGUIWindow_CurrentMenu->Release();
435 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
436 viewparams->bRedrawGameUI = v0;
437 if ( !uMessageParam )
438 pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
439 uGameState = 7;
440 }
441 else
442 {
443 ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2u);// "Are you sure? Click again to quit"
444 pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
445 dword_6BE138 = 132;
446 }
447 goto _release_tex_and_continue;
448 case 0x80:
449 pIcons_LOD->_40F9C5();
450 pIcons_LOD->_4114F2();
451 pGUIWindow_CurrentMenu->Release();
452 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 2;
453 v162 = 0;
454 v148 = 0;
455 v141 = (WindowType)8;
456 goto LABEL_439;
457 case UIMSG_A2:
458 --dword_6A0C9C;
459 if ( dword_6A0C9C < 0 )
460 dword_6A0C9C = 0;
461 v163 = 0;
462 v8 = 199;
463 v149 = ptr_69BD5C;
464 goto LABEL_60;
465 case UIMSG_A3:
466 ++dword_6A0C9C;
467 if ( dword_6A0C9C >= uMessageParam )
468 dword_6A0C9C = uMessageParam - 1;
469 v163 = 0;
470 v8 = 323;
471 v149 = ptr_69BD58;
472 LABEL_60:
473 v142 = (WindowType)90;
474 v137 = 17;
475 v133 = 17;
476 v9 = 215;
477 goto LABEL_733;
478 case UIMSG_A6:
479 v163 = 0;
480 v8 = 302;
481 v149 = ptr_69BD60;
482 v9 = 350;
483 v142 = (WindowType)96;
484 v137 = 42;
485 v133 = 106;
486 goto LABEL_733;
487 case UIMSG_A4:
488 v163 = 0;
489 v8 = 302;
490 v149 = ptr_69BD64;
491 v9 = 241;
492 v142 = (WindowType)94;
493 v137 = 42;
494 v133 = 106;
495 goto LABEL_733;
496 case UIMSG_A5:
497 if ( pGUIWindow_CurrentMenu->field_40 == v0 )
498 pKeyActionMap->_459ED1(0);
499 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11
500 || uLoadGameUI_SelectedSlot != dword_6A0C9C + uMessageParam )
501 {
502 v10 = dword_6A0C9C + uMessageParam;
503 if ( dword_6BE138 == dword_6A0C9C + uMessageParam )
504 {
505 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
506 {
507 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)164;
508 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
509 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
510 v11 = pMessageQueue_50CBD0->uNumMessages + 1;
511 v13 = __OFSUB__(pMessageQueue_50CBD0->uNumMessages + 1, 40);
512 v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
513 ++pMessageQueue_50CBD0->uNumMessages;
514 if ( v12 ^ v13 )
515 {
516 pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)82;
517 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
518 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
519 ++pMessageQueue_50CBD0->uNumMessages;
520 }
521 }
522 }
523 uLoadGameUI_SelectedSlot = v10;
524 dword_6BE138 = v10;
525 }
526 else
527 {
528 pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
529 if ( strcmp(
530 (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot,
531 pGlobalTXT_LocalizationStrings[72]) )// "Empty"
532 strcpy(
533 (char *)pKeyActionMap->pPressedKeysBuffer,
534 (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
535 pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
536 }
537 goto _continue;
538 case UIMSG_LoadGame:
539 if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
540 {
541 LoadGame(uLoadGameUI_SelectedSlot);
542 uGameState = 3;
543 }
544 goto _release_tex_and_continue;
545 case UIMSG_SaveGame:
546 if ( pGUIWindow_CurrentMenu->field_40 == v0 )
547 {
548 pKeyActionMap->_459ED1(0);
549 strcpy(
550 (char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot,
551 (const char *)pKeyActionMap->pPressedKeysBuffer);
552 }
553 DoSavegame(uLoadGameUI_SelectedSlot);
554 goto _release_tex_and_continue;
555 case UIMSG_StartNewGame|0x2:
556 pGUIWindow_CurrentMenu->Release();
557 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 11;
558 GameUI_DrawSaveMenu();
559 goto _continue;
560 case UIMSG_Game_OpenOptionsDialog:
561 if ( pMessageQueue_50CBD0->uNumMessages )
562 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
563 pGUIWindow_CurrentMenu->Release();
564 viewparams->field_48 = v0;
565 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 2;
566 uTextureID_507C60 = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
567 uTextureID_507C6C = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
568 uTextureID_507C68 = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
569 uTextureID_507C70 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
570 uTextureID_507C74 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
571 uTextureID_507C64[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
572 pTextureIDs_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
573 pTextureIDs_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
574 pTextureIDs_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
575 pTextureIDs_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
576 pTextureIDs_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
577 pTextureIDs_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
578 pTextureIDs_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
579 pTextureIDs_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
580 pTextureIDs_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
581 pTextureIDs_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
582 uTextureID_507C84 = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
583 uTextureID_507CB0 = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
584 uTextureID_507CB8 = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
585 uTextureID_507CB4 = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
586 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_Options, 0, 0);
587 pGUIWindow_CurrentMenu->CreateButton(
588 0x16u,
589 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,
593 0,
594 0xB8u,
595 0x80u,
596 0,
597 v1,
598 0);
599 pGUIWindow_CurrentMenu->CreateButton(
600 0x5Du,
601 0x10Eu,
602 (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureWidth : 24),
603 (uTextureID_507C68 != -1 ? pIcons_LOD->pTextures[uTextureID_507C68].uTextureHeight : 26),
604 v0,
605 0,
606 0xB8u,
607 0x40u,
608 0,
609 v1,
610 0);
611 pGUIWindow_CurrentMenu->CreateButton(
612 0xA4u,
613 0x10Eu,
614 (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureWidth : 24),
615 (uTextureID_507C64[0] != -1 ? pIcons_LOD->pTextures[uTextureID_507C64[0]].uTextureHeight : 26),
616 v0,
617 0,
618 0xB8u,
619 0,
620 0,
621 v1,
622 0);
623 pGUIWindow_CurrentMenu->CreateButton(
624 0x14u,
625 0x12Fu,
626 (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureWidth : 24),
627 (uTextureID_507CB4 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB4].uTextureHeight : 26),
628 v0,
629 0,
630 0xB9u,
631 0,
632 0,
633 v1,
634 0);
635 pGUIWindow_CurrentMenu->CreateButton(
636 0x80u,
637 0x12Fu,
638 (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureWidth : 24),
639 (uTextureID_507CB8 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB8].uTextureHeight : 26),
640 v0,
641 0,
642 0xBBu,
643 0,
644 0,
645 v1,
646 0);
647 pGUIWindow_CurrentMenu->CreateButton(
648 0x14u,
649 0x145u,
650 (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureWidth : 24),
651 (uTextureID_507CB0 != -1 ? pIcons_LOD->pTextures[uTextureID_507CB0].uTextureHeight : 26),
652 v0,
653 0,
654 0xE1u,
655 0,
656 0,
657 v1,
658 0);
659 pGUIWindow_CurrentMenu->CreateButton(
660 0x80u,
661 0x145u,
662 (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureWidth : 24),
663 (uTextureID_507C84 != -1 ? pIcons_LOD->pTextures[uTextureID_507C84].uTextureHeight : 26),
664 v0,
665 0,
666 0xE2u,
667 0,
668 0,
669 v1,
670 0);
671 ptr_50C9CC = pGUIWindow_CurrentMenu->CreateButton(
672 243u,
673 162u,
674 16u,
675 16u,
676 v0,
677 0,
678 111u,
679 4u,
680 0,
681 v1,
682 &pIcons_LOD->pTextures[uTextureID_507C70],
683 0);
684 ptr_50C9C8 = pGUIWindow_CurrentMenu->CreateButton(
685 0x1B3u,
686 0xA2u,
687 0x10u,
688 0x10u,
689 v0,
690 0,
691 0x6Fu,
692 5u,
693 0,
694 v1,
695 &pIcons_LOD->pTextures[uTextureID_507C74],
696 0);
697 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, 0x6Fu, 0, 0, v1, 0);
698 ptr_50C9CC = pGUIWindow_CurrentMenu->CreateButton(
699 0xF3u,
700 0xD8u,
701 0x10u,
702 0x10u,
703 v0,
704 0,
705 0x70u,
706 4u,
707 0,
708 v1,
709 &pIcons_LOD->pTextures[uTextureID_507C70],
710 0);
711 ptr_50C9C8 = pGUIWindow_CurrentMenu->CreateButton(
712 0x1B3u,
713 0xD8u,
714 0x10u,
715 0x10u,
716 v0,
717 0,
718 0x70u,
719 5u,
720 0,
721 v1,
722 &pIcons_LOD->pTextures[uTextureID_507C74],
723 0);
724 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, 0x70u, 0, 0, v1, 0);
725 ptr_50C9CC = pGUIWindow_CurrentMenu->CreateButton(
726 0xF3u,
727 0x10Eu,
728 0x10u,
729 0x10u,
730 v0,
731 0,
732 0xBAu,
733 4u,
734 0,
735 v1,
736 &pIcons_LOD->pTextures[uTextureID_507C70],
737 0);
738 ptr_50C9C8 = pGUIWindow_CurrentMenu->CreateButton(
739 0x1B3u,
740 0x10Eu,
741 0x10u,
742 0x10u,
743 v0,
744 0,
745 0xBAu,
746 5u,
747 0,
748 v1,
749 &pIcons_LOD->pTextures[uTextureID_507C74],
750 0);
751 pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, 0xBAu, 0, 0, v1, 0);
752 pGUIWindow_CurrentMenu->CreateButton(
753 0xF1u,
754 0x12Eu,
755 0xD6u,
756 0x28u,
757 v0,
758 0,
759 0x71u,
760 0,
761 0,
762 pGlobalTXT_LocalizationStrings[619],// "Return to Game"
763 0);
764 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, 0x19Fu, 0, 0x4Bu, v1, 0);
765 v164 = 0;
766 v150 = v1;
767 v143 = 86;
768 v138 = 0;
769 v134 = 421;
770 v131 = 0;
771 v129 = v0;
772 v126 = 40;
773 v124 = 214;
774 v122 = 194;
775 v120 = 19;
776 goto LABEL_117;
777 case UIMSG_OpenKeyMappingOptions:
778 if ( pMessageQueue_50CBD0->uNumMessages )
779 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
780 pGUIWindow_CurrentMenu->Release();
781 viewparams->field_48 = 1;
782 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 26;
783 uTextureID_507BF4 = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
784 uTextureID_507BF8 = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
785 uTextureID_507BFC = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
786 uTextureID_507C00 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
787 uTextureID_507C04 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
788 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_KeyMappingOptions, 0, 0);
789 pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, nullstring, 0);
790 pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, nullstring, 0);
791 pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, nullstring, 0);
792 pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, nullstring, 0);
793 pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, nullstring, 0);
794 pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, nullstring, 0);
795 pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, nullstring, 0);
796 pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, nullstring, 0);
797 pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, nullstring, 0);
798 pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, nullstring, 0);
799 pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, nullstring, 0);
800 pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, nullstring, 0);
801 pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, nullstring, 0);
802 pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, nullstring, 0);
803 pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, nullstring, 0);
804 pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, nullstring, 0);
805 pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, nullstring, 0);
806 pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, nullstring, 0);
807 pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, nullstring, 0);
808 dword_506E68 = -1;
809 dword_506F08 = 1;
810 memset(word_506E6C, 0, 0x1Cu);
811 word_506E6C[14] = 0;
812 memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
813 goto LABEL_90;
814 default:
815 goto _continue;
816 case UIMSG_ResetKeyMapping|0x1:
817 if ( dword_506E68 != -1 )
818 goto LABEL_623;
819 v14 = uMessageParam;
820 if ( dword_506F08 != v0 )
821 v14 = uMessageParam + 14;
822 dword_506E68 = v14;
823 pKeyActionMap->_459E5A(0, v0, pGUIWindow_CurrentMenu);
824 goto _continue;
825 case UIMSG_ResetKeyMapping:
826 v197 = 1;
827 pKeyActionMap->SetDefaultMapping();
828 uAction = 0;
829 do
830 {
831 v15 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
832 if ( v15 != pPrevVirtualCidesMapping[uAction] )
833 {
834 if ( v197 )
835 {
836 v16 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
837 GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v16, v0);
838 v197 = 0;
839 }
840 else
841 {
842 v17 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
843 GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[uAction]), v17, 0);
844 }
845 }
846 pPrevVirtualCidesMapping[uAction] = pKeyActionMap->GetActionVKey(
847 (enum InputAction)uAction);
848 v18 = uAction++;
849 v13 = __OFSUB__(uAction, 28);
850 v12 = uAction - 28 < 0;
851 *((char *)word_506E6C + v18) = 0;
852 }
853 while ( v12 ^ v13 );
854 v165 = 0;
855 v151 = 0;
856 v144 = 0;
857 v139 = 0;
858 v135 = -1;
859 v132 = 0;
860 v130 = 0;
861 v127 = 219;
862 goto _play_sound_and_continue;
863 case 0x1A0:
864 dword_506F08 = v0;
865 goto _continue;
866 case UIMSG_StartNPCDialogue|0x100:
867 dword_506F08 = 2;
868 goto _continue;
869 case UIMSG_OpenVideoOptions:
870 if ( pMessageQueue_50CBD0->uNumMessages )
871 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
872 pGUIWindow_CurrentMenu->Release();
873 viewparams->field_48 = v0;
874 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 28;
875 uTextureID_507C10 = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE);
876 uTextureID_507C14 = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE);
877 uTextureID_507C18 = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE);
878 uTextureID_507C1C = pIcons_LOD->LoadTexture("opvdH-tn", TEXTURE_16BIT_PALETTE);
879 uTextureID_507C20 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
880 uTextureID_507C24 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
881 pTextureIDs_GammaPositions[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
882 pTextureIDs_GammaPositions[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
883 pTextureIDs_GammaPositions[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
884 pTextureIDs_GammaPositions[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
885 pTextureIDs_GammaPositions[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
886 pTextureIDs_GammaPositions[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
887 pTextureIDs_GammaPositions[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
888 pTextureIDs_GammaPositions[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
889 pTextureIDs_GammaPositions[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
890 pTextureIDs_GammaPositions[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
891 uTextureID_507C50 = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE);
892 uTextureID_507C54 = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE);
893 uTextureID_507C58 = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE);
894 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_VideoOptions, 0, 0);
895 pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0, v1, 0);
896 if ( pRenderer->pRenderD3D )
897 {
898 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, v0, 0, 0x1A6u, 0, 0, v1, 0);
899 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, v0, 0, 0x1A7u, 0, 0, v1, 0);
900 pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, v0, 0, 0x1A8u, 0, 0, v1, 0);
901 }
902 if ( !pRenderer->bWindowMode )
903 {
904 v0 = 1;
905 if ( GammaController::IsGammaSupported() )
906 {
907 ptr_50C9CC = pGUIWindow_CurrentMenu->CreateButton(
908 0x15u,
909 0xA1u,
910 0x10u,
911 0x10u,
912 1,
913 0,
914 0x1A9u,
915 4u,
916 0,
917 v1,
918 &pIcons_LOD->pTextures[uTextureID_507C20],
919 0);
920 ptr_50C9C8 = pGUIWindow_CurrentMenu->CreateButton(
921 0xD5u,
922 0xA1u,
923 0x10u,
924 0x10u,
925 1,
926 0,
927 0x1A9u,
928 5u,
929 0,
930 v1,
931 &pIcons_LOD->pTextures[uTextureID_507C24],
932 0);
933 v164 = 0;
934 v150 = v1;
935 v143 = 0;
936 v138 = 0;
937 v134 = 425;
938 v131 = 0;
939 v129 = 1;
940 v126 = 18;
941 v124 = 170;
942 v122 = 162;
943 v120 = 42;
944 LABEL_117:
945 pGUIWindow_CurrentMenu->CreateButton(
946 v120,
947 v122,
948 v124,
949 v126,
950 v129,
951 v131,
952 v134,
953 v138,
954 v143,
955 v150,
956 v164);
957 }
958 }
959 goto _continue;
960 case UIMSG_ToggleTint|0x1:
961 if ( uMessageParam == 4 )
962 {
963 --uGammaPos;
964 if ( (uGammaPos & 0x80000000u) != 0 )
965 {
966 uGammaPos = 0;
967 goto LABEL_128;
968 }
969 v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
970 pGame->pGammaController->Initialize(v19);
971 v166 = v0;
972 v152 = (int)ptr_50C9CC;
973 v145 = (WindowType)90;
974 v140 = 0;
975 v136 = 0;
976 v20 = 21;
977 goto LABEL_122;
978 }
979 if ( uMessageParam == 5 )
980 {
981 ++uGammaPos;
982 if ( (signed int)uGammaPos <= 9 )
983 {
984 v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
985 pGame->pGammaController->Initialize(v21);
986 v20 = 213;
987 v166 = v0;
988 v152 = (int)ptr_50C9C8;
989 v145 = (WindowType)90;
990 v140 = 0;
991 v136 = 0;
992 LABEL_122:
993 GUIWindow::Create(v20, 0xA1u, v136, v140, v145, v152, v166);
994 goto LABEL_128;
995 }
996 uGammaPos = 9;
997 }
998 else
999 {
1000 uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17;
1001 v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
1002 pGame->pGammaController->Initialize(v22);
1003 }
1004 LABEL_128:
1005 v165 = 0;
1006 v151 = 0;
1007 v144 = 0;
1008 v139 = 0;
1009 v135 = -1;
1010 v132 = 0;
1011 v130 = 0;
1012 v127 = 21;
1013 goto _play_sound_and_continue;
1014 case UIMSG_ToggleBloodsplats:
1015 pGame->ToggleFlags2(0x20u);
1016 goto _continue;
1017 case UIMSG_ToggleColoredLights:
1018 pRenderer->bUseColoredLights = pRenderer->bUseColoredLights == 0;
1019 goto _continue;
1020 case UIMSG_ToggleTint:
1021 pRenderer->bTinting = pRenderer->bTinting == 0;
1022 goto _continue;
1023 case UIMSG_ChangeMusicVolume:
1024 if ( uMessageParam == 4 )
1025 {
1026 --uMusicVolimeMultiplier;
1027 if ( (char)uMusicVolimeMultiplier < 1 )
1028 uMusicVolimeMultiplier = 0;
1029 v167 = v0;
1030 v23 = 243;
1031 v153 = (int)ptr_50C9CC;
1032 LABEL_136:
1033 GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
1034 goto LABEL_143;
1035 }
1036 if ( uMessageParam == 5 )
1037 {
1038 ++uMusicVolimeMultiplier;
1039 if ( (char)uMusicVolimeMultiplier > 9 )
1040 uMusicVolimeMultiplier = 9;
1041 v167 = v0;
1042 v23 = 435;
1043 v153 = (int)ptr_50C9C8;
1044 goto LABEL_136;
1045 }
1046 uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;
1047 if ( (char)uMusicVolimeMultiplier > 9 )
1048 uMusicVolimeMultiplier = 9;
1049 LABEL_143:
1050 if ( uMusicVolimeMultiplier )
1051 pAudioPlayer->PlaySound(
1052 SOUND_Bell,
1053 -1,
1054 0,
1055 -1,
1056 0,
1057 0,
1058 (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0),
1059 0);
1060 pAudioPlayer->SetMusicVolume(
1061 (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
1062 goto _continue;
1063 case UIMSG_ChangeSoundVolume:
1064 if ( uMessageParam == 4 )
1065 {
1066 --uSoundVolumeMultiplier;
1067 if ( (char)uSoundVolumeMultiplier < 1 )
1068 uSoundVolumeMultiplier = 0;
1069 v168 = v0;
1070 v24 = 243;
1071 v154 = (int)ptr_50C9CC;
1072 LABEL_150:
1073 GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
1074 goto LABEL_157;
1075 }
1076 if ( uMessageParam == 5 )
1077 {
1078 ++uSoundVolumeMultiplier;
1079 if ( (char)uSoundVolumeMultiplier > 8 )
1080 uSoundVolumeMultiplier = 9;
1081 v168 = v0;
1082 v24 = 435;
1083 v154 = (int)ptr_50C9C8;
1084 goto LABEL_150;
1085 }
1086 uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17;
1087 if ( (char)uSoundVolumeMultiplier > 8 )
1088 uSoundVolumeMultiplier = 9;
1089 LABEL_157:
1090 pAudioPlayer->SetMasterVolume(
1091 (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0));
1092 v165 = 0;
1093 v151 = 0;
1094 v144 = 0;
1095 v139 = 0;
1096 v135 = -1;
1097 v132 = 0;
1098 v130 = -1;
1099 v127 = 218;
1100 goto _play_sound_and_continue;
1101 case UIMSG_ToggleFlipOnExit:
1102 bFlipOnExit = bFlipOnExit == 0;
1103 goto _continue;
1104 case UIMSG_ToggleAlwaysRun:
1105 bAlwaysRun = bAlwaysRun == 0;
1106 goto _continue;
1107 case UIMSG_ToggleWalkSound:
1108 bWalkSound = bWalkSound == 0;
1109 goto _continue;
1110 case UIMSG_ToggleShowDamage:
1111 bShowDamage = bShowDamage == 0;
1112 goto _continue;
1113 case UIMSG_ChangeVoiceVolume:
1114 if ( uMessageParam == 4 )
1115 {
1116 --uVoicesVolumeMultiplier;
1117 if ( (char)uVoicesVolumeMultiplier < 1 )
1118 uVoicesVolumeMultiplier = 0;
1119 v169 = v0;
1120 v25 = 243;
1121 v155 = (int)ptr_50C9CC;
1122 LABEL_166:
1123 GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
1124 goto LABEL_173;
1125 }
1126 if ( uMessageParam == 5 )
1127 {
1128 ++uVoicesVolumeMultiplier;
1129 if ( (char)uVoicesVolumeMultiplier > 8 )
1130 uVoicesVolumeMultiplier = 9;
1131 v169 = v0;
1132 v25 = 435;
1133 v155 = (int)ptr_50C9C8;
1134 goto LABEL_166;
1135 }
1136 uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17;
1137 if ( (char)uVoicesVolumeMultiplier > 8 )
1138 uVoicesVolumeMultiplier = 9;
1139 LABEL_173:
1140 if ( !uVoicesVolumeMultiplier )
1141 goto _continue;
1142 v165 = 0;
1143 v151 = (signed __int64)(pSoundVolumeLevels[(char)uVoicesVolumeMultiplier] * 128.0);
1144 v144 = 0;
1145 v139 = 0;
1146 v135 = -1;
1147 v132 = 0;
1148 v130 = -1;
1149 v127 = 5788;
1150 goto _play_sound_and_continue;
1151 case UIMSG_SetTurnSpeed:
1152 if ( uMessageParam )
1153 pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
1154 uTurnSpeed = uMessageParam;
1155 goto _continue;
1156 case UIMSG_SetGraphicsMode:
1157 if ( !bUseLoResSprites )
1158 {
1159 byte_6BE388_graphicsmode = uMessageParam;
1160 LABEL_184:
1161 MM7Initialization();
1162 goto _continue;
1163 }
1164 if ( uMessageParam )
1165 {
1166 if ( uMessageParam == 1 )
1167 {
1168 byte_6BE388_graphicsmode = 0;
1169 }
1170 else
1171 {
1172 if ( uMessageParam != 2 )
1173 goto _continue;
1174 byte_6BE388_graphicsmode = 1;
1175 }
1176 goto LABEL_184;
1177 }
1178 ModalWindow(pstr_722494, 0);
1179 goto _continue;
1180 case UIMSG_SkillUp|0x2:
1181 pGUIWindow_CurrentMenu->Release();
1182 pEventTimer->Resume();
1183 goto LABEL_188;
1184 case UIMSG_OpenQuestBook:
1185 if ( pMessageQueue_50CBD0->uNumMessages )
1186 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1187 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1188 pGUIWindow_CurrentMenu->Release();
1189 pEventTimer->Pause();
1190 pAudioPlayer->StopChannels(-1, -1);
1191 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1192 ptr_507BE0 = GUIWindow::Create(493u, 355u, 0, 0, (enum WindowType)99, (int)ptr_507A10, 0);
1193 bFlashQuestBook = 0;
1194 goto _continue;
1195 case UIMSG_OpenAutonotes:
1196 if ( pMessageQueue_50CBD0->uNumMessages )
1197 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1198 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1199 pGUIWindow_CurrentMenu->Release();
1200 pEventTimer->Pause();
1201 pAudioPlayer->StopChannels(-1, -1);
1202 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1203 ptr_507BE0 = GUIWindow::Create(527u, 353u, 0, 0, (enum WindowType)99, (int)ptr_507A0C, 0);
1204 bFlashAutonotesBook = 0;
1205 goto _continue;
1206 case UIMSG_OpenMapBook:
1207 if ( pMessageQueue_50CBD0->uNumMessages )
1208 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1209 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1210 pGUIWindow_CurrentMenu->Release();
1211 pEventTimer->Pause();
1212 viewparams->sPartyPosX = pParty->vPosition.x;
1213 viewparams->sPartyPosZ = pParty->vPosition.z;
1214 pAudioPlayer->StopChannels(-1, -1);
1215 v26 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
1216 v27 = 353;
1217 v28 = 546;
1218 v170 = 0;
1219 v156 = (int)ptr_507A08;
1220 goto LABEL_210;
1221 case UIMSG_OpenCalendar:
1222 if ( pMessageQueue_50CBD0->uNumMessages )
1223 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1224 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1225 pGUIWindow_CurrentMenu->Release();
1226 pEventTimer->Pause();
1227 pAudioPlayer->StopChannels(-1, -1);
1228 v26 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_Book, uMessage, 0);
1229 v27 = 354;
1230 v28 = 570;
1231 v170 = 0;
1232 v156 = (int)dword_507A04;
1233 LABEL_210:
1234 pGUIWindow_CurrentMenu = v26;
1235 ptr_507BE0 = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
1236 goto _continue;
1237 case UIMSG_OpenHistoryBook:
1238 if ( pMessageQueue_50CBD0->uNumMessages )
1239 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1240 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1241 pGUIWindow_CurrentMenu->Release();
1242 pEventTimer->Pause();
1243 pAudioPlayer->StopChannels(-1, -1);
1244 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_Book, uMessage, 0);
1245 ptr_507BE0 = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)ptr_507A00, 0);
1246 bFlashHistoryBook = 0;
1247 goto _continue;
1248 case UIMSG_CloseBook:
1249 back_to_game();
1250 if ( pMessageQueue_50CBD0->uNumMessages )
1251 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1252 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 15 )
1253 {
1254 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions >= 17
1255 && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 18
1256 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 104) )
1257 {
1258 LABEL_229:
1259 if ( dword_50CDC8 )
1260 goto LABEL_232;
1261 sub_42FC15();
1262 goto LABEL_231;
1263 }
1264 }
1265 else
1266 {
1267 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions >= 14
1268 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4
1269 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
1270 goto LABEL_229;
1271 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13
1272 && !dword_50CDC8
1273 && !dword_5C35C8 )
1274 {
1275 sub_42FC15();
1276 dword_5C35C8 = 0;
1277 LABEL_231:
1278 uMessageParam = v0;
1279 goto LABEL_232;
1280 }
1281 }
1282 LABEL_232:
1283 if ( !ptr_507BDC )
1284 {
1285 pRenderer->ClearZBuffer(0, 479);
1286 viewparams->bRedrawGameUI = v0;
1287 viewparams->field_48 = v0;
1288 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1289 {
1290 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 103 )
1291 {
1292 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 104 )
1293 goto LABEL_321;
1294 }
1295 else
1296 {
1297 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions < 100 )
1298 {
1299 switch ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
1300 {
1301 case 23:
1302 pIcons_LOD->_4114F2();
1303 if ( some_active_character )
1304 {
1305 uActiveCharacter = some_active_character;
1306 uActiveCharacter = pParty->GetNextActiveCharacter();
1307 some_active_character = 0;
1308 if ( pParty->bTurnBasedModeOn )
1309 pTurnEngine->_40471C();
1310 dword_50C9D0 = 0;
1311 dword_50C9D4 = 0;
1312 dword_50C9D8 = 0;
1313 }
1314 if ( ptr_50C9A4 && ptr_50C9A4->uItemID )
1315 {
1316 LOBYTE(ptr_50C9A4->uAttributtes) &= 0xFu;
1317 dword_50C9A8 = 0;
1318 ptr_50C9A4 = 0;
1319 }
1320 goto LABEL_322;
1321 case 3:
1322 ptr_507BE0->Release();
1323 crt_deconstruct_ptr_6A0118();
1324 ptr_507BE0 = 0;
1325 pEventTimer->Resume();
1326 goto LABEL_322;
1327 case 11:
1328 case 12:
1329 pIcons_LOD->_4114F2();
1330 crt_deconstruct_ptr_6A0118();
1331 goto LABEL_291;
1332 case 15:
1333 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 10;
1334 goto _continue;
1335 case 10:
1336 v29 = ptr_507BB8;
1337 goto LABEL_249;
1338 case 25:
1339 v29 = ptr_507BC8;
1340 LABEL_249:
1341 v29->Release();
1342 pIcons_LOD->_4114F2();
1343 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
1344 viewparams->bRedrawGameUI = v0;
1345 pEventTimer->Resume();
1346 goto _continue;
1347 case 2:
1348 thisa = (signed int)&uTextureID_507C60;
1349 do
1350 {
1351 if ( *(int *)thisa )
1352 pIcons_LOD->pTextures[*(int *)thisa].Release();
1353 thisa += 4;
1354 }
1355 while ( thisa < (signed int)&dword_507CBC );
1356 memset(&uTextureID_507C60, 0, 0x5Cu);
1357 pIcons_LOD->_40F9C5();
1358 WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
1359 WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
1360 WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier);
1361 WriteWindowsRegistryInt("WalkSound", bWalkSound);
1362 WriteWindowsRegistryInt("ShowDamage", bShowDamage);
1363 WriteWindowsRegistryInt("graphicsmode", (unsigned __int8)byte_6BE388_graphicsmode);
1364 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun);
1365 WriteWindowsRegistryInt("FlipOnExit", bFlipOnExit);
1366 if ( !uTurnSpeed )
1367 {
1368 v171 = 3;
1369 goto LABEL_261;
1370 }
1371 if ( uTurnSpeed == 64 )
1372 {
1373 v171 = 2;
1374 LABEL_261:
1375 v30 = v171;
1376 goto LABEL_262;
1377 }
1378 if ( uTurnSpeed != 128 )
1379 goto LABEL_291;
1380 v30 = v0;
1381 LABEL_262:
1382 v31 = "TurnDelta";
1383 LABEL_263:
1384 WriteWindowsRegistryInt(v31, v30);
1385 LABEL_291:
1386 stru_506E40.Release();
1387 break;
1388 case 1:
1389 pIcons_LOD->_40F9C5();
1390 pIcons_LOD->_4114F2();
1391 pIcons_LOD->_40F9C5();
1392 pIcons_LOD->_4114F2();
1393 goto LABEL_291;
1394 case 28:
1395 if ( pRenderer->pRenderD3D )
1396 {
1397 WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights);
1398 WriteWindowsRegistryInt("Tinting", pRenderer->bTinting);
1399 WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
1400 }
1401 if ( pRenderer->bWindowMode )
1402 goto LABEL_291;
1403 v30 = uGammaPos;
1404 v31 = "GammaPos";
1405 goto LABEL_263;
1406 case 26:
1407 v197 = 1;
1408 v32 = 0;
1409 while ( *((char *)word_506E6C + v32) != 1 )
1410 {
1411 ++v32;
1412 if ( v32 >= 28 )
1413 {
1414 thisb = (signed int)&uTextureID_507BF4;
1415 do
1416 {
1417 if ( *(int *)thisb )
1418 pIcons_LOD->pTextures[*(int *)thisb].Release();
1419 thisb += 4;
1420 }
1421 while ( thisb < (signed int)&dword_507C08 );
1422 memset(&uTextureID_507BF4, 0, 0x14u);
1423 pIcons_LOD->_40F9C5();
1424 uAction = 0;
1425 do
1426 {
1427 v33 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1428 if ( v33 != pPrevVirtualCidesMapping[uAction] )
1429 {
1430 if ( v197 )
1431 {
1432 v34 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1433 GUI_ReplaceHotkey(v34, LOBYTE(pPrevVirtualCidesMapping[uAction]), v0);
1434 v197 = 0;
1435 }
1436 else
1437 {
1438 v35 = pKeyActionMap->GetActionVKey((enum InputAction)uAction);
1439 GUI_ReplaceHotkey(v35, LOBYTE(pPrevVirtualCidesMapping[uAction]), 0);
1440 }
1441 }
1442 if ( uAction
1443 && uAction != 2
1444 && uAction != 3
1445 && uAction != v0
1446 && uAction != 25
1447 && uAction != 26 )
1448 v172 = (KeyToggleType)v0;
1449 else
1450 v172 = (KeyToggleType)0;
1451 pKeyActionMap->SetKeyMapping(
1452 uAction,
1453 pPrevVirtualCidesMapping[uAction],
1454 v172);
1455 ++uAction;
1456 }
1457 while ( uAction < 28 );
1458 pKeyActionMap->StoreMappings();
1459 goto LABEL_291;
1460 }
1461 }
1462 goto LABEL_623;
1463 case 5:
1464 if ( dword_506F14 )
1465 {
1466 Rest(_506F18_num_hours_to_sleep);
1467 pParty->pPlayers[3].pConditions[2] = 0i64;
1468 pParty->pPlayers[2].pConditions[2] = 0i64;
1469 pParty->pPlayers[1].pConditions[2] = 0i64;
1470 pParty->pPlayers[0].pConditions[2] = 0i64;
1471 }
1472 pTexture_RestUI_CurrentSkyFrame->Release();
1473 pTexture_RestUI_CurrentHourglassFrame->Release();
1474 pTexture_RestUI_CurrentHourglassFrame = 0;
1475 pTexture_RestUI_CurrentSkyFrame = 0;
1476 pIcons_LOD->_40F9C5();
1477 pIcons_LOD->_4114F2();
1478 _506F18_num_hours_to_sleep = 0;
1479 dword_506F14 = 0;
1480 dword_507B94 = v0;
1481 goto LABEL_322;
1482 case 14:
1483 pGUIWindow_CurrentMenu->Release();
1484 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 13;
1485 pIcons_LOD->_4114F2();
1486 goto _continue;
1487 case 13:
1488 if ( uDialogueType )
1489 uDialogueType = 0;
1490 if ( uGameState == 2 )
1491 {
1492 while ( sub_4BD8B5() )
1493 ;
1494 }
1495 else
1496 {
1497 if ( sub_4BD8B5() )
1498 goto _continue;
1499 }
1500 sub_4B1D27();
1501 pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 814, 0, -1, 0, 0, 0, 0);
1502 pVideoPlayer->Unload();
1503 pGUIWindow_CurrentMenu = ptr_507BC0;
1504 goto LABEL_322;
1505 case 18:
1506 if ( uCurrentHouse_Animation == 153 )
1507 HousePlaySomeSound(0x99u, 3);
1508 pVideoPlayer->Unload();
1509 goto LABEL_306;
1510 case 4:
1511 LABEL_306:
1512 if ( dword_5B65CC )
1513 {
1514 pParty->field_709 = 0;
1515 LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
1516 sub_44A56A();
1517 viewparams->bRedrawGameUI = v0;
1518 dword_5B65CC = 0;
1519 }
1520 goto LABEL_317;
1521 case 19:
1522 memset(GameUI_StatusBar_TimedString, 0, 0xC8u);
1523 sub_4452BB();
1524 goto LABEL_317;
1525 case 17:
1526 if ( pParty->vPosition.x < -22528 )
1527 pParty->vPosition.x = -22528;
1528 if ( pParty->vPosition.x > 22528 )
1529 pParty->vPosition.x = 22528;
1530 if ( pParty->vPosition.z < -22528 )
1531 pParty->vPosition.z = -22528;
1532 if ( pParty->vPosition.z > 22528 )
1533 pParty->vPosition.z = 22528;
1534 goto LABEL_317;
1535 case 16:
1536 pVideoPlayer->Unload();
1537 goto _continue;
1538 case 7:
1539 goto LABEL_319;
1540 default:
1541 goto LABEL_322;
1542 }
1543 goto LABEL_322;
1544 }
1545 LABEL_319:
1546 sub_4196A0();
1547 sub_419379();
1548 LABEL_321:
1549 pIcons_LOD->_4114F2();
1550 }
1551 LABEL_322:
1552 if ( ptr_507BD4 )
1553 {
1554 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 7 )
1555 {
1556 pMouse->SetCursorBitmap("MICON2");
1557 }
1558 else
1559 {
1560 ptr_507BD4->Release();
1561 ptr_507BD4 = 0;
1562 pMouse->SetCursorBitmap("MICON1");
1563 GameUI_StatusBar_TimedStringTimeLeft = 0;
1564 unk_50C9A0 = 0;
1565 back_to_game();
1566 }
1567 }
1568 if ( (signed int)uActiveCharacter < v0 || (signed int)uActiveCharacter > 4 )
1569 uActiveCharacter = pParty->GetNextActiveCharacter();
1570 pGUIWindow_CurrentMenu->Release();
1571 if ( pGUIWindow_CurrentMenu == ptr_507BC0 )
1572 ptr_507BC0 = 0;
1573 pGUIWindow_CurrentMenu = 0;
1574 pEventTimer->Resume();
1575 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
1576 viewparams->bRedrawGameUI = v0;
1577 pIcons_LOD->_4355F7();
1578 goto _continue;
1579 }
1580 v36 = ptr_507BD4;
1581 if ( !ptr_507BD4 )
1582 {
1583 dword_6BE138 = -1;
1584 GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)90, (int)ptr_5079F0, v0);
1585 pEventTimer->Pause();
1586 pAudioPlayer->StopChannels(-1, -1);
1587 ++pIcons_LOD->uTexturePacksCount;
1588 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v0;
1589 if ( !pIcons_LOD->uNumPrevLoadedFiles )
1590 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
1591 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, (enum WindowType)3, 0, 0);
1592 uTextureID_507944 = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
1593 uTextureID_507940 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
1594 uTextureID_50793C = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
1595 uTextureID_507938 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE);
1596 uTextureID_507934 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE);
1597 uTextureID_507930 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
1598 uTextureID_50792C = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
1599 ptr_50C9C4 = pGUIWindow_CurrentMenu->CreateButton(
1600 0x13u,
1601 0x9Bu,
1602 0xD6u,
1603 0x28u,
1604 v0,
1605 0,
1606 0x7Cu,
1607 0,
1608 0x4Eu,
1609 pGlobalTXT_LocalizationStrings[614],// "New Game"
1610 (Texture *)(uTextureID_507940 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507940] : 0),
1611 0);
1612 ptr_50C9C0 = pGUIWindow_CurrentMenu->CreateButton(
1613 0x13u,
1614 0xD1u,
1615 0xD6u,
1616 0x28u,
1617 v0,
1618 0,
1619 0x7Eu,
1620 0,
1621 0x53u,
1622 pGlobalTXT_LocalizationStrings[615],// "Save Game"
1623 (Texture *)(uTextureID_507938 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507938] : 0),
1624 0);
1625 ptr_50C9BC = pGUIWindow_CurrentMenu->CreateButton(
1626 0x13u,
1627 0x107u,
1628 0xD6u,
1629 0x28u,
1630 v0,
1631 0,
1632 0x7Du,
1633 0,
1634 0x4Cu,
1635 pGlobalTXT_LocalizationStrings[616],// "Load Game"
1636 (Texture *)(uTextureID_50793C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50793C] : 0),
1637 0);
1638 pyt_50C9B8 = pGUIWindow_CurrentMenu->CreateButton(
1639 0xF1u,
1640 0x9Bu,
1641 0xD6u,
1642 0x28u,
1643 v0,
1644 0,
1645 0x7Fu,
1646 0,
1647 0x43u,
1648 pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
1649 (Texture *)(uTextureID_507934 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507934] : 0),
1650 0);
1651 ptr_50C9B4 = pGUIWindow_CurrentMenu->CreateButton(
1652 0xF1u,
1653 0xD1u,
1654 0xD6u,
1655 0x28u,
1656 v0,
1657 0,
1658 0x84u,
1659 0,
1660 0x51u,
1661 pGlobalTXT_LocalizationStrings[618],// "Quit"
1662 (Texture *)(uTextureID_50792C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50792C] : 0),
1663 0);
1664 ptr_50C9B0 = pGUIWindow_CurrentMenu->CreateButton(
1665 0xF1u,
1666 0x107u,
1667 0xD6u,
1668 0x28u,
1669 v0,
1670 0,
1671 0x7Bu,
1672 0,
1673 0x52u,
1674 pGlobalTXT_LocalizationStrings[619],// "Return to Game"
1675 (Texture *)(uTextureID_507930 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507930] : 0),
1676 0);
1677 pGUIWindow_CurrentMenu->_41D08F(6, v0, 0, 0);
1678 viewparams->field_48 = v0;
1679 stru_506E40.Release();
1680 uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
1681 pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
1682 free((void *)uNumSeconds);
1683 stru_506E40._40E55E("gamma.pcx", 0);
1684 goto _continue;
1685 }
1686 goto LABEL_333;
1687 }
1688 sub_41426F();
1689 _continue:
1690 if ( !pMessageQueue_50CBD0->uNumMessages )
1691 break;
1692 continue;
1693 case UIMSG_BC:
1694 if ( uMessageParam )
1695 {
1696 GUIWindow::Create(0x272u, 0xB3u, 0, 0, (enum WindowType)90, (int)ptr_5079E8, 0);
1697 v37 = (pParty->pHirelings[0].pName != 0)
1698 + (pParty->pHirelings[1].pName != 0)
1699 + (unsigned __int8)pParty->field_70A
1700 - 2;
1701 if ( (unsigned __int8)pParty->field_709 < v37 )
1702 {
1703 ++pParty->field_709;
1704 if ( (unsigned __int8)pParty->field_709 >= v37 )
1705 pParty->field_709 = (pParty->pHirelings[0].pName != 0)
1706 + (pParty->pHirelings[1].pName != 0)
1707 + pParty->field_70A
1708 - 2;
1709 }
1710 }
1711 else
1712 {
1713 GUIWindow::Create(0x1D5u, 0xB3u, 0, 0, (enum WindowType)90, (int)ptr_5079EC, 0);
1714 if ( pParty->field_709 )
1715 {
1716 --pParty->field_709;
1717 if ( pParty->field_709 < 1 )
1718 pParty->field_709 = 0;
1719 }
1720 }
1721 DrawHiredNPCs();
1722 goto _continue;
1723 case UIMSG_OpenRestUI|0x2:
1724 if ( pMessageQueue_50CBD0->uNumMessages )
1725 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1726 dword_50CDC8 = v0;
1727 sub_42FBDD();
1728 HousePlaySomeSound(uCurrentHouse_Animation, 2);
1729 pVideoPlayer->Unload();
1730 sub_44603D();
1731 viewparams->bRedrawGameUI = v0;
1732 if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz )
1733 {
1734 if ( dword_59117C_teleportx )
1735 {
1736 pParty->vPosition.x = dword_59117C_teleportx;
1737 _5B65A8_npcdata_uflags_or_other = dword_59117C_teleportx;
1738 }
1739 if ( dword_591178_teleporty )
1740 {
1741 pParty->vPosition.z = dword_591178_teleporty;
1742 _5B65AC_npcdata_fame_or_other = dword_591178_teleporty;
1743 }
1744 if ( dword_591174_teleportz )
1745 {
1746 pParty->vPosition.y = dword_591174_teleportz;
1747 _5B65B0_npcdata_rep_or_other = dword_591174_teleportz;
1748 pParty->uFallStartY = dword_591174_teleportz;
1749 }
1750 if ( dword_591170_teleport_directiony )
1751 {
1752 pParty->sRotationY = dword_591170_teleport_directiony;
1753 _5B65B4_npcdata_loword_house_or_other = dword_591170_teleport_directiony;
1754 }
1755 if ( dword_59116C_teleport_directionx )
1756 {
1757 pParty->sRotationX = dword_59116C_teleport_directionx;
1758 _5B65B8_npcdata_hiword_house_or_other = dword_59116C_teleport_directionx;
1759 v38 = dword_591168_teleport_speedz;
1760 pParty->uFallSpeed = dword_591168_teleport_speedz;
1761 dword_5B65BC = dword_591168_teleport_speedz;
1762 }
1763 else
1764 {
1765 v38 = dword_5B65BC;
1766 }
1767 if ( *dword_591164_teleport_map_name != 48 )
1768 {
1769 pGameLoadingUI_ProgressBar->uType = 2;
1770 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;
1771 OnMapLeave();
1772 sub_44987B(dword_591164_teleport_map_name, 0);
1773 }
1774 }
1775 else
1776 {
1777 dword_597F18 = dword_5C341C;
1778 EventProcessor(dword_5C3418, 0, v0);
1779 }
1780 dword_597F18 = 0;
1781 if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
1782 pParty->uTimePlayed += 1474560i64;
1783 goto _continue;
1784 case 0x19C:
1785 sub_42FC15();
1786 pVideoPlayer->Unload();
1787 sub_44603D();
1788 dword_597F18 = 0;
1789 goto LABEL_422;
1790 case UIMSG_CycleCharacters:
1791 v39 = GetAsyncKeyState(VK_SHIFT);
1792 v40 = CycleCharacter(v39);
1793 goto LABEL_421;
1794 case UIMSG_LoadGame|0x8:
1795 if ( pMessageQueue_50CBD0->uNumMessages )
1796 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1797 dword_50CDC8 = v0;
1798 sub_42FBDD();
1799 v195 = (NPCData *)GetTravelTime();
1800 strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
1801 if ( bUnderwater != 1 && pParty->bFlying
1802 || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, &pOut, 20) != v0 )
1803 {
1804 viewparams->bRedrawGameUI = v0;
1805 LABEL_387:
1806 sub_42FC15();
1807 if ( pParty->vPosition.x < -22528 )
1808 pParty->vPosition.x = -22528;
1809 if ( pParty->vPosition.x > 22528 )
1810 pParty->vPosition.x = 22528;
1811 if ( pParty->vPosition.z < -22528 )
1812 pParty->vPosition.z = -22528;
1813 if ( pParty->vPosition.z > 22528 )
1814 pParty->vPosition.z = 22528;
1815 LABEL_317:
1816 sub_44603D();
1817 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
1818 }
1819 else
1820 {
1821 pParty->field_6E4 = 0;
1822 pParty->field_6E0 = 0;
1823 pStru277->_427D48(v0);
1824 sub_44603D();
1825 pEventTimer->Pause();
1826 pGameLoadingUI_ProgressBar->_443484(2);
1827 ++pGameLoadingUI_ProgressBar->uProgressMax;
1828 SaveGame(v0, 0);
1829 pGameLoadingUI_ProgressBar->Progress();
1830 RestAndHeal(1440 * (signed int)v195);
1831 if ( pParty->uNumFoodRations )
1832 {
1833 pParty->RestAndHeal();
1834 if ( ((pParty->uNumFoodRations - (signed int)v195) & 0x80000000u) != 0 )
1835 {
1836 thisc = pParty->pPlayers;
1837 do
1838 {
1839 thisc->SetCondition(v0, 0);
1840 ++thisc;
1841 }
1842 while ( (signed int)thisc < (signed int)pParty->pHirelings );
1843 ++pParty->field_764;
1844 }
1845 Party::TakeFood((unsigned int)v195);
1846 }
1847 else
1848 {
1849 thisd = pParty->pPlayers;
1850 do
1851 {
1852 thisd->SetCondition(v0, 0);
1853 ++thisd;
1854 }
1855 while ( (signed int)thisd < (signed int)pParty->pHirelings );
1856 ++pParty->field_764;
1857 }
1858 pPaletteManager->ResetNonLocked();
1859 pSpriteFrameTable->ResetSomeSpriteFlags();
1860 strcpy(pCurrentMapName, &pOut);
1861 strcpy(&pLevelName, pCurrentMapName);
1862 v41 = strtok(&pLevelName, ".");
1863 strcpy(&pLevelName, v41);
1864 Level_LoadEvtAndStr(&pLevelName);
1865 pDecalBuilder->Reset( 0);
1866 LoadLevel_InitializeLevelEvt();
1867 uLevelMapStatsID = pMapStats->GetMapInfo(pCurrentMapName);
1868 bUnderwater = 0;
1869 bNoNPCHiring = 0;
1870 pGame->uFlags2 &= 0xFFFFFFF7u;
1871 if ( Is_out15odm_underwater() )
1872 {
1873 bUnderwater = 1;
1874 pGame->uFlags2 |= 8u;
1875 }
1876 if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d47.blv") )
1877 bNoNPCHiring = 1;
1878 v0 = 1;
1879 PrepareToLoadODM(1u, (OutdoorCamera *)1);
1880 pAudioPlayer->SetMapEAX();
1881 bDialogueUI_InitializeActor_NPC_ID = 0;
1882 OnMapLoad();
1883 pOutdoor->SetFog();
1884 TeleportToStartingPoint(uLevel_StartingPointType);
1885 pParty->vPosition.y = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, (int *)&v213, 0);
1886 pParty->uFallStartY = pParty->vPosition.y;
1887 sub_461103();
1888 pEventTimer->Resume();
1889 viewparams->bRedrawGameUI = 1;
1890 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
1891 pGameLoadingUI_ProgressBar->Release();
1892 }
1893 goto LABEL_422;
1894 case UIMSG_SaveGame|0x8:
1895 goto LABEL_387;
1896 case UIMSG_BE:
1897 if ( pRenderer->pRenderD3D )
1898 {
1899 LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val();
1900 }
1901 else
1902 {
1903 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210);
1904 v43 = pMouse->GetCursorPos(&v208);
1905 v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[v43->y]];
1906 }
1907 v44 = (unsigned __int16)v42;
1908 v45 = v44 & 7;
1909 uNumSeconds = v44;
1910 v46 = v44 >> 3;
1911 if ( v45 == 3 )
1912 {
1913 v47 = pActors[v46].uAIState == Dead;
1914 goto LABEL_400;
1915 }
1916 if ( v45 == 2 )
1917 {
1918 v47 = (pObjectList->pObjects[pLayingItems[v46].uObjectDescID].uFlags & 0x10) == 0;
1919 LABEL_400:
1920 if ( !v47 )
1921 goto _continue;
1922 goto LABEL_415;
1923 }
1924 if ( v45 == 5 )
1925 {
1926 v48 = pLevelDecorations[v46].field_16_event_id == 0;
1927 }
1928 else
1929 {
1930 if ( v45 != 6 )
1931 goto _continue;
1932 if ( uCurrentlyLoadedLevelType != v0 )
1933 {
1934 v50 = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
1935 if ( !(BYTE3(v50->uFaceAttributes) & 2) || !v50->sCogTriggeredID )
1936 goto _continue;
1937 v44 = uNumSeconds;
1938 goto LABEL_415;
1939 }
1940 v49 = &pIndoor->pFaces[v46];
1941 if ( !(BYTE3(v49->uAttributes) & 2) )
1942 goto _continue;
1943 v48 = pIndoor->pFaceExtras[v49->uFaceExtraID].uEventID == 0;
1944 }
1945 if ( v48 )
1946 goto _continue;
1947 LABEL_415:
1948 v51 = ptr_507BD4->ptr_1C;
1949 *((char *)v51 + 8) &= 0xBFu;
1950 LABEL_416:
1951 *((short *)v51 + 2) = uMessageParam;
1952 *((int *)v51 + 3) = v44;
1953 pParty->pPlayers[*((short *)v51 + 1)].SetRecoveryTime(300);
1954 v36 = ptr_507BD4;
1955 LABEL_333:
1956 v36->Release();
1957 ptr_507BD4 = 0;
1958 pMouse->SetCursorBitmap("MICON1");
1959 GameUI_StatusBar_TimedStringTimeLeft = 0;
1960 unk_50C9A0 = 0;
1961 back_to_game();
1962 goto _continue;
1963 case UIMSG_ChangeGameState|0x40:
1964 case 0x8D:
1965 case 0x8F:
1966 if ( pMessageQueue_50CBD0->uNumMessages )
1967 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1968 if ( unk_50C9A0 )
1969 {
1970 v40 = uMessageParam;
1971 LABEL_421:
1972 uActiveCharacter = v40;
1973 LABEL_422:
1974 viewparams->bRedrawGameUI = v0;
1975 }
1976 else
1977 {
1978 if ( ptr_507BD4 )
1979 {
1980 v52 = ptr_507BD4->ptr_1C;
1981 switch ( uMessage )
1982 {
1983 case 69:
1984 *((char *)v52 + 8) &= 0xFDu;
1985 break;
1986 case 141:
1987 *((char *)v52 + 9) &= 0xFEu;
1988 break;
1989 case 143:
1990 *((char *)v52 + 9) &= 0xFDu;
1991 break;
1992 }
1993 *((short *)v52 + 2) = uMessageParam;
1994 pParty->pPlayers[*((short *)v52 + 1)].SetRecoveryTime(300);
1995 ptr_507BD4->Release();
1996 ptr_507BD4 = 0;
1997 pEventTimer->Resume();
1998 pMouse->SetCursorBitmap("MICON1");
1999 GameUI_StatusBar_TimedStringTimeLeft = 0;
2000 unk_50C9A0 = 0;
2001 }
2002 }
2003 goto _continue;
2004 case UIMSG_BF:
2005 dword_50CDC8 = v0;
2006 sub_42FBDD();
2007 SaveGame(v0, 0);
2008 strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename);
2009 dword_6BE364_game_settings_1 |= v0;
2010 uGameState = 2;
2011
2012
2013 //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C];
2014 v53 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1]._quest_related;
2015
2016 if ( v53 < 0 )
2017 {
2018 v54 = abs(v53) - 1;
2019 _5B65B8_npcdata_hiword_house_or_other = 0;
2020 dword_5B65BC = 0;
2021 v55 = dword_4E4560[v54];
2022 _5B65AC_npcdata_fame_or_other = dword_4E4578[v54];
2023 v56 = dword_4E4590[v54];
2024 v57 = dword_4E45A8[v54];
2025 _5B65A8_npcdata_uflags_or_other = v55;
2026 _5B65B4_npcdata_loword_house_or_other = v57;
2027 _5B65B0_npcdata_rep_or_other = v56;
2028 dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
2029 }
2030 sub_4BD8B5();
2031 goto LABEL_434;
2032 case UIMSG_C3:
2033 pAudioPlayer->StopChannels(-1, -1);
2034 v162 = uMessageParam;
2035 v148 = 195;
2036 goto LABEL_438;
2037 case UIMSG_B1:
2038 pAudioPlayer->StopChannels(-1, -1);
2039 v162 = 0;
2040 v148 = 177;
2041 LABEL_438:
2042 v141 = (WindowType)9;
2043 LABEL_439:
2044 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, v141, v148, v162);
2045 goto _continue;
2046 case UIMSG_B2:
2047 v165 = 0;
2048 v151 = 0;
2049 v144 = 0;
2050 v139 = 0;
2051 bRecallingBeacon = uMessageParam;
2052 v135 = -1;
2053 v132 = 0;
2054 v130 = 0;
2055 v127 = uMessageParam + 204;
2056 goto _play_sound_and_continue;
2057 case UIMSG_B4:
2058 if ( !pGUIWindow_CurrentMenu )
2059 goto _continue;
2060 v58 = pPlayers[_506348_current_lloyd_playerid + 1];
2061 uNumSeconds = (unsigned int)&v58->pInstalledBeacons[uMessageParam];
2062 if ( bRecallingBeacon )
2063 {
2064 if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) )
2065 goto _continue;
2066 v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v58->pInstalledBeacons[uMessageParam].field_18))].pName;
2067 v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s"
2068 goto _sprintex_2args_draw_status_and_continue;
2069 }
2070 v59 = pMapStats->GetMapInfo(pCurrentMapName);
2071 thise = "Not in Map Stats";
2072 if ( v59 )
2073 thise = pMapStats->pInfos[v59].pName;
2074 if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) || !v59 )
2075 {
2076 v173 = thise;
2077 v157 = pGlobalTXT_LocalizationStrings[476];// "Set to %s"
2078 goto _sprintex_2args_draw_status_and_continue;
2079 }
2080 v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
2081 v158 = (unsigned int)thise;
2082 v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
2083 _sprintex_draw_status_and_continue:
2084 sprintfex(pTmpBuf, v146, v158, v174);
2085 goto _set_status_string_pTmpBuf_and_continue;
2086 case UIMSG_B5:
2087 dword_50CDC8 = v0;
2088 goto LABEL_453;
2089 case UIMSG_B3:
2090 thisf = pPlayers[_506348_current_lloyd_playerid + 1];
2091 v195 = (NPCData *)&thisf->pInstalledBeacons[uMessageParam];
2092 if ( !*(_QWORD *)&v195->pName && bRecallingBeacon )
2093 goto _continue;
2094 byte_506360 = 1;
2095 thisf->CanCastSpell(uRequiredMana);
2096 if ( pParty->bTurnBasedModeOn )
2097 {
2098 v60 = sRecoveryTime;
2099 pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime;
2100 thisf->SetRecoveryTime(v60);
2101 pTurnEngine->_40471C();
2102 }
2103 else
2104 {
2105 thisf->SetRecoveryTime(
2106 (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
2107 }
2108 pAudioPlayer->PlaySound(
2109 (SoundID)word_4EE088_sound_ids[dword_506338],
2110 0,
2111 0,
2112 -1,
2113 0,
2114 dword_50633C,
2115 0,
2116 0);
2117 if ( bRecallingBeacon )
2118 {
2119 if ( _strcmpi(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(v195->uProfession)]) )
2120 {
2121 SaveGame(v0, 0);
2122 OnMapLeave();
2123 strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(v195->uProfession)]);
2124 dword_6BE364_game_settings_1 |= v0;
2125 uGameState = 2;
2126 _5B65A8_npcdata_uflags_or_other = v195->uFlags;
2127 _5B65AC_npcdata_fame_or_other = v195->fame;
2128 _5B65B0_npcdata_rep_or_other = v195->rep;
2129 _5B65B4_npcdata_loword_house_or_other = LOWORD(v195->house);
2130 _5B65B8_npcdata_hiword_house_or_other = HIWORD(v195->house);
2131 dword_5B65C0 = v0;
2132 }
2133 else
2134 {
2135 pParty->vPosition.x = v195->uFlags;
2136 pParty->vPosition.z = v195->fame;
2137 pParty->vPosition.y = v195->rep;
2138 pParty->uFallStartY = pParty->vPosition.y;
2139 pParty->sRotationY = LOWORD(v195->house);
2140 pParty->sRotationX = HIWORD(v195->house);
2141 }
2142 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2143 {
2144 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2145 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
2146 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2147 ++pMessageQueue_50CBD0->uNumMessages;
2148 }
2149 crt_deconstruct_ptr_6A0118();
2150 ptr_507BE0->Release();
2151 pGUIWindow_CurrentMenu->Release();
2152 ptr_507BE0 = 0;
2153 pGUIWindow_CurrentMenu = 0;
2154 }
2155 else
2156 {
2157 sprintfex(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
2158 SaveScreenshot(a1);
2159 LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
2160 v212 = qword_506350 << 7;
2161 v61 = v195;
2162 thisg = 0;
2163 v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
2164 v195->pName = (char *)v62;
2165 v61->uPortraitID = HIDWORD(v62);
2166 v61->uFlags = pParty->vPosition.x;
2167 v61->fame = pParty->vPosition.z;
2168 v61->rep = pParty->vPosition.y;
2169 LOWORD(v61->house) = LOWORD(pParty->sRotationY);
2170 HIWORD(v61->house) = LOWORD(pParty->sRotationX);
2171 if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
2172 goto _continue;
2173 uAction = 0;
2174 while ( _strcmpi((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
2175 {
2176 ++thisg;
2177 uAction += 32;
2178 if ( thisg >= (signed int)pGames_LOD->uNumSubIndices / 2 )
2179 goto _continue;
2180 }
2181 HIWORD(v195->uProfession) = thisg;
2182 }
2183 goto _continue;
2184 case UIMSG_B7:
2185 if ( uMessageParam )
2186 {
2187 switch ( uMessageParam )
2188 {
2189 case 1:
2190 v63 = 208;
2191 break;
2192 case 2:
2193 v63 = 207;
2194 break;
2195 case 3:
2196 v63 = 211;
2197 break;
2198 case 4:
2199 v63 = 209;
2200 break;
2201 default:
2202 if ( uMessageParam != 5 )
2203 {
2204 LABEL_486:
2205 SaveGame(v0, 0);
2206 v64 = pMapStats->GetMapInfo(pCurrentMapName);
2207 v65 = uMessageParam;
2208 if ( v64 == stru_4ECBB8[uMessageParam].uMapInfoID )
2209 {
2210 pParty->vPosition.x = stru_4ECBB8[v65].pos.x;
2211 pParty->vPosition.z = stru_4ECBB8[v65].pos.y;
2212 pParty->vPosition.y = stru_4ECBB8[v65].pos.z;
2213 pParty->uFallStartY = pParty->vPosition.y;
2214 pParty->sRotationY = stru_4ECBB8[v65].rot_y;
2215 pParty->sRotationX = stru_4ECBB8[v65].rot_x;
2216 }
2217 else
2218 {
2219 SaveGame(v0, 0);
2220 OnMapLeave();
2221 dword_6BE364_game_settings_1 |= v0;
2222 uGameState = 2;
2223 strcpy(pCurrentMapName, pMapStats->pInfos[stru_4ECBB8[uMessageParam].uMapInfoID].pFilename);
2224 dword_5B65C0 = v0;
2225 _5B65A8_npcdata_uflags_or_other = stru_4ECBB8[uMessageParam].pos.x;
2226 _5B65AC_npcdata_fame_or_other = stru_4ECBB8[uMessageParam].pos.y;
2227 _5B65B0_npcdata_rep_or_other = stru_4ECBB8[uMessageParam].pos.z;
2228 v66 = stru_4ECBB8[uMessageParam].rot_x;
2229 _5B65B4_npcdata_loword_house_or_other = stru_4ECBB8[uMessageParam].rot_y;
2230 _5B65B8_npcdata_hiword_house_or_other = v66;
2231 UpdateActors();
2232 }
2233 v67 = pGUIWindow_CurrentMenu->str_48;
2234 if ( v67 )
2235 *((int *)v67 + 17) = v0;
2236 else
2237 pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
2238 LABEL_434:
2239 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2240 {
2241 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2242 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
2243 LABEL_771:
2244 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2245 ++pMessageQueue_50CBD0->uNumMessages;
2246 }
2247 goto _continue;
2248 }
2249 v63 = 210;
2250 break;
2251 }
2252 }
2253 else
2254 {
2255 v63 = 206;
2256 }
2257 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v63) )
2258 return;
2259 goto LABEL_486;
2260 case UIMSG_B6:
2261 if ( uMessageParam )
2262 {
2263 switch ( uMessageParam )
2264 {
2265 case 1:
2266 v68 = 208;
2267 break;
2268 case 2:
2269 v68 = 207;
2270 break;
2271 case 3:
2272 v68 = 211;
2273 break;
2274 case 4:
2275 v68 = 209;
2276 break;
2277 default:
2278 if ( uMessageParam != 5 )
2279 goto LABEL_506;
2280 v68 = 210;
2281 break;
2282 }
2283 }
2284 else
2285 {
2286 v68 = 206;
2287 }
2288 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v68) )
2289 {
2290 pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
2291 goto _continue;
2292 }
2293 LABEL_506:
2294 if ( uMessageParam )
2295 {
2296 switch ( uMessageParam )
2297 {
2298 case 1:
2299 v69 = pMapStats->pInfos[4].pName;
2300 break;
2301 case 2:
2302 v69 = pMapStats->pInfos[3].pName;
2303 break;
2304 case 3:
2305 v69 = pMapStats->pInfos[10].pName;
2306 break;
2307 case 4:
2308 v69 = pMapStats->pInfos[7].pName;
2309 break;
2310 default:
2311 if ( uMessageParam != 5 )
2312 goto LABEL_519;
2313 v69 = pMapStats->pInfos[8].pName;
2314 break;
2315 }
2316 }
2317 else
2318 {
2319 v69 = pMapStats->pInfos[21].pName;
2320 }
2321 v200 = v69;
2322 LABEL_519:
2323 v173 = v200;
2324 v157 = pGlobalTXT_LocalizationStrings[35];
2325 goto _sprintex_2args_draw_status_and_continue;
2326 case UIMSG_ShowFinalWindow:
2327 sprintfex(
2328 pFinalMessage,
2329 "%s\n \n%s\n \n%s",
2330 pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer."
2331 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."
2332 pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team."
2333 ModalWindow(pFinalMessage, 196);
2334 uGameState = GAME_STATE_FINAL_WINDOW;
2335 goto _continue;
2336 case UIMSG_C4:
2337 uGameState = 0;
2338 strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
2339 goto LABEL_524;
2340 case UIMSG_D5|0x8:
2341 LABEL_524:
2342 sprintfex(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer);
2343 memcpy(
2344 &v216,
2345 texture_frame_table_txt_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218),
2346 sizeof(v216));
2347 if ( v216.field_0 == 1 )
2348 {
2349 v195 = (NPCData *)((signed int)pGames_LOD->uNumSubIndices / 2);
2350 v70 = atoi(v216.pProperties[0]);
2351 if ( v70 <= 0 || v70 >= 77 )
2352 {
2353 LABEL_90:
2354 v1 = nullstring;
2355 LABEL_91:
2356 v0 = 1;
2357 goto _continue;
2358 }
2359 v71 = v70;
2360 strcpy(Str2, pMapStats->pInfos[v70].pFilename);
2361 v72 = 0;
2362 if ( (signed int)v195 > 0 )
2363 {
2364 thish = 0;
2365 do
2366 {
2367 if ( !_strcmpi((const char *)&pGames_LOD->pSubIndices[thish], Str2) )
2368 break;
2369 ++thish;
2370 v72 = (NPCData *)((char *)v72 + 1);
2371 }
2372 while ( (signed int)v72 < (signed int)v195 );
2373 if ( (signed int)v72 < (signed int)v195 )
2374 {
2375 strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[(int)v72]);
2376 dword_6BE364_game_settings_1 |= 1u;
2377 uGameState = 2;
2378 OnMapLeave();
2379 goto LABEL_90;
2380 }
2381 }
2382 sprintfex(Str2, "No map found for %s", pMapStats->pInfos[v71].pName);
2383 v73 = Str2;
2384 }
2385 else
2386 {
2387 if ( v216.field_0 != 3 )
2388 goto LABEL_90;
2389 v74 = atoi(v216.pProperties[0]);
2390 thisi = atoi(v216.pProperties[1]);
2391 v75 = atoi(v216.pProperties[2]);
2392 v76 = v75;
2393 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
2394 {
2395 if ( pIndoor->GetSector(v74, thisi, v75) )
2396 {
2397 v77 = thisi;
2398 LABEL_544:
2399 pParty->vPosition.x = v74;
2400 pParty->vPosition.z = v77;
2401 pParty->vPosition.y = v76;
2402 pParty->uFallStartY = v76;
2403 goto LABEL_90;
2404 }
2405 }
2406 else
2407 {
2408 if ( v74 > -32768 )
2409 {
2410 if ( v74 < 32768 )
2411 {
2412 v77 = thisi;
2413 if ( thisi > -32768 )
2414 {
2415 if ( thisi < 32768 && v76 >= 0 && v76 < 10000 )
2416 goto LABEL_544;
2417 }
2418 }
2419 }
2420 }
2421 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
2422 v73 = "Can't jump to that location!";
2423 }
2424 ShowStatusBarString(v73, 6u);
2425 goto LABEL_90;
2426 case 0x19:
2427 if ( bUnderwater == 1 )
2428 goto LABEL_682;
2429 if ( !uActiveCharacter || (v78 = pPlayers[uActiveCharacter], v78->uTimeToRecovery) )
2430 goto LABEL_90;
2431 v79 = v78->uQuickSpell;
2432 v175 = uActiveCharacter;
2433 v159 = 0;
2434 v147 = 0;
2435 v80 = uActiveCharacter - 1;
2436 goto LABEL_679;
2437 case 0x46:
2438 case UIMSG_Quit|0x8:
2439 if ( pRenderer->pRenderD3D )
2440 {
2441 v81 = pGame->pVisInstance->get_picked_object_zbuf_val();
2442 }
2443 else
2444 {
2445 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206);
2446 v82 = pMouse->GetCursorPos(&v201);
2447 v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[v82->y]];
2448 }
2449 v83 = v81;
2450 v44 = (unsigned __int16)v81;
2451 v84 = v83 >> 16;
2452 if ( (v44 & 7) != 3 || v84 >= 5120 )
2453 goto LABEL_90;
2454 v51 = ptr_507BD4->ptr_1C;
2455 if ( uMessage == 70 )
2456 {
2457 *((char *)v51 + 8) &= 0xF7u;
2458 }
2459 else
2460 {
2461 if ( uMessage == 140 )
2462 *((char *)v51 + 9) &= 0xFEu;
2463 else
2464 *((char *)v51 + 9) &= 0xFDu;
2465 }
2466 goto LABEL_416;
2467 case 0x1C:
2468 if ( !uActiveCharacter
2469 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
2470 goto LABEL_90;
2471 ptr_507BC8 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, (enum WindowType)104, uMessageParam, 0);
2472 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 25;
2473 pEventTimer->Pause();
2474 goto _continue;
2475 case 0x1B:
2476 if ( !uActiveCharacter )
2477 goto LABEL_90;
2478 if ( pParty->bTurnBasedModeOn != v0 )
2479 goto LABEL_569;
2480 if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
2481 goto LABEL_90;
2482 if ( !(pTurnEngine->field_18 & 2) )
2483 {
2484 LABEL_569:
2485 if ( pActors[uMessageParam].uAIState == 5 )
2486 stru_50C198.LootActor(&pActors[uMessageParam]);
2487 else
2488 Actor::StealFrom(uMessageParam);
2489 }
2490 goto _continue;
2491 case 0x17:
2492 if ( !uActiveCharacter )
2493 goto LABEL_90;
2494 if ( pParty->bTurnBasedModeOn != v0 )
2495 goto LABEL_577;
2496 if ( pTurnEngine->field_4 == v0 || pTurnEngine->field_4 == 3 )
2497 goto LABEL_90;
2498 if ( !(pTurnEngine->field_18 & 2) )
2499 LABEL_577:
2500 _42ECB5_PlayerAttacksActor();
2501 goto _continue;
2502 case UIMSG_A7:
2503 v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest"
2504 v85 = pButton_RestUI_Exit;
2505 v149 = pButton_RestUI_Exit;
2506 v142 = (WindowType)96;
2507 goto LABEL_731;
2508 case UIMSG_ShowStatus_Player|0x1:
2509 if ( dword_506F14 == 2 )
2510 goto LABEL_621;
2511 GUIWindow::Create(
2512 pButton_RestUI_Wait5Minutes->uX,
2513 pButton_RestUI_Wait5Minutes->uY,
2514 0,
2515 0,
2516 (enum WindowType)90,
2517 (int)pButton_RestUI_Wait5Minutes,
2518 (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
2519 dword_506F14 = v0;
2520 _506F18_num_hours_to_sleep = 5;
2521 goto _continue;
2522 case 0x60:
2523 if ( dword_506F14 == 2 )
2524 goto LABEL_621;
2525 GUIWindow::Create(
2526 pButton_RestUI_Wait1Hour->uX,
2527 pButton_RestUI_Wait1Hour->uY,
2528 0,
2529 0,
2530 (enum WindowType)90,
2531 (int)pButton_RestUI_Wait1Hour,
2532 (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
2533 dword_506F14 = v0;
2534 _506F18_num_hours_to_sleep = 60;
2535 goto _continue;
2536 case UIMSG_OpenRestUI:
2537 dword_506F14 = 2;
2538 RestUI_Initialize();
2539 v86 = 60 * (sub_494820(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
2540 _506F18_num_hours_to_sleep = v86;
2541 if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
2542 _506F18_num_hours_to_sleep = v86 + 720;
2543 goto LABEL_615;
2544 case 0x68:
2545 if ( pMessageQueue_50CBD0->uNumMessages )
2546 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2547 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
2548 goto _continue;
2549 if ( sub_42F4DA() )
2550 goto LABEL_594;
2551 if ( pParty->bTurnBasedModeOn == v0 )
2552 goto LABEL_595;
2553 if ( !(pParty->uFlags & 0x88) )
2554 {
2555 RestUI_Initialize();
2556 goto _continue;
2557 }
2558 LABEL_594:
2559 if ( pParty->bTurnBasedModeOn == v0 )
2560 {
2561 LABEL_595:
2562 v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
2563 goto _draw_status_string_and_continue;
2564 }
2565 v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
2566 if ( pParty->uFlags & 0x88 )
2567 v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
2568 ShowStatusBarString(v88, 2u);
2569 v89 = uActiveCharacter;
2570 if ( !uActiveCharacter )
2571 goto LABEL_90;
2572 v176 = 0;
2573 v160 = 13;
2574 goto LABEL_619;
2575 case 0x61:
2576 if ( dword_506F14 )
2577 goto LABEL_621;
2578 if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest )
2579 {
2580 ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
2581 if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() )
2582 {
2583 v89 = uActiveCharacter;
2584 v176 = 0;
2585 v160 = 108;
2586 LABEL_619:
2587 pPlayers[v89]->PlaySound(v160, v176);
2588 }
2589 }
2590 else
2591 {
2592 pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
2593 pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
2594 pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
2595 pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
2596 v90 = pMapStats->GetMapInfo(pCurrentMapName);
2597 if ( !v90 )
2598 v90 = rand() % (signed int)pMapStats->uNumMaps + 1;
2599 thisj = &pMapStats->pInfos[v90];
2600 if ( rand() % 100 + 1 <= thisj->field_30 )
2601 {
2602 v91 = rand() % 100;
2603 v92 = thisj->field_31;
2604 v93 = v91 + 1;
2605 if ( v93 > v92 )
2606 v195 = (NPCData *)((v93 > v92 + thisj->field_32) + 2);
2607 else
2608 v195 = (NPCData *)v0;
2609 if ( !sub_45063B(thisj, (int)v195) )
2610 v195 = 0;
2611 if ( v195 )
2612 {
2613 v94 = rand() % 4;
2614 LODWORD(pParty->pPlayers[v94].pConditions[2]) = 0;
2615 HIDWORD(pParty->pPlayers[v94].pConditions[2]) = 0;
2616 v95 = rand();
2617 Rest(v95 % 6 + 60);
2618 _506F18_num_hours_to_sleep = 0;
2619 dword_506F14 = 0;
2620 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2621 {
2622 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2623 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
2624 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2625 ++pMessageQueue_50CBD0->uNumMessages;
2626 }
2627 ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!"
2628 v165 = 0;
2629 v151 = 0;
2630 v144 = 0;
2631 v139 = 0;
2632 v135 = -1;
2633 v132 = 0;
2634 v130 = 0;
2635 v127 = 227;
2636 goto _play_sound_and_continue;
2637 }
2638 }
2639 Party::TakeFood(uRestUI_FoodRequiredToRest);
2640 _506F18_num_hours_to_sleep = 480;
2641 LABEL_615:
2642 dword_506F14 = 2;
2643 pParty->RestAndHeal();
2644 pParty->field_764 = 0;
2645 pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed;
2646 pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed;
2647 pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed;
2648 pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed;
2649 }
2650 goto _continue;
2651 case UIMSG_ShowStatus_Funds|0x8:
2652 if ( dword_506F14 == 2 )
2653 {
2654 LABEL_621:
2655 v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
2656 goto LABEL_622;
2657 }
2658 GUIWindow::Create(
2659 pButton_RestUI_WaitUntilDawn->uX,
2660 pButton_RestUI_WaitUntilDawn->uY,
2661 0,
2662 0,
2663 (enum WindowType)90,
2664 (int)pButton_RestUI_WaitUntilDawn,
2665 (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
2666 v97 = sub_494820(pParty->uCurrentHour);
2667 dword_506F14 = v0;
2668 _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
2669 goto _continue;
2670 case 0x4E:
2671 if ( dword_50654C && byte_506550 )
2672 {
2673 v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->field_1A4E].pName;
2674 v157 = pGlobalTXT_LocalizationStrings[483];
2675 _sprintex_2args_draw_status_and_continue:
2676 sprintfex(pTmpBuf, v157, v173);
2677 }
2678 else
2679 {
2680 if ( pPlayers[uActiveCharacter]->uQuickSpell )
2681 v177 = pGlobalTXT_LocalizationStrings[584];// "Click here to remove your Quick Spell"
2682 else
2683 v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
2684 strcpy(pTmpBuf, v177);
2685 }
2686 _set_status_string_pTmpBuf_and_continue:
2687 sub_41C0B8_set_status_string(pTmpBuf);
2688 goto _continue;
2689 case 0x4F:
2690 if ( !uActiveCharacter
2691 || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
2692 !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) )
2693 goto _continue;
2694 if ( sub_4637E0_is_there_popup_onscreen() )
2695 dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1;
2696 v98 = *(char *)(uNumSeconds + 6734);
2697 if ( dword_50654C - 1 == uMessageParam )
2698 {
2699 v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
2700 v161 = pGlobalTXT_LocalizationStrings[485];
2701 }
2702 else
2703 {
2704 v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
2705 v161 = pGlobalTXT_LocalizationStrings[486];
2706 }
2707 sprintfex(pTmpBuf, v161, v178);
2708 sub_41C0B8_set_status_string(pTmpBuf);
2709 goto LABEL_91;
2710 case 0x58:
2711 GUIWindow::Create(ptr_5064F8->uX, ptr_5064F8->uY, 0, 0, (enum WindowType)90, (int)ptr_5064F8, 0);
2712 if ( !uActiveCharacter )
2713 goto _continue;
2714 thisk = pPlayers[uActiveCharacter];
2715 if ( !byte_506550 || !dword_50654C )
2716 {
2717 v165 = 0;
2718 v151 = 0;
2719 v144 = 0;
2720 v139 = 0;
2721 v135 = -1;
2722 v132 = 0;
2723 thisk->uQuickSpell = 0;
2724 v130 = 0;
2725 dword_50654C = 0;
2726 v127 = 203;
2727 goto _play_sound_and_continue;
2728 }
2729 v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->field_1A4E;
2730 pPlayers[uActiveCharacter]->uQuickSpell = v99;
2731 stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
2732 if ( uActiveCharacter )
2733 thisk->PlaySound(12, 0);
2734 byte_506550 = 0;
2735 goto _continue;
2736 case 0x33:
2737 if ( !uActiveCharacter )
2738 goto _continue;
2739 v100 = pPlayers[uActiveCharacter];
2740 v195 = 0;
2741 uAction = 0;
2742 v101 = 0;
2743 thisl = (int)&v100->pActiveSkills[12];
2744 do
2745 {
2746 if ( *(short *)thisl )
2747 {
2748 if ( v100->field_1A4E == v101 )
2749 uAction = (int)v195;
2750 v102 = (int)v195;
2751 v195 = (NPCData *)((char *)v195 + 1);
2752 v217[v102] = v101;
2753 }
2754 thisl += 2;
2755 ++v101;
2756 }
2757 while ( v101 < 9 );
2758 if ( !v195 )
2759 goto LABEL_662;
2760 if ( GetAsyncKeyState(16) )
2761 {
2762 --uAction;
2763 if ( uAction < 0 )
2764 uAction = (int)((char *)v195 - 1);
2765 }
2766 else
2767 {
2768 ++uAction;
2769 if ( uAction >= (signed int)v195 )
2770 uAction = 0;
2771 }
2772 sub_41140B();
2773 pPlayers[uActiveCharacter]->field_1A4E = LOBYTE(v217[uAction]);
2774 goto LABEL_661;
2775 case UIMSG_SaveGame|0x4:
2776 if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->field_1A4E )
2777 goto _continue;
2778 sub_41140B();
2779 pPlayers[uActiveCharacter]->field_1A4E = uMessageParam;
2780 LABEL_661:
2781 pGUIWindow_CurrentMenu->_411621();
2782 LABEL_662:
2783 v165 = 0;
2784 v151 = 0;
2785 v144 = 0;
2786 v139 = 0;
2787 v135 = -1;
2788 v132 = 0;
2789 v130 = 0;
2790 v127 = rand() % 2 + 204;
2791 goto _play_sound_and_continue;
2792 case UIMSG_LoadGame|0x4:
2793 if ( pTurnEngine->field_4 != 3 )
2794 {
2795 if ( uActiveCharacter )
2796 {
2797 uNumSeconds = (unsigned int)pPlayers[uActiveCharacter];
2798 if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402) )
2799 {
2800 if ( dword_50654C - 1 == uMessageParam )
2801 {
2802 pGUIWindow_CurrentMenu->Release();
2803 pEventTimer->Resume();
2804 viewparams->bRedrawGameUI = v0;
2805 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
2806 pIcons_LOD->_4114F2();
2807 v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734);
2808 if ( dword_50C9E8 < 40 )
2809 {
2810 dword_50C9EC[3 * dword_50C9E8] = 142;
2811 dword_50C9F0[3 * dword_50C9E8] = v103;
2812 *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = uActiveCharacter - 1;
2813 ++dword_50C9E8;
2814 }
2815 }
2816 else
2817 {
2818 byte_506550 = 1;
2819 dword_50654C = uMessageParam + 1;
2820 }
2821 }
2822 }
2823 }
2824 goto _continue;
2825 case 0x8E:
2826 if ( pTurnEngine->field_4 == 3 )
2827 goto _continue;
2828 v175 = 0;
2829 v159 = 0;
2830 v147 = 0;
2831 goto LABEL_678;
2832 case 0x92:
2833 if ( pTurnEngine->field_4 != 3 )
2834 {
2835 v175 = 0;
2836 v159 = v0;
2837 v147 = 133;
2838 LABEL_678:
2839 v80 = v199;
2840 v79 = uMessageParam;
2841 LABEL_679:
2842 _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
2843 }
2844 goto _continue;
2845 case 0x69:
2846 if ( pTurnEngine->field_4 == 3 )
2847 goto _continue;
2848 if ( bUnderwater == 1 )
2849 {
2850 LABEL_682:
2851 v96 = pGlobalTXT_LocalizationStrings[652];// "You can not do that while you are underwater!"
2852 LABEL_622:
2853 ShowStatusBarString(v96, 2u);
2854 LABEL_623:
2855 v165 = 0;
2856 v151 = 0;
2857 v144 = 0;
2858 v139 = 0;
2859 v135 = -1;
2860 v132 = 0;
2861 v130 = 0;
2862 v127 = 27;
2863 _play_sound_and_continue:
2864 pAudioPlayer->PlaySound((SoundID)v127, v130, v132, v135, v139, v144, v151, v165);
2865 }
2866 else
2867 {
2868 if ( pMessageQueue_50CBD0->uNumMessages )
2869 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2870 if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
2871 {
2872 if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
2873 goto LABEL_693;
2874 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5
2875 && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 7
2876 && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 99
2877 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 103) )
2878 {
2879 pGUIWindow_CurrentMenu->Release();
2880 LABEL_693:
2881 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)ptr_5079F8, 0);
2882 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 8;
2883 pEventTimer->Pause();
2884 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, (enum WindowType)18, 0, 0);
2885 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
2886 viewparams->field_48 = v0;
2887 goto _continue;
2888 }
2889 }
2890 }
2891 goto _continue;
2892 case 0x6A:
2893 if ( pMessageQueue_50CBD0->uNumMessages )
2894 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
2895 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
2896 pGUIWindow_CurrentMenu->Release();
2897 ++pIcons_LOD->uTexturePacksCount;
2898 if ( !pIcons_LOD->uNumPrevLoadedFiles )
2899 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
2900 GUIWindow::Create(0x230u, 0x1C2u, 0, 0, (enum WindowType)90, (int)ptr_5079F4, 0);
2901 viewparams->bRedrawGameUI = v0;
2902 pEventTimer->Pause();
2903 pAudioPlayer->StopChannels(-1, -1);
2904 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 104;
2905 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, (enum WindowType)12, 5, 0);
2906 papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
2907 ptr_5076F4 = pGUIWindow_CurrentMenu->CreateButton(
2908 0x187u,
2909 0x13Cu,
2910 0x4Bu,
2911 0x21u,
2912 v0,
2913 0,
2914 0x71u,
2915 0,
2916 0,
2917 pGlobalTXT_LocalizationStrings[79],// "Exit"
2918 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
2919 0,
2920 v179);
2921 goto _continue;
2922 case 0x6B:
2923 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
2924 {
2925 pGUIWindow_CurrentMenu->Release();
2926 pEventTimer->Resume();
2927 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
2928 viewparams->bRedrawGameUI = v0;
2929 }
2930 stru_506E40.Release();
2931 uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
2932 pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
2933 free((void *)uNumSeconds);
2934 stru_506E40._40E55E("gamma.pcx", 0);
2935 GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)ptr_5079F0, 0);
2936 LABEL_453:
2937 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
2938 goto _continue;
2939 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2940 goto LABEL_770;
2941 case UIMSG_C0:
2942 dword_50651C = v0;
2943 if ( pMouse->GetCursorPos(&v211)->y > 178 )
2944 dword_50651C = -1;
2945 goto _continue;
2946 case UIMSG_A9:
2947 GUIWindow::Create(ptr_507B9C->uX, ptr_507B9C->uY, 0, 0, WINDOW_HouseInterior|0x42, (int)ptr_507B9C, 0);
2948 LABEL_707:
2949 dword_506548 = v0;
2950 goto _continue;
2951 case UIMSG_AA:
2952 GUIWindow::Create(ptr_507BA0->uX, ptr_507BA0->uY, 0, 0, WINDOW_HouseInterior|0x42, (int)ptr_507BA0, 0);
2953 LABEL_709:
2954 dword_506544 = v0;
2955 goto _continue;
2956 case 0x55:
2957 bRingsShownInCharScreen ^= v0;
2958 GUIButton::_41D0D8(ptr_507694);
2959 GUIButton::_41D0D8(ptr_507690);
2960 if ( bRingsShownInCharScreen )
2961 {
2962 v128 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureHeight : 26);
2963 v125 = (uTextureID_5118C8 != -1 ? pIcons_LOD->pTextures[uTextureID_5118C8].uTextureWidth : 24);
2964 v123 = 445;
2965 v121 = 470;
2966 }
2967 else
2968 {
2969 v128 = 30;
2970 v125 = 30;
2971 v123 = 300;
2972 v121 = 600;
2973 }
2974 ptr_507694 = pGUIWindow_CurrentMenu->CreateButton(
2975 v121,
2976 v123,
2977 v125,
2978 v128,
2979 v0,
2980 0,
2981 0x55u,
2982 0,
2983 0,
2984 pGlobalTXT_LocalizationStrings[64],// "Detail Toggle"
2985 0);
2986 ptr_507690 = pGUIWindow_CurrentMenu->CreateButton(
2987 0x1DCu,
2988 0,
2989 0xA4u,
2990 0x159u,
2991 v0,
2992 0,
2993 0x85u,
2994 0,
2995 0,
2996 v1,
2997 0);
2998 goto LABEL_422;
2999 case UIMSG_Quit|0x1:
3000 OnPaperdollLeftClick();
3001 goto _continue;
3002 case UIMSG_CloseBook|0x2:
3003 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
3004 sub_4196A0();
3005 sub_419379();
3006 v85 = pCharacterScreen_StatsBtn;
3007 goto LABEL_716;
3008 case UIMSG_ChangeMusicVolume|0x2:
3009 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
3010 sub_4196A0();
3011 sub_419379();
3012 sub_419401();
3013 v85 = pCharacterScreen_SkillsBtn;
3014 goto LABEL_716;
3015 case UIMSG_SkillUp:
3016 v104 = pPlayers[uActiveCharacter];
3017 v105 = (int)&v104->pActiveSkills[uMessageParam];
3018 LOWORD(v2) = *(short *)v105;
3019 uNumSeconds = v2;
3020 if ( v104->uSkillPoints < (v2 & 0x3F) + 1 )
3021 {
3022 v87 = pGlobalTXT_LocalizationStrings[488];// "You don't have enough skill points!"
3023 }
3024 else
3025 {
3026 if ( (uNumSeconds & 0x3F) < 0x3C )
3027 {
3028 *(short *)v105 = uNumSeconds + 1;
3029 v104->uSkillPoints -= v104->pActiveSkills[uMessageParam] & 0x3F;
3030 v104->PlaySound(14, 0);
3031 v165 = 0;
3032 v151 = 0;
3033 v144 = 0;
3034 v139 = 0;
3035 v135 = -1;
3036 v132 = 0;
3037 v130 = 0;
3038 v127 = 20001;
3039 goto _play_sound_and_continue;
3040 }
3041 v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
3042 }
3043 _draw_status_string_and_continue:
3044 ShowStatusBarString(v87, 2u);
3045 goto _continue;
3046 case UIMSG_ChangeMusicVolume|0x4:
3047 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
3048 sub_419379();
3049 sub_4196A0();
3050 v85 = pCharacterScreen_InventoryBtn;
3051 LABEL_716:
3052 v163 = 0;
3053 v149 = v85;
3054 v142 = (WindowType)91;
3055 goto LABEL_731;
3056 case UIMSG_A8:
3057 v85 = ptr_50767C;
3058 v163 = 0;
3059 v149 = ptr_50767C;
3060 v142 = (WindowType)97;
3061 goto LABEL_731;
3062 case UIMSG_CloseBook|0x4:
3063 sub_419379();
3064 sub_4196A0();
3065 sub_419220();
3066 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102;
3067 GUIWindow::Create(
3068 pCharacterScreen_AwardsBtn->uX,
3069 pCharacterScreen_AwardsBtn->uY,
3070 0,
3071 0,
3072 WINDOW_HouseInterior|0x42,
3073 (int)pCharacterScreen_AwardsBtn,
3074 0);
3075 sub_419100();
3076 goto _continue;
3077 case 0x47:
3078 switch ( uMessageParam )
3079 {
3080 default:
3081 goto _continue;
3082 case 11:
3083 goto LABEL_707;
3084 case 10:
3085 goto LABEL_709;
3086 case 0:
3087 v85 = pBtn_Book_1;
3088 dword_506544 = v0;
3089 break;
3090 case 1:
3091 v85 = pBtn_Book_2;
3092 dword_506548 = v0;
3093 break;
3094 case 2:
3095 dword_506540 = v0;
3096 if ( dword_506364 )
3097 goto _continue;
3098 v85 = pBtn_Book_3;
3099 break;
3100 case 3:
3101 dword_50653C = v0;
3102 if ( dword_506364 )
3103 goto _continue;
3104 v85 = pBtn_Book_4;
3105 break;
3106 case 4:
3107 dword_506538 = v0;
3108 if ( dword_506364 )
3109 goto _continue;
3110 v85 = pBtn_Book_5;
3111 break;
3112 case 5:
3113 dword_506534 = v0;
3114 if ( dword_506364 )
3115 goto _continue;
3116 v85 = pBtn_Book_6;
3117 break;
3118 case 6:
3119 v85 = pBtn_Autonotes_Misc;
3120 dword_506530 = v0;
3121 break;
3122 case 7:
3123 v85 = pBtn_Autonotes_Instructors;
3124 dword_50652C = v0;
3125 break;
3126 }
3127 v163 = v0;
3128 v149 = v85;
3129 v142 = (WindowType)92;
3130 LABEL_731:
3131 v8 = v85->uY;
3132 v9 = v85->uX;
3133 goto LABEL_732;
3134 case UIMSG_SelectCharacter:
3135 if ( pMessageQueue_50CBD0->uNumMessages )
3136 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
3137 GameUI_OnPlayerPortraitLeftClick(uMessageParam);
3138 goto _continue;
3139 case UIMSG_ShowStatus_Funds:
3140 v174 = (char *)pParty->uNumGoldInBank;
3141 v158 = pParty->uNumGold + pParty->uNumGoldInBank;
3142 v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
3143 goto _sprintex_draw_status_and_continue;
3144 case UIMSG_ShowStatus_DateTime:
3145 v195 = (NPCData *)pParty->uCurrentHour;
3146 if ( (signed int)pParty->uCurrentHour <= 12 )
3147 {
3148 if ( !v195 )
3149 v195 = (NPCData *)12;
3150 }
3151 else
3152 {
3153 v195 = (NPCData *)((char *)v195 - 12);
3154 }
3155 if ( pParty->uCurrentHour < 0xC || (uNumSeconds = v0, pParty->uCurrentHour >= 0x18) )
3156 uNumSeconds = 0;
3157 sprintfex(
3158 pTmpBuf,
3159 "%d:%02d%s %s %d %s %d",
3160 v195,
3161 pParty->uCurrentMinute,
3162 aAMPMNames[uNumSeconds],
3163 aDayNames[pParty->uDaysPlayed % 7],
3164 7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1,
3165 aMonthNames[pParty->uCurrentMonth],
3166 pParty->uCurrentYear);
3167 goto _set_status_string_pTmpBuf_and_continue;
3168 case UIMSG_ShowStatus_Food:
3169 v173 = (char *)pParty->uNumFoodRations;
3170 v157 = pGlobalTXT_LocalizationStrings[501];// You have %lu food"
3171 goto _sprintex_2args_draw_status_and_continue;
3172 case UIMSG_ShowStatus_Player:
3173 v106 = pPlayers[uMessageParam];
3174 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v106->pName, pClassNames[v106->uClass]);// "%s the %s"
3175 strcat(pTmpBuf, ": ");
3176 v107 = v106->GetMajorConditionrIdx();
3177 strcat(pTmpBuf, aCharacterConditionNames[v107]);
3178 sub_41C0B8_set_status_string(pTmpBuf);
3179 v108 = 8 * uMessageParam - 8;
3180 LOBYTE(v108) = v108 | 4;
3181 pMouse->uPointingObjectID = v108;
3182 goto _continue;
3183 case UIMSG_ShowStatus_ManaHP:
3184 v109 = pGlobalTXT_LocalizationStrings[212];// "Spell Points"
3185 v110 = pPlayers[uMessageParam];
3186 v111 = v110->GetMaxMana();
3187 v112 = v110->sMana;
3188 v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
3189 v114 = v110->GetMaxHealth();
3190 sprintfex(pTmpBuf, "%d / %d %s %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
3191 goto _set_status_string_pTmpBuf_and_continue;
3192 case 0xC:
3193 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15 )
3194 goto LABEL_762;
3195 sub_420E01();
3196 goto _continue;
3197 case UIMSG_ChangeMusicVolume|0x8:
3198 LABEL_762:
3199 sub_421EA6_OnInventoryLeftClick();
3200 goto _continue;
3201 case 0xA:
3202 if ( !pRenderer->pRenderD3D )
3203 goto LABEL_772;
3204 v115 = pMessageQueue_50CBD0->uNumMessages;
3205 if ( !pMessageQueue_50CBD0->uNumMessages )
3206 goto LABEL_768;
3207 if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
3208 {
3209 v115 = v0;
3210 pMessageQueue_50CBD0->uNumMessages = v0;
3211 LABEL_769:
3212 pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
3213 LABEL_770:
3214 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
3215 goto LABEL_771;
3216 }
3217 v115 = 0;
3218 pMessageQueue_50CBD0->uNumMessages = 0;
3219 LABEL_768:
3220 if ( (signed int)v115 < 40 )
3221 goto LABEL_769;
3222 goto _continue;
3223 case 0xE:
3224 LABEL_772:
3225 if ( pMessageQueue_50CBD0->uNumMessages )
3226 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
3227 OnGameViewportClick();
3228 goto _continue;
3229 case 0xF:
3230 if ( pRenderer->pRenderD3D )
3231 {
3232 LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
3233 }
3234 else
3235 {
3236 uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209);
3237 v117 = pMouse->GetCursorPos(&v204);
3238 v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[v117->y]];
3239 }
3240 v163 = 0;
3241 v149 = (GUIButton *)(unsigned __int16)v116;
3242 v142 = (WindowType)15;
3243 goto LABEL_779;
3244 case 0x54:
3245 v163 = 0;
3246 v149 = (GUIButton *)uMessageParam;
3247 v142 = (WindowType)22;
3248 LABEL_779:
3249 v8 = 0;
3250 v9 = 0;
3251 LABEL_732:
3252 v137 = 0;
3253 v133 = 0;
3254 LABEL_733:
3255 GUIWindow::Create(v9, v8, v133, v137, v142, (int)v149, v163);
3256 goto _continue;
3257 case 0x194:
3258 if ( pMessageQueue_50CBD0->uNumMessages )
3259 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
3260 OnPressSpace();
3261 goto _continue;
3262 case UIMSG_ChangeSoundVolume|0x100:
3263 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
3264 goto _continue;
3265 pParty->uFlags |= 2u;
3266 GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A14, 0);
3267 uNumSeconds = 131072;
3268 v118 = 2 * viewparams->uMinimapZoom;
3269 ++viewparams->field_28;
3270 viewparams->uMinimapZoom *= 2;
3271 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
3272 {
3273 if ( (signed int)v118 > 4096 )
3274 {
3275 viewparams->uMinimapZoom = 4096;
3276 viewparams->field_28 = 12;
3277 }
3278 goto _continue;
3279 }
3280 v119 = 2048;
3281 if ( (signed int)v118 <= 2048 )
3282 goto LABEL_789;
3283 viewparams->field_28 = 11;
3284 goto LABEL_788;
3285 case UIMSG_ChangeMusicVolume|0x100:
3286 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
3287 goto _continue;
3288 pParty->uFlags |= 2u;
3289 GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A18, 0);
3290 uNumSeconds = 32768;
3291 v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
3292 --viewparams->field_28;
3293 viewparams->uMinimapZoom = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16;
3294 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3295 {
3296 v119 = 512;
3297 if ( (signed int)v118 < 512 )
3298 {
3299 viewparams->field_28 = 9;
3300 LABEL_788:
3301 v118 = v119;
3302 viewparams->uMinimapZoom = v119;
3303 }
3304 LABEL_789:
3305 dword_576E2C = v118;
3306 dword_576E28 = viewparams->field_28;
3307 }
3308 else
3309 {
3310 if ( (signed int)v118 < 256 )
3311 {
3312 viewparams->uMinimapZoom = 256;
3313 viewparams->field_28 = 8;
3314 }
3315 }
3316 goto _continue;
3317 }
3318 }
3319 }
3320 pMessageQueue_50CBD0->uNumMessages = dword_50C9E8;
3321 memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
3322 dword_50C9E8 = 0;
3323 if ( dword_50C9DC )
3324 {
3325 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3326 {
3327 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC;
3328 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0;
3329 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3330 ++pMessageQueue_50CBD0->uNumMessages;
3331 }
3332 dword_50C9DC = 0;
3333 }
3334 else
3335 {
3336 if ( dword_50C9D0 > 0 )
3337 {
3338 dword_50C9D8 -= pEventTimer->uTimeElapsed;
3339 if ( dword_50C9D8 <= 0 )
3340 {
3341 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3342 {
3343 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0;
3344 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4;
3345 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3346 ++pMessageQueue_50CBD0->uNumMessages;
3347 }
3348 dword_50C9D0 = 0;
3349 dword_50C9D4 = 0;
3350 dword_50C9D8 = 0;
3351 }
3352 }
3353 }
3354 pStru277->_427E01_cast_spell();
3355 }
3356
3357
3358 //----- (004356FF) --------------------------------------------------------
3359 void __cdecl back_to_game()
3360 {
3361 dword_507BF0_is_there_popup_onscreen = 0;
3362 dword_4E455C = 1;
3363 dword_50CDCC = 0;
3364 if ( ptr_507BC4 )
3365 free_book_subwindow();
3366 if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
3367 && !ptr_507BD4 )
3368 pEventTimer->Resume();
3369 viewparams->bRedrawGameUI = 1;
3370 }
3371 //----- (00435748) --------------------------------------------------------
3372 void __cdecl GUI_MainMenuMessageProc()
3373 {
3374 AudioPlayer *v0; // ebp@2
3375 char *v1; // ebx@2
3376 unsigned int v2; // ecx@18
3377 void *v3; // edi@21
3378 signed int v4; // eax@29
3379 int v5; // ecx@29
3380 enum PLAYER_SKILL_TYPE v6; // edi@37
3381 GUIWindow *v7; // eax@56
3382 unsigned int v8; // edx@56
3383 Player *v9; // edi@57
3384 signed int v10; // eax@58
3385 GUIButton *v11; // eax@59
3386 unsigned __int8 v12; // sf@62
3387 signed int v13; // eax@64
3388 unsigned int v14; // eax@66
3389 int v15; // edi@70
3390 char v16; // zf@73
3391 int v17; // eax@73
3392 unsigned int v18; // ecx@105
3393 int v19; // edi@116
3394 char v20; // dl@116
3395 unsigned int v21; // eax@116
3396 Player *v22; // ecx@116
3397 char *v23; // ebx@118
3398 int v24; // eax@118
3399 unsigned int v25; // eax@120
3400 unsigned int v26; // ecx@127
3401 unsigned int v27; // eax@129
3402 unsigned __int8 v28; // of@129
3403 SoundID v29; // [sp-2Ch] [bp-3Ch]@36
3404 signed int v30; // [sp-28h] [bp-38h]@36
3405 unsigned int v31; // [sp-24h] [bp-34h]@36
3406 signed int v32; // [sp-20h] [bp-30h]@36
3407 unsigned int v33; // [sp-20h] [bp-30h]@105
3408 signed int v34; // [sp-1Ch] [bp-2Ch]@36
3409 unsigned int v35; // [sp-1Ch] [bp-2Ch]@105
3410 int v36; // [sp-18h] [bp-28h]@36
3411 enum WindowType v37; // [sp-18h] [bp-28h]@105
3412 unsigned int v38; // [sp-14h] [bp-24h]@36
3413 int v39; // [sp-14h] [bp-24h]@56
3414 signed int v40; // [sp-10h] [bp-20h]@15
3415 signed int v41; // [sp-10h] [bp-20h]@29
3416 int v42; // [sp-10h] [bp-20h]@36
3417 int v43; // [sp-10h] [bp-20h]@56
3418 unsigned __int8 uClass[4]; // [sp+4h] [bp-Ch]@3
3419 UIMessageType v45; // [sp+8h] [bp-8h]@3
3420 int v46; // [sp+Ch] [bp-4h]@3
3421
3422 if ( pMessageQueue_50CBD0->uNumMessages )
3423 {
3424 v0 = pAudioPlayer;
3425 v1 = (char *)pParty->pPlayers;
3426 do
3427 {
3428 pMessageQueue_50CBD0->PopMessage(&v45, (int *)uClass, &v46);
3429 if ( (signed int)v45 > 75 )
3430 {
3431 if ( v45 > UIMSG_A3 )
3432 {
3433 if ( v45 == UIMSG_A4 )
3434 {
3435 v43 = 0;
3436 v39 = (int)ptr_69BD64;
3437 v8 = pGUIWindow_CurrentMenu->uFrameY + 302;
3438 v37 = (WindowType)94;
3439 v18 = pGUIWindow_CurrentMenu->uFrameX + 241;
3440 LABEL_133:
3441 v35 = 28;
3442 v33 = 61;
3443 LABEL_134:
3444 GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43);
3445 continue;
3446 }
3447 if ( v45 == UIMSG_A5 )
3448 {
3449 if ( pGUIWindow_CurrentMenu->field_40 == 1 )
3450 pKeyActionMap->_459ED1(0);
3451 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11
3452 || uLoadGameUI_SelectedSlot != *(int *)uClass + dword_6A0C9C )
3453 {
3454 v26 = *(int *)uClass + dword_6A0C9C;
3455 if ( dword_6BE138 == *(int *)uClass + dword_6A0C9C )
3456 {
3457 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3458 {
3459 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_A4;
3460 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
3461 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3462 v27 = pMessageQueue_50CBD0->uNumMessages + 1;
3463 v28 = __OFSUB__(pMessageQueue_50CBD0->uNumMessages + 1, 40);
3464 v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0;
3465 ++pMessageQueue_50CBD0->uNumMessages;
3466 if ( v12 ^ v28 )
3467 {
3468 pMessageQueue_50CBD0->pMessages[v27].eType = (UIMessageType)82;
3469 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
3470 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3471 ++pMessageQueue_50CBD0->uNumMessages;
3472 }
3473 }
3474 }
3475 uLoadGameUI_SelectedSlot = v26;
3476 dword_6BE138 = v26;
3477 }
3478 else
3479 {
3480 pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu);
3481 strcpy(
3482 (char *)pKeyActionMap->pPressedKeysBuffer,
3483 (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
3484 pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer);
3485 }
3486 continue;
3487 }
3488 if ( v45 == UIMSG_A6 )
3489 {
3490 v43 = 0;
3491 v39 = (int)ptr_69BD60;
3492 v8 = pGUIWindow_CurrentMenu->uFrameY + 302;
3493 v37 = (WindowType)95;
3494 v18 = pGUIWindow_CurrentMenu->uFrameX + 350;
3495 goto LABEL_133;
3496 }
3497 if ( v45 == UIMSG_AB )
3498 {
3499 v23 = (char *)&pParty->pPlayers[*(int *)uClass];
3500 v24 = (int)(v23 + 186);
3501 v12 = (char)(v23[186] - 1) < 0;
3502 --*(char *)v24;
3503 if ( v12 )
3504 *(char *)v24 = 19;
3505 *((int *)v23 + 1608) = *(char *)v24;
3506 ((Player *)v23)->SetInitialStats();
3507 ((Player *)v23)->SetSexByVoice();
3508 ((Player *)v23)->RandomizeName();
3509 v25 = *(int *)uClass;
3510 pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
3511 - pGUIWindow_CurrentMenu->field_38)
3512 % 7
3513 + pGUIWindow_CurrentMenu->field_38
3514 + 7 * *(int *)uClass;
3515 uPlayerCreationUI_SelectedCharacter = v25;
3516 GUIWindow::Create(
3517 pCreationUI_BtnPressLeft[v25]->uX,
3518 pCreationUI_BtnPressLeft[v25]->uY,
3519 0,
3520 0,
3521 (enum WindowType)92,
3522 (int)pCreationUI_BtnPressLeft[v25],
3523 1);
3524 v0 = pAudioPlayer;
3525 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3526 v22 = (Player *)v23;
3527 goto LABEL_117;
3528 }
3529 if ( v45 == UIMSG_AC )
3530 {
3531 v19 = (int)&v1[6972 * *(int *)uClass];
3532 v20 = (char)(*(char *)(v19 + 186) + 1) % 20;
3533 *(char *)(v19 + 186) = v20;
3534 *(int *)(v19 + 6432) = v20;
3535 ((Player *)v19)->SetInitialStats();
3536 ((Player *)v19)->SetSexByVoice();
3537 ((Player *)v19)->RandomizeName();
3538 v21 = *(int *)uClass;
3539 pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
3540 - pGUIWindow_CurrentMenu->field_38)
3541 % 7
3542 + pGUIWindow_CurrentMenu->field_38
3543 + 7 * *(int *)uClass;
3544 uPlayerCreationUI_SelectedCharacter = v21;
3545 GUIWindow::Create(
3546 pCreationUI_BtnPressRight[v21]->uX,
3547 pCreationUI_BtnPressRight[v21]->uY,
3548 0,
3549 0,
3550 (enum WindowType)92,
3551 (int)pCreationUI_BtnPressRight[v21],
3552 1);
3553 v0 = pAudioPlayer;
3554 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3555 v22 = (Player *)v19;
3556 LABEL_117:
3557 v22->PlaySound(102, 0);
3558 v1 = (char *)pParty->pPlayers;
3559 continue;
3560 }
3561 if ( v45 == UIMSG_AD )
3562 {
3563 GUIWindow::Create(
3564 pMainMenu_BtnNew->uX,
3565 pMainMenu_BtnNew->uY,
3566 0,
3567 0,
3568 (enum WindowType)90,
3569 (int)pMainMenu_BtnNew,
3570 0);
3571 goto LABEL_99;
3572 }
3573 if ( v45 != 174 )
3574 continue;
3575 GUIWindow::Create(
3576 pMainMenu_BtnExit->uX,
3577 pMainMenu_BtnExit->uY,
3578 0,
3579 0,
3580 (enum WindowType)90,
3581 (int)pMainMenu_BtnExit,
3582 0);
3583 LABEL_114:
3584 v40 = 10;
3585 LABEL_89:
3586 v2 = v40;
3587 LABEL_90:
3588 SetCurrentMenuID(v2);
3589 continue;
3590 }
3591 if ( v45 == UIMSG_A3 )
3592 {
3593 ++dword_6A0C9C;
3594 if ( dword_6A0C9C >= *(int *)uClass )
3595 dword_6A0C9C = *(int *)uClass - 1;
3596 if ( dword_6A0C9C < 1 )
3597 dword_6A0C9C = 0;
3598 v7 = pGUIWindow_CurrentMenu;
3599 v43 = 0;
3600 v39 = (int)ptr_69BD58;
3601 v8 = pGUIWindow_CurrentMenu->uFrameY + 323;
3602 goto LABEL_105;
3603 }
3604 if ( v45 == UIMSG_LoadGame )
3605 {
3606 if ( !pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
3607 continue;
3608 LABEL_99:
3609 v40 = 9;
3610 goto LABEL_89;
3611 }
3612 if ( v45 == 107 )
3613 {
3614 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
3615 {
3616 pGUIWindow_CurrentMenu->Release();
3617 pEventTimer->Resume();
3618 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
3619 viewparams->bRedrawGameUI = 1;
3620 }
3621 GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)ptr_5079F0, 0);
3622 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
3623 continue;
3624 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
3625 goto LABEL_93;
3626 }
3627 if ( v45 == UIMSG_CloseBook )
3628 {
3629 if ( ptr_507BDC )
3630 {
3631 sub_41426F();
3632 continue;
3633 }
3634 if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x40) )
3635 continue;
3636 v15 = 1;
3637 pVideoPlayer->bStopBeforeSchedule = 1;
3638 viewparams->bRedrawGameUI = 1;
3639 viewparams->field_48 = 1;
3640 if ( !GetCurrentMenuID() || GetCurrentMenuID() == 6 || GetCurrentMenuID() == 7 )
3641 {
3642 v17 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
3643 LABEL_83:
3644 if ( v17 == 16 )
3645 pVideoPlayer->_4BECD5(pVideoPlayer->field_40);
3646 if ( GetCurrentMenuID() == 7 )
3647 {
3648 v40 = 6;
3649 goto LABEL_89;
3650 }
3651 if ( GetCurrentMenuID() == 8 )
3652 {
3653 v40 = 11;
3654 goto LABEL_89;
3655 }
3656 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3657 {
3658 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)5;
3659 LABEL_93:
3660 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
3661 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3662 ++pMessageQueue_50CBD0->uNumMessages;
3663 continue;
3664 }
3665 continue;
3666 }
3667 v16 = GetCurrentMenuID() == 8;
3668 v17 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
3669 if ( v16
3670 && !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
3671 goto LABEL_83;
3672 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 12 )
3673 {
3674 pIcons_LOD->_4114F2();
3675 crt_deconstruct_ptr_6A0118();
3676 stru_506F20.Release();
3677 stru_506F20.Load("title.pcx", 0);
3678 SetCurrentMenuID(0);
3679 v15 = 1;
3680 LABEL_81:
3681 pGUIWindow_CurrentMenu->Release();
3682 pGUIWindow2->Release();
3683 pGUIWindow2 = 0;
3684 pEventTimer->Resume();
3685 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
3686 viewparams->bRedrawGameUI = v15;
3687 continue;
3688 }
3689 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16 )
3690 {
3691 pVideoPlayer->Unload();
3692 }
3693 else
3694 {
3695 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 27 )
3696 goto LABEL_81;
3697 //VideoPlayer::dtor();
3698 }
3699 }
3700 else
3701 {
3702 if ( v45 == 118 )
3703 {
3704 v14 = *(int *)uClass;
3705 pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
3706 - pGUIWindow_CurrentMenu->field_38)
3707 % 7
3708 + pGUIWindow_CurrentMenu->field_38
3709 + 7 * *(int *)uClass;
3710 uPlayerCreationUI_SelectedCharacter = v14;
3711 LABEL_36:
3712 v42 = 0;
3713 v38 = 0;
3714 v36 = 0;
3715 v34 = 0;
3716 v32 = -1;
3717 v31 = 0;
3718 v30 = 0;
3719 v29 = (SoundID)66;
3720 LABEL_40:
3721 pAudioPlayer->PlaySound(v29, v30, v31, v32, v34, v36, v38, v42);
3722 continue;
3723 }
3724 if ( v45 == 144 )
3725 {
3726 v9 = (Player *)&v1[6972 * *(int *)uClass];
3727 v46 = v9->GetSexByVoice();
3728 do
3729 {
3730 v12 = ((v9->uVoiceID-- - 1) & 0x80000000u) != 0;
3731 if ( v12 )
3732 v9->uVoiceID = 19;
3733 v13 = v9->GetSexByVoice();
3734 }
3735 while ( v13 != v46 );
3736 v11 = pCreationUI_BtnPressLeft2[*(int *)uClass];
3737 goto LABEL_60;
3738 }
3739 if ( v45 == 145 )
3740 {
3741 v9 = (Player *)&v1[6972 * *(int *)uClass];
3742 v46 = v9->GetSexByVoice();
3743 do
3744 {
3745 v9->uVoiceID = (signed int)(v9->uVoiceID + 1) % 20;
3746 v10 = v9->GetSexByVoice();
3747 }
3748 while ( v10 != v46 );
3749 v11 = pCreationUI_BtnPressRight2[*(int *)uClass];
3750 LABEL_60:
3751 GUIWindow::Create(v11->uX, v11->uY, 0, 0, (enum WindowType)92, (int)v11, 1);
3752 pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
3753 v9->PlaySound(102, 0);
3754 continue;
3755 }
3756 if ( v45 == UIMSG_A2 )
3757 {
3758 --dword_6A0C9C;
3759 if ( dword_6A0C9C < 0 )
3760 dword_6A0C9C = 0;
3761 v7 = pGUIWindow_CurrentMenu;
3762 v43 = 0;
3763 v39 = (int)ptr_69BD5C;
3764 v8 = pGUIWindow_CurrentMenu->uFrameY + 197;
3765 LABEL_105:
3766 v37 = (WindowType)90;
3767 v35 = 0;
3768 v33 = 0;
3769 v18 = v7->uFrameX + 215;
3770 goto LABEL_134;
3771 }
3772 }
3773 }
3774 else
3775 {
3776 if ( v45 == 75 )
3777 {
3778 uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
3779 v41 = 3;
3780 v1 = (char *)pParty->pPlayers;
3781 v5 = (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7
3782 + pGUIWindow_CurrentMenu->field_38
3783 + 7 * *(int *)uClass;
3784 goto LABEL_44;
3785 }
3786 if ( (signed int)v45 > 60 )
3787 {
3788 if ( v45 == 62 )
3789 {
3790 GUIWindow::Create(0x265u, 0x189u, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
3791 ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->IncreaseAttribute(
3792 (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7);
3793 v42 = 0;
3794 v38 = 0;
3795 v36 = 0;
3796 v34 = 0;
3797 v32 = -1;
3798 v31 = 0;
3799 v30 = 0;
3800 v29 = (SoundID)20;
3801 goto LABEL_40;
3802 }
3803 if ( v45 == 63 )
3804 {
3805 GUIWindow::Create(0x20Bu, 0x189u, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
3806 ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
3807 (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7);
3808 v42 = 0;
3809 v38 = 0;
3810 v36 = 0;
3811 v34 = 0;
3812 v32 = -1;
3813 v31 = 0;
3814 v30 = 0;
3815 v29 = (SoundID)23;
3816 goto LABEL_40;
3817 }
3818 if ( v45 == 64 )
3819 {
3820 auto _t = (Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter];
3821 v6 = _t->GetSkillIdxByOrder(
3822 *(int *)uClass + 4);
3823 if ( _t->GetSkillIdxByOrder(3) == 37 )
3824 pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
3825 v42 = 0;
3826 v38 = 0;
3827 v36 = 0;
3828 v34 = 0;
3829 v32 = -1;
3830 v31 = 0;
3831 v30 = 0;
3832 v29 = (SoundID)24;
3833 goto LABEL_40;
3834 }
3835 if ( v45 == 65 )
3836 {
3837 ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->Reset(uClass[0]);
3838 goto LABEL_36;
3839 }
3840 if ( v45 == 66 )
3841 {
3842 GUIWindow::Create(0x244u, 0x1AFu, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
3843 if ( PlayerCreation_ComputeAttributeBonus() || !sub_4908DE() )
3844 GameUI_StatusBar_TimedStringTimeLeft = GetTickCount() + 4000;
3845 else
3846 uGameState = 6;
3847 continue;
3848 }
3849 if ( v45 == 67 )
3850 {
3851 GUIWindow::Create(0x20Fu, 0x1AFu, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
3852 pParty->Reset();
3853 }
3854 else
3855 {
3856 if ( v45 == 74 )
3857 {
3858 uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
3859 v4 = pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38;
3860 v46 = pGUIWindow_CurrentMenu->field_38;
3861 v41 = 2;
3862 v5 = v4 % 7 + v46 + 7 * *(int *)uClass;
3863 LABEL_44:
3864 pGUIWindow_CurrentMenu->field_2C_focus_id = v5;
3865 pParty->pPlayers[0].pActiveSkills[((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
3866 + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
3867 continue;
3868 }
3869 }
3870 }
3871 else
3872 {
3873 switch ( v45 )
3874 {
3875 case 60:
3876 pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
3877 v3 = *(void **)uClass;
3878 uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
3879 pKeyActionMap->_459E5A(0, 15, pGUIWindow_CurrentMenu);
3880 pGUIWindow_CurrentMenu->ptr_1C = v3;
3881 break;
3882 case 5:
3883 uGameState = 1;
3884 break;
3885 case 17:
3886 pMouse->SetCursorBitmap("MICON2");
3887 break;
3888 default:
3889 if ( v45 == 54 )
3890 {
3891 GUIWindow::Create(0x1EFu, 0xACu, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
3892 v2 = 1;
3893 goto LABEL_90;
3894 }
3895 if ( v45 == 55 )
3896 {
3897 GUIWindow::Create(0x1EFu, 0xE3u, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnLoad, 0);
3898 v40 = 3;
3899 goto LABEL_89;
3900 }
3901 if ( v45 == 56 )
3902 {
3903 GUIWindow::Create(0x1EFu, 0x11Au, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnCredits, 0);
3904 v40 = 2;
3905 goto LABEL_89;
3906 }
3907 if ( v45 == 57 )
3908 {
3909 GUIWindow::Create(0x1EFu, 0x151u, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
3910 v40 = 4;
3911 goto LABEL_89;
3912 }
3913 if ( v45 == 58 )
3914 goto LABEL_114;
3915 break;
3916 }
3917 }
3918 }
3919 }
3920 while ( pMessageQueue_50CBD0->uNumMessages );
3921 }
3922 }
3923
3924 //----- (00436427) --------------------------------------------------------
3925 double __cdecl get_shading_dist_mist()
3926 {
3927 double result; // st7@2
3928
3929 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3930 result = (double)pOutdoorCamera->shading_dist_mist;
3931 else
3932 result = 16192.0;
3933 return result;
3934 }
3935
3936 //----- (0043643E) --------------------------------------------------------
3937 double __cdecl GetPickDepth()
3938 {
3939 double result; // st7@2
3940
3941 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3942 result = (double)pOutdoorCamera->uPickDepth;
3943 else
3944 result = 16192.0;
3945 return result;
3946 }
3947
3948 //----- (0043648F) --------------------------------------------------------
3949 void __thiscall Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
3950 {
3951 signed int v2; // edx@1
3952 double v3; // st7@1
3953
3954 _this->flt_2C = 0.0;
3955 v2 = a2->y;
3956 v3 = (double)a2->z;
3957 _this->vWorldPosition.x = (double)a2->x;
3958 _this->vWorldPosition.y = (double)v2;
3959 _this->vWorldPosition.z = v3;
3960 }
3961
3962 //----- (004369DB) --------------------------------------------------------
3963 void Vec3_float_::Normalize()
3964 {
3965 Vec3_float_ *v1; // esi@1
3966 double v2; // st7@1
3967
3968 auto a1 = this;
3969 v1 = a1;
3970 v2 = 1.0 / sqrt(a1->x * a1->x + a1->y * a1->y + a1->z * a1->z);
3971 v1->x = v2 * v1->x;
3972 v1->y = v2 * v1->y;
3973 v1->z = v2 * v1->z;
3974 }
3975
3976
3977
3978
3979
3980
3981
3982 //----- (004382BC) --------------------------------------------------------
3983 __int16 __thiscall sub_4382BC(int _this)
3984 {
3985 LOG_DECOMPILATION_WARNING();
3986 return 0;
3987 /*__int16 result; // ax@4
3988 __int16 v14; // sp@11
3989 int v15; // [sp-4h] [bp-Ch]@0
3990 signed __int16 v16; // [sp+4h] [bp-4h]@1
3991 __int16 v17; // [sp+4h] [bp-4h]@8
3992 __int16 v18; // [sp+4h] [bp-4h]@11
3993
3994 v16 = 1;
3995 __asm { pushf }
3996 if ( v15 == (v15 ^ 0x200000) )
3997 v16 = 0;
3998 if ( v16 )
3999 {
4000 result = sub_43847A();
4001 }
4002 else
4003 {
4004 //UNDEF(_ZF);
4005 //UNDEF(_SF);
4006 //UNDEF(_OF);
4007 _CF = 0;
4008 if ( !_ZF )
4009 _CF = 1;
4010 __asm { pushfw }
4011 bProcessorIsNotIntel = (BYTE2(v15) & 1 ^ 1) & 1;
4012 _CF = 0;
4013 _OF = 0;
4014 _ZF = 0;
4015 _SF = 1;
4016 __asm { pushfw }
4017 v17 = 2;
4018 if ( (HIWORD(v15) | 0xF000) & 0xF000 )
4019 v17 = -1;
4020 __asm { popfw }
4021 result = v17;
4022 if ( v17 != 2 )
4023 {
4024 _CF = 0;
4025 _OF = 0;
4026 _ZF = v14 == 0;
4027 _SF = v14 < 0;
4028 __asm { pushf }
4029 v18 = 3;
4030 if ( v15 != (v15 ^ 0x40000) )
4031 v18 = -1;
4032 __asm { popf }
4033 result = v18;
4034 if ( v18 != 3 )
4035 result = 4;
4036 }
4037 }
4038 if ( bProcessorIsNotIntel )
4039 HIBYTE(result) |= 0x80u;
4040 return result;*/
4041 }
4042
4043 //----- (004383ED) --------------------------------------------------------
4044 int __cdecl sub_4383ED()
4045 {
4046 LOG_DECOMPILATION_WARNING();
4047 return 0;
4048 /*signed int v9; // eax@4
4049 int v16; // [sp-4h] [bp-38h]@0
4050 int v17[3]; // [sp+Ch] [bp-28h]@1
4051 char v18; // [sp+18h] [bp-1Ch]@1
4052 char v19; // [sp+19h] [bp-1Bh]@1
4053 int v20[4]; // [sp+1Ch] [bp-18h]@1
4054 int v21; // [sp+2Ch] [bp-8h]@1
4055 int v22; // [sp+30h] [bp-4h]@1
4056
4057 v17[0] = *(int *)"------------";
4058 v17[1] = *(int *)"--------";
4059 v17[2] = *(int *)"----";
4060 v18 = asc_4E4938[12];
4061 v19 = 0;
4062 v22 = 0;
4063 v20[0] = *(int *)"GenuineIntel";
4064 v20[1] = *(int *)"ineIntel";
4065 v20[2] = *(int *)"ntel";
4066 LOBYTE(v20[3]) = aGenuineintel[12];
4067 _CF = 0;
4068 _OF = 0;
4069 _ZF = 0;
4070 _SF = 0;
4071 v21 = 1;
4072 __asm { pushf }
4073 if ( v16 == (v16 ^ 0x200000) )
4074 v21 = 0;
4075 if ( (short)v21 )
4076 {
4077 _EAX = 0;
4078 __asm { cpuid }
4079 v17[0] = _EBX;
4080 v17[1] = _EDX;
4081 v17[2] = _ECX;
4082 v9 = 0;
4083 do
4084 {
4085 if ( *((char *)v17 + v9) != *((char *)v20 + v9) )
4086 bProcessorIsNotIntel = 1;
4087 ++v9;
4088 }
4089 while ( v9 < 12 );
4090 if ( v9 >= 1 )
4091 {
4092 _EAX = 1;
4093 __asm { cpuid }
4094 v22 = _EDX;
4095 }
4096 }
4097 return v22;*/
4098 }
4099
4100 //----- (0043847A) --------------------------------------------------------
4101 __int16 __cdecl sub_43847A()
4102 {
4103 __debugbreak();
4104 return 0;
4105 /*signed int v5; // eax@1
4106 char v12[12]; // [sp+Ch] [bp-28h]@1
4107 char v13; // [sp+18h] [bp-1Ch]@1
4108 char v14; // [sp+19h] [bp-1Bh]@1
4109 int v15[4]; // [sp+1Ch] [bp-18h]@1
4110 int v16; // [sp+2Eh] [bp-6h]@1
4111 char v17; // [sp+32h] [bp-2h]@6
4112 char v18; // [sp+33h] [bp-1h]@1
4113
4114 *(int *)v12 = *(int *)"------------";
4115 *(int *)&v12[4] = *(int *)"--------";
4116 *(int *)&v12[8] = *(int *)"----";
4117 v13 = asc_4E4938[12];
4118 v14 = 0;
4119 v18 = 0;
4120 v15[0] = *(int *)"GenuineIntel";
4121 v15[1] = *(int *)"ineIntel";
4122 v15[2] = *(int *)"ntel";
4123 v16 = 65535;
4124 LOBYTE(v15[3]) = aGenuineintel[12];
4125 _EAX = 0;
4126 __asm { cpuid }
4127 *(int *)v12 = _EBX;
4128 *(int *)&v12[4] = _EDX;
4129 *(int *)&v12[8] = _ECX;
4130 v5 = 0;
4131 do
4132 {
4133 if ( v12[v5] != *((char *)v15 + v5) )
4134 bProcessorIsNotIntel = 1;
4135 ++v5;
4136 }
4137 while ( v5 < 12 );
4138 if ( v5 >= 1 )
4139 {
4140 _EAX = 1;
4141 __asm { cpuid }
4142 v18 = _EAX & 0xF;
4143 LOBYTE(_EAX) = (unsigned __int8)(_EAX & 0xF0) >> 4;
4144 v17 = _EAX;
4145 LOWORD(v16) = ((_EAX & 0xF00u) >> 8) & 0xF;
4146 }
4147 return v16;*/
4148 }
4149
4150
4151
4152 //----- (004385B5) --------------------------------------------------------
4153 void stru11::CheckCPU()
4154 {
4155 LOG_DECOMPILATION_WARNING();
4156 /*
4157 int v5; // [sp-4h] [bp-10h]@0
4158 signed int v6; // [sp+4h] [bp-8h]@1
4159 signed int v7; // [sp+8h] [bp-4h]@1
4160
4161 _CF = 0;
4162 _OF = 0;
4163 _ZF = 1;
4164 _SF = 0;
4165 v7 = 0;
4166 __asm { pushf }
4167 v6 = 3;
4168 if ( v5 != (v5 ^ 0x40000) )
4169 {
4170 __asm { popf }
4171 v6 = 4;
4172 __asm { pushf }
4173 if ( v5 != (v5 ^ 0x200000) )
4174 {
4175 v7 = 1;
4176 v6 = 0;
4177 }
4178 }
4179 if ( v6 == 3 )
4180 {
4181 this->field_AC = 1;
4182 }
4183 else
4184 {
4185 if ( v6 == 4 )
4186 {
4187 this->field_AC = 2;
4188 }
4189 else
4190 {
4191 if ( v7 )
4192 {
4193 this->field_AC = 2;
4194 RunCPUID();
4195 }
4196 else
4197 {
4198 this->field_AC = 0;
4199 }
4200 }
4201 }*/
4202 }
4203
4204 //----- (00438659) --------------------------------------------------------
4205 void stru11::RunCPUID()
4206 {
4207 __debugbreak();
4208 /*stru11 *v6; // esi@1
4209 unsigned int uNumOps; // edi@1
4210 int uNumExtOps; // edi@16
4211 char pCyrixString[16]; // [sp+Ch] [bp-60h]@1
4212 char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1
4213 char pAMDString[16]; // [sp+2Ch] [bp-40h]@1
4214 char pIntelString[16]; // [sp+3Ch] [bp-30h]@1
4215 char pCPUString[16]; // [sp+4Ch] [bp-20h]@1
4216 stru11 *thisa; // [sp+5Ch] [bp-10h]@1
4217 char *v35; // [sp+60h] [bp-Ch]@1
4218 int v36; // [sp+64h] [bp-8h]@1
4219 int v37; // [sp+68h] [bp-4h]@1
4220
4221 thisa = this;
4222 *(int *)pIntelString = *(int *)"GenuineIntel";
4223 *(int *)&pIntelString[4] = *(int *)"ineIntel";
4224 *(int *)&pIntelString[8] = *(int *)"ntel";
4225 pIntelString[12] = aGenuineintel[12];
4226 *(int *)pAMDString = *(int *)"AuthenticAMD";
4227 *(int *)&pAMDString[4] = *(int *)"enticAMD";
4228 *(int *)&pAMDString[8] = *(int *)"cAMD";
4229 pAMDString[12] = aAuthenticamd[12];
4230 *(int *)pCyrixString = *(int *)"CyrixInstead";
4231 *(int *)&pCyrixString[4] = *(int *)"xInstead";
4232 *(int *)&pCyrixString[8] = *(int *)"tead";
4233 pCyrixString[12] = aCyrixinstead[12];
4234 *(int *)pCentaurString = *(int *)"CentaurHauls";
4235 *(int *)&pCentaurString[4] = *(int *)"aurHauls";
4236 *(int *)&pCentaurString[8] = *(int *)"auls";
4237 v37 = 0;
4238 v36 = 0;
4239 pCentaurString[12] = aCentaurhauls[12];
4240 v35 = pCPUString;
4241 pCPUString[12] = 0;
4242 _EAX = 0;
4243 __asm { cpuid }
4244 v37 = _EAX;
4245 *(int *)pCPUString = _EBX;
4246 *(int *)&pCPUString[4] = _EDX;
4247 *(int *)&pCPUString[8] = _ECX;
4248 v6 = thisa;
4249 uNumOps = _EAX;
4250 thisa->cpuid_00000000_ebx_vendorstr1 = _EBX;
4251 v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4];
4252 v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8];
4253 v6->cpuid_00000000_eax_numops = _EAX;
4254 strcpy(v6->pCPUString, pCPUString);
4255 if ( strcmp(pIntelString, pCPUString) )
4256 {
4257 if ( strcmp(pAMDString, pCPUString) )
4258 {
4259 if ( strcmp(pCyrixString, pCPUString) )
4260 {
4261 if ( strcmp(pCentaurString, pCPUString) )
4262 v6->uProcessorManufacturer = 0;
4263 else
4264 v6->uProcessorManufacturer = 4;
4265 }
4266 else
4267 {
4268 v6->uProcessorManufacturer = 3;
4269 }
4270 }
4271 else
4272 {
4273 v6->uProcessorManufacturer = 2;
4274 }
4275 }
4276 else
4277 {
4278 v6->uProcessorManufacturer = 1;
4279 }
4280 if ( uNumOps >= 1 )
4281 RunCPUID_op1();
4282 if ( uNumOps >= 2 )
4283 RunCPUID_op2();
4284 _EAX = 0x80000000u;
4285 __asm { cpuid }
4286 if ( !(_EAX & 0x80000000) )
4287 _EAX = 0x80000000u;
4288 v36 = _EAX;
4289 v6->cpuid_80000000_edx = _EAX;
4290 uNumExtOps = _EAX ^ 0x80000000;
4291 if ( (_EAX ^ 0x80000000u) >= 1 )
4292 {
4293 _EAX = 0x80000001u;
4294 __asm { cpuid }
4295 thisa = (stru11 *)_EAX;
4296 v35 = (char *)_EDX;
4297 v6->cpuid_80000001_eax = _EAX;
4298 v6->cpuid_80000001_edx = (int)v35;
4299 }
4300 if ( (unsigned int)uNumExtOps >= 4 )
4301 RunCPUID_ext2_3_4();
4302 if ( (unsigned int)uNumExtOps >= 5 )
4303 {
4304 _EAX = 0x80000005u;
4305 __asm { cpuid }
4306 thisa = (stru11 *)_EBX;
4307 v35 = (char *)_ECX;
4308 v36 = _EDX;
4309 v6->cpuid_80000005_ebx = _EBX;
4310 v6->cpuid_80000005_ecx = (int)v35;
4311 v6->cpuid_80000005_edx = v36;
4312 }
4313 if ( (unsigned int)uNumExtOps >= 6 )
4314 {
4315 _EAX = 0x80000006u;
4316 __asm { cpuid }
4317 v6->cpuid_80000006_ecx = _ECX;
4318 }*/
4319 }
4320
4321 //----- (00438821) --------------------------------------------------------
4322 void stru11::RunCPUID_op1()
4323 {
4324 __debugbreak();
4325 /*stru11 *v1; // esi@1
4326 unsigned int v7; // ecx@1
4327 int v8; // eax@3
4328 int v9; // eax@10
4329 signed int v10; // eax@11
4330 int v11; // ecx@11
4331 int v12; // eax@15
4332 signed int v13; // eax@19
4333 int v14; // ecx@19
4334 signed int v15; // eax@25
4335 int v16; // ecx@25
4336 signed int v17; // eax@34
4337 int v18; // ecx@34
4338
4339 v1 = this;
4340 _EAX = 1;
4341 __asm { cpuid }
4342 v7 = _EAX;
4343 v1->cpuid_00000001_edx = _EDX;
4344 v1->cpuid_00000001_eax = _EAX;
4345 if ( (_EAX & 0x3000) == 8192 )
4346 {
4347 LOBYTE(v1->cpuid_80000002_registers2[0]) = 1;
4348 v7 = 0;
4349 }
4350 v8 = (v7 >> 8) & 0xF;
4351 switch ( v8 )
4352 {
4353 case 4:
4354 v1->field_AC = 2;
4355 break;
4356 case 5:
4357 v1->field_AC = 15;
4358 break;
4359 case 6:
4360 v1->field_AC = 36;
4361 break;
4362 default:
4363 v1->field_AC = 49;
4364 break;
4365 }
4366 v9 = v1->uProcessorManufacturer;
4367 if ( v9 == 1 )
4368 {
4369 v10 = 0;
4370 v11 = v7 & 0x3FF0;
4371 while ( v11 != dword_4E4948[2 * v10] )
4372 {
4373 ++v10;
4374 if ( v10 >= 17 )
4375 return;
4376 }
4377 v12 = dword_4E494C[2 * v10];
4378 goto LABEL_39;
4379 }
4380 if ( v9 == 2 )
4381 {
4382 if ( (v7 & 0xF00) == dword_4E49D0[0] )
4383 {
4384 v12 = dword_4E49D4[0];
4385 }
4386 else
4387 {
4388 v13 = 1;
4389 v14 = v7 & 0x3FF0;
4390 while ( v14 != dword_4E49D0[2 * v13] )
4391 {
4392 ++v13;
4393 if ( v13 >= 9 )
4394 return;
4395 }
4396 v12 = dword_4E49D4[2 * v13];
4397 }
4398 goto LABEL_39;
4399 }
4400 if ( v9 != 3 )
4401 {
4402 if ( v9 != 4 )
4403 return;
4404 v17 = 0;
4405 v18 = v7 & 0x3FF0;
4406 while ( v18 != dword_4E4A40[2 * v17] )
4407 {
4408 ++v17;
4409 if ( v17 >= 2 )
4410 return;
4411 }
4412 v12 = dword_4E4A44[2 * v17];
4413 goto LABEL_39;
4414 }
4415 v15 = 1;
4416 v16 = v7 & 0x3FF0;
4417 while ( v16 != dword_4E4A18[2 * v15] )
4418 {
4419 ++v15;
4420 if ( v15 >= 5 )
4421 goto LABEL_30;
4422 }
4423 v1->field_AC = dword_4E4A1C[2 * v15];
4424 LABEL_30:
4425 v12 = 24;
4426 if ( v1->field_AC == 24 )
4427 {
4428 if ( _EDX != 1 )
4429 v12 = (((_EDX != 261) - 1) & 0xA) + 15;
4430 LABEL_39:
4431 v1->field_AC = v12;
4432 }*/
4433 }
4434
4435 //----- (00438992) --------------------------------------------------------
4436 void stru11::RunCPUID_op2()
4437 {
4438 __debugbreak();
4439 /*
4440 stru11 *v1; // edi@1
4441 int v7; // eax@1
4442 signed int v8; // ecx@2
4443 unsigned __int8 v9; // al@3
4444 signed int v10; // ecx@14
4445 unsigned __int8 v11; // al@15
4446 int v12; // [sp+Ch] [bp-14h]@1
4447 int v13; // [sp+10h] [bp-10h]@1
4448 int v14; // [sp+14h] [bp-Ch]@1
4449 int v15; // [sp+18h] [bp-8h]@1
4450 int *v16; // [sp+1Ch] [bp-4h]@1
4451
4452 v1 = this;
4453 v16 = &v12;
4454 _EAX = 2;
4455 __asm { cpuid }
4456 v12 = _EAX;
4457 v13 = _EBX;
4458 v14 = _ECX;
4459 v15 = _EDX;
4460 v1->cpuid_00000002_eax = _EAX;
4461 v1->cpuid_00000002_ebx = v13;
4462 v1->cpuid_00000002_ecx = v14;
4463 v1->cpuid_00000002_edx = v15;
4464 v7 = v1->field_AC;
4465 if ( v7 == 40 )
4466 {
4467 v8 = 0;
4468 while ( 1 )
4469 {
4470 v9 = *((char *)&v12 + v8);
4471 if ( v9 == 64 )
4472 {
4473 v1->field_AC = 43;
4474 return;
4475 }
4476 if ( v9 >= 0x41u && v9 <= 0x43u )
4477 {
4478 v1->field_AC = 41;
4479 return;
4480 }
4481 if ( v9 >= 0x44u && v9 <= 0x45u )
4482 break;
4483 ++v8;
4484 if ( v8 >= 16 )
4485 return;
4486 }
4487 v1->field_AC = 42;
4488 }
4489 else
4490 {
4491 if ( v7 == 45 )
4492 {
4493 v10 = 0;
4494 while ( 1 )
4495 {
4496 v11 = *((char *)&v12 + v10);
4497 if ( v11 >= 0x40u && v11 <= 0x43u )
4498 {
4499 v1->field_AC = 46;
4500 return;
4501 }
4502 if ( v11 >= 0x44u && v11 <= 0x45u )
4503 break;
4504 ++v10;
4505 if ( v10 >= 16 )
4506 return;
4507 }
4508 v1->field_AC = 47;
4509 }
4510 }*/
4511 }
4512
4513 //----- (00438A67) --------------------------------------------------------
4514 void stru11::RunCPUID_ext2_3_4()
4515 {
4516 __debugbreak();
4517 /*stru11 *v1; // edi@1
4518 stru11 *v17; // eax@1
4519 int v18[3][4]; // [sp+Ch] [bp-38h]@1
4520 stru11 *v19; // [sp+3Ch] [bp-8h]@1
4521
4522 v1 = this;
4523 v19 = this;
4524 _EAX = 0x80000002u;
4525 __asm { cpuid }
4526 v18[0][0] = _EAX;
4527 *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX);
4528 v18[0][3] = _EDX;
4529 _EAX = 0x80000003u;
4530 __asm { cpuid }
4531 v18[1][0] = _EAX;
4532 *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX);
4533 v18[1][3] = _EDX;
4534 _EAX = 0x80000004u;
4535 __asm { cpuid }
4536 v18[2][0] = _EAX;
4537 *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX);
4538 v18[2][3] = _EDX;
4539 v17 = v19;
4540 memcpy(v1->cpuid_80000002_registers, v18, 0x30u);
4541 memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/
4542 }
4543
4544
4545
4546 //----- (00438BDF) --------------------------------------------------------
4547 bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype)
4548 {
4549 unsigned __int8 v2; // zf@15
4550 char v3; // sf@15
4551 unsigned __int8 v4; // of@15
4552 bool result; // eax@33
4553
4554 switch ( eSupertype )
4555 {
4556 case MONSTER_SUPERTYPE_UNDEAD:
4557 if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3
4558 || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3
4559 || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3
4560 || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3
4561 || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3
4562 || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 )
4563 goto ret_true;
4564 if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 )
4565 goto ret_false;
4566 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3);
4567 v2 = uMonsterInfoID == MONSTER_GHOUL_3;
4568 v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0;
4569 goto false_if_outside;
4570 case MONSTER_SUPERTYPE_KREEGAN:
4571 if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 )
4572 goto ret_false;
4573 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3);
4574 v2 = uMonsterInfoID == MONSTER_DEVIL_3;
4575 v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0;
4576 goto false_if_outside;
4577 case MONSTER_SUPERTYPE_ELF:
4578 if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1
4579 && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3
4580 || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 )
4581 goto ret_true;
4582 if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 )
4583 goto ret_false;
4584 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3);
4585 v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3;
4586 v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0;
4587 goto false_if_outside;
4588 case MONSTER_SUPERTYPE_DRAGON:
4589 if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 )
4590 goto ret_false;
4591 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3);
4592 v2 = uMonsterInfoID == MONSTER_DRAGON_3;
4593 v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0;
4594 goto false_if_outside;
4595 case MONSTER_SUPERTYPE_WATER_ELEMENTAL:
4596 if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 )
4597 goto ret_false;
4598 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3);
4599 v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3;
4600 v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0;
4601 goto false_if_outside;
4602 case MONSTER_SUPERTYPE_TREANT:
4603 if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 )
4604 goto ret_false;
4605 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3);
4606 v2 = uMonsterInfoID == MONSTER_TREANT_3;
4607 v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0;
4608 goto false_if_outside;
4609 case MONSTER_SUPERTYPE_TITAN:
4610 if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 )
4611 goto ret_false;
4612 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3);
4613 v2 = uMonsterInfoID == MONSTER_TITAN_3;
4614 v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0;
4615 false_if_outside:
4616 if ( !((unsigned __int8)(v3 ^ v4) | v2) )
4617 goto ret_false;
4618 ret_true:
4619 result = 1;
4620 break;
4621 default:
4622 ret_false:
4623 result = 0;
4624 break;
4625 }
4626 return result;
4627 }
4628
4629
4630 //----- (00438F8F) --------------------------------------------------------
4631 void __cdecl _438F8F_area_of_effect__damage_evaluate()
4632 {
4633 int v0; // edx@1
4634 char *v1; // esi@2
4635 int v2; // ecx@3
4636 signed int v3; // eax@3
4637 LayingItem *v4; // eax@4
4638 signed int v5; // eax@4
4639 signed int v6; // eax@6
4640 unsigned int v7; // edi@6
4641 int v8; // eax@6
4642 __int16 v9; // bx@8
4643 int v10; // edi@8
4644 Vec3_int_ v11; // ST04_12@9
4645 int v12; // ST0C_4@10
4646 Actor *v13; // edi@11
4647 int v14; // edx@15
4648 int v15; // edx@15
4649 int v16; // ebx@15
4650 signed int v17; // eax@15
4651 int v18; // edi@15
4652 int v19; // edi@15
4653 Vec3_int_ v20; // ST04_12@16
4654 Vec3_int_ *v21; // eax@17
4655 unsigned int v22; // edx@17
4656 int v23; // edx@18
4657 int v24; // eax@18
4658 Vec3_int_ v25; // ST04_12@19
4659 unsigned int v26; // ebx@20
4660 char *v27; // edi@20
4661 char *v28; // edi@27
4662 int v29; // ebx@29
4663 int v30; // eax@29
4664 int v31; // edx@29
4665 int v32; // eax@29
4666 int v33; // ST24_4@29
4667 Vec3_int_ v34; // ST04_12@30
4668 Vec3_int_ *v35; // eax@31
4669 LayingItem *v36; // [sp+0h] [bp-28h]@0
4670 signed int v37; // [sp+4h] [bp-24h]@5
4671 int v38; // [sp+4h] [bp-24h]@15
4672 signed int v39; // [sp+8h] [bp-20h]@3
4673 int v40; // [sp+8h] [bp-20h]@15
4674 int v41; // [sp+Ch] [bp-1Ch]@5
4675 int v42; // [sp+Ch] [bp-1Ch]@15
4676 int v43; // [sp+10h] [bp-18h]@1
4677 int v44; // [sp+14h] [bp-14h]@15
4678 unsigned int uActorID; // [sp+18h] [bp-10h]@6
4679 Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2
4680 int a1; // [sp+20h] [bp-8h]@8
4681 int v48; // [sp+24h] [bp-4h]@8
4682
4683 v0 = 0;
4684 v43 = 0;
4685 if ( stru_50FE08.count > 0 )
4686 {
4687 pVelocity = &stru_50FE08.vec_4B4;
4688 v1 = (char *)stru_50FE08.pZs;
4689 do
4690 {
4691 v2 = *((short *)v1 - 300) & 7;
4692 v3 = (signed int)*((short *)v1 - 300) >> 3;
4693 v39 = (signed int)*((short *)v1 - 300) >> 3;
4694 if ( v2 == 2 )
4695 {
4696 v4 = &pLayingItems[v3];
4697 v36 = v4;
4698 v5 = v4->field_58;
4699 v2 = v5 & 7;
4700 v3 = v5 >> 3;
4701 }
4702 v41 = v2;
4703 v37 = v3;
4704 if ( stru_50FE08.field_3EC[v0] & 1 )
4705 {
4706 v6 = dword_4F6E08[v3];
4707 v7 = v6 >> 3;
4708 v8 = (v6 & 7) - 3;
4709 uActorID = v7;
4710 if ( v8 )
4711 {
4712 if ( v8 == 1 )
4713 {
4714 v9 = *(short *)v1;
4715 v10 = pParty->vPosition.z - *((short *)v1 - 100);
4716 a1 = pParty->vPosition.x - *((short *)v1 - 200);
4717 v48 = v10;
4718 if ( a1 * a1
4719 + v10 * v10
4720 + ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9))
4721 * ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
4722 {
4723 v11.z = *(short *)v1;
4724 v11.y = *((short *)v1 - 100);
4725 v11.x = *((short *)v1 - 200);
4726 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v11) )
4727 {
4728 v12 = stru_50C198.which_player_would_attack(&pActors[v39]);
4729 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
4730 }
4731 }
4732 }
4733 }
4734 else
4735 {
4736 v13 = &pActors[v7];
4737 if ( SHIDWORD(v13->pActorBuffs[6].uExpireTime) > 0
4738 || SHIDWORD(v13->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(v13->pActorBuffs[6].uExpireTime)
4739 || v13->CanAct() )
4740 {
4741 v14 = v13->vPosition.y;
4742 v40 = v13->vPosition.x;
4743 v38 = v14;
4744 v15 = v14 - *((short *)v1 - 100);
4745 v16 = *(short *)v1;
4746 v42 = v13->vPosition.z;
4747 a1 = v40 - *((short *)v1 - 200);
4748 v17 = v13->uActorHeight;
4749 v18 = v13->uActorRadius;
4750 v44 = v42;
4751 v19 = *((short *)v1 + 100) + v18;
4752 v48 = v15;
4753 if ( a1 * a1 + v15 * v15 + (v42 + (v17 >> 1) - v16) * (v42 + (v17 >> 1) - v16) < (unsigned int)(v19 * v19) )
4754 {
4755 v20.z = *(short *)v1;
4756 v20.y = *((short *)v1 - 100);
4757 v20.x = *((short *)v1 - 200);
4758 if ( sub_407A1C(v40, v38, v42 + 50, v20) )
4759 {
4760 Vec3_int_::Normalize(&a1, &v48, &v44);
4761 v21 = pVelocity;
4762 v22 = uActorID;
4763 pVelocity->x = a1;
4764 v21->y = v48;
4765 v21->z = v44;
4766 sub_43B1B0(*((short *)v1 - 300), v22, v21, stru_50FE08.field_450[v43]);
4767 }
4768 }
4769 }
4770 }
4771 }
4772 else
4773 {
4774 v23 = pParty->vPosition.z - *((short *)v1 - 100);
4775 v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
4776 a1 = pParty->vPosition.x - *((short *)v1 - 200);
4777 v48 = v23;
4778 if ( a1 * a1 + v23 * v23 + (pParty->vPosition.y + v24) * (pParty->vPosition.y + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
4779 {
4780 v25.z = *(short *)v1;
4781 v25.y = *((short *)v1 - 100);
4782 v25.x = *((short *)v1 - 200);
4783 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v25) )
4784 {
4785 v26 = 0;
4786 v27 = (char *)&pParty->pPlayers[0].pConditions[15];
4787 do
4788 {
4789 if ( !(*((int *)v27 - 1) | *((int *)v27 - 2)) && !*(_QWORD *)v27 && !*((_QWORD *)v27 + 1) )
4790 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v26);
4791 v27 += 6972;
4792 ++v26;
4793 }
4794 while ( (signed int)v27 < (signed int)&pParty->pHirelings[1].evtb );
4795 }
4796 }
4797 uActorID = 0;
4798 if ( (signed int)uNumActors > 0 )
4799 {
4800 v28 = (char *)&pActors[0].vPosition.z;
4801 do
4802 {
4803 if ( ((Actor *)(v28 - 146))->CanAct() )
4804 {
4805 v29 = *(short *)v1;
4806 v30 = *((short *)v28 - 1) - *((short *)v1 - 100);
4807 a1 = *((short *)v28 - 2) - *((short *)v1 - 200);
4808 v31 = *(short *)v28;
4809 v48 = v30;
4810 v44 = v31;
4811 v32 = ((signed int)*((short *)v28 - 4) >> 1) - v29;
4812 v33 = *((short *)v28 - 5) + *((short *)v1 + 100);
4813 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) )
4814 {
4815 v34.z = *(short *)v1;
4816 v34.y = *((short *)v1 - 100);
4817 v34.x = *((short *)v1 - 200);
4818 if ( sub_407A1C(*((short *)v28 - 2), *((short *)v28 - 1), *(short *)v28 + 50, v34) )
4819 {
4820 Vec3_int_::Normalize(&a1, &v48, &v44);
4821 v35 = pVelocity;
4822 pVelocity->x = a1;
4823 v35->y = v48;
4824 v35->z = v44;
4825 switch ( v41 )
4826 {
4827 case 4:
4828 DamageMonsterFromParty(*((short *)v1 - 300), uActorID, v35);
4829 break;
4830 case 3:
4831 if ( v36 && pActors[v37].GetActorsRelation((Actor *)(v28 - 146)) )
4832 sub_43B1B0(*((short *)v1 - 300), uActorID, pVelocity, v36->field_61);
4833 break;
4834 case 2:
4835 sub_43B057(*((short *)v1 - 300), uActorID, v35);
4836 break;
4837 }
4838 }
4839 }
4840 }
4841 ++uActorID;
4842 v28 += 836;
4843 }
4844 while ( (signed int)uActorID < (signed int)uNumActors );
4845 }
4846 }
4847 ++pVelocity;
4848 v0 = v43 + 1;
4849 v1 += 2;
4850 ++v43;
4851 }
4852 while ( v43 < stru_50FE08.count );
4853 }
4854 stru_50FE08.count = 0;
4855 }
4856 // 50FE08: using guessed type stru298 stru_50FE08;
4857
4858 //----- (00439474) --------------------------------------------------------
4859 bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
4860 {
4861 signed int v3; // eax@1
4862 LayingItem *v4; // ebx@1
4863 int v5; // edx@3
4864 bool uPlayerID; // eax@3
4865 Player *pPlayer; // edi@4
4866 Actor *pMonster; // esi@7
4867 LayingItem *v9; // ebx@12
4868 int v10; // eax@12
4869 int v11; // ebx@12
4870 unsigned int v12; // ecx@12
4871 int v13; // edx@15
4872 int v14; // edx@17
4873 int v15; // eax@24
4874 unsigned __int16 v16; // cx@25
4875 int v17; // eax@29
4876 int v18; // eax@38
4877 unsigned __int8 v19; // zf@38
4878 unsigned __int8 v20; // sf@38
4879 int v21; // edx@44
4880 int v22; // eax@44
4881 unsigned __int8 v23; // zf@44
4882 unsigned __int8 v24; // sf@44
4883 int v25; // edx@51
4884 int v26; // ecx@51
4885 signed int v27; // eax@51
4886 int v28; // eax@53
4887 signed int v29; // eax@76
4888 signed int v30; // eax@84
4889 signed int v31; // eax@92
4890 int v32; // eax@94
4891 int v33; // eax@100
4892 int v34; // eax@104
4893 signed int v35; // eax@104
4894 double v36; // st7@104
4895 float v37; // ST08_4@104
4896 float v38; // ST04_4@104
4897 float v39; // ST00_4@104
4898 int v40; // ebx@107
4899 unsigned int v41; // ebx@109
4900 signed __int64 v42; // qax@125
4901 unsigned __int16 v43; // ax@132
4902 char v44; // bl@132
4903 unsigned __int16 v45; // ax@132
4904 unsigned __int64 v46; // [sp+Ch] [bp-60h]@6
4905 const char *v47; // [sp+14h] [bp-58h]@104
4906 char *pPlayerName; // [sp+18h] [bp-54h]@12
4907 char *pMonsterName; // [sp+1Ch] [bp-50h]@6
4908 int v50; // [sp+20h] [bp-4Ch]@6
4909 unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6
4910 int v52; // [sp+34h] [bp-38h]@12
4911 int v53; // [sp+38h] [bp-34h]@10
4912 int v54; // [sp+3Ch] [bp-30h]@1
4913 int v55; // [sp+40h] [bp-2Ch]@12
4914 signed int a4; // [sp+44h] [bp-28h]@1
4915 PlayerEquipment *v57; // [sp+48h] [bp-24h]@10
4916 int v58; // [sp+4Ch] [bp-20h]@10
4917 int v59; // [sp+50h] [bp-1Ch]@1
4918 unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
4919 int v61; // [sp+58h] [bp-14h]@1
4920 int v62; // [sp+5Ch] [bp-10h]@1
4921 int uDamageAmount; // [sp+60h] [bp-Ch]@1
4922 int a2; // [sp+64h] [bp-8h]@27
4923 int a3; // [sp+6Bh] [bp-1h]@6
4924
4925 v3 = a1;
4926 v4 = 0;
4927 uActorID_Monster_ = uActorID_Monster;
4928 v54 = a1;
4929 uDamageAmount = 0;
4930 a4 = 0;
4931 v61 = 0;
4932 v59 = 0;
4933 v62 = 0;
4934 if ( (a1 & 7) == 2 )
4935 {
4936 v4 = &pLayingItems[a1 >> 3];
4937 uDamageAmount = (int)v4;
4938 v61 = v4->field_60_distance_related_prolly_lod;
4939 v3 = v4->field_58;
4940 v54 = v4->field_58;
4941 }
4942 v5 = v3 & 7;
4943 uPlayerID = v3 >> 3;
4944 if ( v5 != 4 )
4945 return uPlayerID;
4946 pPlayer = &pParty->pPlayers[uPlayerID];
4947 if ( uPlayerID < 0 && uPlayerID > 3 )
4948 {
4949 MessageBoxW(nullptr, L"Invalid player in damageMonsterFromParty!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Damage.cpp:457", 0);
4950 }
4951 pMonster = &pActors[uActorID_Monster_];
4952 uPlayerID = pMonster->IsAlive();
4953 if ( uPlayerID )
4954 return uPlayerID;
4955 BYTE1(pMonster->uAttributes) |= 0xC0u;
4956 if ( pMonster->uAIState == Fleeing )
4957 pMonster->uAttributes |= 0x20000u;
4958 v58 = 0;
4959 v53 = 0;
4960 v57 = 0;
4961 if ( !v4 )
4962 {
4963 v51 = (unsigned __int64 *)pPlayer->pEquipment.uMainHand;
4964 v59 = 1;
4965 if ( pPlayer->HasItemEquipped(EQUIP_TWO_HANDED) )
4966 {
4967 v55 = pItemsTable->pItems[*(int *)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * (int)v51 + 5]].uSkillType;
4968 v28 = SkillToMastery(pPlayer->pActiveSkills[v55]);
4969 uDamageAmount = v28;
4970 if ( v55 )
4971 {
4972 if ( v55 == 6 )
4973 {
4974 if ( v28 >= 3 )
4975 {
4976 LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
4977 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4978 if ( rand() % 100 < (unsigned __int8)v51 )
4979 v58 = 1;
4980 }
4981 if ( uDamageAmount >= 4 )
4982 {
4983 LOBYTE(v51) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F;
4984 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4985 if ( rand() % 100 < (unsigned __int8)v51 )
4986 v53 = 1;
4987 }
4988 }
4989 }
4990 else
4991 {
4992 if ( uDamageAmount >= 3 )
4993 {
4994 LOBYTE(v51) = pPlayer->GetActualSkillLevel((PLAYER_SKILL_TYPE)0) & 0x3F;
4995 v51 = (unsigned __int64 *)(unsigned __int8)v51;
4996 if ( rand() % 100 < (unsigned __int8)v51 )
4997 v58 = 1;
4998 }
4999 }
5000 }
5001 v50 = pMonster->pMonsterInfo.uID;
5002 a2 = 4;
5003 v27 = pPlayer->CalculateMeleeDamageTo(0, 0, v50);
5004 goto LABEL_65;
5005 }
5006 v19 = v4->field_48 == 99;
5007 v61 = v4->field_60_distance_related_prolly_lod;
5008 if ( !v19 )
5009 {
5010 v9 = (LayingItem *)uDamageAmount;
5011 v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4);
5012 v55 = abs(v50);
5013 pMonsterName = (char *)(pParty->vPosition.z - v9->vPosition.y);
5014 v51 = (unsigned __int64 *)abs((int)pMonsterName);
5015 pPlayerName = (char *)(pParty->vPosition.y - v9->vPosition.z);
5016 v52 = abs((int)pPlayerName);
5017 v61 = v55;
5018 v10 = v55;
5019 v11 = (int)v51;
5020 v12 = v52;
5021 if ( v55 < (signed int)v51 )
5022 {
5023 v10 = (int)v51;
5024 v11 = v55;
5025 }
5026 if ( v10 < v52 )
5027 {
5028 v13 = v10;
5029 v10 = v52;
5030 v12 = v13;
5031 }
5032 if ( v11 < (signed int)v12 )
5033 {
5034 v14 = v12;
5035 v12 = v11;
5036 v11 = v14;
5037 }
5038 uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
5039 v61 = uPlayerID;
5040 if ( uPlayerID >= 2560 )
5041 {
5042 if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
5043 return uPlayerID;
5044 v61 = 2;
5045 }
5046 else
5047 {
5048 v61 = 1;
5049 }
5050 v4 = (LayingItem *)uDamageAmount;
5051 }
5052 v15 = v4->field_48;
5053 if ( v15 == 102 )
5054 {
5055 v16 = pPlayer->pActiveSkills[7];
5056 v61 = 1;
5057 if ( (signed int)SkillToMastery(v16) >= 3 )
5058 a4 = pPlayer->pActiveSkills[7] & 0x3F;
5059 a2 = 4;
5060 uDamageAmount = pPlayer->CalculateMeleeDamageTo(1, 1, 0);
5061 goto LABEL_67;
5062 }
5063 if ( v15 != 100 )
5064 {
5065 if ( v15 == 101 )
5066 {
5067 a2 = 0;
5068 v18 = pPlayer->CalculateRangedDamageTo(0);
5069 v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
5070 v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
5071 uDamageAmount = v18;
5072 if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
5073 uDamageAmount >>= 1;
5074 v59 = 1;
5075 goto LABEL_67;
5076 }
5077 if ( v15 == 39 )
5078 {
5079 a4 = 5 * v4->field_4C;
5080 a2 = pPlayer->GetSpellSchool(0x27u);
5081 v21 = v4->field_4C;
5082 v50 = pMonster->sCurrentHP;
5083 pMonsterName = (char *)v4->field_50;
5084 v22 = _43AFE3_calc_spell_damage(39, v21, (signed int)pMonsterName, v50);
5085 v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
5086 v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
5087 uDamageAmount = v22;
5088 if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
5089 uDamageAmount >>= 1;
5090 v59 = 0;
5091 LABEL_67:
5092 if ( !stru_50C198.PlayerHitOrMiss(pPlayer, pMonster, v61, a4) )
5093 {
5094 LABEL_68:
5095 LOWORD(uPlayerID) = pPlayer->PlaySound(52, 0);
5096 return uPlayerID;
5097 }
5098 goto LABEL_69;
5099 }
5100 if ( v15 == 34 )
5101 {
5102 uDamageAmount = 0;
5103 a2 = 4;
5104 v58 = 1;
5105 goto LABEL_67;
5106 }
5107 v50 = v4->field_48;
5108 a2 = pPlayer->GetSpellSchool(v50);
5109 v25 = v4->field_4C;
5110 v26 = v4->field_48;
5111 v50 = pMonster->sCurrentHP;
5112 pMonsterName = (char *)v4->field_50;
5113 v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50);
5114 v59 = 0;
5115 v57 = (PlayerEquipment *)1;
5116 LABEL_65:
5117 uDamageAmount = v27;
5118 goto LABEL_66;
5119 }
5120 v50 = pMonster->word_000086_some_monster_id;
5121 a2 = 4;
5122 v17 = pPlayer->CalculateRangedDamageTo(v50);
5123 v19 = v4->stru_24.uItemID == 0;
5124 uDamageAmount = v17;
5125 if ( !v19 && v4->stru_24.uAdditionalValue == 3 )
5126 {
5127 a2 = 0;
5128 v57 = (PlayerEquipment *)1;
5129 }
5130 if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0
5131 && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
5132 uDamageAmount >>= 1;
5133 v59 = 1;
5134 LABEL_66:
5135 if ( !v57 )
5136 goto LABEL_67;
5137 LABEL_69:
5138 if ( pPlayer->pConditions[1] )
5139 uDamageAmount >>= 1;
5140 if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
5141 uDamageAmount = 0;
5142 v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount);
5143 if ( !v4 && pPlayer->IsUnarmed() && (signed __int64)pPlayer->pPlayerBuffs[6].uExpireTime > 0 )
5144 {
5145 v50 = pPlayer->pPlayerBuffs[6].uPower;
5146 v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50);
5147 v61 += v29;
5148 }
5149 uDamageAmount = v61;
5150 if ( v59 )
5151 {
5152 if ( v4 )
5153 {
5154 a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62);
5155 if ( v62 && pMonster->sCurrentHP > 0 )
5156 {
5157 pPlayer->sHealth += v61 / 5;
5158 if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
5159 pPlayer->sHealth = pPlayer->GetMaxHealth();
5160 v62 = 0;
5161 }
5162 v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
5163 uDamageAmount = v61 + v30;
5164 }
5165 else
5166 {
5167 v59 = 0;
5168 v57 = &pPlayer->pEquipment;
5169 do
5170 {
5171 if ( pPlayer->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
5172 {
5173 auto _s = (ItemGen *)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * v57->uOffHand + 5];
5174 a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
5175 if ( v62 && pMonster->sCurrentHP > 0 )
5176 {
5177 pPlayer->sHealth += v61 / 5;
5178 if ( pPlayer->sHealth > pPlayer->GetMaxHealth() )
5179 pPlayer->sHealth = pPlayer->GetMaxHealth();
5180 v62 = 0;
5181 }
5182 v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4);
5183 uDamageAmount += v31;
5184 }
5185 ++v59;
5186 v57 = (PlayerEquipment *)((char *)v57 + 4);
5187 }
5188 while ( v59 <= 1 );
5189 }
5190 }
5191 v32 = uDamageAmount;
5192 pMonster->sCurrentHP -= uDamageAmount;
5193 if ( !v32 && !v58 )
5194 goto LABEL_68;
5195 if ( pMonster->sCurrentHP > 0 )
5196 {
5197 Actor::_4030AD(uActorID_Monster_, v54, 0);
5198 Actor::_43AC45(uActorID_Monster_, 1);
5199 if ( bShowDamage )
5200 {
5201 v50 = uDamageAmount;
5202 pMonsterName = (char *)pMonster;
5203 pPlayerName = pPlayer->pName;
5204 if ( v4 )
5205 v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points"
5206 else
5207 v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage"
5208 sprintfex(pTmpBuf, v47, pPlayerName, pMonsterName, v50);
5209 ShowStatusBarString(pTmpBuf, 2u);
5210 }
5211 v41 = 0;
5212 }
5213 else
5214 {
5215 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 )
5216 {
5217 v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius;
5218 v55 = v33;
5219 if ( pRenderer->pRenderD3D )
5220 {
5221 if ( pGame->uFlags2 & 0x20 )
5222 {
5223 v50 = 0;
5224 pMonsterName = 0;
5225 v34 = pMonster->vPosition.z;
5226 *(float *)&pPlayerName = (double)v55;
5227 v51 = (unsigned __int64 *)v34;
5228 *(float *)&v47 = 0.0;
5229 v35 = pMonster->vPosition.y;
5230 *((float *)&v46 + 1) = 0.0;
5231 *(float *)&v46 = 1.0;
5232 v36 = (double)(signed int)v51;
5233 v51 = (unsigned __int64 *)v35;
5234 v37 = v36;
5235 v51 = (unsigned __int64 *)pMonster->vPosition.x;
5236 v38 = (double)v35;
5237 v39 = (double)(signed int)v51;
5238 pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0);
5239 }
5240 }
5241 }
5242 Actor::Die(uActorID_Monster_);
5243 Actor::_438CF3(uActorID_Monster_);
5244 Actor::_43AC45(uActorID_Monster_, 1);
5245 if ( pMonster->pMonsterInfo.uExp )
5246 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
5247 v40 = 51;
5248 if ( rand() % 100 < 20 )
5249 v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
5250 pPlayer->PlaySound(v40, 0);
5251 v41 = 0;
5252 if ( bShowDamage )
5253 {
5254 v50 = (int)pMonster;
5255 pMonsterName = (char *)uDamageAmount;
5256 pPlayerName = pPlayer->pName; // "%s inflicts %lu points killing %s"
5257 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[175], pPlayer->pName, uDamageAmount, pMonster);
5258 ShowStatusBarString(pTmpBuf, 2u);
5259 }
5260 }
5261 if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41
5262 && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41
5263 || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41)
5264 && uDamageAmount != v41 )
5265 pPlayer->ReceiveDamage(uDamageAmount, a2);
5266 v50 = 24;
5267 v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP;
5268 if ( (pPlayer->_48EA46_calc_special_bonus_by_items(24) || v58 != v41)
5269 && stru_50C198.GetMagicalResistance(pMonster, 3u) )
5270 {
5271 LODWORD(v42) = 20;
5272 v59 = 10;
5273 if ( pParty->bTurnBasedModeOn == v41 )
5274 v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666);
5275 pMonster->pMonsterInfo.uRecoveryTime += v42;
5276 if ( bShowDamage != v41 )
5277 {
5278 v50 = (int)pMonster;
5279 pMonsterName = pPlayer->pName; // "%s stuns %s"
5280 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[635], pPlayer->pName, pMonster);
5281 ShowStatusBarString(pTmpBuf, 2u);
5282 }
5283 }
5284 if ( v53 != v41 )
5285 {
5286 if ( pMonster->CanAct() )
5287 {
5288 if ( stru_50C198.GetMagicalResistance(pMonster, 3u) )
5289 {
5290 LOBYTE(v43) = pPlayer->GetActualSkillLevel(PLAYER_SKILL_MACE);
5291 v44 = v43;
5292 v45 = SkillToMastery(v43);
5293 v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F));
5294 v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v51 * 0.033333335);
5295 pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0);
5296 if ( bShowDamage )
5297 {
5298 v50 = (int)pMonster;
5299 pMonsterName = pPlayer->pName; // "%s paralyzes %s"
5300 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[636], pPlayer->pName, pMonster);
5301 ShowStatusBarString(pTmpBuf, 2u);
5302 }
5303 }
5304 }
5305 }
5306 if ( v59 > 10 )
5307 v59 = 10;
5308 if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
5309 {
5310 pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16;
5311 pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16;
5312 pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16;
5313 pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x);
5314 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
5315 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
5316 }
5317 return Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
5318 }
5319 // 4D864C: using guessed type char byte_4D864C;
5320
5321
5322 //----- (00439FCB) --------------------------------------------------------
5323 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4)
5324 {
5325 signed int v4; // esi@1
5326 unsigned int v5; // ecx@1
5327 Player *v6; // ebx@3
5328 Actor *v7; // esi@3
5329 unsigned int v8; // eax@4
5330 char *v9; // eax@5
5331 signed int v10; // eax@6
5332 int v11; // edx@8
5333 int v12; // edx@9
5334 int v13; // edx@10
5335 int v14; // edx@16
5336 int v15; // edx@17
5337 int v16; // edx@18
5338 enum SoundID v17; // eax@24
5339 int v18; // eax@26
5340 unsigned __int8 v19; // zf@26
5341 unsigned __int8 v20; // sf@26
5342 unsigned __int16 v21; // ax@29
5343 signed int v22; // edi@36
5344 int v23; // eax@38
5345 signed int v24; // eax@44
5346 unsigned __int16 v25; // cx@47
5347 signed int v26; // eax@49
5348 int v27; // eax@54
5349 float v28; // ST18_4@58
5350 double v29; // st7@58
5351 float v30; // ST08_4@58
5352 double v31; // st7@58
5353 float v32; // ST04_4@58
5354 float v33; // ST00_4@58
5355 int v34; // edi@61
5356 int v35; // eax@70
5357 double v36; // st7@70
5358 LayingItem *v37; // ebx@77
5359 int v38; // edi@77
5360 int v39; // esi@77
5361 int v40; // eax@77
5362 int v41; // eax@77
5363 int v42; // eax@78
5364 char *v43; // eax@81
5365 Actor *v44; // esi@82
5366 char *v45; // edi@84
5367 unsigned __int16 v46; // ax@84
5368 int v47; // ebx@105
5369 int v48; // eax@107
5370 unsigned __int16 v49; // ax@116
5371 int v50; // ebx@123
5372 unsigned __int16 v51; // ax@124
5373 char v52; // bl@124
5374 int v53; // eax@128
5375 signed int v54; // eax@134
5376 unsigned __int16 v55; // cx@137
5377 signed int v56; // eax@139
5378 int v57; // eax@144
5379 float v58; // ST18_4@148
5380 double v59; // st7@148
5381 float v60; // ST08_4@148
5382 double v61; // st7@148
5383 float v62; // ST04_4@148
5384 float v63; // ST00_4@148
5385 int v64; // ebx@151
5386 int v65; // eax@161
5387 double v66; // st7@161
5388 signed int v67; // ecx@164
5389 signed int v68; // eax@170
5390 int v69; // ecx@170
5391 int v70; // eax@171
5392 enum SoundID v71; // [sp+20h] [bp-34h]@12
5393 int v72; // [sp+30h] [bp-24h]@164
5394 double v73; // [sp+40h] [bp-14h]@72
5395 signed int v74; // [sp+44h] [bp-10h]@1
5396 unsigned int v75; // [sp+48h] [bp-Ch]@3
5397 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
5398 int v77; // [sp+50h] [bp-4h]@26
5399 signed int a4a; // [sp+60h] [bp+Ch]@162
5400 Player *a4b; // [sp+60h] [bp+Ch]@168
5401
5402 v4 = (signed int)uObjID >> 3;
5403 v5 = (uObjID & 7) - 2;
5404 v74 = a2;
5405 uActorID = v4;
5406 if ( v5 )
5407 {
5408 if ( v5 != 1
5409 || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4],
5410 v75 = v6->sHealth,
5411 !stru_50C198.ActorHitOrMiss(v7, v6)) )
5412 return;
5413 v8 = v6->pEquipment.uBody;
5414 if ( !v8
5415 || (v9 = (char *)v6 + 36 * v8, v9[516] & 2)
5416 || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10)
5417 || v10 > 11 )
5418 {
5419 v14 = rand() % 4;
5420 if ( !v14 )
5421 {
5422 v71 = (SoundID)108;
5423 goto LABEL_24;
5424 }
5425 v15 = v14 - 1;
5426 if ( !v15 )
5427 {
5428 v71 = (SoundID)109;
5429 goto LABEL_24;
5430 }
5431 v16 = v15 - 1;
5432 if ( !v16 )
5433 {
5434 v71 = (SoundID)110;
5435 goto LABEL_24;
5436 }
5437 if ( v16 == 1 )
5438 {
5439 v71 = (SoundID)44;
5440 goto LABEL_24;
5441 }
5442 }
5443 else
5444 {
5445 v11 = rand() % 4;
5446 if ( !v11 )
5447 {
5448 v71 = (SoundID)105;
5449 goto LABEL_24;
5450 }
5451 v12 = v11 - 1;
5452 if ( !v12 )
5453 {
5454 v71 = (SoundID)106;
5455 goto LABEL_24;
5456 }
5457 v13 = v12 - 1;
5458 if ( !v13 )
5459 {
5460 v71 = (SoundID)107;
5461 goto LABEL_24;
5462 }
5463 if ( v13 == 1 )
5464 {
5465 v71 = (SoundID)45;
5466 LABEL_24:
5467 v17 = v71;
5468 goto LABEL_26;
5469 }
5470 }
5471 v17 = (SoundID)a4;
5472 LABEL_26:
5473 pAudioPlayer->PlaySound(v17, (8 * a4 + 80) | 4, 0, -1, 0, 0, 0, 0);
5474 v18 = Actor::_43B3E0_CalcDamage(v7, v74);
5475 v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0;
5476 v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0;
5477 v77 = v18;
5478 if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) )
5479 {
5480 v21 = v7->pActorBuffs[3].uPower;
5481 if ( v21 )
5482 v77 /= (signed int)v21;
5483 }
5484 if ( v74 )
5485 {
5486 if ( v74 == 1 )
5487 {
5488 v22 = v7->pMonsterInfo.uAttack2Type;
5489 }
5490 else
5491 {
5492 if ( v74 == 2 )
5493 {
5494 v23 = v7->pMonsterInfo.uSpell1ID;
5495 }
5496 else
5497 {
5498 if ( v74 != 3 )
5499 {
5500 if ( v74 == 4 )
5501 v22 = v7->pMonsterInfo.field_3C_some_special_attack;
5502 else
5503 v22 = 4;
5504 goto LABEL_43;
5505 }
5506 v23 = v7->pMonsterInfo.uSpell2ID;
5507 }
5508 v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool);
5509 }
5510 }
5511 else
5512 {
5513 v22 = v7->pMonsterInfo.uAttack1Type;
5514 }
5515 LABEL_43:
5516 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
5517 {
5518 v24 = v6->ReceiveDamage(v77, v22);
5519 if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0
5520 && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) )
5521 {
5522 v25 = v7->uAIState;
5523 if ( v25 != 5 )
5524 {
5525 if ( v25 != 4 )
5526 {
5527 v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24);
5528 v7->sCurrentHP -= v26;
5529 if ( v26 )
5530 {
5531 if ( v7->sCurrentHP >= 1 )
5532 {
5533 Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
5534 Actor::_43AC45(uActorID, 1);
5535 }
5536 else
5537 {
5538 if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 )
5539 {
5540 v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius;
5541 v74 = v27;
5542 if ( pRenderer->pRenderD3D )
5543 {
5544 if ( pGame->uFlags2 & 0x20 )
5545 {
5546 v28 = (double)v74;
5547 v74 = v7->vPosition.z;
5548 v29 = (double)v74;
5549 v74 = v7->vPosition.y;
5550 v30 = v29;
5551 v31 = (double)v74;
5552 v74 = v7->vPosition.x;
5553 v32 = v31;
5554 v33 = (double)v74;
5555 pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0);
5556 }
5557 }
5558 }
5559 Actor::Die(uActorID);
5560 Actor::_438CF3(uActorID);
5561 Actor::_43AC45(uActorID, 1);
5562 if ( v7->pMonsterInfo.uExp )
5563 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
5564 v34 = 51;
5565 if ( rand() % 100 < 20 )
5566 v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
5567 v6->PlaySound(v34, 0);
5568 }
5569 }
5570 }
5571 }
5572 }
5573 if ( !(dword_6BE368_debug_settings_2 & 0x10)
5574 && v7->pMonsterInfo.uSpecialAttack
5575 && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType )
5576 v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7);
5577 }
5578 if ( !pParty->bTurnBasedModeOn )
5579 {
5580 v35 = v6->GetActualEndurance();
5581 v36 = (double)(20 - v6->_48EA1B_get_static_effect(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
5582 v6->SetRecoveryTime((signed __int64)v36);
5583 }
5584 if ( v77 )
5585 {
5586 v73 = (double)(signed int)v75;
5587 if ( (double)v6->GetMaxHealth() * 0.25 < v73 )
5588 {
5589 if ( v6->sHealth > 0 )
5590 {
5591 if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
5592 v6->PlaySound(48, 0);
5593 }
5594 }
5595 }
5596 viewparams->bRedrawGameUI = 1;
5597 return;
5598 }
5599 v37 = &pLayingItems[uActorID];
5600 v38 = v37->field_58 & 7;
5601 v39 = v37->field_58 >> 3;
5602 v40 = v37->field_58 & 7;
5603 uActorID = v37->field_58 >> 3;
5604 v41 = v40 - 2;
5605 if ( !v41 )
5606 goto LABEL_80;
5607 v42 = v41 - 1;
5608 if ( !v42 )
5609 {
5610 v44 = &pActors[v39];
5611 if ( a4 == -1 )
5612 a4 = stru_50C198.which_player_would_attack(v44);
5613 v45 = (char *)&pParty->pPlayers[a4];
5614 v77 = Actor::_43B3E0_CalcDamage(v44, v74);
5615 v46 = v37->uItemType;
5616 if ( v37->uItemType == 545 )
5617 {
5618 LOBYTE(v51) = ((Player *)v45)->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5619 v52 = v51;
5620 if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) )
5621 {
5622 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[637], v45 + 168);
5623 ShowStatusBarString(pTmpBuf, 2u);
5624 ((Player *)v45)->PlaySound(6, 0);
5625 return;
5626 }
5627 }
5628 else
5629 {
5630 if ( v46 != 555
5631 && v46 != 510
5632 && v46 != 500
5633 && v46 != 515
5634 && v46 != 505
5635 && v46 != 530
5636 && v46 != 525
5637 && v46 != 520
5638 && v46 != 535
5639 && v46 != 540 )
5640 goto LABEL_115;
5641 }
5642 if ( !stru_50C198.ActorHitOrMiss(v44, (Player *)v45) )
5643 return;
5644 if ( *((_QWORD *)v45 + 782) > 0i64 )
5645 v77 >>= 1;
5646 if ( ((Player *)v45)->HasEnchantedItemEquipped(36) )
5647 v77 >>= 1;
5648 if ( ((Player *)v45)->HasEnchantedItemEquipped(69) )
5649 v77 >>= 1;
5650 if ( ((Player *)v45)->HasItemEquipped(EQUIP_ARMOUR)
5651 && *(int *)&v45[36 * *((int *)v45 + 1621) + 496] == 504 )
5652 v77 >>= 1;
5653 v75 = 0;
5654 v47 = (int)(v45 + 6472);
5655 do
5656 {
5657 if ( ((Player *)v45)->HasItemEquipped((ITEM_EQUIP_TYPE)v75) )
5658 {
5659 v48 = *(int *)&v45[36 * *(int *)v47 + 496];
5660 if ( v48 == 520 )
5661 v77 >>= 1;
5662 if ( v48 == 531 )
5663 v77 >>= 1;
5664 if ( ((Player *)v45)->GetEquippedItemEquipType(v75) == 4 && SkillToMastery(*((short *)v45 + 140)) == 4 )
5665 v77 >>= 1;
5666 }
5667 ++v75;
5668 v47 += 4;
5669 }
5670 while ( (signed int)v75 <= 1 );
5671 LABEL_115:
5672 if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 )
5673 {
5674 v49 = v44->pActorBuffs[3].uPower;
5675 if ( v49 )
5676 v77 /= (signed int)v49;
5677 }
5678 if ( !v74 )
5679 {
5680 v50 = v44->pMonsterInfo.uAttack1Type;
5681 goto LABEL_133;
5682 }
5683 if ( v74 == 1 )
5684 {
5685 v50 = v44->pMonsterInfo.uAttack2Type;
5686 goto LABEL_133;
5687 }
5688 if ( v74 == 2 )
5689 {
5690 v53 = v44->pMonsterInfo.uSpell1ID;
5691 }
5692 else
5693 {
5694 if ( v74 != 3 )
5695 {
5696 if ( v74 == 4 )
5697 v50 = v44->pMonsterInfo.field_3C_some_special_attack;
5698 else
5699 v50 = 4;
5700 LABEL_133:
5701 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
5702 {
5703 v54 = ((Player *)v45)->ReceiveDamage(v77, v50);
5704 if ( *((int *)v45 + 1553) >= 0 )
5705 {
5706 if ( *((int *)v45 + 1553) > 0 || *((int *)v45 + 1552) )
5707 {
5708 v55 = v44->uAIState;
5709 if ( v55 != 5 )
5710 {
5711 if ( v55 != 4 )
5712 {
5713 v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54);
5714 v44->sCurrentHP -= v56;
5715 if ( v56 )
5716 {
5717 if ( v44->sCurrentHP >= 1 )
5718 {
5719 Actor::_4030AD(uActorID, 8 * a4 | 4, 0);
5720 Actor::_43AC45(uActorID, 1);
5721 }
5722 else
5723 {
5724 if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 )
5725 {
5726 v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius;
5727 v75 = v57;
5728 if ( pRenderer->pRenderD3D )
5729 {
5730 if ( pGame->uFlags2 & 0x20 )
5731 {
5732 v58 = (double)(signed int)v75;
5733 v75 = v44->vPosition.z;
5734 v59 = (double)(signed int)v75;
5735 v75 = v44->vPosition.y;
5736 v60 = v59;
5737 v61 = (double)(signed int)v75;
5738 v75 = v44->vPosition.x;
5739 v62 = v61;
5740 v63 = (double)(signed int)v75;
5741 pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0);
5742 }
5743 }
5744 }
5745 Actor::Die(uActorID);
5746 Actor::_438CF3(uActorID);
5747 Actor::_43AC45(uActorID, 1);
5748 if ( v44->pMonsterInfo.uExp )
5749 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
5750 v64 = 51;
5751 if ( rand() % 100 < 20 )
5752 v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
5753 ((Player *)v45)->PlaySound(v64, 0);
5754 }
5755 }
5756 }
5757 }
5758 }
5759 }
5760 }
5761 if ( !v74
5762 && !(dword_6BE368_debug_settings_2 & 0x10)
5763 && v44->pMonsterInfo.uSpecialAttack
5764 && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType )
5765 ((Player *)v45)->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44);
5766 if ( !pParty->bTurnBasedModeOn )
5767 {
5768 v65 = ((Player *)v45)->GetActualEndurance();
5769 v66 = (double)(20 - ((Player *)v45)->_48EA1B_get_static_effect(v65))
5770 * flt_6BE3A4_debug_recmod1
5771 * 2.133333333333333;
5772 ((Player *)v45)->SetRecoveryTime((signed __int64)v66);
5773 }
5774 return;
5775 }
5776 v53 = v44->pMonsterInfo.uSpell2ID;
5777 }
5778 v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool);
5779 goto LABEL_133;
5780 }
5781 if ( v42 != 1 )
5782 return;
5783 LABEL_80:
5784 if ( a4 != -1 )
5785 {
5786 v43 = (char *)&pParty->pPlayers[a4];
5787 LABEL_168:
5788 a4b = (Player *)v43;
5789 if ( v38 != 4 || v37->field_48 != 100 )
5790 {
5791 v70 = ((Player *)v43)->GetMaxHealth();
5792 v68 = _43AFE3_calc_spell_damage(v37->field_48, v37->field_4C, v37->field_50, v70);
5793 v69 = LOBYTE(pSpellStats->pInfos[v37->field_48].uSchool);
5794 }
5795 else
5796 {
5797 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
5798 v69 = 0;
5799 }
5800 a4b->ReceiveDamage(v68, v69);
5801 if ( v38 == 4 && !qword_A750D8 )
5802 {
5803 qword_A750D8 = 256i64;
5804 word_A750E0 = 44;
5805 word_A750E2 = uActorID + 1;
5806 }
5807 return;
5808 }
5809 v74 = 0;
5810 a4a = 1;
5811 do
5812 {
5813 if ( pPlayers[a4a]->CanAct() )
5814 {
5815 v67 = v74++;
5816 *(&v72 + v67) = a4a;
5817 }
5818 ++a4a;
5819 }
5820 while ( a4a <= 4 );
5821 if ( v74 )
5822 {
5823 v43 = &stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
5824 goto LABEL_168;
5825 }
5826 }
5827
5828
5829 //----- (0043A97E) --------------------------------------------------------
5830 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
5831 {
5832 unsigned int v2; // esi@1
5833 unsigned int v3; // ebx@1
5834 int v4; // edi@1
5835 int v5; // edx@1
5836 unsigned int v6; // [sp+10h] [bp-4h]@1
5837
5838 v6 = uLayingItemID;
5839 v2 = uLayingItemID;
5840 v3 = a2 >> 3;
5841 v4 = pLayingItems[uLayingItemID].field_58 & 7;
5842 v5 = (a2 & 7) - 3;
5843 if ( v5 )
5844 {
5845 if ( v5 == 1 )
5846 {
5847 layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
5848 layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
5849 layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
5850 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
5851 DamagePlayerFromMonster(8 * v6 | 2, pLayingItems[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu);
5852 }
5853 }
5854 else
5855 {
5856 layingitem_vel_50FDFC.x = pLayingItems[v2].vVelocity.x;
5857 layingitem_vel_50FDFC.y = pLayingItems[v2].vVelocity.y;
5858 layingitem_vel_50FDFC.z = pLayingItems[v2].vVelocity.z;
5859 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
5860 switch ( v4 )
5861 {
5862 case OBJECT_Actor:
5863 sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pLayingItems[v2].field_61);
5864 break;
5865 case OBJECT_Player:
5866 DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
5867 break;
5868 case OBJECT_Item:
5869 sub_43B057(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC);
5870 break;
5871 }
5872 }
5873 }
5874
5875 //----- (0043AA99) --------------------------------------------------------
5876 void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz)
5877 {
5878 int v7; // ebx@1
5879 int v8; // ST14_4@1
5880 int v9; // edi@1
5881 int anglea; // [sp+20h] [bp+8h]@1
5882
5883 v7 = sRotX;
5884 v8 = sDepth;
5885 v9 = sRotY;
5886 anglea = (unsigned __int64)(stru_5C6E00->SinCos(sRotX) * (signed __int64)sDepth) >> 16;
5887 *outx = v.x + ((unsigned __int64)(stru_5C6E00->SinCos(v9) * (signed __int64)anglea) >> 16);
5888 *outy = v.y
5889 + ((unsigned __int64)(stru_5C6E00->SinCos(v9 - stru_5C6E00->uIntegerHalfPi)
5890 * (signed __int64)anglea) >> 16);
5891 *outz = v.z
5892 + ((unsigned __int64)(stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v8) >> 16);
5893 }
5894
5895 //----- (0043AB61) --------------------------------------------------------
5896 void Vec3_int_::Normalize(int *x, int *y, int *z)
5897 {
5898 int *v3; // edi@1
5899 int *v4; // esi@1
5900 signed int v5; // eax@1
5901
5902 v3 = x;
5903 v4 = y;
5904 v5 = sub_452A9E(*y * *y + *z * *z + *x * *x);
5905 *v3 *= 65536 / (v5 | 1);
5906 *v4 *= 65536 / (v5 | 1);
5907 *z *= 65536 / (v5 | 1);
5908 }
5909
5910
5911
5912
5913 //----- (0043AE12) --------------------------------------------------------
5914 double __fastcall sub_43AE12(signed int a1)
5915 {
5916 signed int v1; // ST00_4@1
5917 signed int v2; // ecx@1
5918 double v3; // st7@1
5919 double result; // st7@6
5920
5921 v1 = a1;
5922 v2 = 0;
5923 v3 = (double)v1;
5924 do
5925 {
5926 if ( v3 < flt_4E4A80[v2 + 5] )
5927 break;
5928 ++v2;
5929 }
5930 while ( v2 < 5 );
5931 if ( v2 <= 0 || v2 >= 5 )
5932 {
5933 if ( v2 )
5934 result = flt_4E4A80[4];
5935 else
5936 result = flt_4E4A80[0];
5937 }
5938 else
5939 {
5940 result = (flt_4E4A80[v2] - *(float *)&aAuthenticamd[4 * v2 + 12])
5941 * (v3 - flt_4E4A80[v2 + 4])
5942 / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4])
5943 + flt_4E4A80[v2];
5944 }
5945 return result;
5946 }
5947
5948 //----- (0043AFE3) --------------------------------------------------------
5949 int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4)
5950 {
5951 int result; // eax@1
5952 unsigned int v5; // [sp-4h] [bp-8h]@9
5953
5954 result = 0;
5955 if ( a1 == 7 )
5956 {
5957 if ( a3 <= 0 )
5958 return result;
5959 if ( a3 <= 2 )
5960 {
5961 v5 = 6;
5962 }
5963 else
5964 {
5965 if ( a3 == 3 )
5966 {
5967 v5 = 8;
5968 }
5969 else
5970 {
5971 if ( a3 != 4 )
5972 return result;
5973 v5 = 10;
5974 }
5975 }
5976 result = GetDiceResult(a2, v5);
5977 }
5978 else
5979 {
5980 if ( a1 == 44 )
5981 result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100;
5982 else
5983 result = *((char *)&pSpellDatas[0].field_10 + 20 * a1)
5984 + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1));
5985 }
5986 return result;
5987 }
5988
5989 //----- (0043B057) --------------------------------------------------------
5990 void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity)
5991 {
5992 Actor *pActor; // esi@1
5993 LayingItem *v4; // eax@3
5994 int v5; // ecx@3
5995 int v6; // eax@4
5996 int v7; // edi@4
5997 unsigned int uActorIDa; // [sp+8h] [bp-8h]@1
5998 unsigned int a2; // [sp+Ch] [bp-4h]@1
5999 int a2a; // [sp+Ch] [bp-4h]@8
6000
6001 uActorIDa = uActorID;
6002 pActor = &pActors[uActorID];
6003 a2 = uObjID;
6004 if ( !pActors[uActorID].IsAlive() )
6005 {
6006 if ( (a2 & 7) == 2 )
6007 {
6008 v4 = &pLayingItems[(signed int)a2 >> 3];
6009 v5 = v4->field_48;
6010 if ( v5 )
6011 {
6012 v6 = _43AFE3_calc_spell_damage(v5, v4->field_4C, v4->field_50, pActor->sCurrentHP);
6013 v7 = stru_50C198.CalcMagicalDamageToActor(pActor, 0, v6);
6014 pActor->sCurrentHP -= v7;
6015 if ( v7 )
6016 {
6017 if ( pActor->sCurrentHP > 0 )
6018 Actor::_4030AD(uActorIDa, a2, 0);
6019 else
6020 Actor::Die(uActorIDa);
6021 a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP;
6022 if ( 20 * v7 / (signed int)pActor->pMonsterInfo.uHP > 10 )
6023 a2a = 10;
6024 if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
6025 {
6026 pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16;
6027 pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16;
6028 pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16;
6029 pActor->vVelocity.x = 50 * LOWORD(pVelocity->x);
6030 pActor->vVelocity.y = 50 * LOWORD(pVelocity->y);
6031 pActor->vVelocity.z = 50 * LOWORD(pVelocity->z);
6032 }
6033 Actor::AddBloodsplatOnDamageOverlay(uActorIDa, 1, v7);
6034 }
6035 else
6036 {
6037 Actor::_4030AD(uActorIDa, a2, 0);
6038 }
6039 }
6040 }
6041 }
6042 }
6043
6044 //----- (0043B1B0) --------------------------------------------------------
6045 __int16 __fastcall sub_43B1B0(signed int a1, unsigned int a2, Vec3_int_ *pVelocity, signed int a4)
6046 {
6047 int v4; // ebx@1
6048 LayingItem *v5; // eax@2
6049 bool v6; // eax@3
6050 Actor *v7; // esi@4
6051 Actor *v8; // edi@4
6052 char v9; // zf@5
6053 __int64 v10; // qax@8
6054 signed __int16 v11; // cx@9
6055 signed int v12; // ecx@20
6056 int v13; // ecx@22
6057 int v14; // edi@30
6058 unsigned int uActorID; // [sp+Ch] [bp-8h]@1
6059 signed int v17; // [sp+10h] [bp-4h]@1
6060 int v18; // [sp+20h] [bp+Ch]@34
6061
6062 v4 = 0;
6063 uActorID = a2;
6064 v17 = a1;
6065 if ( (a1 & 7) == 2 )
6066 {
6067 v5 = &pLayingItems[a1 >> 3];
6068 v4 = v5->field_60_distance_related_prolly_lod;
6069 v17 = v5->field_58;
6070 }
6071 LOWORD(v6) = v17 & 7;
6072 if ( v6 == 3 )
6073 {
6074 v7 = &pActors[a2];
6075 v8 = &pActors[v17 >> 3];
6076 v6 = pActors[a2].IsAlive();
6077 if ( !v6 )
6078 {
6079 v9 = v7->uAIState == 7;
6080 v7->uLastCharacterIDToHit = v17;
6081 if ( v9 )
6082 BYTE2(v7->uAttributes) |= 2u;
6083 v6 = stru_50C198._4273BB(v8, v7, v4, 0);
6084 if ( v6 )
6085 {
6086 v10 = (unsigned int)Actor::_43B3E0_CalcDamage(v8, a4);
6087 if ( (signed __int64)v8->pActorBuffs[3].uExpireTime > 0 )
6088 {
6089 v11 = v8->pActorBuffs[3].uPower;
6090 if ( v11 )
6091 v10 = (signed int)v10 / (unsigned __int16)v11;
6092 }
6093 if ( SHIDWORD(v7->pActorBuffs[5].uExpireTime) >= SHIDWORD(v10)
6094 && (SHIDWORD(v7->pActorBuffs[5].uExpireTime) > SHIDWORD(v10)
6095 || LODWORD(v7->pActorBuffs[5].uExpireTime) > HIDWORD(v10)) )
6096 LODWORD(v10) = 0;
6097 if ( a4 != HIDWORD(v10) )
6098 {
6099 if ( a4 - HIDWORD(v10) == 1 )
6100 {
6101 v12 = v8->pMonsterInfo.uAttack2Type;
6102 if ( SHIDWORD(v7->pActorBuffs[15].uExpireTime) >= SHIDWORD(v10)
6103 && (SHIDWORD(v7->pActorBuffs[15].uExpireTime) > SHIDWORD(v10)
6104 || LODWORD(v7->pActorBuffs[15].uExpireTime) > HIDWORD(v10)) )
6105 LODWORD(v10) = (signed int)v10 >> 1;
6106 goto LABEL_30;
6107 }
6108 if ( a4 - HIDWORD(v10) == 2 )
6109 {
6110 v13 = v7->pMonsterInfo.uSpell1ID;
6111 }
6112 else
6113 {
6114 if ( a4 - HIDWORD(v10) != 3 )
6115 {
6116 if ( a4 - HIDWORD(v10) == 4 )
6117 v12 = v8->pMonsterInfo.field_3C_some_special_attack;
6118 else
6119 v12 = 4;
6120 LABEL_30:
6121 v14 = stru_50C198.CalcMagicalDamageToActor(v7, v12, v10);
6122 v7->sCurrentHP -= v14;
6123 if ( v14 )
6124 {
6125 if ( v7->sCurrentHP > 0 )
6126 Actor::_4030AD(uActorID, v17, 0);
6127 else
6128 Actor::Die(uActorID);
6129 Actor::_43AC45(uActorID, 0);
6130 v18 = 20 * v14 / (signed int)v7->pMonsterInfo.uHP;
6131 if ( 20 * v14 / (signed int)v7->pMonsterInfo.uHP > 10 )
6132 v18 = 10;
6133 if ( !MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
6134 {
6135 pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16;
6136 pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16;
6137 pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16;
6138 v7->vVelocity.x = 50 * LOWORD(pVelocity->x);
6139 v7->vVelocity.y = 50 * LOWORD(pVelocity->y);
6140 v7->vVelocity.z = 50 * LOWORD(pVelocity->z);
6141 }
6142 LOWORD(v6) = Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v14);
6143 }
6144 else
6145 {
6146 LOWORD(v6) = Actor::_4030AD(uActorID, v17, 0);
6147 }
6148 return v6;
6149 }
6150 v13 = v7->pMonsterInfo.uSpell2ID;
6151 }
6152 v12 = LOBYTE(pSpellStats->pInfos[v13].uSchool);
6153 goto LABEL_30;
6154 }
6155 v12 = v8->pMonsterInfo.uAttack1Type;
6156 goto LABEL_30;
6157 }
6158 }
6159 }
6160 return v6;
6161 }
6162
6163
6164 //----- (0043BCA7) --------------------------------------------------------
6165 int __cdecl CharacterUI_LoadPaperdollTextures()
6166 {
6167 int v0; // edi@7
6168 enum CHARACTER_RACE v1; // ebx@7
6169 signed int v2; // eax@7
6170 int v3; // ebx@10
6171 Player *v4; // edi@12
6172 unsigned __int8 v5; // cl@12
6173 int v6; // edi@16
6174 unsigned int v7; // eax@16
6175 Player *v8; // ebx@16
6176 char *v9; // ebx@16
6177 char v10; // al@16
6178 signed int v11; // edi@21
6179 Player *v12; // ebx@23
6180 Player *v13; // edi@29
6181 int v14; // ebp@29
6182 stru331 *v15; // edi@65
6183 signed int v16; // ebx@66
6184 unsigned int v17; // eax@67
6185 unsigned int *v18; // ecx@67
6186 unsigned int *v19; // ebx@68
6187 int v20; // edi@73
6188 int v21; // ebp@73
6189 unsigned int v22; // eax@76
6190 int v23; // ecx@76
6191 unsigned int v24; // eax@78
6192 int v25; // ecx@78
6193 int v26; // ebx@79
6194 unsigned int v27; // eax@80
6195 int v28; // ecx@80
6196 int result; // eax@83
6197 int v30; // [sp+10h] [bp-28h]@5
6198 signed int v31; // [sp+10h] [bp-28h]@68
6199 signed int v32; // [sp+10h] [bp-28h]@75
6200 signed int v33; // [sp+10h] [bp-28h]@77
6201 int v34; // [sp+10h] [bp-28h]@79
6202 char *v35; // [sp+14h] [bp-24h]@65
6203 int v36; // [sp+14h] [bp-24h]@75
6204 int v37; // [sp+14h] [bp-24h]@77
6205 signed int v38; // [sp+14h] [bp-24h]@79
6206 unsigned int *v39; // [sp+18h] [bp-20h]@66
6207 int *v40; // [sp+18h] [bp-20h]@73
6208 unsigned int *v41; // [sp+1Ch] [bp-1Ch]@73
6209 int v42; // [sp+20h] [bp-18h]@6
6210 int v43; // [sp+20h] [bp-18h]@73
6211 char pContainer[128]; // [sp+24h] [bp-14h]@12
6212
6213 uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
6214 if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
6215 uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
6216 uTextureID_507B04 = uTextureID_right_panel;
6217 v30 = 0;
6218 uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
6219 uTextureID_5118C8 = uTextureID_506438;
6220 do
6221 {
6222 v42 = v30 + 1;
6223 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v30 + 1) )
6224 {
6225 v0 = v30;
6226 v1 = pPlayers[v30 + 1]->GetRace();
6227 v2 = pPlayers[v30 + 1]->GetSexByVoice();
6228 if ( v1 && v1 != 1 && v1 != 2 )
6229 v3 = (v2 != 0) + 3;
6230 else
6231 v3 = (v2 != 0) + 1;
6232 wsprintfA(pContainer, "pc23v%dBod", v3);
6233 papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6234 wsprintfA(pContainer, "pc23v%dlad", v3);
6235 papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6236 wsprintfA(pContainer, "pc23v%dlau", v3);
6237 papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6238 wsprintfA(pContainer, "pc23v%drh", v3);
6239 papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6240 wsprintfA(pContainer, "pc23v%dlh", v3);
6241 papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6242 wsprintfA(pContainer, "pc23v%dlhu", v3);
6243 papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6244 v4 = pPlayers[v0 + 1];
6245 v5 = v4->uFace;
6246 if ( v5 == 12 || v5 == 13 )
6247 papredoll_dbrds[(char)v5] = 0;
6248 papredoll_flying_feet[v4->uFace] = 0;
6249 IsPlayerWearingWatersuit[v30 + 1] = 1;
6250 }
6251 else
6252 {
6253 v6 = v30;
6254 papredoll_dbods[v30] = pIcons_LOD->LoadTexture(
6255 dbod_texnames_by_face[pPlayers[v30 + 1]->uFace],
6256 TEXTURE_16BIT_PALETTE);
6257 papredoll_dlads[v30] = pIcons_LOD->LoadTexture(
6258 dlad_texnames_by_face[pPlayers[v30 + 1]->uFace],
6259 TEXTURE_16BIT_PALETTE);
6260 papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(
6261 dlau_texnames_by_face[pPlayers[v30 + 1]->uFace],
6262 TEXTURE_16BIT_PALETTE);
6263 papredoll_drhs[v30] = pIcons_LOD->LoadTexture(
6264 drh_texnames_by_face[pPlayers[v30 + 1]->uFace],
6265 TEXTURE_16BIT_PALETTE);
6266 papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(
6267 dlh_texnames_by_face[pPlayers[v30 + 1]->uFace],
6268 TEXTURE_16BIT_PALETTE);
6269 v7 = pIcons_LOD->LoadTexture(
6270 dlhu_texnames_by_face[pPlayers[v30 + 1]->uFace],
6271 TEXTURE_16BIT_PALETTE);
6272 v8 = pPlayers[v30 + 1];
6273 papredoll_dlhus[v30] = v7;
6274 v9 = (char *)&v8->uFace;
6275 v10 = *v9;
6276 if ( *v9 == 12 || v10 == 13 )
6277 {
6278 wsprintfA(pContainer, "pc%02dbrd", v10 + 1);
6279 v9 = (char *)&pPlayers[v6 + 1]->uFace;
6280 papredoll_dbrds[*v9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6281 }
6282 wsprintfA(pContainer, "item281pc%02d", *v9 + 1);
6283 papredoll_flying_feet[pPlayers[v6 + 1]->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6284 IsPlayerWearingWatersuit[v30 + 1] = 0;
6285 }
6286 ++v30;
6287 }
6288 while ( v42 < 4 );
6289 uTextureID_ar_up_up = pIcons_LOD->LoadTexture("ar_up_up", TEXTURE_16BIT_PALETTE);
6290 uTextureID_ar_up_dn = pIcons_LOD->LoadTexture("ar_up_dn", TEXTURE_16BIT_PALETTE);
6291 uTextureID_ar_dn_up = pIcons_LOD->LoadTexture("ar_dn_up", TEXTURE_16BIT_PALETTE);
6292 uTextureID_ar_dn_dn = pIcons_LOD->LoadTexture("ar_dn_dn", TEXTURE_16BIT_PALETTE);
6293 papredoll_dbrds[9] = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
6294 papredoll_dbrds[7] = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
6295 papredoll_dbrds[5] = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
6296 papredoll_dbrds[3] = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
6297 papredoll_dbrds[1] = pIcons_LOD->LoadTexture("ib-cd5-d", TEXTURE_16BIT_PALETTE);
6298 v11 = 0;
6299 do
6300 {
6301 byte_5111C0[v11] = 0;
6302 if ( pParty->pPickedItem.uItemID != v11 + 66 )
6303 {
6304 v12 = pParty->pPlayers;
6305 while ( !sub_43EE15_player_has_item(v11 + 66, v12, 0) )
6306 {
6307 ++v12;
6308 if ( (signed int)v12 >= (signed int)pParty->pHirelings )
6309 goto LABEL_28;
6310 }
6311 }
6312 byte_5111C0[v11] = 1;
6313 LABEL_28:
6314 ++v11;
6315 }
6316 while ( v11 < 54 );
6317 *(int *)byte_5111F6 = 0;
6318 *(int *)&byte_5111F6[4] = 0;
6319 *(int *)&byte_5111F6[8] = 0;
6320 *(int *)&byte_5111F6[12] = 0;
6321 *(int *)&byte_5111F6[16] = 0;
6322 v13 = pParty->pPlayers;
6323 v14 = 1;
6324 do
6325 {
6326 if ( sub_43EE15_player_has_item(0x204u, v13, 1) )
6327 byte_5111F6[2] = 1;
6328 if ( sub_43EE15_player_has_item(0x1F8u, v13, 1) )
6329 byte_5111F6[0] = 1;
6330 if ( sub_43EE15_player_has_item(0x1F9u, v13, 1) )
6331 byte_5111F6[1] = 1;
6332 if ( sub_43EE15_player_has_item(0x215u, v13, 1) )
6333 byte_5111F6[16] = 1;
6334 if ( sub_43EE15_player_has_item(0x200u, v13, 1) )
6335 byte_5111F6[3] = 1;
6336 if ( sub_43EE15_player_has_item(0x209u, v13, 1) )
6337 byte_5111F6[4] = 1;
6338 if ( sub_43EE15_player_has_item(0x20Au, v13, 1) )
6339 byte_5111F6[5] = 1;
6340 if ( sub_43EE15_player_has_item(0x20Bu, v13, 1) )
6341 byte_5111F6[6] = 1;
6342 if ( sub_43EE15_player_has_item(0x214u, v13, 1) )
6343 byte_5111F6[7] = 1;
6344 if ( sub_43EE15_player_has_item(0x220u, v13, 1) )
6345 byte_5111F6[8] = 1;
6346 if ( sub_43EE15_player_has_item(0x20Cu, v13, 1) )
6347 byte_5111F6[9] = 1;
6348 if ( sub_43EE15_player_has_item(0x217u, v13, 1) )
6349 byte_5111F6[10] = 1;
6350 if ( sub_43EE15_player_has_item(0x20Du, v13, 1) )
6351 byte_5111F6[11] = 1;
6352 if ( sub_43EE15_player_has_item(0x212u, v13, 1) )
6353 byte_5111F6[12] = 1;
6354 if ( sub_43EE15_player_has_item(0x223u, v13, 1) )
6355 byte_5111F6[13] = 1;
6356 if ( sub_43EE15_player_has_item(0x224u, v13, 1) )
6357 byte_5111F6[14] = 1;
6358 if ( sub_43EE15_player_has_item(0x226u, v13, 1) )
6359 byte_5111F6[15] = 1;
6360 ++v13;
6361 }
6362 while ( (signed int)v13 < (signed int)pParty->pHirelings );
6363 v15 = &stru_511698.field_2C;
6364 v35 = (char *)&stru_511718.field_18;
6365 do
6366 {
6367 v16 = 0;
6368 v39 = (unsigned int *)(v35 - 24);
6369 do
6370 {
6371 _43C91D_FormItemTextureFilename(pContainer, v16 + 100, v14, 0);
6372 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6373 ++v16;
6374 v18 = v39;
6375 ++v39;
6376 *v18 = v17;
6377 }
6378 while ( v16 < 5 );
6379 _43C91D_FormItemTextureFilename(pContainer, 535, v14, 0);
6380 v31 = 0;
6381 v19 = (unsigned int *)((char *)v15 - 44);
6382 *(int *)v35 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6383 do
6384 {
6385 _43C91D_FormItemTextureFilename(pContainer, v31++ + 89, v14, 0);
6386 *v19 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6387 ++v19;
6388 }
6389 while ( v31 < 11 );
6390 _43C91D_FormItemTextureFilename(pContainer, 521, v14, 0);
6391 v15->field_0 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6392 _43C91D_FormItemTextureFilename(pContainer, 522, v14, 0);
6393 v15->field_4 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6394 _43C91D_FormItemTextureFilename(pContainer, 523, v14, 0);
6395 v15->field_8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6396 _43C91D_FormItemTextureFilename(pContainer, 532, v14, 0);
6397 v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6398 _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0);
6399 v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6400 if ( sub_43ED6F_get_some_race_sex_relation(1u) )
6401 papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE);
6402 v35 += 28;
6403 ++v14;
6404 ++v15;
6405 }
6406 while ( v14 - 1 < 2 );
6407 v43 = 0;
6408 v20 = 1;
6409 v40 = &dword_511638[0][5];
6410 v21 = (int)paperdoll_array_511290[0][13];
6411 v41 = (unsigned int *)&stru_511718.texid1;
6412 do
6413 {
6414 if ( sub_43EDB9_get_some_race_sex_relation_2(v20 - 1) )
6415 {
6416 _43C91D_FormItemTextureFilename(pContainer, 524, v20, 0);
6417 v32 = 66;
6418 *v41 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6419 v36 = v21 - 152;
6420 do
6421 {
6422 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 0);
6423 *(int *)(v36 - 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6424 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 1);
6425 *(int *)v36 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6426 _43C91D_FormItemTextureFilename(pContainer, v32, v20, 2);
6427 v22 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6428 v23 = v36;
6429 v36 += 12;
6430 ++v32;
6431 *(int *)(v23 + 4) = v22;
6432 }
6433 while ( v32 - 66 < 13 );
6434 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 0);
6435 *(int *)v21 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6436 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 1);
6437 *(int *)(v21 + 4) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6438 _43C91D_FormItemTextureFilename(pContainer, 516, v20, 2);
6439 *(int *)(v21 + 8) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6440 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 0);
6441 *(int *)(v21 + 12) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6442 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 1);
6443 *(int *)(v21 + 16) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6444 _43C91D_FormItemTextureFilename(pContainer, 505, v20, 2);
6445 *(int *)(v21 + 20) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6446 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 0);
6447 *(int *)(v21 + 24) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6448 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 1);
6449 *(int *)(v21 + 28) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6450 _43C91D_FormItemTextureFilename(pContainer, 504, v20, 2);
6451 *(int *)(v21 + 32) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6452 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 0);
6453 *(int *)(v21 + 36) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6454 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 1);
6455 *(int *)(v21 + 40) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6456 _43C91D_FormItemTextureFilename(pContainer, 533, v20, 2);
6457 *(int *)(v21 + 44) = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6458 v33 = 0;
6459 v37 = (int)(v40 - 5);
6460 do
6461 {
6462 _43C91D_FormItemTextureFilename(pContainer, v33 + 115, v20, 0);
6463 v24 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6464 ++v33;
6465 v25 = v37;
6466 v37 += 4;
6467 *(int *)v25 = v24;
6468 }
6469 while ( v33 < 5 );
6470 _43C91D_FormItemTextureFilename(pContainer, 512, v20, 0);
6471 v26 = v43;
6472 v38 = 105;
6473 v34 = v43;
6474 *v40 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6475 do
6476 {
6477 _43C91D_FormItemTextureFilename(pContainer, v38, v20, 0);
6478 *(int *)((char *)paperdoll_array_511828 + v34) = pIcons_LOD->LoadTexture(
6479 pContainer,
6480 TEXTURE_16BIT_PALETTE);
6481 _43C91D_FormItemTextureFilename(pContainer, v38, v20, 1);
6482 v27 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
6483 v28 = v34;
6484 v34 += 4;
6485 ++v38;
6486 *(int *)((char *)dword_511788 + v28) = v27;
6487 }
6488 while ( v38 - 105 < 5 );
6489 _43C91D_FormItemTextureFilename(pContainer, 525, v20, 0);
6490 *(int *)((char *)&paperdoll_array_511828[0][5] + v43) = pIcons_LOD->LoadTexture(
6491 pContainer,
6492 TEXTURE_16BIT_PALETTE);
6493 _43C91D_FormItemTextureFilename(pContainer, 530, v20, 0);
6494 *(int *)((char *)&paperdoll_array_511828[0][6] + v43) = pIcons_LOD->LoadTexture(
6495 pContainer,
6496 TEXTURE_16BIT_PALETTE);
6497 _43C91D_FormItemTextureFilename(pContainer, 547, v20, 0);
6498 *(int *)((char *)&paperdoll_array_511828[0][7] + v43) = pIcons_LOD->LoadTexture(
6499 pContainer,
6500 TEXTURE_16BIT_PALETTE);
6501 _43C91D_FormItemTextureFilename(pContainer, 548, v20, 0);
6502 *(int *)((char *)&paperdoll_array_511828[0][8] + v43) = pIcons_LOD->LoadTexture(
6503 pContainer,
6504 TEXTURE_16BIT_PALETTE);
6505 _43C91D_FormItemTextureFilename(pContainer, 550, v20, 0);
6506 *(int *)((char *)&paperdoll_array_511828[0][9] + v43) = pIcons_LOD->LoadTexture(
6507 pContainer,
6508 TEXTURE_16BIT_PALETTE);
6509 _43C91D_FormItemTextureFilename(pContainer, 525, v20, 1);
6510 *(int *)((char *)&dword_51179C + v43) = pIcons_LOD->LoadTexture(
6511 pContainer,
6512 TEXTURE_16BIT_PALETTE);
6513 _43C91D_FormItemTextureFilename(pContainer, 530, v20, 1);
6514 *(int *)((char *)&dword_5117A0 + v43) = pIcons_LOD->LoadTexture(
6515 pContainer,
6516 TEXTURE_16BIT_PALETTE);
6517 _43C91D_FormItemTextureFilename(pContainer, 547, v20, 1);
6518 *(int *)((char *)&dword_5117A4 + v43) = pIcons_LOD->LoadTexture(
6519 pContainer,
6520 TEXTURE_16BIT_PALETTE);
6521 _43C91D_FormItemTextureFilename(pContainer, 548, v20, 1);
6522 *(int *)((char *)&dword_5117A8 + v43) = pIcons_LOD->LoadTexture(
6523 pContainer,
6524 TEXTURE_16BIT_PALETTE);
6525 _43C91D_FormItemTextureFilename(pContainer, 550, v20, 1);
6526 *(int *)((char *)&dword_5117AC + v43) = pIcons_LOD->LoadTexture(
6527 pContainer,
6528 TEXTURE_16BIT_PALETTE);
6529 }
6530 else
6531 {
6532 v26 = v43;
6533 }
6534 v41 += 7;
6535 v40 += 6;
6536 v21 += 204;
6537 ++v20;
6538 result = v20 - 1;
6539 v43 = v26 + 40;
6540 }
6541 while ( v20 - 1 < 4 );
6542 return result;
6543 }
6544
6545
6546
6547 //----- (0043C91D) --------------------------------------------------------
6548 int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4)
6549 {
6550 int result; // eax@2
6551 char v5; // zf@3
6552 const char *v6; // [sp-Ch] [bp-18h]@88
6553 signed int v7; // [sp-8h] [bp-14h]@61
6554 int v8; // [sp-4h] [bp-10h]@61
6555 signed int v9; // [sp-4h] [bp-10h]@69
6556
6557 if ( a2 <= 500 )
6558 {
6559 v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
6560 LABEL_21:
6561 if ( v5 )
6562 return result;
6563 result = 516;
6564 if ( a2 < 66 || a2 > 78 )
6565 {
6566 if ( a2 == 516 )
6567 goto LABEL_79;
6568 if ( a2 != 504 && a2 != 505 && a2 != 533 )
6569 {
6570 if ( (a2 < 100 || a2 > 104) && a2 != 524 && a2 != 535 )
6571 {
6572 if ( a2 >= 115 && a2 <= 119 || a2 == 512 )
6573 {
6574 if ( a2 == 512 )
6575 a2 = 312;
6576 goto LABEL_87;
6577 }
6578 if ( (a2 < 89 || a2 > 99) && a2 != 521 && a2 != 522 && a2 != 523 && a2 != 532 && a2 != 544 )
6579 {
6580 result = 525;
6581 if ( (a2 < 105 || a2 > 109) && a2 != 525 && a2 != 530 && a2 != 547 && a2 != 548 && a2 != 550 )
6582 return result;
6583 switch ( a2 )
6584 {
6585 case 525:
6586 a2 = 325;
6587 break;
6588 case 530:
6589 a2 = 330;
6590 break;
6591 case 547:
6592 a2 = 347;
6593 break;
6594 case 548:
6595 a2 = 348;
6596 break;
6597 case 550:
6598 a2 = 350;
6599 break;
6600 }
6601 v8 = a3;
6602 v7 = a2;
6603 if ( !a4 )
6604 goto LABEL_88;
6605 LABEL_91:
6606 v6 = "item%3.3dv%da1";
6607 return sprintfex(a1, v6, v7, v8);
6608 }
6609 if ( a2 == 521 )
6610 {
6611 a2 = 239;
6612 goto LABEL_87;
6613 }
6614 if ( a2 == 522 )
6615 {
6616 a2 = 240;
6617 goto LABEL_87;
6618 }
6619 if ( a2 == 523 )
6620 {
6621 a2 = 241;
6622 goto LABEL_87;
6623 }
6624 if ( a2 != 532 )
6625 {
6626 if ( a2 == 544 )
6627 a2 = 344;
6628 goto LABEL_87;
6629 }
6630 v9 = 93;
6631 goto LABEL_70;
6632 }
6633 if ( a2 == 524 )
6634 {
6635 a2 = 324;
6636 goto LABEL_87;
6637 }
6638 if ( a2 == 535 )
6639 {
6640 v9 = 104;
6641 LABEL_70:
6642 a2 = v9;
6643 }
6644 LABEL_87:
6645 v8 = a3;
6646 v7 = a2;
6647 LABEL_88:
6648 v6 = "item%3.3dv%d";
6649 return sprintfex(a1, v6, v7, v8);
6650 }
6651 }
6652 if ( a2 != 516 )
6653 {
6654 switch ( a2 )
6655 {
6656 case 504:
6657 a2 = 235;
6658 break;
6659 case 505:
6660 a2 = 236;
6661 break;
6662 case 533:
6663 a2 = 73;
6664 break;
6665 }
6666 LABEL_86:
6667 if ( a4 )
6668 {
6669 if ( a4 != 1 )
6670 {
6671 if ( a4 != 2 )
6672 return result;
6673 v8 = a3;
6674 v7 = a2;
6675 v6 = "item%3.3dv%da2";
6676 return sprintfex(a1, v6, v7, v8);
6677 }
6678 v8 = a3;
6679 v7 = a2;
6680 goto LABEL_91;
6681 }
6682 goto LABEL_87;
6683 }
6684 LABEL_79:
6685 a2 = 234;
6686 goto LABEL_86;
6687 }
6688 result = a2 - 504;
6689 switch ( a2 )
6690 {
6691 case 516:
6692 v5 = byte_5111F6[2] == 0;
6693 goto LABEL_21;
6694 case 505:
6695 v5 = byte_5111F6[1] == 0;
6696 goto LABEL_21;
6697 case 504:
6698 v5 = byte_5111F6[0] == 0;
6699 goto LABEL_21;
6700 case 533:
6701 v5 = byte_5111F6[16] == 0;
6702 goto LABEL_21;
6703 case 512:
6704 v5 = byte_5111F6[3] == 0;
6705 goto LABEL_21;
6706 case 521:
6707 v5 = byte_5111F6[4] == 0;
6708 goto LABEL_21;
6709 case 522:
6710 v5 = byte_5111F6[5] == 0;
6711 goto LABEL_21;
6712 case 523:
6713 v5 = byte_5111F6[6] == 0;
6714 goto LABEL_21;
6715 case 532:
6716 v5 = byte_5111F6[7] == 0;
6717 goto LABEL_21;
6718 case 544:
6719 v5 = byte_5111F6[8] == 0;
6720 goto LABEL_21;
6721 case 524:
6722 v5 = byte_5111F6[9] == 0;
6723 goto LABEL_21;
6724 case 535:
6725 v5 = byte_5111F6[10] == 0;
6726 goto LABEL_21;
6727 case 525:
6728 v5 = byte_5111F6[11] == 0;
6729 goto LABEL_21;
6730 case 530:
6731 v5 = byte_5111F6[12] == 0;
6732 goto LABEL_21;
6733 case 547:
6734 v5 = byte_5111F6[13] == 0;
6735 goto LABEL_21;
6736 case 548:
6737 v5 = byte_5111F6[14] == 0;
6738 goto LABEL_21;
6739 case 550:
6740 v5 = byte_5111F6[15] == 0;
6741 goto LABEL_21;
6742 default:
6743 return result;
6744 }
6745 return result;
6746 }
6747
6748 //----- (0043CC7C) --------------------------------------------------------
6749 void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID)
6750 {
6751 Player **ppPlayer; // esi@1
6752 Player *pPlayer; // ebx@1
6753 enum CHARACTER_RACE v3; // edi@1
6754 signed int v4; // eax@1
6755 int v5; // edi@4
6756 unsigned int v6; // ecx@9
6757 int v7; // ecx@10
6758 unsigned int v8; // eax@14
6759 int v9; // eax@15
6760 int v10; // edx@15
6761 int v11; // ecx@15
6762 int v12; // eax@15
6763 unsigned int v13; // edi@15
6764 unsigned int v14; // ebx@18
6765 int v15; // ecx@18
6766 Texture *v16; // ebp@27
6767 double v17; // st7@29
6768 int v18; // edi@30
6769 char *v19; // eax@30
6770 Texture *v20; // edi@31
6771 unsigned int v21; // eax@37
6772 int v22; // edi@38
6773 int v23; // eax@38
6774 int v24; // ebx@38
6775 int v25; // eax@38
6776 LODFile_IconsBitmaps *v26; // ecx@42
6777 Texture *v27; // edi@51
6778 double v28; // st7@51
6779 char v29; // zf@54
6780 char *v30; // eax@54
6781 unsigned int v31; // eax@59
6782 int v32; // edx@60
6783 int v33; // eax@65
6784 int v34; // eax@74
6785 int v35; // ebx@74
6786 unsigned int v36; // ecx@74
6787 int v37; // eax@74
6788 LODFile_IconsBitmaps *v38; // ecx@78
6789 Texture *v39; // edi@85
6790 double v40; // st7@87
6791 int v41; // edi@88
6792 Texture *v42; // edi@89
6793 unsigned int v43; // eax@93
6794 int v44; // edx@94
6795 int v45; // eax@98
6796 int v46; // eax@106
6797 int v47; // ecx@106
6798 int v48; // ebx@106
6799 int v49; // eax@106
6800 LODFile_IconsBitmaps *v50; // ecx@110
6801 Texture *v51; // edi@117
6802 double v52; // st7@119
6803 int v53; // edi@120
6804 Texture *v54; // edi@121
6805 char *v55; // eax@122
6806 unsigned int v56; // eax@127
6807 int v57; // edi@128
6808 int v58; // ecx@128
6809 int v59; // ebx@129
6810 int v60; // ecx@132
6811 int v61; // eax@134
6812 int v62; // ecx@136
6813 Texture *v63; // edi@145
6814 double v64; // st7@147
6815 int v65; // edi@148
6816 char *v66; // eax@148
6817 Texture *v67; // edi@149
6818 Player *v68; // ebx@155
6819 unsigned int v69; // edx@155
6820 int v70; // edx@156
6821 unsigned int v71; // eax@160
6822 int v72; // edi@161
6823 int v73; // edx@163
6824 int v74; // ecx@168
6825 unsigned int v75; // ebx@170
6826 int v76; // ecx@172
6827 Texture *v77; // edi@181
6828 double v78; // st7@183
6829 int v79; // edi@184
6830 char *v80; // eax@184
6831 Texture *v81; // edi@185
6832 unsigned int v82; // eax@192
6833 int v83; // eax@193
6834 int v84; // eax@197
6835 int v85; // eax@197
6836 int v86; // ecx@197
6837 int v87; // eax@197
6838 int v88; // eax@198
6839 int v89; // eax@199
6840 int v90; // edi@201
6841 int v91; // edi@213
6842 int v92; // ebx@213
6843 int v93; // edi@214
6844 int v94; // ebx@214
6845 int v95; // eax@214
6846 char *v96; // edi@226
6847 double v97; // st7@228
6848 int v98; // edi@229
6849 char *v99; // eax@229
6850 Render *v100; // ecx@229
6851 Texture *v101; // edi@230
6852 int v102; // edi@236
6853 int v103; // eax@237
6854 int v104; // ecx@237
6855 int v105; // edx@237
6856 int v106; // edx@238
6857 int v107; // edx@239
6858 int v108; // edx@240
6859 int v109; // edi@250
6860 char *v110; // edx@250
6861 unsigned int v111; // eax@259
6862 int v112; // eax@260
6863 int v113; // eax@260
6864 int v114; // eax@265
6865 int v115; // eax@274
6866 int v116; // ebx@274
6867 unsigned int v117; // edi@274
6868 double v118; // st7@286
6869 int v119; // edi@287
6870 char *v120; // eax@287
6871 Texture *v121; // edi@288
6872 unsigned int v122; // edi@295
6873 int v123; // ebx@297
6874 int v124; // edi@298
6875 int v125; // ecx@303
6876 int v126; // eax@312
6877 unsigned int v127; // ebx@314
6878 int v128; // ecx@316
6879 Texture *v129; // edi@325
6880 double v130; // st7@327
6881 int v131; // edi@328
6882 char *v132; // eax@328
6883 Texture *v133; // edi@329
6884 unsigned int v134; // eax@335
6885 int v135; // eax@336
6886 int v136; // edx@336
6887 int v137; // eax@336
6888 unsigned int v138; // ebx@339
6889 int v139; // ecx@339
6890 Texture *v140; // edi@348
6891 double v141; // st7@350
6892 int v142; // edi@351
6893 char *v143; // eax@351
6894 Texture *v144; // edi@352
6895 unsigned int v145; // eax@358
6896 int v146; // eax@359
6897 int v147; // ecx@359
6898 int v148; // eax@359
6899 int v149; // edx@359
6900 int v150; // ebx@362
6901 int v151; // ecx@363
6902 int v152; // ecx@364
6903 unsigned int v153; // eax@370
6904 unsigned int v154; // edi@370
6905 int v155; // eax@370
6906 LODFile_IconsBitmaps *v156; // ecx@374
6907 Texture *v157; // ebp@381
6908 double v158; // st7@383
6909 Texture *v159; // edi@385
6910 char *v160; // eax@386
6911 unsigned int v161; // eax@393
6912 int v162; // eax@394
6913 unsigned int v163; // [sp-Ch] [bp-58h]@230
6914 unsigned int v164; // [sp-Ch] [bp-58h]@233
6915 signed int v165; // [sp-Ch] [bp-58h]@235
6916 char *v166; // [sp-8h] [bp-54h]@16
6917 const char *v167; // [sp-8h] [bp-54h]@23
6918 const char *v168; // [sp-8h] [bp-54h]@43
6919 const char *v169; // [sp-8h] [bp-54h]@79
6920 const char *v170; // [sp-8h] [bp-54h]@111
6921 const char *v171; // [sp-8h] [bp-54h]@141
6922 const char *v172; // [sp-8h] [bp-54h]@177
6923 const char *v173; // [sp-8h] [bp-54h]@222
6924 int v174; // [sp-8h] [bp-54h]@228
6925 unsigned int v175; // [sp-8h] [bp-54h]@230
6926 unsigned int v176; // [sp-8h] [bp-54h]@233
6927 signed int v177; // [sp-8h] [bp-54h]@235
6928 const char *v178; // [sp-8h] [bp-54h]@242
6929 const char *v179; // [sp-8h] [bp-54h]@280
6930 const char *v180; // [sp-8h] [bp-54h]@321
6931 char *v181; // [sp-8h] [bp-54h]@337
6932 const char *v182; // [sp-8h] [bp-54h]@344
6933 const char *v183; // [sp-8h] [bp-54h]@375
6934 signed int v184; // [sp-4h] [bp-50h]@66
6935 signed int v185; // [sp-4h] [bp-50h]@99
6936 signed int v186; // [sp-4h] [bp-50h]@202
6937 int v187; // [sp-4h] [bp-50h]@228
6938 Texture *v188; // [sp-4h] [bp-50h]@230
6939 Texture *v189; // [sp-4h] [bp-50h]@233
6940 Texture *v190; // [sp-4h] [bp-50h]@235
6941 signed int v191; // [sp-4h] [bp-50h]@266
6942 signed int v192; // [sp-4h] [bp-50h]@304
6943 unsigned int a3; // [sp+10h] [bp-3Ch]@7
6944 int a3a; // [sp+10h] [bp-3Ch]@15
6945 int a3b; // [sp+10h] [bp-3Ch]@38
6946 unsigned int a3c; // [sp+10h] [bp-3Ch]@74
6947 unsigned int a3d; // [sp+10h] [bp-3Ch]@106
6948 int a3e; // [sp+10h] [bp-3Ch]@129
6949 int a3f; // [sp+10h] [bp-3Ch]@168
6950 unsigned int a3g; // [sp+10h] [bp-3Ch]@216
6951 unsigned int a3h; // [sp+10h] [bp-3Ch]@274
6952 int a3i; // [sp+10h] [bp-3Ch]@312
6953 int a3j; // [sp+10h] [bp-3Ch]@336
6954 int a3k; // [sp+10h] [bp-3Ch]@362
6955 signed int a2; // [sp+14h] [bp-38h]@7
6956 unsigned int a2a; // [sp+14h] [bp-38h]@15
6957 Texture *a2b; // [sp+14h] [bp-38h]@49
6958 int a2c; // [sp+14h] [bp-38h]@74
6959 int a2d; // [sp+14h] [bp-38h]@106
6960 int a2e; // [sp+14h] [bp-38h]@129
6961 int a2f; // [sp+14h] [bp-38h]@168
6962 int a2g; // [sp+14h] [bp-38h]@214
6963 int a2h; // [sp+14h] [bp-38h]@274
6964 Texture *a2i; // [sp+14h] [bp-38h]@284
6965 int a2j; // [sp+14h] [bp-38h]@312
6966 int a2k; // [sp+14h] [bp-38h]@336
6967 Player *v217; // [sp+18h] [bp-34h]@1
6968 int v218; // [sp+1Ch] [bp-30h]@15
6969 int v219; // [sp+1Ch] [bp-30h]@60
6970 int v220; // [sp+1Ch] [bp-30h]@94
6971 int v221; // [sp+1Ch] [bp-30h]@128
6972 int v222; // [sp+1Ch] [bp-30h]@161
6973 int v223; // [sp+1Ch] [bp-30h]@213
6974 char v224; // [sp+1Ch] [bp-30h]@237
6975 int v225; // [sp+1Ch] [bp-30h]@260
6976 int v226; // [sp+1Ch] [bp-30h]@298
6977 int v227; // [sp+1Ch] [bp-30h]@336
6978 int v228; // [sp+1Ch] [bp-30h]@359
6979 int v229; // [sp+20h] [bp-2Ch]@15
6980 int v230; // [sp+20h] [bp-2Ch]@38
6981 int v231; // [sp+20h] [bp-2Ch]@60
6982 int v232; // [sp+20h] [bp-2Ch]@94
6983 int v233; // [sp+20h] [bp-2Ch]@128
6984 int v234; // [sp+20h] [bp-2Ch]@161
6985 int v235; // [sp+20h] [bp-2Ch]@197
6986 int v236; // [sp+20h] [bp-2Ch]@260
6987 int v237; // [sp+20h] [bp-2Ch]@298
6988 int v238; // [sp+20h] [bp-2Ch]@336
6989 int v239; // [sp+24h] [bp-28h]@6
6990 int v240; // [sp+28h] [bp-24h]@7
6991 unsigned int v241; // [sp+2Ch] [bp-20h]@38
6992 int v242; // [sp+2Ch] [bp-20h]@197
6993 unsigned int v243; // [sp+2Ch] [bp-20h]@370
6994 int v244; // [sp+34h] [bp-18h]@6
6995 signed int v245; // [sp+34h] [bp-18h]@361
6996 unsigned int uPlayerID_; // [sp+38h] [bp-14h]@1
6997 int uPlayerID_a; // [sp+38h] [bp-14h]@9
6998 signed int v248; // [sp+40h] [bp-Ch]@4
6999 int v249; // [sp+40h] [bp-Ch]@358
7000 signed int v250; // [sp+44h] [bp-8h]@1
7001
7002 ppPlayer = &pPlayers[uPlayerID];
7003 pPlayer = *ppPlayer;
7004 uPlayerID_ = uPlayerID;
7005 v217 = *ppPlayer;
7006 pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
7007 v3 = pPlayer->GetRace();
7008 v4 = pPlayer->GetSexByVoice();
7009 v250 = v4;
7010 if ( v3 && v3 != 1 && v3 != 2 )
7011 {
7012 v248 = 1;
7013 v5 = (v4 != 0) + 2;
7014 }
7015 else
7016 {
7017 v248 = 0;
7018 v5 = v4 != 0;
7019 }
7020 v239 = v5;
7021 v244 = (*ppPlayer)->uFace;
7022 pRenderer->ResetClip();
7023 pRenderer->DrawTextureIndexed(
7024 0x1D3u,
7025 0,
7026 (Texture *)(uTextureID_BACKDOLL != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BACKDOLL] : 0));
7027 if ( !IsPlayerWearingWatersuit[uPlayerID_] )
7028 {
7029 v21 = pPlayer->pEquipment.uBow;
7030 if ( !v21 )
7031 goto LABEL_59;
7032 v230 = pPlayer->pEquipment.uBow;
7033 v22 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v21 + 5];
7034 v23 = *(int *)v22;
7035 v24 = papredoll_4E4C28 + array_4E4C30[v239].equip_x - pItemsTable->pItems[v23].uEquipX;
7036 a3b = paperdoll_4E4C2C + array_4E4C30[v239].equip_y - pItemsTable->pItems[v23].uEquipY;
7037 v241 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v23].pIconName, TEXTURE_16BIT_PALETTE);
7038 v25 = *(int *)(v22 + 20);
7039 if ( !(*(int *)(v22 + 20) & 0xF0) )
7040 {
7041 if ( v25 & 2 )
7042 {
7043 v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
7044 pRenderer->_4A6776(v24, a3b, v27);
7045 }
7046 else
7047 {
7048 v29 = (v25 & 1) == 0;
7049 v30 = (char *)&pIcons_LOD->pTextures[v241];
7050 if ( v29 )
7051 {
7052 v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
7053 pRenderer->DrawTransparentGreenShade(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
7054 }
7055 else
7056 {
7057 v27 = (Texture *)(v241 != -1 ? (int)v30 : 0);
7058 pRenderer->DrawTextureTransparent(v24, a3b, (Texture *)(v241 != -1 ? (int)v30 : 0));
7059 }
7060 }
7061 LABEL_57:
7062 if ( !bRingsShownInCharScreen )
7063 pRenderer->_4A612A(v24, a3b, v27, v230);
7064 LABEL_59:
7065 v31 = v217->pEquipment.uCloak;
7066 if ( !v31 )
7067 goto LABEL_93;
7068 v231 = v217->pEquipment.uCloak;
7069 v32 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v31 + 5];
7070 v219 = v32;
7071 if ( *(int *)v32 != 525 )
7072 {
7073 switch ( *(int *)v32 )
7074 {
7075 case 0x212:
7076 v184 = 6;
7077 break;
7078 case 0x223:
7079 v184 = 7;
7080 break;
7081 case 0x224:
7082 v184 = 8;
7083 break;
7084 default:
7085 if ( *(int *)v32 != 550 )
7086 {
7087 v33 = *(int *)v32 - 105;
7088 LABEL_72:
7089 if ( v33 < 0 || v33 >= 10 )
7090 goto LABEL_93;
7091 LABEL_74:
7092 v34 = v33 + 10 * v239;
7093 v35 = paperdoll_array_511828[0][v34];
7094 a2c = papredoll_4E4C28 + paperdoll_array_4E5570[0][v34][0];// TODO indexing
7095 v36 = paperdoll_4E4C2C + paperdoll_array_4E5570[0][v34][1];
7096 v37 = *(int *)(v32 + 20);
7097 a3c = v36;
7098 if ( !(v37 & 0xF0) )
7099 {
7100 v41 = v35 + 1;
7101 if ( v37 & 2 )
7102 {
7103 v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
7104 pRenderer->_4A6776(a2c, v36, v42);
7105 }
7106 else
7107 {
7108 v42 = (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0);
7109 pRenderer->DrawTextureTransparent(a2c, v36, v42);
7110 }
7111 if ( !bRingsShownInCharScreen )
7112 pRenderer->_4A612A(a2c, a3c, v42, v231);
7113 LABEL_93:
7114 v240 = 4 * uPlayerID_ - 4;
7115 pRenderer->DrawTextureTransparent(
7116 papredoll_4E4C28,
7117 paperdoll_4E4C2C,
7118 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
7119 v43 = v217->pEquipment.uBody;
7120 if ( !v43 )
7121 goto LABEL_127;
7122 v232 = v217->pEquipment.uBody;
7123 v44 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v43 + 5];
7124 v220 = v44;
7125 if ( *(int *)v44 != 504 )
7126 {
7127 if ( *(int *)v44 == 505 )
7128 {
7129 v185 = 14;
7130 }
7131 else
7132 {
7133 if ( *(int *)v44 == 516 )
7134 {
7135 v185 = 13;
7136 }
7137 else
7138 {
7139 if ( *(int *)v44 != 533 )
7140 {
7141 v45 = *(int *)v44 - 66;
7142 LABEL_104:
7143 if ( v45 < 0 || v45 >= 17 )
7144 goto LABEL_127;
7145 LABEL_106:
7146 v46 = 17 * v239 + v45;
7147 a2d = papredoll_4E4C28 + paperdoll_array_4E4E30[0][v46][0];// TODO indexing
7148 v47 = paperdoll_4E4C2C + paperdoll_array_4E4E30[0][v46][1];
7149 v48 = paperdoll_array_511290[0][v46][0];
7150 v49 = *(int *)(v44 + 20);
7151 a3d = v47;
7152 if ( !(v49 & 0xF0) )
7153 {
7154 v53 = v48 + 1;
7155 if ( v49 & 2 )
7156 {
7157 v54 = (Texture *)(v53 != 0 ? (int)&pIcons_LOD->pTextures[v48] : 0);
7158 pRenderer->_4A6776(a2d, v47, v54);
7159 }
7160 else
7161 {
7162 v29 = (v49 & 1) == 0;
7163 v55 = (char *)&pIcons_LOD->pTextures[v48];
7164 if ( v29 )
7165 {
7166 v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
7167 pRenderer->DrawTransparentGreenShade(a2d, v47, v54);
7168 }
7169 else
7170 {
7171 v54 = (Texture *)(v53 != 0 ? (int)v55 : 0);
7172 pRenderer->DrawTextureTransparent(a2d, v47, v54);
7173 }
7174 }
7175 if ( !bRingsShownInCharScreen )
7176 pRenderer->_4A612A(a2d, a3d, v54, v232);
7177 LABEL_127:
7178 v56 = v217->pEquipment.field_20;
7179 if ( !v56 )
7180 goto LABEL_155;
7181 v233 = v217->pEquipment.field_20;
7182 v57 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v56 + 5];
7183 v221 = v57;
7184 v58 = *(int *)v57;
7185 if ( *(int *)v57 == 529 )
7186 {
7187 a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][1];
7188 a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][0];
7189 v59 = papredoll_flying_feet[v244];
7190 }
7191 else
7192 {
7193 if ( v58 == 512 )
7194 {
7195 a3e = paperdoll_4E4C2C + paredoll_array_4E54B8[v239][3];
7196 a2e = papredoll_4E4C28 + paredoll_array_4E54B8[v239][2];
7197 v59 = dword_511638[v239][5];
7198 }
7199 else
7200 {
7201 v60 = v58 - 115;
7202 if ( v60 < 0 || v60 >= 5 )
7203 {
7204 a2e = 0;
7205 a3e = 0;
7206 v59 = dword_511638[v239][0];
7207 }
7208 else
7209 {
7210 v61 = v60 + 7 * v239;
7211 a3e = paperdoll_4E4C2C + dword_4E5490[0][v61][1];
7212 a2e = papredoll_4E4C28 + dword_4E5490[0][v61][0];
7213 v59 = dword_511638[0][v60 + 6 * v239];
7214 }
7215 }
7216 }
7217 v62 = *(int *)(v57 + 20);
7218 if ( !(*(int *)(v57 + 20) & 0xF0) )
7219 {
7220 v65 = v59 + 1;
7221 v66 = (char *)&pIcons_LOD->pTextures[v59];
7222 if ( v62 & 2 )
7223 {
7224 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
7225 pRenderer->_4A6776(a2e, a3e, v67);
7226 }
7227 else
7228 {
7229 if ( v62 & 1 )
7230 {
7231 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
7232 pRenderer->DrawTextureTransparent(a2e, a3e, v67);
7233 }
7234 else
7235 {
7236 v67 = (Texture *)(v65 != 0 ? (int)v66 : 0);
7237 pRenderer->DrawTransparentGreenShade(a2e, a3e, v67);
7238 }
7239 }
7240 if ( !bRingsShownInCharScreen )
7241 pRenderer->_4A612A(a2e, a3e, v67, v233);
7242 LABEL_155:
7243 v68 = v217;
7244 v69 = v217->pEquipment.uMainHand;
7245 uPlayerID_a = 2 * v239;
7246 if ( !v69
7247 || (v70 = *(int *)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
7248 pItemsTable->pItems[v70].uEquipType != 1)
7249 && (pItemsTable->pItems[v70].uSkillType != 4 || v217->pEquipment.uOffHand) )
7250 pRenderer->DrawTextureTransparent(
7251 papredoll_4E4C28 + dword_4E5AE0[2 * v239],
7252 paperdoll_4E4C2C + dword_4E5AE0[2 * v239 + 1],
7253 (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
7254 v71 = v217->pEquipment.uBelt;
7255 if ( v71 )
7256 {
7257 v234 = v217->pEquipment.uBelt;
7258 v72 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v71 + 5];
7259 v222 = v72;
7260 if ( *(int *)v72 == 524 )
7261 {
7262 v73 = 5;
7263 }
7264 else
7265 {
7266 if ( *(int *)v72 == 535 )
7267 {
7268 v73 = 6;
7269 goto LABEL_168;
7270 }
7271 v73 = *(int *)v72 - 100;
7272 }
7273 if ( v73 >= 0 && v73 < 7 )
7274 {
7275 LABEL_168:
7276 v74 = 7 * v239 + v73;
7277 a2f = papredoll_4E4C28 + dword_4E57F0[0][v74][0];
7278 a3f = paperdoll_4E4C2C + dword_4E57F0[0][v74][1];
7279 if ( v248 != 1 || v73 == 5 )
7280 v75 = stru_511718.texids[v74];
7281 else
7282 v75 = stru_511718.texids[v73 + 7 * (v239 - 2)];
7283 v76 = *(int *)&v217->field_1F5[36 * v71 + 15];
7284 if ( !(*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) )
7285 {
7286 v79 = v75 + 1;
7287 v80 = (char *)&pIcons_LOD->pTextures[v75];
7288 if ( v76 & 2 )
7289 {
7290 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
7291 pRenderer->_4A6776(a2f, a3f, v81);
7292 }
7293 else
7294 {
7295 if ( v76 & 1 )
7296 {
7297 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
7298 pRenderer->DrawTextureTransparent(a2f, a3f, v81);
7299 }
7300 else
7301 {
7302 v81 = (Texture *)(v79 != 0 ? (int)v80 : 0);
7303 pRenderer->DrawTransparentGreenShade(a2f, a3f, v81);
7304 }
7305 }
7306 if ( !bRingsShownInCharScreen )
7307 pRenderer->_4A612A(a2f, a3f, v81, v234);
7308 goto LABEL_191;
7309 }
7310 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) != 16 )
7311 {
7312 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 32 )
7313 {
7314 v172 = "sp28a";
7315 goto LABEL_181;
7316 }
7317 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 64 )
7318 {
7319 v172 = "sp30a";
7320 goto LABEL_181;
7321 }
7322 if ( (*(int *)&v217->field_1F5[36 * v71 + 15] & 0xF0) == 128 )
7323 {
7324 v172 = "sp91a";
7325 LABEL_181:
7326 v77 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v172, TEXTURE_16BIT_PALETTE)];
7327 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7328 if ( dword_50C9A8 <= 0 )
7329 {
7330 dword_50C9A8 = 0;
7331 *(char *)(v222 + 20) &= 0xFu;
7332 ptr_50C9A4 = 0;
7333 }
7334 v78 = (double)GetTickCount() * 0.1;
7335 pRenderer->_4A63E6(
7336 a2f,
7337 a3f,
7338 (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0),
7339 v77,
7340 (signed __int64)v78,
7341 0,
7342 255);
7343 LABEL_191:
7344 v68 = v217;
7345 goto LABEL_192;
7346 }
7347 }
7348 v172 = "sptext01";
7349 goto LABEL_181;
7350 }
7351 }
7352 LABEL_192:
7353 v82 = v68->pEquipment.uMainHand;
7354 if ( v82 )
7355 {
7356 v83 = *(int *)&v68->pDarkSpellbook.bIsSpellAvailable[36 * v82 + 5];
7357 if ( pItemsTable->pItems[v83].uEquipType == 1
7358 || pItemsTable->pItems[v83].uSkillType == 4 && !v68->pEquipment.uOffHand )
7359 pRenderer->DrawTextureTransparent(
7360 papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
7361 paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
7362 (Texture *)(*(unsigned int *)((char *)papredoll_dlaus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlaus + v240)] : 0));
7363 }
7364 v84 = v68->pEquipment.uBody;
7365 v235 = v84;
7366 v85 = (int)((char *)v68 + 36 * v84);
7367 v242 = v85;
7368 v86 = *(int *)(v85 + 496);
7369 v87 = *(int *)(v85 + 496) - 504;
7370 if ( v87 )
7371 {
7372 v88 = v87 - 1;
7373 if ( v88 )
7374 {
7375 v89 = v88 - 11;
7376 if ( v89 )
7377 {
7378 if ( v89 != 17 )
7379 {
7380 v90 = v86 - 66;
7381 LABEL_207:
7382 if ( v90 < 0 || v90 > 17 )
7383 {
7384 LABEL_259:
7385 v111 = v68->pEquipment.uCloak;
7386 if ( !v111 )
7387 goto LABEL_293;
7388 v236 = v68->pEquipment.uCloak;
7389 v112 = (int)&v68->pDarkSpellbook.bIsSpellAvailable[36 * v111 + 5];
7390 v225 = v112;
7391 v113 = *(int *)v112;
7392 if ( v113 != 525 )
7393 {
7394 switch ( v113 )
7395 {
7396 case 530:
7397 v191 = 6;
7398 break;
7399 case 547:
7400 v191 = 7;
7401 break;
7402 case 548:
7403 v191 = 8;
7404 break;
7405 default:
7406 if ( v113 != 550 )
7407 {
7408 v114 = v113 - 105;
7409 LABEL_272:
7410 if ( v114 < 0 || v114 >= 10 )
7411 goto LABEL_293;
7412 LABEL_274:
7413 v115 = v114 + 10 * v239;
7414 v116 = dword_511788[v115];
7415 v115 *= 8;
7416 v117 = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
7417 a2h = papredoll_4E4C28 + *(int *)((char *)&dword_4E56B0 + v115);
7418 a3h = paperdoll_4E4C2C + *(int *)((char *)&dword_4E56B4 + v115);
7419 if ( v116 == pIcons_LOD->FindTextureByName("pending") )
7420 {
7421 LABEL_292:
7422 v68 = v217;
7423 LABEL_293:
7424 if ( v244 == 12 || v244 == 13 )
7425 {
7426 v122 = papredoll_dbrds[v244];
7427 if ( v122 != pIcons_LOD->FindTextureByName("Pending") )
7428 pRenderer->DrawTextureTransparent(
7429 papredoll_4E4C28 + dword_4E5AD0[2 * v244 - 24],
7430 paperdoll_4E4C2C + dword_4E5AD4[2 * v244 - 24],
7431 (Texture *)(v122 != -1 ? (int)&pIcons_LOD->pTextures[v122] : 0));
7432 }
7433 v123 = v68->pEquipment.uHelm;
7434 if ( !v123 )
7435 goto LABEL_335;
7436 v237 = v123;
7437 v124 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v123 + 5];
7438 v226 = v124;
7439 if ( *(int *)v124 != 521 )
7440 {
7441 switch ( *(int *)v124 )
7442 {
7443 case 0x20A:
7444 v192 = 12;
7445 break;
7446 case 0x20B:
7447 v192 = 13;
7448 break;
7449 case 0x214:
7450 v192 = 14;
7451 break;
7452 default:
7453 if ( *(int *)v124 != 544 )
7454 {
7455 v125 = *(int *)v124 - 89;
7456 LABEL_310:
7457 if ( v125 < 0 || v125 >= 16 )
7458 goto LABEL_335;
7459 goto LABEL_312;
7460 }
7461 v192 = 15;
7462 break;
7463 }
7464 v125 = v192;
7465 LABEL_312:
7466 v126 = 2 * (v125 + 16 * v239);
7467 a2j = papredoll_4E4C28 + dword_4E58D0[v126];
7468 a3i = paperdoll_4E4C2C + dword_4E58D4[v126];
7469 if ( v248 != 1 || *(int *)v124 != 92 )
7470 v127 = stru_511698.texids[v125 + 16 * v250];
7471 else
7472 v127 = papredoll_dbrds[11];
7473 v128 = *(int *)(v124 + 20);
7474 if ( *(int *)(v124 + 20) & 0xF0 )
7475 {
7476 if ( (*(int *)(v124 + 20) & 0xF0) != 16 )
7477 {
7478 if ( (*(int *)(v124 + 20) & 0xF0) == 32 )
7479 {
7480 v180 = "sp28a";
7481 goto LABEL_325;
7482 }
7483 if ( (*(int *)(v124 + 20) & 0xF0) == 64 )
7484 {
7485 v180 = "sp30a";
7486 goto LABEL_325;
7487 }
7488 if ( (*(int *)(v124 + 20) & 0xF0) == 128 )
7489 {
7490 v180 = "sp91a";
7491 LABEL_325:
7492 v129 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v180, TEXTURE_16BIT_PALETTE)];
7493 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7494 if ( dword_50C9A8 <= 0 )
7495 {
7496 dword_50C9A8 = 0;
7497 *(char *)(v226 + 20) &= 0xFu;
7498 ptr_50C9A4 = 0;
7499 }
7500 v130 = (double)GetTickCount() * 0.1;
7501 pRenderer->_4A63E6(
7502 a2j,
7503 a3i,
7504 (Texture *)(v127 != -1 ? (int)&pIcons_LOD->pTextures[v127] : 0),
7505 v129,
7506 (signed __int64)v130,
7507 0,
7508 255);
7509 goto LABEL_335;
7510 }
7511 }
7512 v180 = "sptext01";
7513 goto LABEL_325;
7514 }
7515 v131 = v127 + 1;
7516 v132 = (char *)&pIcons_LOD->pTextures[v127];
7517 if ( v128 & 2 )
7518 {
7519 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7520 pRenderer->_4A6776(a2j, a3i, v133);
7521 }
7522 else
7523 {
7524 if ( v128 & 1 )
7525 {
7526 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7527 pRenderer->DrawTextureTransparent(a2j, a3i, v133);
7528 }
7529 else
7530 {
7531 v133 = (Texture *)(v131 != 0 ? (int)v132 : 0);
7532 pRenderer->DrawTransparentGreenShade(a2j, a3i, v133);
7533 }
7534 }
7535 if ( !bRingsShownInCharScreen )
7536 pRenderer->_4A612A(a2j, a3i, v133, v237);
7537 LABEL_335:
7538 v134 = v217->pEquipment.uMainHand;
7539 if ( !v134 )
7540 goto LABEL_358;
7541 v238 = v217->pEquipment.uMainHand;
7542 v135 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v134 + 5];
7543 v227 = v135;
7544 v136 = *(int *)v135;
7545 v137 = *(int *)v135;
7546 a2k = papredoll_4E4C28
7547 + array_4E4C30[v239].field_8
7548 - pItemsTable->pItems[v137].uEquipX;
7549 a3j = paperdoll_4E4C2C
7550 + array_4E4C30[v239].field_C
7551 - pItemsTable->pItems[v137].uEquipY;
7552 if ( v136 == 64 )
7553 v181 = "item64v1";
7554 else
7555 v181 = pItemsTable->pItems[v137].pIconName;
7556 v138 = pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE);
7557 v139 = *(int *)(v227 + 20);
7558 if ( !(*(int *)(v227 + 20) & 0xF0) )
7559 {
7560 v142 = v138 + 1;
7561 v143 = (char *)&pIcons_LOD->pTextures[v138];
7562 if ( v139 & 2 )
7563 {
7564 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7565 pRenderer->_4A6776(a2k, a3j, v144);
7566 }
7567 else
7568 {
7569 if ( v139 & 1 )
7570 {
7571 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7572 pRenderer->DrawTextureTransparent(a2k, a3j, v144);
7573 }
7574 else
7575 {
7576 v144 = (Texture *)(v142 != 0 ? (int)v143 : 0);
7577 pRenderer->DrawTransparentGreenShade(a2k, a3j, v144);
7578 }
7579 }
7580 if ( !bRingsShownInCharScreen )
7581 pRenderer->_4A612A(a2k, a3j, v144, v238);
7582 LABEL_358:
7583 v145 = v217->pEquipment.uOffHand;
7584 v249 = v217->pEquipment.uOffHand;
7585 if ( !v145 )
7586 goto LABEL_393;
7587 v146 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v145 + 5];
7588 v228 = v146;
7589 v147 = *(int *)v146;
7590 v148 = *(int *)v146;
7591 v149 = pItemsTable->pItems[v148].uSkillType;
7592 if ( v149 != 2 && v149 != 1 )
7593 {
7594 v245 = 0;
7595 LABEL_362:
7596 v150 = papredoll_4E4C28
7597 + array_4E4C30[v239].field_0
7598 - pItemsTable->pItems[v148].uEquipX;
7599 a3k = paperdoll_4E4C2C
7600 + LODWORD(array_4E4C30[v239].field_4)
7601 - pItemsTable->pItems[v148].uEquipY;
7602 goto LABEL_370;
7603 }
7604 v151 = v147 - 400;
7605 v245 = 1;
7606 if ( v151 )
7607 {
7608 v152 = v151 - 3;
7609 if ( v152 )
7610 {
7611 if ( v152 != 12 )
7612 goto LABEL_362;
7613 v150 = 595;
7614 a3k = 33;
7615 LABEL_370:
7616 v153 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v148].pIconName, TEXTURE_16BIT_PALETTE);
7617 v154 = v153;
7618 v243 = v153;
7619 v155 = *(int *)(v228 + 20);
7620 if ( !(*(int *)(v228 + 20) & 0xF0) )
7621 {
7622 if ( v155 & 2 )
7623 {
7624 v159 = (Texture *)(v243 != -1 ? (int)&pIcons_LOD->pTextures[v243] : 0);
7625 pRenderer->_4A6776(v150, a3k, v159);
7626 }
7627 else
7628 {
7629 v29 = (v155 & 1) == 0;
7630 v160 = (char *)&pIcons_LOD->pTextures[v243];
7631 if ( v29 )
7632 {
7633 v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
7634 pRenderer->DrawTransparentGreenShade(
7635 v150,
7636 a3k,
7637 (Texture *)(v243 != -1 ? (int)v160 : 0));
7638 }
7639 else
7640 {
7641 v159 = (Texture *)(v243 != -1 ? (int)v160 : 0);
7642 pRenderer->DrawTextureTransparent(
7643 v150,
7644 a3k,
7645 (Texture *)(v243 != -1 ? (int)v160 : 0));
7646 }
7647 }
7648 if ( !bRingsShownInCharScreen )
7649 pRenderer->_4A612A(v150, a3k, v159, v249);
7650 goto LABEL_391;
7651 }
7652 if ( (*(int *)(v228 + 20) & 0xF0) != 16 )
7653 {
7654 if ( (*(int *)(v228 + 20) & 0xF0) == 32 )
7655 {
7656 v183 = "sp28a";
7657 }
7658 else
7659 {
7660 if ( (*(int *)(v228 + 20) & 0xF0) != 64 )
7661 {
7662 v156 = pIcons_LOD;
7663 if ( (*(int *)(v228 + 20) & 0xF0) == 128 )
7664 {
7665 v183 = "sp91a";
7666 LABEL_381:
7667 v157 = &pIcons_LOD->pTextures[v156->LoadTexture(
7668 v183,
7669 TEXTURE_16BIT_PALETTE)];
7670 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7671 if ( dword_50C9A8 <= 0 )
7672 {
7673 dword_50C9A8 = 0;
7674 *(char *)(v228 + 20) &= 0xFu;
7675 ptr_50C9A4 = 0;
7676 }
7677 v158 = (double)GetTickCount() * 0.1;
7678 pRenderer->_4A63E6(
7679 v150,
7680 a3k,
7681 (Texture *)(v154 != -1 ? (int)&pIcons_LOD->pTextures[v154] : 0),
7682 v157,
7683 (signed __int64)v158,
7684 0,
7685 255);
7686 LABEL_391:
7687 if ( v245 )
7688 pRenderer->DrawTextureTransparent(
7689 papredoll_4E4C28
7690 + pPaperdollLeftEmptyHand[uPlayerID_a],
7691 paperdoll_4E4C2C
7692 + pPaperdollLeftEmptyHand[uPlayerID_a + 1],
7693 (Texture *)(*(unsigned int *)((char *)papredoll_dlhs
7694 + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhs + v240)] : 0));
7695 goto LABEL_393;
7696 }
7697 LABEL_380:
7698 v183 = "sptext01";
7699 goto LABEL_381;
7700 }
7701 v183 = "sp30a";
7702 }
7703 v156 = pIcons_LOD;
7704 goto LABEL_381;
7705 }
7706 v156 = pIcons_LOD;
7707 goto LABEL_380;
7708 }
7709 a3k = 28;
7710 }
7711 else
7712 {
7713 a3k = 86;
7714 }
7715 v150 = 596;
7716 goto LABEL_370;
7717 }
7718 if ( (*(int *)(v227 + 20) & 0xF0) != 16 )
7719 {
7720 if ( (*(int *)(v227 + 20) & 0xF0) == 32 )
7721 {
7722 v182 = "sp28a";
7723 goto LABEL_348;
7724 }
7725 if ( (*(int *)(v227 + 20) & 0xF0) == 64 )
7726 {
7727 v182 = "sp30a";
7728 goto LABEL_348;
7729 }
7730 if ( (*(int *)(v227 + 20) & 0xF0) == 128 )
7731 {
7732 v182 = "sp91a";
7733 LABEL_348:
7734 v140 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v182, TEXTURE_16BIT_PALETTE)];
7735 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7736 if ( dword_50C9A8 <= 0 )
7737 {
7738 dword_50C9A8 = 0;
7739 *(char *)(v227 + 20) &= 0xFu;
7740 ptr_50C9A4 = 0;
7741 }
7742 v141 = (double)GetTickCount() * 0.1;
7743 pRenderer->_4A63E6(
7744 a2k,
7745 a3j,
7746 (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0),
7747 v140,
7748 (signed __int64)v141,
7749 0,
7750 255);
7751 goto LABEL_358;
7752 }
7753 }
7754 v182 = "sptext01";
7755 goto LABEL_348;
7756 }
7757 v125 = 11;
7758 goto LABEL_310;
7759 }
7760 if ( !(*(int *)(v225 + 20) & 0xF0) )
7761 {
7762 v119 = v116 + 1;
7763 v120 = (char *)&pIcons_LOD->pTextures[v116];
7764 if ( *(int *)(v225 + 20) & 2 )
7765 {
7766 v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
7767 pRenderer->_4A6776(a2h, a3h, v121);
7768 }
7769 else
7770 {
7771 v121 = (Texture *)(v119 != 0 ? (int)v120 : 0);
7772 pRenderer->DrawTextureTransparent(a2h, a3h, v121);
7773 }
7774 if ( !bRingsShownInCharScreen )
7775 pRenderer->_4A612A(a2h, a3h, v121, v236);
7776 goto LABEL_292;
7777 }
7778 if ( (*(int *)(v225 + 20) & 0xF0) != 16 )
7779 {
7780 if ( (*(int *)(v225 + 20) & 0xF0) == 32 )
7781 {
7782 v179 = "sp28a";
7783 goto LABEL_284;
7784 }
7785 if ( (*(int *)(v225 + 20) & 0xF0) == 64 )
7786 {
7787 v179 = "sp30a";
7788 goto LABEL_284;
7789 }
7790 if ( (*(int *)(v225 + 20) & 0xF0) == 128 )
7791 {
7792 v179 = "sp91a";
7793 LABEL_284:
7794 a2i = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v179, TEXTURE_16BIT_PALETTE)];
7795 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7796 if ( dword_50C9A8 <= 0 )
7797 {
7798 dword_50C9A8 = 0;
7799 *(char *)(v225 + 20) &= 0xFu;
7800 ptr_50C9A4 = 0;
7801 }
7802 v118 = (double)GetTickCount() * 0.1;
7803 pRenderer->_4A63E6(
7804 v117,
7805 a3h,
7806 (Texture *)(v116 != -1 ? (int)&pIcons_LOD->pTextures[v116] : 0),
7807 a2i,
7808 (signed __int64)v118,
7809 0,
7810 255);
7811 goto LABEL_292;
7812 }
7813 }
7814 v179 = "sptext01";
7815 goto LABEL_284;
7816 }
7817 v191 = 9;
7818 break;
7819 }
7820 v114 = v191;
7821 goto LABEL_274;
7822 }
7823 v114 = 5;
7824 goto LABEL_272;
7825 }
7826 LABEL_209:
7827 if ( v68->pEquipment.uMainHand
7828 && (v68->GetEquippedItemEquipType(1u) == 1
7829 || v68->GetEquippedItemSkillType(EQUIP_TWO_HANDED) == 4
7830 && !v68->pEquipment.uOffHand) )
7831 {
7832 v91 = 17 * v239 + v90;
7833 v92 = v91;
7834 v223 = paperdoll_array_511290[0][v91][2];
7835 if ( v223 == pIcons_LOD->FindTextureByName("pending") )
7836 {
7837 v93 = 2 * v91;
7838 v94 = paperdoll_array_511290[0][v92][1];
7839 a2g = papredoll_4E4C28 + dword_4E5050[v93];
7840 v95 = dword_4E5050[v93 + 1];
7841 }
7842 else
7843 {
7844 v94 = v223;
7845 a2g = papredoll_4E4C28 + dword_4E5270[2 * v91];
7846 v95 = dword_4E5270[2 * v91 + 1];
7847 }
7848 a3g = paperdoll_4E4C2C + v95;
7849 if ( v94 == pIcons_LOD->FindTextureByName("pending") )
7850 goto LABEL_258;
7851 if ( *(int *)(v242 + 516) & 0xF0 )
7852 {
7853 if ( (*(int *)(v242 + 516) & 0xF0) != 16 )
7854 {
7855 if ( (*(int *)(v242 + 516) & 0xF0) == 32 )
7856 {
7857 v173 = "sp28a";
7858 goto LABEL_226;
7859 }
7860 if ( (*(int *)(v242 + 516) & 0xF0) == 64 )
7861 {
7862 v173 = "sp30a";
7863 goto LABEL_226;
7864 }
7865 if ( (*(int *)(v242 + 516) & 0xF0) == 128 )
7866 {
7867 v173 = "sp91a";
7868 LABEL_226:
7869 v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v173, TEXTURE_16BIT_PALETTE)];
7870 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7871 if ( dword_50C9A8 <= 0 )
7872 {
7873 dword_50C9A8 = 0;
7874 *(char *)(v242 + 516) &= 0xFu;
7875 ptr_50C9A4 = 0;
7876 }
7877 v187 = 255;
7878 v174 = 0;
7879 v97 = (double)GetTickCount();
7880 LABEL_249:
7881 pRenderer->_4A63E6(
7882 a2g,
7883 a3g,
7884 (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0),
7885 (Texture *)v96,
7886 (signed __int64)(v97 * 0.1),
7887 v174,
7888 v187);
7889 goto LABEL_258;
7890 }
7891 }
7892 v173 = "sptext01";
7893 goto LABEL_226;
7894 }
7895 v98 = v94 + 1;
7896 v99 = (char *)&pIcons_LOD->pTextures[v94];
7897 v100 = pRenderer;
7898 if ( *(int *)(v242 + 516) & 2 )
7899 {
7900 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7901 v188 = v101;
7902 v175 = a3g;
7903 v163 = a2g;
7904 LABEL_231:
7905 v100->_4A6776(v163, v175, v188);
7906 goto LABEL_256;
7907 }
7908 if ( *(char *)(v242 + 516) & 1 )
7909 {
7910 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7911 v189 = v101;
7912 v176 = a3g;
7913 v164 = a2g;
7914 LABEL_234:
7915 pRenderer->DrawTextureTransparent(v164, v176, v189);
7916 goto LABEL_256;
7917 }
7918 v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
7919 v190 = v101;
7920 v177 = a3g;
7921 v165 = a2g;
7922 goto LABEL_255;
7923 }
7924 v102 = 17 * v239 + v90;
7925 v94 = paperdoll_array_511290[0][v102][1];
7926 if ( v94 == pIcons_LOD->FindTextureByName("pending") )
7927 {
7928 LABEL_258:
7929 v68 = v217;
7930 goto LABEL_259;
7931 }
7932 v103 = papredoll_4E4C28 + dword_4E5050[2 * v102];
7933 v104 = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
7934 v224 = *(int *)(v242 + 516);
7935 v105 = *(int *)(v242 + 516) & 0xF0;
7936 a2g = papredoll_4E4C28 + dword_4E5050[2 * v102];
7937 a3g = paperdoll_4E4C2C + dword_4E5050[2 * v102 + 1];
7938 if ( !v105 )
7939 {
7940 v109 = v94 + 1;
7941 v110 = (char *)&pIcons_LOD->pTextures[v94];
7942 if ( v224 & 2 )
7943 {
7944 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7945 v188 = v101;
7946 v175 = v104;
7947 v163 = v103;
7948 v100 = pRenderer;
7949 goto LABEL_231;
7950 }
7951 if ( v224 & 1 )
7952 {
7953 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7954 v189 = v101;
7955 v176 = v104;
7956 v164 = v103;
7957 v100 = pRenderer;
7958 goto LABEL_234;
7959 }
7960 v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
7961 v190 = v101;
7962 v177 = v104;
7963 v165 = v103;
7964 v100 = pRenderer;
7965 LABEL_255:
7966 pRenderer->DrawTransparentGreenShade(v165, v177, v190);
7967 LABEL_256:
7968 if ( !bRingsShownInCharScreen )
7969 pRenderer->_4A612A(a2g, a3g, v101, v235);
7970 goto LABEL_258;
7971 }
7972 v106 = v105 - 16;
7973 if ( v106 )
7974 {
7975 v107 = v106 - 16;
7976 if ( !v107 )
7977 {
7978 v178 = "sp28a";
7979 goto LABEL_246;
7980 }
7981 v108 = v107 - 32;
7982 if ( !v108 )
7983 {
7984 v178 = "sp30a";
7985 goto LABEL_246;
7986 }
7987 if ( v108 == 64 )
7988 {
7989 v178 = "sp91a";
7990 LABEL_246:
7991 v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v178, TEXTURE_16BIT_PALETTE)];
7992 dword_50C9A8 -= pEventTimer->uTimeElapsed;
7993 if ( dword_50C9A8 <= 0 )
7994 {
7995 dword_50C9A8 = 0;
7996 *(char *)(v242 + 516) &= 0xFu;
7997 ptr_50C9A4 = 0;
7998 }
7999 v187 = 255;
8000 v174 = 0;
8001 v97 = (double)GetTickCount();
8002 goto LABEL_249;
8003 }
8004 }
8005 v178 = "sptext01";
8006 goto LABEL_246;
8007 }
8008 v186 = 16;
8009 }
8010 else
8011 {
8012 v186 = 13;
8013 }
8014 }
8015 else
8016 {
8017 v186 = 14;
8018 }
8019 v90 = v186;
8020 goto LABEL_209;
8021 }
8022 v90 = 15;
8023 goto LABEL_207;
8024 }
8025 if ( (*(int *)(v57 + 20) & 0xF0) != 16 )
8026 {
8027 if ( (*(int *)(v57 + 20) & 0xF0) == 32 )
8028 {
8029 v171 = "sp28a";
8030 goto LABEL_145;
8031 }
8032 if ( (*(int *)(v57 + 20) & 0xF0) == 64 )
8033 {
8034 v171 = "sp30a";
8035 goto LABEL_145;
8036 }
8037 if ( (*(int *)(v57 + 20) & 0xF0) == 128 )
8038 {
8039 v171 = "sp91a";
8040 LABEL_145:
8041 v63 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v171, TEXTURE_16BIT_PALETTE)];
8042 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8043 if ( dword_50C9A8 <= 0 )
8044 {
8045 dword_50C9A8 = 0;
8046 *(char *)(v221 + 20) &= 0xFu;
8047 ptr_50C9A4 = 0;
8048 }
8049 v64 = (double)GetTickCount() * 0.1;
8050 pRenderer->_4A63E6(
8051 a2e,
8052 a3e,
8053 (Texture *)(v59 != -1 ? (int)&pIcons_LOD->pTextures[v59] : 0),
8054 v63,
8055 (signed __int64)v64,
8056 0,
8057 255);
8058 goto LABEL_155;
8059 }
8060 }
8061 v171 = "sptext01";
8062 goto LABEL_145;
8063 }
8064 if ( (*(int *)(v44 + 20) & 0xF0) != 16 )
8065 {
8066 if ( (*(int *)(v44 + 20) & 0xF0) == 32 )
8067 {
8068 v170 = "sp28a";
8069 }
8070 else
8071 {
8072 if ( (*(int *)(v44 + 20) & 0xF0) != 64 )
8073 {
8074 v50 = pIcons_LOD;
8075 if ( (*(int *)(v44 + 20) & 0xF0) == 128 )
8076 {
8077 v170 = "sp91a";
8078 LABEL_117:
8079 v51 = &pIcons_LOD->pTextures[v50->LoadTexture(v170, TEXTURE_16BIT_PALETTE)];
8080 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8081 if ( dword_50C9A8 <= 0 )
8082 {
8083 dword_50C9A8 = 0;
8084 *(char *)(v220 + 20) &= 0xFu;
8085 ptr_50C9A4 = 0;
8086 }
8087 v52 = (double)GetTickCount() * 0.1;
8088 pRenderer->_4A63E6(
8089 a2d,
8090 a3d,
8091 (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0),
8092 v51,
8093 (signed __int64)v52,
8094 0,
8095 255);
8096 goto LABEL_127;
8097 }
8098 LABEL_116:
8099 v170 = "sptext01";
8100 goto LABEL_117;
8101 }
8102 v170 = "sp30a";
8103 }
8104 v50 = pIcons_LOD;
8105 goto LABEL_117;
8106 }
8107 v50 = pIcons_LOD;
8108 goto LABEL_116;
8109 }
8110 v185 = 16;
8111 }
8112 }
8113 v45 = v185;
8114 goto LABEL_106;
8115 }
8116 v45 = 15;
8117 goto LABEL_104;
8118 }
8119 if ( (*(int *)(v32 + 20) & 0xF0) != 16 )
8120 {
8121 if ( (*(int *)(v32 + 20) & 0xF0) == 32 )
8122 {
8123 v169 = "sp28a";
8124 }
8125 else
8126 {
8127 if ( (*(int *)(v32 + 20) & 0xF0) != 64 )
8128 {
8129 v38 = pIcons_LOD;
8130 if ( (*(int *)(v32 + 20) & 0xF0) == 128 )
8131 {
8132 v169 = "sp91a";
8133 LABEL_85:
8134 v39 = &pIcons_LOD->pTextures[v38->LoadTexture(v169, TEXTURE_16BIT_PALETTE)];
8135 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8136 if ( dword_50C9A8 <= 0 )
8137 {
8138 dword_50C9A8 = 0;
8139 *(char *)(v219 + 20) &= 0xFu;
8140 ptr_50C9A4 = 0;
8141 }
8142 v40 = (double)GetTickCount() * 0.1;
8143 pRenderer->_4A63E6(
8144 a2c,
8145 a3c,
8146 (Texture *)(v35 != -1 ? (int)&pIcons_LOD->pTextures[v35] : 0),
8147 v39,
8148 (signed __int64)v40,
8149 0,
8150 255);
8151 goto LABEL_93;
8152 }
8153 LABEL_84:
8154 v169 = "sptext01";
8155 goto LABEL_85;
8156 }
8157 v169 = "sp30a";
8158 }
8159 v38 = pIcons_LOD;
8160 goto LABEL_85;
8161 }
8162 v38 = pIcons_LOD;
8163 goto LABEL_84;
8164 }
8165 v184 = 9;
8166 break;
8167 }
8168 v33 = v184;
8169 goto LABEL_74;
8170 }
8171 v33 = 5;
8172 goto LABEL_72;
8173 }
8174 if ( (*(int *)(v22 + 20) & 0xF0) != 16 )
8175 {
8176 if ( (*(int *)(v22 + 20) & 0xF0) == 32 )
8177 {
8178 v168 = "sp28a";
8179 }
8180 else
8181 {
8182 if ( (*(int *)(v22 + 20) & 0xF0) != 64 )
8183 {
8184 v26 = pIcons_LOD;
8185 if ( (*(int *)(v22 + 20) & 0xF0) == 128 )
8186 {
8187 v168 = "sp91a";
8188 LABEL_49:
8189 a2b = &pIcons_LOD->pTextures[v26->LoadTexture(v168, TEXTURE_16BIT_PALETTE)];
8190 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8191 if ( dword_50C9A8 <= 0 )
8192 {
8193 dword_50C9A8 = 0;
8194 *(char *)(v22 + 20) &= 0xFu;
8195 ptr_50C9A4 = 0;
8196 }
8197 v27 = (Texture *)(v241 != -1 ? (int)&pIcons_LOD->pTextures[v241] : 0);
8198 v28 = (double)GetTickCount() * 0.1;
8199 pRenderer->_4A63E6(v24, a3b, v27, a2b, (signed __int64)v28, 0, 255);
8200 goto LABEL_57;
8201 }
8202 LABEL_48:
8203 v168 = "sptext01";
8204 goto LABEL_49;
8205 }
8206 v168 = "sp30a";
8207 }
8208 v26 = pIcons_LOD;
8209 goto LABEL_49;
8210 }
8211 v26 = pIcons_LOD;
8212 goto LABEL_48;
8213 }
8214 a3 = paperdoll_4E4C2C;
8215 a2 = papredoll_4E4C28;
8216 v240 = 4 * uPlayerID_ - 4;
8217 pRenderer->DrawTextureTransparent(
8218 papredoll_4E4C28,
8219 paperdoll_4E4C2C,
8220 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
8221 //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
8222 // * *(unsigned int *)((char *)papredoll_dbods
8223 // + v240)
8224 // + 7145548 : 0));
8225 if ( !bRingsShownInCharScreen )
8226 pRenderer->_4A612A(
8227 a2,
8228 a3,
8229 //(Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? 72
8230 // * *(unsigned int *)((char *)papredoll_dbods
8231 // + v240)
8232 // + 7145548 : 0),
8233 (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0),
8234 pPlayer->pEquipment.uBody);
8235 uPlayerID_a = 2 * v5;
8236 v6 = pPlayer->pEquipment.uMainHand;
8237 if ( !v6
8238 || (v7 = *(int *)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5], pItemsTable->pItems[v7].uEquipType != 1)
8239 && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayer->pEquipment.uOffHand) )
8240 pRenderer->DrawTextureTransparent(
8241 papredoll_4E4C28 + dword_4E5AE0[2 * v5],
8242 paperdoll_4E4C2C + dword_4E5AE0[2 * v5 + 1],
8243 (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
8244 //(Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? 72
8245 // * *(unsigned int *)((char *)papredoll_dlads
8246 // + v240)
8247 // + 7145548 : 0));
8248 v8 = pPlayer->pEquipment.uMainHand;
8249 if ( v8 )
8250 {
8251 v229 = pPlayer->pEquipment.uMainHand;
8252 v9 = (int)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
8253 v10 = v5 << 7;
8254 v218 = v9;
8255 v11 = *(int *)v9;
8256 v12 = *(int *)v9;
8257 v13 = papredoll_4E4C28 + array_4E4C30[v5].field_8 - pItemsTable->pItems[v12].uEquipX;
8258 a2a = v13;
8259 a3a = paperdoll_4E4C2C + *(int *)((char *)&array_4E4C30[0].field_C + v10) - pItemsTable->pItems[v12].uEquipY;
8260 if ( v11 == 64 )
8261 v166 = "item64v1";
8262 else
8263 v166 = pItemsTable->pItems[v12].pIconName;
8264 v14 = pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE);
8265 v15 = *(int *)(v218 + 20);
8266 if ( *(int *)(v218 + 20) & 0xF0 )
8267 {
8268 if ( (*(int *)(v218 + 20) & 0xF0) != 16 )
8269 {
8270 if ( (*(int *)(v218 + 20) & 0xF0) == 32 )
8271 {
8272 v167 = "sp28a";
8273 goto LABEL_27;
8274 }
8275 if ( (*(int *)(v218 + 20) & 0xF0) == 64 )
8276 {
8277 v167 = "sp30a";
8278 goto LABEL_27;
8279 }
8280 if ( (*(int *)(v218 + 20) & 0xF0) == 128 )
8281 {
8282 v167 = "sp91a";
8283 LABEL_27:
8284 //v16 = (Texture *)(72 * pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE) + 7145548);
8285 v16 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE)];
8286
8287 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8288 if ( dword_50C9A8 <= 0 )
8289 {
8290 dword_50C9A8 = 0;
8291 *(char *)(v218 + 20) &= 0xFu;
8292 ptr_50C9A4 = 0;
8293 }
8294 v17 = (double)GetTickCount() * 0.1;
8295 pRenderer->_4A63E6(
8296 v13,
8297 a3a,
8298 (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0),
8299 v16,
8300 (signed __int64)v17,
8301 0,
8302 255);
8303 goto LABEL_393;
8304 }
8305 }
8306 v167 = "sptext01";
8307 goto LABEL_27;
8308 }
8309 v18 = v14 + 1;
8310 v19 = (char *)&pIcons_LOD->pTextures[v14];
8311 if ( v15 & 2 )
8312 {
8313 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
8314 pRenderer->_4A6776(a2a, a3a, v20);
8315 }
8316 else
8317 {
8318 if ( v15 & 1 )
8319 {
8320 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
8321 pRenderer->DrawTextureTransparent(a2a, a3a, v20);
8322 }
8323 else
8324 {
8325 v20 = (Texture *)(v18 != 0 ? (int)v19 : 0);
8326 pRenderer->DrawTransparentGreenShade(a2a, a3a, v20);
8327 }
8328 }
8329 if ( !bRingsShownInCharScreen )
8330 pRenderer->_4A612A(a2a, a3a, v20, v229);
8331 }
8332 LABEL_393:
8333 pRenderer->DrawTextureTransparent(
8334 papredoll_4E4C28 + pPaperdollRightHand[uPlayerID_a],
8335 paperdoll_4E4C2C + pPaperdollRightHand[uPlayerID_a + 1],
8336 (Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_drhs + v240)] : 0));
8337 //(Texture *)(*(unsigned int *)((char *)papredoll_drhs + v240) != -1 ? 72
8338 // * *(unsigned int *)((char *)papredoll_drhs + v240)
8339 // + 7145548 : 0));
8340 v161 = v217->pEquipment.uMainHand;
8341 if ( v161 )
8342 {
8343 v162 = *(int *)&v217->pDarkSpellbook.bIsSpellAvailable[36 * v161 + 5];
8344 if ( pItemsTable->pItems[v162].uEquipType == 1
8345 || pItemsTable->pItems[v162].uSkillType == 4 && !v217->pEquipment.uOffHand )
8346 pRenderer->DrawTextureTransparent(
8347 papredoll_4E4C28 + pPaperdollLeftHand[uPlayerID_a],
8348 paperdoll_4E4C2C + pPaperdollLeftHand[uPlayerID_a + 1],
8349 (Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlhus + v240)] : 0));
8350 //(Texture *)(*(unsigned int *)((char *)papredoll_dlhus + v240) != -1 ? 72
8351 // * *(unsigned int *)((char *)papredoll_dlhus
8352 // + v240)
8353 // + 7145548 : 0));
8354 }
8355 if ( !bRingsShownInCharScreen )
8356 pRenderer->DrawTextureTransparent(
8357 0x25Bu,
8358 0x12Bu,
8359 (Texture *)(uTextureID_MAGNIF_B != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_MAGNIF_B] : 0));
8360 pRenderer->DrawTextureTransparent(
8361 0x1D4u,
8362 0,
8363 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
8364 }
8365
8366
8367 //----- (0043E825) --------------------------------------------------------
8368 void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID)
8369 {
8370 unsigned int v1; // ebx@1
8371 Player *pPlayer; // edi@1
8372 int v3; // ecx@1
8373 int v4; // edi@3
8374 unsigned int v5; // ebx@3
8375 int v6; // eax@3
8376 LODFile_IconsBitmaps *v7; // ecx@7
8377 double v8; // st7@16
8378 int v9; // edi@17
8379 Texture *v10; // edi@18
8380 unsigned __int8 v11; // zf@19
8381 Texture *v12; // eax@19
8382 char v13; // sf@24
8383 unsigned __int8 v14; // of@24
8384 unsigned int v15; // eax@25
8385 unsigned int v16; // ebx@26
8386 int v17; // eax@26
8387 LODFile_IconsBitmaps *v18; // ecx@30
8388 double v19; // st7@39
8389 int v20; // edi@40
8390 int v21; // eax@41
8391 signed int v22; // ebx@41
8392 Texture *v23; // edi@41
8393 int v24; // eax@42
8394 char *v25; // eax@42
8395 unsigned int v26; // eax@46
8396 int v27; // edi@47
8397 unsigned int v28; // ebx@47
8398 int v29; // eax@47
8399 LODFile_IconsBitmaps *v30; // ecx@51
8400 Texture *v31; // esi@58
8401 double v32; // st7@60
8402 int v33; // esi@61
8403 int v34; // esi@62
8404 Texture *v35; // eax@63
8405 const char *v36; // [sp-8h] [bp-38h]@8
8406 const char *v37; // [sp-8h] [bp-38h]@31
8407 const char *v38; // [sp-8h] [bp-38h]@52
8408 int v39; // [sp+10h] [bp-20h]@3
8409 Texture *v40; // [sp+10h] [bp-20h]@14
8410 int v41; // [sp+10h] [bp-20h]@26
8411 Texture *v42; // [sp+10h] [bp-20h]@37
8412 int v43; // [sp+10h] [bp-20h]@47
8413 unsigned int a3; // [sp+14h] [bp-1Ch]@3
8414 unsigned int a2; // [sp+18h] [bp-18h]@3
8415 int v46; // [sp+1Ch] [bp-14h]@1
8416 Player *v47; // [sp+20h] [bp-10h]@1
8417 int v48; // [sp+24h] [bp-Ch]@1
8418 int v49; // [sp+24h] [bp-Ch]@26
8419
8420 v1 = uPlayerID;
8421 pPlayer = pPlayers[uPlayerID];
8422 v47 = pPlayers[uPlayerID];
8423 pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
8424 CharacterUI_DrawPaperdoll(v1);
8425 pRenderer->DrawTextureTransparent(
8426 0x1D9u,
8427 0,
8428 (Texture *)(uTextureID_BACKHAND != -1 ? &pIcons_LOD->pTextures[uTextureID_BACKHAND] : 0));
8429 pRenderer->DrawTextureTransparent(
8430 0x1D4u,
8431 0,
8432 (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0));
8433 pRenderer->DrawTextureIndexed(
8434 ptr_507694->uX,
8435 ptr_507694->uY,
8436 (Texture *)(uTextureID_5118C8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5118C8] : 0));
8437 v3 = 0;
8438 v46 = (int)&pPlayer->pEquipment.field_28;
8439 v48 = 0;
8440 do
8441 {
8442 if ( !*(int *)v46 )
8443 goto LABEL_24;
8444 v39 = *(int *)v46;
8445 v4 = (int)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v46 + 5];
8446 a3 = *(int *)((char *)dword_4E5C34 + v3);
8447 a2 = *(int *)((char *)dword_4E5C1C + v3);
8448 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v4].pIconName, TEXTURE_16BIT_PALETTE);
8449 v6 = *(int *)(v4 + 20);
8450 if ( *(int *)(v4 + 20) & 0xF0 )
8451 {
8452 if ( (*(int *)(v4 + 20) & 0xF0) != 16 )
8453 {
8454 if ( (*(int *)(v4 + 20) & 0xF0) == 32 )
8455 {
8456 v36 = "sp28a";
8457 }
8458 else
8459 {
8460 if ( (*(int *)(v4 + 20) & 0xF0) != 64 )
8461 {
8462 v7 = pIcons_LOD;
8463 if ( (*(int *)(v4 + 20) & 0xF0) == 128 )
8464 {
8465 v36 = "sp91a";
8466 LABEL_14:
8467 v40 = &pIcons_LOD->pTextures[v7->LoadTexture(v36, TEXTURE_16BIT_PALETTE)];
8468 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8469 if ( dword_50C9A8 <= 0 )
8470 {
8471 dword_50C9A8 = 0;
8472 *(char *)(v4 + 20) &= 0xFu;
8473 ptr_50C9A4 = 0;
8474 }
8475 v8 = (double)GetTickCount() * 0.1;
8476 pRenderer->_4A63E6(
8477 a2,
8478 a3,
8479 (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0),
8480 v40,
8481 (signed __int64)v8,
8482 0,
8483 255);
8484 goto LABEL_23;
8485 }
8486 LABEL_13:
8487 v36 = "sptext01";
8488 goto LABEL_14;
8489 }
8490 v36 = "sp30a";
8491 }
8492 v7 = pIcons_LOD;
8493 goto LABEL_14;
8494 }
8495 v7 = pIcons_LOD;
8496 goto LABEL_13;
8497 }
8498 v9 = v5 + 1;
8499 if ( v6 & 2 )
8500 {
8501 v10 = (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[v5] : 0);
8502 pRenderer->_4A6776(a2, a3, v10);
8503 }
8504 else
8505 {
8506 v11 = (v6 & 1) == 0;
8507 v12 = &pIcons_LOD->pTextures[v5];
8508 if ( v11 )
8509 {
8510 v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
8511 pRenderer->DrawTransparentGreenShade(a2, a3, v10);
8512 }
8513 else
8514 {
8515 v10 = (Texture *)(v9 != 0 ? (int)v12 : 0);
8516 pRenderer->DrawTextureTransparent(a2, a3, v10);
8517 }
8518 }
8519 pRenderer->_4A601E(a2, a3, v10, v39);
8520 LABEL_23:
8521 pPlayer = v47;
8522 LABEL_24:
8523 v46 += 4;
8524 v3 = v48 + 4;
8525 v14 = __OFSUB__(v48 + 4, 20);
8526 v11 = v48 == 16;
8527 v13 = v48 - 16 < 0;
8528 v48 += 4;
8529 }
8530 while ( (unsigned __int8)(v13 ^ v14) | v11 );
8531 v15 = pPlayer->pEquipment.field_24;
8532 if ( !v15 )
8533 goto LABEL_46;
8534 v41 = pPlayer->pEquipment.field_24;
8535 v49 = (int)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5];
8536 v16 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v49].pIconName, TEXTURE_16BIT_PALETTE);
8537 v17 = *(int *)(v49 + 20);
8538 if ( !(*(int *)(v49 + 20) & 0xF0) )
8539 {
8540 v20 = v16 + 1;
8541 if ( v17 & 2 )
8542 {
8543 v21 = 9 * v16;
8544 v22 = 493;
8545 v23 = (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0);
8546 pRenderer->_4A6776(0x1EDu, 0x5Bu, v23);
8547 }
8548 else
8549 {
8550 v11 = (v17 & 1) == 0;
8551 v24 = 9 * v16;
8552 v22 = 493;
8553 v25 = (char *)&pIcons_LOD->pTextures[8 * v24 / 0x48u];
8554 if ( v11 )
8555 {
8556 v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
8557 pRenderer->DrawTransparentGreenShade(493, 91, v23);
8558 }
8559 else
8560 {
8561 v23 = (Texture *)(v20 != 0 ? (int)v25 : 0);
8562 pRenderer->DrawTextureTransparent(0x1EDu, 0x5Bu, v23);
8563 }
8564 }
8565 pRenderer->_4A601E(v22, 91, v23, v41);
8566 pPlayer = v47;
8567 goto LABEL_46;
8568 }
8569 if ( (*(int *)(v49 + 20) & 0xF0) == 16 )
8570 {
8571 v18 = pIcons_LOD;
8572 goto LABEL_36;
8573 }
8574 if ( (*(int *)(v49 + 20) & 0xF0) == 32 )
8575 {
8576 v37 = "sp28a";
8577 goto LABEL_34;
8578 }
8579 if ( (*(int *)(v49 + 20) & 0xF0) == 64 )
8580 {
8581 v37 = "sp30a";
8582 LABEL_34:
8583 v18 = pIcons_LOD;
8584 goto LABEL_37;
8585 }
8586 v18 = pIcons_LOD;
8587 if ( (*(int *)(v49 + 20) & 0xF0) == 128 )
8588 {
8589 v37 = "sp91a";
8590 goto LABEL_37;
8591 }
8592 LABEL_36:
8593 v37 = "sptext01";
8594 LABEL_37:
8595 v42 = &pIcons_LOD->pTextures[v18->LoadTexture(v37, TEXTURE_16BIT_PALETTE)];
8596 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8597 if ( dword_50C9A8 <= 0 )
8598 {
8599 dword_50C9A8 = 0;
8600 *(char *)(v49 + 20) &= 0xFu;
8601 ptr_50C9A4 = 0;
8602 }
8603 v19 = (double)GetTickCount() * 0.1;
8604 pRenderer->_4A63E6(
8605 0x1EDu,
8606 0x5Bu,
8607 (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0),
8608 v42,
8609 (signed __int64)v19,
8610 0,
8611 255);
8612 LABEL_46:
8613 v26 = pPlayer->pEquipment.field_1C;
8614 if ( !v26 )
8615 return;
8616 v43 = pPlayer->pEquipment.field_1C;
8617 v27 = (int)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * v26 + 5];
8618 v28 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v27].pIconName, TEXTURE_16BIT_PALETTE);
8619 v29 = *(int *)(v27 + 20);
8620 if ( !(*(int *)(v27 + 20) & 0xF0) )
8621 {
8622 v33 = v28 + 1;
8623 if ( v29 & 2 )
8624 {
8625 v34 = v33 != 0 ? (int)&pIcons_LOD->pTextures[v28] : 0;
8626 pRenderer->_4A6776(0x24Au, 0x58u, (Texture *)v34);
8627 }
8628 else
8629 {
8630 v11 = (v29 & 1) == 0;
8631 v35 = &pIcons_LOD->pTextures[v28];
8632 if ( v11 )
8633 {
8634 v34 = v33 != 0 ? (int)v35 : 0;
8635 pRenderer->DrawTransparentGreenShade(586, 88, (Texture *)v34);
8636 }
8637 else
8638 {
8639 v34 = v33 != 0 ? (int)v35 : 0;
8640 pRenderer->DrawTextureTransparent(0x24Au, 0x58u, (Texture *)v34);
8641 }
8642 }
8643 pRenderer->_4A601E(586, 88, (Texture *)v34, v43);
8644 return;
8645 }
8646 if ( (*(int *)(v27 + 20) & 0xF0) == 16 )
8647 {
8648 v30 = pIcons_LOD;
8649 goto LABEL_57;
8650 }
8651 if ( (*(int *)(v27 + 20) & 0xF0) == 32 )
8652 {
8653 v38 = "sp28a";
8654 goto LABEL_55;
8655 }
8656 if ( (*(int *)(v27 + 20) & 0xF0) == 64 )
8657 {
8658 v38 = "sp30a";
8659 LABEL_55:
8660 v30 = pIcons_LOD;
8661 goto LABEL_58;
8662 }
8663 v30 = pIcons_LOD;
8664 if ( (*(int *)(v27 + 20) & 0xF0) == 128 )
8665 {
8666 v38 = "sp91a";
8667 goto LABEL_58;
8668 }
8669 LABEL_57:
8670 v38 = "sptext01";
8671 LABEL_58:
8672 v31 = &pIcons_LOD->pTextures[v30->LoadTexture(v38, TEXTURE_16BIT_PALETTE)];
8673 dword_50C9A8 -= pEventTimer->uTimeElapsed;
8674 if ( dword_50C9A8 <= 0 )
8675 {
8676 dword_50C9A8 = 0;
8677 *(char *)(v27 + 20) &= 0xFu;
8678 ptr_50C9A4 = 0;
8679 }
8680 v32 = (double)GetTickCount() * 0.1;
8681 pRenderer->_4A63E6(
8682 0x24Au,
8683 0x58u,
8684 (Texture *)(v28 != -1 ? (int)&pIcons_LOD->pTextures[v28] : 0),
8685 v31,
8686 (signed __int64)v32,
8687 0,
8688 255);
8689 }
8690
8691
8692 //----- (0043ED6F) --------------------------------------------------------
8693 bool __thiscall sub_43ED6F_get_some_race_sex_relation(unsigned int a1)
8694 {
8695 unsigned int v1; // ebp@1
8696 Player **v2; // ebx@1
8697 Player *v3; // esi@2
8698 enum CHARACTER_RACE v4; // edi@2
8699 bool result; // eax@2
8700 char v6; // zf@5
8701
8702 v1 = a1;
8703 v2 = &pPlayers[1];
8704 while ( 1 )
8705 {
8706 v3 = *v2;
8707 v4 = v3->GetRace();
8708 result = v3->GetSexByVoice();
8709 if ( v4 && v4 != CHARACTER_RACE_ELF && v4 != CHARACTER_RACE_GOBLIN )
8710 v6 = v1 == 1;
8711 else
8712 v6 = v1 == 0;
8713 if ( v6 )
8714 break;
8715 ++v2;
8716 if ( (signed int)v2 >= (signed int)&qword_A750D8 )
8717 {
8718 LOBYTE(result) = 0;
8719 return result;
8720 }
8721 }
8722 LOBYTE(result) = 1;
8723 return result;
8724 }
8725 // A750D8: using guessed type __int64 qword_A750D8;
8726
8727 //----- (0043EDB9) --------------------------------------------------------
8728 bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this)
8729 {
8730 unsigned int v1; // ebp@1
8731 Player **v2; // ebx@1
8732 Player *v3; // esi@2
8733 enum CHARACTER_RACE v4; // edi@2
8734 bool result; // eax@2
8735 char v6; // zf@7
8736
8737 v1 = _this;
8738 v2 = &pPlayers[1];
8739 while ( 1 )
8740 {
8741 v3 = *v2;
8742 v4 = v3->GetRace();
8743 result = v3->GetSexByVoice();
8744 if ( !v4 )
8745 break;
8746 if ( v4 == 1 || v4 == 2 )
8747 break;
8748 if ( !result && v1 == 2 )
8749 goto LABEL_15;
8750 v6 = v1 == 3;
8751 LABEL_11:
8752 if ( v6 )
8753 goto LABEL_15;
8754 ++v2;
8755 if ( (signed int)v2 >= (signed int)&qword_A750D8 )
8756 {
8757 LOBYTE(result) = 0;
8758 return result;
8759 }
8760 }
8761 if ( result || v1 )
8762 {
8763 v6 = v1 == 1;
8764 goto LABEL_11;
8765 }
8766 LABEL_15:
8767 LOBYTE(result) = 1;
8768 return result;
8769 }
8770 // A750D8: using guessed type __int64 qword_A750D8;
8771
8772 //----- (0043EE15) --------------------------------------------------------
8773 bool __fastcall sub_43EE15_player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
8774 {
8775 bool result; // eax@0
8776 signed int v4; // edi@3
8777 int *v5; // esi@3
8778 signed int v6; // edi@7
8779 bool *v7; // esi@7
8780
8781 if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
8782 {
8783 v4 = 0;
8784 v5 = pPlayer->pInventoryIndices;
8785 while ( 1 )
8786 {
8787 if ( *v5 )
8788 {
8789 result = 9 * *v5;
8790 if ( *(int *)&pPlayer->pDarkSpellbook.bIsSpellAvailable[36 * *v5 + 5] == uItemID )
8791 break;
8792 }
8793 ++v4;
8794 ++v5;
8795 if ( v4 >= 126 )
8796 {
8797 v6 = 0;
8798 v7 = (bool *)&pPlayer->pEquipment;
8799 while ( 1 )
8800 {
8801 result = *v7;
8802 if ( *v7 )
8803 {
8804 result *= 9;
8805 if ( *(int *)&pPlayer->pDarkSpellbook.bIsSpellAvailable[4 * result + 5] == uItemID )
8806 break;
8807 }
8808 ++v6;
8809 ++v7;
8810 if ( v6 >= 16 )
8811 {
8812 LOBYTE(result) = 0;
8813 return result;
8814 }
8815 }
8816 break;
8817 }
8818 }
8819 }
8820 LOBYTE(result) = 1;
8821 return result;
8822 }
8823
8824 //----- (0043EE77) --------------------------------------------------------
8825 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
8826 {
8827 bool result; // eax@0
8828 Player *v2; // edx@3
8829 int v3; // ecx@3
8830 Player **pPlayers; // esi@8
8831 unsigned int v5; // ecx@8
8832 Player *v6; // edx@9
8833
8834 if ( a1 < 1 || a1 > 4 )
8835 {
8836 if ( !a1 )
8837 {
8838 pPlayers = &::pPlayers[1];
8839 v5 = 604;
8840 while ( 1 )
8841 {
8842 result = sub_43EE15_player_has_item(v5, *pPlayers, 0);
8843 if ( !result )
8844 break;
8845 result = v6->pEquipment.uBody;
8846 if ( !result )
8847 break;
8848 result *= 9;
8849 if ( *(int *)&v6->pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
8850 break;
8851 ++pPlayers;
8852 if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
8853 goto LABEL_13;
8854 }
8855 }
8856 goto LABEL_6;
8857 }
8858 result = sub_43EE15_player_has_item(604u, ::pPlayers[a1], 0);
8859 if ( !result
8860 || (result = v2->pEquipment.uBody) == 0
8861 || (result *= 9, *(int *)&v2->pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
8862 {
8863 LABEL_6:
8864 LOBYTE(result) = 0;
8865 return result;
8866 }
8867 LABEL_13:
8868 LOBYTE(result) = 1;
8869 return result;
8870 }
8871 // A750D8: using guessed type __int64 qword_A750D8;
8872
8873 //----- (0043EF2B) --------------------------------------------------------
8874 void __fastcall WetsuitOn(unsigned int uPlayerID)
8875 {
8876 unsigned int v1; // ebx@1
8877 Player **v2; // esi@2
8878 enum CHARACTER_RACE v3; // edi@2
8879 signed int v4; // eax@2
8880 int v5; // ecx@5
8881 unsigned __int8 v6; // al@7
8882 char pContainer[20]; // [sp+4h] [bp-1Ch]@7
8883 unsigned int v8; // [sp+18h] [bp-8h]@1
8884 int v9; // [sp+1Ch] [bp-4h]@7
8885
8886 v1 = uPlayerID - 1;
8887 v8 = uPlayerID;
8888 if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
8889 {
8890 v2 = &pPlayers[uPlayerID];
8891 v3 = (*v2)->GetRace();
8892 v4 = (*v2)->GetSexByVoice();
8893 if ( v3 && v3 != 1 && v3 != 2 )
8894 v5 = (v4 != 0) + 3;
8895 else
8896 v5 = (v4 != 0) + 1;
8897 v9 = v5;
8898 wsprintfA(pContainer, "pc23v%dBod", v5);
8899 papredoll_dbods[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8900 wsprintfA(pContainer, "pc23v%dlad", v9);
8901 papredoll_dlads[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8902 wsprintfA(pContainer, "pc23v%dlau", v9);
8903 papredoll_dlaus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8904 wsprintfA(pContainer, "pc23v%drh", v9);
8905 papredoll_drhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8906 wsprintfA(pContainer, "pc23v%dlh", v9);
8907 papredoll_dlhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8908 wsprintfA(pContainer, "pc23v%dlhu", v9);
8909 papredoll_dlhus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8910 v6 = pPlayers[v1 + 1]->uFace;
8911 if ( v6 == 12 || v6 == 13 )
8912 papredoll_dbrds[pPlayers[v8]->uFace] = 0;
8913 papredoll_flying_feet[pPlayers[v8]->uFace] = 0;
8914 IsPlayerWearingWatersuit[v8] = 1;
8915 }
8916 }
8917
8918 //----- (0043F0BD) --------------------------------------------------------
8919 unsigned int __fastcall WetsuitOff(unsigned int uPlayerID)
8920 {
8921 unsigned int result; // eax@1
8922 Player **v2; // edi@2
8923 unsigned int v3; // ebx@2
8924 int v4; // ebx@2
8925 char v5; // al@2
8926 char pContainer[20]; // [sp+0h] [bp-18h]@4
8927 unsigned int v7; // [sp+14h] [bp-4h]@1
8928
8929 result = uPlayerID - 1;
8930 v7 = uPlayerID;
8931 if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
8932 {
8933 v2 = &pPlayers[uPlayerID];
8934 v3 = uPlayerID - 1;
8935 papredoll_dbods[v3] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8936 papredoll_dlads[v3] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8937 papredoll_dlaus[v3] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8938 papredoll_drhs[v3] = pIcons_LOD->LoadTexture(drh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8939 papredoll_dlhs[v3] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8940 papredoll_dlhus[v3] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[(*v2)->uFace], TEXTURE_16BIT_PALETTE);
8941 v4 = (int)&(*v2)->uFace;
8942 v5 = *(char *)v4;
8943 if ( *(char *)v4 == 12 || v5 == 13 )
8944 {
8945 wsprintfA(pContainer, "pc%02dbrd", v5 + 1);
8946 v4 = (int)&(*v2)->uFace;
8947 papredoll_dbrds[*(char *)v4] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8948 }
8949 wsprintfA(pContainer, "item281pc%02d", *(char *)v4 + 1);
8950 papredoll_flying_feet[(*v2)->uFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
8951 result = v7;
8952 IsPlayerWearingWatersuit[v7] = 0;
8953 }
8954 return result;
8955 }
8956
8957
8958 //----- (0043F333) --------------------------------------------------------
8959 int stru170::RenderWalls()
8960 {
8961 signed int result; // eax@1
8962 unsigned __int8 v2; // zf@1
8963 unsigned __int8 v3; // sf@1
8964 stru170_stru0 *v4; // edx@2
8965 int v5; // eax@3
8966 int v6; // ebx@3
8967 char *v7; // esi@4
8968 signed int v8; // [sp+0h] [bp-4h]@1
8969
8970 result = 0;
8971 v2 = this->std__vector_000FA8 == 0;
8972 v3 = (this->std__vector_000FA8 & 0x80000000u) != 0;
8973 this->field_53730 = 0;
8974 v8 = 0;
8975 if ( !(v3 | v2) )
8976 {
8977 v4 = this->field_FA8;
8978 do
8979 {
8980 v5 = this->field_53730;
8981 v6 = 0;
8982 if ( v5 <= 0 )
8983 {
8984 LABEL_7:
8985 this->pSectorIDs_toDrawDecorationsFrom[v5] = v4->uSectorID;
8986 ++this->field_53730;
8987 }
8988 else
8989 {
8990 v7 = (char *)this->pSectorIDs_toDrawDecorationsFrom;
8991 while ( *(short *)v7 != v4->uSectorID )
8992 {
8993 ++v6;
8994 v7 += 2;
8995 if ( v6 >= v5 )
8996 goto LABEL_7;
8997 }
8998 }
8999 ++v8;
9000 ++v4;
9001 result = v8;
9002 }
9003 while ( v8 < (signed int)this->std__vector_000FA8 );
9004 }
9005 return result;
9006 }
9007
9008
9009 //----- (0043F515) --------------------------------------------------------
9010 void __cdecl MessWithBillboards_BLV()
9011 {
9012 signed int v0; // edi@1
9013 char *v1; // esi@2
9014
9015 v0 = 0;
9016 if ( (signed int)uNumBillboardsToDraw > 0 )
9017 {
9018 v1 = (char *)&pBillboardRenderList[0].field_2A;
9019 do
9020 {
9021 if ( *(v1 - 12) & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !*((short *)v1 - 7) )
9022 *(short *)v1 = 0;
9023 else
9024 *(short *)v1 = sub_43F55F((RenderBillboard *)(v1 - 42), -1);
9025 ++v0;
9026 v1 += 52;
9027 }
9028 while ( v0 < (signed int)uNumBillboardsToDraw );
9029 }
9030 }
9031
9032 //----- (0043F55F) --------------------------------------------------------
9033 signed int __fastcall sub_43F55F(RenderBillboard *a1, signed int a2)
9034 {
9035 RenderBillboard *v2; // eax@1
9036 signed int v3; // ecx@2
9037 float v4; // ST08_4@6
9038 float v5; // ST04_4@6
9039 float v6; // ST00_4@6
9040
9041 v2 = a1;
9042 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
9043 {
9044 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
9045 }
9046 else
9047 {
9048 if ( a2 == -1 )
9049 v3 = a1->field_2A;
9050 else
9051 v3 = a2;
9052 }
9053 v4 = (double)v2->field_24;
9054 v5 = (double)v2->field_22;
9055 v6 = (double)v2->field_20;
9056 return sub_43F5C8(v3, v2->uIndoorSectorID, v6, v5, v4);
9057 }
9058
9059 //----- (0043F5C8) --------------------------------------------------------
9060 signed int __fastcall sub_43F5C8(signed int a1, int a2, float a3, float a4, float a5)
9061 {
9062 int v5; // esi@1
9063 signed int v6; // edi@1
9064 char *v7; // ebx@2
9065 int v8; // eax@6
9066 int v9; // ebx@6
9067 unsigned int v10; // ecx@6
9068 unsigned int v11; // edx@9
9069 unsigned int v12; // edx@11
9070 signed int v13; // ecx@12
9071 BLVSector *v14; // esi@17
9072 int v15; // ecx@17
9073 BLVLightMM7 *v16; // esi@20
9074 int v17; // ebx@21
9075 int v18; // eax@24
9076 int v19; // ebx@24
9077 unsigned int v20; // ecx@24
9078 int v21; // edx@25
9079 unsigned int v22; // edx@27
9080 unsigned int v23; // edx@29
9081 signed int v24; // ecx@30
9082 char *v25; // esi@34
9083 int v26; // ebx@35
9084 int v27; // eax@38
9085 int v28; // ebx@38
9086 unsigned int v29; // ecx@38
9087 int v30; // edx@39
9088 unsigned int v31; // edx@41
9089 unsigned int v32; // edx@43
9090 signed int v33; // ecx@44
9091 int v35; // [sp+Ch] [bp-18h]@4
9092 BLVSector *v36; // [sp+Ch] [bp-18h]@17
9093 int v37; // [sp+Ch] [bp-18h]@37
9094 int v38; // [sp+10h] [bp-14h]@5
9095 int v39; // [sp+10h] [bp-14h]@23
9096 int v40; // [sp+10h] [bp-14h]@36
9097 int v41; // [sp+14h] [bp-10h]@3
9098 int v42; // [sp+14h] [bp-10h]@22
9099 unsigned int v43; // [sp+18h] [bp-Ch]@12
9100 unsigned int v44; // [sp+18h] [bp-Ch]@30
9101 unsigned int v45; // [sp+18h] [bp-Ch]@44
9102 char *v46; // [sp+1Ch] [bp-8h]@2
9103 int v47; // [sp+1Ch] [bp-8h]@17
9104 int v48; // [sp+20h] [bp-4h]@1
9105 int v49; // [sp+20h] [bp-4h]@17
9106 int v50; // [sp+20h] [bp-4h]@33
9107
9108 v48 = 0;
9109 v5 = a2;
9110 v6 = a1;
9111 if ( uNumMobileLightsApplied > 0 )
9112 {
9113 v7 = (char *)&pMobileLights[0].uRadius;
9114 v46 = (char *)&pMobileLights[0].uRadius;
9115 do
9116 {
9117 v41 = abs((signed __int64)((double)*((short *)v7 - 3) - a3));
9118 if ( v41 <= *(short *)v7 )
9119 {
9120 v35 = abs((signed __int64)((double)*((short *)v7 - 2) - a4));
9121 if ( v35 <= *(short *)v7 )
9122 {
9123 v38 = abs((signed __int64)((double)*((short *)v7 - 1) - a5));
9124 if ( v38 <= *(short *)v7 )
9125 {
9126 v8 = v41;
9127 v9 = v35;
9128 v10 = v38;
9129 if ( v41 < v35 )
9130 {
9131 v8 = v35;
9132 v9 = v41;
9133 }
9134 if ( v8 < v38 )
9135 {
9136 v11 = v8;
9137 v8 = v38;
9138 v10 = v11;
9139 }
9140 if ( v9 < (signed int)v10 )
9141 {
9142 v12 = v10;
9143 v10 = v9;
9144 v9 = v12;
9145 }
9146 v43 = ((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8;
9147 v13 = *(short *)v46;
9148 if ( (signed int)v43 < v13 )
9149 v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
9150 v7 = v46;
9151 }
9152 }
9153 }
9154 ++v48;
9155 v7 += 18;
9156 v46 = v7;
9157 }
9158 while ( v48 < uNumMobileLightsApplied );
9159 }
9160 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
9161 {
9162 v14 = &pIndoor->pSectors[v5];
9163 v15 = 0;
9164 v49 = 0;
9165 v36 = v14;
9166 v47 = v14->uNumLights;
9167 if ( v14->uNumLights > 0 )
9168 {
9169 while ( 1 )
9170 {
9171 v16 = &pIndoor->pLights[*(&v14->pLights->vPosition.x + v15)];
9172 if ( !(v16->uAtributes & 8) )
9173 {
9174 v17 = abs((signed __int64)((double)v16->vPosition.x - a3));
9175 if ( v17 <= v16->uRadius )
9176 {
9177 v42 = abs((signed __int64)((double)v16->vPosition.y - a4));
9178 if ( v42 <= v16->uRadius )
9179 {
9180 v39 = abs((signed __int64)((double)v16->vPosition.z - a5));
9181 if ( v39 <= v16->uRadius )
9182 {
9183 v18 = v17;
9184 v19 = v42;
9185 v20 = v39;
9186 if ( v18 < v42 )
9187 {
9188 v21 = v18;
9189 v18 = v42;
9190 v19 = v21;
9191 }
9192 if ( v18 < v39 )
9193 {
9194 v22 = v18;
9195 v18 = v39;
9196 v20 = v22;
9197 }
9198 if ( v19 < (signed int)v20 )
9199 {
9200 v23 = v20;
9201 v20 = v19;
9202 v19 = v23;
9203 }
9204 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
9205 v24 = v16->uRadius;
9206 if ( (signed int)v44 < v24 )
9207 v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
9208 }
9209 }
9210 }
9211 }
9212 v15 = v49++ + 1;
9213 if ( v49 >= v47 )
9214 break;
9215 v14 = v36;
9216 }
9217 }
9218 }
9219 v50 = 0;
9220 if ( uNumStationaryLightsApplied > 0 )
9221 {
9222 v25 = (char *)&pStationaryLights[0].uRadius;
9223 do
9224 {
9225 v26 = abs((signed __int64)((double)*((short *)v25 - 3) - a3));
9226 if ( v26 <= *(short *)v25 )
9227 {
9228 v40 = abs((signed __int64)((double)*((short *)v25 - 2) - a4));
9229 if ( v40 <= *(short *)v25 )
9230 {
9231 v37 = abs((signed __int64)((double)*((short *)v25 - 1) - a5));
9232 if ( v37 <= *(short *)v25 )
9233 {
9234 v27 = v26;
9235 v28 = v40;
9236 v29 = v37;
9237 if ( v27 < v40 )
9238 {
9239 v30 = v27;
9240 v27 = v40;
9241 v28 = v30;
9242 }
9243 if ( v27 < v37 )
9244 {
9245 v31 = v27;
9246 v27 = v37;
9247 v29 = v31;
9248 }
9249 if ( v28 < (signed int)v29 )
9250 {
9251 v32 = v29;
9252 v29 = v28;
9253 v28 = v32;
9254 }
9255 v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
9256 v33 = *(short *)v25;
9257 if ( (signed int)v45 < v33 )
9258 v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
9259 }
9260 }
9261 }
9262 ++v50;
9263 v25 += 12;
9264 }
9265 while ( v50 < uNumStationaryLightsApplied );
9266 }
9267 if ( v6 <= 31 )
9268 {
9269 if ( v6 < 0 )
9270 v6 = 0;
9271 }
9272 else
9273 {
9274 v6 = 31;
9275 }
9276 return v6;
9277 }
9278 // 519AB4: using guessed type int uNumStationaryLightsApplied;
9279
9280 //----- (00406051) --------------------------------------------------------
9281 __int16 stru262_TurnBased::StartTurn()
9282 {
9283 stru262_TurnBased *v1; // esi@1
9284 int v2; // ecx@1
9285 int v3; // ebx@1
9286 char *v4; // edi@1
9287 int v5; // eax@4
9288 int v6; // eax@12
9289 char *v7; // eax@15
9290 TurnBased_QueueElem *v8; // edi@17
9291 unsigned int v9; // edx@23
9292 char *v10; // eax@26
9293 int v11; // eax@30
9294 int v12; // ebx@30
9295 char *v13; // edi@31
9296 int v15; // [sp+Ch] [bp-10h]@5
9297 TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3
9298 int v17; // [sp+14h] [bp-8h]@2
9299 int v18; // [sp+14h] [bp-8h]@16
9300 signed int v19; // [sp+18h] [bp-4h]@1
9301 int v20; // [sp+18h] [bp-4h]@14
9302
9303 v1 = this;
9304 v2 = 0;
9305 v19 = 0;
9306 v3 = v1->uActorQueueSize;
9307 v1->field_1C = 0;
9308 v4 = (char *)&v1->pQueue[v3].field_4;
9309 do
9310 {
9311 v17 = v2;
9312 if ( v1->uActorQueueSize <= v2 )
9313 goto LABEL_11;
9314 v16 = v1->pQueue;
9315 while ( 1 )
9316 {
9317 v5 = v16->uPackedID;
9318 if ( (v16->uPackedID & 7) == 4 )
9319 break;
9320 LABEL_8:
9321 ++v17;
9322 ++v16;
9323 if ( v17 >= v1->uActorQueueSize )
9324 goto LABEL_11;
9325 }
9326 v15 = v5 >> 3;
9327 if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 )
9328 {
9329 v2 = 0;
9330 goto LABEL_8;
9331 }
9332 v2 = 0;
9333 LABEL_11:
9334 if ( v17 == v1->uActorQueueSize )
9335 {
9336 *(int *)v4 = 100;
9337 v6 = 8 * v19;
9338 LOBYTE(v6) = 8 * v19 | 4;
9339 *((int *)v4 + 2) = v2;
9340 *((int *)v4 - 1) = v6;
9341 *((int *)v4 + 1) = v2;
9342 ++v3;
9343 v4 += 16;
9344 }
9345 ++v19;
9346 }
9347 while ( v19 < 4 );
9348 v1->uActorQueueSize = v3;
9349 v20 = v2;
9350 if ( ai_arrays_size > v2 )
9351 {
9352 v7 = (char *)&v1->pQueue[v3].field_4;
9353 do
9354 {
9355 v18 = v2;
9356 if ( v1->uActorQueueSize > v2 )
9357 {
9358 v8 = v1->pQueue;
9359 do
9360 {
9361 if ( (v8->uPackedID & 7) == 3 && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 )
9362 break;
9363 ++v18;
9364 ++v8;
9365 }
9366 while ( v18 < v1->uActorQueueSize );
9367 v2 = 0;
9368 }
9369 if ( v18 == v1->uActorQueueSize )
9370 {
9371 v9 = ai_array_4F7DB0_actor_ids[v20];
9372 *(int *)v7 = 1;
9373 *((int *)v7 + 2) = v2;
9374 *((int *)v7 - 1) = 8 * v9 | 3;
9375 *((int *)v7 + 1) = v2;
9376 ++v3;
9377 v7 += 16;
9378 }
9379 ++v20;
9380 }
9381 while ( v20 < ai_arrays_size );
9382 }
9383 ++v1->field_0;
9384 v1->uActorQueueSize = v3;
9385 v1->field_10 = 100;
9386 if ( v3 > 0 )
9387 {
9388 v10 = (char *)&v1->pQueue[0].field_4;
9389 do
9390 {
9391 if ( *(int *)v10 <= 0 )
9392 *(int *)v10 = 100;
9393 ++v2;
9394 v10 += 16;
9395 }
9396 while ( v2 < v1->uActorQueueSize );
9397 }
9398 LOWORD(v11) = v1->_4063A1();
9399 v12 = 0;
9400 if ( v1->uActorQueueSize > 0 )
9401 {
9402 v13 = (char *)&v1->pQueue[0].field_4;
9403 do
9404 {
9405 v11 = *((int *)v13 - 1) & 7;
9406 if ( (char)v11 == 4 )
9407 break;
9408 if ( *(int *)v13 > 0 )
9409 break;
9410 LOWORD(v11) = v1->_40680F(v12++);
9411 v13 += 16;
9412 }
9413 while ( v12 < v1->uActorQueueSize );
9414 }
9415 return v11;
9416 }
9417 // 4F75D8: using guessed type int ai_arrays_size;
9418
9419 //----- (004061CA) --------------------------------------------------------
9420 void stru262_TurnBased::NextTurn()
9421 {
9422 stru262_TurnBased *v1; // esi@1
9423 TurnBased_QueueElem *v2; // ebp@1
9424 int v3; // ebx@1
9425 int v4; // edi@7
9426 Actor *v5; // eax@9
9427 int v6; // ecx@9
9428 signed int v7; // ebx@17
9429 int v8; // ebp@27
9430 TurnBased_QueueElem *v9; // edi@28
9431 int v10; // ecx@30
9432 unsigned __int16 v11; // ax@30
9433 signed int v12; // edx@35
9434 signed int v13; // [sp+10h] [bp-4h]@7
9435
9436 v1 = this;
9437 _404544();
9438 v2 = v1->pQueue;
9439 v3 = 0;
9440 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
9441 uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1;
9442 else
9443 uActiveCharacter = 0;
9444 viewparams->bRedrawGameUI = 1;
9445 if ( v1->field_1C )
9446 {
9447 pTurnEngine->field_18 |= 2u;
9448 return;
9449 }
9450 pTurnEngine->field_18 &= 0xFFFFFFFDu;
9451 if ( v1->pQueue[0].field_4 <= 0 )
9452 return;
9453 v4 = 0;
9454 v13 = 0;
9455 if ( v1->uActorQueueSize <= 0 )
9456 goto LABEL_27;
9457 do
9458 {
9459 if ( (v2->uPackedID & 7) != 4 )
9460 {
9461 v5 = &pActors[v2->uPackedID >> 3];
9462 LOWORD(v6) = v5->uAIState;
9463 if ( (short)v6 == 4
9464 || (short)v6 == 8
9465 || (short)v6 == 2
9466 || (short)v6 == 3
9467 || (short)v6 == 12
9468 || (short)v6 == 13
9469 || (short)v6 == 18
9470 || (short)v6 == 17 )
9471 {
9472 v7 = v5->uCurrentActionLength;
9473 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
9474 if ( (signed int)v5->uCurrentActionTime < v7 )
9475 {
9476 v13 = 1;
9477 LABEL_19:
9478 v3 = 0;
9479 goto LABEL_20;
9480 }
9481 v6 = (signed __int16)v6;
9482 if ( (signed __int16)v6 == 4 )
9483 {
9484 v3 = 0;
9485 v5->uAIState = 5;
9486 v5->uCurrentActionTime = 0;
9487 v5->uCurrentActionLength = 0;
9488 v5->UpdateAnimation();
9489 }
9490 else
9491 {
9492 if ( v6 != 8 )
9493 goto LABEL_19;
9494 v3 = 0;
9495 Actor::_403F58(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0);
9496 }
9497 }
9498 }
9499 LABEL_20:
9500 ++v4;
9501 ++v2;
9502 }
9503 while ( v4 < v1->uActorQueueSize );
9504 if ( v13 != v3 )
9505 {
9506 v1->field_18 |= 1u;
9507 return;
9508 }
9509 LABEL_27:
9510 v1->field_18 &= 0xFFFFFFFEu;
9511 v8 = 0;
9512 if ( v1->uActorQueueSize > v3 )
9513 {
9514 v9 = v1->pQueue;
9515 do
9516 {
9517 if ( (v9->uPackedID & 7) != 4 )
9518 {
9519 v10 = v9->uPackedID >> 3;
9520 v11 = pActors[v10].uAIState;
9521 if ( v11 != 5 )
9522 {
9523 if ( v11 != 4 && v11 != 11 && v11 != 19 )
9524 {
9525 if ( v11 != 17 )
9526 {
9527 v12 = dword_4F6E08[v10];
9528 v9->uActionLength = v3;
9529 Actor::_403F58(v10, v12, 32, (AIDirection *)v3);
9530 }
9531 }
9532 }
9533 }
9534 ++v8;
9535 ++v9;
9536 }
9537 while ( v8 < v1->uActorQueueSize );
9538 }
9539 v1->field_4 = 3;
9540 pParty->uTimePlayed += __PAIR__(v3, 213);
9541 _494035_timed_effects__water_walking_damage__etc();
9542 v1->uActionPointsLeft = 130;
9543 }
9544
9545 //----- (004063A1) --------------------------------------------------------
9546 int stru262_TurnBased::_4063A1()
9547 {
9548 stru262_TurnBased *v1; // esi@1
9549 int v2; // ebp@1
9550 signed int result; // eax@1
9551 int v4; // edx@1
9552 int v5; // edx@3
9553 int v6; // edi@4
9554 int v7; // ecx@5
9555 Actor *v8; // ecx@11
9556 unsigned __int16 v9; // dx@12
9557 int v10; // edi@16
9558 int v11; // edx@17
9559 char v12; // zf@18
9560
9561 v1 = this;
9562 _404544();
9563 v2 = (int)&v1->pQueue[0].field_4;
9564 result = 1;
9565 viewparams->bRedrawGameUI = 1;
9566 v4 = v1->pQueue[0].field_4;
9567 if ( v4 )
9568 {
9569 if ( (v1->pQueue[0].uPackedID & 7) == 4 )
9570 {
9571 v5 = v1->uActorQueueSize;
9572 while ( 1 )
9573 {
9574 v6 = 0;
9575 if ( v5 > 0 )
9576 {
9577 v7 = (int)&v1->pQueue[0].field_4;
9578 do
9579 {
9580 --*(int *)v7;
9581 v5 = v1->uActorQueueSize;
9582 ++v6;
9583 v7 += 16;
9584 }
9585 while ( v6 < v5 );
9586 }
9587 --v1->field_10;
9588 if ( v1->field_10 <= 0 )
9589 break;
9590 if ( !*(int *)v2 )
9591 goto LABEL_9;
9592 }
9593 LABEL_24:
9594 result = 1;
9595 }
9596 else
9597 {
9598 v8 = &pActors[v1->pQueue[0].uPackedID >> 3];
9599 if ( v4 > 0 )
9600 {
9601 do
9602 {
9603 v9 = v8->uAIState;
9604 if ( v9 == 5 )
9605 break;
9606 if ( v9 == 4 || v9 == 19 || v9 == 11 )
9607 break;
9608 v10 = 0;
9609 if ( v1->uActorQueueSize > 0 )
9610 {
9611 v11 = (int)&v1->pQueue[0].field_4;
9612 do
9613 {
9614 v12 = (*(int *)v11)-- == 1;
9615 if ( v12 )
9616 *(int *)(v11 + 4) = 0;
9617 ++v10;
9618 v11 += 16;
9619 }
9620 while ( v10 < v1->uActorQueueSize );
9621 }
9622 --v1->field_10;
9623 if ( v1->field_10 <= 0 )
9624 goto LABEL_24;
9625 }
9626 while ( *(int *)v2 > 0 );
9627 }
9628 LABEL_9:
9629 result = 0;
9630 }
9631 }
9632 return result;
9633 }
9634
9635 //----- (00406457) --------------------------------------------------------
9636 int stru262_TurnBased::_406457(int a2)
9637 {
9638 stru262_TurnBased *v2; // esi@1
9639 signed int v3; // eax@1
9640 signed int v4; // ecx@2
9641 char *v5; // edx@2
9642 signed int v6; // eax@2
9643 int result; // eax@11
9644 int v8; // edx@13
9645 int v9; // ecx@14
9646 char v10; // zf@15
9647
9648 v2 = this;
9649 v3 = *(&this->field_0 + 4 * (a2 + 2));
9650 if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == 4 )
9651 {
9652 v4 = v3 >> 3;
9653 v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3];
9654 v6 = *(int *)v5;
9655 if ( *(int *)v5 )
9656 *(int *)v5 = 0;
9657 else
9658 v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0);
9659 if ( v6 < 30 )
9660 v6 = 30;
9661 }
9662 else
9663 {
9664 v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime;
9665 }
9666 v2->pQueue[a2].field_4 = v6;
9667 v2->_404544();
9668 if ( (v2->pQueue[0].uPackedID & 7) == 4 )
9669 uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1;
9670 else
9671 uActiveCharacter = 0;
9672 result = (int)&v2->pQueue[0].field_4;
9673 viewparams->bRedrawGameUI = 1;
9674 while ( *(int *)result > 0 )
9675 {
9676 if ( v2->field_10 <= 0 )
9677 break;
9678 v8 = 0;
9679 if ( v2->uActorQueueSize > 0 )
9680 {
9681 v9 = (int)&v2->pQueue[0].field_4;
9682 do
9683 {
9684 v10 = (*(int *)v9)-- == 1;
9685 if ( v10 )
9686 *(int *)(v9 + 4) = 0;
9687 ++v8;
9688 v9 += 16;
9689 }
9690 while ( v8 < v2->uActorQueueSize );
9691 }
9692 --v2->field_10;
9693 if ( v2->field_10 <= 0 )
9694 break;
9695 }
9696 return result;
9697 }
9698
9699 //----- (0040652A) --------------------------------------------------------
9700 void stru262_TurnBased::_40652A()
9701 {
9702 char *v1; // edx@2
9703 Actor *v2; // eax@5
9704 unsigned __int16 v3; // si@5
9705 unsigned int v4; // esi@8
9706 int v5; // [sp+Ch] [bp-4h]@1
9707
9708 v5 = 0;
9709 if ( this->uActorQueueSize > 0 )
9710 {
9711 v1 = (char *)&this->pQueue[0].field_4;
9712 do
9713 {
9714 if ( !*(int *)v1 )
9715 {
9716 if ( (*(v1 - 4) & 7) == 4 )
9717 return;
9718 v2 = &pActors[*((int *)v1 - 1) >> 3];
9719 v3 = v2->uAIState;
9720 if ( !v3 || v3 == 9 || v3 == 7 )
9721 {
9722 v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime;
9723 *(int *)v1 = v4;
9724 if ( (signed __int64)v2->pActorBuffs[7].uExpireTime > 0 )
9725 *(int *)v1 = 2 * v4;
9726 }
9727 }
9728 ++v5;
9729 v1 += 16;
9730 }
9731 while ( v5 < this->uActorQueueSize );
9732 }
9733 }
9734
9735 //----- (004065B0) --------------------------------------------------------
9736 __int16 stru262_TurnBased::_4065B0()
9737 {
9738 stru262_TurnBased *v1; // esi@1
9739 signed int v2; // eax@1
9740 int v3; // ebx@6
9741 int v4; // edi@7
9742 unsigned int v5; // edi@14
9743
9744 v1 = this;
9745 LOWORD(v2) = _404544();
9746 if ( v1->pQueue[0].field_4 <= 0
9747 || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != 4) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2),
9748 viewparams->bRedrawGameUI = 1,
9749 v1->pQueue[0].field_4 <= 0) )
9750 {
9751 v3 = 0;
9752 if ( v1->uActorQueueSize > 0 )
9753 {
9754 v4 = (int)v1->pQueue;
9755 do
9756 {
9757 v2 = *(int *)v4;
9758 if ( (*(char *)v4 & 7) == 4 || *(int *)(v4 + 4) > 0 )
9759 break;
9760 if ( *(int *)(v4 + 8) <= 0 )
9761 {
9762 LOWORD(v2) = v2 & 3;
9763 if ( (char)v2 == 3 )
9764 LOWORD(v2) = v1->_40680F(v3);
9765 }
9766 ++v3;
9767 v4 += 16;
9768 }
9769 while ( v3 < v1->uActorQueueSize );
9770 }
9771 }
9772 v5 = 0;
9773 if ( v1->uActorQueueSize > 0 )
9774 {
9775 do
9776 LOWORD(v2) = v1->_406648(v5++);
9777 while ( (signed int)v5 < v1->uActorQueueSize );
9778 }
9779 return v2;
9780 }
9781
9782 //----- (00406648) --------------------------------------------------------
9783 __int16 stru262_TurnBased::_406648(unsigned int a2)
9784 {
9785 TurnBased_QueueElem *v1; // ecx@1
9786 int v3; // eax@1
9787 unsigned int v4; // ebx@2
9788 Actor *v5; // esi@2
9789 signed int v6; // edi@5
9790 int v7; // ecx@6
9791 int v8; // eax@6
9792 int v9; // eax@7
9793 int v10; // eax@8
9794 int v11; // eax@9
9795 int v12; // eax@10
9796 int v13; // eax@11
9797 int v14; // eax@14
9798 unsigned int v15; // ecx@14
9799 unsigned int v16; // edx@14
9800 int v17; // eax@17
9801 int v18; // eax@20
9802 char v19; // al@24
9803 unsigned int v21; // [sp-8h] [bp-50h]@16
9804 int v22; // [sp-8h] [bp-50h]@17
9805 AIDirection *v23; // [sp-4h] [bp-4Ch]@14
9806 unsigned int v24; // [sp-4h] [bp-4Ch]@17
9807 char v25; // [sp-4h] [bp-4Ch]@20
9808 AIDirection a3; // [sp+Ch] [bp-3Ch]@2
9809 AIDirection a4; // [sp+28h] [bp-20h]@2
9810 TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1
9811 unsigned int a2a; // [sp+50h] [bp+8h]@2
9812
9813 v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
9814 v28 = v1;
9815 v3 = v1->uPackedID;
9816 if ( (v1->uPackedID & 7) != 4 )
9817 {
9818 v4 = v3 >> 3; // turn based only stuff
9819 a2a = dword_4F6E08[v3 >> 3];
9820 memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3));
9821 memcpy(&a4, &a3, sizeof(a4));
9822 v5 = &pActors[v3 >> 3];
9823 LOWORD(v3) = v5->uAIState;
9824 if ( (short)v3 != Dead )
9825 {
9826 if ( (short)v3 != Disabled )
9827 {
9828 if ( (short)v3 != Removed )
9829 {
9830 v6 = v5->uCurrentActionLength;
9831 v5->uCurrentActionTime += pEventTimer->uTimeElapsed;
9832 if ( (signed int)v5->uCurrentActionTime >= v6 )
9833 {
9834 v7 = (signed __int16)v3;
9835 v8 = (signed __int16)v3 - 2;
9836 if ( !v8 )
9837 {
9838 v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4);
9839 stru_50FE08.Add(
9840 v28->uPackedID,
9841 5120,
9842 v5->vPosition.x,
9843 v5->vPosition.y,
9844 v5->vPosition.z + ((signed int)v5->uActorHeight >> 1),
9845 v19,
9846 1);
9847 goto LABEL_25;
9848 }
9849 v9 = v8 - 1;
9850 if ( v9 )
9851 {
9852 v10 = v9 - 1;
9853 if ( !v10 )
9854 goto LABEL_21;
9855 v11 = v10 - 4;
9856 if ( !v11 )
9857 goto LABEL_25;
9858 v12 = v11 - 4;
9859 if ( v12 )
9860 {
9861 v13 = v12 - 1;
9862 if ( v13 )
9863 {
9864 if ( v13 != Dead )
9865 {
9866 if ( v7 != 4 )
9867 {
9868 v14 = rand();
9869 v15 = v4;
9870 v23 = &a4;
9871 v16 = a2a;
9872 if ( !(v14 % 2) )
9873 {
9874 LOWORD(v3) = Actor::_402F87(v4, a2a, &a4);
9875 return v3;
9876 }
9877 v21 = 64;
9878 LABEL_26:
9879 LOWORD(v3) = Actor::_403EB6(v15, v16, v21, v23);
9880 return v3;
9881 }
9882 LABEL_21:
9883 v5->uCurrentActionTime = 0;
9884 v5->uCurrentActionLength = 0;
9885 v5->uAIState = Dead;
9886 return pActors[v4].UpdateAnimation();
9887 }
9888 v24 = v5->pMonsterInfo.uSpellSkillAndMastery2;
9889 v22 = 3;
9890 v17 = v5->pMonsterInfo.uSpell2ID;
9891 }
9892 else
9893 {
9894 v24 = v5->pMonsterInfo.uSpellSkillAndMastery1;
9895 v22 = 2;
9896 v17 = v5->pMonsterInfo.uSpell1ID;
9897 }
9898 Actor::_404AC7(v4, &a4, v17, v22, v24);
9899 LABEL_25:
9900 v16 = a2a;
9901 v23 = &a4;
9902 v21 = 0;
9903 v15 = v4;
9904 goto LABEL_26;
9905 }
9906 v18 = v5->pMonsterInfo.uMissleAttack2Type;
9907 v25 = 1;
9908 }
9909 else
9910 {
9911 v18 = v5->pMonsterInfo.uMissleAttack1Type;
9912 v25 = 0;
9913 }
9914 Actor::_404874(v4, &a4, v18, v25);
9915 goto LABEL_25;
9916 }
9917 }
9918 }
9919 }
9920 }
9921 return v3;
9922 }
9923 // 50FE08: using guessed type stru298 stru_50FE08;
9924
9925 //----- (0040680F) --------------------------------------------------------
9926 __int16 stru262_TurnBased::_40680F(int a2)
9927 {
9928 TurnBased_QueueElem *v2; // eax@1
9929 TurnBased_QueueElem *v3; // eax@1
9930 TurnBased_QueueElem *v4; // edi@2
9931 Actor *v5; // ebx@2
9932 unsigned int *v6; // esi@7
9933 AIDirection *v7; // esi@10
9934 int v8; // eax@10
9935 unsigned int v9; // ecx@10
9936 signed int v10; // eax@13
9937 unsigned __int8 v11; // sf@19
9938 unsigned __int8 v12; // of@19
9939 int v13; // esi@29
9940 bool v14; // eax@29
9941 unsigned __int8 v15; // cl@33
9942 AIDirection a3; // [sp+Ch] [bp-44h]@10
9943 AIDirection v18; // [sp+28h] [bp-28h]@10
9944 int a2a; // [sp+44h] [bp-Ch]@2
9945 unsigned int v20; // [sp+48h] [bp-8h]@10
9946 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1
9947 signed int v22; // [sp+58h] [bp+8h]@10
9948
9949 v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2));
9950 v21 = v2;
9951 v2->uActionLength = 0;
9952 v3 = (TurnBased_QueueElem *)v2->uPackedID;
9953 if ( (unsigned __int8)v3 & 3 )
9954 {
9955 v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3);
9956 v4 = v3;
9957 a2a = (int)v3;
9958 v5 = &pActors[(int)v3];
9959 LOWORD(v3) = v5->uAIState;
9960 if ( (short)v3 != 5 )
9961 {
9962 if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
9963 {
9964 v6 = (unsigned int *)&dword_4F6E08[(int)v4];
9965 Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u);
9966 if ( v5->pMonsterInfo.uHostilityType && !*v6 )
9967 v5->pMonsterInfo.uHostilityType = 0;
9968 v22 = *v6;
9969 v7 = Actor::GetDirectionInfo(8 * (int)v4 | 3, *v6, &a3, 0);
9970 v8 = v5->uActorRadius;
9971 memcpy(&a3, v7, sizeof(a3));
9972 memcpy(&v18, &a3, sizeof(v18));
9973 v9 = a3.uDistance - v8;
9974 v20 = a3.uDistance - v8;
9975 if ( ((a3.uDistance - v8) & 0x80000000u) != 0 )
9976 {
9977 v9 = 0;
9978 v20 = 0;
9979 }
9980 if ( (v22 & 7) == 3 )
9981 v10 = (unsigned __int8)*(&byte_5C8D1A[89
9982 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1)
9983 / 3]
9984 + (v5->pMonsterInfo.uID - 1) / 3);
9985 else
9986 v10 = 4;
9987 if ( v10 == 1 )
9988 {
9989 if ( (double)(signed int)v20 < 307.2 )
9990 goto LABEL_25;
9991 }
9992 else
9993 {
9994 if ( v10 == 2 )
9995 {
9996 v12 = __OFSUB__(v9, 1024);
9997 v11 = ((v9 - 1024) & 0x80000000u) != 0;
9998 }
9999 else
10000 {
10001 if ( v10 == 3 )
10002 {
10003 v12 = __OFSUB__(v9, 2560);
10004 v11 = ((v9 - 2560) & 0x80000000u) != 0;
10005 }
10006 else
10007 {
10008 if ( v10 != 4 )
10009 goto LABEL_26;
10010 v12 = __OFSUB__(v9, 5120);
10011 v11 = ((v9 - 5120) & 0x80000000u) != 0;
10012 }
10013 }
10014 if ( v11 ^ v12 )
10015 {
10016 LABEL_25:
10017 v5->pMonsterInfo.uHostilityType = 4;
10018 goto LABEL_26;
10019 }
10020 }
10021 LABEL_26:
10022 if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 )
10023 {
10024 v13 = a2a;
10025 goto LABEL_47;
10026 }
10027 v13 = a2a;
10028 v14 = stru_50C198.special_ability_use_check(v5, a2a);
10029 if ( v14 == 1 )
10030 {
10031 if ( v5->pMonsterInfo.uMissleAttack2Type )
10032 {
10033 Actor::_40368B(v13, v22, &v18);
10034 goto LABEL_43;
10035 }
10036 }
10037 else
10038 {
10039 if ( v14 > 1 && v14 <= 3 )
10040 {
10041 if ( v14 == 2 )
10042 v15 = v5->pMonsterInfo.uSpell1ID;
10043 else
10044 v15 = v5->pMonsterInfo.uSpell2ID;
10045 if ( v15 )
10046 {
10047 if ( v14 == 2 )
10048 Actor::_403854(v13, v22, &v18);
10049 else
10050 Actor::_403A60(v13, v22, &v18);
10051 goto LABEL_43;
10052 }
10053 goto LABEL_44;
10054 }
10055 if ( v5->pMonsterInfo.uMissleAttack1Type )
10056 {
10057 Actor::_403476(v13, v22, &v18);
10058 LABEL_43:
10059 v3 = v21;
10060 v21->field_C = 1;
10061 LABEL_48:
10062 v3->uActionLength = v5->uCurrentActionLength;
10063 return (signed __int16)v3;
10064 }
10065 }
10066 LABEL_44:
10067 if ( (double)(signed int)v20 < 307.2 )
10068 {
10069 Actor::_403C6C(v13, v22, &v18);
10070 v3 = v21;
10071 v21->field_C = 3;
10072 goto LABEL_48;
10073 }
10074 LABEL_47:
10075 Actor::_403EB6(v13, v22, 0x40u, &v18);
10076 v3 = v21;
10077 v21->field_C = 0;
10078 goto LABEL_48;
10079 }
10080 }
10081 }
10082 return (signed __int16)v3;
10083 }
10084
10085 //----- (00406A63) --------------------------------------------------------
10086 void stru262_TurnBased::_406A63()
10087 {
10088 stru262_TurnBased *v1; // ebx@1
10089 int v2; // esi@1
10090 unsigned __int8 v3; // zf@1
10091 unsigned __int8 v4; // sf@1
10092 signed int v5; // ecx@4
10093 AIDirection a3; // [sp+8h] [bp-44h]@5
10094 AIDirection v7; // [sp+24h] [bp-28h]@5
10095 unsigned int v8; // [sp+40h] [bp-Ch]@5
10096 signed int a2; // [sp+44h] [bp-8h]@1
10097 TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
10098
10099 v1 = this;
10100 v2 = 0;
10101 this->field_8 = 64;
10102 dword_50C994 = 0;
10103 uActiveCharacter = 0;
10104 v3 = this->uActorQueueSize == 0;
10105 v4 = this->uActorQueueSize < 0;
10106 a2 = 0;
10107 if ( !(v4 | v3) )
10108 {
10109 v10 = this->pQueue;
10110 while ( 1 )
10111 {
10112 v5 = v10->uPackedID;
10113 if ( (v10->uPackedID & 7) == 3 )
10114 {
10115 v8 = dword_4F6E08[v5 >> 3];
10116 memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
10117 if ( !v1->_406D10(a2) )
10118 Actor::_403EB6(v10->uPackedID >> 3, v8, 0x20u, &v7);
10119 }
10120 ++a2;
10121 ++v10;
10122 if ( a2 >= v1->uActorQueueSize )
10123 break;
10124 v2 = 0;
10125 }
10126 }
10127 }
10128 // 50C994: using guessed type int dword_50C994;
10129
10130 //----- (00406AFE) --------------------------------------------------------
10131 void stru262_TurnBased::_406AFE()
10132 {
10133 stru262_TurnBased *v1; // edi@1
10134 TurnBased_QueueElem *v2; // ebx@2
10135 int v3; // esi@4
10136 int v4; // ecx@5
10137 AIDirection a3; // [sp+4h] [bp-48h]@5
10138 AIDirection v6; // [sp+20h] [bp-2Ch]@5
10139 stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1
10140 unsigned int v8; // [sp+40h] [bp-Ch]@4
10141 unsigned int v9; // [sp+44h] [bp-8h]@5
10142 int v10; // [sp+48h] [bp-4h]@1
10143
10144 v10 = 0;
10145 v1 = this;
10146 v7 = this;
10147 if ( this->uActorQueueSize > 0 )
10148 {
10149 v2 = this->pQueue;
10150 do
10151 {
10152 if ( (v2->uPackedID & 7) == 3 )
10153 {
10154 v3 = v2->uPackedID >> 3;
10155 v8 = v3;
10156 if ( pActors[v3].CanAct() )
10157 {
10158 v4 = v2->uPackedID;
10159 v9 = dword_4F6E08[v3];
10160 memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
10161 Actor::_403EB6(v8, v9, 0x20u, &v6);
10162 v2->field_C = 0;
10163 v2->uActionLength = 0;
10164 v1 = v7;
10165 }
10166 }
10167 ++v10;
10168 ++v2;
10169 }
10170 while ( v10 < v1->uActorQueueSize );
10171 }
10172 v1->field_4 = 2;
10173 v1->field_8 = 100;
10174 }
10175
10176 //----- (00406B9F) --------------------------------------------------------
10177 int stru262_TurnBased::_406B9F()
10178 {
10179 signed int result; // eax@1
10180 unsigned __int8 v2; // zf@1
10181 unsigned __int8 v3; // sf@1
10182 int v4; // esi@4
10183 unsigned int v5; // esi@5
10184 Actor *v6; // ebx@5
10185 unsigned __int16 v7; // cx@15
10186 AIDirection a3; // [sp+0h] [bp-50h]@15
10187 AIDirection v9; // [sp+1Ch] [bp-34h]@15
10188 signed int a1; // [sp+38h] [bp-18h]@4
10189 stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
10190 unsigned int v12; // [sp+40h] [bp-10h]@5
10191 unsigned int v13; // [sp+44h] [bp-Ch]@8
10192 TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
10193 signed int a2; // [sp+4Ch] [bp-4h]@1
10194
10195 result = 0;
10196 thisa = this;
10197 v2 = this->uActorQueueSize == 0;
10198 v3 = this->uActorQueueSize < 0;
10199 a2 = 0;
10200 if ( !(v3 | v2) )
10201 {
10202 v14 = this->pQueue;
10203 while ( 1 )
10204 {
10205 v4 = v14->uPackedID;
10206 a1 = v14->uPackedID;
10207 if ( (a1 & 7) != 4 )
10208 {
10209 v5 = v4 >> 3;
10210 v12 = v5;
10211 v6 = &pActors[v5];
10212 if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
10213 || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
10214 v13 = result;
10215 else
10216 v13 = 1;
10217 if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
10218 && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
10219 result = 1;
10220 if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) )
10221 {
10222 v13 = dword_4F6E08[v5];
10223 memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
10224 v7 = v6->uAIState;
10225 if ( v7 == 6 || v7 == 1 )
10226 {
10227 if ( (double)(signed int)v9.uDistance < 307.2 )
10228 goto LABEL_26;
10229 }
10230 v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
10231 if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
10232 {
10233 if ( v7 == 4 )
10234 {
10235 v6->uCurrentActionTime = 0;
10236 v6->uCurrentActionLength = 0;
10237 v6->uAIState = 5;
10238 v6->UpdateAnimation();
10239 }
10240 if ( !thisa->_406D10(a2) )
10241 LABEL_26:
10242 Actor::_403EB6(v12, v13, 0x20u, &v9);
10243 }
10244 }
10245 }
10246 ++a2;
10247 result = (signed int)thisa;
10248 ++v14;
10249 if ( a2 >= thisa->uActorQueueSize )
10250 break;
10251 result = 0;
10252 }
10253 }
10254 return result;
10255 }
10256
10257 //----- (00406D10) --------------------------------------------------------
10258 bool stru262_TurnBased::_406D10(signed int a2)
10259 {
10260 int v2; // ecx@1
10261 int v3; // ecx@2
10262 Actor *v4; // ebx@2
10263 unsigned __int16 v5; // dx@2
10264 int *v6; // esi@7
10265 TurnBased_QueueElem *v7; // edi@7
10266 int v8; // eax@7
10267 AIDirection *v9; // esi@10
10268 int v10; // eax@10
10269 unsigned int v11; // ecx@10
10270 unsigned __int8 v12; // al@12
10271 unsigned __int8 v13; // sf@16
10272 unsigned __int8 v14; // of@16
10273 unsigned int v15; // edx@22
10274 unsigned int v16; // ecx@23
10275 TurnBased_QueueElem *v17; // eax@25
10276 double v18; // st7@33
10277 double v19; // st6@33
10278 int v21; // [sp-8h] [bp-5Ch]@23
10279 int v22; // [sp-8h] [bp-5Ch]@26
10280 AIDirection *v23; // [sp-4h] [bp-58h]@23
10281 int v24; // [sp-4h] [bp-58h]@26
10282 AIDirection a3; // [sp+Ch] [bp-48h]@10
10283 AIDirection pDir; // [sp+28h] [bp-2Ch]@10
10284 int v27; // [sp+44h] [bp-10h]@33
10285 unsigned int v28; // [sp+48h] [bp-Ch]@10
10286 TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
10287 unsigned int uActorID; // [sp+50h] [bp-4h]@2
10288 unsigned int a2a; // [sp+5Ch] [bp+8h]@7
10289
10290 v2 = *(&this->field_0 + 4 * (a2 + 2));
10291 if ( (v2 & 7) == 4 )
10292 return 0;
10293 v3 = v2 >> 3;
10294 uActorID = v3;
10295 v4 = &pActors[v3];
10296 v5 = v4->uAIState;
10297 if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 )
10298 return 1;
10299 v6 = &dword_4F6E08[v3];
10300 v7 = &pTurnEngine->pQueue[a2];
10301 v8 = *v6;
10302 v29 = &pTurnEngine->pQueue[a2];
10303 a2a = v8;
10304 Actor::_401221(v3, &dword_4F6E08[v3], 1u);
10305 if ( v4->pMonsterInfo.uHostilityType && !*v6 )
10306 v4->pMonsterInfo.uHostilityType = 0;
10307 v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
10308 v10 = v4->uActorRadius;
10309 memcpy(&a3, v9, sizeof(a3));
10310 memcpy(&pDir, &a3, sizeof(pDir));
10311 v11 = a3.uDistance - v10;
10312 v28 = a3.uDistance - v10;
10313 if ( ((a3.uDistance - v10) & 0x80000000u) != 0 )
10314 {
10315 v11 = 0;
10316 v28 = 0;
10317 }
10318 v12 = v4->pMonsterInfo.uHostilityType;
10319 if ( v12 == 1 )
10320 {
10321 if ( (double)(signed int)v28 >= 307.2 )
10322 goto LABEL_21;
10323 LABEL_20:
10324 v4->pMonsterInfo.uHostilityType = 4;
10325 goto LABEL_21;
10326 }
10327 if ( v12 == 2 )
10328 {
10329 v14 = __OFSUB__(v11, 1024);
10330 v13 = ((v11 - 1024) & 0x80000000u) != 0;
10331 }
10332 else
10333 {
10334 if ( v12 != 3 )
10335 goto LABEL_21;
10336 v14 = __OFSUB__(v11, 2560);
10337 v13 = ((v11 - 2560) & 0x80000000u) != 0;
10338 }
10339 if ( v13 ^ v14 )
10340 goto LABEL_20;
10341 LABEL_21:
10342 if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
10343 {
10344 v15 = a2a;
10345 if ( (signed int)v11 < 10240 )
10346 {
10347 v23 = &pDir;
10348 v16 = uActorID;
10349 v21 = 0;
10350 goto LABEL_24;
10351 }
10352 v24 = 0;
10353 v22 = 1024;
10354 goto LABEL_58;
10355 }
10356 if ( v4->pMonsterInfo.uHostilityType != 4 )
10357 goto LABEL_46;
10358 if ( !(v4->uAttributes & 0x020000) || v4->pMonsterInfo.uAIType == 1 )
10359 {
10360 if ( v4->pMonsterInfo.uAIType == 1 )
10361 goto LABEL_36;
10362 if ( v4->pMonsterInfo.uAIType == 2 )
10363 {
10364 v27 = v4->sCurrentHP;
10365 v18 = (double)v27;
10366 v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.2;
10367 goto LABEL_34;
10368 }
10369 if ( v4->pMonsterInfo.uAIType == 3 )
10370 {
10371 v27 = v4->sCurrentHP;
10372 v18 = (double)v27;
10373 v19 = (double)(signed int)v4->pMonsterInfo.uHP * 0.1;
10374 LABEL_34:
10375 if ( v19 > v18 && (signed int)v11 < 10240 )
10376 {
10377 LABEL_36:
10378 v16 = uActorID;
10379 v15 = a2a;
10380 v23 = 0;
10381 v21 = 32;
10382 if ( v4->pMonsterInfo.uMovementType == 5 )
10383 {
10384 Actor::_403EB6(uActorID, a2a, 0x20u, 0);
10385 goto LABEL_25;
10386 }
10387 LABEL_24:
10388 Actor::_402968(v16, v15, v21, v23);
10389 LABEL_25:
10390 v17 = v29;
10391 v29->field_C = 4;
10392 LABEL_60:
10393 v17->uActionLength = v4->uCurrentActionLength;
10394 return 1;
10395 }
10396 goto LABEL_39;
10397 }
10398 }
10399 LABEL_39:
10400 if ( (double)(signed int)v28 < 307.2 )
10401 return 0;
10402 if ( (signed int)v11 < 5120 )
10403 {
10404 if ( v4->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
10405 Actor::_402AD7(uActorID, a2a, uActorID, 32, &pDir);
10406 else
10407 Actor::_40281C(uActorID, a2a, 32, &pDir, 307);
10408 goto LABEL_59;
10409 }
10410 LABEL_46:
10411 if ( !v4->pMonsterInfo.uMovementType )
10412 {
10413 v24 = 32;
10414 v22 = 1024;
10415 goto LABEL_57;
10416 }
10417 if ( v4->pMonsterInfo.uMovementType == 1 )
10418 {
10419 v24 = 32;
10420 v22 = 2560;
10421 goto LABEL_57;
10422 }
10423 if ( v4->pMonsterInfo.uMovementType == 2 )
10424 {
10425 v24 = 32;
10426 v22 = 5120;
10427 LABEL_57:
10428 v15 = a2a;
10429 LABEL_58:
10430 Actor::_4032B2(uActorID, v15, v22, v24);
10431 LABEL_59:
10432 v17 = v29;
10433 v29->field_C = 2;
10434 goto LABEL_60;
10435 }
10436 if ( v4->pMonsterInfo.uMovementType == 4 )
10437 {
10438 Actor::_4032B2(uActorID, a2a, 10240, 32);
10439 goto LABEL_53;
10440 }
10441 if ( v4->pMonsterInfo.uMovementType == 5 )
10442 {
10443 Actor::_403EB6(uActorID, a2a, 0x20u, 0);
10444 LABEL_53:
10445 v17 = v29;
10446 v29->field_C = 2;
10447 goto LABEL_60;
10448 }
10449 return 1;
10450 }
10451
10452 //----- (00406FA8) --------------------------------------------------------
10453 void stru262_TurnBased::_406FA8()
10454 {
10455 unsigned __int8 v1; // zf@1
10456 unsigned __int8 v2; // sf@1
10457 TurnBased_QueueElem *v3; // edi@2
10458 int v4; // eax@4
10459 Actor *v5; // ebx@4
10460 unsigned __int16 v6; // cx@4
10461 unsigned int *v7; // edx@8
10462 unsigned int v8; // esi@8
10463 unsigned __int8 v9; // of@13
10464 AIDirection a3; // [sp+Ch] [bp-6Ch]@8
10465 AIDirection v11; // [sp+28h] [bp-50h]@8
10466 AIDirection a4; // [sp+44h] [bp-34h]@8
10467 stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1
10468 TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2
10469 int uActorID; // [sp+68h] [bp-10h]@4
10470 unsigned int a2; // [sp+6Ch] [bp-Ch]@8
10471 int v17; // [sp+70h] [bp-8h]@1
10472 unsigned int v18; // [sp+74h] [bp-4h]@2
10473
10474 v17 = 0;
10475 v1 = this->uActorQueueSize == 0;
10476 v2 = this->uActorQueueSize < 0;
10477 v13 = this;
10478 if ( !(v2 | v1) )
10479 {
10480 v3 = this->pQueue;
10481 v18 = (char *)&pTurnEngine - (char *)this;
10482 v14 = this->pQueue;
10483 do
10484 {
10485 if ( (v3->uPackedID & 7) != 4 )
10486 {
10487 v4 = v3->uPackedID >> 3;
10488 uActorID = v4;
10489 v5 = &pActors[v4];
10490 v6 = v5->uAIState;
10491 if ( v6 != 5 )
10492 {
10493 if ( v6 != 11 )
10494 {
10495 if ( v6 != 19 )
10496 {
10497 if ( v6 != 17 )
10498 {
10499 v7 = (unsigned int *)&dword_4F6E08[v4];
10500 a2 = *v7;
10501 v8 = a2;
10502 Actor::_401221(v4, (int *)v7, 1u);
10503 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
10504 memcpy(&a4, &v11, sizeof(a4));
10505 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
10506 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
10507 {
10508 if ( v5->uAIState == 4 )
10509 {
10510 v5->uCurrentActionTime = 0;
10511 v5->uCurrentActionLength = 0;
10512 v5->uAIState = 5;
10513 v5->UpdateAnimation();
10514 return;
10515 }
10516 if ( rand() % 2 )
10517 Actor::_403EB6(uActorID, a2, 0x40u, &a4);
10518 else
10519 Actor::_402F87(uActorID, a2, &a4);
10520 }
10521 }
10522 }
10523 }
10524 }
10525 }
10526 ++v17;
10527 v3 = v14 + 1;
10528 v9 = __OFSUB__(v17, v13->uActorQueueSize);
10529 v2 = v17 - v13->uActorQueueSize < 0;
10530 ++v14;
10531 }
10532 while ( v2 ^ v9 );
10533 }
10534 }
10535
10536 //----- (004070EF) --------------------------------------------------------
10537 bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID)
10538 {
10539 signed int v2; // eax@1
10540 unsigned int v3; // ecx@1
10541 signed int v4; // esi@1
10542 int v5; // ecx@2
10543 signed int v6; // eax@4
10544 int v7; // eax@4
10545 float v8; // ST24_4@5
10546 double v9; // ST18_8@5
10547 signed int v10; // eax@6
10548 int v11; // ecx@6
10549 signed int v12; // eax@7
10550 int v13; // esi@7
10551 int v14; // esi@8
10552 int v15; // esi@9
10553 signed int v16; // eax@11
10554 int v17; // edi@11
10555 int v18; // esi@11
10556 int v19; // eax@13
10557 float v20; // ST24_4@14
10558 double v21; // ST18_8@14
10559 signed int v22; // eax@15
10560 int v23; // ebx@16
10561 signed int v24; // ecx@16
10562 int v25; // eax@18
10563 int v26; // eax@28
10564 BLVSector *v27; // edx@31
10565 int v28; // ecx@31
10566 BLVFace *v29; // ebx@32
10567 Vec3_short_ *v30; // esi@32
10568 int v31; // eax@32
10569 int v32; // ST50_4@44
10570 int v33; // ST54_4@44
10571 int v34; // eax@44
10572 char v35; // zf@44
10573 int v36; // edi@44
10574 int v37; // eax@45
10575 signed int v38; // esi@45
10576 int v39; // ST4C_4@49
10577 signed __int64 v40; // qtt@50
10578 __int16 v42; // bx@58
10579 int v43; // [sp-8h] [bp-70h]@11
10580 int v44; // [sp-4h] [bp-6Ch]@11
10581 int v45; // [sp+Ch] [bp-5Ch]@32
10582 __int16 v46; // [sp+10h] [bp-58h]@32
10583 int v47; // [sp+18h] [bp-50h]@20
10584 int v48; // [sp+1Ch] [bp-4Ch]@20
10585 int v49; // [sp+20h] [bp-48h]@20
10586 int v50; // [sp+24h] [bp-44h]@16
10587 signed int v51; // [sp+24h] [bp-44h]@27
10588 signed int v52; // [sp+28h] [bp-40h]@26
10589 signed int v53; // [sp+2Ch] [bp-3Ch]@23
10590 signed int v54; // [sp+30h] [bp-38h]@22
10591 signed int v55; // [sp+34h] [bp-34h]@21
10592 signed int v56; // [sp+38h] [bp-30h]@20
10593 signed int v57; // [sp+3Ch] [bp-2Ch]@28
10594 int v58; // [sp+44h] [bp-24h]@50
10595 int v59; // [sp+48h] [bp-20h]@44
10596 int v60; // [sp+50h] [bp-18h]@11
10597 signed int v61; // [sp+50h] [bp-18h]@31
10598 int v62; // [sp+54h] [bp-14h]@16
10599 int v63; // [sp+58h] [bp-10h]@4
10600 int v64; // [sp+5Ch] [bp-Ch]@4
10601 int v65; // [sp+60h] [bp-8h]@4
10602 int v66; // [sp+64h] [bp-4h]@7
10603
10604 v2 = (signed int)uObjID >> 3;
10605 v3 = (uObjID & 7) - 2;
10606 v4 = uObj2ID;
10607 if ( v3 )
10608 {
10609 v5 = v3 - 1;
10610 if ( v5 )
10611 {
10612 if ( v5 != 2 )
10613 return 0;
10614 v6 = v2;
10615 v63 = pLevelDecorations[v6].vPosition.x;
10616 v64 = pLevelDecorations[v6].vPosition.y;
10617 v65 = pLevelDecorations[v6].vPosition.z;
10618 v7 = pIndoor->GetSector(v63, v64, v65);
10619 }
10620 else
10621 {
10622 v63 = pActors[v2].vPosition.x;
10623 v64 = pActors[v2].vPosition.y;
10624 v8 = (double)pActors[v2].uActorHeight * 0.69999999;
10625 v9 = v8 + 6.7553994e15;
10626 v65 = LODWORD(v9) + pActors[v2].vPosition.z;
10627 v7 = pActors[v2].uSectorID;
10628 }
10629 }
10630 else
10631 {
10632 v10 = v2;
10633 v63 = pLayingItems[v10].vPosition.x;
10634 v64 = pLayingItems[v10].vPosition.y;
10635 v11 = pLayingItems[v10].vPosition.z;
10636 v7 = pLayingItems[v10].uSectorID;
10637 v65 = v11;
10638 }
10639 v66 = v7;
10640 v12 = v4 >> 3;
10641 v13 = (v4 & 7) - 2;
10642 if ( v13 )
10643 {
10644 v14 = v13 - 1;
10645 if ( v14 )
10646 {
10647 v15 = v14 - 1;
10648 if ( v15 )
10649 {
10650 if ( v15 != 1 )
10651 return 0;
10652 v16 = v12;
10653 v17 = pLevelDecorations[v16].vPosition.z;
10654 v18 = pLevelDecorations[v16].vPosition.x;
10655 v44 = pLevelDecorations[v16].vPosition.z;
10656 v60 = pLevelDecorations[v16].vPosition.y;
10657 v43 = pLevelDecorations[v16].vPosition.y;
10658 }
10659 else
10660 {
10661 v18 = pParty->vPosition.x;
10662 v17 = pParty->sEyelevel + pParty->vPosition.y;
10663 v60 = pParty->vPosition.z;
10664 v44 = pParty->sEyelevel + pParty->vPosition.y;
10665 v43 = pParty->vPosition.z;
10666 }
10667 v19 = pIndoor->GetSector(v18, v43, v44);
10668 }
10669 else
10670 {
10671 v60 = pActors[v12].vPosition.y;
10672 v18 = pActors[v12].vPosition.x;
10673 v20 = (double)pActors[v12].uActorHeight * 0.69999999;
10674 v21 = v20 + 6.7553994e15;
10675 v17 = LODWORD(v21) + pActors[v12].vPosition.z;
10676 v19 = pActors[v12].uSectorID;
10677 }
10678 }
10679 else
10680 {
10681 v22 = v12;
10682 v18 = pLayingItems[v22].vPosition.x;
10683 v17 = pLayingItems[v22].vPosition.z;
10684 v60 = pLayingItems[v22].vPosition.y;
10685 v19 = pLayingItems[v22].uSectorID;
10686 }
10687 v62 = v19;
10688 v23 = v18 - v63;
10689 v50 = v17 - v65;
10690 v24 = sub_452A9E(v23 * v23 + (v60 - v64) * (v60 - v64) + v50 * v50);
10691 if ( v24 > 5120 )
10692 return 0;
10693 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
10694 return 1;
10695 v25 = 65536;
10696 if ( v24 )
10697 v25 = 65536 / v24;
10698 v49 = v23 * v25;
10699 v47 = v50 * v25;
10700 v48 = (v60 - v64) * v25;
10701 v56 = v63;
10702 if ( v63 < v18 )
10703 {
10704 v55 = v18;
10705 }
10706 else
10707 {
10708 v56 = v18;
10709 v55 = v63;
10710 }
10711 v54 = v64;
10712 if ( v64 < v60 )
10713 {
10714 v53 = v60;
10715 }
10716 else
10717 {
10718 v54 = v60;
10719 v53 = v64;
10720 }
10721 v52 = v65;
10722 if ( v65 < v17 )
10723 {
10724 v51 = v17;
10725 }
10726 else
10727 {
10728 v52 = v17;
10729 v51 = v65;
10730 }
10731 v57 = 0;
10732 v26 = v66;
10733 while ( 2 )
10734 {
10735 if ( v26 == v62 )
10736 return 1;
10737 if ( v57 >= 30 || (v27 = pIndoor->pSectors, v28 = v66, v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) )
10738 break;
10739 while ( 1 )
10740 {
10741 v29 = &pIndoor->pFaces[v27[v28].pPortals[v61]];
10742 v30 = &pIndoor->pVertices[*v29->pVertexIDs];
10743 v45 = *(int *)&v30->x;
10744 v46 = v30->z;
10745 v31 = v29->pFacePlane_old.vNormal.z * (v46 - v65)
10746 + v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - v64)
10747 + v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - v63);
10748 if ( v66 != v29->uSectorID )
10749 v31 = -v31;
10750 if ( v31 >= 0 && (signed __int16)v45 != v63 && SHIWORD(v45) != v64 && v46 != v65
10751 || v56 > v29->pBounding.x2
10752 || v55 < v29->pBounding.x1
10753 || v54 > v29->pBounding.y2
10754 || v53 < v29->pBounding.y1
10755 || v52 > v29->pBounding.z2
10756 || v51 < v29->pBounding.z1 )
10757 goto LABEL_54;
10758 v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16;
10759 v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16;
10760 v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16;
10761 v35 = v32 + v33 + v34 == 0;
10762 v36 = v32 + v33 + v34;
10763 v59 = v32 + v33 + v34;
10764 if ( v35 )
10765 goto LABEL_53;
10766 v37 = v65 * v29->pFacePlane_old.vNormal.z;
10767 v38 = -(v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y);
10768 if ( v36 <= 0 )
10769 break;
10770 if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y <= 0 )
10771 goto LABEL_49;
10772 LABEL_53:
10773 v27 = pIndoor->pSectors;
10774 LABEL_54:
10775 ++v61;
10776 if ( v61 >= v27[v28].uNumPortals )
10777 goto LABEL_55;
10778 }
10779 if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y < 0 )
10780 goto LABEL_53;
10781 LABEL_49:
10782 v39 = abs(-(v29->pFacePlane_old.dist
10783 + v37
10784 + v63 * v29->pFacePlane_old.vNormal.x
10785 + v64 * v29->pFacePlane_old.vNormal.y)) >> 14;
10786 if ( v39 > abs(v36)
10787 || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0)
10788 || !sub_4075DB(
10789 v63 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16),
10790 v64 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16),
10791 v65 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16),
10792 v29) )
10793 {
10794 v28 = v66;
10795 goto LABEL_53;
10796 }
10797 if ( v29->uSectorID == v66 )
10798 v42 = v29->uBackSectorID;
10799 else
10800 v42 = v29->uSectorID;
10801 v26 = v42;
10802 if ( v42 != v66 )
10803 {
10804 ++v57;
10805 v66 = v42;
10806 continue;
10807 }
10808 break;
10809 }
10810 LABEL_55:
10811 if ( v66 != v62 )
10812 return 0;
10813 return 1;
10814 }
10815
10816 //----- (004075DB) --------------------------------------------------------
10817 bool __fastcall sub_4075DB(int a1, int a2, int a3, BLVFace *a4)
10818 {
10819 BLVFace *v4; // eax@1
10820 unsigned int v5; // esi@1
10821 signed int v6; // esi@2
10822 char v7; // zf@2
10823 int v8; // edi@2
10824 Vec3_short_ *v9; // ecx@3
10825 int v10; // edx@4
10826 signed int v11; // esi@7
10827 Vec3_short_ *v12; // ecx@8
10828 int v13; // edx@9
10829 signed int v14; // esi@11
10830 Vec3_short_ *v15; // ecx@12
10831 int v16; // edx@13
10832 int v17; // eax@14
10833 bool v18; // esi@14
10834 int v19; // ecx@14
10835 int v20; // ecx@16
10836 int v21; // edx@16
10837 int v22; // eax@17
10838 signed int v23; // ebx@18
10839 int v24; // esi@20
10840 signed int v25; // eax@22
10841 signed __int64 v26; // qtt@22
10842 bool result; // eax@25
10843 int v28; // [sp+8h] [bp-14h]@14
10844 int v29; // [sp+10h] [bp-Ch]@14
10845 signed int a3a; // [sp+24h] [bp+8h]@14
10846 int a4a; // [sp+28h] [bp+Ch]@2
10847
10848 v4 = a4;
10849 v5 = a4->uAttributes;
10850 if ( v5 & 0x100 )
10851 {
10852 v6 = 0;
10853 v7 = a4->uNumVertices == 0;
10854 a4a = a1;
10855 v8 = a2;
10856 if ( !v7 )
10857 {
10858 v9 = pIndoor->pVertices;
10859 do
10860 {
10861 dword_4F5D98_xs[v6] = v9[v4->pVertexIDs[v6]].x;
10862 v10 = v4->pVertexIDs[v6++];
10863 dword_4F5CC4_ys[v6] = v9[v10].y;
10864 }
10865 while ( v6 < v4->uNumVertices );
10866 }
10867 }
10868 else
10869 {
10870 v8 = a3;
10871 if ( v5 & 0x200 )
10872 {
10873 v11 = 0;
10874 v7 = a4->uNumVertices == 0;
10875 a4a = a1;
10876 if ( !v7 )
10877 {
10878 v12 = pIndoor->pVertices;
10879 do
10880 {
10881 dword_4F5D98_xs[v11] = v12[v4->pVertexIDs[v11]].x;
10882 v13 = v4->pVertexIDs[v11++];
10883 dword_4F5CC4_ys[v11] = v12[v13].z;
10884 }
10885 while ( v11 < v4->uNumVertices );
10886 }
10887 }
10888 else
10889 {
10890 v14 = 0;
10891 v7 = a4->uNumVertices == 0;
10892 a4a = a2;
10893 if ( !v7 )
10894 {
10895 v15 = pIndoor->pVertices;
10896 do
10897 {
10898 dword_4F5D98_xs[v14] = v15[v4->pVertexIDs[v14]].y;
10899 v16 = v4->pVertexIDs[v14++];
10900 dword_4F5CC4_ys[v14] = v15[v16].z;
10901 }
10902 while ( v14 < v4->uNumVertices );
10903 }
10904 }
10905 }
10906 v17 = v4->uNumVertices;
10907 a3a = 0;
10908 dword_4F5D98_xs[v17] = dword_4F5D98_xs[0];
10909 dword_4F5CC4_ys[v17 + 1] = dword_4F5CC4_ys[1];
10910 v28 = v17;
10911 v18 = dword_4F5CC4_ys[1] >= v8;
10912 v19 = 0;
10913 v29 = 0;
10914 if ( v17 <= 0 )
10915 goto LABEL_29;
10916 do
10917 {
10918 if ( a3a >= 2 )
10919 break;
10920 v20 = v19;
10921 v21 = dword_4F5CC4_ys[v20 + 2];
10922 if ( v18 ^ v21 >= v8 )
10923 {
10924 v22 = dword_4F5D98_xs[v20 + 1];
10925 if ( v22 >= a4a )
10926 v23 = 0;
10927 else
10928 v23 = 2;
10929 v24 = v23 | dword_4F5D98_xs[v20] < a4a;
10930 if ( v24 != 3 )
10931 {
10932 if ( !v24
10933 || (v25 = v22 - dword_4F5D98_xs[v20],
10934 LODWORD(v26) = v25 << 16,
10935 HIDWORD(v26) = v25 >> 16,
10936 dword_4F5D98_xs[v20]
10937 + ((signed int)(((unsigned __int64)(v26
10938 / (v21 - dword_4F5CC4_ys[v20 + 1])
10939 * ((v8 - dword_4F5CC4_ys[v20 + 1]) << 16)) >> 16)
10940 + 32768) >> 16) >= a4a) )
10941 ++a3a;
10942 }
10943 }
10944 v18 = v21 >= v8;
10945 v19 = v29++ + 1;
10946 }
10947 while ( v29 < v28 );
10948 result = 1;
10949 if ( a3a != 1 )
10950 LABEL_29:
10951 result = 0;
10952 return result;
10953 }
10954
10955 //----- (004077F1) --------------------------------------------------------
10956 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *a4, BSPVertexBuffer *a5)
10957 {
10958 ODMFace *v5; // eax@1
10959 unsigned int v6; // esi@1
10960 signed int v7; // edi@1
10961 char v8; // zf@2
10962 unsigned __int16 *v9; // edx@3
10963 int v10; // ecx@4
10964 unsigned __int16 *v11; // edx@8
10965 int v12; // ecx@9
10966 int v13; // edx@12
10967 int v14; // ecx@13
10968 int v15; // esi@14
10969 bool v16; // edi@14
10970 int v17; // ecx@16
10971 int v18; // edx@16
10972 int v19; // eax@17
10973 signed int v20; // ebx@18
10974 int v21; // edi@20
10975 signed int v22; // eax@22
10976 signed __int64 v23; // qtt@22
10977 bool result; // eax@25
10978 int v25; // [sp+14h] [bp-8h]@14
10979 int a4a; // [sp+28h] [bp+Ch]@2
10980 signed int a5a; // [sp+2Ch] [bp+10h]@14
10981
10982 v5 = a4;
10983 v6 = a4->uFaceAttributes;
10984 v7 = 0;
10985 if ( v6 & 0x100 )
10986 {
10987 v8 = a4->uNumVertices == 0;
10988 a4a = a1;
10989 a3 = a2;
10990 if ( !v8 )
10991 {
10992 v9 = v5->pVertexIDs;
10993 do
10994 {
10995 ++v7;
10996 dword_4F5BF4_xs[v7] = a5->pVertices[*v9].x;
10997 v10 = *v9;
10998 ++v9;
10999 dword_4F5B24_ys[v7] = a5->pVertices[v10].y;
11000 }
11001 while ( v7 < v5->uNumVertices );
11002 }
11003 }
11004 else
11005 {
11006 if ( v6 & 0x200 )
11007 {
11008 v8 = a4->uNumVertices == 0;
11009 a4a = a1;
11010 if ( !v8 )
11011 {
11012 v11 = v5->pVertexIDs;
11013 do
11014 {
11015 ++v7;
11016 dword_4F5BF4_xs[v7] = a5->pVertices[*v11].x;
11017 v12 = *v11;
11018 ++v11;
11019 dword_4F5B24_ys[v7] = a5->pVertices[v12].z;
11020 }
11021 while ( v7 < v5->uNumVertices );
11022 }
11023 }
11024 else
11025 {
11026 v8 = a4->uNumVertices == 0;
11027 a4a = a2;
11028 if ( !v8 )
11029 {
11030 v13 = (int)v5->pVertexIDs;
11031 do
11032 {
11033 ++v7;
11034 dword_4F5BF4_xs[v7] = a5->pVertices[*(short *)v13].y;
11035 v14 = *(short *)v13;
11036 v13 += 2;
11037 dword_4F5B24_ys[v7] = a5->pVertices[v14].z;
11038 }
11039 while ( v7 < v5->uNumVertices );
11040 }
11041 }
11042 }
11043 v15 = v5->uNumVertices;
11044 a5a = 0;
11045 dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1];
11046 dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1];
11047 v25 = 0;
11048 v16 = dword_4F5B24_ys[1] >= a3;
11049 if ( v15 <= 0 )
11050 goto LABEL_29;
11051 do
11052 {
11053 if ( a5a >= 2 )
11054 break;
11055 v17 = v25;
11056 v18 = dword_4F5B24_ys[v25 + 2];
11057 if ( v16 ^ v18 >= a3 )
11058 {
11059 v19 = dword_4F5BF4_xs[v17 + 2];
11060 if ( v19 >= a4a )
11061 v20 = 0;
11062 else
11063 v20 = 2;
11064 v21 = v20 | dword_4F5BF4_xs[v17 + 1] < a4a;
11065 if ( v21 != 3 )
11066 {
11067 if ( !v21
11068 || (v22 = v19 - dword_4F5BF4_xs[v17 + 1],
11069 LODWORD(v23) = v22 << 16,
11070 HIDWORD(v23) = v22 >> 16,
11071 dword_4F5BF4_xs[v17 + 1]
11072 + ((signed int)(((unsigned __int64)(v23
11073 / (v18 - dword_4F5B24_ys[v17 + 1])
11074 * ((a3 - dword_4F5B24_ys[v17 + 1]) << 16)) >> 16)
11075 + 32768) >> 16) >= a4a) )
11076 ++a5a;
11077 }
11078 }
11079 ++v25;
11080 v16 = v18 >= a3;
11081 }
11082 while ( v25 < v15 );
11083 result = 1;
11084 if ( a5a != 1 )
11085 LABEL_29:
11086 result = 0;
11087 return result;
11088 }
11089
11090 //----- (00407A1C) --------------------------------------------------------
11091 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
11092 {
11093 unsigned int v4; // esi@1
11094 Vec3_int_ v5; // ST08_12@2
11095 int v6; // edi@2
11096 int v7; // ebx@2
11097 int v8; // esi@2
11098 signed int v9; // ecx@2
11099 int v10; // eax@2
11100 int v11; // ecx@4
11101 int v12; // eax@4
11102 int v13; // ebx@4
11103 int v14; // edx@6
11104 char *v15; // edi@16
11105 ODMFace *v16; // esi@19
11106 int v17; // ST34_4@25
11107 int v18; // ST38_4@25
11108 int v19; // eax@25
11109 char v20; // zf@25
11110 int v21; // ebx@25
11111 int v22; // eax@26
11112 signed int v23; // edi@26
11113 int v24; // ST34_4@30
11114 signed __int64 v25; // qtt@31
11115 int v26; // eax@31
11116 Vec3_int_ v27; // ST08_12@37
11117 Vec3_int_ v28; // ST08_12@37
11118 int v29; // edi@37
11119 int v30; // ebx@37
11120 int v31; // esi@37
11121 signed int v32; // ecx@37
11122 int v33; // eax@37
11123 int v34; // ecx@39
11124 int v35; // eax@39
11125 int v36; // ebx@39
11126 int v37; // edx@41
11127 char *v38; // edi@51
11128 ODMFace *v39; // esi@54
11129 int v40; // ebx@60
11130 int v41; // eax@61
11131 signed int v42; // edi@61
11132 signed __int64 v43; // qtt@66
11133 int v44; // eax@66
11134 Vec3_int_ v45; // ST08_12@73
11135 int v46; // edi@73
11136 int v47; // ebx@73
11137 int v48; // esi@73
11138 signed int v49; // ecx@73
11139 int v50; // eax@73
11140 int v51; // edx@75
11141 int v52; // ecx@75
11142 int v53; // eax@75
11143 int v54; // ebx@75
11144 int v55; // edi@77
11145 int v56; // ecx@77
11146 int v57; // eax@81
11147 int v58; // esi@81
11148 int v59; // eax@90
11149 BLVSector *v60; // edx@90
11150 int v61; // ecx@90
11151 BLVFace *v62; // esi@91
11152 int v63; // ST34_4@98
11153 int v64; // ST30_4@98
11154 int v65; // eax@98
11155 int v66; // ebx@98
11156 int v67; // eax@99
11157 signed int v68; // edi@99
11158 int v69; // ST2C_4@103
11159 signed __int64 v70; // qtt@104
11160 int v71; // eax@104
11161 Vec3_int_ v72; // ST08_12@111
11162 Vec3_int_ v73; // ST08_12@111
11163 int v74; // edi@111
11164 int v75; // ebx@111
11165 int v76; // esi@111
11166 signed int v77; // ecx@111
11167 int v78; // eax@111
11168 int v79; // edx@113
11169 int v80; // ecx@113
11170 int v81; // eax@113
11171 int v82; // ebx@113
11172 int v83; // edi@115
11173 int v84; // ecx@115
11174 int v85; // eax@119
11175 int v86; // esi@119
11176 int v87; // ecx@128
11177 BLVSector *v88; // eax@128
11178 int v89; // ecx@128
11179 BLVFace *v90; // esi@129
11180 int v91; // ebx@136
11181 int v92; // eax@137
11182 signed int v93; // edi@137
11183 signed __int64 v94; // qtt@142
11184 int v95; // eax@142
11185 Vec3_int_ v97; // [sp-18h] [bp-94h]@1
11186 int v98; // [sp-Ch] [bp-88h]@88
11187 int v99; // [sp-Ch] [bp-88h]@126
11188 int v100; // [sp-8h] [bp-84h]@88
11189 int v101; // [sp-8h] [bp-84h]@126
11190 int v102; // [sp-4h] [bp-80h]@88
11191 int v103; // [sp-4h] [bp-80h]@126
11192 int v104; // [sp+Ch] [bp-70h]@13
11193 int v105; // [sp+Ch] [bp-70h]@48
11194 int v106; // [sp+10h] [bp-6Ch]@18
11195 int v107; // [sp+10h] [bp-6Ch]@98
11196 int v108; // [sp+10h] [bp-6Ch]@104
11197 int v109; // [sp+18h] [bp-64h]@25
11198 int v110; // [sp+18h] [bp-64h]@31
11199 int i; // [sp+18h] [bp-64h]@90
11200 int v112; // [sp+18h] [bp-64h]@128
11201 signed int v113; // [sp+20h] [bp-5Ch]@1
11202 signed int v114; // [sp+24h] [bp-58h]@1
11203 unsigned __int64 a4; // [sp+28h] [bp-54h]@1
11204 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
11205 int v117; // [sp+34h] [bp-48h]@4
11206 int v118; // [sp+34h] [bp-48h]@39
11207 int v119; // [sp+34h] [bp-48h]@75
11208 int v120; // [sp+34h] [bp-48h]@113
11209 int v121; // [sp+38h] [bp-44h]@4
11210 int v122; // [sp+38h] [bp-44h]@39
11211 int v123; // [sp+38h] [bp-44h]@76
11212 int v124; // [sp+38h] [bp-44h]@114
11213 int v125; // [sp+3Ch] [bp-40h]@4
11214 int v126; // [sp+3Ch] [bp-40h]@39
11215 int v127; // [sp+3Ch] [bp-40h]@77
11216 int v128; // [sp+3Ch] [bp-40h]@115
11217 int v129; // [sp+40h] [bp-3Ch]@11
11218 int v130; // [sp+40h] [bp-3Ch]@46
11219 int v131; // [sp+40h] [bp-3Ch]@78
11220 int v132; // [sp+40h] [bp-3Ch]@116
11221 int v133; // [sp+44h] [bp-38h]@10
11222 int v134; // [sp+44h] [bp-38h]@45
11223 int v135; // [sp+44h] [bp-38h]@81
11224 int v136; // [sp+44h] [bp-38h]@119
11225 int v137; // [sp+48h] [bp-34h]@7
11226 int v138; // [sp+48h] [bp-34h]@42
11227 int v139; // [sp+48h] [bp-34h]@82
11228 int v140; // [sp+48h] [bp-34h]@120
11229 int v141; // [sp+4Ch] [bp-30h]@6
11230 int v142; // [sp+4Ch] [bp-30h]@41
11231 int v143; // [sp+4Ch] [bp-30h]@75
11232 int v144; // [sp+4Ch] [bp-30h]@113
11233 int v145; // [sp+50h] [bp-2Ch]@5
11234 int v146; // [sp+50h] [bp-2Ch]@40
11235 int v147; // [sp+50h] [bp-2Ch]@75
11236 int v148; // [sp+50h] [bp-2Ch]@113
11237 int v149; // [sp+54h] [bp-28h]@4
11238 int v150; // [sp+54h] [bp-28h]@39
11239 int v151; // [sp+54h] [bp-28h]@75
11240 int v152; // [sp+54h] [bp-28h]@113
11241 int sDepth; // [sp+58h] [bp-24h]@17
11242 int sDeptha; // [sp+58h] [bp-24h]@52
11243 int sDepthb; // [sp+58h] [bp-24h]@90
11244 char *a5; // [sp+5Ch] [bp-20h]@16
11245 char *a5a; // [sp+5Ch] [bp-20h]@51
11246 signed int a5b; // [sp+5Ch] [bp-20h]@83
11247 signed int a5c; // [sp+5Ch] [bp-20h]@121
11248 signed int v160; // [sp+60h] [bp-1Ch]@12
11249 signed int v161; // [sp+60h] [bp-1Ch]@47
11250 int v162; // [sp+60h] [bp-1Ch]@128
11251 int v163; // [sp+64h] [bp-18h]@2
11252 int outx; // [sp+68h] [bp-14h]@2
11253 int outy; // [sp+6Ch] [bp-10h]@2
11254 int outz; // [sp+70h] [bp-Ch]@2
11255 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2
11256 int ya; // [sp+84h] [bp+8h]@60
11257 int yb; // [sp+84h] [bp+8h]@136
11258 int ve; // [sp+88h] [bp+Ch]@60
11259 int va; // [sp+88h] [bp+Ch]@60
11260 int vb; // [sp+88h] [bp+Ch]@66
11261 int vf; // [sp+88h] [bp+Ch]@136
11262 int vc; // [sp+88h] [bp+Ch]@136
11263 int vd; // [sp+88h] [bp+Ch]@142
11264 int v_4; // [sp+8Ch] [bp+10h]@60
11265 int v_4a; // [sp+8Ch] [bp+10h]@65
11266 int v_4b; // [sp+8Ch] [bp+10h]@136
11267 int v_4c; // [sp+8Ch] [bp+10h]@141
11268 int v_8; // [sp+90h] [bp+14h]@53
11269
11270 a4 = __PAIR__(z, x);
11271 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
11272 v114 = 0;
11273 v97.z = y;
11274 v113 = 0;
11275 a4_8 = v4;
11276 *(_QWORD *)&v97.x = a4;
11277 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
11278 {
11279 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
11280 v45.z = v.z;
11281 *(_QWORD *)&v45.x = *(_QWORD *)&v;
11282 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163);
11283 v46 = outy - pOut.y;
11284 v47 = v163 - outz;
11285 v48 = outx - pOut.x;
11286 v49 = sub_452A9E(v48 * v48 + v46 * v46 + v47 * v47);
11287 v50 = 65536;
11288 if ( v49 )
11289 v50 = 65536 / v49;
11290 v51 = outx;
11291 v143 = v48 * v50;
11292 v52 = v46 * v50;
11293 v53 = v47 * v50;
11294 v54 = pOut.x;
11295 v147 = v52;
11296 v151 = v53;
11297 v119 = pOut.x;
11298 if ( pOut.x < outx )
11299 {
11300 v123 = outx;
11301 }
11302 else
11303 {
11304 v119 = outx;
11305 v123 = pOut.x;
11306 }
11307 v55 = pOut.y;
11308 v56 = outy;
11309 v127 = pOut.y;
11310 if ( pOut.y < outy )
11311 {
11312 v131 = outy;
11313 }
11314 else
11315 {
11316 v127 = outy;
11317 v131 = pOut.y;
11318 }
11319 v57 = v163;
11320 v58 = outz;
11321 v135 = outz;
11322 if ( outz < v163 )
11323 {
11324 v139 = v163;
11325 }
11326 else
11327 {
11328 v135 = v163;
11329 v139 = outz;
11330 }
11331 a5b = 0;
11332 while ( !v114 )
11333 {
11334 if ( a5b )
11335 {
11336 v102 = v58;
11337 v100 = v55;
11338 v98 = v54;
11339 }
11340 else
11341 {
11342 v102 = v57;
11343 v100 = v56;
11344 v98 = v51;
11345 }
11346 v59 = pIndoor->GetSector(v98, v100, v102);
11347 v60 = pIndoor->pSectors;
11348 v61 = 116 * v59;
11349 sDepthb = 0;
11350 for ( i = 116 * v59;
11351 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
11352 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v61);
11353 ++sDepthb )
11354 {
11355 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
11356 if ( v62->uAttributes & 1
11357 || v119 > v62->pBounding.x2
11358 || v123 < v62->pBounding.x1
11359 || v127 > v62->pBounding.y2
11360 || v131 < v62->pBounding.y1
11361 || v135 > v62->pBounding.z2
11362 || v139 < v62->pBounding.z1
11363 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16,
11364 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16,
11365 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16,
11366 v20 = v63 + v64 + v65 == 0,
11367 v66 = v63 + v64 + v65,
11368 v107 = v63 + v64 + v65,
11369 v20) )
11370 goto LABEL_107;
11371 v67 = outz * v62->pFacePlane_old.vNormal.z;
11372 v68 = -(v62->pFacePlane_old.dist
11373 + v67
11374 + pOut.y * v62->pFacePlane_old.vNormal.y
11375 + pOut.x * v62->pFacePlane_old.vNormal.x);
11376 if ( v66 <= 0 )
11377 {
11378 if ( v62->pFacePlane_old.dist
11379 + v67
11380 + pOut.y * v62->pFacePlane_old.vNormal.y
11381 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 )
11382 goto LABEL_107;
11383 }
11384 else
11385 {
11386 if ( v62->pFacePlane_old.dist
11387 + v67
11388 + pOut.y * v62->pFacePlane_old.vNormal.y
11389 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 )
11390 goto LABEL_107;
11391 }
11392 v69 = abs(-(v62->pFacePlane_old.dist
11393 + v67
11394 + pOut.y * v62->pFacePlane_old.vNormal.y
11395 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14;
11396 if ( v69 <= abs(v66) )
11397 {
11398 LODWORD(v70) = v68 << 16;
11399 HIDWORD(v70) = v68 >> 16;
11400 v71 = v70 / v107;
11401 v108 = v70 / v107;
11402 if ( v71 >= 0 )
11403 {
11404 if ( sub_4075DB(
11405 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16),
11406 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16),
11407 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16),
11408 v62) )
11409 {
11410 v114 = 1;
11411 break;
11412 }
11413 }
11414 }
11415 v61 = i;
11416 LABEL_107:
11417 v60 = pIndoor->pSectors;
11418 }
11419 ++a5b;
11420 if ( a5b >= 2 )
11421 break;
11422 v57 = v163;
11423 v56 = outy;
11424 v51 = outx;
11425 v58 = outz;
11426 v55 = pOut.y;
11427 v54 = pOut.x;
11428 }
11429 v72.z = y;
11430 *(_QWORD *)&v72.x = a4;
11431 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
11432 v73.z = v.z;
11433 *(_QWORD *)&v73.x = *(_QWORD *)&v;
11434 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
11435 v74 = outy - pOut.y;
11436 v75 = v163 - outz;
11437 v76 = outx - pOut.x;
11438 v77 = sub_452A9E(v76 * v76 + v74 * v74 + v75 * v75);
11439 v78 = 65536;
11440 if ( v77 )
11441 v78 = 65536 / v77;
11442 v79 = outx;
11443 v144 = v76 * v78;
11444 v80 = v74 * v78;
11445 v81 = v75 * v78;
11446 v82 = pOut.x;
11447 v148 = v80;
11448 v152 = v81;
11449 v120 = pOut.x;
11450 if ( pOut.x < outx )
11451 {
11452 v124 = outx;
11453 }
11454 else
11455 {
11456 v120 = outx;
11457 v124 = pOut.x;
11458 }
11459 v83 = pOut.y;
11460 v84 = outy;
11461 v128 = pOut.y;
11462 if ( pOut.y < outy )
11463 {
11464 v132 = outy;
11465 }
11466 else
11467 {
11468 v128 = outy;
11469 v132 = pOut.y;
11470 }
11471 v85 = v163;
11472 v86 = outz;
11473 v136 = outz;
11474 if ( outz < v163 )
11475 {
11476 v140 = v163;
11477 }
11478 else
11479 {
11480 v136 = v163;
11481 v140 = outz;
11482 }
11483 a5c = 0;
11484 while ( 1 )
11485 {
11486 if ( v113 )
11487 return !v114 || !v113;
11488 if ( a5c )
11489 {
11490 v103 = v86;
11491 v101 = v83;
11492 v99 = v82;
11493 }
11494 else
11495 {
11496 v103 = v85;
11497 v101 = v84;
11498 v99 = v79;
11499 }
11500 v87 = pIndoor->GetSector(v99, v101, v103);
11501 v88 = pIndoor->pSectors;
11502 v89 = 116 * v87;
11503 v162 = 0;
11504 v112 = v89;
11505 if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
11506 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) > 0 )
11507 break;
11508 LABEL_148:
11509 ++a5c;
11510 if ( a5c >= 2 )
11511 return !v114 || !v113;
11512 v85 = v163;
11513 v84 = outy;
11514 v79 = outx;
11515 v86 = outz;
11516 v83 = pOut.y;
11517 v82 = pOut.x;
11518 }
11519 while ( 1 )
11520 {
11521 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
11522 if ( v90->uAttributes & 1
11523 || v120 > v90->pBounding.x2
11524 || v124 < v90->pBounding.x1
11525 || v128 > v90->pBounding.y2
11526 || v132 < v90->pBounding.y1
11527 || v136 > v90->pBounding.z2
11528 || v140 < v90->pBounding.z1
11529 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16,
11530 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16,
11531 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16,
11532 v20 = yb + vf + v_4b == 0,
11533 v91 = yb + vf + v_4b,
11534 vc = yb + vf + v_4b,
11535 v20) )
11536 goto LABEL_145;
11537 v92 = outz * v90->pFacePlane_old.vNormal.z;
11538 v93 = -(v90->pFacePlane_old.dist
11539 + v92
11540 + pOut.y * v90->pFacePlane_old.vNormal.y
11541 + pOut.x * v90->pFacePlane_old.vNormal.x);
11542 if ( v91 <= 0 )
11543 {
11544 if ( v90->pFacePlane_old.dist
11545 + v92
11546 + pOut.y * v90->pFacePlane_old.vNormal.y
11547 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 )
11548 goto LABEL_145;
11549 }
11550 else
11551 {
11552 if ( v90->pFacePlane_old.dist
11553 + v92
11554 + pOut.y * v90->pFacePlane_old.vNormal.y
11555 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 )
11556 goto LABEL_145;
11557 }
11558 v_4c = abs(-(v90->pFacePlane_old.dist
11559 + v92
11560 + pOut.y * v90->pFacePlane_old.vNormal.y
11561 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14;
11562 if ( v_4c <= abs(v91) )
11563 {
11564 LODWORD(v94) = v93 << 16;
11565 HIDWORD(v94) = v93 >> 16;
11566 v95 = v94 / vc;
11567 vd = v94 / vc;
11568 if ( v95 >= 0 )
11569 {
11570 if ( sub_4075DB(
11571 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16),
11572 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16),
11573 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16),
11574 v90) )
11575 {
11576 v113 = 1;
11577 goto LABEL_148;
11578 }
11579 }
11580 }
11581 v89 = v112;
11582 LABEL_145:
11583 v88 = pIndoor->pSectors;
11584 ++v162;
11585 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
11586 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) )
11587 goto LABEL_148;
11588 }
11589 }
11590 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
11591 v5.z = v.z;
11592 *(_QWORD *)&v5.x = *(_QWORD *)&v;
11593 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163);
11594 v6 = outy - pOut.y;
11595 v7 = v163 - outz;
11596 v8 = outx - pOut.x;
11597 v9 = sub_452A9E(v8 * v8 + v6 * v6 + v7 * v7);
11598 v10 = 65536;
11599 if ( v9 )
11600 v10 = 65536 / v9;
11601 v125 = v8 * v10;
11602 v11 = v10;
11603 v12 = v7 * v10;
11604 v13 = pOut.x;
11605 v117 = v12;
11606 v121 = v6 * v11;
11607 v149 = pOut.x;
11608 if ( pOut.x < outx )
11609 {
11610 v145 = outx;
11611 }
11612 else
11613 {
11614 v149 = outx;
11615 v145 = pOut.x;
11616 }
11617 v14 = outy;
11618 v141 = pOut.y;
11619 if ( pOut.y < outy )
11620 {
11621 v137 = outy;
11622 }
11623 else
11624 {
11625 v141 = outy;
11626 v137 = pOut.y;
11627 }
11628 v133 = outz;
11629 if ( outz < v163 )
11630 {
11631 v129 = v163;
11632 }
11633 else
11634 {
11635 v133 = v163;
11636 v129 = outz;
11637 }
11638 v160 = 0;
11639 if ( (signed int)pOutdoor->uNumBModels > 0 )
11640 {
11641 v104 = 0;
11642 while ( 1 )
11643 {
11644 v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
11645 a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
11646 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
11647 {
11648 sDepth = 0;
11649 if ( *((int *)v15 + 2) > 0 )
11650 break;
11651 }
11652 LABEL_36:
11653 ++v160;
11654 ++v104;
11655 if ( v160 >= (signed int)pOutdoor->uNumBModels )
11656 goto LABEL_37;
11657 v14 = outy;
11658 v13 = pOut.x;
11659 }
11660 v106 = 0;
11661 while ( 1 )
11662 {
11663 v16 = (ODMFace *)(v106 + *((int *)a5 + 4));
11664 if ( v149 > v16->pBoundingBox.x2
11665 || v145 < v16->pBoundingBox.x1
11666 || v141 > v16->pBoundingBox.y2
11667 || v137 < v16->pBoundingBox.y1
11668 || v133 > v16->pBoundingBox.z2
11669 || v129 < v16->pBoundingBox.z1
11670 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16,
11671 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16,
11672 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16,
11673 v20 = v17 + v18 + v19 == 0,
11674 v21 = v17 + v18 + v19,
11675 v109 = v17 + v18 + v19,
11676 v20) )
11677 goto LABEL_33;
11678 v22 = pOut.y * v16->pFacePlane.vNormal.y;
11679 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x);
11680 if ( v21 <= 0 )
11681 {
11682 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 )
11683 goto LABEL_33;
11684 }
11685 else
11686 {
11687 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 )
11688 goto LABEL_33;
11689 }
11690 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14;
11691 if ( v24 <= abs(v21) )
11692 {
11693 LODWORD(v25) = v23 << 16;
11694 HIDWORD(v25) = v23 >> 16;
11695 v26 = v25 / v109;
11696 v110 = v25 / v109;
11697 if ( v26 >= 0 )
11698 {
11699 if ( sub_4077F1(
11700 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16),
11701 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16),
11702 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16),
11703 v16,
11704 (BSPVertexBuffer *)a5) )
11705 {
11706 v114 = 1;
11707 goto LABEL_36;
11708 }
11709 }
11710 }
11711 LABEL_33:
11712 ++sDepth;
11713 v106 += 308;
11714 if ( sDepth >= *((int *)a5 + 2) )
11715 goto LABEL_36;
11716 }
11717 }
11718 LABEL_37:
11719 v27.z = y;
11720 *(_QWORD *)&v27.x = a4;
11721 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
11722 v28.z = v.z;
11723 *(_QWORD *)&v28.x = *(_QWORD *)&v;
11724 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
11725 v29 = outy - pOut.y;
11726 v30 = v163 - outz;
11727 v31 = outx - pOut.x;
11728 v32 = sub_452A9E(v31 * v31 + v29 * v29 + v30 * v30);
11729 v33 = 65536;
11730 if ( v32 )
11731 v33 = 65536 / v32;
11732 v126 = v31 * v33;
11733 v34 = v33;
11734 v35 = v30 * v33;
11735 v36 = pOut.x;
11736 v118 = v35;
11737 v122 = v29 * v34;
11738 v150 = pOut.x;
11739 if ( pOut.x < outx )
11740 {
11741 v146 = outx;
11742 }
11743 else
11744 {
11745 v150 = outx;
11746 v146 = pOut.x;
11747 }
11748 v37 = outy;
11749 v142 = pOut.y;
11750 if ( pOut.y < outy )
11751 {
11752 v138 = outy;
11753 }
11754 else
11755 {
11756 v142 = outy;
11757 v138 = pOut.y;
11758 }
11759 v134 = outz;
11760 if ( outz < v163 )
11761 {
11762 v130 = v163;
11763 }
11764 else
11765 {
11766 v134 = v163;
11767 v130 = outz;
11768 }
11769 v161 = 0;
11770 if ( (signed int)pOutdoor->uNumBModels > 0 )
11771 {
11772 v105 = 0;
11773 while ( 1 )
11774 {
11775 v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
11776 a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
11777 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
11778 {
11779 sDeptha = 0;
11780 if ( *((int *)v38 + 2) > 0 )
11781 break;
11782 }
11783 LABEL_71:
11784 ++v161;
11785 ++v105;
11786 if ( v161 >= (signed int)pOutdoor->uNumBModels )
11787 return !v114 || !v113;
11788 v37 = outy;
11789 v36 = pOut.x;
11790 }
11791 v_8 = 0;
11792 while ( 1 )
11793 {
11794 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4));
11795 if ( v150 > v39->pBoundingBox.x2
11796 || v146 < v39->pBoundingBox.x1
11797 || v142 > v39->pBoundingBox.y2
11798 || v138 < v39->pBoundingBox.y1
11799 || v134 > v39->pBoundingBox.z2
11800 || v130 < v39->pBoundingBox.z1
11801 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16,
11802 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16,
11803 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16,
11804 v20 = ya + ve + v_4 == 0,
11805 v40 = ya + ve + v_4,
11806 va = ya + ve + v_4,
11807 v20) )
11808 goto LABEL_68;
11809 v41 = pOut.y * v39->pFacePlane.vNormal.y;
11810 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x);
11811 if ( v40 <= 0 )
11812 {
11813 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 )
11814 goto LABEL_68;
11815 }
11816 else
11817 {
11818 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 )
11819 goto LABEL_68;
11820 }
11821 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14;
11822 if ( v_4a <= abs(v40) )
11823 {
11824 LODWORD(v43) = v42 << 16;
11825 HIDWORD(v43) = v42 >> 16;
11826 v44 = v43 / va;
11827 vb = v43 / va;
11828 if ( v44 >= 0 )
11829 {
11830 if ( sub_4077F1(
11831 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16),
11832 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16),
11833 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16),
11834 v39,
11835 (BSPVertexBuffer *)a5a) )
11836 {
11837 v113 = 1;
11838 goto LABEL_71;
11839 }
11840 }
11841 }
11842 LABEL_68:
11843 ++sDeptha;
11844 v_8 += 308;
11845 if ( sDeptha >= *((int *)a5a + 2) )
11846 goto LABEL_71;
11847 }
11848 }
11849 return !v114 || !v113;
11850 }
11851
11852
11853 //----- (00408768) --------------------------------------------------------
11854 char __cdecl UpdateActors()
11855 {
11856 unsigned int v0; // edi@1
11857 __int16 v1; // ax@7
11858 char *v2; // esi@10
11859 char v3; // zf@13
11860 signed int v5; // [sp+Ch] [bp-10h]@1
11861 signed int v6; // [sp+10h] [bp-Ch]@1
11862 signed int v7; // [sp+14h] [bp-8h]@1
11863 signed int v8; // [sp+18h] [bp-4h]@1
11864
11865 v0 = 0;
11866 v8 = 0;
11867 v6 = 0;
11868 v7 = 0;
11869 v5 = 0;
11870 if ( !_strcmpi(pCurrentMapName, "d25.blv") )
11871 v8 = 1;
11872 if ( !_strcmpi(pCurrentMapName, "d26.blv") )
11873 v6 = 1;
11874 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 99) )
11875 v7 = 1;
11876 v1 = _449B57_test_bit(pParty->_award_bits, 100);
11877 if ( v1 )
11878 v5 = 1;
11879 if ( (signed int)uNumActors > 0 )
11880 {
11881 v2 = (char *)&pActors[0].vPosition;
11882 do
11883 {
11884 if ( ((Actor *)(v2 - 142))->CanAct() || *((short *)v2 + 17) == 19 )
11885 {
11886 v3 = *((short *)v2 + 17) == 19;
11887 *(short *)v2 = *((short *)v2 + 10);
11888 *((short *)v2 + 1) = *((short *)v2 + 11);
11889 *((short *)v2 + 2) = *((short *)v2 + 12);
11890 *((short *)v2 - 51) = *((short *)v2 - 17);
11891 if ( !v3 )
11892 Actor::_403EB6(v0, dword_4F6E08[v0], *(int *)(v2 - 18), 0);
11893 }
11894 *(v2 - 81) = 0;
11895 LOBYTE(v1) = 0;
11896 if ( !v8 || v7 )
11897 {
11898 if ( !v6 || v5 )
11899 {
11900 LOBYTE(v1) = ((Actor *)(v2 - 142))->_438B9B();
11901 if ( (char)v1 )
11902 *(v2 - 104) &= 0xF7u;
11903 }
11904 }
11905 *(v2 - 104) &= 0x7Fu;
11906 if ( *(v2 - 104) & 0x40 )
11907 LOBYTE(v1) = Actor::_4031C1_update_job(v0, pParty->uCurrentHour, 1);
11908 ++v0;
11909 v2 += 836;
11910 }
11911 while ( (signed int)v0 < (signed int)uNumActors );
11912 }
11913 return v1;
11914 }
11915
11916 //----- (00408896) --------------------------------------------------------
11917 char *__cdecl UpdateLayingItems()
11918 {
11919 unsigned int v0; // edi@1
11920 char *v1; // esi@1
11921 char *result; // eax@7
11922
11923 v0 = 0;
11924 v1 = (char *)&pLayingItems[0].uObjectDescID;
11925 do
11926 {
11927 if ( *(short *)v1 && (v1[24] & 8 || pObjectList->pObjects[*(short *)v1].uFlags & 0x10) )
11928 LayingItem::_42F933(v0);
11929 v1 += 112;
11930 ++v0;
11931 }
11932 while ( (signed int)v1 < (signed int)((char *)&pObjectList->uNumObjects + 2) );
11933 result = (char *)&array_5118E8.pElements[0].field_C;
11934 do
11935 {
11936 *(short *)result = 0;
11937 result += 24;
11938 }
11939 while ( (signed int)result < (signed int)&pBillboardRenderList[0].field_4 );
11940 return result;
11941 }
11942
11943 //----- (004088E9) --------------------------------------------------------
11944 signed int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6)
11945 {
11946 int v6; // esi@1
11947 int v7; // edi@1
11948 int v8; // eax@1
11949 signed int result; // eax@1
11950 int v10; // [sp+Ch] [bp-4h]@1
11951 int v11; // [sp+18h] [bp+8h]@1
11952
11953 v6 = a1;
11954 v10 = a2;
11955 v7 = a3 - a1;
11956 v11 = abs(a3 - a1);
11957 v8 = abs(a4 - v10);
11958 result = sub_452A9E(v11 * v11 + v8 * v8);
11959 if ( result )
11960 result = abs((v7 * (v10 - a6) - (a4 - v10) * (v6 - a5)) / result);
11961 return result;
11962 }
11963
11964
11965 //----- (00408A27) --------------------------------------------------------
11966 unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors)
11967 {
11968 unsigned int *v1; // esi@1
11969 int v2; // eax@1
11970 unsigned int v3; // ebp@1
11971 signed int v4; // ebx@1
11972 Actor *v5; // edi@2
11973 unsigned int v6; // eax@3
11974 int v8; // [sp+Ch] [bp-4h]@1
11975
11976 v1 = pTotalActors;
11977 v2 = GetAlertStatus();
11978 v3 = 0;
11979 v4 = 0;
11980 *v1 = 0;
11981 v8 = v2;
11982 if ( (signed int)uNumActors > 0 )
11983 {
11984 v5 = pActors;
11985 do
11986 {
11987 v6 = v5->uAttributes;
11988 if ( (v6 & 0x100000) == v8 )
11989 {
11990 ++*v1;
11991 if ( v5->IsAlive() == 1 )
11992 ++v3;
11993 }
11994 ++v4;
11995 ++v5;
11996 }
11997 while ( v4 < (signed int)uNumActors );
11998 }
11999 return v3;
12000 }
12001
12002 //----- (00408A7E) --------------------------------------------------------
12003 unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID)
12004 {
12005 unsigned int *v2; // esi@1
12006 signed int v3; // ebx@1
12007 char *v4; // edi@2
12008 int v5; // eax@3
12009 int v7; // [sp+8h] [bp-Ch]@1
12010 int v8; // [sp+Ch] [bp-8h]@1
12011 unsigned int v9; // [sp+10h] [bp-4h]@1
12012
12013 v7 = uMonsterID;
12014 v2 = pTotalActors;
12015 v3 = 0;
12016 v8 = GetAlertStatus();
12017 *v2 = 0;
12018 v9 = 0;
12019 if ( (signed int)uNumActors > 0 )
12020 {
12021 v4 = (char *)&pActors[0].pMonsterInfo.uID;
12022 do
12023 {
12024 v5 = *((int *)v4 - 15); // actor::attributes
12025 if ( (v5 & 0x100000) == v8 )
12026 {
12027 if ( *(short *)v4 - 1 == v7 )
12028 {
12029 ++*v2;
12030 if ( ((Actor *)(v4 - 96))->IsAlive() == 1 )
12031 ++v9;
12032 }
12033 }
12034 ++v3;
12035 v4 += 836;
12036 }
12037 while ( v3 < (signed int)uNumActors );
12038 }
12039 return v9;
12040 }
12041
12042 //----- (00408AE7) --------------------------------------------------------
12043 unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup)
12044 {
12045 unsigned int *v2; // esi@1
12046 signed int v3; // ebx@1
12047 char *v4; // edi@2
12048 int v5; // eax@3
12049 unsigned int v7; // [sp+8h] [bp-Ch]@1
12050 int v8; // [sp+Ch] [bp-8h]@1
12051 unsigned int v9; // [sp+10h] [bp-4h]@1
12052
12053 v7 = uGroup;
12054 v2 = pTotalActors;
12055 v3 = 0;
12056 v8 = GetAlertStatus();
12057 *v2 = 0;
12058 v9 = 0;
12059 if ( (signed int)uNumActors > 0 )
12060 {
12061 v4 = (char *)&pActors[0].uGroup;
12062 do
12063 {
12064 v5 = *((int *)v4 - 168);
12065 if ( (v5 & 0x100000) == v8 )
12066 {
12067 if ( *(int *)v4 == v7 )
12068 {
12069 ++*v2;
12070 if ( ((Actor *)(v4 - 708))->IsAlive() == 1 )
12071 ++v9;
12072 }
12073 }
12074 ++v3;
12075 v4 += 836;
12076 }
12077 while ( v3 < (signed int)uNumActors );
12078 }
12079 return v9;
12080 }
12081
12082 //----- (00408B54) --------------------------------------------------------
12083 unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
12084 {
12085 unsigned int v2; // edi@1
12086 unsigned int *v3; // esi@1
12087 int v4; // eax@1
12088 unsigned int v5; // ebx@1
12089 unsigned int v6; // edx@1
12090
12091 v2 = a2;
12092 v3 = pTotalActors;
12093 v4 = GetAlertStatus();
12094 v5 = 0;
12095 *v3 = 0;
12096 v6 = pActors[v2].uAttributes;
12097 if ( (v6 & 0x100000) == v4 )
12098 {
12099 *v3 = 1;
12100 if ( pActors[v2].IsAlive() == 1 )
12101 v5 = 1;
12102 }
12103 return v5;
12104 }
12105
12106
12107 //----- (00409BE8) --------------------------------------------------------
12108 void __cdecl sub_409BE8()
12109 {
12110 void *v0; // eax@1
12111 stru348 *v1; // eax@1
12112 int v2; // ecx@1
12113 int v3; // eax@1
12114
12115 v0 = ptr_507BC0->ptr_1C;
12116 dword_4E1874 = 5;
12117 v1 = &stru_4E1890[(int)((char *)v0 - 108)];
12118 amuint_4E1860 = v1->field_4;
12119 amuint_4E1864 = v1->field_6;
12120 amuint_4E1868 = v1->field_8 - 1;
12121 amuint_4E186C = v1->field_A - 1;
12122 amuint_4E1870 = v1->field_C - 1;
12123 amuint_505884 = v1->field_E;
12124 amuint_505888 = v1->field_10;
12125 amuint_50588C = v1->field_12;
12126 dword_4E1878 = 1;
12127 dword_4E187C = 1;
12128 dword_4E1880 = 1;
12129 dword_4E1884 = v1->field_0;
12130 v2 = v1->field_2;
12131 v3 = v1->field_14;
12132 dword_4E1888 = v2;
12133 dword_4DF3A4 = v3;
12134 }
12135 // 4DF3A4: using guessed type int dword_4DF3A4;
12136 // 4E1860: using guessed type int amuint_4E1860;
12137 // 4E1864: using guessed type int amuint_4E1864;
12138 // 4E1868: using guessed type int amuint_4E1868;
12139 // 4E186C: using guessed type int amuint_4E186C;
12140 // 4E1870: using guessed type int amuint_4E1870;
12141 // 4E1874: using guessed type int dword_4E1874;
12142 // 4E1878: using guessed type int dword_4E1878;
12143 // 4E187C: using guessed type int dword_4E187C;
12144 // 4E1880: using guessed type int dword_4E1880;
12145 // 4E1884: using guessed type int dword_4E1884;
12146 // 4E1888: using guessed type int dword_4E1888;
12147 // 505884: using guessed type int amuint_505884;
12148 // 505888: using guessed type int amuint_505888;
12149 // 50588C: using guessed type int amuint_50588C;
12150
12151
12152
12153
12154
12155
12156
12157 //----- (0040D75D) --------------------------------------------------------
12158 char __fastcall pGUIWindow0_draws_text(int a1, const char *pText, int *pXY)
12159 {
12160 const char *v3; // ST0C_4@1
12161 __int64 v4; // qax@1
12162
12163 v3 = pText;
12164 v4 = LOBYTE(pFontComic->uFontHeight) - 3;
12165 return pGUIWindow0->DrawText(
12166 pFontComic,
12167 *pXY,
12168 pXY[1] - (((signed int)v4 - HIDWORD(v4)) >> 1) + 3,
12169 0,
12170 v3,
12171 0,
12172 0,
12173 0);
12174 }
12175
12176
12177
12178 //----- (0040DB27) --------------------------------------------------------
12179 void __fastcall DrawRect(Vec4_int_ *pXYZW, unsigned __int16 uColor, char bSolidFill)
12180 {
12181 Vec4_int_ *v3; // esi@1
12182 unsigned __int16 v4; // bp@1
12183 unsigned int i; // ebx@3
12184
12185 v3 = pXYZW;
12186 v4 = uColor;
12187 pRenderer->BeginScene();
12188 pRenderer->Clip_v2(0, 0, 639u, 479u);
12189 if ( bSolidFill )
12190 {
12191 for ( i = v3->y; (signed int)i <= v3->w; ++i )
12192 pRenderer->FillRect(v3->x, i, v3->z, i, v4);
12193 }
12194 else
12195 {
12196 pRenderer->FillRect(v3->x, v3->y, v3->z, v3->y, v4);
12197 pRenderer->FillRect(v3->z, v3->y, v3->z, v3->w, v4);
12198 pRenderer->FillRect(v3->z, v3->w, v3->x, v3->w, v4);
12199 pRenderer->FillRect(v3->x, v3->w, v3->x, v3->y, v4);
12200 }
12201 pRenderer->EndScene();
12202 }
12203
12204
12205
12206
12207 //----- (0040DDB1) --------------------------------------------------------
12208 int __fastcall rand_interval(int a, int b)
12209 {
12210 return a + rand() % (b - a + 1);
12211 }
12212
12213 //----- (0040DEB4) --------------------------------------------------------
12214 char *__fastcall inv_strcat(const char *Source, char *Dest)
12215 {
12216 return strcat(Dest, Source);
12217 }
12218
12219 //----- (0040DEBE) --------------------------------------------------------
12220 char *__fastcall inv_strcpy(const char *Source, char *Dest)
12221 {
12222 return strcpy(Dest, Source);
12223 }
12224
12225 //----- (0040DEC8) --------------------------------------------------------
12226 void __fastcall intToString(int val, char *pOut)
12227 {
12228 sprintfex(pOut, "%d", val);
12229 }
12230
12231 //----- (0040DEDB) --------------------------------------------------------
12232 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
12233 {
12234 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
12235 }
12236
12237 //----- (0040DEF3) --------------------------------------------------------
12238 unsigned int __fastcall GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b)
12239 {
12240 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));
12241 }
12242
12243 //----- (0040DF3D) --------------------------------------------------------
12244 void __cdecl CallRenderPresent()
12245 {
12246 pRenderer->Present();
12247 }
12248
12249
12250 //----- (0040DFA7) --------------------------------------------------------
12251 int __stdcall retzero_sub_40DFA7(int a1)
12252 {
12253 return 0;
12254 }
12255 // 40DFA7: using guessed type int __stdcall retzero_sub_40DFA7(int);
12256
12257 //----- (0040DFD1) --------------------------------------------------------
12258 void stru272::_40DFD1()
12259 {
12260 stru272 *v1; // esi@1
12261 stru272_stru0 *v2; // eax@1
12262
12263 v1 = this;
12264 v2 = (stru272_stru0 *)malloc(0x5Cu);
12265 v1->ptr_0 = v2;
12266 v2->field_0 = 0x67707274u;
12267 v1->ptr_0->field_8 = 0;
12268 v1->ptr_0->field_30 = 0.0;
12269 v1->ptr_0->field_58 = 0;
12270 v1->ptr_0->field_59 = 0;
12271 }
12272
12273 //----- (0040DFFE) --------------------------------------------------------
12274 int stru272_stru0::_40DFFE()
12275 {
12276 signed int result; // eax@2
12277
12278 if ( this->field_0 == 0x67707274 )
12279 {
12280 this->field_0 = 0x78787878u;
12281 free(this);
12282 result = 0;
12283 }
12284 else
12285 {
12286 result = 2;
12287 }
12288 return result;
12289 }
12290
12291 //----- (0040E01A) --------------------------------------------------------
12292 int stru272_stru0::_40E01A(int a2)
12293 {
12294 signed int result; // eax@2
12295
12296 auto a1 = this;
12297 if ( a1->field_0 == 0x67707274 )
12298 {
12299 a1->field_4 = *(int *)(a2 + 32);
12300 a1->field_C = *(int *)a2 << 16;
12301 a1->field_10 = *(int *)(a2 + 4) << 16;
12302 a1->field_14 = *(int *)(a2 + 8) << 16;
12303 a1->field_18 = *(int *)(a2 + 12) << 16;
12304 a1->field_1C = *(int *)(a2 + 16);
12305 a1->field_20 = *(int *)(a2 + 20);
12306 a1->field_24 = *(int *)(a2 + 24);
12307 a1->field_28 = *(float *)(a2 + 28) * 65536.0;
12308 LODWORD(a1->field_2C) = *(int *)(a2 + 36);
12309 a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0);
12310 a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0);
12311 a1->field_3C = *(int *)(a2 + 48);
12312 a1->field_40 = *(int *)(a2 + 52);
12313 a1->field_54 = *(int *)(a2 + 56);
12314 a1->field_59 = 1;
12315 result = 0;
12316 }
12317 else
12318 {
12319 result = 2;
12320 }
12321 return result;
12322 }
12323
12324 //----- (0040E0F5) --------------------------------------------------------
12325 int stru272_stru0::_40E0F5(char a2, char a3)
12326 {
12327 signed int result; // eax@2
12328 int v4; // edx@7
12329 int v5; // eax@7
12330
12331 auto a1 = this;
12332 if ( a1->field_0 == 0x67707274 )
12333 {
12334 if ( a2 )
12335 {
12336 a1->field_8 = 0;
12337 a1->field_30 = 0.0;
12338 }
12339 if ( a1->field_59 && a3 )
12340 {
12341 v4 = a1->field_4;
12342 v5 = a1->field_54;
12343 do
12344 {
12345 *(int *)v5 = 0;
12346 v5 += 28;
12347 --v4;
12348 }
12349 while ( v4 );
12350 a1->field_58 = 0;
12351 }
12352 result = 0;
12353 }
12354 else
12355 {
12356 result = 2;
12357 }
12358 return result;
12359 }
12360
12361 //----- (0040E133) --------------------------------------------------------
12362 int stru272_stru0::_40E133()
12363 {
12364 stru272_stru0 *v1; // edi@1
12365 int v3; // ST18_4@3
12366 double v4; // st7@3
12367 double v5; // st6@4
12368 char v6; // bl@8
12369 int v7; // esi@8
12370 int v8; // ecx@10
12371 signed int v9; // eax@10
12372 int v10; // ecx@10
12373 signed int v11; // eax@10
12374 signed int v12; // edx@12
12375 signed int v13; // edx@12
12376 int v14; // [sp+8h] [bp-10h]@8
12377 int v15; // [sp+Ch] [bp-Ch]@8
12378 float v16; // [sp+14h] [bp-4h]@3
12379
12380 v1 = this;
12381 if ( this->field_0 != 0x67707274 )
12382 return 2;
12383 v3 = this->field_8;
12384 v16 = this->field_30;
12385 v4 = (double)v3;
12386 if ( v3 > 0 )
12387 {
12388 v5 = v16 + this->field_2C;
12389 v16 = v5;
12390 if ( v5 > v4 )
12391 v16 = v4;
12392 }
12393 if ( v16 >= 1.0 || this->field_58 )
12394 {
12395 v6 = 0;
12396 v7 = this->field_54;
12397 v14 = (signed __int64)this->field_28;
12398 v15 = this->field_4;
12399 while ( *(int *)v7 <= 0 )
12400 {
12401 if ( v16 >= 1.0 )
12402 {
12403 *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1);
12404 *(int *)(v7 + 20) = (rand() % 17 - 8) << 16;
12405 *(int *)(v7 + 24) = (rand() % 17 - 8) << 16;
12406 v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1);
12407 *(int *)(v7 + 12) = v12;
12408 *(int *)(v7 + 4) = v12 >> 16;
12409 v16 = v16 - 1.0;
12410 v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1);
12411 *(int *)(v7 + 16) = v13;
12412 *(int *)(v7 + 8) = v13 >> 16;
12413 --v1->field_8;
12414 goto LABEL_13;
12415 }
12416 LABEL_14:
12417 v7 += 28;
12418 --v15;
12419 if ( !v15 )
12420 {
12421 v1->field_58 = v6;
12422 v1->field_30 = v16;
12423 return 0;
12424 }
12425 }
12426 v8 = *(int *)(v7 + 20);
12427 --*(int *)v7;
12428 v9 = v8 + *(int *)(v7 + 12);
12429 v10 = v14 + *(int *)(v7 + 24);
12430 *(int *)(v7 + 12) = v9;
12431 *(int *)(v7 + 4) = v9 >> 16;
12432 v11 = v10 + *(int *)(v7 + 16);
12433 *(int *)(v7 + 24) = v10;
12434 *(int *)(v7 + 16) = v11;
12435 *(int *)(v7 + 8) = v11 >> 16;
12436 LABEL_13:
12437 v6 = 1;
12438 goto LABEL_14;
12439 }
12440 return 0;
12441 }
12442
12443 //----- (0040E2A7) --------------------------------------------------------
12444 int stru272_stru0::_40E2A7()
12445 {
12446 int result; // eax@2
12447
12448 if ( this->field_0 == 0x67707274 )
12449 {
12450 if ( this->field_8 <= 0 )
12451 result = this->field_58 != 0 ? 2 : 0;
12452 else
12453 result = 1;
12454 }
12455 else
12456 {
12457 result = 3;
12458 }
12459 return result;
12460 }
12461
12462
12463
12464
12465
12466
12467
12468 //----- (0040F82D) --------------------------------------------------------
12469 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue)
12470 {
12471 ZBuffer_DoFill(pZBuffer, (Texture *)(uTextureId != -1 ? 72 * uTextureId + 0x6D084C : 0), iZValue);
12472 }
12473
12474 //----- (0040F845) --------------------------------------------------------
12475 __int16 __fastcall sub_40F845(int a1, int a2, int a3, int a4, int a5, __int16 a6, int a7)
12476 {
12477 int v7; // edi@1
12478 int v8; // esi@1
12479 int v9; // ecx@2
12480 int v10; // eax@3
12481
12482 v7 = a1;
12483 v8 = a2;
12484 do
12485 {
12486 v9 = a3;
12487 do
12488 {
12489 v10 = *(char *)v8++;
12490 if ( (char)v10 )
12491 {
12492 if ( (char)v10 == 1 )
12493 {
12494 LOWORD(v10) = *(short *)(a5 + 2 * v10);
12495 *(short *)v7 = v10;
12496 }
12497 else
12498 {
12499 LOWORD(v10) = a6;
12500 *(short *)v7 = a6;
12501 }
12502 }
12503 v7 += 2;
12504 --v9;
12505 }
12506 while ( v9 );
12507 v7 = a7 + v7 - a3 - a3;
12508 --a4;
12509 }
12510 while ( a4 );
12511 return v10;
12512 }
12513
12514 //----- (0040F89C) --------------------------------------------------------
12515 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue)
12516 {
12517 void *v3; // eax@3
12518 void *v4; // esi@5
12519 int *v5; // edi@5
12520 int v6; // eax@5
12521 int v7; // ecx@6
12522 Texture *v8; // [sp+Ch] [bp-14h]@1
12523 int *v9; // [sp+10h] [bp-10h]@1
12524 int v10; // [sp+14h] [bp-Ch]@1
12525 int v11; // [sp+18h] [bp-8h]@1
12526 void *v12; // [sp+1Ch] [bp-4h]@5
12527
12528 v10 = pTex->uTextureWidth;
12529 v8 = pTex;
12530 v9 = pZBuffer;
12531 v11 = pTex->uTextureHeight;
12532 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize )
12533 v3 = pTex->UnzipPalette();
12534 else
12535 v3 = pTex->pLevelOfDetail0;
12536 v12 = v3;
12537 v4 = v3;
12538 v5 = v9;
12539 v6 = 0;
12540 do
12541 {
12542 v7 = v10;
12543 do
12544 {
12545 LOBYTE(v6) = *(char *)v4;
12546 v4 = (char *)v4 + 1;
12547 if ( v6 )
12548 *v5 = uZValue;
12549 ++v5;
12550 --v7;
12551 }
12552 while ( v7 );
12553 v5 += 640 - v10;
12554 --v11;
12555 }
12556 while ( v11 );
12557 if ( pIcons_LOD->dword_011BA4 )
12558 {
12559 if ( v8->uDecompressedSize )
12560 free(v12);
12561 }
12562 }
12563
12564
12565 //----- (0040F92A) --------------------------------------------------------
12566 void __fastcall sub_40F92A(int *pZBuffer, Texture *a2, int a3)
12567 {
12568 Texture *v3; // esi@1
12569 void *v4; // eax@3
12570 int *v5; // edi@5
12571 int v6; // ecx@6
12572 int *v7; // [sp+Ch] [bp-10h]@1
12573 int v8; // [sp+10h] [bp-Ch]@1
12574 int v9; // [sp+18h] [bp-4h]@1
12575
12576 v3 = a2;
12577 v7 = pZBuffer;
12578 v8 = a2->uTextureWidth;
12579 v9 = a2->uTextureHeight;
12580 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize )
12581 v4 = a2->UnzipPalette();
12582 else
12583 v4 = a2->pLevelOfDetail0;
12584 v5 = v7;
12585 do
12586 {
12587 v6 = v8;
12588 do
12589 {
12590 *v5 = a3;
12591 ++v5;
12592 --v6;
12593 }
12594 while ( v6 );
12595 v5 += 640 - v8;
12596 --v9;
12597 }
12598 while ( v9 );
12599 if ( pIcons_LOD->dword_011BA4 )
12600 {
12601 if ( v3->uDecompressedSize )
12602 free(v4);
12603 }
12604 }
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619 //----- (00410AF5) --------------------------------------------------------
12620 void __cdecl SetMoonPhaseNames()
12621 {
12622 aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
12623 aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
12624 aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
12625 aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
12626 aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
12627 }
12628
12629 //----- (00410B28) --------------------------------------------------------
12630 void __thiscall DrawSpellDescriptionPopup(void *_this)
12631 {
12632 Player *v1; // edi@1
12633 SpellInfo *v2; // esi@1
12634 unsigned int v3; // eax@2
12635 int v4; // eax@4
12636 LONG v5; // ecx@4
12637 int v6; // eax@10
12638 char *v7; // ST44_4@12
12639 unsigned __int16 v8; // ax@12
12640 GUIWindow a1; // [sp+Ch] [bp-68h]@4
12641 void *v10; // [sp+60h] [bp-14h]@1
12642 POINT a2; // [sp+64h] [bp-10h]@1
12643 int v12; // [sp+6Ch] [bp-8h]@4
12644 int v13; // [sp+70h] [bp-4h]@4
12645
12646 v1 = pPlayers[uActiveCharacter];
12647 v10 = _this;
12648 v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->field_1A4E) + 1];
12649 if ( pMouse->GetCursorPos(&a2)->y <= 250 )
12650 v3 = pMouse->GetCursorPos(&a2)->y + 30;
12651 else
12652 v3 = 30;
12653 a1.uFrameY = v3;
12654 a1.uFrameWidth = 328;
12655 a1.uFrameHeight = 68;
12656 a1.uFrameX = 90;
12657 a1.uFrameZ = 417;
12658 a1.uFrameW = v3 + 67;
12659 a1.str_48 = 0;
12660 a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);
12661 v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);
12662 v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);
12663 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);
12664 v5 = a2.y;
12665 if ( v13 > a2.y )
12666 v5 = v13;
12667 if ( v12 > v5 )
12668 v5 = v12;
12669 if ( v4 > v5 )
12670 v5 = v4;
12671 sprintfex(
12672 pTmpBuf2,
12673 "%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",
12674 v2->pDescription,
12675 pGlobalTXT_LocalizationStrings[431],
12676 v5 + 3,
12677 v5 + 10,
12678 v2->pBasicSkillDesc,
12679 pGlobalTXT_LocalizationStrings[433],
12680 v5 + 3,
12681 v5 + 10,
12682 v2->pExpertSkillDesc,
12683 pGlobalTXT_LocalizationStrings[432],
12684 v5 + 3,
12685 v5 + 10,
12686 v2->pMasterSkillDesc,
12687 pGlobalTXT_LocalizationStrings[96],
12688 v5 + 3,
12689 v5 + 10,
12690 v2->pGrandmasterSkillDesc);
12691 v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0);
12692 a1.uFrameHeight += v6;
12693 if ( (signed int)a1.uFrameHeight < 150 )
12694 a1.uFrameHeight = 150;
12695 a1.uFrameWidth = 460;
12696 a1._415551(0);
12697 a1.uFrameWidth -= 12;
12698 a1.uFrameHeight -= 12;
12699 v7 = v2->pName;
12700 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
12701 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
12702 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
12703 a1.DrawText2(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
12704 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
12705 a1.uFrameWidth = 108;
12706 a1.uFrameZ = a1.uFrameX + 107;
12707 a1.DrawText2(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->field_1A4E + 12], 3u);
12708 sprintfex(
12709 pTmpBuf,
12710 "%s\n%d",
12711 pGlobalTXT_LocalizationStrings[522],
12712 *(&pSpellDatas[0].field_14
12713 + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->field_1A4E + 12]) >> 6)
12714 + 10 * (int)((char *)v10 + 11 * v1->field_1A4E)));
12715 a1.DrawText2(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
12716 dword_507B00_spell_info_to_draw_in_popup = 0;
12717 }
12718 // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup;
12719
12720 //----- (00410D99) --------------------------------------------------------
12721 signed int __fastcall sub_410D99_get_map_index(int a1)
12722 {
12723 int v1; // edi@1
12724 signed int v2; // ebp@1
12725 const char **v3; // esi@2
12726 char *v4; // ebx@2
12727
12728 v1 = a1;
12729 v2 = 1;
12730 if ( _strcmpi(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
12731 {
12732 v3 = (const char **)&pMapStats->pInfos[1].pFilename;
12733 v4 = (char *)&pMapStats->pInfos[1].pFilename;
12734 do
12735 {
12736 if ( !*(int *)v4 )
12737 break;
12738 v3 += 17;
12739 ++v2;
12740 v4 = (char *)v3;
12741 }
12742 while ( _strcmpi(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
12743 }
12744 return v2;
12745 }
12746
12747 //----- (00410DEC) --------------------------------------------------------
12748 unsigned int __cdecl DrawLloydBeaconsScreen()
12749 {
12750 Player *v0; // esi@1
12751 char *v1; // eax@1
12752 unsigned __int16 v2; // ax@6
12753 unsigned int result; // eax@11
12754 unsigned int v4; // esi@13
12755 unsigned int v5; // ecx@13
12756 char v6; // zf@13
12757 LloydBeacon *v7; // esi@14
12758 int v8; // eax@14
12759 unsigned __int64 v9; // kr08_8@14
12760 unsigned int v10; // esi@14
12761 unsigned int v11; // eax@14
12762 char *v12; // eax@19
12763 char *v13; // ecx@22
12764 int v14; // eax@27
12765 unsigned int v15; // [sp-10h] [bp-98h]@25
12766 unsigned __int16 v16; // [sp-Ch] [bp-94h]@25
12767 int v17; // [sp-8h] [bp-90h]@21
12768 char *v18; // [sp-8h] [bp-90h]@25
12769 Texture *v19; // [sp-4h] [bp-8Ch]@4
12770 char *v20; // [sp-4h] [bp-8Ch]@21
12771 unsigned int v21; // [sp-4h] [bp-8Ch]@25
12772 GUIWindow v22; // [sp+Ch] [bp-7Ch]@1
12773 unsigned int v23; // [sp+64h] [bp-24h]@14
12774 __int64 v24; // [sp+68h] [bp-20h]@14
12775 unsigned int v25; // [sp+70h] [bp-18h]@13
12776 char *Str; // [sp+74h] [bp-14h]@14
12777 int v27; // [sp+78h] [bp-10h]@11
12778 LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
12779 RGBTexture *v29; // [sp+80h] [bp-8h]@12
12780 int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
12781
12782 v0 = &pParty->pPlayers[_506348_current_lloyd_playerid];
12783 pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
12784 v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon
12785 v22.uFrameX = 8;
12786 v22.uFrameY = 8;
12787 v22.uFrameWidth = 428;
12788 v22.uFrameHeight = 344;
12789 v22.uFrameZ = 435;
12790 v22.uFrameW = 351;
12791 if ( !bRecallingBeacon )
12792 v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon
12793 sprintfex(pTmpBuf, "%s", v1);
12794 v22.DrawText2(pBook2Font, 0, 22u, 0, pTmpBuf, 3u);
12795 if ( bRecallingBeacon )
12796 {
12797 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
12798 v19 = pTex_tab_an_6a__zoom_off;
12799 }
12800 else
12801 {
12802 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
12803 v19 = pTex_tab_an_6b__zoom_on;
12804 }
12805 pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
12806 v2 = v0->pActiveSkills[14];
12807 uNumMaxBeacons = 1;
12808 if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
12809 {
12810 uNumMaxBeacons = 5;
12811 }
12812 else
12813 {
12814 if ( v2 & 0x40 )
12815 uNumMaxBeacons = 3;
12816 }
12817 result = 0;
12818 v27 = 0;
12819 if ( uNumMaxBeacons > 0 )
12820 {
12821 v29 = pSavegameThumbnails;
12822 v28 = v0->pInstalledBeacons;
12823 while ( 1 )
12824 {
12825 v22.uFrameWidth = 92;
12826 v4 = result;
12827 v22.uFrameHeight = 68;
12828 v5 = pLloydsBeaconsPreviewXs[result];
12829 v22.uFrameY = pLloydsBeaconsPreviewYs[result];
12830 v25 = v22.uFrameY;
12831 v22.uFrameX = v5;
12832 v22.uFrameW = v22.uFrameY + 67;
12833 v6 = v29->pPixels == 0;
12834 v22.uFrameZ = v5 + 91;
12835 if ( !v6 )
12836 break;
12837 if ( !bRecallingBeacon )
12838 {
12839 pRenderer->DrawTextureTransparent(
12840 pLloydsBeacons_SomeXs[v4],
12841 pLloydsBeacons_SomeYs[v4],
12842 pTexture_CurrentBook);
12843 v21 = 3;
12844 v18 = pGlobalTXT_LocalizationStrings[19];
12845 v16 = 1;
12846 v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &v22, 0, 0);
12847 v15 = (signed int)v22.uFrameHeight / 2 - v14 / 2;
12848 goto LABEL_28;
12849 }
12850 LABEL_29:
12851 ++v29;
12852 ++v28;
12853 result = v27++ + 1;
12854 if ( v27 >= uNumMaxBeacons )
12855 goto LABEL_30;
12856 }
12857 pRenderer->DrawTextureTransparent(
12858 pLloydsBeacons_SomeXs[v4],
12859 pLloydsBeacons_SomeYs[v4],
12860 pTexture_CurrentBook);
12861 pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
12862 v7 = v28;
12863 Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
12864 v8 = pSpellFont->CalcTextHeight(Str, &v22, 0, 0);
12865 v22.uFrameY += -6 - v8;
12866 v22.DrawText2(pSpellFont, 0, 0, 1u, Str, 3u);
12867 v9 = v7->uBeaconTime - pParty->uTimePlayed;
12868 LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
12869 HIDWORD(v24) = HIDWORD(v9);
12870 v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
12871 v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
12872 v11 = v10 / 0x18;
12873 if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
12874 {
12875 v13 = pGlobalTXT_LocalizationStrings[57]; // Days
12876 if ( v11 > 1 )
12877 {
12878 LABEL_24:
12879 v20 = v13;
12880 v17 = v11 + 1;
12881 LABEL_25:
12882 sprintfex(pTmpBuf, "%lu %s", v17, v20);
12883 v21 = 3;
12884 v18 = pTmpBuf;
12885 v16 = 1;
12886 v22.uFrameY = v25 + v22.uFrameHeight + 4;
12887 v15 = 0;
12888 LABEL_28:
12889 v22.DrawText2(pSpellFont, 0, v15, v16, v18, v21);
12890 goto LABEL_29;
12891 }
12892 }
12893 else
12894 {
12895 if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
12896 {
12897 if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
12898 v12 = pGlobalTXT_LocalizationStrings[109];// Hour
12899 else
12900 v12 = pGlobalTXT_LocalizationStrings[110];// Hours
12901 v20 = v12;
12902 v17 = v10 + 1;
12903 goto LABEL_25;
12904 }
12905 }
12906 v13 = pGlobalTXT_LocalizationStrings[56]; // Day
12907 goto LABEL_24;
12908 }
12909 LABEL_30:
12910 if ( byte_506360 )
12911 {
12912 result = pMessageQueue_50CBD0->uNumMessages;
12913 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12914 {
12915 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)181;
12916 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
12917 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
12918 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
12919 ++pMessageQueue_50CBD0->uNumMessages;
12920 }
12921 }
12922 return result;
12923 }
12924
12925
12926 //----- (00411150) --------------------------------------------------------
12927 char *__cdecl DrawTownPortalScreen()
12928 {
12929 signed int v0; // edi@1
12930 __int16 v1; // dx@8
12931 POINT *v2; // edi@17
12932 int v3; // edi@17
12933 __int16 v4; // dx@24
12934 GUIWindow v6; // [sp+Ch] [bp-64h]@1
12935 POINT v7; // [sp+60h] [bp-10h]@17
12936 POINT a2; // [sp+68h] [bp-8h]@17
12937
12938 pRenderer->ClearZBuffer(0, 479);
12939 pRenderer->DrawTextureTransparent(8u, 8u, pTexture_CurrentBook);
12940 pRenderer->DrawTextureTransparent(
12941 0x1D7u,
12942 0x1BDu,
12943 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
12944 v6.uFrameX = 8;
12945 v6.uFrameY = 8;
12946 v6.uFrameWidth = 460;
12947 v6.uFrameHeight = 344;
12948 v6.uFrameZ = 467;
12949 v6.uFrameW = 351;
12950 v0 = 0;
12951 do
12952 {
12953 if ( !v0 )
12954 {
12955 v1 = 206;
12956 LABEL_14:
12957 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, v1) )
12958 goto LABEL_16;
12959 goto LABEL_15;
12960 }
12961 if ( v0 == 1 )
12962 {
12963 v1 = 208;
12964 goto LABEL_14;
12965 }
12966 if ( v0 == 2 )
12967 {
12968 v1 = 207;
12969 goto LABEL_14;
12970 }
12971 if ( v0 == 3 )
12972 {
12973 v1 = 211;
12974 goto LABEL_14;
12975 }
12976 if ( v0 == 4 )
12977 {
12978 v1 = 209;
12979 goto LABEL_14;
12980 }
12981 if ( v0 == 5 )
12982 {
12983 v1 = 210;
12984 goto LABEL_14;
12985 }
12986 LABEL_15:
12987 pRenderer->_4A612A(
12988 pTownPortalBook_xs[v0],
12989 pTownPortalBook_ys[v0],
12990 *(&pTexture_TownPortalHarmn + v0),
12991 v0 + 1);
12992 LABEL_16:
12993 ++v0;
12994 }
12995 while ( v0 < 6 );
12996 v2 = pMouse->GetCursorPos(&a2);
12997 v3 = pRenderer->pActiveZBuffer[v2->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF;
12998 if ( !v3 ) // Town Portal
12999 return v6.DrawText2(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
13000 if ( v3 == 1 )
13001 {
13002 v4 = 206;
13003 LABEL_30:
13004 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, v4) )
13005 goto LABEL_31;
13006 return v6.DrawText2(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
13007 }
13008 if ( v3 == 2 )
13009 {
13010 v4 = 208;
13011 goto LABEL_30;
13012 }
13013 if ( v3 == 3 )
13014 {
13015 v4 = 207;
13016 goto LABEL_30;
13017 }
13018 if ( v3 == 4 )
13019 {
13020 v4 = 211;
13021 goto LABEL_30;
13022 }
13023 if ( v3 == 5 )
13024 {
13025 v4 = 209;
13026 goto LABEL_30;
13027 }
13028 if ( v3 == 6 )
13029 {
13030 v4 = 210;
13031 goto LABEL_30;
13032 }
13033 LABEL_31:
13034 pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3));
13035 return v6.DrawText2(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
13036 }
13037 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
13038
13039 //----- (00411300) --------------------------------------------------------
13040 Texture *__fastcall LoadSpellbook(unsigned int uID)
13041 {
13042 unsigned int v1; // esi@1
13043 Player *pPlayer; // ecx@1
13044 char v3; // al@1
13045 int v4; // edi@5
13046 Texture *result; // eax@6
13047 char *v6; // edi@7
13048 unsigned int v7; // eax@7
13049 unsigned __int8 v8; // sf@8
13050 unsigned __int8 v9; // of@8
13051 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
13052 Texture *v11; // [sp+20h] [bp-8h]@5
13053 int v12; // [sp+24h] [bp-4h]@5
13054
13055 byte_506550 = 0;
13056 v1 = uID;
13057 pPlayer = pPlayers[uActiveCharacter];
13058 v3 = pPlayer->uQuickSpell;
13059 if ( v3 && (unsigned __int8)v3 / 11 == v1 )
13060 dword_50654C = (unsigned __int8)v3 - 11 * v1;
13061 else
13062 dword_50654C = 0;
13063 v4 = 1;
13064 v12 = 1;
13065 v11 = (Texture *)&pPlayer->field_152[11 * v1 + 63];
13066 do
13067 {
13068 result = v11;
13069 if ( v11->pName[v4] )
13070 {
13071 v6 = &byte_4E2430[12 * v1] + v4;
13072 sprintfex(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
13073 v7 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
13074 dword_506408[v12] = 72 * v7 + 7145548;
13075 sprintfex(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
13076 result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
13077 dword_5063D8[v12] = result;
13078 }
13079 v4 = v12 + 1;
13080 v9 = __OFSUB__(v12 + 1, 12);
13081 v8 = v12++ - 11 < 0;
13082 }
13083 while ( v8 ^ v9 );
13084 return result;
13085 }
13086 // 4E1D18: using guessed type char *spellbook_texture_filename_suffices[8];
13087 // 506408: using guessed type int dword_506408[];
13088 // 50654C: using guessed type int dword_50654C;
13089 // 506550: using guessed type char byte_506550;
13090
13091 //----- (0041140B) --------------------------------------------------------
13092 GUIWindow *__cdecl sub_41140B()
13093 {
13094 signed int v0; // esi@1
13095 GUIButton *v1; // eax@3
13096 GUIButton *v2; // esi@4
13097 GUIWindow *result; // eax@5
13098
13099 v0 = 0;
13100 do
13101 {
13102 dword_506404[v0]->Release();
13103 dword_506434[v0]->Release();
13104 --v0;
13105 }
13106 while ( v0 >= -11 );
13107 pIcons_LOD->_40F9C5();
13108 v1 = pGUIWindow_CurrentMenu->pControlsHead;
13109 if ( v1 )
13110 {
13111 do
13112 {
13113 v2 = v1->pNext;
13114 pAllocator->FreeChunk(v1);
13115 v1 = v2;
13116 }
13117 while ( v2 );
13118 }
13119 pGUIWindow_CurrentMenu->pControlsHead = 0;
13120 pGUIWindow_CurrentMenu->pControlsTail = 0;
13121 result = pGUIWindow_CurrentMenu;
13122 pGUIWindow_CurrentMenu->uNumControls = 0;
13123 return result;
13124 }
13125
13126 //----- (00411473) --------------------------------------------------------
13127 void __cdecl sub_411473()
13128 {
13129 char *v0; // esi@1
13130 Texture **v1; // edi@1
13131 Texture *v2; // ecx@2
13132 Texture *v3; // ecx@2
13133
13134 pTexture_pagemask->Release();
13135 pTexture_506448->Release();
13136 pTexture_50643C->Release();
13137 v0 = &pTextures_tabs[0][0].pName[4];
13138 v1 = pTextures_5064A0;
13139 do
13140 {
13141 (*v1)->Release();
13142 v2 = (Texture *)*((int *)v0 - 1);
13143 *v1 = 0;
13144 v2->Release();
13145 v3 = *(Texture **)v0;
13146 *((int *)v0 - 1) = 0;
13147 v3->Release();
13148 *(int *)v0 = 0;
13149 ++v1;
13150 v0 += 8;
13151 }
13152 while ( (signed int)v1 < (signed int)&pTextures_5064A0[9] );
13153 pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
13154 pIcons_LOD->_4114F2();
13155 }
13156
13157
13158 //----- (00411597) --------------------------------------------------------
13159 void __cdecl OnCloseSpellook()
13160 {
13161 pAllocator->FreeChunk(pSpellFont);
13162 pSpellFont = 0;
13163 pAllocator->FreeChunk(pBookFont);
13164 pBookFont = 0;
13165 pAllocator->FreeChunk(pBook2Font);
13166 pBook2Font = 0;
13167 pAllocator->FreeChunk(pAutonoteFont);
13168 pAutonoteFont = 0;
13169 pTexture_mapbordr->Release();
13170 pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
13171 pIcons_LOD->_4114F2();
13172 dword_506364 = 0;
13173 }
13174 // 506364: using guessed type int dword_506364;
13175
13176
13177
13178
13179
13180
13181
13182 //----- (00412AF9) --------------------------------------------------------
13183 void __cdecl sub_412AF9()
13184 {
13185 int v0; // ecx@1
13186
13187 v0 = 0;
13188 if ( uActiveCharacter )
13189 v0 = *((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
13190 pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
13191 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
13192 pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
13193 }
13194
13195 //----- (00412B58) --------------------------------------------------------
13196 void __cdecl sub_412B58()
13197 {
13198 Player *v0; // ebx@1
13199 int v1; // ebp@1
13200 unsigned int v2; // eax@1
13201 Texture *v3; // edi@1
13202 int v4; // esi@1
13203 Texture *v5; // eax@3
13204 Texture *v6; // edx@5
13205 int v7; // eax@8
13206 int v8; // eax@11
13207 POINT *v9; // esi@13
13208 int v10; // eax@13
13209 Texture *v11; // edx@14
13210 int v12; // eax@15
13211 signed int v13; // ecx@18
13212 unsigned int v14; // esi@18
13213 unsigned int v15; // edi@18
13214 Texture *v16; // eax@21
13215 unsigned int v17; // [sp-Ch] [bp-2Ch]@8
13216 unsigned int v18; // [sp-Ch] [bp-2Ch]@15
13217 unsigned int v19; // [sp-8h] [bp-28h]@8
13218 unsigned int v20; // [sp-8h] [bp-28h]@15
13219 Texture *v21; // [sp-4h] [bp-24h]@15
13220 signed int v22; // [sp-4h] [bp-24h]@22
13221 int v23[2]; // [sp+10h] [bp-10h]@5
13222 POINT a2; // [sp+18h] [bp-8h]@13
13223
13224 sub_412AF9();
13225 v0 = pPlayers[uActiveCharacter];
13226 v1 = 11 * v0->field_1A4E;
13227 v2 = pIcons_LOD->FindTextureByName("Pending");
13228 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
13229 pRenderer->ClearZBuffer(0, 479);
13230 v4 = 1;
13231 if ( __OFSUB__(v1, v1 + 11) ^ 1 )
13232 {
13233 do
13234 {
13235 if ( *(&v0->field_152[v1 + 63] + v4) )
13236 {
13237 v5 = (Texture *)dword_506408[v4];
13238 if ( v5 != v3 )
13239 {
13240 if ( dword_50654C == v4 )
13241 {
13242 v6 = dword_5063D8[v4];
13243 v23[0] = (int)dword_5063D8[v4];
13244 }
13245 else
13246 {
13247 v23[0] = dword_506408[v4];
13248 v6 = v5;
13249 }
13250 if ( v6->pLevelOfDetail0 )
13251 {
13252 v7 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v4));
13253 v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
13254 v17 = pViewport->uViewportX + dword_4E20D0[v7];
13255 if ( BYTE1(v6->pBits) & 2 )
13256 pRenderer->DrawTextureTransparent(v17, v19, v6);
13257 else
13258 pRenderer->DrawTextureIndexed(v17, v19, v6);
13259 v8 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v4));
13260 pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], (Texture *)v23[0], v4);
13261 }
13262 }
13263 }
13264 ++v4;
13265 }
13266 while ( v4 + v1 - 1 < v1 + 11 );
13267 }
13268 v9 = pMouse->GetCursorPos(&a2);
13269 v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)v23)->y]] & 0xFFFF;
13270 if ( v10 )
13271 {
13272 v11 = dword_5063D8[v10];
13273 if ( v11->pLevelOfDetail0 )
13274 {
13275 v21 = dword_5063D8[v10];
13276 v12 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v10));
13277 v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
13278 v18 = pViewport->uViewportX + dword_4E20D0[v12];
13279 if ( BYTE1(v11->pBits) & 2 )
13280 pRenderer->DrawTextureTransparent(v18, v20, v21);
13281 else
13282 pRenderer->DrawTextureIndexed(v18, v20, v21);
13283 }
13284 }
13285 v13 = 0;
13286 a2.x = (LONG)&v0->pActiveSkills[12];
13287 v14 = (unsigned int)&v0->pActiveSkills[12];
13288 v15 = (unsigned int)&v0->pActiveSkills[12];
13289 v23[0] = 0;
13290 do
13291 {
13292 if ( *(short *)a2.x )
13293 {
13294 if ( v0->field_1A4E == v13 )
13295 {
13296 v16 = *(Texture **)&pTextures_tabs[0][0].pName[8 * v13 + 4];
13297 switch ( v13 )
13298 {
13299 case 0:
13300 v14 = 406;
13301 v22 = 9;
13302 goto LABEL_27;
13303 case 1:
13304 v14 = 406;
13305 goto LABEL_38;
13306 case 2:
13307 v14 = 406;
13308 v22 = 84;
13309 goto LABEL_27;
13310 case 3:
13311 v14 = 406;
13312 goto LABEL_26;
13313 case 4:
13314 v14 = 407;
13315 goto LABEL_29;
13316 case 5:
13317 v15 = 196;
13318 goto LABEL_34;
13319 case 6:
13320 v15 = 234;
13321 goto LABEL_34;
13322 case 7:
13323 v15 = 272;
13324 goto LABEL_34;
13325 case 8:
13326 v15 = 309;
13327 LABEL_34:
13328 v14 = 405;
13329 break;
13330 default:
13331 break;
13332 }
13333 }
13334 else
13335 {
13336 v16 = *(Texture **)&pTextures_tabs[0][0].pName[8 * v13];
13337 switch ( v13 )
13338 {
13339 case 0:
13340 v14 = 415;
13341 v22 = 10;
13342 goto LABEL_27;
13343 case 1:
13344 v14 = 415;
13345 LABEL_38:
13346 v22 = 46;
13347 goto LABEL_27;
13348 case 2:
13349 v14 = 415;
13350 v22 = 83;
13351 goto LABEL_27;
13352 case 3:
13353 v14 = 415;
13354 LABEL_26:
13355 v22 = 121;
13356 LABEL_27:
13357 v15 = v22;
13358 break;
13359 case 4:
13360 v14 = 415;
13361 LABEL_29:
13362 v15 = 158;
13363 break;
13364 case 5:
13365 v15 = 196;
13366 goto LABEL_46;
13367 case 6:
13368 v15 = 234;
13369 goto LABEL_46;
13370 case 7:
13371 v15 = 271;
13372 goto LABEL_46;
13373 case 8:
13374 v15 = 307;
13375 LABEL_46:
13376 v14 = 416;
13377 break;
13378 default:
13379 break;
13380 }
13381 }
13382 pRenderer->DrawTextureTransparent(v14, v15, v16);
13383 v13 = v23[0];
13384 }
13385 a2.x += 2;
13386 ++v13;
13387 v23[0] = v13;
13388 }
13389 while ( v13 < 9 );
13390 }
13391 // 506408: using guessed type int dword_506408[];
13392 // 50654C: using guessed type int dword_50654C;
13393
13394 //----- (00412E85) --------------------------------------------------------
13395 char __cdecl sub_412E85()
13396 {
13397 unsigned int v0; // eax@3
13398 unsigned int v1; // eax@7
13399 int v2; // eax@10
13400 const char *v3; // eax@10
13401 signed int v4; // ecx@12
13402 int v5; // ecx@14
13403 int v6; // eax@21
13404 int v7; // esi@21
13405 char *v8; // eax@21
13406 int v9; // eax@22
13407 unsigned int v11; // [sp-8h] [bp-64h]@3
13408 unsigned int v12; // [sp-8h] [bp-64h]@7
13409 Texture *v13; // [sp-4h] [bp-60h]@3
13410 Texture *v14; // [sp-4h] [bp-60h]@7
13411 GUIWindow a1; // [sp+8h] [bp-54h]@10
13412
13413 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[11]);
13414 if ( dword_506548 || !dword_506528 )
13415 {
13416 v13 = pTex_tab_an_6a__zoom_off;
13417 v11 = pViewport->uViewportY + 2;
13418 v0 = pViewport->uViewportX + 407;
13419 }
13420 else
13421 {
13422 v13 = pTex_tab_an_6b__zoom_on;
13423 v11 = pViewport->uViewportY + 1;
13424 v0 = pViewport->uViewportX + 398;
13425 }
13426 pRenderer->DrawTextureTransparent(v0, v11, v13);
13427 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
13428 {
13429 v14 = pTex_tab_an_7a__zoot_off;
13430 v12 = pViewport->uViewportY + 38;
13431 v1 = pViewport->uViewportX + 407;
13432 }
13433 else
13434 {
13435 v14 = pTex_tab_an_7b__zoot_on;
13436 v12 = pViewport->uViewportY + 38;
13437 v1 = pViewport->uViewportX + 398;
13438 }
13439 pRenderer->DrawTextureTransparent(v1, v12, v14);
13440 if ( !byte_5C6D50[dword_506528] )
13441 {
13442 v2 = pStru179->field_0[dword_506528];
13443 a1.uFrameWidth = 460;
13444 a1.uFrameX = 8;
13445 a1.uFrameY = 8;
13446 a1.uFrameHeight = 344;
13447 v3 = (const char *)pStorylineText->field_4[3 * v2];
13448 a1.uFrameZ = 467;
13449 a1.uFrameW = 351;
13450 if ( v3 )
13451 a1.DrawText2(pBook2Font, 0, 0x16u, 0, v3, 3u);
13452 }
13453 a1.uFrameX = 48;
13454 a1.uFrameY = 70;
13455 a1.uFrameWidth = 360;
13456 a1.uFrameHeight = 264;
13457 v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
13458 a1.uFrameZ = 407;
13459 a1.uFrameHeight = v4 * 264 / v4;
13460 a1.uFrameW = a1.uFrameHeight + 69;
13461 if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
13462 {
13463 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13464 v5 = dword_50651C++;
13465 dword_506528 += dword_506520;
13466 byte_506130[v5] = dword_506520;
13467 }
13468 if ( dword_506548 && dword_50651C )
13469 {
13470 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13471 --dword_50651C;
13472 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
13473 }
13474 if ( !dword_506520 || dword_506528 < 1 )
13475 {
13476 dword_506528 = 0;
13477 dword_50651C = 0;
13478 }
13479 dword_506544 = 0;
13480 v6 = pStru179->field_0[dword_506528];
13481 dword_506548 = 0;
13482 dword_506520 = 0;
13483 v7 = *(&pStorylineText->field_0 + 3 * v6);
13484 v8 = sub_495461(
13485 *((char **)&pStorylineText->field_0 + 3 * v6),
13486 uActiveCharacter - 1,
13487 0,
13488 0,
13489 0,
13490 (__int64 *)&pParty->field_3C.field_440[2 * v6 + 42]);
13491 if ( v7 )
13492 {
13493 v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
13494 LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
13495 ++dword_506520;
13496 }
13497 return (char)v8;
13498 }
13499
13500
13501 //----- (00413126) --------------------------------------------------------
13502 void __cdecl DrawSpellbook_Quests()
13503 {
13504 unsigned int v0; // eax@3
13505 unsigned int v1; // eax@7
13506 int v2; // ecx@11
13507 int v3; // ebx@16
13508 int v4; // eax@19
13509 const char *v5; // edi@19
13510 int v6; // eax@19
13511 unsigned int v7; // edi@19
13512 unsigned int v8; // [sp-8h] [bp-68h]@3
13513 unsigned int v9; // [sp-8h] [bp-68h]@7
13514 Texture *v10; // [sp-4h] [bp-64h]@3
13515 Texture *v11; // [sp-4h] [bp-64h]@7
13516 GUIWindow a1; // [sp+Ch] [bp-54h]@9
13517
13518 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_CurrentBook);
13519 if ( dword_506548 || !dword_506528 )
13520 {
13521 v10 = pTex_tab_an_6a__zoom_off;
13522 v8 = pViewport->uViewportY + 2;
13523 v0 = pViewport->uViewportX + 407;
13524 }
13525 else
13526 {
13527 v10 = pTex_tab_an_6b__zoom_on;
13528 v8 = pViewport->uViewportY + 1;
13529 v0 = pViewport->uViewportX + 398;
13530 }
13531 pRenderer->DrawTextureTransparent(v0, v8, v10);
13532 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
13533 {
13534 v11 = pTex_tab_an_7a__zoot_off;
13535 v9 = pViewport->uViewportY + 38;
13536 v1 = pViewport->uViewportX + 407;
13537 }
13538 else
13539 {
13540 v11 = pTex_tab_an_7b__zoot_on;
13541 v9 = pViewport->uViewportY + 38;
13542 v1 = pViewport->uViewportX + 398;
13543 }
13544 pRenderer->DrawTextureTransparent(v1, v9, v11);
13545 a1.uFrameWidth = 460;
13546 a1.uFrameHeight = 344;
13547 a1.uFrameX = 8;
13548 a1.uFrameY = 8;
13549 a1.uFrameZ = 467;
13550 a1.uFrameW = 351;
13551 a1.DrawText2(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[174], 3u);
13552 a1.uFrameX = 48;
13553 a1.uFrameY = 70;
13554 a1.uFrameWidth = 360;
13555 a1.uFrameHeight = 264;
13556 a1.uFrameZ = 407;
13557 a1.uFrameW = 333;
13558 if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
13559 {
13560 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13561 v2 = dword_50651C++;
13562 dword_506528 += dword_506520;
13563 byte_506130[v2] = dword_506520;
13564 }
13565 if ( dword_506548 && dword_50651C )
13566 {
13567 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13568 --dword_50651C;
13569 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
13570 }
13571 if ( !dword_506520 || (v3 = dword_506528, dword_506528 < 1) )
13572 {
13573 v3 = 0;
13574 dword_50651C = 0;
13575 dword_506528 = 0;
13576 }
13577 dword_506544 = 0;
13578 dword_506548 = 0;
13579 dword_506520 = 0;
13580 while ( v3 < dword_506524 )
13581 {
13582 v4 = pStru179->field_0[v3];
13583 ++dword_506520;
13584 v5 = (&dword_722F10)[4 * v4];
13585 a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_722F10)[4 * v4], 0, 0, 0);
13586 v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
13587 v7 = a1.uFrameY + v6;
13588 if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight )
13589 break;
13590 pRenderer->DrawTextureTransparent(0x64u, v7 + 12, pTextures_5064A0[10]);
13591 ++v3;
13592 a1.uFrameY = v7 + 24;
13593 }
13594 }
13595
13596
13597 //----- (0041338E) --------------------------------------------------------
13598 void __cdecl DrawSpellbook_Autonotes()
13599 {
13600 unsigned int v0; // eax@3
13601 unsigned int v1; // eax@7
13602 signed int v2; // ebp@11
13603 unsigned int v3; // eax@18
13604 unsigned int v4; // eax@24
13605 unsigned int v5; // eax@30
13606 unsigned int v6; // eax@36
13607 unsigned int v7; // eax@42
13608 signed int v8; // ebp@47
13609 int v9; // eax@52
13610 int v10; // eax@56
13611 int v11; // edx@57
13612 int v12; // ebp@64
13613 int v13; // eax@65
13614 const char *v14; // edi@65
13615 int v15; // eax@65
13616 unsigned int v16; // edi@65
13617 unsigned int v17; // [sp-8h] [bp-70h]@3
13618 unsigned int v18; // [sp-8h] [bp-70h]@7
13619 unsigned int v19; // [sp-8h] [bp-70h]@18
13620 unsigned int v20; // [sp-8h] [bp-70h]@24
13621 unsigned int v21; // [sp-8h] [bp-70h]@30
13622 unsigned int v22; // [sp-8h] [bp-70h]@36
13623 unsigned int v23; // [sp-8h] [bp-70h]@42
13624 Texture *v24; // [sp-4h] [bp-6Ch]@3
13625 Texture *v25; // [sp-4h] [bp-6Ch]@7
13626 Texture *v26; // [sp-4h] [bp-6Ch]@18
13627 Texture *v27; // [sp-4h] [bp-6Ch]@24
13628 Texture *v28; // [sp-4h] [bp-6Ch]@30
13629 Texture *v29; // [sp-4h] [bp-6Ch]@36
13630 Texture *v30; // [sp-4h] [bp-6Ch]@42
13631 signed __int16 v31; // [sp+10h] [bp-58h]@1
13632 char *v32; // [sp+10h] [bp-58h]@49
13633 GUIWindow a1; // [sp+14h] [bp-54h]@46
13634
13635 v31 = 0;
13636 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_AutonotesBook);
13637 if ( dword_506548 || !dword_506528 )
13638 {
13639 v24 = pTex_tab_an_6a__zoom_off;
13640 v17 = pViewport->uViewportY + 2;
13641 v0 = pViewport->uViewportX + 407;
13642 }
13643 else
13644 {
13645 v24 = pTex_tab_an_6b__zoom_on;
13646 v17 = pViewport->uViewportY + 1;
13647 v0 = pViewport->uViewportX + 398;
13648 }
13649 pRenderer->DrawTextureTransparent(v0, v17, v24);
13650 if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
13651 {
13652 v25 = pTex_tab_an_7a__zoot_off;
13653 v18 = pViewport->uViewportY + 38;
13654 v1 = pViewport->uViewportX + 407;
13655 }
13656 else
13657 {
13658 v25 = pTex_tab_an_7b__zoot_on;
13659 v18 = pViewport->uViewportY + 38;
13660 v1 = pViewport->uViewportX + 398;
13661 }
13662 pRenderer->DrawTextureTransparent(v1, v18, v25);
13663 if ( !dword_506540 )
13664 {
13665 if ( dword_506568 )
13666 {
13667 pRenderer->DrawTextureTransparent(
13668 pViewport->uViewportX + 408,
13669 pViewport->uViewportY + 113,
13670 pTexture_506390);
13671 v2 = 1;
13672 goto LABEL_16;
13673 }
13674 goto LABEL_14;
13675 }
13676 if ( !dword_506568 )
13677 {
13678 LABEL_14:
13679 v2 = 1;
13680 goto LABEL_15;
13681 }
13682 v2 = 1;
13683 v31 = 1;
13684 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13685 LABEL_15:
13686 dword_506568 = 0;
13687 pRenderer->DrawTextureTransparent(pViewport->uViewportX + 398, pViewport->uViewportY + 113, pTexture_506394);
13688 LABEL_16:
13689 if ( dword_50653C )
13690 {
13691 if ( dword_506568 != v2 )
13692 {
13693 v31 = v2;
13694 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13695 }
13696 }
13697 else
13698 {
13699 if ( dword_506568 != v2 )
13700 {
13701 v26 = pTexture_506388;
13702 v19 = pViewport->uViewportY + 150;
13703 v3 = pViewport->uViewportX + 408;
13704 goto LABEL_22;
13705 }
13706 }
13707 v26 = pTexture_50638C;
13708 dword_506568 = v2;
13709 v19 = pViewport->uViewportY + 150;
13710 v3 = pViewport->uViewportX + 399;
13711 LABEL_22:
13712 pRenderer->DrawTextureTransparent(v3, v19, v26);
13713 if ( dword_506538 )
13714 {
13715 if ( dword_506568 != 2 )
13716 {
13717 v31 = v2;
13718 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13719 }
13720 }
13721 else
13722 {
13723 if ( dword_506568 != 2 )
13724 {
13725 v27 = pTexture_506380;
13726 v20 = pViewport->uViewportY + 188;
13727 v4 = pViewport->uViewportX + 408;
13728 goto LABEL_28;
13729 }
13730 }
13731 v27 = pTexture_506384;
13732 dword_506568 = 2;
13733 v20 = pViewport->uViewportY + 188;
13734 v4 = pViewport->uViewportX + 397;
13735 LABEL_28:
13736 pRenderer->DrawTextureTransparent(v4, v20, v27);
13737 if ( dword_506534 )
13738 {
13739 if ( dword_506568 != 3 )
13740 {
13741 v31 = v2;
13742 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13743 }
13744 }
13745 else
13746 {
13747 if ( dword_506568 != 3 )
13748 {
13749 v28 = pTexture_506378;
13750 v21 = pViewport->uViewportY + 226;
13751 v5 = pViewport->uViewportX + 408;
13752 goto LABEL_34;
13753 }
13754 }
13755 v28 = pTexture_50637C;
13756 dword_506568 = 3;
13757 v21 = pViewport->uViewportY + 226;
13758 v5 = pViewport->uViewportX + 397;
13759 LABEL_34:
13760 pRenderer->DrawTextureTransparent(v5, v21, v28);
13761 if ( dword_506530 )
13762 {
13763 if ( dword_506568 != 4 )
13764 {
13765 v31 = v2;
13766 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13767 }
13768 }
13769 else
13770 {
13771 if ( dword_506568 != 4 )
13772 {
13773 v29 = pTexture_506370;
13774 v22 = pViewport->uViewportY + 263;
13775 v6 = pViewport->uViewportX + 408;
13776 goto LABEL_40;
13777 }
13778 }
13779 v29 = pTexture_506374;
13780 dword_506568 = 4;
13781 v22 = pViewport->uViewportY + 264;
13782 v6 = pViewport->uViewportX + 397;
13783 LABEL_40:
13784 pRenderer->DrawTextureTransparent(v6, v22, v29);
13785 if ( dword_50652C )
13786 {
13787 if ( dword_506568 != 5 )
13788 {
13789 v31 = v2;
13790 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
13791 }
13792 }
13793 else
13794 {
13795 if ( dword_506568 != 5 )
13796 {
13797 v30 = pTexture_506368;
13798 v23 = pViewport->uViewportY + 302;
13799 v7 = pViewport->uViewportX + 408;
13800 goto LABEL_46;
13801 }
13802 }
13803 v30 = pTexture_50636C;
13804 dword_506568 = 5;
13805 v23 = pViewport->uViewportY + 302;
13806 v7 = pViewport->uViewportX + 397;
13807 LABEL_46:
13808 pRenderer->DrawTextureTransparent(v7, v23, v30);
13809 a1.uFrameWidth = 460;
13810 a1.uFrameHeight = 344;
13811 a1.uFrameX = 8;
13812 a1.uFrameY = 8;
13813 a1.uFrameZ = 467;
13814 a1.uFrameW = 467;
13815 a1.DrawText2(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[154], 3u);
13816 a1.uFrameX = 48;
13817 a1.uFrameY = 70;
13818 a1.uFrameWidth = 360;
13819 a1.uFrameHeight = 264;
13820 a1.uFrameZ = 407;
13821 a1.uFrameW = 333;
13822 if ( v31 )
13823 {
13824 dword_506524 = 0;
13825 dword_506528 = 0;
13826 dword_50651C = 0;
13827 dword_506520 = 0;
13828 v8 = 0;
13829 do
13830 {
13831 if ( dword_72371C[2 * v8] == dword_506568 )
13832 {
13833 v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8];
13834 if ( (short)v8 )
13835 {
13836 if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pParty->_autonote_related_stuff, v8) && v32 )
13837 {
13838 v9 = dword_506520++;
13839 pStru179->field_0[v9] = (signed __int16)v8;
13840 }
13841 }
13842 }
13843 ++v8;
13844 }
13845 while ( v8 < 196 );
13846 dword_506524 = dword_506520;
13847 }
13848 else
13849 {
13850 if ( dword_506544 )
13851 {
13852 v10 = dword_506520 + dword_506528;
13853 if ( dword_506520 + dword_506528 < dword_506524 )
13854 {
13855 v11 = dword_50651C++;
13856 byte_506130[v11] = dword_506520;
13857 dword_506528 = v10;
13858 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13859 }
13860 }
13861 if ( dword_506548 && dword_50651C )
13862 {
13863 --dword_50651C;
13864 dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
13865 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
13866 }
13867 if ( !dword_506520 || dword_506528 < 1 )
13868 {
13869 dword_506528 = 0;
13870 dword_50651C = 0;
13871 }
13872 }
13873 v12 = dword_506528;
13874 dword_50652C = 0;
13875 dword_506544 = 0;
13876 dword_506548 = 0;
13877 dword_506520 = 0;
13878 dword_506530 = 0;
13879 dword_506534 = 0;
13880 dword_506538 = 0;
13881 dword_50653C = 0;
13882 dword_506540 = 0;
13883 while ( v12 < dword_506524 )
13884 {
13885 v13 = pStru179->field_0[v12];
13886 ++dword_506520;
13887 v14 = (&dword_723718_autonote_related)[8 * v13];
13888 a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
13889 v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0);
13890 v16 = a1.uFrameY + v15;
13891 if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight )
13892 break;
13893 pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pTextures_5064A0[10]);
13894 ++v12;
13895 a1.uFrameY = v16 + 24;
13896 }
13897 }
13898
13899
13900 //----- (00413980) --------------------------------------------------------
13901 char *__cdecl DrawSpellbook_Map()
13902 {
13903 unsigned int v0; // eax@3
13904 unsigned int v1; // eax@7
13905 unsigned int v2; // eax@10
13906 unsigned int v3; // eax@13
13907 unsigned int v4; // eax@16
13908 unsigned int v5; // eax@19
13909 int v6; // eax@31
13910 unsigned int v7; // eax@35
13911 unsigned int v9; // [sp-8h] [bp-E0h]@3
13912 unsigned int v10; // [sp-8h] [bp-E0h]@7
13913 unsigned int v11; // [sp-8h] [bp-E0h]@10
13914 unsigned int v12; // [sp-8h] [bp-E0h]@13
13915 unsigned int v13; // [sp-8h] [bp-E0h]@16
13916 unsigned int v14; // [sp-8h] [bp-E0h]@19
13917 Texture *v15; // [sp-4h] [bp-DCh]@3
13918 Texture *v16; // [sp-4h] [bp-DCh]@7
13919 Texture *v17; // [sp-4h] [bp-DCh]@10
13920 Texture *v18; // [sp-4h] [bp-DCh]@13
13921 Texture *v19; // [sp-4h] [bp-DCh]@16
13922 Texture *v20; // [sp-4h] [bp-DCh]@19
13923 char Str[120]; // [sp+Ch] [bp-CCh]@37
13924 GUIWindow v22; // [sp+84h] [bp-54h]@35
13925
13926 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[12]);
13927 if ( dword_506548 || viewparams->field_2C / 128 >= 12 )
13928 {
13929 v15 = pTex_tab_an_6a__zoom_off;
13930 v9 = pViewport->uViewportY + 2;
13931 v0 = pViewport->uViewportX + 408;
13932 }
13933 else
13934 {
13935 v15 = pTex_tab_an_6b__zoom_on;
13936 v9 = pViewport->uViewportY + 1;
13937 v0 = pViewport->uViewportX + 398;
13938 }
13939 pRenderer->DrawTextureTransparent(v0, v9, v15);
13940 if ( dword_506544 || viewparams->field_2C / 128 <= 3 )
13941 {
13942 v16 = pTex_tab_an_7a__zoot_off;
13943 v10 = pViewport->uViewportY + 38;
13944 v1 = pViewport->uViewportX + 408;
13945 }
13946 else
13947 {
13948 v16 = pTex_tab_an_7b__zoot_on;
13949 v10 = pViewport->uViewportY + 38;
13950 v1 = pViewport->uViewportX + 398;
13951 }
13952 pRenderer->DrawTextureTransparent(v1, v10, v16);
13953 if ( dword_506540 )
13954 {
13955 v17 = pTexture_506390;
13956 v11 = pViewport->uViewportY + 113;
13957 v2 = pViewport->uViewportX + 408;
13958 }
13959 else
13960 {
13961 v17 = pTexture_506394;
13962 v11 = pViewport->uViewportY + 113;
13963 v2 = pViewport->uViewportX + 398;
13964 }
13965 pRenderer->DrawTextureTransparent(v2, v11, v17);
13966 if ( dword_50653C )
13967 {
13968 v18 = pTexture_506388;
13969 v12 = pViewport->uViewportX + 150;
13970 v3 = pViewport->uViewportY + 408;
13971 }
13972 else
13973 {
13974 v18 = pTexture_50638C;
13975 v12 = pViewport->uViewportX + 150;
13976 v3 = pViewport->uViewportY + 399;
13977 }
13978 pRenderer->DrawTextureTransparent(v3, v12, v18);
13979 if ( dword_506538 )
13980 {
13981 v19 = pTexture_506380;
13982 v13 = pViewport->uViewportY + 188;
13983 v4 = pViewport->uViewportX + 408;
13984 }
13985 else
13986 {
13987 v19 = pTexture_506384;
13988 v13 = pViewport->uViewportY + 188;
13989 v4 = pViewport->uViewportX + 397;
13990 }
13991 pRenderer->DrawTextureTransparent(v4, v13, v19);
13992 if ( dword_506534 )
13993 {
13994 v20 = pTexture_506378;
13995 v14 = pViewport->uViewportY + 226;
13996 v5 = pViewport->uViewportX + 408;
13997 }
13998 else
13999 {
14000 v20 = pTexture_50637C;
14001 v14 = pViewport->uViewportY + 226;
14002 v5 = pViewport->uViewportX + 397;
14003 }
14004 pRenderer->DrawTextureTransparent(v5, v14, v20);
14005 if ( dword_506544 )
14006 viewparams->_443291();
14007 if ( dword_506548 )
14008 viewparams->_443249();
14009 if ( dword_506540 )
14010 viewparams->_443219();
14011 if ( dword_50653C )
14012 viewparams->_443231();
14013 if ( dword_506538 )
14014 viewparams->_44323D();
14015 v6 = dword_506534;
14016 if ( dword_506534 )
14017 {
14018 viewparams->_443225();
14019 v6 = dword_506534;
14020 }
14021 if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | v6 )
14022 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14023 dword_506548 = 0;
14024 dword_506544 = 0;
14025 dword_506534 = 0;
14026 dword_506538 = 0;
14027 dword_50653C = 0;
14028 dword_506540 = 0;
14029 DrawSpellbook_Map_sub(0x61u, 0x31u, 0x169u, 313, 0);
14030 pRenderer->DrawTextureTransparent(0x4Bu, 0x16u, pTexture_mapbordr);
14031 v22.uFrameWidth = 460;
14032 v22.uFrameHeight = 344;
14033 v22.uFrameX = 8;
14034 v22.uFrameY = 8;
14035 v22.uFrameZ = 467;
14036 v22.uFrameW = 467;
14037 v7 = pMapStats->GetMapInfo(pCurrentMapName);
14038 if ( v7 )
14039 v22.DrawText2(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
14040 v22.uFrameX = 0;
14041 sprintfex(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.z);
14042 return v22.DrawText2(pFontComic, 0, 0x140u, 0, Str, 0);
14043 }
14044
14045
14046 //----- (00413CC6) --------------------------------------------------------
14047 void __thiscall DrawSpellbook(unsigned int uBook)
14048 {
14049 unsigned int v1; // esi@1
14050
14051 v1 = uBook;
14052 pRenderer->DrawTextureIndexed(
14053 471u,
14054 445u,
14055 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
14056 switch ( v1 )
14057 {
14058 case 0xB1u:
14059 DrawLloydBeaconsScreen();
14060 break;
14061 case 0xC3u:
14062 DrawTownPortalScreen();
14063 break;
14064 case 0xC8u:
14065 DrawSpellbook_Quests();
14066 break;
14067 case 0xC9u:
14068 DrawSpellbook_Autonotes();
14069 break;
14070 case 0xCAu:
14071 DrawSpellbook_Map();
14072 break;
14073 case 0xCBu:
14074 DrawSpellbook_Calendar();
14075 break;
14076 case 0xE0u:
14077 sub_412E85();
14078 break;
14079 }
14080 }
14081
14082 //----- (00413D3C) --------------------------------------------------------
14083 char *__cdecl GetDayPart()
14084 {
14085 if ( pParty->uCurrentHour > 4 )
14086 {
14087 if ( pParty->uCurrentHour == 5 )
14088 return pGlobalTXT_LocalizationStrings[55];
14089 if ( pParty->uCurrentHour == 20 )
14090 return pGlobalTXT_LocalizationStrings[566];
14091 if ( pParty->uCurrentHour <= 0x14 || pParty->uCurrentHour > 0x17 )
14092 return pGlobalTXT_LocalizationStrings[56];
14093 }
14094 return pGlobalTXT_LocalizationStrings[567];
14095 }
14096
14097 //----- (00413D6F) --------------------------------------------------------
14098 char __cdecl DrawSpellbook_Calendar()
14099 {
14100 unsigned int v0; // esi@1
14101 char *v1; // eax@5
14102 int v2; // ecx@5
14103 char *v3; // eax@6
14104 GUIWindow a1; // [sp+Ch] [bp-60h]@5
14105 unsigned int v6; // [sp+60h] [bp-Ch]@1
14106 int v7; // [sp+64h] [bp-8h]@1
14107 int a5; // [sp+68h] [bp-4h]@1
14108
14109 v0 = pParty->uCurrentHour;
14110 v6 = pMapStats->GetMapInfo(pCurrentMapName);
14111 a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
14112 pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[13]);
14113 v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
14114 if ( (signed int)v0 <= 12 )
14115 {
14116 if ( !v0 )
14117 v0 = 12;
14118 }
14119 else
14120 {
14121 v0 -= 12;
14122 }
14123 a1.uFrameX = 8;
14124 a1.uFrameY = 8;
14125 a1.uFrameWidth = 460;
14126 a1.uFrameHeight = 344;
14127 a1.uFrameZ = 467;
14128 a1.uFrameW = 467;
14129 a1.DrawText2(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[186], 3u);
14130 v1 = GetDayPart();
14131 sprintfex(
14132 pTmpBuf,
14133 "%s\t100:\t110%d:%02d %s - %s",
14134 pGlobalTXT_LocalizationStrings[526],
14135 v0,
14136 pParty->uCurrentMinute,
14137 aAMPMNames[v2],
14138 v1);
14139 a1.DrawText(pBookFont, 70, 55, a5, pTmpBuf, 0, 0, 0);
14140 sprintfex(
14141 pTmpBuf,
14142 "%s\t100:\t110%d - %s",
14143 pGlobalTXT_LocalizationStrings[56],
14144 pParty->uDaysPlayed + 1,
14145 aDayNames[pParty->uDaysPlayed % 7]);
14146 a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, a5, pTmpBuf, 0, 0, 0);
14147 sprintfex(
14148 pTmpBuf,
14149 "%s\t100:\t110%d - %s",
14150 pGlobalTXT_LocalizationStrings[146],
14151 pParty->uCurrentMonth + 1,
14152 aMonthNames[pParty->uCurrentMonth]);
14153 a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, a5, pTmpBuf, 0, 0, 0);
14154 sprintfex(pTmpBuf, "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
14155 a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, a5, pTmpBuf, 0, 0, 0);
14156 sprintfex(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[v7]);
14157 a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, a5, pTmpBuf, 0, 0, 0);
14158 if ( v6 )
14159 v3 = pMapStats->pInfos[v6].pName;
14160 else
14161 v3 = "Unknown";
14162 sprintfex(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3);
14163 return a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, a5, pTmpBuf, 0, 0, 0);
14164 }
14165
14166 //----- (00413FF1) --------------------------------------------------------
14167 void __cdecl SetMonthNames()
14168 {
14169 aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
14170 aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
14171 aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
14172 aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
14173 aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
14174 aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
14175 aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
14176 aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
14177 aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
14178 aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
14179 aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
14180 aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
14181 }
14182
14183 //----- (0041406F) --------------------------------------------------------
14184 void __cdecl SetDayNames()
14185 {
14186 aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
14187 aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
14188 aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
14189 aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
14190 aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
14191 aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
14192 aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
14193 }
14194
14195 //----- (004140BB) --------------------------------------------------------
14196 void __cdecl SetSpellSchoolNames()
14197 {
14198 aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
14199 aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
14200 aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
14201 aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
14202 aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
14203 aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
14204 aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
14205 aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
14206 aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
14207 }
14208
14209 //----- (0041411B) --------------------------------------------------------
14210 void __cdecl SetAttributeNames()
14211 {
14212 aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
14213 aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
14214 aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
14215 aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
14216 aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
14217 aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
14218 aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
14219 }
14220
14221 //----- (00414162) --------------------------------------------------------
14222 void __cdecl uGameUIFontMain_initialize()
14223 {
14224 uGameUIFontMain = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
14225 }
14226
14227 //----- (00414174) --------------------------------------------------------
14228 void __cdecl uGameUIFontShadow_initialize()
14229 {
14230 uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 214u, 193u);
14231 }
14232
14233
14234
14235
14236
14237 //----- (004141CA) --------------------------------------------------------
14238 GUIWindow *__fastcall ModalWindow(const char *pStr, int a4)
14239 {
14240 const char *v2; // edi@1
14241 int v3; // esi@1
14242 GUIWindow *result; // eax@1
14243
14244 v2 = pStr;
14245 v3 = a4;
14246 pEventTimer->Pause();
14247 dword_506F0C[0] = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
14248 result = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_FinalWindow, v3, (int)v2);
14249 ptr_507BDC = result;
14250 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 22;
14251 return result;
14252 }
14253 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
14254
14255 //----- (0041420D) --------------------------------------------------------
14256 void __cdecl sub_41420D_press_esc()
14257 {
14258 GUIWindow v0; // [sp+4h] [bp-54h]@1
14259
14260 sprintfex(pTmpBuf2, "%s\n \n%s", ptr_507BDC->str_48, pGlobalTXT_LocalizationStrings[61]);// Press Escape
14261 v0.str_48 = pTmpBuf2;
14262 v0.uFrameWidth = 400;
14263 v0.uFrameHeight = 100;
14264 v0.uFrameX = 120;
14265 v0.uFrameY = 140;
14266 v0.uFrameZ = 519;
14267 v0.uFrameW = 239;
14268 v0._415551(0);
14269 }
14270
14271 //----- (0041426F) --------------------------------------------------------
14272 void __cdecl sub_41426F()
14273 {
14274 GUIWindow *v0; // ecx@1
14275
14276 v0 = ptr_507BDC;
14277 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
14278 {
14279 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C;
14280 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14281 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14282 ++pMessageQueue_50CBD0->uNumMessages;
14283 }
14284 v0->Release();
14285 ptr_507BDC = 0;
14286 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506F0C[0];
14287 pEventTimer->Resume();
14288 }
14289 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
14290
14291 //----- (004142D3) --------------------------------------------------------
14292 char __cdecl GameMenuUI_DrawKeyBindings()
14293 {
14294 unsigned int v0; // ebp@1
14295 int v1; // ecx@2
14296 unsigned int v2; // eax@6
14297 GUIWindow *v3; // edx@6
14298 signed int v4; // ecx@7
14299 signed int v5; // eax@8
14300 const char *v6; // ST0C_4@16
14301 unsigned int v7; // eax@16
14302 const char *v8; // ST0C_4@16
14303 unsigned int v9; // eax@16
14304 const char *v10; // ST0C_4@16
14305 unsigned int v11; // eax@16
14306 const char *v12; // ST0C_4@16
14307 unsigned int v13; // eax@16
14308 const char *v14; // ST0C_4@16
14309 unsigned int v15; // eax@16
14310 const char *v16; // ST0C_4@16
14311 unsigned int v17; // eax@16
14312 const char *v18; // ST0C_4@16
14313 unsigned int v19; // eax@16
14314 const char *v20; // ST0C_4@16
14315 unsigned int v21; // eax@16
14316 signed int v22; // ebp@16
14317 const char *v23; // ST0C_4@16
14318 unsigned int v24; // eax@16
14319 const char *v25; // ST0C_4@16
14320 unsigned int v26; // eax@16
14321 const char *v27; // ST0C_4@16
14322 unsigned int v28; // eax@16
14323 const char *v29; // ST0C_4@16
14324 unsigned int v30; // eax@16
14325 const char *v31; // ST0C_4@16
14326 unsigned int v32; // eax@16
14327 const char *v33; // ST0C_4@17
14328 unsigned int v34; // eax@17
14329 const char *v35; // ST0C_4@17
14330 unsigned int v36; // eax@17
14331 const char *v37; // ST0C_4@17
14332 unsigned int v38; // eax@17
14333 const char *v39; // ST0C_4@17
14334 unsigned int v40; // eax@17
14335 const char *v41; // ST0C_4@17
14336 unsigned int v42; // eax@17
14337 const char *v43; // ST0C_4@17
14338 unsigned int v44; // eax@17
14339 const char *v45; // ST0C_4@17
14340 unsigned int v46; // eax@17
14341 const char *v47; // ST0C_4@17
14342 unsigned int v48; // eax@17
14343 const char *v49; // ST0C_4@17
14344 unsigned int v50; // eax@17
14345 const char *v51; // ST0C_4@17
14346 unsigned int v52; // eax@17
14347 const char *v53; // ST0C_4@17
14348 unsigned int v54; // eax@17
14349 const char *v55; // ST0C_4@17
14350 unsigned int v56; // eax@17
14351 const char *v57; // ST0C_4@17
14352 unsigned int v58; // eax@17
14353 unsigned int v59; // eax@18
14354 int v61; // [sp-14h] [bp-28h]@16
14355 const char *v62; // [sp-10h] [bp-24h]@16
14356 int v63; // [sp-Ch] [bp-20h]@16
14357 int v64; // [sp-8h] [bp-1Ch]@16
14358 unsigned int v65; // [sp-4h] [bp-18h]@16
14359 unsigned int a5; // [sp+10h] [bp-4h]@1
14360
14361 v0 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14362 a5 = v0;
14363 if ( byte_4E28FC )
14364 {
14365 v1 = dword_507C0C + 15;
14366 dword_507C0C = v1;
14367 if ( v1 == 255 )
14368 byte_4E28FC = 0;
14369 }
14370 else
14371 {
14372 v1 = dword_507C0C - 15;
14373 dword_507C0C = v1;
14374 if ( v1 == 15 )
14375 byte_4E28FC = 1;
14376 }
14377 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, 0, 0);
14378 v3 = pGUIWindow_CurrentMenu;
14379 dword_507C08 = v2;
14380 if ( pGUIWindow_CurrentMenu->field_40 == 2 )
14381 {
14382 pPrevVirtualCidesMapping[dword_506E68] = pKeyActionMap->pPressedKeysBuffer[0];
14383 memset(word_506E6C, 0, 0x1Cu);
14384 v4 = 0;
14385 do
14386 {
14387 v5 = 0;
14388 do
14389 {
14390 if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] )
14391 {
14392 *((char *)word_506E6C + v4) = 1;
14393 *((char *)word_506E6C + v5) = 1;
14394 }
14395 ++v5;
14396 }
14397 while ( v5 < 28 );
14398 ++v4;
14399 }
14400 while ( v4 < 28 );
14401 dword_506E68 = -1;
14402 v3->field_40 = 0;
14403 }
14404 pRenderer->DrawTextureIndexed(
14405 8u,
14406 8u,
14407 (Texture *)(uTextureID_507BF4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507BF4] : 0));
14408 if ( dword_506F08 == 1 )
14409 {
14410 pRenderer->DrawTextureIndexed(
14411 0x13u,
14412 0x12Eu,
14413 (Texture *)(uTextureID_507C00 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C00] : 0));
14414 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
14415 v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
14416 v7 = sub_414D24(0);
14417 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v7, v6, 0, 0, 0);
14418 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2D50, 0, 0, 0);
14419 v8 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]);
14420 v9 = sub_414D24(1);
14421 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v9, v8, 0, 0, 0);
14422 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2D48, 0, 0, 0);
14423 v10 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]);
14424 v11 = sub_414D24(2);
14425 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v11, v10, 0, 0, 0);
14426 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2D40, 0, 0, 0);
14427 v12 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]);
14428 v13 = sub_414D24(3);
14429 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v13, v12, 0, 0, 0);
14430 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2D38, 0, 0, 0);
14431 v14 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]);
14432 v15 = sub_414D24(4);
14433 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v15, v14, 0, 0, 0);
14434 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2D30, 0, 0, 0);
14435 v16 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]);
14436 v17 = sub_414D24(5);
14437 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v17, v16, 0, 0, 0);
14438 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2D28, 0, 0, 0);
14439 v18 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]);
14440 v19 = sub_414D24(6);
14441 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v19, v18, 0, 0, 0);
14442 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2D1C, 0, 0, 0);
14443 v20 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]);
14444 v21 = sub_414D24(7);
14445 v22 = 350;
14446 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v21, v20, 0, 0, 0);
14447 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2D14, 0, 0, 0);
14448 v23 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]);
14449 v24 = sub_414D24(8);
14450 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v24, v23, 0, 0, 0);
14451 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2D0C, 0, 0, 0);
14452 v25 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]);
14453 v26 = sub_414D24(9);
14454 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v26, v25, 0, 0, 0);
14455 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2D04, 0, 0, 0);
14456 v27 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]);
14457 v28 = sub_414D24(10);
14458 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v28, v27, 0, 0, 0);
14459 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2CFC, 0, 0, 0);
14460 v29 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]);
14461 v30 = sub_414D24(11);
14462 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v30, v29, 0, 0, 0);
14463 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2CF0, 0, 0, 0);
14464 v31 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]);
14465 v32 = sub_414D24(12);
14466 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v32, v31, 0, 0, 0);
14467 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2CE8, 0, 0, 0);
14468 v65 = 0;
14469 v64 = 0;
14470 v63 = 0;
14471 v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
14472 v61 = 13;
14473 }
14474 else
14475 {
14476 pRenderer->DrawTextureIndexed(
14477 0x7Fu,
14478 0x12Eu,
14479 (Texture *)(uTextureID_507C04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C04] : 0));
14480 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
14481 v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
14482 v34 = sub_414D24(14);
14483 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v34, v33, 0, 0, 0);
14484 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2CD4, 0, 0, 0);
14485 v35 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]);
14486 v36 = sub_414D24(15);
14487 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v36, v35, 0, 0, 0);
14488 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2CC8, 0, 0, 0);
14489 v37 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]);
14490 v38 = sub_414D24(16);
14491 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v38, v37, 0, 0, 0);
14492 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2CBC, 0, 0, 0);
14493 v39 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]);
14494 v40 = sub_414D24(17);
14495 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v40, v39, 0, 0, 0);
14496 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2CB0, 0, 0, 0);
14497 v41 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]);
14498 v42 = sub_414D24(18);
14499 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v42, v41, 0, 0, 0);
14500 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2CA4, 0, 0, 0);
14501 v43 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]);
14502 v44 = sub_414D24(19);
14503 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v44, v43, 0, 0, 0);
14504 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2C9C, 0, 0, 0);
14505 v45 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]);
14506 v46 = sub_414D24(20);
14507 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v46, v45, 0, 0, 0);
14508 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2C90, 0, 0, 0);
14509 v47 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]);
14510 v48 = sub_414D24(21);
14511 v22 = 350;
14512 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v48, v47, 0, 0, 0);
14513 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2C84, 0, 0, 0);
14514 v49 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]);
14515 v50 = sub_414D24(22);
14516 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v50, v49, 0, 0, 0);
14517 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2C7C, 0, 0, 0);
14518 v51 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]);
14519 v52 = sub_414D24(23);
14520 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v52, v51, 0, 0, 0);
14521 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2C70, 0, 0, 0);
14522 v53 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]);
14523 v54 = sub_414D24(24);
14524 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v54, v53, 0, 0, 0);
14525 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2C68, 0, 0, 0);
14526 v55 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]);
14527 v56 = sub_414D24(25);
14528 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v56, v55, 0, 0, 0);
14529 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2C5C, 0, 0, 0);
14530 v57 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]);
14531 v58 = sub_414D24(26);
14532 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v58, v57, 0, 0, 0);
14533 pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2C54, 0, 0, 0);
14534 v65 = 0;
14535 v64 = 0;
14536 v63 = 0;
14537 v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
14538 v61 = 27;
14539 }
14540 v59 = sub_414D24(v61);
14541 return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, v63, v64, v65);
14542 }
14543
14544
14545 //----- (00414D24) --------------------------------------------------------
14546 unsigned int __thiscall sub_414D24(int _this)
14547 {
14548 int v1; // esi@1
14549 unsigned int v2; // edi@1
14550 unsigned int v3; // ebx@1
14551 unsigned int result; // eax@1
14552
14553 v1 = _this;
14554 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
14555 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFu, 0, 0);
14556 result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
14557 if ( dword_506E68 == v1 )
14558 {
14559 if ( GetTickCount() % 0x3E8 <= 0x1F4 )
14560 result = v3;
14561 else
14562 result = v2;
14563 }
14564 else
14565 {
14566 if ( *((char *)word_506E6C + v1) )
14567 result = dword_507C08;
14568 }
14569 return result;
14570 }
14571 // 506E68: using guessed type int dword_506E68;
14572 // 506E6C: using guessed type __int16 word_506E6C[18];
14573 // 507C08: using guessed type int dword_507C08;
14574
14575 //----- (00414D9A) --------------------------------------------------------
14576 void __cdecl GameMenuUI_DrawVideoOptions()
14577 {
14578 const char *v0; // ST0C_4@3
14579 unsigned __int16 v1; // ax@3
14580 int v2; // eax@10
14581 GUIWindow v3; // [sp+8h] [bp-54h]@3
14582
14583 pRenderer->DrawTextureIndexed(
14584 8u,
14585 8u,
14586 (Texture *)(uTextureID_507C10 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C10] : 0));
14587 if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
14588 {
14589 pRenderer->DrawTextureIndexed(
14590 17 * uGammaPos + 42,
14591 162u,
14592 (Texture *)(pTextureIDs_GammaPositions[uGammaPos] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_GammaPositions[uGammaPos]] : 0));
14593 pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
14594 v3.uFrameX = 22;
14595 v0 = pGlobalTXT_LocalizationStrings[226];
14596 v3.uFrameY = 190;
14597 v3.uFrameWidth = 211;
14598 v3.uFrameHeight = 79;
14599 v3.uFrameZ = 232;
14600 v3.uFrameW = 268;
14601 v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
14602 v3.DrawText2(pFontSmallnum, 0, 0, v1, v0, 3u);
14603 }
14604 if ( !pRenderer->pRenderD3D )
14605 {
14606 pRenderer->DrawTextureIndexed(
14607 0x14u,
14608 0x119u,
14609 (Texture *)(uTextureID_507C50 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C50] : 0));
14610 pRenderer->DrawTextureIndexed(
14611 0x14u,
14612 0x12Fu,
14613 (Texture *)(uTextureID_507C54 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C54] : 0));
14614 v2 = uTextureID_507C58;
14615 goto LABEL_12;
14616 }
14617 if ( pGame->uFlags2 & 0x20 )
14618 pRenderer->DrawTextureIndexed(
14619 0x14u,
14620 0x119u,
14621 (Texture *)(uTextureID_507C14 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C14] : 0));
14622 if ( pRenderer->bUseColoredLights )
14623 pRenderer->DrawTextureIndexed(
14624 0x14u,
14625 0x12Fu,
14626 (Texture *)(uTextureID_507C18 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C18] : 0));
14627 if ( pRenderer->bTinting )
14628 {
14629 v2 = uTextureID_507C1C;
14630 LABEL_12:
14631 pRenderer->DrawTextureIndexed(0x14u, 0x145u, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
14632 }
14633 }
14634
14635
14636
14637 //----- (00414F82) --------------------------------------------------------
14638 void __cdecl sub_414F82_DrawGameOptions()
14639 {
14640 signed int v0; // eax@1
14641
14642 pRenderer->DrawTextureIndexed(
14643 8u,
14644 8u,
14645 (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0));
14646 pRenderer->DrawTextureIndexed(
14647 8u,
14648 0x84u,
14649 (Texture *)(uTextureID_507C60 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C60] : 0));
14650 v0 = 0;
14651 if ( uTurnSpeed == 128 )
14652 {
14653 v0 = 2;
14654 }
14655 else
14656 {
14657 if ( uTurnSpeed == 64 )
14658 v0 = 1;
14659 }
14660 pRenderer->DrawTextureIndexed(
14661 dword_4E2910[v0],
14662 0x10Eu,
14663 (Texture *)(uTextureID_507C64[v0] != -1 ? &pIcons_LOD->pTextures[uTextureID_507C64[v0]] : 0));
14664 if ( bWalkSound )
14665 pRenderer->DrawTextureIndexed(
14666 0x14u,
14667 0x12Fu,
14668 (Texture *)(uTextureID_507CB4 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB4] : 0));
14669 if ( bShowDamage )
14670 pRenderer->DrawTextureIndexed(
14671 0x80u,
14672 0x12Fu,
14673 (Texture *)(uTextureID_507CB8 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB8] : 0));
14674 if ( bFlipOnExit )
14675 pRenderer->DrawTextureIndexed(
14676 0x80u,
14677 0x145u,
14678 (Texture *)(uTextureID_507C84 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C84] : 0));
14679 if ( bAlwaysRun )
14680 pRenderer->DrawTextureIndexed(
14681 0x14u,
14682 0x145u,
14683 (Texture *)(uTextureID_507CB0 != -1 ? &pIcons_LOD->pTextures[uTextureID_507CB0] : 0));
14684 pRenderer->DrawTextureIndexed(
14685 17 * (char)uSoundVolumeMultiplier + 265,
14686 0xA2u,
14687 (Texture *)(pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier]] : 0));
14688 pRenderer->DrawTextureIndexed(
14689 17 * (char)uMusicVolimeMultiplier + 265,
14690 0xD8u,
14691 (Texture *)(pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier]] : 0));
14692 pRenderer->DrawTextureIndexed(
14693 17 * (char)uVoicesVolumeMultiplier + 265,
14694 0x10Eu,
14695 (Texture *)(pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier]] : 0));
14696 }
14697
14698
14699
14700
14701 //----- (004151D9) --------------------------------------------------------
14702 void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
14703 {
14704 unsigned int v4; // ebx@1
14705 Texture *v5; // edi@1
14706 signed int uTileWidth; // ecx@1
14707 int v7; // eax@5
14708 int v8; // ecx@10
14709 unsigned int v9; // ebx@14
14710 int v10; // [sp+10h] [bp-28h]@5
14711 signed int uTileHeight; // [sp+18h] [bp-20h]@1
14712 int v12; // [sp+1Ch] [bp-1Ch]@7
14713 int v13; // [sp+20h] [bp-18h]@1
14714 int a5; // [sp+24h] [bp-14h]@5
14715 unsigned int a5a; // [sp+24h] [bp-14h]@11
14716 unsigned int a4; // [sp+28h] [bp-10h]@1
14717 int uNumXTiles; // [sp+2Ch] [bp-Ch]@3
14718 unsigned int uNumXTilesa; // [sp+2Ch] [bp-Ch]@6
14719 unsigned int uNumXTilesb; // [sp+2Ch] [bp-Ch]@11
14720 unsigned int a2a; // [sp+30h] [bp-8h]@1
14721 unsigned int v21; // [sp+34h] [bp-4h]@5
14722 unsigned int v22; // [sp+34h] [bp-4h]@11
14723
14724 v4 = uY;
14725 a2a = uX;
14726 a4 = uX + uWidth;
14727 pRenderer->Clip(uX, v4, uX + uWidth, v4 + uHeight);
14728 v5 = (Texture *)(uTextureID_Parchment != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Parchment] : 0);
14729 uTileWidth = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
14730 v13 = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
14731 uTileHeight = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26);
14732 if ( (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24)
14733 && (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26) )
14734 {
14735 uNumXTiles = (signed int)uWidth / uTileWidth;
14736 if ( (signed int)uWidth % uTileWidth )
14737 ++uNumXTiles;
14738 a5 = 0;
14739 v21 = v4;
14740 v7 = uNumXTiles + 1;
14741 v10 = uNumXTiles + 1;
14742 do
14743 {
14744 uNumXTilesa = a2a - v13;
14745 if ( v7 > 0 )
14746 {
14747 v12 = v7;
14748 do
14749 {
14750 uNumXTilesa += v13;
14751 pRenderer->DrawTextureIndexed(uNumXTilesa, v21, v5);
14752 --v12;
14753 }
14754 while ( v12 );
14755 v7 = v10;
14756 }
14757 v21 += uTileHeight;
14758 v8 = a5++;
14759 }
14760 while ( v8 < (signed int)uHeight / uTileHeight );
14761 a5a = v4 + uHeight - 32;
14762 pRenderer->DrawTextureTransparent(
14763 a2a,
14764 v4,
14765 (Texture *)(uTextureID_5076AC != -1 ? &pIcons_LOD->pTextures[uTextureID_5076AC] : 0));
14766 pRenderer->DrawTextureTransparent(
14767 a2a,
14768 a5a,
14769 (Texture *)(uTextureID_5076B4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076B4] : 0));
14770 pRenderer->DrawTextureTransparent(
14771 a4 - 32,
14772 v4,
14773 (Texture *)(uTextureID_5076A8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A8] : 0));
14774 pRenderer->DrawTextureTransparent(
14775 a4 - 32,
14776 a5a,
14777 (Texture *)(uTextureID_5076B0 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_5076B0] : 0));
14778 uNumXTilesb = a2a + 32;
14779 v22 = v4 + uHeight - 10;
14780 if ( (signed int)uWidth > 64 )
14781 {
14782 pRenderer->Clip(a2a + 32, v4, a4 - 32, v4 + uHeight);
14783 pRenderer->DrawTextureTransparent(
14784 uNumXTilesb,
14785 v4,
14786 (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
14787 pRenderer->DrawTextureTransparent(
14788 uNumXTilesb,
14789 v22,
14790 (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
14791 if ( (signed int)uWidth > 512 )
14792 {
14793 pRenderer->DrawTextureTransparent(
14794 a2a + 544,
14795 v4,
14796 (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
14797 pRenderer->DrawTextureTransparent(
14798 a2a + 544,
14799 v22,
14800 (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
14801 }
14802 }
14803 v9 = v4 + 32;
14804 if ( (signed int)uHeight > 64 )
14805 {
14806 pRenderer->Clip(a2a, v9, a4, a5a);
14807 pRenderer->DrawTextureTransparent(
14808 a2a,
14809 v9,
14810 (Texture *)(uTextureID_5076A0 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A0] : 0));
14811 pRenderer->DrawTextureTransparent(
14812 a4 - 10,
14813 v9,
14814 (Texture *)(uTextureID_50769C != -1 ? &pIcons_LOD->pTextures[uTextureID_50769C] : 0));
14815 }
14816 pRenderer->ResetClip();
14817 }
14818 }
14819
14820
14821 //----- (00415485) --------------------------------------------------------
14822 char *__cdecl DrawCopyrightWindow()
14823 {
14824 GUIWindow Dst; // [sp+8h] [bp-54h]@1
14825
14826 memset(&Dst, 0, 0x54u);
14827 Dst.uFrameWidth = 624;
14828 Dst.uFrameHeight = 256;
14829 Dst.uFrameX = 8;
14830 Dst.uFrameY = 30; // c 1999 The 3DO Company.
14831 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
14832 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
14833 + 24;
14834 Dst.uFrameY = 470 - Dst.uFrameHeight;
14835 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
14836 Dst.uFrameW = 469;
14837 Dst._415551(0);
14838 Dst.uFrameWidth -= 24;
14839 Dst.uFrameX += 12;
14840 Dst.uFrameY += 12;
14841 Dst.uFrameHeight -= 12;
14842 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
14843 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
14844 return Dst.DrawText2(pFontSmallnum, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[157], 3u);
14845 }
14846
14847
14848
14849
14850 //----- (004156F0) --------------------------------------------------------
14851 void __cdecl GUI_UpdateWindows()
14852 {
14853 GUIWindow *v0; // esi@4
14854 unsigned int v1; // eax@4
14855 int v2; // eax@10
14856 int v3; // eax@11
14857 int v4; // eax@12
14858 int v5; // eax@20
14859 int v6; // eax@21
14860 int v7; // eax@29
14861 int v8; // eax@30
14862 int v9; // eax@31
14863 void *v10; // eax@41
14864 int v11; // ecx@42
14865 int v12; // eax@48
14866 int v13; // eax@49
14867 int v14; // eax@57
14868 int v15; // eax@58
14869 int v16; // eax@59
14870 int v17; // eax@60
14871 int v18; // eax@61
14872 int v19; // eax@62
14873 void *v20; // ebp@66
14874 char *v21; // edx@66
14875 GUIButton *v22; // ebp@79
14876 char *v23; // edx@80
14877 char v24; // zf@81
14878 unsigned int v25; // eax@91
14879 int v26; // eax@98
14880 unsigned int v27; // ebp@106
14881 GUIWindow *v28; // ecx@109
14882 unsigned int v29; // eax@111
14883 GUIFont *v30; // ST1C_4@115
14884 int v31; // eax@115
14885 void *v32; // ebp@118
14886 int v33; // eax@119
14887 int v34; // eax@120
14888 int v35; // eax@121
14889 int v36; // eax@122
14890 int v37; // eax@123
14891 int v38; // eax@124
14892 int v39; // eax@129
14893 char *v40; // edx@138
14894 unsigned int v41; // eax@142
14895 GUIButton *v42; // ebp@146
14896 char *v43; // edx@146
14897 unsigned int v44; // [sp-1Ch] [bp-124h]@17
14898 unsigned int v45; // [sp-18h] [bp-120h]@17
14899 Texture *v46; // [sp-14h] [bp-11Ch]@17
14900 Texture *v47; // [sp-14h] [bp-11Ch]@86
14901 int i; // [sp+0h] [bp-108h]@3
14902 ItemGen _this; // [sp+4h] [bp-104h]@98
14903 GUIButton Dst; // [sp+28h] [bp-E0h]@133
14904 ItemGen v51; // [sp+E4h] [bp-24h]@129
14905
14906 if ( GetCurrentMenuID() != 6 )
14907 sub_41CD4F(0x22u);
14908 for ( i = 1; i <= uNumVisibleWindows; ++i )
14909 {
14910 v0 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[i]];
14911 v1 = v0->uWindowType;
14912 if ( (signed int)v1 > 70 )
14913 {
14914 if ( (signed int)v1 > 95 )
14915 {
14916 v33 = v1 - 96;
14917 if ( !v33 )
14918 {
14919 if ( v0->str_48 != (char *)1 )
14920 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
14921 v42 = (GUIButton *)v0->ptr_1C;
14922 pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v42->pTextures[0]);
14923 v43 = v0->str_48;
14924 viewparams->bRedrawGameUI = 1;
14925 if ( v43 && v43 != (char *)1 )
14926 v42->DrawLabel(v43, pFontCreate, 0, 0);
14927 v0->Release();
14928 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
14929 continue;
14930 v41 = pMessageQueue_50CBD0->uNumMessages;
14931 LABEL_151:
14932 pMessageQueue_50CBD0->pMessages[v41].eType = (UIMessageType)113;
14933 LABEL_152:
14934 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
14935 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
14936 ++pMessageQueue_50CBD0->uNumMessages;
14937 continue;
14938 }
14939 v34 = v33 - 1;
14940 if ( v34 )
14941 {
14942 v35 = v34 - 1;
14943 if ( v35 )
14944 {
14945 v36 = v35 - 1;
14946 if ( v36 )
14947 {
14948 v37 = v36 - 4;
14949 if ( v37 )
14950 {
14951 v38 = v37 - 2;
14952 if ( v38 )
14953 {
14954 if ( v38 == 1 )
14955 GameMenuUI_DrawVideoOptions();
14956 }
14957 else
14958 {
14959 GameMenuUI_DrawKeyBindings();
14960 }
14961 }
14962 else
14963 {
14964 v0->_415551(0);
14965 v0->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
14966 v0->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
14967 if ( !pKeyActionMap->field_204 )
14968 {
14969 v51.Reset();
14970 v0->Release();
14971 pEventTimer->Resume();
14972 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
14973 viewparams->bRedrawGameUI = 1;
14974 v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
14975 if ( v39 > 0 )
14976 {
14977 if ( v39 < 800 )
14978 SpawnActor(v39);
14979 }
14980 }
14981 }
14982 continue;
14983 }
14984 v46 = (Texture *)*((_DWORD *)v0->ptr_1C + 15);
14985 v45 = v0->uFrameY;
14986 v44 = v0->uFrameX;
14987 LABEL_18:
14988 pRenderer->DrawTextureIndexed(v44, v45, v46);
14989 LABEL_114:
14990 viewparams->bRedrawGameUI = 1;
14991 continue;
14992 }
14993 memset(&Dst, 0, 0xBCu);
14994 Dst.uZ = 197;
14995 Dst.uW = 197;
14996 Dst.uX = 27;
14997 Dst.uY = 161;
14998 Dst.uWidth = 171;
14999 Dst.uHeight = 37;
15000 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
15001 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15002 pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v0->ptr_1C + 15));
15003 viewparams->bRedrawGameUI = 1;
15004 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);
15005 Dst.pParent = 0;
15006 goto LABEL_134;
15007 }
15008 if ( v0->str_48 != (char *)1 )
15009 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15010 v32 = v0->ptr_1C;
15011 pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v32 + 16));
15012 goto LABEL_138;
15013 }
15014 if ( v1 == 95 )
15015 {
15016 if ( v0->str_48 != (char *)1 )
15017 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15018 v32 = v0->ptr_1C;
15019 pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, *((Texture **)v32 + 15));
15020 LABEL_138:
15021 v40 = v0->str_48;
15022 viewparams->bRedrawGameUI = 1;
15023 if ( v40 && v40 != (char *)1 )
15024 ((GUIButton *)v32)->DrawLabel(v40, pFontCreate, 0, 0);
15025 v0->Release();
15026 LABEL_142:
15027 v41 = pMessageQueue_50CBD0->uNumMessages;
15028 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15029 goto LABEL_151;
15030 continue;
15031 }
15032 v14 = v1 - 80;
15033 if ( v14 )
15034 {
15035 v15 = v14 - 9;
15036 if ( !v15 )
15037 {
15038 v0->_415551(0);
15039 v0->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
15040 v0->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
15041 if ( !pKeyActionMap->field_204 )
15042 {
15043 _this.Reset();
15044 v0->Release();
15045 pEventTimer->Resume();
15046 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
15047 viewparams->bRedrawGameUI = 1;
15048 v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
15049 if ( v26 > 0 )
15050 {
15051 if ( v26 < 800 )
15052 {
15053 _this.uAttributtes |= 1u;
15054 _this.uItemID = v26;
15055 if ( pItemsTable->pItems[v26].uEquipType == 12 )
15056 {
15057 _this.uNumCharges = rand() % 6 + pItemsTable->pItems[_this.uItemID].uDamageMod + 1;
15058 _this.uMaxCharges = LOBYTE(_this.uNumCharges);
15059 }
15060 else
15061 {
15062 if ( v26 >= 221 && v26 < 271 )
15063 _this._bonus_type = rand() % 10 + 1;
15064 }
15065 pItemsTable->SetSpecialBonus(&_this);
15066 pParty->SetHoldingItem(&_this);
15067 }
15068 }
15069 }
15070 continue;
15071 }
15072 v16 = v15 - 1;
15073 if ( !v16 )
15074 {
15075 if ( v0->str_48 != (char *)1 )
15076 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15077 v22 = (GUIButton *)v0->ptr_1C;
15078 if ( (v22->uX & 0x80000000u) == 0 )
15079 {
15080 if ( (signed int)v22->uX <= 640 )
15081 {
15082 v25 = v22->uY;
15083 if ( (v25 & 0x80000000u) == 0 )
15084 {
15085 if ( (signed int)v25 <= 480 )
15086 {
15087 v47 = v22->pTextures[0];
15088 goto LABEL_94;
15089 }
15090 }
15091 }
15092 }
15093 v23 = v0->str_48;
15094 viewparams->bRedrawGameUI = 1;
15095 if ( v23 )
15096 {
15097 v24 = v23 == (char *)1;
15098 goto LABEL_82;
15099 }
15100 LABEL_134:
15101 v28 = v0;
15102 goto LABEL_110;
15103 }
15104 v17 = v16 - 1;
15105 if ( !v17 )
15106 {
15107 if ( v0->str_48 != (char *)1 )
15108 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15109 v22 = (GUIButton *)v0->ptr_1C;
15110 v47 = v22->pTextures[1];
15111 LABEL_94:
15112 pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v47);
15113 LABEL_80:
15114 v23 = v0->str_48;
15115 viewparams->bRedrawGameUI = 1;
15116 if ( v23 )
15117 {
15118 v24 = v23 == (char *)1;
15119 LABEL_82:
15120 if ( !v24 )
15121 v22->DrawLabel(v23, pFontCreate, 0, 0);
15122 }
15123 goto LABEL_134;
15124 }
15125 v18 = v17 - 1;
15126 if ( !v18 )
15127 {
15128 if ( v0->str_48 != (char *)1 )
15129 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15130 v22 = (GUIButton *)v0->ptr_1C;
15131 pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, v22->pTextures[0]);
15132 goto LABEL_80;
15133 }
15134 v19 = v18 - 1;
15135 if ( !v19 )
15136 {
15137 if ( v0->str_48 != (char *)1 )
15138 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15139 pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, *((Texture **)v0->ptr_1C + 16));
15140 viewparams->bRedrawGameUI = 1;
15141 goto LABEL_134;
15142 }
15143 if ( v19 == 1 )
15144 {
15145 if ( v0->str_48 != (char *)1 )
15146 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
15147 v20 = v0->ptr_1C;
15148 pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v20 + 15));
15149 v21 = v0->str_48;
15150 viewparams->bRedrawGameUI = 1;
15151 if ( v21 && v21 != (char *)1 )
15152 ((GUIButton *)v20)->DrawLabel(v21, pFontCreate, 0, 0);
15153 v0->Release();
15154 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
15155 {
15156 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15157 {
15158 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)83;
15159 goto LABEL_152;
15160 }
15161 }
15162 else
15163 {
15164 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15165 {
15166 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)82;
15167 goto LABEL_152;
15168 }
15169 }
15170 }
15171 }
15172 else
15173 {
15174 v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
15175 if ( ptr_507BD0->field_40 == 1 )
15176 {
15177 ptr_507BD0->_415551(0);
15178 ptr_507BD0->DrawText(
15179 pFontCreate,
15180 30,
15181 40,
15182 v27,
15183 (const char *)pKeyActionMap->pPressedKeysBuffer,
15184 0,
15185 0,
15186 0);
15187 v30 = pFontCreate;
15188 v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
15189 ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, v30);
15190 continue;
15191 }
15192 if ( ptr_507BD0->field_40 == 2 )
15193 {
15194 v29 = pMessageQueue_50CBD0->uNumMessages;
15195 v0->field_40 = 0;
15196 if ( (signed int)v29 < 40 )
15197 {
15198 pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
15199 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
15200 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15201 ++pMessageQueue_50CBD0->uNumMessages;
15202 }
15203 pEventTimer->Resume();
15204 ptr_507BD0->Release();
15205 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
15206 goto LABEL_114;
15207 }
15208 if ( ptr_507BD0->field_40 == 3 )
15209 {
15210 v0->field_40 = 0;
15211 pEventTimer->Resume();
15212 v28 = ptr_507BD0;
15213 LABEL_110:
15214 v28->Release();
15215 continue;
15216 }
15217 }
15218 }
15219 else
15220 {
15221 if ( v1 == 70 )
15222 {
15223 sub_41420D_press_esc();
15224 continue;
15225 }
15226 if ( (signed int)v1 > 18 )
15227 {
15228 if ( (signed int)v1 > 25 )
15229 {
15230 v12 = v1 - 26;
15231 if ( v12 )
15232 {
15233 v13 = v12 - 4;
15234 if ( v13 )
15235 {
15236 if ( v13 == 1 )
15237 {
15238 pRenderer->ClearZBuffer(0, 479);
15239 draw_leather();
15240 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
15241 CharacterUI_DrawPaperdoll(uActiveCharacter);
15242 pRenderer->DrawTextureTransparent(
15243 ptr_5076F4->uX,
15244 ptr_5076F4->uY,
15245 (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
15246 }
15247 }
15248 else
15249 {
15250 sub_467FB6();
15251 }
15252 }
15253 else
15254 {
15255 TransitionUI_Draw();
15256 }
15257 continue;
15258 }
15259 if ( v1 != 25 )
15260 {
15261 v7 = v1 - 19;
15262 if ( v7 )
15263 {
15264 v8 = v7 - 1;
15265 if ( v8 )
15266 {
15267 v9 = v8 - 3;
15268 if ( v9 )
15269 {
15270 if ( v9 == 1 )
15271 sub_4606F7();
15272 }
15273 else
15274 {
15275 sub_4606FE();
15276 }
15277 }
15278 else
15279 {
15280 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
15281 {
15282 Chest::DrawChestUI((unsigned int)v0->ptr_1C);
15283 }
15284 else
15285 {
15286 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15 )
15287 {
15288 pRenderer->ClearZBuffer(0, 479);
15289 draw_leather();
15290 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
15291 pRenderer->DrawTextureIndexed(
15292 ptr_5076F4->uX,
15293 ptr_5076F4->uY,
15294 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
15295 }
15296 }
15297 }
15298 }
15299 else
15300 {
15301 DrawBranchlessDialogueUI();
15302 }
15303 continue;
15304 }
15305 pWindowList[pVisibleWindowsIdxs[i] - 1]._4B3157();
15306 if ( !ptr_507BC0 )
15307 continue;
15308 v10 = ptr_507BC0->ptr_1C;
15309 if ( (signed int)v10 >= 53 )
15310 continue;
15311 v11 = pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1];
15312 if ( !__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * (_DWORD)v10])
15313 || v11 < SHIDWORD(pParty->uTimePlayed)
15314 || v11 <= SHIDWORD(pParty->uTimePlayed)
15315 && (unsigned int)pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] <= LODWORD(pParty->uTimePlayed) )
15316 {
15317 if ( (signed int)v10 < 53 )
15318 {
15319 pParty->field_3C._shop_ban_times[2 * (_DWORD)v10] = 0;
15320 pParty->field_3C._shop_ban_times[2 * (_DWORD)v10 + 1] = 0;
15321 }
15322 continue;
15323 }
15324 goto LABEL_142;
15325 }
15326 if ( v1 == 18 )
15327 {
15328 sub_412B58();
15329 }
15330 else
15331 {
15332 if ( (signed int)v1 > 10 )
15333 {
15334 v5 = v1 - 12;
15335 if ( v5 )
15336 {
15337 v6 = v5 - 4;
15338 if ( v6 )
15339 {
15340 if ( v6 == 1 )
15341 TravelUI_Draw();
15342 }
15343 else
15344 {
15345 RestUI_Draw();
15346 }
15347 }
15348 else
15349 {
15350 QuickRefDraw();
15351 }
15352 continue;
15353 }
15354 if ( v1 != 10 )
15355 {
15356 v2 = v1 - 3;
15357 if ( v2 )
15358 {
15359 v3 = v2 - 1;
15360 if ( v3 )
15361 {
15362 v4 = v3 - 2;
15363 if ( v4 )
15364 {
15365 if ( v4 == 3 )
15366 DrawSpellbook((unsigned int)v0->ptr_1C);
15367 }
15368 else
15369 {
15370 sub_414F82_DrawGameOptions();
15371 }
15372 }
15373 else
15374 {
15375 CharacterUI_CharacterScreen_Draw(uActiveCharacter);
15376 }
15377 continue;
15378 }
15379 v46 = (Texture *)(uTextureID_507944 != -1 ? &pIcons_LOD->pTextures[uTextureID_507944] : 0);
15380 v45 = pViewport->uViewportY;
15381 v44 = pViewport->uViewportX;
15382 goto LABEL_18;
15383 }
15384 DrawDialogueUI();
15385 }
15386 }
15387 }
15388 if ( GetCurrentMenuID() == -1 )
15389 GameUI_DrawFoodAndGold();
15390 if ( sub_4637E0_is_there_popup_onscreen() )
15391 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
15392 }
15393
15394
15395
15396
15397
15398
15399
15400 //----- (00416196) --------------------------------------------------------
15401 void __cdecl identify_item()
15402 {
15403 Player *v0; // esi@2
15404 POINT *v1; // edi@2
15405 signed int v2; // ecx@5
15406 signed int v3; // eax@5
15407 int v4; // eax@5
15408 char v5; // sf@5
15409 int v6; // eax@5
15410 int v7; // eax@7
15411 unsigned __int16 v8; // ax@10
15412 int v9; // edi@10
15413 int v10; // eax@10
15414 int v11; // edx@13
15415 LONG v12; // edx@23
15416 signed int v13; // edx@23
15417 int v14; // edx@25
15418 unsigned int v15; // edi@25
15419 signed int v16; // edx@27
15420 int v17; // eax@54
15421 unsigned int v18; // edx@57
15422 int v19; // eax@65
15423 int v20; // edi@67
15424 int v21; // eax@72
15425 int v22; // ecx@74
15426 int v23; // edx@78
15427 int v24; // eax@79
15428 int v25; // eax@80
15429 int v26; // eax@84
15430 ItemGen *v27; // esi@98
15431 unsigned int v28; // eax@98
15432 ItemGen *v29; // edi@98
15433 unsigned int v30; // ecx@103
15434 double v31; // st7@112
15435 unsigned __int64 v32; // qax@113
15436 unsigned int v33; // ecx@117
15437 int v34; // eax@126
15438 unsigned int v35; // ecx@127
15439 double v36; // st7@132
15440 signed __int64 v37; // qax@135
15441 unsigned int v38; // eax@138
15442 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
15443 int *v40; // [sp-Ch] [bp-9Ch]@83
15444 int *v41; // [sp-8h] [bp-98h]@83
15445 int *v42; // [sp-4h] [bp-94h]@83
15446 GUIWindow v43; // [sp+Ch] [bp-84h]@137
15447 unsigned int pY; // [sp+60h] [bp-30h]@2
15448 int v45; // [sp+64h] [bp-2Ch]@10
15449 unsigned int pX; // [sp+68h] [bp-28h]@2
15450 int v47; // [sp+6Ch] [bp-24h]@25
15451 POINT y; // [sp+70h] [bp-20h]@2
15452 POINT a2; // [sp+78h] [bp-18h]@2
15453 Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
15454 unsigned int v51; // [sp+8Ch] [bp-4h]@23
15455
15456 if ( dword_50CDCC )
15457 return;
15458 v0 = pPlayers[uActiveCharacter];
15459 v1 = pMouse->GetCursorPos(&a2);
15460 pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF;
15461 pMouse->GetClickPos(&pX, &pY);
15462 if ( !pOut.z )
15463 {
15464 if ( (signed int)pX <= 13
15465 || (signed int)pX >= 462
15466 || (v2 = pX - 14,
15467 v3 = pY - 17,
15468 pX = v2,
15469 pY = v3,
15470 v4 = 14 * (v3 >> 5),
15471 v2 >>= 5,
15472 v5 = v2 + v4 < 0,
15473 v6 = v2 + v4,
15474 pOut.z = v6,
15475 v5)
15476 || v6 > 126
15477 || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 )
15478 return;
15479 pOut.z = v7;
15480 }
15481 if ( !v0->CanAct() )
15482 {
15483 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]);
15484 v43.str_48 = pTmpBuf;
15485 v43.uFrameWidth = 384;
15486 v43.uFrameHeight = 180;
15487 v43.uFrameY = 40;
15488 if ( pMouse->GetCursorPos(&a2)->x <= 320 )
15489 v38 = pMouse->GetCursorPos(&a2)->x + 30;
15490 else
15491 v38 = pMouse->GetCursorPos(&a2)->x - 414;
15492 v43.uFrameX = v38;
15493 v43._415551(0);
15494 return;
15495 }
15496 --pOut.z;
15497 LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
15498 v9 = v8 & 0x3F;
15499 v45 = v8 & 0x3F;
15500 pOut.y = SkillToMastery(v8);
15501 v10 = pOut.z;
15502 if ( pParty->pPickedItem.uItemID == 220 )
15503 {
15504 LABEL_116:
15505 GameUI_DrawItemInfo(&v0->pInventoryItems[v10]);
15506 return;
15507 }
15508 if ( (signed int)pParty->pPickedItem.uItemID < 200
15509 || (signed int)pParty->pPickedItem.uItemID > 219
15510 || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) )
15511 {
15512 if ( (signed int)pParty->pPickedItem.uItemID < 221
15513 || (signed int)pParty->pPickedItem.uItemID > 271
15514 || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221)
15515 || v13 > 271 )
15516 {
15517 if ( pParty->pPickedItem.uItemID != 236
15518 && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250)
15519 && pParty->pPickedItem.uItemID != 263
15520 && pParty->pPickedItem.uItemID != 233 )
15521 goto LABEL_116;
15522 v27 = &v0->pInventoryItems[pOut.z];
15523 v28 = v27->uItemID;
15524 v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
15525 v29 = (ItemGen *)(1800 * pParty->pPickedItem._bonus_type);
15526 if ( pParty->pPickedItem.uItemID != 233 )
15527 {
15528 if ( pParty->pPickedItem.uItemID == 236 )
15529 {
15530 v35 = v27->uAttributtes;
15531 if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
15532 goto LABEL_92;
15533 LOWORD(v35) = v35 | 0x210;
15534 v27->uAttributtes = v35;
15535 }
15536 else
15537 {
15538 if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
15539 goto LABEL_92;
15540 if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
15541 {
15542 v27->UpdateTempBonus(pParty->uTimePlayed);
15543 v33 = v27->uItemID;
15544 if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65
15545 || (pOut.y = v27->uAttributtes, pOut.y & 2)
15546 || v27->uAdditionalValue
15547 || v27->_bonus_type
15548 || v51 && v51 != 1 && v51 != 2
15549 || (signed int)v33 >= 500 )
15550 goto LABEL_92;
15551 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
15552 a2.y = (int)v29 << 7;
15553 v31 = (double)(signed int)((int)v29 << 7);
15554 v27->uAdditionalValue = v34;
15555 }
15556 else
15557 {
15558 if ( pParty->pPickedItem.uItemID != 263
15559 || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64)
15560 && (signed int)v30 <= 65
15561 || (pOut.y = v27->uAttributtes, pOut.y & 2)
15562 || v27->uAdditionalValue
15563 || v27->_bonus_type
15564 || v51 && v51 != 1 && v51 != 2
15565 || (signed int)v30 >= 500 )
15566 goto LABEL_92;
15567 a2.y = (int)v29 << 7;
15568 v27->uAdditionalValue = 40;
15569 v31 = (double)a2.y;
15570 }
15571 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
15572 LODWORD(v27->uExpireTime) = v32;
15573 LODWORD(v32) = pOut.y;
15574 LOBYTE(v32) = LOBYTE(pOut.y) | 0x18;
15575 HIDWORD(v27->uExpireTime) = HIDWORD(v32);
15576 v27->uAttributtes = v32;
15577 }
15578 dword_50C9A8 = 256;
15579 goto LABEL_92;
15580 }
15581 v36 = (70.0 - (double)pParty->pPickedItem._bonus_type) * 0.01;
15582 if ( v36 < 0.0 )
15583 v36 = 0.0;
15584 if ( v51 != 12 )
15585 {
15586 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
15587 return;
15588 }
15589 a2.y = v27->uMaxCharges;
15590 v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
15591 v27->uMaxCharges = v37;
15592 v27->uNumCharges = (unsigned __int8)v37;
15593 goto LABEL_92;
15594 }
15595 v14 = v13 - 222;
15596 v15 = pParty->pPickedItem.uItemID - 222;
15597 v47 = v14;
15598 y.y = 0;
15599 if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 )
15600 {
15601 v16 = 5;
15602 }
15603 else
15604 {
15605 v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388];
15606 v10 = pOut.z;
15607 }
15608 v51 = v16;
15609 if ( v45 )
15610 {
15611 if ( v16 < 225 || v16 > 227 )
15612 {
15613 if ( v16 < 228 || v16 > 239 )
15614 {
15615 if ( v16 < 240 || v16 > 261 )
15616 {
15617 if ( v16 >= 262 && pOut.y != 4 )
15618 {
15619 LABEL_53:
15620 v51 = 4;
15621 goto LABEL_54;
15622 }
15623 }
15624 else
15625 {
15626 if ( pOut.y <= 2 )
15627 {
15628 LABEL_38:
15629 v51 = 3;
15630 goto LABEL_54;
15631 }
15632 }
15633 }
15634 else
15635 {
15636 if ( pOut.y == 1 )
15637 {
15638 LABEL_35:
15639 v51 = 2;
15640 goto LABEL_54;
15641 }
15642 }
15643 }
15644 }
15645 else
15646 {
15647 if ( v16 >= 225 && v16 <= 227 )
15648 {
15649 v51 = 1;
15650 goto LABEL_54;
15651 }
15652 if ( v16 >= 228 && v16 <= 239 )
15653 goto LABEL_35;
15654 if ( v16 >= 240 && v16 <= 261 )
15655 goto LABEL_38;
15656 if ( v16 >= 262 )
15657 goto LABEL_53;
15658 }
15659 LABEL_54:
15660 pOut.y = 0;
15661 pOut.x = v10 + 1;
15662 v17 = (int)v0->pInventoryIndices;
15663 while ( *(int *)v17 != pOut.x )
15664 {
15665 ++pOut.y;
15666 v17 += 4;
15667 if ( pOut.y >= 126 )
15668 {
15669 v18 = y.y;
15670 goto LABEL_59;
15671 }
15672 }
15673 v18 = pOut.y;
15674 LABEL_59:
15675 if ( !v51 )
15676 {
15677 LABEL_115:
15678 v10 = pOut.z;
15679 goto LABEL_116;
15680 }
15681 if ( v51 == 1 )
15682 {
15683 v0->RemoveItemAtInventoryIndex(v18);
15684 v26 = rand();
15685 v0->ReceiveDamage(v26 % 11 + 10, 0);
15686 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
15687 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15688 {
15689 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
15690 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
15691 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15692 ++pMessageQueue_50CBD0->uNumMessages;
15693 }
15694 v42 = (int *)&a2.y;
15695 v41 = (int *)&y.y;
15696 v40 = (int *)&pOut;
15697 v39.z = pParty->vPosition.y + pParty->sEyelevel;
15698 }
15699 else
15700 {
15701 if ( v51 == 2 )
15702 {
15703 v0->RemoveItemAtInventoryIndex(v18);
15704 v25 = rand();
15705 v0->ReceiveDamage(v25 % 71 + 30, 0);
15706 v23 = 1;
15707 }
15708 else
15709 {
15710 if ( v51 == 3 )
15711 {
15712 v0->RemoveItemAtInventoryIndex(v18);
15713 v24 = rand();
15714 v0->ReceiveDamage(v24 % 201 + 50, 0);
15715 v23 = 5;
15716 }
15717 else
15718 {
15719 if ( v51 != 4 )
15720 {
15721 if ( v51 != 5 )
15722 {
15723 v19 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
15724 if ( v19 )
15725 *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
15726 v20 = v47 + 50 * v15;
15727 v0->pInventoryItems[pOut.z].uItemID = v51;
15728 v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type
15729 + v0->pInventoryItems[pOut.z]._bonus_type)
15730 / 2;
15731 v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->field_10168[2 * v20 + 388]);
15732 LABEL_74:
15733 v22 = (int)((char *)v0 + 36 * pOut.z);
15734 if ( !BYTE2(pItemsTable->pItems[*(int *)(v22 + 532) + 1].uItemID) )
15735 *(int *)(v22 + 552) |= 1u;
15736 if ( !dword_4E455C )
15737 goto LABEL_92;
15738 v0->PlaySound(16, 0);
15739 goto LABEL_91;
15740 }
15741 if ( v45 )
15742 {
15743 if ( *(int *)(a2.y + 532) == 221 )
15744 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
15745 else
15746 *(int *)(a2.y + 536) = pParty->pPickedItem._bonus_type;
15747 v21 = v0->AddItem(0xFFFFFFFFu, 0xDCu);
15748 if ( v21 )
15749 *(int *)&v0->field_1F5[36 * v21 + 15] = 1;
15750 goto LABEL_74;
15751 }
15752 goto LABEL_115;
15753 }
15754 v0->RemoveItemAtInventoryIndex(v18);
15755 v0->SetCondition(0x10u, 0);
15756 v23 = 0;
15757 }
15758 }
15759 v0->_4160CA(v23);
15760 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
15761 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15762 {
15763 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
15764 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
15765 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15766 ++pMessageQueue_50CBD0->uNumMessages;
15767 }
15768 v42 = (int *)&a2.y;
15769 v41 = (int *)&y.y;
15770 v40 = (int *)&pOut;
15771 v39.z = pParty->vPosition.y + pParty->sEyelevel;
15772 }
15773 *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
15774 Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
15775 sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0);
15776 if ( dword_4E455C )
15777 {
15778 if ( v0->CanAct() )
15779 v0->PlaySound(17, 0);
15780 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
15781 LABEL_91:
15782 dword_4E455C = 0;
15783 }
15784 LABEL_92:
15785 pMouse->RemoveHoldingItem();
15786 dword_50CDCC = 1;
15787 return;
15788 }
15789 *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
15790 switch ( pParty->pPickedItem.uItemID )
15791 {
15792 case 0xC8u:
15793 case 0xC9u:
15794 case 0xCAu:
15795 case 0xCBu:
15796 case 0xCCu:
15797 v0->pInventoryItems[pOut.z].uItemID = 222;
15798 break;
15799 case 0xCDu:
15800 case 0xCEu:
15801 case 0xCFu:
15802 case 0xD0u:
15803 case 0xD1u:
15804 v0->pInventoryItems[pOut.z].uItemID = 223;
15805 break;
15806 case 0xD2u:
15807 case 0xD3u:
15808 case 0xD4u:
15809 case 0xD5u:
15810 case 0xD6u:
15811 v0->pInventoryItems[pOut.z].uItemID = 224;
15812 break;
15813 case 0xD7u:
15814 case 0xD8u:
15815 case 0xD9u:
15816 case 0xDAu:
15817 case 0xDBu:
15818 v0->pInventoryItems[pOut.z].uItemID = 221;
15819 break;
15820 default:
15821 break;
15822 }
15823 pMouse->RemoveHoldingItem();
15824 dword_50CDCC = 1;
15825 if ( dword_4E455C )
15826 {
15827 v0->PlaySound(16, 0);
15828 dword_4E455C = 0;
15829 }
15830 }
15831
15832
15833 //----- (00416B01) --------------------------------------------------------
15834 void __thiscall sub_416B01(void *_this)
15835 {
15836 int v1; // edi@2
15837 int v2; // ecx@2
15838 NPCData *v3; // eax@2
15839 NPCData *v4; // esi@7
15840 NPCData *v5; // eax@16
15841 NPCData *v6; // esi@16
15842 const CHAR *v7; // eax@18
15843 unsigned int v8; // eax@25
15844 unsigned int v9; // eax@25
15845 const char *v10; // ST14_4@26
15846 char *v11; // esi@26
15847 const char *v12; // ST18_4@27
15848 unsigned __int16 v13; // ax@28
15849 char *v14; // eax@28
15850 GUIWindow a1; // [sp+Ch] [bp-60h]@23
15851 int a2; // [sp+60h] [bp-Ch]@16
15852 void *v17; // [sp+64h] [bp-8h]@1
15853 LPCSTR lpsz; // [sp+68h] [bp-4h]@6
15854
15855 v17 = _this;
15856 if ( bNoNPCHiring != 1 )
15857 {
15858 v1 = 0;
15859 v2 = 0;
15860 v3 = pParty->pHirelings;
15861 do
15862 {
15863 if ( v3->pName )
15864 pTmpBuf[v1++] = v2;
15865 ++v3;
15866 ++v2;
15867 }
15868 while ( (signed int)v3 < (signed int)&pParty->pPickedItem );
15869 lpsz = 0;
15870 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
15871 {
15872 v4 = pNPCStats->pNewNPCData;
15873 do
15874 {
15875 if ( v4->uFlags & 0x80
15876 && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName))
15877 && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) )
15878 pTmpBuf[v1++] = (char)lpsz + 2;
15879 ++lpsz;
15880 ++v4;
15881 }
15882 while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );
15883 }
15884 if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
15885 {
15886 uDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
15887 v5 = GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&a2);
15888 v6 = v5;
15889 if ( v5 )
15890 {
15891 if ( a2 == 57 )
15892 v7 = (const CHAR *)dword_72266C;
15893 else
15894 v7 = (const CHAR *)*(&pNPCStats->field_13A5C + 5 * v5->uProfession);
15895 lpsz = v7;
15896 if ( !v7 )
15897 {
15898 lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
15899 if ( !lpsz )
15900 lpsz = nullstring;
15901 }
15902 a1.str_48 = 0;
15903 a1.uFrameX = 38;
15904 a1.uFrameY = 60;
15905 a1.uFrameWidth = 276;
15906 a1.uFrameZ = 313;
15907 a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0)
15908 + 2 * LOBYTE(pFontArrus->uFontHeight)
15909 + 24;
15910 if ( (signed int)a1.uFrameHeight < 130 )
15911 a1.uFrameHeight = 130;
15912 a1.uFrameWidth = 400;
15913 a1.uFrameZ = a1.uFrameX + 399;
15914 a1._415551(0);
15915 sprintfex(pTmpBuf2, "NPC%03d", v6->uPortraitID);
15916 v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE);
15917 pRenderer->DrawTextureIndexed(
15918 a1.uFrameX + 22,
15919 a1.uFrameY + 36,
15920 (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
15921 v9 = v6->uProfession;
15922 if ( v9 )
15923 {
15924 v10 = v6->pName;
15925 v11 = pTmpBuf;
15926 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]);
15927 }
15928 else
15929 {
15930 v12 = v6->pName;
15931 v11 = pTmpBuf;
15932 strcpy(pTmpBuf, v12);
15933 }
15934 v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
15935 a1.DrawText2(pFontArrus, 0, 0xCu, v13, v11, 3u);
15936 a1.uFrameWidth -= 24;
15937 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
15938 v14 = sub_495461((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0);
15939 a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0);
15940 }
15941 }
15942 }
15943 }
15944
15945
15946 //----- (00416D62) --------------------------------------------------------
15947 void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(Vec2_int_ *_this)
15948 {
15949 signed int v1; // eax@12
15950 char *v2; // eax@32
15951 void *v3; // ecx@52
15952 unsigned int v4; // eax@59
15953 int v5; // esi@62
15954 signed int v6; // esi@64
15955 signed int v7; // esi@69
15956 ItemGen *v8; // ecx@70
15957 unsigned int v9; // eax@72
15958 unsigned int v10; // eax@76
15959 char v11; // zf@83
15960 GUIButton *v12; // esi@84
15961 unsigned int v13; // ecx@85
15962 char *v14; // edi@85
15963 signed int v15; // eax@92
15964 int v16; // eax@95
15965 int v17; // eax@96
15966 enum PLAYER_SKILL_TYPE v18; // eax@98
15967 char *v19; // eax@99
15968 unsigned int v20; // eax@108
15969 unsigned int v21; // eax@109
15970 const char *v22; // eax@111
15971 char *v23; // ebx@112
15972 char *v24; // edx@113
15973 unsigned int v25; // eax@113
15974 GUIWindow a1; // [sp+4h] [bp-74h]@32
15975 double v27; // [sp+58h] [bp-20h]@33
15976 struct tagPOINT Point; // [sp+60h] [bp-18h]@6
15977 char *v29; // [sp+68h] [bp-10h]@33
15978 float v30; // [sp+6Ch] [bp-Ch]@33
15979 unsigned int pX; // [sp+70h] [bp-8h]@3
15980 unsigned int pY; // [sp+74h] [bp-4h]@3
15981
15982 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16 )
15983 return;
15984 if ( _this )
15985 {
15986 pX = _this->x;
15987 pY = _this->y;
15988 }
15989 else
15990 {
15991 pMouse->GetClickPos(&pX, &pY);
15992 }
15993 if ( pRenderer->bWindowMode )
15994 {
15995 GetCursorPos(&Point);
15996 ScreenToClient(hWnd, &Point);
15997 if ( Point.x < 1 || Point.y < 1 || Point.x > 638 || Point.y > 478 )
15998 {
15999 back_to_game();
16000 return;
16001 }
16002 }
16003 if ( pParty->pPickedItem.uItemID )
16004 {
16005 v1 = 0;
16006 do
16007 {
16008 if ( (signed int)pX > word_4E2930[v1]
16009 && (signed int)pX < word_4E2938[v1]
16010 && (signed int)pY > 375
16011 && (signed int)pY < 466 )
16012 {
16013 pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(v1 + 1, 1);
16014 return;
16015 }
16016 ++v1;
16017 }
16018 while ( v1 < 4 );
16019 }
16020 pEventTimer->Pause();
16021 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 10 )
16022 {
16023 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
16024 {
16025 if ( !pPlayers[uActiveCharacter]->CanAct() )
16026 {
16027 sprintfex(
16028 pTmpBuf,
16029 pGlobalTXT_LocalizationStrings[427],
16030 pPlayers[uActiveCharacter]->pName,
16031 pGlobalTXT_LocalizationStrings[541]);
16032 a1.str_48 = pTmpBuf;
16033 a1.uFrameWidth = 384;
16034 a1.uFrameHeight = 180;
16035 a1.uFrameY = 40;
16036 if ( (signed int)pX <= 320 )
16037 v10 = pX + 30;
16038 else
16039 v10 = pX - 414;
16040 a1.uFrameX = v10;
16041 goto LABEL_42;
16042 }
16043 v9 = pX + pSRZBufferLineOffsets[pY];
16044 if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) )
16045 goto LABEL_132;
16046 v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4
16047 + 2662 * (unsigned int)ptr_507BB8->ptr_1C
16048 + 18
16049 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
16050 + (pRenderer->pActiveZBuffer[v9] & 0xFFFF)
16051 + 2662 * (unsigned int)ptr_507BB8->ptr_1C
16052 + 3));
16053 }
16054 else
16055 {
16056 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
16057 {
16058 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 3 )
16059 {
16060 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 7 )
16061 {
16062 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8 )
16063 {
16064 if ( dword_507B00_spell_info_to_draw_in_popup )
16065 DrawSpellDescriptionPopup((void *)(dword_507B00_spell_info_to_draw_in_popup - 1));
16066 }
16067 goto LABEL_132;
16068 }
16069 LABEL_119:
16070 if ( (signed int)pX > 467
16071 && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 14 )
16072 {
16073 LABEL_126:
16074 identify_item();
16075 goto LABEL_132;
16076 }
16077 if ( (signed int)pY >= 345 )
16078 goto LABEL_132;
16079 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )
16080 {
16081 CharacterUI_StatsTab_ShowHint();
16082 goto LABEL_132;
16083 }
16084 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )
16085 {
16086 CharacterUI_SkillsTab_ShowHint();
16087 goto LABEL_132;
16088 }
16089 v11 = pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103;
16090 LABEL_125:
16091 if ( !v11 )
16092 goto LABEL_132;
16093 goto LABEL_126;
16094 }
16095 if ( !dword_506364
16096 || (signed int)pX < (signed int)pViewport->uViewportX
16097 || (signed int)pX > (signed int)pViewport->uViewportZ
16098 || (signed int)pY < (signed int)pViewport->uViewportY
16099 || (signed int)pY > (signed int)pViewport->uViewportW
16100 || (v2 = (char *)sub_444564(), (a1.str_48 = v2) == 0) )
16101 goto LABEL_132;
16102 v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
16103 v27 = v30 + 6.7553994e15;
16104 v29 = (char *)LODWORD(v27);
16105 a1.uFrameWidth = LODWORD(v27);
16106 a1.uFrameX = pX + 5;
16107 a1.uFrameY = pY + 5;
16108 goto LABEL_41;
16109 }
16110 if ( (GetCurrentMenuID() & 0x80000000u) == 0 )
16111 goto LABEL_132;
16112 if ( (signed int)pY > (signed int)pViewport->uViewportW )
16113 {
16114 a1.ptr_1C = (void *)((signed int)pX / 118);
16115 if ( (signed int)pX / 118 < 4 )
16116 {
16117 a1.str_48 = 0;
16118 a1.uFrameWidth = 400;
16119 a1.uFrameHeight = 200;
16120 a1.uFrameX = 38;
16121 a1.uFrameY = 60;
16122 pAudioPlayer->StopChannels(-1, -1);
16123 a1._41D3B7();
16124 }
16125 goto LABEL_132;
16126 }
16127 if ( (signed int)pX > (signed int)pViewport->uViewportZ )
16128 {
16129 if ( (signed int)pY >= 130 )
16130 {
16131 if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
16132 {
16133 a1.str_48 = 0;
16134 a1.uFrameWidth = 400;
16135 a1.uFrameHeight = 200;
16136 a1.uFrameX = 38;
16137 a1.uFrameY = 60;
16138 pAudioPlayer->StopChannels(-1, -1);
16139 a1._41D73D_draw_buff_tooltip();
16140 goto LABEL_132;
16141 }
16142 if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
16143 {
16144 if ( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 )
16145 goto LABEL_132;
16146 pAudioPlayer->StopChannels(-1, -1);
16147 v3 = (void *)1;
16148 }
16149 else
16150 {
16151 pAudioPlayer->StopChannels(-1, -1);
16152 v3 = 0;
16153 }
16154 sub_416B01(v3);
16155 goto LABEL_132;
16156 }
16157 a1.str_48 = _4443D5_GetMinimapRightClickText();
16158 a1.uFrameWidth = 256;
16159 a1.uFrameX = 130;
16160 a1.uFrameY = 140;
16161 LABEL_41:
16162 a1.uFrameHeight = 64;
16163 pAudioPlayer->StopChannels(-1, -1);
16164 LABEL_42:
16165 a1._415551(0);
16166 goto LABEL_132;
16167 }
16168 a1.str_48 = 0;
16169 a1.uFrameWidth = 320;
16170 a1.uFrameHeight = 320;
16171 v4 = pX - 350;
16172 if ( (signed int)pX <= 320 )
16173 v4 = pX + 30;
16174 a1.uFrameX = v4;
16175 a1.uFrameY = 40;
16176 if ( pRenderer->pRenderD3D )
16177 LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
16178 else
16179 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
16180 v6 = (unsigned __int16)v5;
16181 if ( (v6 & 7) != 2 )
16182 {
16183 if ( (v6 & 7) == 3 )
16184 {
16185 if ( pRenderer->uNumSceneBegins )
16186 {
16187 a1._415551(1);
16188 MonsterPopup_Draw(v6 >> 3, &a1);
16189 }
16190 else
16191 {
16192 pRenderer->BeginScene();
16193 a1._415551(1);
16194 MonsterPopup_Draw(v6 >> 3, &a1);
16195 pRenderer->EndScene();
16196 }
16197 }
16198 goto LABEL_132;
16199 }
16200 v7 = v6 >> 3;
16201 if ( pObjectList->pObjects[pLayingItems[v7].uObjectDescID].uFlags & 0x10 )
16202 goto LABEL_132;
16203 v8 = &pLayingItems[v7].stru_24;
16204 }
16205 GameUI_DrawItemInfo(v8);
16206 goto LABEL_132;
16207 }
16208 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 )
16209 {
16210 if ( (signed int)pY < 345 && (signed int)pX < 469 )
16211 sub_4B1A2D();
16212 goto LABEL_132;
16213 }
16214 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 13 )
16215 goto LABEL_132;
16216 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 15 )
16217 goto LABEL_119;
16218 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 21 )
16219 {
16220 v11 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 23;
16221 goto LABEL_125;
16222 }
16223 a1.str_48 = 0;
16224 v12 = pGUIWindow_CurrentMenu->pControlsHead;
16225 if ( !v12 )
16226 goto LABEL_132;
16227 v13 = pY;
16228 v14 = v29;
16229 while ( 1 )
16230 {
16231 if ( v12->uButtonType != 1 && v12->uButtonType != 3
16232 || (signed int)pX < (signed int)v12->uX
16233 || (signed int)pX > (signed int)v12->uZ
16234 || (signed int)v13 < (signed int)v12->uY
16235 || (signed int)v13 > (signed int)v12->uW )
16236 goto LABEL_117;
16237 v15 = v12->uControlID;
16238 if ( v15 <= 65 )
16239 {
16240 if ( v15 == 65 )
16241 {
16242 a1.str_48 = pClassDescriptions[v12->uControlParam];
16243 v14 = pClassNames[v12->uControlParam];
16244 }
16245 else
16246 {
16247 if ( v15 )
16248 {
16249 v16 = v15 - 62;
16250 if ( v16 )
16251 {
16252 v17 = v16 - 1;
16253 if ( v17 )
16254 {
16255 if ( v17 == 1 )
16256 {
16257 v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(
16258 v12->uControlParam + 4);
16259 v14 = pSkillNames[v18];
16260 a1.str_48 = pSkillDesc[v18];
16261 v13 = pY;
16262 }
16263 goto LABEL_117;
16264 }
16265 v14 = pGlobalTXT_LocalizationStrings[668];
16266 v19 = pGlobalTXT_LocalizationStrings[669];
16267 }
16268 else
16269 {
16270 v14 = pGlobalTXT_LocalizationStrings[670];
16271 v19 = pGlobalTXT_LocalizationStrings[671];
16272 }
16273 goto LABEL_116;
16274 }
16275 a1.str_48 = pAttributeDescriptions[(signed int)v12->uControlParam % 7];
16276 v14 = aAttributeNames[(signed int)v12->uControlParam % 7];
16277 }
16278 goto LABEL_117;
16279 }
16280 if ( v15 == 66 )
16281 {
16282 v19 = pGlobalTXT_LocalizationStrings[664];
16283 v14 = pGlobalTXT_LocalizationStrings[665];
16284 goto LABEL_116;
16285 }
16286 if ( v15 == 67 )
16287 {
16288 v19 = pGlobalTXT_LocalizationStrings[666];
16289 v14 = pGlobalTXT_LocalizationStrings[667];
16290 goto LABEL_116;
16291 }
16292 if ( v15 > 71 )
16293 break;
16294 LABEL_117:
16295 v12 = v12->pNext;
16296 if ( !v12 )
16297 goto LABEL_112;
16298 }
16299 if ( v15 > 75 )
16300 {
16301 if ( v15 == 118 )
16302 {
16303 v20 = v12->uControlParam;
16304 v14 = pParty->pPlayers[v20].pName;
16305 v19 = pClassDescriptions[pParty->pPlayers[v20].uClass];
16306 LABEL_116:
16307 a1.str_48 = v19;
16308 goto LABEL_117;
16309 }
16310 goto LABEL_117;
16311 }
16312 v21 = pParty->pPlayers[v12->uControlParam].GetSkillIdxByOrder(v15 - 72);
16313 v13 = v21;
16314 pY = v21;
16315 if ( (v21 & 0x80000000u) != 0 || (signed int)v21 >= 37 )
16316 goto LABEL_117;
16317 v22 = CharacterUI_GetSkillDescText(v12->uControlParam, (enum PLAYER_SKILL_TYPE)v21);
16318 strcpy(pTmpBuf2, v22);
16319 a1.str_48 = pTmpBuf2;
16320 v14 = pSkillNames[pY];
16321 LABEL_112:
16322 v23 = a1.str_48;
16323 if ( a1.str_48 )
16324 {
16325 v24 = a1.str_48;
16326 a1.str_48 = 0;
16327 a1.uFrameWidth = 384;
16328 a1.uFrameHeight = 256;
16329 a1.uFrameX = 128;
16330 a1.uFrameY = 40;
16331 a1.uFrameHeight = pFontSmallnum->CalcTextHeight(v24, &a1, 24, 0)
16332 + 2 * LOBYTE(pFontLucida->uFontHeight)
16333 + 24;
16334 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
16335 a1.uFrameW = a1.uFrameY + a1.uFrameHeight - 1;
16336 a1._415551(0);
16337 a1.uFrameX += 12;
16338 a1.uFrameWidth -= 24;
16339 a1.uFrameY += 12;
16340 a1.uFrameHeight -= 12;
16341 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
16342 a1.uFrameW = a1.uFrameY + a1.uFrameHeight - 1;
16343 v25 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
16344 sprintfex(pTmpBuf, format_4E2D80, v25, v14);
16345 a1.DrawText2(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
16346 a1.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v23, 0, 0, 0);
16347 }
16348 LABEL_132:
16349 dword_507BF0_is_there_popup_onscreen = 1;
16350 viewparams->bRedrawGameUI = 1;
16351 }
16352
16353
16354 //----- (004175C0) --------------------------------------------------------
16355 void __thiscall UI_OnMouseLeftClick(int *pXY)
16356 {
16357 int *pXY_; // esi@1
16358 signed int y; // eax@7
16359 signed int x; // ecx@7
16360 unsigned int v4; // eax@11
16361 signed int v5; // eax@17
16362 signed int v6; // esi@19
16363 int v7; // esi@30
16364 GUIWindow *v8; // edx@31
16365 GUIButton *i; // esi@37
16366 signed int v10; // eax@50
16367 int v11; // ecx@52
16368 unsigned int pX; // [sp+14h] [bp-8h]@7
16369 unsigned int pY; // [sp+18h] [bp-4h]@7
16370
16371 pXY_ = pXY;
16372 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16
16373 || sub_4637E0_is_there_popup_onscreen() )
16374 return;
16375 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
16376 {
16377 sub_4452BB();
16378 return;
16379 }
16380 if ( pXY_ )
16381 {
16382 x = *pXY_;
16383 y = pXY_[1];
16384 pX = *pXY_;
16385 pY = y;
16386 }
16387 else
16388 {
16389 pMouse->GetClickPos(&pX, &pY);
16390 y = pY;
16391 x = pX;
16392 }
16393 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
16394 || !dword_507B98_ctrl_pressed )
16395 goto LABEL_30;
16396 v4 = GetCurrentMenuID();
16397 x = pX;
16398 if ( (v4 & 0x80000000u) == 0
16399 || (signed int)pX < (signed int)pViewport->uViewportX
16400 || (signed int)pX > (signed int)pViewport->uViewportZ )
16401 {
16402 y = pY;
16403 LABEL_30:
16404 v7 = uNumVisibleWindows;
16405 if ( uNumVisibleWindows < 0 )
16406 return;
16407 while ( 1 )
16408 {
16409 v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]];
16410 if ( x >= (signed int)v8->uFrameX )
16411 {
16412 if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW )
16413 break;
16414 }
16415 --v7;
16416 if ( v7 < 0 )
16417 return;
16418 }
16419 for ( i = v8->pControlsHead; ; i = i->pNext )
16420 {
16421 if ( !i )
16422 return;
16423 if ( i->uButtonType == 1 )
16424 goto LABEL_41;
16425 if ( i->uButtonType != 2 )
16426 break;
16427 if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth )
16428 goto LABEL_50;
16429 y = pY;
16430 x = pX;
16431 LABEL_45:
16432 ;
16433 }
16434 if ( i->uButtonType != 3 )
16435 goto LABEL_45;
16436 LABEL_41:
16437 if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW )
16438 {
16439 LABEL_50:
16440 i->field_2C = 1;
16441 v10 = pMessageQueue_50CBD0->uNumMessages;
16442 if ( pMessageQueue_50CBD0->uNumMessages )
16443 {
16444 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
16445 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
16446 }
16447 v11 = i->uControlParam;
16448 if ( v10 < 40 )
16449 {
16450 pMessageQueue_50CBD0->pMessages[v10].eType = (UIMessageType)i->uControlID;
16451 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11;
16452 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
16453 ++pMessageQueue_50CBD0->uNumMessages;
16454 }
16455 return;
16456 }
16457 goto LABEL_45;
16458 }
16459 y = pY;
16460 if ( (signed int)pY < (signed int)pViewport->uViewportY || (signed int)pY > (signed int)pViewport->uViewportW )
16461 goto LABEL_30;
16462 if ( pRenderer->pRenderD3D )
16463 v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
16464 else
16465 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
16466 v6 = (unsigned __int16)v5;
16467 if ( (v5 & 7) == 3
16468 && uActiveCharacter
16469 && v5 < 33554432
16470 && pPlayers[uActiveCharacter]->CanAct()
16471 && pPlayers[uActiveCharacter]->CanSteal() )
16472 {
16473 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
16474 {
16475 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)27;
16476 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
16477 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
16478 ++pMessageQueue_50CBD0->uNumMessages;
16479 }
16480 if ( pParty->bTurnBasedModeOn == 1 )
16481 {
16482 if ( pTurnEngine->field_4 == 3 )
16483 pTurnEngine->field_18 |= 8u;
16484 }
16485 }
16486 }
16487
16488
16489
16490 //----- (00417871) --------------------------------------------------------
16491 void __thiscall sub_417871(int *pXY)
16492 {
16493 POINT v1; // [sp+0h] [bp-18h]@5
16494 POINT a2; // [sp+8h] [bp-10h]@5
16495 unsigned int pY; // [sp+10h] [bp-8h]@3
16496 unsigned int pX; // [sp+14h] [bp-4h]@3
16497
16498 if ( !pRenderer->pRenderD3D )
16499 {
16500 if ( pXY )
16501 {
16502 pX = *pXY;
16503 pY = pXY[1];
16504 }
16505 else
16506 {
16507 pMouse->GetClickPos(&pX, &pY);
16508 }
16509 pMouse->GetCursorPos(&a2);
16510 pMouse->GetCursorPos(&v1);
16511 }
16512 }
16513
16514 //----- (004178C4) --------------------------------------------------------
16515 void __cdecl sub_4178C4()
16516 {
16517 if ( pArcomageGame->bGameInProgress == 1 )
16518 {
16519 if ( pAsyncMouse )
16520 pArcomageGame->stru1.field_0 = 7;
16521 }
16522 }
16523
16524 //----- (004178E1) --------------------------------------------------------
16525 void __cdecl sub_4178E1()
16526 {
16527 if ( pArcomageGame->bGameInProgress == 1 )
16528 {
16529 if ( pAsyncMouse )
16530 pArcomageGame->stru1.field_0 = 8;
16531 }
16532 }
16533
16534 //----- (004178FE) --------------------------------------------------------
16535 unsigned int __fastcall sub_4178FE(signed int a1, signed int a2)
16536 {
16537 unsigned __int16 v2; // dx@2
16538 unsigned __int16 v3; // cx@2
16539 int v5; // eax@5
16540 unsigned __int16 v6; // [sp-4h] [bp-8h]@2
16541
16542 if ( a1 <= a2 )
16543 {
16544 if ( a1 == a2 )
16545 return 0;
16546 v5 = 100 * a1 / a2;
16547 v3 = 255;
16548 if ( v5 >= 25 )
16549 {
16550 v6 = 100;
16551 v2 = 255;
16552 }
16553 else
16554 {
16555 v6 = 0;
16556 v2 = 0;
16557 }
16558 }
16559 else
16560 {
16561 v6 = 0;
16562 v2 = 255;
16563 v3 = 0;
16564 }
16565 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
16566 }
16567
16568 //----- (00417939) --------------------------------------------------------
16569 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx)
16570 {
16571 unsigned int v1; // ebx@1
16572 signed int v2; // edi@1
16573 unsigned int v3; // esi@1
16574 unsigned int v4; // eax@1
16575 unsigned int v6; // [sp+Ch] [bp-4h]@1
16576
16577 v1 = uConditionIdx;
16578 v2 = 65535;
16579 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
16580 v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
16581 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
16582 switch ( v1 )
16583 {
16584 case 0u:
16585 case 1u:
16586 case 3u:
16587 case 4u:
16588 case 5u:
16589 case 6u:
16590 case 7u:
16591 v2 = v4;
16592 break;
16593 case 2u:
16594 case 8u:
16595 case 9u:
16596 case 0xCu:
16597 case 0xDu:
16598 v2 = v3;
16599 break;
16600 case 0xAu:
16601 case 0xBu:
16602 case 0xEu:
16603 case 0xFu:
16604 case 0x10u:
16605 v2 = v6;
16606 break;
16607 default:
16608 return v2;
16609 }
16610 return v2;
16611 }
16612
16613 //----- (004179BC) --------------------------------------------------------
16614 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2)
16615 {
16616 const char *v2; // ebx@1
16617 const char *v3; // edi@1
16618 unsigned int v4; // eax@1
16619 GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1
16620 POINT v6; // [sp+60h] [bp-8h]@1
16621
16622 v2 = a2;
16623 v3 = a1;
16624 memset(&Dst, 0, 0x54u);
16625 Dst.uFrameWidth = 384;
16626 Dst.uFrameHeight = 256;
16627 Dst.uFrameX = 128;
16628 Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30;
16629 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
16630 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
16631 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
16632 Dst._415551(0);
16633 Dst.uFrameX += 12;
16634 Dst.uFrameWidth -= 24;
16635 Dst.uFrameY += 12;
16636 Dst.uFrameHeight -= 12;
16637 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
16638 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
16639 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
16640 sprintfex(pTmpBuf, format_4E2D80, v4, v3);
16641 Dst.DrawText2(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
16642 return Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
16643 }
16644
16645 //----- (00417AD4) --------------------------------------------------------
16646 unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3)
16647 {
16648 enum PLAYER_SKILL_TYPE v3; // ebx@1
16649 signed int v4; // edi@1
16650 unsigned int v5; // ecx@1
16651 int v6; // edx@1
16652 int v7; // eax@7
16653 int v8; // eax@10
16654 unsigned __int8 v9; // sf@10
16655 unsigned __int8 v10; // of@10
16656 int v11; // eax@11
16657 int v12; // eax@14
16658 unsigned int yellow; // [sp+Ch] [bp-Ch]@1
16659 unsigned int red; // [sp+10h] [bp-8h]@1
16660 unsigned int white; // [sp+14h] [bp-4h]@1
16661
16662 v3 = uPlayerSkillType;
16663 v4 = uPlayerClass;
16664 white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16665 red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
16666 yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0);
16667 v5 = 0;
16668 v6 = v4 % 4;
16669 if ( !(v4 % 4) )
16670 {
16671 v11 = 37 * v4 + v3;
16672 if ( byte_4ED970_skill_learn_ability_by_class_table[0][v11] >= a3 )
16673 goto LABEL_8;
16674 if ( byte_4ED970_skill_learn_ability_by_class_table[1][v11] < a3
16675 && byte_4ED970_skill_learn_ability_by_class_table[2][v11] < a3 )
16676 {
16677 v12 = byte_4ED970_skill_learn_ability_by_class_table[3][v11];
16678 v10 = __OFSUB__(v12, a3);
16679 v9 = v12 - a3 < 0;
16680 LABEL_15:
16681 v5 = red;
16682 if ( v9 ^ v10 )
16683 return v5;
16684 }
16685 return yellow;
16686 }
16687 if ( v6 == 1 )
16688 {
16689 v7 = 37 * v4 + v3;
16690 if ( byte_4ED970_skill_learn_ability_by_class_table[0][v7] >= a3 )
16691 goto LABEL_8;
16692 if ( byte_4ED970_skill_learn_ability_by_class_table[1][v7] < a3 )
16693 {
16694 v8 = byte_4ED970_skill_learn_ability_by_class_table[2][v7];
16695 v10 = __OFSUB__(v8, a3);
16696 v9 = v8 - a3 < 0;
16697 goto LABEL_15;
16698 }
16699 return yellow;
16700 }
16701 if ( v6 > 1 && v6 <= 3 )
16702 {
16703 if ( byte_4ED970_skill_learn_ability_by_class_table[v4][v3] < a3 )
16704 return red;
16705 LABEL_8:
16706 v5 = white;
16707 }
16708 return v5;
16709 }
16710
16711 //----- (00417BB5) --------------------------------------------------------
16712 const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, enum PLAYER_SKILL_TYPE uPlayerSkillType)
16713 {
16714 enum PLAYER_SKILL_TYPE v2; // esi@1
16715 unsigned int v3; // ebx@1
16716 int v4; // edi@1
16717 int v5; // eax@1
16718 Player *pPlayer; // ebx@7
16719 char v7; // al@7
16720 char v8; // cl@7
16721 unsigned int v9; // eax@8
16722 unsigned int v10; // eax@8
16723 unsigned int v11; // eax@8
16724 enum PLAYER_SKILL_TYPE v12; // edi@8
16725 unsigned int v13; // eax@8
16726 unsigned int v14; // eax@8
16727 enum PLAYER_SKILL_TYPE v15; // esi@8
16728 int v16; // edi@8
16729 char v17; // al@8
16730 int v18; // ST5C_4@8
16731 int v19; // ST4C_4@8
16732 int v20; // ST3C_4@8
16733 int v21; // ST2C_4@8
16734 int v22; // ST1C_4@8
16735 char *v23; // esi@8
16736 unsigned int v24; // eax@9
16737 unsigned int v25; // eax@9
16738 unsigned int v26; // eax@9
16739 unsigned int v27; // ecx@9
16740 enum PLAYER_SKILL_TYPE v28; // ebx@9
16741 unsigned int v29; // eax@9
16742 char a2[1200]; // [sp+Ch] [bp-538h]@7
16743 char Source[120]; // [sp+4BCh] [bp-88h]@7
16744 unsigned __int16 *v33; // [sp+534h] [bp-10h]@1
16745 int v34; // [sp+538h] [bp-Ch]@1
16746 unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1
16747 enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1
16748
16749 v2 = uPlayerSkillType;
16750 v3 = uPlayerID;
16751 v36 = uPlayerSkillType;
16752 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal
16753 v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert
16754 v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master
16755 v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);// Grand
16756 v35 = (unsigned __int16 *)v4;
16757 if ( v34 > v4 )
16758 v35 = (unsigned __int16 *)v34;
16759 if ( (signed int)v33 > (signed int)v35 )
16760 v35 = v33;
16761 if ( v5 > (signed int)v35 )
16762 v35 = (unsigned __int16 *)v5;
16763 pPlayer = &pParty->pPlayers[v3];
16764 v33 = &pPlayer->pActiveSkills[v2];
16765 v7 = pPlayer->GetActualSkillLevel(v2);
16766 v8 = LOBYTE(pPlayer->pActiveSkills[v2]);
16767 a2[0] = 0;
16768 Source[0] = 0;
16769 if ( (v8 & 0x3F) == (v7 & 0x3F) )
16770 {
16771 strcpy(a2, "%s\n\n");
16772 v24 = sub_417AD4(pPlayer->uClass, v2, 1);
16773 sprintfex(Source, format_4E2DC8, v24);
16774 strcat(a2, Source);
16775 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16776 v25 = sub_417AD4(pPlayer->uClass, v36, 2);
16777 sprintfex(Source, format_4E2DC8, v25);
16778 strcat(a2, Source);
16779 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16780 v26 = sub_417AD4(pPlayer->uClass, v36, 3);
16781 sprintfex(Source, format_4E2DC8, v26);
16782 strcat(a2, Source);
16783 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16784 v27 = pPlayer->uClass;
16785 v28 = v36;
16786 v29 = sub_417AD4(v27, v36, 4);
16787 sprintfex(Source, format_4E2DC8, v29);
16788 strcat(a2, Source);
16789 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16790
16791 v23 = static_sub_417BB5_out_string;
16792 sprintfex(
16793 static_sub_417BB5_out_string,
16794 a2,
16795 pSkillDesc[v28],
16796 pGlobalTXT_LocalizationStrings[431], // Normal
16797 (char *)v35 + 3,
16798 v35 + 5,
16799 pNormalSkillDesc[v28],
16800 pGlobalTXT_LocalizationStrings[433], // Expert
16801 (char *)v35 + 3,
16802 v35 + 5,
16803 pExpertSkillDesc[v28],
16804 pGlobalTXT_LocalizationStrings[432], // Master
16805 (char *)v35 + 3,
16806 v35 + 5,
16807 pMasterSkillDesc[v28],
16808 pGlobalTXT_LocalizationStrings[96], // Grand
16809 (char *)v35 + 3,
16810 v35 + 5,
16811 pGrandSkillDesc[v28]);
16812 }
16813 else
16814 {
16815 strcpy(a2, "%s\n\n");
16816 v9 = sub_417AD4(pPlayer->uClass, v2, 1);
16817 sprintfex(Source, format_4E2DC8, v9);
16818 strcat(a2, Source);
16819 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16820 v10 = sub_417AD4(pPlayer->uClass, v36, 2);
16821 sprintfex(Source, format_4E2DC8, v10);
16822 strcat(a2, Source);
16823 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16824 v11 = sub_417AD4(pPlayer->uClass, v36, 3);
16825 sprintfex(Source, format_4E2DC8, v11);
16826 strcat(a2, Source);
16827 strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
16828 v12 = v36;
16829 v13 = sub_417AD4(pPlayer->uClass, v36, 4);
16830 sprintfex(Source, format_4E2DC8, v13);
16831 strcat(a2, Source);
16832 strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
16833 v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
16834 sprintfex(Source, format_4E2DC8, v14);
16835 strcat(a2, Source);
16836 strcat(a2, "%s: +%d");
16837 v15 = v12;
16838 v16 = (int)(v35 + 5);
16839 v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4);
16840 v34 = (int)((char *)v35 + 3);
16841 v17 = pPlayer->GetActualSkillLevel(v36);
16842 v18 = *(int *)((char *)pGrandSkillDesc + v15);
16843 v19 = *(int *)((char *)pMasterSkillDesc + v15);
16844 v20 = *(int *)((char *)pExpertSkillDesc + v15);
16845 v21 = *(int *)((char *)pNormalSkillDesc + v15);
16846 v22 = *(int *)((char *)pSkillDesc + v15);
16847 v23 = static_sub_417BB5_out_string;
16848 sprintfex(
16849 static_sub_417BB5_out_string,
16850 a2,
16851 v22,
16852 pGlobalTXT_LocalizationStrings[431],
16853 v34,
16854 v16,
16855 v21,
16856 pGlobalTXT_LocalizationStrings[433],
16857 v34,
16858 v16,
16859 v20,
16860 pGlobalTXT_LocalizationStrings[432],
16861 v34,
16862 v16,
16863 v19,
16864 pGlobalTXT_LocalizationStrings[96],
16865 v34,
16866 v16,
16867 v18,
16868 pGlobalTXT_LocalizationStrings[623],
16869 (v17 & 0x3F) - (*(char *)v33 & 0x3F));
16870 }
16871 return v23;
16872 }
16873
16874 //----- (00417FE5) --------------------------------------------------------
16875 char __cdecl CharacterUI_SkillsTab_ShowHint()
16876 {
16877 unsigned int v0; // ecx@1
16878 unsigned int v1; // eax@1
16879 GUIButton *i; // esi@6
16880 const char *v3; // eax@12
16881 unsigned int pX; // [sp+4h] [bp-8h]@1
16882 unsigned int pY; // [sp+8h] [bp-4h]@1
16883
16884 pMouse->GetClickPos(&pX, &pY);
16885 v0 = pX;
16886 v1 = pY;
16887 if ( (signed int)pX < 24 || (signed int)pX > 455 || (signed int)pY < 18 || (signed int)pY > 36 )
16888 {
16889 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
16890 {
16891 if ( i->uControlID == 121
16892 && (signed int)v0 >= (signed int)i->uX
16893 && (signed int)v0 <= (signed int)i->uZ
16894 && (signed int)v1 >= (signed int)i->uY
16895 && (signed int)v1 <= (signed int)i->uW )
16896 {
16897 v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (enum PLAYER_SKILL_TYPE)i->uControlParam);
16898 sub_4179BC_draw_tooltip(pSkillNames[i->uControlParam], v3);
16899 v1 = pY;
16900 v0 = pX;
16901 }
16902 }
16903 }
16904 else
16905 {
16906 LOBYTE(v1) = sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription);
16907 }
16908 return v1;
16909 }
16910
16911 //----- (00418083) --------------------------------------------------------
16912 char __cdecl CharacterUI_StatsTab_ShowHint()
16913 {
16914 LONG _x; // esi@1
16915 Player *_y; // eax@1
16916 int v2; // edi@1
16917 __int16 *v3; // ecx@1
16918 LONG v4; // edx@2
16919 signed int v5; // edx@4
16920 char *v6; // ecx@9
16921 char *v7; // ebx@9
16922 unsigned int v8; // ebx@15
16923 unsigned __int64 v9; // kr00_8@15
16924 char *v10; // ST2C_4@15
16925 signed int v11; // eax@15
16926 char *v12; // ecx@17
16927 char *v13; // eax@20
16928 Player *v14; // esi@28
16929 int v15; // ebx@28
16930 int v16; // eax@33
16931 POINT a2; // [sp+Ch] [bp-24h]@1
16932 __int64 v19; // [sp+14h] [bp-1Ch]@15
16933 char *v20; // [sp+1Ch] [bp-14h]@13
16934 Player *v21; // [sp+20h] [bp-10h]@13
16935 unsigned int v22; // [sp+24h] [bp-Ch]@15
16936 int *v23; // [sp+28h] [bp-8h]@13
16937 const char *v24; // [sp+2Ch] [bp-4h]@10
16938
16939 _x = pMouse->GetCursorPos(&a2)->x;
16940 _y = (Player *)pMouse->GetCursorPos(&a2)->y;
16941 v2 = 0;
16942 v3 = &array_4E2940[0].field_2;
16943 while ( 1 )
16944 {
16945 v4 = *(v3 - 1);
16946 if ( _x >= v4 )
16947 {
16948 if ( _x <= v4 + v3[1] )
16949 {
16950 v5 = *v3;
16951 if ( (signed int)_y >= v5 )
16952 {
16953 if ( (signed int)_y <= v5 + v3[2] )
16954 break;
16955 }
16956 }
16957 }
16958 v3 += 4;
16959 ++v2;
16960 if ( (signed int)v3 >= (signed int)&off_4E2A12 )
16961 return (char)_y;
16962 }
16963 switch ( v2 )
16964 {
16965 case 0:
16966 case 1:
16967 case 2:
16968 case 3:
16969 case 4:
16970 case 5:
16971 case 6:
16972 LOBYTE(_y) = 4 * v2;
16973 v6 = aAttributeNames[v2];
16974 v7 = pAttributeDescriptions[v2];
16975 goto LABEL_46;
16976 case 7:
16977 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[108]);
16978 v7 = pHealthPointsAttributeDescription;
16979 v24 = pGlobalTXT_LocalizationStrings[108];
16980 goto LABEL_47;
16981 case 8:
16982 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[212]);
16983 v7 = pSpellPointsAttributeDescription;
16984 v24 = pGlobalTXT_LocalizationStrings[212];
16985 goto LABEL_47;
16986 case 9:
16987 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[12]);
16988 v7 = pArmourClassAttributeDescription;
16989 v24 = pGlobalTXT_LocalizationStrings[12];
16990 goto LABEL_47;
16991 case 10:
16992 v24 = pGlobalTXT_LocalizationStrings[47];
16993 strcpy(pTmpBuf2, pPlayerConditionAttributeDescription);
16994 v7 = pTmpBuf2;
16995 v20 = pTmpBuf2;
16996 strcat(pTmpBuf2, "\n");
16997 v23 = pConditionImportancyTable;
16998 _y = pPlayers[uActiveCharacter];
16999 v21 = pPlayers[uActiveCharacter];
17000 do
17001 {
17002 if ( _y->pConditions[*v23] )
17003 {
17004 strcat(pTmpBuf2, " \n");
17005 v8 = *v23;
17006 v9 = pParty->uTimePlayed - v21->pConditions[*v23];
17007 a2.x = LODWORD(pParty->uTimePlayed) - LODWORD(v21->pConditions[*v23]);
17008 a2.y = HIDWORD(v9);
17009 v19 = (signed __int64)((double)*(signed __int64 *)&a2 * 0.234375) / 60 / 60;
17010 v22 = (unsigned int)v19 / 0x18;
17011 v10 = aCharacterConditionNames[v8];
17012 v19 %= 24i64;
17013 v11 = GetConditionDrawColor(v8);
17014 sprintfex(pTmpBuf, &byte_4E2DE8, v11, v10);
17015 strcat(pTmpBuf2, pTmpBuf);
17016 if ( v19 && v19 <= 1 )
17017 v12 = pGlobalTXT_LocalizationStrings[109];
17018 else
17019 v12 = pGlobalTXT_LocalizationStrings[110];
17020 if ( !v22 || (v13 = pGlobalTXT_LocalizationStrings[56], v22 > 1) )
17021 v13 = pGlobalTXT_LocalizationStrings[57];
17022 sprintfex(pTmpBuf, "%lu %s, %lu %s", v22, v13, v19, v12);
17023 strcat(pTmpBuf2, pTmpBuf);
17024 v7 = v20;
17025 _y = v21;
17026 }
17027 ++v23;
17028 }
17029 while ( (signed int)v23 < (signed int)&unk_4EDF40 );
17030 goto LABEL_47;
17031 case 11:
17032 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[172]);
17033 v7 = pFastSpellAttributeDescription;
17034 v24 = pGlobalTXT_LocalizationStrings[172];
17035 goto LABEL_47;
17036 case 12:
17037 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[5]);
17038 v7 = pPlayerAgeAttributeDescription;
17039 v24 = pGlobalTXT_LocalizationStrings[5];
17040 goto LABEL_47;
17041 case 13:
17042 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[131]);
17043 v7 = pPlayerLevelAttributeDescription;
17044 v24 = pGlobalTXT_LocalizationStrings[131];
17045 goto LABEL_47;
17046 case 14:
17047 v14 = pPlayers[uActiveCharacter];
17048 v24 = pGlobalTXT_LocalizationStrings[83];
17049 v15 = v14->uLevel;
17050 do
17051 {
17052 if ( (signed __int64)v14->uExperience < (unsigned int)sub_4B46F8(v15) )
17053 break;
17054 ++v15;
17055 }
17056 while ( v15 <= 10000 );
17057 pTmpBuf[0] = 0;
17058 pTmpBuf2[0] = 0;
17059 if ( v15 > v14->uLevel )
17060 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[147], v15);
17061 v16 = sub_4B46F8(v15) - LODWORD(v14->uExperience);
17062 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[538], v16, v15 + 1);
17063 strcat(pTmpBuf, "\n");
17064 strcat(pTmpBuf, pTmpBuf2);
17065 LOBYTE(_y) = sprintfex(pTmpBuf2, "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf);
17066 v7 = pTmpBuf2;
17067 goto LABEL_47;
17068 case 15:
17069 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[587]);
17070 v7 = pAttackBonusAttributeDescription;
17071 v24 = pGlobalTXT_LocalizationStrings[587];
17072 goto LABEL_47;
17073 case 16:
17074 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[588]);
17075 v7 = pAttackDamageAttributeDescription;
17076 v24 = pGlobalTXT_LocalizationStrings[588];
17077 goto LABEL_47;
17078 case 17:
17079 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[589]);
17080 v7 = pMissleBonusAttributeDescription;
17081 v24 = pGlobalTXT_LocalizationStrings[589];
17082 goto LABEL_47;
17083 case 18:
17084 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[590]);
17085 v7 = pMissleDamageAttributeDescription;
17086 v24 = pGlobalTXT_LocalizationStrings[590];
17087 goto LABEL_47;
17088 case 19:
17089 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[87]);
17090 v7 = pFireResistanceAttributeDescription;
17091 v24 = pGlobalTXT_LocalizationStrings[87];
17092 goto LABEL_47;
17093 case 20:
17094 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[6]);
17095 v7 = pAirResistanceAttributeDescription;
17096 v24 = pGlobalTXT_LocalizationStrings[6];
17097 goto LABEL_47;
17098 case 21:
17099 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[240]);
17100 v7 = pWaterResistanceAttributeDescription;
17101 v24 = pGlobalTXT_LocalizationStrings[240];
17102 goto LABEL_47;
17103 case 22:
17104 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[70]);
17105 v7 = pEarthResistanceAttributeDescription;
17106 v24 = pGlobalTXT_LocalizationStrings[70];
17107 goto LABEL_47;
17108 case 23:
17109 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[142]);
17110 v7 = pMindResistanceAttributeDescription;
17111 v24 = pGlobalTXT_LocalizationStrings[142];
17112 goto LABEL_47;
17113 case 24:
17114 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[29]);
17115 v7 = pBodyResistanceAttributeDescription;
17116 v24 = pGlobalTXT_LocalizationStrings[29];
17117 goto LABEL_47;
17118 case 25:
17119 LOBYTE(_y) = LOBYTE(pGlobalTXT_LocalizationStrings[207]);
17120 v7 = pSkillPointsAttributeDescription;
17121 v24 = pGlobalTXT_LocalizationStrings[207];
17122 goto LABEL_47;
17123 case 26:
17124 _y = (Player *)(4 * pPlayers[uActiveCharacter]->uClass);
17125 v6 = *(char **)((char *)_y->pConditions + (int)pClassNames);
17126 v7 = *(char **)((char *)_y->pConditions + (int)pClassDescriptions);
17127 LABEL_46:
17128 v24 = v6;
17129 LABEL_47:
17130 if ( v24 && v7 )
17131 LOBYTE(_y) = sub_4179BC_draw_tooltip(v24, v7);
17132 break;
17133 default:
17134 return (char)_y;
17135 }
17136 return (char)_y;
17137 }
17138 // 4E2A12: using guessed type void *off_4E2A12;
17139
17140 //----- (00418511) --------------------------------------------------------
17141 char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
17142 {
17143 Player *pPlayer; // edi@1
17144 unsigned int v2; // eax@1
17145 unsigned int v3; // eax@1
17146 unsigned int v4; // eax@2
17147 int v5; // ST20_4@4
17148 int v6; // ST1C_4@4
17149 int v7; // ebp@4
17150 int v8; // eax@4
17151 unsigned int v9; // eax@4
17152 int v10; // ST34_4@4
17153 int v11; // ST20_4@4
17154 int v12; // ST1C_4@4
17155 int v13; // ebp@4
17156 int v14; // eax@4
17157 unsigned int v15; // eax@4
17158 int v16; // ST34_4@4
17159 int v17; // ST20_4@4
17160 int v18; // ST1C_4@4
17161 int v19; // ebp@4
17162 int v20; // eax@4
17163 unsigned int v21; // eax@4
17164 int v22; // ST34_4@4
17165 int v23; // ST20_4@4
17166 int v24; // ST1C_4@4
17167 int v25; // ebp@4
17168 int v26; // eax@4
17169 unsigned int v27; // eax@4
17170 int v28; // ST34_4@4
17171 int v29; // ST20_4@4
17172 int v30; // ST1C_4@4
17173 int v31; // ebp@4
17174 int v32; // eax@4
17175 unsigned int v33; // eax@4
17176 int v34; // ST34_4@4
17177 int v35; // ST20_4@4
17178 int v36; // ST1C_4@4
17179 int v37; // ebp@4
17180 int v38; // eax@4
17181 unsigned int v39; // eax@4
17182 int v40; // ST34_4@4
17183 int v41; // ST20_4@4
17184 int v42; // ST1C_4@4
17185 int v43; // ebp@4
17186 int v44; // eax@4
17187 unsigned int v45; // eax@4
17188 int v46; // ebp@4
17189 signed int v47; // ST20_4@6
17190 int v48; // ST1C_4@6
17191 signed int v49; // eax@6
17192 unsigned int v50; // eax@6
17193 int v51; // ST20_4@8
17194 int v52; // ST1C_4@8
17195 int v53; // eax@8
17196 unsigned int v54; // eax@8
17197 int v55; // ST34_4@8
17198 int v56; // ST20_4@8
17199 int v57; // ST1C_4@8
17200 int v58; // ebp@8
17201 int v59; // eax@8
17202 unsigned int v60; // eax@8
17203 unsigned int v61; // ebp@8
17204 unsigned int v62; // eax@8
17205 char *v63; // ST20_4@8
17206 signed int v64; // eax@8
17207 unsigned int v65; // ebp@8
17208 unsigned __int8 v66; // al@8
17209 char *v67; // eax@9
17210 unsigned int v68; // ST20_4@11
17211 unsigned int v69; // ST1C_4@11
17212 signed int v70; // ebp@11
17213 signed int v71; // eax@11
17214 unsigned int v72; // eax@11
17215 int v73; // ST20_4@13
17216 int v74; // ST1C_4@13
17217 int v75; // ebp@13
17218 int v76; // eax@13
17219 unsigned int v77; // eax@13
17220 char *v78; // ecx@14
17221 int v79; // ST20_4@16
17222 char *v80; // ST40_4@16
17223 unsigned int v81; // eax@16
17224 int v82; // ST34_4@16
17225 int v83; // eax@16
17226 int v84; // ST34_4@16
17227 char *v85; // eax@16
17228 int v86; // ST34_4@16
17229 int v87; // eax@16
17230 int v88; // ST34_4@16
17231 char *v89; // eax@16
17232 int v90; // eax@16
17233 int v91; // ST20_4@19
17234 unsigned int v92; // eax@19
17235 int v93; // eax@19
17236 int v94; // ST20_4@22
17237 unsigned int v95; // eax@22
17238 int v96; // eax@22
17239 int v97; // ST20_4@25
17240 unsigned int v98; // eax@25
17241 int v99; // eax@25
17242 int v100; // ST20_4@27
17243 unsigned int v101; // eax@27
17244 int v102; // eax@27
17245 int v103; // ST20_4@30
17246 unsigned int v104; // eax@30
17247 char *v105; // ST20_4@32
17248 unsigned int v106; // eax@32
17249 int v107; // eax@33
17250 int v108; // ST20_4@36
17251 unsigned int v109; // eax@36
17252 char *v110; // ST20_4@38
17253 unsigned int v111; // eax@38
17254 int uY; // [sp+10h] [bp-10h]@6
17255 int uYa; // [sp+10h] [bp-10h]@11
17256 int uYb; // [sp+10h] [bp-10h]@13
17257 int uYc; // [sp+10h] [bp-10h]@16
17258 int uYd; // [sp+10h] [bp-10h]@19
17259 int uYe; // [sp+10h] [bp-10h]@22
17260 int uYf; // [sp+10h] [bp-10h]@25
17261 int uYg; // [sp+10h] [bp-10h]@27
17262 int uYh; // [sp+10h] [bp-10h]@33
17263 const char *a2; // [sp+14h] [bp-Ch]@4
17264 const char *a2a; // [sp+14h] [bp-Ch]@6
17265 const char *a2b; // [sp+14h] [bp-Ch]@11
17266 const char *a2c; // [sp+14h] [bp-Ch]@16
17267 const char *a2d; // [sp+14h] [bp-Ch]@19
17268 const char *a2e; // [sp+14h] [bp-Ch]@22
17269 const char *a2f; // [sp+14h] [bp-Ch]@25
17270 const char *a2g; // [sp+14h] [bp-Ch]@27
17271 const char *a2h; // [sp+14h] [bp-Ch]@33
17272 int v131; // [sp+18h] [bp-8h]@16
17273 int v132; // [sp+18h] [bp-8h]@19
17274 int v133; // [sp+18h] [bp-8h]@22
17275 int v134; // [sp+18h] [bp-8h]@25
17276 int v135; // [sp+18h] [bp-8h]@27
17277 int v136; // [sp+18h] [bp-8h]@33
17278 int v137; // [sp+1Ch] [bp-4h]@27
17279 int v138; // [sp+1Ch] [bp-4h]@33
17280
17281 pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * uPlayerID + 40552];
17282 v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
17283 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
17284 v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
17285 sprintfex(pTmpBuf, format_4E2DC8, v3);
17286 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
17287 strcat(pTmpBuf, pTmpBuf2);
17288 if ( pPlayer->uSkillPoints )
17289 v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
17290 else
17291 v4 = 0xFFFFu;
17292 sprintfex(pTmpBuf2, &byte_4E2F14, pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
17293 strcat(pTmpBuf, pTmpBuf2);
17294 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
17295 v5 = pPlayer->GetBaseStrength();
17296 v6 = pPlayer->GetActualMight();
17297 v7 = pPlayer->GetBaseStrength();
17298 v8 = pPlayer->GetActualMight();
17299 v9 = sub_4178FE(v8, v7);
17300 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);
17301 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
17302 v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
17303 v11 = pPlayer->GetBaseIntelligence();
17304 v12 = pPlayer->GetActualIntelligence();
17305 v13 = pPlayer->GetBaseIntelligence();
17306 v14 = pPlayer->GetActualIntelligence();
17307 v15 = sub_4178FE(v14, v13);
17308 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);
17309 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
17310 v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
17311 v17 = pPlayer->GetBaseWillpower();
17312 v18 = pPlayer->GetActualWillpower();
17313 v19 = pPlayer->GetBaseWillpower();
17314 v20 = pPlayer->GetActualWillpower();
17315 v21 = sub_4178FE(v20, v19);
17316 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);
17317 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
17318 v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
17319 v23 = pPlayer->GetBaseEndurance();
17320 v24 = pPlayer->GetActualEndurance();
17321 v25 = pPlayer->GetBaseEndurance();
17322 v26 = pPlayer->GetActualEndurance();
17323 v27 = sub_4178FE(v26, v25);
17324 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);
17325 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
17326 v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
17327 v29 = pPlayer->GetBaseAccuracy();
17328 v30 = pPlayer->GetActualAccuracy();
17329 v31 = pPlayer->GetBaseAccuracy();
17330 v32 = pPlayer->GetActualAccuracy();
17331 v33 = sub_4178FE(v32, v31);
17332 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
17333 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
17334 v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
17335 v35 = pPlayer->GetBaseSpeed();
17336 v36 = pPlayer->GetActualSpeed();
17337 v37 = pPlayer->GetBaseSpeed();
17338 v38 = pPlayer->GetActualSpeed();
17339 v39 = sub_4178FE(v38, v37);
17340 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
17341 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
17342 v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
17343 v41 = pPlayer->GetBaseLuck();
17344 v42 = pPlayer->GetActualLuck();
17345 v43 = pPlayer->GetBaseLuck();
17346 v44 = pPlayer->GetActualLuck();
17347 v45 = sub_4178FE(v44, v43);
17348 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
17349 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
17350 a2 = "%s";
17351 v46 = v40 + 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
17352 if ( pPlayer->GetMaxHealth() >= 1000 )
17353 a2 = (const char *)&unk_4E2EB8;
17354 v47 = pPlayer->GetMaxHealth();
17355 v48 = pPlayer->sHealth;
17356 v49 = pPlayer->GetMaxHealth();
17357 v50 = sub_4178FE(pPlayer->sHealth, v49);
17358 sprintfex(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
17359 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
17360 a2a = "%s";
17361 uY = LOBYTE(pFontArrus->uFontHeight) + v46 - 2;
17362 if ( pPlayer->GetMaxMana() >= 1000 )
17363 a2a = (const char *)&unk_4E2EB8;
17364 v51 = pPlayer->GetMaxMana();
17365 v52 = pPlayer->sMana;
17366 v53 = pPlayer->GetMaxMana();
17367 v54 = sub_4178FE(pPlayer->sMana, v53);
17368 sprintfex(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
17369 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
17370 v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
17371 v56 = pPlayer->GetBaseAC();
17372 v57 = pPlayer->GetActualAC();
17373 v58 = pPlayer->GetBaseAC();
17374 v59 = pPlayer->GetActualAC();
17375 v60 = sub_4178FE(v59, v58);
17376 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
17377 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
17378 v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
17379 v62 = pPlayer->GetMajorConditionrIdx();
17380 v63 = aCharacterConditionNames[v62];
17381 v64 = GetConditionDrawColor(v62);
17382 sprintfex(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[47], v64, v63);
17383 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v61, 0, pTmpBuf, 226, 0);
17384 v65 = LOBYTE(pFontArrus->uFontHeight) + v61 - 1;
17385 v66 = pPlayer->uQuickSpell;
17386 if ( v66 )
17387 v67 = pSpellStats->pInfos[v66].pShortName;
17388 else
17389 v67 = pGlobalTXT_LocalizationStrings[153];
17390 sprintfex(pTmpBuf, "%s: %s", pGlobalTXT_LocalizationStrings[172], v67);
17391 pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v65, 0, pTmpBuf, 226, 0);
17392 v68 = pPlayer->GetBaseAge();
17393 v69 = pPlayer->GetActualAge();
17394 v70 = pPlayer->GetBaseAge();
17395 v71 = pPlayer->GetActualAge();
17396 v72 = sub_4178FE(v71, v70);
17397 sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
17398 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
17399 a2b = "%s";
17400 uYa = LOBYTE(pFontArrus->uFontHeight) + 48;
17401 if ( pPlayer->GetBaseLevel() > 99 )
17402 a2b = format_4E2E68;
17403 v73 = pPlayer->GetBaseLevel();
17404 v74 = pPlayer->GetActualLevel();
17405 v75 = pPlayer->GetBaseLevel();
17406 v76 = pPlayer->GetActualLevel();
17407 v77 = sub_4178FE(v76, v75);
17408 sprintfex(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
17409 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
17410 uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
17411 if ( (signed __int64)pPlayer->uExperience <= 9999999 )
17412 v78 = pGlobalTXT_LocalizationStrings[83];
17413 else
17414 v78 = pGlobalTXT_LocalizationStrings[17];
17415 v79 = LODWORD(pPlayer->uExperience);
17416 v80 = v78;
17417 v81 = pPlayer->GetExperienceDisplayColor();
17418 sprintfex(pTmpBuf, "%s\r180", v80, v81, v79);
17419 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYb, 0, pTmpBuf, 0, 0, 0);
17420 v82 = uYb + 2 * LOBYTE(pFontArrus->uFontHeight);
17421 v83 = pPlayer->GetActualAttack(0);
17422 sprintfex(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83);
17423 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v82, 0, pTmpBuf, 0, 0, 0);
17424 v84 = v82 + LOBYTE(pFontArrus->uFontHeight) - 2;
17425 v85 = pPlayer->GetMeleeDamageString();
17426 sprintfex(pTmpBuf, "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85);
17427 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v84, 0, pTmpBuf, 0, 0, 0);
17428 v86 = v84 + LOBYTE(pFontArrus->uFontHeight) - 2;
17429 v87 = pPlayer->GetRangedAttack();
17430 sprintfex(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87);
17431 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v86, 0, pTmpBuf, 0, 0, 0);
17432 v88 = v86 + LOBYTE(pFontArrus->uFontHeight) - 2;
17433 v89 = pPlayer->GetRangedDamageString();
17434 sprintfex(pTmpBuf, "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89);
17435 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v88, 0, pTmpBuf, 0, 0, 0);
17436 a2c = format_4E2E10;
17437 uYc = v88 + 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
17438 v131 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
17439 v90 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
17440 if ( v131 > 99 || v90 > 99 )
17441 a2c = format_4E2E68;
17442 v91 = v90;
17443 v92 = sub_4178FE(v131, v90);
17444 sprintfex(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
17445 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
17446 a2d = format_4E2E10;
17447 uYd = uYc + LOBYTE(pFontArrus->uFontHeight) - 2;
17448 v132 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
17449 v93 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
17450 if ( v132 > 99 || v93 > 99 )
17451 a2d = format_4E2E68;
17452 v94 = v93;
17453 v95 = sub_4178FE(v132, v93);
17454 sprintfex(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
17455 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
17456 a2e = format_4E2E10;
17457 uYe = uYd + LOBYTE(pFontArrus->uFontHeight) - 2;
17458 v133 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
17459 v96 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
17460 if ( v133 > 99 || v96 > 99 )
17461 a2e = format_4E2E68;
17462 v97 = v96;
17463 v98 = sub_4178FE(v133, v96);
17464 sprintfex(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
17465 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
17466 a2f = format_4E2E10;
17467 uYf = uYe + LOBYTE(pFontArrus->uFontHeight) - 2;
17468 v134 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
17469 v99 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
17470 if ( v134 > 99 )
17471 a2f = format_4E2E68;
17472 v100 = v99;
17473 v101 = sub_4178FE(v134, v99);
17474 sprintfex(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
17475 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
17476 a2g = format_4E2E10;
17477 uYg = uYf + LOBYTE(pFontArrus->uFontHeight) - 2;
17478 v135 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
17479 v102 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
17480 v137 = v102;
17481 if ( v135 > 99 || v102 > 99 )
17482 a2g = format_4E2E68;
17483 v103 = v102;
17484 v104 = sub_4178FE(v135, v102);
17485 sprintfex(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
17486 if ( pPlayer->uClass == 35 && v137 == 200 )
17487 {
17488 v105 = pGlobalTXT_LocalizationStrings[625];
17489 v106 = sub_4178FE(v135, 200);
17490 sprintfex(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
17491 }
17492 pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
17493 a2h = format_4E2E10;
17494 uYh = uYg + LOBYTE(pFontArrus->uFontHeight) - 2;
17495 v136 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
17496 v107 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
17497 v138 = v107;
17498 if ( v136 > 99 || v107 > 99 )
17499 a2h = format_4E2E68;
17500 v108 = v107;
17501 v109 = sub_4178FE(v136, v107);
17502 sprintfex(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
17503 if ( pPlayer->uClass == 35 && v138 == 200 )
17504 {
17505 v110 = pGlobalTXT_LocalizationStrings[625];
17506 v111 = sub_4178FE(v136, 200);
17507 sprintfex(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
17508 }
17509 return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
17510 }
17511
17512 //----- (00419100) --------------------------------------------------------
17513 int __cdecl sub_419100()
17514 {
17515 Player *v0; // esi@1
17516 int v1; // ebx@1
17517 unsigned __int8 *v2; // esi@1
17518 int v3; // eax@4
17519 int result; // eax@6
17520 int v5; // esi@6
17521 unsigned __int8 v6; // zf@6
17522 unsigned __int8 v7; // sf@6
17523 int v8; // edx@7
17524 int v9; // ecx@7
17525 unsigned __int8 v10; // of@7
17526 stru179 *v11; // edi@9
17527 int v12; // edx@11
17528 int v13; // [sp+Ch] [bp-8h]@2
17529 signed int v14; // [sp+Ch] [bp-8h]@9
17530 int i; // [sp+10h] [bp-4h]@10
17531
17532 v0 = pPlayers[uActiveCharacter];
17533 memset(&pStru179, 0, 0xFA0u);
17534 memset(pTmpBuf2, 0, 0x7D0u);
17535 v1 = 0;
17536 dword_506544 = 0;
17537 dword_506548 = 0;
17538 dword_506520 = 0;
17539 dword_50651C = 0;
17540 dword_506528 = 0;
17541 v2 = (unsigned __int8 *)v0->field_152;
17542 do
17543 {
17544 v13 = dword_723E80_award_related[2 * v1];
17545 if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 )
17546 {
17547 v3 = dword_506520++;
17548 pStru179->field_0[v3] = v1;
17549 }
17550 ++v1;
17551 }
17552 while ( v1 < 105 );
17553 result = dword_506520;
17554 v5 = 0;
17555 v6 = dword_506520 == 0;
17556 v7 = dword_506520 < 0;
17557 dword_506524 = dword_506520;
17558 dword_506520 = 0;
17559 if ( !(v7 | v6) )
17560 {
17561 do
17562 {
17563 v8 = rand() % 16;
17564 result = dword_506524;
17565 v9 = dword_506524 + v5++;
17566 v10 = __OFSUB__(v5, dword_506524);
17567 v7 = v5 - dword_506524 < 0;
17568 pStru179->field_0[v9] = v8;
17569 }
17570 while ( v7 ^ v10 );
17571 if ( result > 0 )
17572 {
17573 v14 = 1;
17574 v11 = pStru179;
17575 do
17576 {
17577 for ( i = v14; i < result; ++i )
17578 {
17579 v12 = pStru179->field_0[i];
17580 if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] )
17581 {
17582 pStru179->field_0[i] = v11->field_0[0];
17583 v11->field_0[0] = v12;
17584 }
17585 }
17586 ++v14;
17587 v11 = (stru179 *)((char *)v11 + 4);
17588 }
17589 while ( v14 - 1 < result );
17590 }
17591 }
17592 return result;
17593 }
17594
17595
17596 //----- (00419220) --------------------------------------------------------
17597 void __cdecl sub_419220()
17598 {
17599 GUIButton *i; // eax@2
17600
17601 if ( !dword_507CBC )
17602 {
17603 dword_507CBC = 1;
17604 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17605 {
17606 if ( i->uControlID == 120 )
17607 {
17608 dword_50698C = i->uX;
17609 dword_506988 = i->uY;
17610 dword_506984 = i->uZ;
17611 dword_506980 = i->uW;
17612 i->uW = 0;
17613 i->uZ = 0;
17614 i->uY = 0;
17615 i->uX = 0;
17616 }
17617 }
17618 ptr_507B9C = pGUIWindow_CurrentMenu->CreateButton(
17619 0x1B6u,
17620 0x2Eu,
17621 (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureWidth : 24),
17622 (uTextureID_ar_up_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_up_up].uTextureHeight : 26),
17623 1,
17624 0,
17625 0xA9u,
17626 0,
17627 0,
17628 nullstring,
17629 (Texture *)(uTextureID_ar_up_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_up] : 0),
17630 uTextureID_ar_up_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_dn] : 0,
17631 0);
17632 ptr_507BA0 = pGUIWindow_CurrentMenu->CreateButton(
17633 0x1B6u,
17634 0x124u,
17635 (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureWidth : 24),
17636 (uTextureID_ar_dn_up != -1 ? pIcons_LOD->pTextures[uTextureID_ar_dn_up].uTextureHeight : 26),
17637 1,
17638 0,
17639 0xAAu,
17640 0,
17641 0,
17642 nullstring,
17643 (Texture *)(uTextureID_ar_dn_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_up] : 0),
17644 uTextureID_ar_dn_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_dn] : 0,
17645 0);
17646 ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(
17647 0x1B8u,
17648 0x3Eu,
17649 0x10u,
17650 0xE8u,
17651 1,
17652 0,
17653 0xC0u,
17654 0,
17655 0,
17656 nullstring,
17657 0);
17658 }
17659 }
17660
17661
17662
17663 //----- (00419379) --------------------------------------------------------
17664 void __cdecl sub_419379()
17665 {
17666 GUIButton *i; // esi@2
17667
17668 if ( dword_507CBC )
17669 {
17670 dword_507CBC = 0;
17671 GUIButton::_41D0D8(ptr_507BA4);
17672 GUIButton::_41D0D8(ptr_507B9C);
17673 GUIButton::_41D0D8(ptr_507BA0);
17674 ptr_507BA0 = 0;
17675 ptr_507B9C = 0;
17676 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17677 {
17678 if ( i->uControlID == 120 )
17679 {
17680 i->uX = dword_50698C;
17681 i->uY = dword_506988;
17682 i->uZ = dword_506984;
17683 i->uW = dword_506980;
17684 pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
17685 }
17686 }
17687 }
17688 }
17689
17690
17691 //----- (00419401) --------------------------------------------------------
17692 void __cdecl sub_419401()
17693 {
17694 unsigned int v0; // ecx@3
17695 GUIButton *i; // eax@3
17696 GUIFont *v2; // eax@8
17697 unsigned int v3; // esi@8
17698 int v4; // eax@10
17699 unsigned int v5; // esi@14
17700 int v6; // eax@17
17701 unsigned int v7; // esi@19
17702 int v8; // eax@21
17703 unsigned int v9; // esi@25
17704 int v10; // eax@27
17705 int a2; // [sp+10h] [bp-14h]@1
17706 int v12; // [sp+14h] [bp-10h]@8
17707 int v13; // [sp+14h] [bp-10h]@19
17708 unsigned int *v14; // [sp+18h] [bp-Ch]@8
17709 unsigned int *v15; // [sp+18h] [bp-Ch]@14
17710 unsigned int *v16; // [sp+18h] [bp-Ch]@19
17711 unsigned int *v17; // [sp+18h] [bp-Ch]@25
17712 char *v18; // [sp+1Ch] [bp-8h]@8
17713 int a5; // [sp+20h] [bp-4h]@8
17714
17715 a2 = 0;
17716 if ( dword_507CC0 )
17717 sub_4196A0();
17718 v0 = uActiveCharacter;
17719 dword_507CC0 = uActiveCharacter;
17720 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
17721 {
17722 if ( i->uControlID == 120 )
17723 {
17724 dword_50698C = i->uX;
17725 dword_506988 = i->uY;
17726 dword_506984 = i->uZ;
17727 dword_506980 = i->uW;
17728 i->uW = 0;
17729 i->uZ = 0;
17730 i->uY = 0;
17731 i->uX = 0;
17732 v0 = uActiveCharacter;
17733 }
17734 }
17735 v12 = 0;
17736 a5 = pGUIWindow_CurrentMenu->uNumControls;
17737 v18 = &stru_AA1058[3].pSounds[6972 * v0 + 40552];
17738 v2 = pFontLucida;
17739 v14 = (unsigned int *)dword_4E2A2C;
17740 v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
17741 do
17742 {
17743 if ( v18[2 * *v14 + 264] & 0x3F )
17744 {
17745 v4 = LOBYTE(v2->uFontHeight);
17746 v3 = v3 + v4 - 3;
17747 ++a2;
17748 ++v12;
17749 pGUIWindow_CurrentMenu->CreateButton(
17750 0x18u,
17751 v3,
17752 0xCCu,
17753 v4 - 3,
17754 3,
17755 *v14 | 0x8000,
17756 0x79u,
17757 *v14,
17758 0,
17759 nullstring,
17760 0);
17761 v2 = pFontLucida;
17762 }
17763 ++v14;
17764 }
17765 while ( (signed int)v14 < (signed int)dword_4E2A50 );
17766 if ( !v12 )
17767 v3 = v3 + LOBYTE(v2->uFontHeight) - 3;
17768 v15 = (unsigned int *)_4E2A80_skills;
17769 v5 = v3 + 2 * LOBYTE(v2->uFontHeight) - 6;
17770 do
17771 {
17772 if ( v18[2 * *v15 + 264] & 0x3F && a2 < 15 )
17773 {
17774 v6 = LOBYTE(v2->uFontHeight);
17775 v5 = v5 + v6 - 3;
17776 ++a2;
17777 pGUIWindow_CurrentMenu->CreateButton(
17778 0x18u,
17779 v5,
17780 0xCCu,
17781 v6 - 3,
17782 3,
17783 *v15 | 0x8000,
17784 0x79u,
17785 *v15,
17786 0,
17787 nullstring,
17788 0);
17789 v2 = pFontLucida;
17790 }
17791 ++v15;
17792 }
17793 while ( (signed int)v15 < (signed int)pAwardsTextColors );
17794 v13 = 0;
17795 v16 = (unsigned int *)dword_4E2A18;
17796 v7 = 2 * LOBYTE(v2->uFontHeight) + 13;
17797 do
17798 {
17799 if ( v18[2 * *v16 + 264] & 0x3F )
17800 {
17801 v8 = LOBYTE(v2->uFontHeight);
17802 v7 = v7 + v8 - 3;
17803 ++a2;
17804 ++v13;
17805 pGUIWindow_CurrentMenu->CreateButton(
17806 0xF6u,
17807 v7,
17808 0xCCu,
17809 v8 - 3,
17810 3,
17811 *v16 | 0x8000,
17812 0x79u,
17813 *v16,
17814 0,
17815 nullstring,
17816 0);
17817 v2 = pFontLucida;
17818 }
17819 ++v16;
17820 }
17821 while ( (signed int)v16 < (signed int)dword_4E2A2C );
17822 if ( !v13 )
17823 v7 = v7 + LOBYTE(v2->uFontHeight) - 3;
17824 v17 = (unsigned int *)dword_4E2A50;
17825 v9 = v7 + 2 * LOBYTE(v2->uFontHeight) - 6;
17826 do
17827 {
17828 if ( v18[2 * *v17 + 264] & 0x3F )
17829 {
17830 v10 = LOBYTE(v2->uFontHeight);
17831 v9 = v9 + v10 - 3;
17832 ++a2;
17833 pGUIWindow_CurrentMenu->CreateButton(
17834 0xF6u,
17835 v9,
17836 0xCCu,
17837 v10 - 3,
17838 3,
17839 *v17 | 0x8000,
17840 0x79u,
17841 *v17,
17842 0,
17843 nullstring,
17844 0);
17845 v2 = pFontLucida;
17846 }
17847 ++v17;
17848 }
17849 while ( (signed int)v17 < (signed int)_4E2A80_skills );
17850 if ( a2 )
17851 pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
17852 }