comparison mm7_2.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 89240115d392
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include <io.h>
2 #include <direct.h>
3 #include <assert.h>
4
5 #include "MapInfo.h"
6 #include "Game.h"
7 #include "GUIWindow.h"
8 #include "GUIButton.h"
9 #include "GUIFont.h"
10 #include "Party.h"
11 #include "AudioPlayer.h"
12 #include "Outdoor.h"
13 #include "IndoorCamera.h"
14 #include "Overlays.h"
15 #include "Monsters.h"
16 #include "Arcomage.h"
17 #include "LOD.h"
18 #include "Actor.h"
19 #include "Allocator.h"
20 #include "Events.h"
21 #include "Viewport.h"
22 #include "FrameTableInc.h"
23 #include "Math.h"
24 #include "LayingItem.h"
25 #include "ObjectList.h"
26 #include "Chest.h"
27 #include "PaletteManager.h"
28 #include "DecorationList.h"
29 #include "SaveLoad.h"
30 #include "stru123.h"
31 #include "stru287.h"
32 #include "Time.h"
33 #include "IconFrameTable.h"
34 #include "GUIProgressBar.h"
35 #include "stru157.h"
36 #include "Bink_Smacker.h"
37 #include "TileFrameTable.h"
38 #include "PlayerFrameTable.h"
39 #include "Awards.h"
40 #include "Autonotes.h"
41 #include "stru160.h"
42 #include "stru279.h"
43 #include "TurnEngine.h"
44 #include "FactionTable.h"
45 #include "StorylineTextTable.h"
46 #include "Random.h"
47 #include "stru277.h"
48 #include "stru298.h"
49 #include "stru12.h"
50 #include "stru351.h"
51 #include "Events2D.h"
52 #include "stru159.h"
53 #include "Log.h"
54
55 #include "mm7_data.h"
56
57
58 //----- (004B4F4F) --------------------------------------------------------
59 char *__cdecl sub_4B4F4F()
60 {
61 const char *v0; // esi@1
62 const char *v1; // ST10_4@1
63 unsigned __int16 v2; // ST0C_2@1
64 int v3; // eax@1
65 GUIWindow v5; // [sp+8h] [bp-54h]@1
66
67 memcpy(&v5, ptr_507BC0, sizeof(v5));
68 v0 = pGlobalTXT_LocalizationStrings[672];
69 v1 = pGlobalTXT_LocalizationStrings[672];
70 v5.uFrameX = 483;
71 v5.uFrameWidth = 148;
72 v5.uFrameZ = 334;
73 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
74 v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
75 return v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
76 }
77
78
79
80 //----- (004B68EA) --------------------------------------------------------
81 bool __fastcall sub_4B68EA(int a1)
82 {
83 signed int v1; // edi@1
84 int *v2; // esi@1
85 int v3; // ecx@2
86
87 v1 = 0;
88 v2 = &dword_4F0E10[a1];
89 while ( 1 )
90 {
91 v3 = 8 * *((char *)v2 + v1);
92 if ( *(&byte_4F09B1[pParty->uDaysPlayed % 7] + v3 * 4) )
93 {
94 if ( !dword_4F09CC[v3] || (unsigned __int16)_449B57_test_bit(pParty->_award_bits, LOWORD(dword_4F09CC[v3])) )
95 break;
96 }
97 ++v1;
98 if ( v1 >= 4 )
99 return 0;
100 }
101 return 1;
102 }
103
104
105
106 //----- (004B7911) --------------------------------------------------------
107 void __cdecl sub_4B7911()
108 {
109 GUIWindow *v0; // eax@4
110 int v1; // eax@10
111 int v2; // esi@10
112 GUIFont *v3; // ST20_4@20
113 int v4; // eax@20
114 MonsterInfo *v5; // edi@21
115 unsigned int v6; // ST20_4@21
116 char *v7; // ST1C_4@21
117 unsigned int v8; // eax@21
118 int v9; // esi@21
119 char *v10; // eax@23
120 signed int v11; // ebx@24
121 signed int i; // esi@26
122 int v13; // eax@27
123 GUIWindow *v14; // ecx@28
124 __int64 v15; // qax@28
125 signed int v16; // ebx@28
126 int v17; // ebx@28
127 unsigned __int8 v18; // sf@28
128 char **v19; // edi@29
129 GUIButton *v20; // eax@30
130 GUIButton *v21; // esi@30
131 int v22; // eax@30
132 unsigned int v23; // ecx@30
133 unsigned __int16 v24; // ax@30
134 GUIWindow a1; // [sp+Ch] [bp-110h]@21
135 GUIWindow w; // [sp+60h] [bp-BCh]@21
136 GUIWindow _this; // [sp+B4h] [bp-68h]@1
137 int v28; // [sp+108h] [bp-14h]@1
138 int v29; // [sp+10Ch] [bp-10h]@28
139 int v30; // [sp+110h] [bp-Ch]@1
140 int v31; // [sp+114h] [bp-8h]@29
141 GUIFont *pOutString; // [sp+118h] [bp-4h]@21
142
143 memcpy(&_this, ptr_507BC0, sizeof(_this));
144 _this.uFrameX = 483;
145 _this.uFrameWidth = 148;
146 _this.uFrameZ = 334;
147 v28 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
148 v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
149 sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
150 _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
151 if ( dword_F8B19C == 1 )
152 {
153 v11 = 1;
154 pOutString = 0;
155 pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
156 if ( pParty->uFine )
157 {
158 pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
159 v11 = 2;
160 }
161 for ( i = 0; i < v11; ++i )
162 {
163 v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
164 pOutString = (GUIFont *)((char *)pOutString + v13);
165 }
166 v29 = (100 - (signed int)pOutString) / v11;
167 v14 = pDialogueWindow;
168 v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
169 v16 = v15 - HIDWORD(v15);
170 LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
171 HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
172 v17 = (v16 >> 1) - v29 / 2 + 158;
173 v18 = -pDialogueWindow->pNumPresenceButton < 0;
174 pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
175 if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
176 {
177 v31 = 2;
178 v19 = pShopOptions;
179 do
180 {
181 v20 = v14->GetControl((unsigned int)pOutString);
182 v21 = v20;
183 v20->uY = v29 + v17;
184 v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
185 v23 = v21->uY;
186 v21->uHeight = v22;
187 v17 = v23 + v22 - 1;
188 v21->uW = v17;
189 v24 = v30;
190 if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
191 v24 = v28;
192 _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
193 v14 = pDialogueWindow;
194 ++v31;
195 ++v19;
196 pOutString = (GUIFont *)((char *)pOutString + 1);
197 }
198 while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
199 }
200 }
201 else
202 {
203 if ( dword_F8B19C != 99 )
204 {
205 if ( dword_F8B19C != 100 )
206 return;
207 v0 = ptr_507BC0;
208 if ( ptr_507BC0->field_40 == 1 )
209 {
210 sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
211 _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
212 _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
213 v3 = pFontArrus;
214 v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
215 _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
216 return;
217 }
218 if ( ptr_507BC0->field_40 == 2 )
219 {
220 v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
221 v2 = v1;
222 if ( v1 <= 0 )
223 {
224 LABEL_8:
225 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
226 {
227 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
228 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
229 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
230 ++pMessageQueue_50CBD0->uNumMessages;
231 }
232 return;
233 }
234 if ( v1 > pParty->uNumGold )
235 {
236 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
237 v2 = pParty->uNumGold;
238 }
239 if ( v2 > pParty->uFine )
240 v2 = pParty->uFine;
241 Party::TakeGold(v2);
242 pParty->uFine -= v2;
243 if ( pParty->uFine < 0 )
244 pParty->uFine = 0;
245 if ( uActiveCharacter )
246 pPlayers[uActiveCharacter]->PlaySound(81, 0);
247 v0 = ptr_507BC0;
248 }
249 else
250 {
251 if ( ptr_507BC0->field_40 != 3 )
252 return;
253 }
254 v0->field_40 = 0;
255 goto LABEL_8;
256 }
257 v5 = &pMonsterStats->pInfos[word_F8B1A0];
258 v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
259 v7 = v5->pName;
260 v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
261 sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
262 sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
263 ptr_F8B1E8 = pTmpBuf2;
264 memcpy(&a1, pDialogueWindow, sizeof(a1));
265 w.uFrameWidth = 458;
266 w.uFrameZ = 457;
267 pOutString = pFontArrus;
268 v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7;
269 if ( 352 - v9 < 8 )
270 {
271 pOutString = pFontCreate;
272 v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
273 }
274
275 auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
276 pRenderer->_4A6A68(
277 8u,
278 352 - v9,
279 pTex,
280 (pTex ? pTex->uTextureHeight : 26) - v9);
281 pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
282 v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
283 a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
284 }
285 }
286 // F8B19C: using guessed type int dword_F8B19C;
287 // F8B1A0: using guessed type __int16 word_F8B1A0;
288
289 //----- (004B7D7E) --------------------------------------------------------
290 void __cdecl _4B7D7E_bank()
291 {
292 GUIWindow *v0; // eax@4
293 int v1; // ecx@5
294 int v2; // eax@6
295 unsigned int v3; // esi@6
296 GUIFont *v4; // ST10_4@12
297 int v5; // eax@12
298 int v6; // eax@19
299 unsigned int v7; // esi@19
300 unsigned __int16 v8; // ax@27
301 unsigned __int16 v9; // ax@29
302 char *v10; // [sp-8h] [bp-70h]@11
303 char *v11; // [sp-4h] [bp-6Ch]@11
304 GUIWindow _this; // [sp+Ch] [bp-5Ch]@1
305 __int16 v13[2]; // [sp+60h] [bp-8h]@1
306 __int16 v14[2]; // [sp+64h] [bp-4h]@1
307
308 memcpy(&_this, ptr_507BC0, sizeof(_this));
309 _this.uFrameX = 483;
310 _this.uFrameWidth = 148;
311 _this.uFrameZ = 334;
312 *(int *)v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
313 *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
314 sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
315 _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
316 if ( dword_F8B19C != 1 )
317 {
318 if ( dword_F8B19C == 7 )
319 {
320 v0 = ptr_507BC0;
321 if ( ptr_507BC0->field_40 != 1 )
322 {
323 v1 = ptr_507BC0->field_40 - 2;
324 if ( ptr_507BC0->field_40 == 2 )
325 {
326 v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
327 v7 = v6;
328 if ( !v6 )
329 {
330 LABEL_17:
331 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
332 {
333 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
334 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
335 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
336 ++pMessageQueue_50CBD0->uNumMessages;
337 }
338 return;
339 }
340 if ( v6 > pParty->uNumGold )
341 {
342 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
343 v7 = pParty->uNumGold;
344 }
345 if ( v7 )
346 {
347 Party::TakeGold(v7);
348 pParty->uNumGoldInBank += v7;
349 if ( uActiveCharacter )
350 pPlayers[uActiveCharacter]->PlaySound(81, 0);
351 }
352 v0 = ptr_507BC0;
353 LABEL_16:
354 v0->field_40 = 0;
355 goto LABEL_17;
356 }
357 LABEL_15:
358 if ( v1 != 1 )
359 return;
360 goto LABEL_16;
361 }
362 v11 = pGlobalTXT_LocalizationStrings[112];
363 v10 = pGlobalTXT_LocalizationStrings[60];
364 }
365 else
366 {
367 if ( dword_F8B19C != 8 )
368 return;
369 v0 = ptr_507BC0;
370 if ( ptr_507BC0->field_40 != 1 )
371 {
372 v1 = ptr_507BC0->field_40 - 2;
373 if ( ptr_507BC0->field_40 == 2 )
374 {
375 ptr_507BC0->field_40 = 0;
376 v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
377 v3 = v2;
378 if ( v2 )
379 {
380 if ( v2 > pParty->uNumGoldInBank )
381 {
382 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
383 v3 = pParty->uNumGoldInBank;
384 }
385 if ( v3 )
386 {
387 Party::SetGold(pParty->uNumGold + v3);
388 pParty->uNumGoldInBank -= v3;
389 }
390 }
391 goto LABEL_17;
392 }
393 goto LABEL_15;
394 }
395 v11 = pGlobalTXT_LocalizationStrings[112];
396 v10 = pGlobalTXT_LocalizationStrings[244];
397 }
398 sprintf(pTmpBuf, "%s\n%s", v10, v11);
399 _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
400 _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
401 v4 = pFontArrus;
402 v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
403 _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
404 return;
405 }
406 v8 = v14[0];
407 if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
408 v8 = v13[0];
409 _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
410 v9 = v14[0];
411 if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
412 v9 = v13[0];
413 _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
414 }
415 // F8B19C: using guessed type int dword_F8B19C;
416
417 //----- (004B8285) --------------------------------------------------------
418 void __cdecl sub_4B8285_prolly_draw_arcomage_result()
419 {
420 GUIWindow *v0; // ebx@1
421 Player *v1; // edi@1
422 double v2; // st7@1
423 signed int v3; // ebx@1
424 int v4; // ecx@1
425 int v5; // esi@3
426 signed int v6; // edi@5
427 int v7; // ecx@5
428 GUIWindow *v8; // edi@16
429 signed int v9; // esi@16
430 unsigned int v10; // esi@18
431 int v11; // eax@18
432 unsigned int v12; // eax@19
433 int v13; // eax@21
434 int v14; // ecx@26
435 GUIButton *v15; // eax@28
436 GUIButton *v16; // esi@28
437 int v17; // eax@28
438 char *v18; // eax@30
439 int v19; // eax@30
440 unsigned int v20; // ecx@30
441 int v21; // edx@30
442 int v22; // eax@30
443 unsigned __int16 v23; // ax@30
444 int v24; // eax@34
445 int v25; // eax@34
446 char *v26; // esi@36
447 int v27; // edi@46
448 unsigned int v28; // eax@53
449 unsigned int v29; // eax@55
450 unsigned int v30; // eax@57
451 signed int v31; // eax@59
452 unsigned int v32; // eax@61
453 GUIWindow *v33; // edi@64
454 int v34; // eax@64
455 int v35; // ecx@64
456 int v36; // esi@64
457 char v37; // sf@64
458 GUIButton *v38; // eax@65
459 int v39; // edx@69
460 int v40; // ecx@69
461 int v41; // ecx@69
462 int v42; // ecx@70
463 unsigned int v43; // edx@70
464 int v44; // edx@71
465 int v45; // ecx@71
466 int v46; // ecx@72
467 int v47; // eax@74
468 signed int v48; // edi@77
469 signed int i; // esi@79
470 int v50; // eax@80
471 GUIWindow *v51; // ecx@81
472 _QWORD v52; // qax@81
473 signed int v53; // edi@81
474 int v54; // edi@81
475 GUIButton *v55; // esi@83
476 const char **v56; // eax@83
477 int v57; // eax@83
478 unsigned int v58; // ecx@83
479 Player *v59; // edx@83
480 unsigned __int16 v60; // ax@83
481 int v61; // eax@99
482 int v62; // edi@99
483 char *v63; // eax@99
484 GUIFont *v64; // edx@99
485 GUIFont *v65; // edi@100
486 unsigned int v66; // [sp-10h] [bp-284h]@75
487 unsigned __int16 v67; // [sp-Ch] [bp-280h]@75
488 int v68; // [sp-Ch] [bp-280h]@99
489 char *v69; // [sp-8h] [bp-27Ch]@75
490 int v70; // [sp-8h] [bp-27Ch]@99
491 unsigned int v71; // [sp-4h] [bp-278h]@75
492 const char *v72; // [sp-4h] [bp-278h]@93
493 unsigned int v73; // [sp-4h] [bp-278h]@99
494 char Dest; // [sp+Ch] [bp-268h]@55
495 char v75; // [sp+70h] [bp-204h]@59
496 char a1; // [sp+D4h] [bp-1A0h]@57
497 char v77; // [sp+138h] [bp-13Ch]@59
498 GUIWindow v78; // [sp+19Ch] [bp-D8h]@99
499 GUIWindow v79; // [sp+1F0h] [bp-84h]@1
500 char *Str[2]; // [sp+244h] [bp-30h]@30
501 unsigned int v81; // [sp+24Ch] [bp-28h]@1
502 unsigned __int8 v82; // [sp+253h] [bp-21h]@59
503 int v83; // [sp+254h] [bp-20h]@1
504 __int16 v84[2]; // [sp+258h] [bp-1Ch]@1
505 Player *v85; // [sp+25Ch] [bp-18h]@1
506 int v86; // [sp+260h] [bp-14h]@18
507 unsigned __int8 v87; // [sp+266h] [bp-Eh]@59
508 unsigned __int8 v88; // [sp+267h] [bp-Dh]@57
509 int v89; // [sp+268h] [bp-Ch]@1
510 unsigned __int8 v90; // [sp+26Fh] [bp-5h]@55
511 GUIFont *pOutString; // [sp+270h] [bp-4h]@3
512
513 v0 = ptr_507BC0;
514 memcpy(&v79, ptr_507BC0, sizeof(v79));
515 v85 = pPlayers[uActiveCharacter];
516 v1 = v85;
517 v79.uFrameX = 483;
518 v79.uFrameWidth = 148;
519 v79.uFrameZ = 334;
520 v81 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
521 *(int *)v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
522 //v2 = p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C];
523 v2 = p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier;
524 *(float *)&v83 = v2;
525 *(float *)&v89 = v2 * v2;
526 v3 = (signed __int64)(*(float *)&v89 * 0.1);
527 v4 = v3 * (100 - v1->GetMerchant()) / 100;
528 if ( v4 < v3 / 3 )
529 v4 = v3 / 3;
530 v5 = 1;
531 pOutString = (GUIFont *)v4;
532 if ( v4 <= 0 )
533 pOutString = (GUIFont *)1;
534 v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998);
535 v7 = v6 * (100 - v85->GetMerchant()) / 100;
536 if ( v7 < v6 / 3 )
537 v7 = v6 / 3;
538 v83 = v7;
539 if ( v7 <= 0 )
540 {
541 v7 = 1;
542 v83 = 1;
543 }
544 if ( dword_F8B19C > 101 )
545 {
546 if ( dword_F8B19C == 102 )
547 {
548 v65 = pFontArrus;
549 pOutString = pFontArrus;
550 strcpy(pTmpBuf, pNPCTopics[354].pText);
551 v78.uFrameWidth = 460;
552 v78.uFrameZ = 452;
553 v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
554 if ( 352 - v62 < 8 )
555 {
556 pOutString = pFontCreate;
557 v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
558 }
559
560 auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
561 pRenderer->_4A6A68(
562 8u,
563 352 - v62,
564 pTex,
565 (pTex ? pTex->uTextureHeight : 26) - v62);
566
567 pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
568 v73 = 0;
569 v70 = 0;
570 v68 = 0;
571 v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
572 v64 = pOutString;
573 }
574 else
575 {
576 if ( dword_F8B19C != 103 )
577 {
578 if ( dword_F8B19C != 104 || pArcomageGame->bGameInProgress == 1 )
579 return;
580 v26 = pTmpBuf;
581 if ( pArcomageGame->uGameResult )
582 {
583 if ( pArcomageGame->uGameResult == 1 )
584 v72 = pGlobalTXT_LocalizationStrings[640];// You won!
585 else
586 v72 = pGlobalTXT_LocalizationStrings[641];// You lost!
587 }
588 else
589 {
590 v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
591 }
592 strcpy(pTmpBuf, v72);
593 LABEL_97:
594 v71 = 3;
595 v69 = v26;
596 v67 = v84[0];
597 v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
598 goto LABEL_98;
599 }
600 strcpy(pTmpBuf, pNPCTopics[(uint)ptr_507BC0->ptr_1C + 247].pText);
601 v78.uFrameWidth = 460;
602 v78.uFrameZ = 452;
603 v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
604 v62 = v61 + 7;
605
606 auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
607 pRenderer->_4A6A68(
608 8u,
609 352 - (v61 + 7),
610 pTex,
611 (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
612
613 pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
614 v73 = 0;
615 v70 = 0;
616 v68 = 0;
617 v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
618 v64 = pFontArrus;
619 }
620 ptr_507BC0->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
621 return;
622 }
623 if ( dword_F8B19C != 101 )
624 {
625 if ( dword_F8B19C != 1 )
626 {
627 if ( dword_F8B19C == 15 )
628 {
629 if ( pParty->uNumGold >= (unsigned int)pOutString )
630 {
631 Party::TakeGold((unsigned int)pOutString);
632 v27 = (int)ptr_507BC0->ptr_1C;
633 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
634 dword_F8B19C = 0;
635 while ( sub_4BD8B5() )
636 ;
637 sub_4B1D27();
638 pVideoPlayer->Unload();
639 ptr_507BC0->Release();
640 ptr_507BC0 = 0;
641 if ( pMessageQueue_50CBD0->uNumMessages )
642 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
643 pMessageQueue_50CBD0->pMessages[0].eType = (UIMessageType)409;
644 pMessageQueue_50CBD0->pMessages[0].param = v27;
645 pMessageQueue_50CBD0->pMessages[0].field_8 = 1;
646 LABEL_51:
647 ++pMessageQueue_50CBD0->uNumMessages;
648 return;
649 }
650 }
651 else
652 {
653 if ( dword_F8B19C != 16 )
654 {
655 if ( dword_F8B19C != 96 || !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
656 return;
657 v8 = pDialogueWindow;
658 *(float *)&v89 = 0.0;
659
660 //v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
661 v9 = (signed __int64)(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].flt_24 * 500.0);
662
663 pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
664 if ( (signed int)pOutString < v9 / 3 )
665 pOutString = (GUIFont *)(v9 / 3);
666 v10 = v8->pStartingPosActiveItem;
667 v11 = v10 + v8->pNumPresenceButton;
668 v86 = 0;
669 if ( (signed int)v10 < v11 )
670 {
671 do
672 {
673 v12 = v8->GetControl(v10)->uControlParam - 36;
674 if ( byte_4ED970_skill_learn_ability_by_class_table[v85->uClass][v12] && !v85->pActiveSkills[v12] )
675 {
676 v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
677 v89 += v13;
678 ++v86;
679 }
680 ++v10;
681 }
682 while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
683 if ( v86 )
684 {
685 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
686 v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
687 pOutString = (GUIFont *)((149 - v89) / v86);
688 if ( (149 - v89) / v86 > 32 )
689 pOutString = (GUIFont *)32;
690 v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
691 v89 = v8->pStartingPosActiveItem;
692 v83 = v14;
693 if ( v89 < v89 + v8->pNumPresenceButton )
694 {
695 v86 = 2;
696 do
697 {
698 v15 = v8->GetControl(v89);
699 v16 = v15;
700 v17 = v15->uControlParam - 36;
701 if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->uClass][v17] || v85->pActiveSkills[v17] )
702 {
703 v16->uW = 0;
704 v16->uHeight = 0;
705 v16->uY = 0;
706 }
707 else
708 {
709 v18 = pSkillNames[v17];
710 v16->uY = (unsigned int)((char *)pOutString + v83);
711 Str[1] = v18;
712 v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
713 v20 = v16->uY;
714 v21 = v86;
715 v16->uHeight = v19;
716 v22 = v19 + v20 - 1;
717 v16->uW = v22;
718 v83 = v22;
719 v23 = v84[0];
720 if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
721 v23 = v81;
722 v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
723 }
724 v24 = v8->pNumPresenceButton;
725 ++v89;
726 v25 = v8->pStartingPosActiveItem + v24;
727 ++v86;
728 }
729 while ( v89 < v25 );
730 }
731 return;
732 }
733 }
734 v26 = pTmpBuf;
735 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->uClass]);
736 strcat(pTmpBuf, "\n \n");
737 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
738 goto LABEL_97;
739 }
740 *(_QWORD *)Str = pParty->uNumFoodRations;
741 //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
742 if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier )
743 {
744 ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u);
745 if ( uActiveCharacter )
746 pPlayers[uActiveCharacter]->PlaySound(67, 0);
747 goto LABEL_43;
748 }
749 if ( pParty->uNumGold >= v7 )
750 {
751 Party::TakeGold(v7);
752 //pParty->uNumFoodRations = (signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
753 pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
754 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 3);
755 v5 = 1;
756 LABEL_43:
757 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
758 return;
759 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
760 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v5;
761 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
762 goto LABEL_51;
763 }
764 }
765 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
766 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 4);
767 goto LABEL_43;
768 }
769 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
770 return;
771 v28 = *(int *)v84;
772 if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
773 v28 = v81;
774 sprintf(&Dest, format_4E2DC8, v28);
775 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
776 strcat(&Dest, pTmpBuf2);
777 v90 = pFontArrus->CalcTextHeight(&Dest, &v79, 0, 0);
778 strcat(&Dest, "\n \n");
779 v29 = *(int *)v84;
780 if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
781 v29 = v81;
782 sprintf(&a1, format_4E2DC8, v29);
783 sprintf(pTmpBuf2,
784 pGlobalTXT_LocalizationStrings[86],
785 //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
786 (signed __int64)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier,
787 v83);
788 strcat(&a1, pTmpBuf2);
789 v88 = pFontArrus->CalcTextHeight(&a1, &v79, 0, 0);
790 strcat(&a1, "\n \n");
791 v30 = *(int *)v84;
792 if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
793 v30 = v81;
794 sprintf(&v77, format_4E2DC8, v30);
795 strcat(&v77, pGlobalTXT_LocalizationStrings[160]);
796 v82 = pFontArrus->CalcTextHeight(&v77, &v79, 0, 0);
797 strcat(&v77, "\n \n");
798 v75 = 0;
799 v87 = 0;
800 v31 = (signed int)ptr_507BC0->ptr_1C;
801 if ( v31 >= 108 && v31 <= 120 )
802 {
803 v32 = *(int *)v84;
804 if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
805 v32 = v81;
806 sprintf(&v75, format_4E2DC8, v32);
807 strcat(&v75, pGlobalTXT_LocalizationStrings[611]);
808 v87 = pFontArrus->CalcTextHeight(&v75, &v79, 0, 0);
809 }
810 v33 = pDialogueWindow;
811 Str[1] = (char *)pDialogueWindow;
812 v34 = pDialogueWindow->pStartingPosActiveItem;
813 v35 = v34 + pDialogueWindow->pNumPresenceButton;
814 v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
815 v37 = -pDialogueWindow->pNumPresenceButton < 0;
816 pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
817 if ( !(v37 ^ __OFSUB__(v34, v35)) )
818 {
819 LABEL_75:
820 sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
821 v71 = 3;
822 v69 = pTmpBuf;
823 v67 = 0;
824 v66 = 146;
825 LABEL_98:
826 v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
827 return;
828 }
829 while ( 1 )
830 {
831 v38 = v33->GetControl((unsigned int)pOutString);
832 if ( v38->uControlParam == 15 )
833 {
834 v46 = v90;
835 v38->uHeight = v90;
836 v38->uY = 146;
837 v41 = v46 + 145;
838 goto LABEL_73;
839 }
840 if ( v38->uControlParam == 16 )
841 {
842 v44 = v88;
843 v45 = v90 + v36 + 146;
844 v38->uHeight = v88;
845 v38->uY = v45;
846 v41 = v45 + v44 - 1;
847 goto LABEL_73;
848 }
849 if ( v38->uControlParam == 96 )
850 break;
851 if ( v38->uControlParam == 101 )
852 {
853 v39 = v90 + 3 * v36 + v87 + v88 + 146;
854 v33 = (GUIWindow *)Str[1];
855 v40 = v87;
856 v38->uHeight = v87;
857 v38->uY = v39;
858 v41 = v39 + v40 - 1;
859 LABEL_73:
860 v38->uW = v41;
861 }
862 v47 = v33->pStartingPosActiveItem;
863 pOutString = (GUIFont *)((char *)pOutString + 1);
864 if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
865 goto LABEL_75;
866 }
867 v42 = v90 + v88 + 2 * v36 + 146;
868 v43 = v82;
869 v38->uY = v42;
870 v38->uHeight = v43;
871 v41 = v43 + v42 - 1;
872 goto LABEL_73;
873 }
874 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
875 {
876 v48 = 2;
877 pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
878 pOutString = 0;
879 pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
880 if ( pParty->HasItem(0x28Bu) )
881 {
882 pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
883 v48 = 3;
884 }
885 for ( i = 0; i < v48; ++i )
886 {
887 v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
888 pOutString = (GUIFont *)((char *)pOutString + v50);
889 }
890 v86 = (174 - (signed int)pOutString) / v48;
891 v51 = pDialogueWindow;
892 v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
893 v53 = v52 - HIDWORD(v52);
894 LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
895 HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
896 v54 = (v53 >> 1) - v86 / 2 + 138;
897 v37 = -pDialogueWindow->pNumPresenceButton < 0;
898 v89 = pDialogueWindow->pStartingPosActiveItem;
899 if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
900 {
901 v85 = (Player *)2;
902 pOutString = (GUIFont *)pShopOptions;
903 do
904 {
905 v55 = v51->GetControl(v89);
906 v56 = (const char **)pOutString;
907 v55->uY = v86 + v54;
908 v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
909 v58 = v55->uY;
910 v59 = v85;
911 v55->uHeight = v57;
912 v54 = v57 + v58 - 1;
913 v55->uW = v54;
914 v60 = v84[0];
915 if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
916 v60 = v81;
917 v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
918 v51 = pDialogueWindow;
919 v85 = (Player *)((char *)v85 + 1);
920 pOutString = (GUIFont *)((char *)pOutString + 4);
921 ++v89;
922 }
923 while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
924 }
925 }
926 }
927
928 //----- (004B8E3D) --------------------------------------------------------
929 void *__cdecl GenerateShopItems()
930 {
931 GUIWindow *v0; // eax@1
932 signed int v1; // edi@1
933 signed int v2; // esi@1
934 int v3; // ecx@3
935 int v4; // ebx@3
936 int v5; // ecx@3
937 bool v6; // ebp@5
938 int v7; // ecx@5
939 void *result; // eax@15
940 signed int v9; // [sp-Ch] [bp-14h]@7
941
942 v0 = ptr_507BC0;
943 v1 = 0;
944 v2 = (signed int)ptr_507BC0->ptr_1C;
945 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] )
946 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].uType] )
947 {
948 while ( v2 > 14 )
949 {
950 if ( v2 <= 28 )
951 {
952 v6 = v1 > 3;
953 v7 = v6 + 2 * v2 - 30;
954 v2 = (signed int)v0->ptr_1C;
955 v4 = word_4F0498[5 * v7];
956 __debugbreak();
957 //things happen around word_4F0400 actually
958 //v5 = *(short *)&aTooManyStation[2 * (5 * (v6 + 2 * v2) + rand() % 4) + 10];
959 goto LABEL_13;
960 }
961 if ( v2 <= 41 )
962 {
963 v4 = word_4F0576[v2];
964 v9 = 22;
965 goto LABEL_12;
966 }
967 if ( v2 <= 53 )
968 {
969 if ( v1 >= 6 )
970 {
971 v4 = word_4F0578[v2];
972 v9 = 45;
973 LABEL_12:
974 v5 = v9;
975 LABEL_13:
976 pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)]);
977 v0 = ptr_507BC0;
978 pParty->field_777C[9 * (v1 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 5] = 1;
979 goto LABEL_14;
980 }
981 auto _t = (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)];
982 _t->Reset();
983 v0 = ptr_507BC0;
984 pParty->field_777C[9 * (v1 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] = 220;
985 }
986 LABEL_14:
987 v2 = (signed int)v0->ptr_1C;
988 ++v1;
989 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v0->ptr_1C]] )
990 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v0->ptr_1C - 1].uType] )
991 goto LABEL_15;
992 }
993 v3 = 5 * v2;
994 v2 = (signed int)v0->ptr_1C;
995 v4 = word_4F03FE[v3];
996 v5 = word_4F0400[5 * v2 + rand() % 4];
997 goto LABEL_13;
998 }
999 LABEL_15:
1000 result = v0->ptr_1C;
1001 *(int *)&pParty->field_16154[4 * (int)result] = 0;
1002 return result;
1003 }
1004
1005
1006
1007 //----- (004B910F) --------------------------------------------------------
1008 char *__cdecl sub_4B910F()
1009 {
1010 Player *v0; // ebx@1
1011 char *result; // eax@6
1012 signed int v2; // esi@8
1013 unsigned int v3; // ebx@10
1014 ItemGen *v4; // eax@11
1015 char *v5; // ecx@12
1016 unsigned __int8 v6; // dl@13
1017 char *v7; // edx@14
1018 int v8; // eax@15
1019 int v9; // ST08_4@16
1020 int v10; // eax@16
1021 signed int v11; // esi@18
1022 int v12; // ST08_4@21
1023 int v13; // eax@21
1024 int v14; // edi@23
1025 char **v15; // esi@23
1026 int v16; // eax@24
1027 GUIWindow *v17; // ecx@25
1028 int v18; // edx@25
1029 int v19; // edi@25
1030 unsigned __int8 v20; // sf@25
1031 GUIButton *v21; // esi@27
1032 const char **v22; // eax@27
1033 int v23; // eax@27
1034 unsigned int v24; // ecx@27
1035 int v25; // edx@27
1036 unsigned __int16 v26; // ax@27
1037 signed int v27; // esi@32
1038 int v28; // ST08_4@36
1039 int v29; // eax@36
1040 GUIWindow *v30; // edi@41
1041 void *v31; // eax@41
1042 signed int v32; // esi@41
1043 unsigned int v33; // esi@43
1044 int v34; // eax@43
1045 unsigned int v35; // eax@44
1046 int v36; // eax@46
1047 __int32 v37; // ecx@51
1048 GUIButton *v38; // eax@53
1049 GUIButton *v39; // esi@53
1050 int v40; // eax@53
1051 char *v41; // eax@55
1052 int v42; // eax@55
1053 unsigned int v43; // ecx@55
1054 const char **v44; // edx@55
1055 int v45; // eax@55
1056 unsigned __int16 v46; // ax@55
1057 int v47; // eax@59
1058 const char **v48; // eax@63
1059 unsigned int v49; // esi@65
1060 Texture *v50; // eax@65
1061 int v51; // edi@65
1062 int v52; // esi@70
1063 Texture *v53; // ST1C_4@70
1064 int v54; // edi@70
1065 signed int v55; // ecx@73
1066 SHORT v56; // di@82
1067 bool v57; // eax@82
1068 const char *v58; // ecx@84
1069 POINT *v59; // esi@89
1070 LONG v60; // ecx@90
1071 int v61; // eax@90
1072 int v62; // ecx@90
1073 ItemGen *v63; // esi@90
1074 int v64; // eax@95
1075 int v65; // esi@96
1076 char **v66; // edi@96
1077 int v67; // eax@97
1078 GUIWindow *v68; // ecx@98
1079 int v69; // edx@98
1080 int v70; // edi@98
1081 GUIButton *v71; // esi@100
1082 const char **v72; // eax@100
1083 int v73; // eax@100
1084 unsigned int v74; // ecx@100
1085 Player *v75; // edx@100
1086 unsigned __int16 v76; // ax@100
1087 GUIWindow *v77; // [sp-18h] [bp-110h]@14
1088 int v78; // [sp-14h] [bp-10Ch]@14
1089 ItemGen *v79; // [sp-10h] [bp-108h]@12
1090 int v80; // [sp-10h] [bp-108h]@14
1091 void *v81; // [sp-Ch] [bp-104h]@12
1092 unsigned __int16 v82; // [sp-Ch] [bp-104h]@14
1093 int v83; // [sp-8h] [bp-100h]@11
1094 char *v84; // [sp-8h] [bp-100h]@14
1095 __int64 *v85; // [sp-4h] [bp-FCh]@11
1096 unsigned int v86; // [sp-4h] [bp-FCh]@14
1097 POINT v87; // [sp+Ch] [bp-ECh]@8
1098 POINT v88; // [sp+14h] [bp-E4h]@18
1099 POINT v89; // [sp+1Ch] [bp-DCh]@89
1100 POINT v90; // [sp+24h] [bp-D4h]@19
1101 POINT v91; // [sp+2Ch] [bp-CCh]@89
1102 POINT v92; // [sp+34h] [bp-C4h]@9
1103 POINT v93; // [sp+3Ch] [bp-BCh]@33
1104 POINT v94; // [sp+44h] [bp-B4h]@18
1105 POINT v95; // [sp+4Ch] [bp-ACh]@32
1106 POINT v96; // [sp+54h] [bp-A4h]@18
1107 POINT v97; // [sp+5Ch] [bp-9Ch]@32
1108 POINT a2; // [sp+64h] [bp-94h]@8
1109 POINT v99; // [sp+6Ch] [bp-8Ch]@32
1110 POINT v100; // [sp+74h] [bp-84h]@8
1111 GUIWindow v101; // [sp+7Ch] [bp-7Ch]@1
1112 char *Str; // [sp+D0h] [bp-28h]@55
1113 __int32 v103; // [sp+D4h] [bp-24h]@25
1114 int v104; // [sp+D8h] [bp-20h]@1
1115 int v105; // [sp+DCh] [bp-1Ch]@1
1116 POINT v106; // [sp+E0h] [bp-18h]@8
1117 Player *_this; // [sp+E8h] [bp-10h]@1
1118 int v108; // [sp+ECh] [bp-Ch]@26
1119 const char **v109; // [sp+F0h] [bp-8h]@26
1120 unsigned __int8 v110; // [sp+F7h] [bp-1h]@16
1121
1122 v0 = pPlayers[uActiveCharacter];
1123 _this = pPlayers[uActiveCharacter];
1124 memcpy(&v101, ptr_507BC0, sizeof(v101));
1125 v101.uFrameX = 483;
1126 v101.uFrameWidth = 148;
1127 v101.uFrameZ = 334;
1128 v105 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
1129 v104 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
1130 if ( dword_F8B19C > 5 )
1131 {
1132 if ( dword_F8B19C == 94 )
1133 {
1134 draw_leather();
1135 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1136 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
1137 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
1138 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
1139 v65 = 0;
1140 v66 = pShopOptions;
1141 do
1142 {
1143 v67 = pFontArrus->CalcTextHeight(*v66, &v101, 0, 0);
1144 ++v66;
1145 v65 += v67;
1146 }
1147 while ( (signed int)v66 < (signed int)&pShopOptions[3] );
1148 v68 = pDialogueWindow;
1149 v109 = (const char **)((174 - v65) / 3);
1150 result = (char *)pDialogueWindow->pStartingPosActiveItem;
1151 v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
1152 v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
1153 v20 = -pDialogueWindow->pNumPresenceButton < 0;
1154 v106.y = pDialogueWindow->pStartingPosActiveItem;
1155 if ( v20 ^ __OFSUB__((int)result, (int)v69) )
1156 {
1157 _this = (Player *)2;
1158 v108 = (int)pShopOptions;
1159 do
1160 {
1161 v71 = v68->GetControl(v106.y);
1162 v72 = (const char **)v108;
1163 v71->uY = (unsigned int)((char *)v109 + v70);
1164 v73 = pFontArrus->CalcTextHeight(*v72, &v101, 0, 0);
1165 v74 = v71->uY;
1166 v75 = _this;
1167 v71->uHeight = v73;
1168 v70 = v73 + v74 - 1;
1169 v71->uW = v70;
1170 v76 = v104;
1171 if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
1172 v76 = v105;
1173 v101.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
1174 v68 = pDialogueWindow;
1175 _this = (Player *)((char *)_this + 1);
1176 v108 += 4;
1177 ++v106.y;
1178 result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
1179 }
1180 while ( v106.y < (signed int)result );
1181 }
1182 return result;
1183 }
1184 if ( dword_F8B19C != 95 )
1185 {
1186 result = (char *)(dword_F8B19C - 96);
1187 if ( dword_F8B19C == 96 )
1188 {
1189 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1190 if ( result )
1191 {
1192 v30 = pDialogueWindow;
1193 v3 = 0;
1194 v31 = ptr_507BC0->ptr_1C;
1195 v106.y = 0;
1196 //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0);
1197 v32 = (signed __int64)(p2DEvents[(signed int)v31 - 1].flt_24 * 500.0);
1198 v108 = v32 * (100 - _this->GetMerchant()) / 100;
1199 if ( v108 < v32 / 3 )
1200 v108 = v32 / 3;
1201 v33 = v30->pStartingPosActiveItem;
1202 v34 = v33 + v30->pNumPresenceButton;
1203 v109 = 0;
1204 if ( (signed int)v33 >= v34 )
1205 goto LABEL_105;
1206 do
1207 {
1208 v35 = v30->GetControl(v33)->uControlParam - 36;
1209 if ( byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v35] && !_this->pActiveSkills[v35] )
1210 {
1211 v36 = pFontArrus->CalcTextHeight(pSkillNames[v35], &v101, 0, 0);
1212 v106.y += v36;
1213 v109 = (const char **)((char *)v109 + 1);
1214 }
1215 ++v33;
1216 }
1217 while ( (signed int)v33 < v30->pNumPresenceButton + v30->pStartingPosActiveItem );
1218 if ( !v109 )
1219 {
1220 LABEL_105:
1221 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
1222 strcat(pTmpBuf, "\n \n");
1223 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
1224 v7 = pTmpBuf;
1225 v86 = 3;
1226 v84 = pTmpBuf;
1227 v82 = v104;
1228 v80 = 0;
1229 v78 = 0;
1230 v77 = &v101;
1231 goto LABEL_15;
1232 }
1233 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
1234 v101.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
1235 v108 = (149 - v106.y) / (signed int)v109;
1236 if ( (149 - v106.y) / (signed int)v109 > 32 )
1237 v108 = 32;
1238 result = (char *)v30->pStartingPosActiveItem;
1239 v37 = (149 - (signed int)v109 * v108 - v106.y) / 2 - v108 / 2 + 162;
1240 v106.y = (LONG)result;
1241 v103 = v37;
1242 if ( (signed int)result < (signed int)&result[v30->pNumPresenceButton] )
1243 {
1244 v109 = (const char **)2;
1245 do
1246 {
1247 v38 = v30->GetControl(v106.y);
1248 v39 = v38;
1249 v40 = v38->uControlParam - 36;
1250 if ( !byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v40] || _this->pActiveSkills[v40] )
1251 {
1252 v39->uW = 0;
1253 v39->uHeight = 0;
1254 v39->uY = 0;
1255 }
1256 else
1257 {
1258 v41 = pSkillNames[v40];
1259 v39->uY = v108 + v103;
1260 Str = v41;
1261 v42 = pFontArrus->CalcTextHeight(v41, &v101, 0, 0);
1262 v43 = v39->uY;
1263 v44 = v109;
1264 v39->uHeight = v42;
1265 v45 = v43 + v42 - 1;
1266 v39->uW = v45;
1267 v103 = v45;
1268 v46 = v104;
1269 if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v44 )
1270 v46 = v105;
1271 v101.DrawTitleText(pFontArrus, 0, v43, v46, Str, 3u);
1272 }
1273 v47 = v30->pStartingPosActiveItem;
1274 ++v106.y;
1275 result = (char *)(v30->pNumPresenceButton + v47);
1276 v109 = (const char **)((char *)v109 + 1);
1277 }
1278 while ( v106.y < (signed int)result );
1279 }
1280 }
1281 }
1282 return result;
1283 }
1284 }
1285 else
1286 {
1287 if ( dword_F8B19C == 5 )
1288 {
1289 draw_leather();
1290 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1291 sub_4B46A5(pGlobalTXT_LocalizationStrings[198], 0);
1292 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1293 if ( result )
1294 {
1295 v27 = pMouse->GetCursorPos(&v99)->x - 14;
1296 v106.x = (v27 >> 5) + 14 * ((pMouse->GetCursorPos(&v97)->y - 17) >> 5);
1297 result = (char *)pMouse->GetCursorPos(&v95);
1298 if ( *(int *)result > 13 )
1299 {
1300 result = (char *)pMouse->GetCursorPos(&v93);
1301 if ( *(int *)result < 462 )
1302 {
1303 result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
1304 v3 = 0;
1305 if ( result )
1306 {
1307 result = (char *)(9 * (int)result);
1308 if ( _this->field_1F5[4 * (int)result + 15] & 2 )
1309 {
1310 v85 = 0;
1311 v83 = 5;
1312 v81 = ptr_507BC0->ptr_1C;
1313 v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5];
1314 v28 = (int)ptr_507BC0->ptr_1C;
1315 v110 = uActiveCharacter - 1;
1316 v29 = _this->_490EEE(
1317 (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5],
1318 1,
1319 v28,
1320 5);
1321 v6 = v110;
1322 v5 = (char *)pMerchantsRepairPhrases[v29];
1323 goto LABEL_14;
1324 }
1325 }
1326 }
1327 }
1328 }
1329 return result;
1330 }
1331 if ( dword_F8B19C == 1 )
1332 {
1333 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1334 if ( result )
1335 {
1336 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
1337 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
1338 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
1339 v14 = 0;
1340 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
1341 v15 = pShopOptions;
1342 do
1343 {
1344 v16 = pFontArrus->CalcTextHeight(*v15, &v101, 0, 0);
1345 ++v15;
1346 v14 += v16;
1347 }
1348 while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
1349 v17 = pDialogueWindow;
1350 v103 = (174 - v14) / 4;
1351 result = (char *)pDialogueWindow->pStartingPosActiveItem;
1352 v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
1353 v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
1354 v20 = -pDialogueWindow->pNumPresenceButton < 0;
1355 _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
1356 if ( v20 ^ __OFSUB__((int)result, v18) )
1357 {
1358 v108 = 2;
1359 v109 = (const char **)pShopOptions;
1360 do
1361 {
1362 v21 = v17->GetControl((unsigned int)_this);
1363 v22 = v109;
1364 v21->uY = v103 + v19;
1365 v23 = pFontArrus->CalcTextHeight(*v22, &v101, 0, 0);
1366 v24 = v21->uY;
1367 v25 = v108;
1368 v21->uHeight = v23;
1369 v19 = v24 + v23 - 1;
1370 v21->uW = v19;
1371 v26 = v104;
1372 if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
1373 v26 = v105;
1374 v101.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
1375 v17 = pDialogueWindow;
1376 ++v108;
1377 ++v109;
1378 _this = (Player *)((char *)_this + 1);
1379 result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
1380 }
1381 while ( (signed int)_this < (signed int)result );
1382 }
1383 }
1384 return result;
1385 }
1386 if ( dword_F8B19C != 2 )
1387 {
1388 if ( dword_F8B19C == 3 )
1389 {
1390 draw_leather();
1391 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1392 sub_4B46A5(pGlobalTXT_LocalizationStrings[199], 0);
1393 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1394 if ( result )
1395 {
1396 v11 = pMouse->GetCursorPos(&v96)->x - 14;
1397 v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5);
1398 result = (char *)pMouse->GetCursorPos(&v94);
1399 if ( *(int *)result > 13 )
1400 {
1401 result = (char *)pMouse->GetCursorPos(&v90);
1402 if ( *(int *)result < 462 )
1403 {
1404 result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
1405 v3 = 0;
1406 if ( result )
1407 {
1408 v85 = 0;
1409 v83 = 3;
1410 v81 = ptr_507BC0->ptr_1C;
1411 v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
1412 v12 = (int)ptr_507BC0->ptr_1C;
1413 v110 = uActiveCharacter - 1;
1414 v13 = _this->_490EEE(v79, 1, v12, 3);
1415 v6 = v110;
1416 v5 = (char *)pMerchantsSellPhrases[v13];
1417 goto LABEL_14;
1418 }
1419 }
1420 }
1421 }
1422 }
1423 else
1424 {
1425 result = (char *)(dword_F8B19C - 4);
1426 if ( dword_F8B19C == 4 )
1427 {
1428 draw_leather();
1429 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1430 sub_4B46A5(pGlobalTXT_LocalizationStrings[197], 0);
1431 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1432 if ( result )
1433 {
1434 v2 = pMouse->GetCursorPos(&a2)->x - 14;
1435 v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5);
1436 result = (char *)pMouse->GetCursorPos(&v100);
1437 if ( *(int *)result > 13 )
1438 {
1439 result = (char *)pMouse->GetCursorPos(&v92);
1440 if ( *(int *)result < 462 )
1441 {
1442 result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
1443 v3 = 0;
1444 if ( result )
1445 {
1446 v85 = 0;
1447 v83 = 4;
1448 v4 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
1449 if ( !(v4->uAttributes & 1) )
1450 {
1451 v81 = ptr_507BC0->ptr_1C;
1452 v79 = v4;
1453 v9 = (int)ptr_507BC0->ptr_1C;
1454 v110 = uActiveCharacter - 1;
1455 v10 = _this->_490EEE(v4, 1, v9, 4);
1456 v6 = v110;
1457 v5 = (char *)pMerchantsIdentifyPhrases[v10];
1458 goto LABEL_14;
1459 }
1460 v81 = ptr_507BC0->ptr_1C;
1461 v5 = "%24";
1462 v79 = v4;
1463 LABEL_13:
1464 v6 = uActiveCharacter - 1;
1465 LABEL_14:
1466 v7 = sub_495461(v5, v6, v79, (char *)v81, v83, v85);
1467 v86 = 3;
1468 v84 = v7;
1469 v82 = v105;
1470 v80 = v3;
1471 v78 = v3;
1472 v77 = &v101;
1473 LABEL_15:
1474 v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
1475 return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
1476 }
1477 }
1478 }
1479 }
1480 }
1481 }
1482 return result;
1483 }
1484 }
1485 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
1486 v3 = 0;
1487 if ( dword_F8B19C == 2 )
1488 {
1489 v48 = 0;
1490 v108 = 0;
1491 v109 = 0;
1492 do
1493 {
1494 if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)ptr_507BC0->ptr_1C]] )
1495 {
1496 v49 = word_F8B158[(signed int)v48];
1497 v50 = dword_F8B168[(signed int)v48];
1498 v49 += 30;
1499 v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
1500 pRenderer->DrawTextureTransparent(v51 + v108, v49, v50);
1501 sub_40F92A(
1502 &pRenderer->pActiveZBuffer[v51 + v108 + 640 * v49],
1503 dword_F8B168[(signed int)v109],
1504 (int)((char *)v109 + 1));
1505 v48 = v109;
1506 }
1507 v108 += 70;
1508 v48 = (const char **)((char *)v48 + 1);
1509 v109 = v48;
1510 }
1511 while ( (signed int)v48 < 6 );
1512 }
1513 else
1514 {
1515 v109 = 0;
1516 v108 = 0;
1517 do
1518 {
1519 if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)ptr_507BC0->ptr_1C] + 724] )
1520 {
1521 v52 = word_F8B158[(signed int)v109] + 30;
1522 v53 = dword_F8B168[(signed int)v109];
1523 v54 = 60 - ((signed int)v53->uTextureWidth >> 1);
1524 pRenderer->DrawTextureTransparent(v54 + v108, word_F8B158[(signed int)v109] + 30, v53);
1525 sub_40F92A(
1526 &pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52],
1527 dword_F8B168[(signed int)v109],
1528 (int)((char *)v109 + 1));
1529 }
1530 v109 = (const char **)((char *)v109 + 1);
1531 v108 += 70;
1532 }
1533 while ( (signed int)v109 < 6 );
1534 }
1535 result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1536 if ( result )
1537 {
1538 v55 = 0;
1539 v106.x = 0;
1540 if ( dword_F8B19C == 2 )
1541 {
1542 v106.x = 0;
1543 do
1544 {
1545 if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
1546 ++v106.x;
1547 ++v55;
1548 }
1549 while ( v55 < 6 );
1550 }
1551 else
1552 {
1553 do
1554 {
1555 if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
1556 ++v106.x;
1557 ++v55;
1558 }
1559 while ( v55 < 6 );
1560 }
1561 v56 = GetAsyncKeyState(17);
1562 v57 = _this->CanSteal();
1563 Str = (char *)v57;
1564 if ( v56 && v57 )
1565 {
1566 v58 = pGlobalTXT_LocalizationStrings[185];
1567 }
1568 else
1569 {
1570 v58 = pGlobalTXT_LocalizationStrings[195];
1571 if ( dword_F8B19C != 2 )
1572 v58 = pGlobalTXT_LocalizationStrings[196];
1573 }
1574 sub_4B46A5(v58, 0);
1575 if ( v106.x )
1576 {
1577 v59 = pMouse->GetCursorPos(&v91);
1578 result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
1579 if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
1580 {
1581 v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
1582 v106.x = v60;
1583 v61 = (int)ptr_507BC0->ptr_1C;
1584 v62 = 9 * (v60 + 12 * v61);
1585 v63 = (ItemGen *)&pParty->field_777C[v62];
1586 if ( dword_F8B19C != 2 )
1587 v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
1588 if ( !v56 || !Str )
1589 {
1590 v85 = 0;
1591 v83 = 2;
1592 v81 = ptr_507BC0->ptr_1C;
1593 v79 = v63;
1594 v110 = uActiveCharacter - 1;
1595 v64 = _this->_490EEE(v63, 1, v61, 2);
1596 v6 = v110;
1597 v5 = (char *)pMerchantsBuyPhrases[v64];
1598 goto LABEL_14;
1599 }
1600 v5 = pGlobalTXT_LocalizationStrings[181];
1601 v85 = 0;
1602 v83 = 2;
1603 v81 = ptr_507BC0->ptr_1C;
1604 v79 = v63;
1605 goto LABEL_13;
1606 }
1607 }
1608 else
1609 {
1610 result = v101._4B1854(
1611 __PAIR__(
1612 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C + 1],
1613 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C])
1614 - pParty->uTimePlayed);
1615 }
1616 }
1617 return result;
1618 }
1619
1620
1621 //----- (004B9CC6) --------------------------------------------------------
1622 POINT *__cdecl sub_4B9CC6()
1623 {
1624 Player *v0; // ebx@1
1625 POINT *result; // eax@7
1626 GUIWindow *v2; // edi@9
1627 unsigned int v3; // ebx@9
1628 void *v4; // eax@9
1629 signed int v5; // esi@9
1630 unsigned int v6; // esi@11
1631 int v7; // eax@11
1632 unsigned int v8; // eax@12
1633 int v9; // eax@14
1634 int v10; // ecx@19
1635 GUIButton *v11; // eax@21
1636 GUIButton *v12; // esi@21
1637 int v13; // eax@21
1638 char *v14; // eax@23
1639 int v15; // eax@23
1640 unsigned int v16; // ecx@23
1641 int v17; // edx@23
1642 int v18; // eax@23
1643 unsigned __int16 v19; // ax@23
1644 int v20; // eax@27
1645 char *v21; // edx@29
1646 int v22; // esi@30
1647 char **v23; // edi@30
1648 int v24; // eax@31
1649 GUIWindow *v25; // ecx@32
1650 int v26; // edx@32
1651 int v27; // edi@32
1652 unsigned __int8 v28; // sf@32
1653 GUIButton *v29; // esi@34
1654 const char **v30; // eax@34
1655 int v31; // eax@34
1656 unsigned int v32; // ecx@34
1657 Player *v33; // edx@34
1658 int v34; // eax@34
1659 unsigned __int16 v35; // ax@34
1660 signed int v36; // esi@39
1661 ItemGen *v37; // eax@42
1662 char *v38; // ecx@43
1663 unsigned __int8 v39; // dl@44
1664 int v40; // eax@46
1665 int v41; // ST08_4@47
1666 int v42; // eax@47
1667 signed int v43; // esi@49
1668 int v44; // ST08_4@52
1669 int v45; // eax@52
1670 Texture *v46; // ecx@55
1671 unsigned int v47; // edi@55
1672 unsigned int v48; // esi@57
1673 int v49; // edx@61
1674 Texture *v50; // ecx@67
1675 unsigned int v51; // edi@67
1676 unsigned int v52; // esi@69
1677 int v53; // edx@73
1678 Texture *v54; // ecx@79
1679 unsigned int v55; // edi@79
1680 unsigned int v56; // esi@81
1681 int v57; // edx@85
1682 Texture *v58; // ecx@91
1683 unsigned int v59; // edi@91
1684 unsigned int v60; // esi@93
1685 int v61; // edx@97
1686 signed int v62; // ecx@102
1687 SHORT v63; // di@110
1688 bool v64; // eax@110
1689 const char *v65; // ecx@112
1690 POINT *v66; // esi@117
1691 int v67; // ecx@118
1692 int v68; // eax@118
1693 int v69; // ecx@118
1694 ItemGen *v70; // esi@118
1695 int v71; // eax@123
1696 int v72; // edi@125
1697 char **v73; // esi@125
1698 int v74; // eax@126
1699 GUIWindow *v75; // ecx@127
1700 int v76; // edx@127
1701 int v77; // edi@127
1702 GUIButton *v78; // esi@129
1703 const char **v79; // eax@129
1704 int v80; // eax@129
1705 unsigned int v81; // ecx@129
1706 Player *v82; // edx@129
1707 unsigned __int16 v83; // ax@129
1708 GUIWindow *v84; // [sp-18h] [bp-F0h]@29
1709 int v85; // [sp-14h] [bp-ECh]@29
1710 int v86; // [sp-10h] [bp-E8h]@29
1711 ItemGen *v87; // [sp-10h] [bp-E8h]@43
1712 unsigned __int16 v88; // [sp-Ch] [bp-E4h]@29
1713 void *v89; // [sp-Ch] [bp-E4h]@43
1714 char *v90; // [sp-8h] [bp-E0h]@29
1715 int v91; // [sp-8h] [bp-E0h]@42
1716 unsigned int v92; // [sp-4h] [bp-DCh]@29
1717 __int64 *v93; // [sp-4h] [bp-DCh]@42
1718 POINT v94; // [sp+Ch] [bp-CCh]@39
1719 POINT v95; // [sp+14h] [bp-C4h]@49
1720 POINT v96; // [sp+1Ch] [bp-BCh]@117
1721 POINT v97; // [sp+24h] [bp-B4h]@40
1722 POINT v98; // [sp+2Ch] [bp-ACh]@117
1723 POINT v99; // [sp+34h] [bp-A4h]@49
1724 POINT v100; // [sp+3Ch] [bp-9Ch]@50
1725 POINT v101; // [sp+44h] [bp-94h]@39
1726 POINT v102; // [sp+4Ch] [bp-8Ch]@49
1727 POINT a2; // [sp+54h] [bp-84h]@39
1728 GUIWindow v104; // [sp+5Ch] [bp-7Ch]@1
1729 int v105; // [sp+B0h] [bp-28h]@19
1730 int v106; // [sp+B4h] [bp-24h]@1
1731 char *Str; // [sp+B8h] [bp-20h]@23
1732 int v108; // [sp+BCh] [bp-1Ch]@1
1733 __int32 v109; // [sp+C0h] [bp-18h]@39
1734 Player *_this; // [sp+C4h] [bp-14h]@1
1735 const char **v111; // [sp+C8h] [bp-10h]@9
1736 unsigned int v112; // [sp+CCh] [bp-Ch]@9
1737 unsigned __int8 v113; // [sp+D3h] [bp-5h]@47
1738 int v114; // [sp+D4h] [bp-4h]@11
1739
1740 v0 = pPlayers[uActiveCharacter];
1741 _this = pPlayers[uActiveCharacter];
1742 memcpy(&v104, ptr_507BC0, sizeof(v104));
1743 v104.uFrameX = 483;
1744 v104.uFrameWidth = 148;
1745 v104.uFrameZ = 334;
1746 v108 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
1747 v106 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
1748 if ( dword_F8B19C == 1 )
1749 {
1750 result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1751 if ( result )
1752 {
1753 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
1754 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
1755 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
1756 v72 = 0;
1757 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
1758 v73 = pShopOptions;
1759 do
1760 {
1761 v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0);
1762 ++v73;
1763 v72 += v74;
1764 }
1765 while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
1766 v75 = pDialogueWindow;
1767 Str = (char *)((174 - v72) / 4);
1768 result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
1769 v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
1770 v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
1771 v28 = -pDialogueWindow->pNumPresenceButton < 0;
1772 v112 = pDialogueWindow->pStartingPosActiveItem;
1773 if ( v28 ^ __OFSUB__((int)result, v76) )
1774 {
1775 _this = (Player *)2;
1776 v111 = (const char **)pShopOptions;
1777 do
1778 {
1779 v78 = v75->GetControl(v112);
1780 v79 = v111;
1781 v78->uY = (unsigned int)&Str[v77];
1782 v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0);
1783 v81 = v78->uY;
1784 v82 = _this;
1785 v78->uHeight = v80;
1786 v77 = v81 + v80 - 1;
1787 v78->uW = v77;
1788 v83 = v106;
1789 if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
1790 v83 = v108;
1791 v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u);
1792 v75 = pDialogueWindow;
1793 _this = (Player *)((char *)_this + 1);
1794 ++v111;
1795 ++v112;
1796 result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
1797 }
1798 while ( (signed int)v112 < (signed int)result );
1799 }
1800 }
1801 }
1802 else
1803 {
1804 if ( dword_F8B19C != 2 )
1805 {
1806 if ( dword_F8B19C == 3 )
1807 {
1808 draw_leather();
1809 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1810 sub_4B46A5(pGlobalTXT_LocalizationStrings[199], 0);
1811 result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1812 if ( !result
1813 || (v43 = pMouse->GetCursorPos(&v99)->x - 14,
1814 v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5),
1815 result = pMouse->GetCursorPos(&v102),
1816 result->x <= 13)
1817 || (result = pMouse->GetCursorPos(&v100), result->x >= 462)
1818 || (result = (POINT *)v0->GetItemIDAtInventoryIndex((int *)&v109), v3 = 0, !result) )
1819 return result;
1820 v93 = 0;
1821 v91 = 3;
1822 v89 = ptr_507BC0->ptr_1C;
1823 v87 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
1824 v44 = (int)ptr_507BC0->ptr_1C;
1825 v113 = uActiveCharacter - 1;
1826 v45 = _this->_490EEE(v87, 4, v44, 3);
1827 v39 = v113;
1828 v38 = (char *)pMerchantsSellPhrases[v45];
1829 goto LABEL_45;
1830 }
1831 if ( dword_F8B19C == 4 )
1832 {
1833 draw_leather();
1834 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1835 sub_4B46A5(pGlobalTXT_LocalizationStrings[197], 0);
1836 result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
1837 if ( !result
1838 || (v36 = pMouse->GetCursorPos(&a2)->x - 14,
1839 v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5),
1840 result = pMouse->GetCursorPos(&v101),
1841 result->x <= 13)
1842 || (result = pMouse->GetCursorPos(&v97), result->x >= 462)
1843 || (result = (POINT *)v0->GetItemIDAtInventoryIndex((int *)&v109), v3 = 0, !result) )
1844 return result;
1845 v93 = 0;
1846 v91 = 4;
1847 v37 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
1848 if ( !(v37->uAttributes & 1) )
1849 {
1850 v89 = ptr_507BC0->ptr_1C;
1851 v87 = v37;
1852 v41 = (int)ptr_507BC0->ptr_1C;
1853 v113 = uActiveCharacter - 1;
1854 v42 = _this->_490EEE(v37, 4, v41, 4);
1855 v39 = v113;
1856 v38 = (char *)pMerchantsIdentifyPhrases[v42];
1857 goto LABEL_45;
1858 }
1859 v89 = ptr_507BC0->ptr_1C;
1860 v38 = "%24";
1861 v87 = v37;
1862 LABEL_44:
1863 v39 = uActiveCharacter - 1;
1864 LABEL_45:
1865 v21 = sub_495461(v38, v39, v87, (char *)v89, v91, v93);
1866 v92 = 3;
1867 v90 = v21;
1868 v88 = v108;
1869 v86 = v3;
1870 v85 = v3;
1871 v84 = &v104;
1872 goto LABEL_46;
1873 }
1874 if ( dword_F8B19C == 94 )
1875 {
1876 draw_leather();
1877 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1878 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
1879 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
1880 v22 = 0;
1881 v23 = pShopOptions;
1882 do
1883 {
1884 v24 = pFontArrus->CalcTextHeight(*v23, &v104, 0, 0);
1885 ++v23;
1886 v22 += v24;
1887 }
1888 while ( (signed int)v23 < (signed int)&pShopOptions[2] );
1889 Str = (char *)((174 - v22) / 2);
1890 v25 = pDialogueWindow;
1891 result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
1892 v26 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
1893 v27 = (2 * (87 - (174 - v22) / 2) - v22) / 2 - (174 - v22) / 2 / 2 + 138;
1894 v28 = -pDialogueWindow->pNumPresenceButton < 0;
1895 v112 = pDialogueWindow->pStartingPosActiveItem;
1896 if ( v28 ^ __OFSUB__((int)result, v26) )
1897 {
1898 _this = (Player *)2;
1899 v111 = (const char **)pShopOptions;
1900 do
1901 {
1902 v29 = v25->GetControl(v112);
1903 v30 = v111;
1904 v29->uY = (unsigned int)&Str[v27];
1905 v31 = pFontArrus->CalcTextHeight(*v30, &v104, 0, 0);
1906 v32 = v29->uY;
1907 v33 = _this;
1908 v29->uHeight = v31;
1909 v34 = v31 + v32 - 1;
1910 v29->uW = v34;
1911 v27 = v34;
1912 v35 = v106;
1913 if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v33 )
1914 v35 = v108;
1915 v104.DrawTitleText(pFontArrus, 0, v32, v35, *v111, 3u);
1916 v25 = pDialogueWindow;
1917 _this = (Player *)((char *)_this + 1);
1918 ++v111;
1919 ++v112;
1920 result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
1921 }
1922 while ( (signed int)v112 < (signed int)result );
1923 }
1924 return result;
1925 }
1926 if ( dword_F8B19C != 95 )
1927 {
1928 result = (POINT *)(dword_F8B19C - 96);
1929 if ( dword_F8B19C != 96
1930 || (result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) == 0 )
1931 return result;
1932 v2 = pDialogueWindow;
1933 v3 = 0;
1934 v4 = ptr_507BC0->ptr_1C;
1935 v112 = 0;
1936 //v5 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v4] * 500.0);
1937 v5 = (signed __int64)(p2DEvents[(signed int)v4 - 1].flt_24 * 500.0);
1938 v111 = (const char **)(v5 * (100 - _this->GetMerchant()) / 100);
1939 if ( (signed int)v111 < v5 / 3 )
1940 v111 = (const char **)(v5 / 3);
1941 v6 = v2->pStartingPosActiveItem;
1942 v7 = v6 + v2->pNumPresenceButton;
1943 v114 = 0;
1944 if ( (signed int)v6 < v7 )
1945 {
1946 do
1947 {
1948 v8 = v2->GetControl(v6)->uControlParam - 36;
1949 if ( byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v8] && !_this->pActiveSkills[v8] )
1950 {
1951 v9 = pFontArrus->CalcTextHeight(pSkillNames[v8], &v104, 0, 0);
1952 v112 += v9;
1953 ++v114;
1954 }
1955 ++v6;
1956 }
1957 while ( (signed int)v6 < v2->pNumPresenceButton + v2->pStartingPosActiveItem );
1958 if ( v114 )
1959 {
1960 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v111);
1961 v104.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
1962 v111 = (const char **)((signed int)(149 - v112) / v114);
1963 if ( (signed int)(149 - v112) / v114 > 32 )
1964 v111 = (const char **)32;
1965 result = (POINT *)v2->pStartingPosActiveItem;
1966 v10 = (signed int)(149 - v114 * (int)v111 - v112) / 2 - (signed int)v111 / 2 + 162;
1967 v112 = (unsigned int)result;
1968 v105 = v10;
1969 if ( (signed int)result < (signed int)((char *)result + v2->pNumPresenceButton) )
1970 {
1971 v114 = 2;
1972 do
1973 {
1974 v11 = v2->GetControl(v112);
1975 v12 = v11;
1976 v13 = v11->uControlParam - 36;
1977 if ( !byte_4ED970_skill_learn_ability_by_class_table[_this->uClass][v13] || _this->pActiveSkills[v13] )
1978 {
1979 v12->uW = 0;
1980 v12->uHeight = 0;
1981 v12->uY = 0;
1982 }
1983 else
1984 {
1985 v14 = pSkillNames[v13];
1986 v12->uY = (unsigned int)((char *)v111 + v105);
1987 Str = v14;
1988 v15 = pFontArrus->CalcTextHeight(v14, &v104, 0, 0);
1989 v16 = v12->uY;
1990 v17 = v114;
1991 v12->uHeight = v15;
1992 v18 = v16 + v15 - 1;
1993 v12->uW = v18;
1994 v105 = v18;
1995 v19 = v106;
1996 if ( pDialogueWindow->pCurrentPosActiveItem != v17 )
1997 v19 = v108;
1998 v104.DrawTitleText(pFontArrus, 0, v16, v19, Str, 3u);
1999 }
2000 v20 = v2->pStartingPosActiveItem;
2001 ++v112;
2002 result = (POINT *)(v2->pNumPresenceButton + v20);
2003 ++v114;
2004 }
2005 while ( (signed int)v112 < (signed int)result );
2006 }
2007 return result;
2008 }
2009 }
2010 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
2011 strcat(pTmpBuf, "\n \n");
2012 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
2013 v21 = pTmpBuf;
2014 v92 = 3;
2015 v90 = pTmpBuf;
2016 v88 = v106;
2017 v86 = 0;
2018 v85 = 0;
2019 v84 = &v104;
2020 LABEL_46:
2021 v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
2022 return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
2023 }
2024 }
2025 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
2026 v3 = 0;
2027 v114 = 0;
2028 if ( dword_F8B19C == 2 )
2029 {
2030 do
2031 {
2032 if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
2033 {
2034 v46 = dword_F8B168[v114];
2035 v47 = 152 - v46->uTextureHeight;
2036 if ( (signed int)v47 < 1 )
2037 v47 = 0;
2038 v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
2039 if ( v114 )
2040 {
2041 if ( v114 == 5 )
2042 {
2043 v49 = dword_F8B168[5]->uTextureWidth;
2044 if ( (signed int)v48 > 457 - v49 )
2045 v48 = 457 - v49;
2046 }
2047 }
2048 else
2049 {
2050 if ( (signed int)v48 < 18 )
2051 v48 = 18;
2052 }
2053 pRenderer->DrawTextureTransparent(v48, v47, v46);
2054 sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], dword_F8B168[v114], v114 + 1);
2055 }
2056 ++v114;
2057 }
2058 while ( v114 < 6 );
2059 v114 = 0;
2060 do
2061 {
2062 if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 54] )
2063 {
2064 v50 = dword_F8B168[v114 + 6];
2065 v51 = 308 - v50->uTextureHeight;
2066 if ( (signed int)v51 < 1 )
2067 v51 = 0;
2068 v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
2069 if ( v114 )
2070 {
2071 if ( v114 == 5 )
2072 {
2073 v53 = dword_F8B168[11]->uTextureWidth;
2074 if ( (signed int)v52 > 457 - v53 )
2075 v52 = 457 - v53;
2076 }
2077 }
2078 else
2079 {
2080 if ( (signed int)v52 < 18 )
2081 v52 = 18;
2082 }
2083 pRenderer->DrawTextureTransparent(v52, v51, v50);
2084 sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], dword_F8B168[v114 + 6], v114 + 7);
2085 }
2086 ++v114;
2087 }
2088 while ( v114 < 6 );
2089 }
2090 else
2091 {
2092 do
2093 {
2094 if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
2095 {
2096 v54 = dword_F8B168[v114];
2097 v55 = 152 - v54->uTextureHeight;
2098 if ( (signed int)v55 < 1 )
2099 v55 = 0;
2100 v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
2101 if ( v114 )
2102 {
2103 if ( v114 == 5 )
2104 {
2105 v57 = dword_F8B168[5]->uTextureWidth;
2106 if ( (signed int)v56 > 457 - v57 )
2107 v56 = 457 - v57;
2108 }
2109 }
2110 else
2111 {
2112 if ( (signed int)v56 < 18 )
2113 v56 = 18;
2114 }
2115 pRenderer->DrawTextureTransparent(v56, v55, v54);
2116 sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], dword_F8B168[v114], v114 + 1);
2117 }
2118 ++v114;
2119 }
2120 while ( v114 < 6 );
2121 v114 = 0;
2122 do
2123 {
2124 if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 778] )
2125 {
2126 v58 = dword_F8B168[v114 + 6];
2127 v59 = 308 - v58->uTextureHeight;
2128 if ( (signed int)v59 < 1 )
2129 v59 = 0;
2130 v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
2131 if ( v114 )
2132 {
2133 if ( v114 == 5 )
2134 {
2135 v61 = dword_F8B168[11]->uTextureWidth;
2136 if ( (signed int)v60 > 457 - v61 )
2137 v60 = 457 - v61;
2138 }
2139 }
2140 else
2141 {
2142 if ( (signed int)v60 < 18 )
2143 v60 = 18;
2144 }
2145 pRenderer->DrawTextureTransparent(v60, v59, v58);
2146 sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], dword_F8B168[v114 + 6], v114 + 7);
2147 }
2148 ++v114;
2149 }
2150 while ( v114 < 6 );
2151 }
2152 result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
2153 if ( result )
2154 {
2155 v62 = 0;
2156 v109 = 0;
2157 if ( dword_F8B19C == 2 )
2158 {
2159 do
2160 {
2161 if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
2162 ++v109;
2163 ++v62;
2164 }
2165 while ( v62 < 12 );
2166 }
2167 else
2168 {
2169 do
2170 {
2171 if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
2172 ++v109;
2173 ++v62;
2174 }
2175 while ( v62 < 12 );
2176 }
2177 v63 = GetAsyncKeyState(17);
2178 v64 = _this->CanSteal();
2179 Str = (char *)v64;
2180 if ( v63 && v64 )
2181 {
2182 v65 = pGlobalTXT_LocalizationStrings[185];
2183 }
2184 else
2185 {
2186 v65 = pGlobalTXT_LocalizationStrings[195];
2187 if ( dword_F8B19C != 2 )
2188 v65 = pGlobalTXT_LocalizationStrings[196];
2189 }
2190 sub_4B46A5(v65, 0);
2191 if ( !v109 )
2192 return (POINT *)v104._4B1854(
2193 __PAIR__(
2194 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C + 1],
2195 pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C])
2196 - pParty->uTimePlayed);
2197 v66 = pMouse->GetCursorPos(&v98);
2198 result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
2199 if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
2200 {
2201 v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
2202 v109 = v67;
2203 v68 = (int)ptr_507BC0->ptr_1C;
2204 v69 = 9 * (v67 + 12 * v68);
2205 v70 = (ItemGen *)&pParty->field_777C[v69];
2206 if ( dword_F8B19C != 2 )
2207 v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
2208 if ( !v63 || !Str )
2209 {
2210 v93 = 0;
2211 v91 = 2;
2212 v89 = ptr_507BC0->ptr_1C;
2213 v87 = v70;
2214 v113 = uActiveCharacter - 1;
2215 v71 = _this->_490EEE(v70, 4, v68, 2);
2216 v39 = v113;
2217 v38 = (char *)pMerchantsBuyPhrases[v71];
2218 goto LABEL_45;
2219 }
2220 v38 = pGlobalTXT_LocalizationStrings[181];
2221 v93 = 0;
2222 v91 = 2;
2223 v89 = ptr_507BC0->ptr_1C;
2224 v87 = v70;
2225 goto LABEL_44;
2226 }
2227 }
2228 }
2229 return result;
2230 }
2231
2232
2233 //----- (004BA928) --------------------------------------------------------
2234 void __cdecl sub_4BA928()
2235 {
2236 Player *v0; // ebx@1
2237 signed int v1; // esi@8
2238 unsigned int v2; // eax@10
2239 ItemGen *v3; // eax@11
2240 unsigned __int8 v4; // dl@12
2241 char *v5; // ecx@12
2242 char *v6; // eax@13
2243 int v7; // ST08_4@15
2244 int v8; // eax@15
2245 signed int v9; // esi@17
2246 unsigned int v10; // eax@19
2247 char *v11; // edi@19
2248 int v12; // ST08_4@20
2249 int v13; // eax@20
2250 unsigned __int8 v14; // dl@20
2251 char *v15; // ecx@20
2252 char **v16; // edi@22
2253 int v17; // ebx@22
2254 char **v18; // esi@22
2255 int v19; // eax@23
2256 GUIWindow *v20; // ecx@24
2257 int v21; // eax@24
2258 int v22; // edx@24
2259 int v23; // ebx@24
2260 unsigned __int8 v24; // sf@24
2261 GUIButton *v25; // eax@26
2262 GUIButton *v26; // esi@26
2263 int v27; // eax@26
2264 unsigned int v28; // ecx@26
2265 Player *v29; // edx@26
2266 unsigned __int16 v30; // ax@26
2267 signed int v31; // esi@31
2268 unsigned int v32; // eax@33
2269 int v33; // eax@34
2270 int v34; // ST08_4@35
2271 int v35; // eax@35
2272 char *v36; // edx@36
2273 GUIWindow *v37; // edi@42
2274 signed int v38; // esi@42
2275 unsigned int v39; // esi@44
2276 int v40; // eax@44
2277 unsigned int v41; // eax@45
2278 int v42; // eax@47
2279 int v43; // ecx@52
2280 GUIButton *v44; // eax@54
2281 GUIButton *v45; // esi@54
2282 int v46; // eax@54
2283 char *v47; // eax@56
2284 int v48; // eax@56
2285 unsigned int v49; // ecx@56
2286 int v50; // edx@56
2287 int v51; // eax@56
2288 unsigned __int16 v52; // ax@56
2289 int v53; // eax@60
2290 int v54; // eax@60
2291 signed int v55; // ebx@65
2292 Texture *v56; // eax@67
2293 unsigned int v57; // edi@68
2294 Texture *v58; // ST1C_4@68
2295 int v59; // eax@68
2296 int v60; // edi@69
2297 signed int v61; // ebx@73
2298 Texture *v62; // eax@75
2299 int v63; // edi@76
2300 Texture *v64; // ST1C_4@76
2301 unsigned int v65; // ST18_4@76
2302 int v66; // eax@76
2303 int v67; // edi@77
2304 signed int v68; // ecx@81
2305 SHORT v69; // bx@89
2306 bool v70; // eax@89
2307 const char *v71; // ecx@91
2308 void *v72; // eax@95
2309 POINT *v73; // esi@97
2310 int v74; // ecx@97
2311 int v75; // eax@98
2312 int v76; // ecx@98
2313 ItemGen *v77; // ecx@99
2314 unsigned __int8 v78; // bl@104
2315 char **v79; // edi@105
2316 int v80; // ebx@105
2317 char **v81; // esi@105
2318 int v82; // eax@106
2319 GUIWindow *v83; // ecx@107
2320 int v84; // eax@107
2321 int v85; // edx@107
2322 int v86; // ebx@107
2323 GUIButton *v87; // eax@109
2324 GUIButton *v88; // esi@109
2325 int v89; // eax@109
2326 unsigned int v90; // ecx@109
2327 int v91; // edx@109
2328 unsigned __int16 v92; // ax@109
2329 signed int v93; // edx@114
2330 POINT *v94; // edi@120
2331 __int32 v95; // ecx@120
2332 void *v96; // ST14_4@122
2333 unsigned __int8 v97; // bl@122
2334 ItemGen *v98; // ST10_4@122
2335 int v99; // eax@122
2336 char *v100; // eax@122
2337 const char *v101; // ST18_4@122
2338 unsigned __int16 v102; // ST14_2@122
2339 int v103; // eax@122
2340 signed int v104; // edi@123
2341 Texture *v105; // eax@125
2342 int v106; // ebx@126
2343 Texture *v107; // ST1C_4@126
2344 unsigned int v108; // ST18_4@126
2345 int v109; // eax@126
2346 int v110; // ebx@127
2347 GUIWindow *v111; // [sp-18h] [bp-11Ch]@36
2348 unsigned int v112; // [sp-14h] [bp-118h]@13
2349 int v113; // [sp-14h] [bp-118h]@36
2350 ItemGen *v114; // [sp-10h] [bp-114h]@12
2351 unsigned int v115; // [sp-10h] [bp-114h]@13
2352 ItemGen *v116; // [sp-10h] [bp-114h]@20
2353 int v117; // [sp-10h] [bp-114h]@36
2354 void *v118; // [sp-Ch] [bp-110h]@12
2355 unsigned __int16 v119; // [sp-Ch] [bp-110h]@13
2356 void *v120; // [sp-Ch] [bp-110h]@20
2357 char *v121; // [sp-8h] [bp-10Ch]@13
2358 int v122; // [sp-8h] [bp-10Ch]@20
2359 unsigned int v123; // [sp-4h] [bp-108h]@13
2360 __int64 *v124; // [sp-4h] [bp-108h]@20
2361 int v125; // [sp-4h] [bp-108h]@68
2362 int v126; // [sp-4h] [bp-108h]@76
2363 int v127; // [sp-4h] [bp-108h]@126
2364 POINT v128; // [sp+Ch] [bp-F8h]@8
2365 POINT v129; // [sp+14h] [bp-F0h]@18
2366 char v130; // [sp+1Ch] [bp-E8h]@120
2367 POINT a2; // [sp+24h] [bp-E0h]@8
2368 POINT v132; // [sp+2Ch] [bp-D8h]@120
2369 POINT v133; // [sp+34h] [bp-D0h]@17
2370 char v134; // [sp+3Ch] [bp-C8h]@97
2371 POINT v135; // [sp+44h] [bp-C0h]@31
2372 POINT v136; // [sp+4Ch] [bp-B8h]@97
2373 POINT v137; // [sp+54h] [bp-B0h]@17
2374 POINT v138; // [sp+5Ch] [bp-A8h]@32
2375 POINT v139; // [sp+64h] [bp-A0h]@17
2376 POINT v140; // [sp+6Ch] [bp-98h]@31
2377 POINT v141; // [sp+74h] [bp-90h]@8
2378 POINT v142; // [sp+7Ch] [bp-88h]@31
2379 POINT v143; // [sp+84h] [bp-80h]@9
2380 GUIWindow v144; // [sp+8Ch] [bp-78h]@1
2381 char *Str; // [sp+E0h] [bp-24h]@56
2382 int v146; // [sp+E4h] [bp-20h]@24
2383 int v147; // [sp+E8h] [bp-1Ch]@1
2384 int v148; // [sp+ECh] [bp-18h]@1
2385 __int32 v149; // [sp+F0h] [bp-14h]@8
2386 Player *_this; // [sp+F4h] [bp-10h]@1
2387 unsigned __int8 uPlayerID; // [sp+FBh] [bp-9h]@15
2388 int v152; // [sp+FCh] [bp-8h]@24
2389 int v153; // [sp+100h] [bp-4h]@44
2390
2391 v0 = pPlayers[uActiveCharacter];
2392 _this = pPlayers[uActiveCharacter];
2393 memcpy(&v144, ptr_507BC0, sizeof(v144));
2394 v144.uFrameX = 483;
2395 v144.uFrameWidth = 148;
2396 v144.uFrameZ = 334;
2397 v148 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
2398 v147 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
2399 if ( dword_F8B19C > 5 )
2400 {
2401 if ( dword_F8B19C == 6 )
2402 {
2403 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
2404 sub_4B46A5(pGlobalTXT_LocalizationStrings[195], 0);
2405 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2406 return;
2407 v149 = 0;
2408 v93 = 0;
2409 do
2410 {
2411 if ( pParty->field_C59C[9 * (v93 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
2412 ++v149;
2413 ++v93;
2414 }
2415 while ( v93 < 8 );
2416 if ( v149 )
2417 {
2418 v94 = pMouse->GetCursorPos(&v132);
2419 v149 = pRenderer->pActiveZBuffer[v94->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v130)->y]];
2420 v95 = v149;
2421 if ( v149 && v149 != -65536 )
2422 {
2423 --v149;
2424 v96 = ptr_507BC0->ptr_1C;
2425 v97 = uActiveCharacter - 1;
2426 v98 = (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724];
2427 v99 = _this->_490EEE(
2428 (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724],
2429 2,
2430 (int)ptr_507BC0->ptr_1C,
2431 2);
2432 v100 = sub_495461((char *)pMerchantsBuyPhrases[v99], v97, v98, (char *)v96, 2, 0);
2433 v101 = v100;
2434 v102 = v148;
2435 v103 = pFontArrus->CalcTextHeight(v100, &v144, 0, 0);
2436 v144.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, v102, v101, 3u);
2437 }
2438 v104 = 0;
2439 v153 = 0;
2440 do
2441 {
2442 if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
2443 {
2444 v105 = dword_F8B168[v104];
2445 if ( v104 >= 4 )
2446 {
2447 v110 = 90 - ((signed int)v105->uTextureWidth >> 1);
2448 pRenderer->DrawTextureTransparent(v153 + v110 - 420, 0x7Eu, dword_F8B168[v104]);
2449 v127 = v104 + 1;
2450 v109 = v153 + v110 + 80220;
2451 }
2452 else
2453 {
2454 v106 = 98 - v105->uTextureHeight;
2455 v107 = dword_F8B168[v104];
2456 v108 = 98 - v105->uTextureHeight;
2457 v152 = 86 - ((signed int)v105->uTextureWidth >> 1);
2458 pRenderer->DrawTextureTransparent(v152 + v153, v108, v107);
2459 v127 = v104 + 1;
2460 v109 = v152 + v153 + 640 * v106;
2461 }
2462 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v109], dword_F8B168[v104], v127);
2463 }
2464 v153 += 105;
2465 ++v104;
2466 }
2467 while ( v104 < 8 );
2468 return;
2469 }
2470 v72 = ptr_507BC0->ptr_1C;
2471 goto LABEL_96;
2472 }
2473 if ( dword_F8B19C == 94 )
2474 {
2475 draw_leather();
2476 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
2477 v79 = pShopOptions;
2478 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
2479 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
2480 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
2481 v80 = 0;
2482 v81 = pShopOptions;
2483 do
2484 {
2485 v82 = pFontArrus->CalcTextHeight(*v81, &v144, 0, 0);
2486 ++v81;
2487 v80 += v82;
2488 }
2489 while ( (signed int)v81 < (signed int)&pShopOptions[3] );
2490 v83 = pDialogueWindow;
2491 v152 = (174 - v80) / 3;
2492 v84 = pDialogueWindow->pStartingPosActiveItem;
2493 v85 = v84 + pDialogueWindow->pNumPresenceButton;
2494 v86 = (3 * (58 - v152) - v80) / 2 - v152 / 2 + 138;
2495 v24 = -pDialogueWindow->pNumPresenceButton < 0;
2496 _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
2497 if ( v24 ^ __OFSUB__(v84, v85) )
2498 {
2499 v153 = 2;
2500 do
2501 {
2502 v87 = v83->GetControl((unsigned int)_this);
2503 v88 = v87;
2504 v87->uY = v152 + v86;
2505 v89 = pFontArrus->CalcTextHeight(*v79, &v144, 0, 0);
2506 v90 = v88->uY;
2507 v91 = v153;
2508 v88->uHeight = v89;
2509 v86 = v90 + v89 - 1;
2510 v88->uW = v86;
2511 v92 = v147;
2512 if ( pDialogueWindow->pCurrentPosActiveItem != v91 )
2513 v92 = v148;
2514 v144.DrawTitleText(pFontArrus, 0, v90, v92, *v79, 3u);
2515 v83 = pDialogueWindow;
2516 ++v153;
2517 ++v79;
2518 _this = (Player *)((char *)_this + 1);
2519 }
2520 while ( (signed int)_this < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
2521 }
2522 return;
2523 }
2524 if ( dword_F8B19C != 95 )
2525 {
2526 if ( dword_F8B19C != 96 || !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2527 return;
2528 v152 = 0;
2529 v37 = pDialogueWindow;
2530 //v38 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
2531 v38 = (signed __int64)(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].flt_24 * 500.0);
2532 _this = (Player *)(v38 * (100 - v0->GetMerchant()) / 100);
2533 if ( (signed int)_this < v38 / 3 )
2534 _this = (Player *)(v38 / 3);
2535 v39 = v37->pStartingPosActiveItem;
2536 v40 = v37->pNumPresenceButton;
2537 v153 = 0;
2538 if ( (signed int)v39 < (signed int)(v39 + v40) )
2539 {
2540 do
2541 {
2542 v41 = v37->GetControl(v39)->uControlParam - 36;
2543 if ( byte_4ED970_skill_learn_ability_by_class_table[v0->uClass][v41] && !v0->pActiveSkills[v41] )
2544 {
2545 v42 = pFontArrus->CalcTextHeight(pSkillNames[v41], &v144, 0, 0);
2546 v152 += v42;
2547 ++v153;
2548 }
2549 ++v39;
2550 }
2551 while ( (signed int)v39 < v37->pNumPresenceButton + v37->pStartingPosActiveItem );
2552 if ( v153 )
2553 {
2554 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], _this);
2555 v144.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
2556 _this = (Player *)((149 - v152) / v153);
2557 if ( (149 - v152) / v153 > 32 )
2558 _this = (Player *)32;
2559 v43 = (149 - v153 * (signed int)_this - v152) / 2 - (signed int)_this / 2 + 162;
2560 v152 = v37->pStartingPosActiveItem;
2561 v146 = v43;
2562 if ( v152 < v152 + v37->pNumPresenceButton )
2563 {
2564 v153 = 2;
2565 do
2566 {
2567 v44 = v37->GetControl(v152);
2568 v45 = v44;
2569 v46 = v44->uControlParam - 36;
2570 if ( !byte_4ED970_skill_learn_ability_by_class_table[v0->uClass][v46] || v0->pActiveSkills[v46] )
2571 {
2572 v45->uW = 0;
2573 v45->uHeight = 0;
2574 v45->uY = 0;
2575 }
2576 else
2577 {
2578 v47 = pSkillNames[v46];
2579 v45->uY = (unsigned int)((char *)_this + v146);
2580 Str = v47;
2581 v48 = pFontArrus->CalcTextHeight(v47, &v144, 0, 0);
2582 v49 = v45->uY;
2583 v50 = v153;
2584 v45->uHeight = v48;
2585 v51 = v49 + v48 - 1;
2586 v45->uW = v51;
2587 v146 = v51;
2588 v52 = v147;
2589 if ( pDialogueWindow->pCurrentPosActiveItem != v50 )
2590 v52 = v148;
2591 v144.DrawTitleText(pFontArrus, 0, v49, v52, Str, 3u);
2592 }
2593 v53 = v37->pStartingPosActiveItem;
2594 ++v152;
2595 v54 = v37->pNumPresenceButton + v53;
2596 ++v153;
2597 }
2598 while ( v152 < v54 );
2599 }
2600 return;
2601 }
2602 }
2603 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);
2604 strcat(pTmpBuf, "\n \n");
2605 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
2606 v11 = 0;
2607 v36 = pTmpBuf;
2608 v123 = 3;
2609 v121 = pTmpBuf;
2610 v119 = v147;
2611 v117 = 0;
2612 v113 = 0;
2613 v111 = &v144;
2614 LABEL_63:
2615 v115 = (174 - pFontArrus->CalcTextHeight(v36, v111, v113, v117)) / 2 + 138;
2616 v112 = (unsigned int)v11;
2617 LABEL_14:
2618 v144.DrawTitleText(pFontArrus, v112, v115, v119, v121, v123);
2619 return;
2620 }
2621 LABEL_64:
2622 pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
2623 if ( dword_F8B19C == 2 )
2624 {
2625 v55 = 0;
2626 v153 = 0;
2627 do
2628 {
2629 if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
2630 {
2631 v56 = dword_F8B168[v55];
2632 if ( v55 >= 4 )
2633 {
2634 v60 = 90 - ((signed int)v56->uTextureWidth >> 1);
2635 pRenderer->DrawTextureTransparent(v60 + v153 - 420, 0x7Eu, dword_F8B168[v55]);
2636 v125 = v55 + 1;
2637 v59 = v60 + v153 + 80220;
2638 }
2639 else
2640 {
2641 v57 = 98 - v56->uTextureHeight;
2642 v58 = dword_F8B168[v55];
2643 v152 = 86 - ((signed int)v56->uTextureWidth >> 1);
2644 pRenderer->DrawTextureTransparent(v153 + v152, v57, v58);
2645 v125 = v55 + 1;
2646 v59 = v153 + v152 + 640 * v57;
2647 }
2648 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], dword_F8B168[v55], v125);
2649 }
2650 v153 += 105;
2651 ++v55;
2652 }
2653 while ( v55 < 8 );
2654 v11 = 0;
2655 }
2656 else
2657 {
2658 v11 = 0;
2659 v61 = 0;
2660 v153 = 0;
2661 do
2662 {
2663 if ( (char *)pParty->field_C59C[9 * (v61 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] != v11 )
2664 {
2665 v62 = dword_F8B168[v61];
2666 if ( v61 >= 4 )
2667 {
2668 v67 = 90 - ((signed int)v62->uTextureWidth >> 1);
2669 pRenderer->DrawTextureTransparent(v153 + v67 - 420, 0x7Eu, dword_F8B168[v61]);
2670 v126 = v61 + 1;
2671 v66 = v153 + v67 + 80220;
2672 }
2673 else
2674 {
2675 v63 = 98 - v62->uTextureHeight;
2676 v64 = dword_F8B168[v61];
2677 v65 = 98 - v62->uTextureHeight;
2678 v152 = 86 - ((signed int)v62->uTextureWidth >> 1);
2679 pRenderer->DrawTextureTransparent(v152 + v153, v65, v64);
2680 v126 = v61 + 1;
2681 v66 = v152 + v153 + 640 * v63;
2682 }
2683 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v66], dword_F8B168[v61], v126);
2684 v11 = 0;
2685 }
2686 v153 += 105;
2687 ++v61;
2688 }
2689 while ( v61 < 8 );
2690 }
2691 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2692 return;
2693 v68 = 0;
2694 v149 = (__int32)v11;
2695 if ( dword_F8B19C == 2 )
2696 {
2697 do
2698 {
2699 if ( (char *)pParty->field_777C[9 * (v68 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] != v11 )
2700 ++v149;
2701 ++v68;
2702 }
2703 while ( v68 < 6 );
2704 }
2705 else
2706 {
2707 do
2708 {
2709 if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] != v11 )
2710 ++v149;
2711 ++v68;
2712 }
2713 while ( v68 < 6 );
2714 }
2715 v69 = GetAsyncKeyState(17);
2716 v70 = _this->CanSteal();
2717 Str = (char *)v70;
2718 if ( v69 == (short)v11 || (char *)v70 == v11 )
2719 {
2720 v71 = pGlobalTXT_LocalizationStrings[195];
2721 if ( dword_F8B19C != 2 )
2722 v71 = pGlobalTXT_LocalizationStrings[196];
2723 }
2724 else
2725 {
2726 v71 = pGlobalTXT_LocalizationStrings[185];
2727 }
2728 sub_4B46A5(v71, 0);
2729 if ( (char *)v149 != v11 )
2730 {
2731 v73 = pMouse->GetCursorPos(&v136);
2732 v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v134)->y]] & 0xFFFF;
2733 if ( !v74 )
2734 return;
2735 v149 = v74 - 1;
2736 v75 = (int)ptr_507BC0->ptr_1C;
2737 v76 = 9 * (v74 - 1 + 12 * v75);
2738 if ( dword_F8B19C == 2 )
2739 v77 = (ItemGen *)&pParty->field_777C[v76];
2740 else
2741 v77 = (ItemGen *)&pParty->field_C59C[v76 + 724];
2742 if ( v69 == (short)v11 || Str == v11 )
2743 {
2744 v124 = (__int64 *)v11;
2745 v122 = 2;
2746 v120 = ptr_507BC0->ptr_1C;
2747 v116 = v77;
2748 v78 = uActiveCharacter - 1;
2749 v15 = (char *)pMerchantsBuyPhrases[_this->_490EEE(v77, 2, v75, 2)];
2750 v14 = v78;
2751 }
2752 else
2753 {
2754 v124 = (__int64 *)v11;
2755 v122 = 2;
2756 v120 = ptr_507BC0->ptr_1C;
2757 v116 = v77;
2758 v15 = pGlobalTXT_LocalizationStrings[181];
2759 v14 = uActiveCharacter - 1;
2760 }
2761 LABEL_36:
2762 v36 = sub_495461(v15, v14, v116, (char *)v120, v122, v124);
2763 v123 = 3;
2764 v121 = v36;
2765 v119 = v148;
2766 v117 = (int)v11;
2767 v113 = (int)v11;
2768 v111 = &v144;
2769 goto LABEL_63;
2770 }
2771 v72 = ptr_507BC0->ptr_1C;
2772 LABEL_96:
2773 v144._4B1854(
2774 __PAIR__(pParty->field_3C.field_50[2 * (int)v72 + 1], pParty->field_3C.field_50[2 * (int)v72])
2775 - pParty->uTimePlayed);
2776 return;
2777 }
2778 if ( dword_F8B19C == 5 )
2779 {
2780 draw_leather();
2781 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
2782 sub_4B46A5(pGlobalTXT_LocalizationStrings[198], 0);
2783 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
2784 || (v31 = pMouse->GetCursorPos(&v135)->x - 14,
2785 v149 = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5),
2786 pMouse->GetCursorPos(&v140)->x <= 13)
2787 || pMouse->GetCursorPos(&v138)->x >= 462
2788 || (v32 = v0->GetItemIDAtInventoryIndex((int *)&v149), v11 = 0, !v32)
2789 || (v33 = 9 * v32, !(v0->field_1F5[4 * v33 + 15] & 2)) )
2790 return;
2791 v124 = 0;
2792 v122 = 5;
2793 v120 = ptr_507BC0->ptr_1C;
2794 v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5];
2795 v34 = (int)ptr_507BC0->ptr_1C;
2796 uPlayerID = uActiveCharacter - 1;
2797 v35 = v0->_490EEE((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * v33 + 5], 2, v34, 5);
2798 v14 = uPlayerID;
2799 v15 = (char *)pMerchantsRepairPhrases[v35];
2800 goto LABEL_36;
2801 }
2802 if ( dword_F8B19C == 1 )
2803 {
2804 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2805 {
2806 v16 = pShopOptions;
2807 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
2808 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
2809 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
2810 v17 = 0;
2811 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
2812 v18 = pShopOptions;
2813 do
2814 {
2815 v19 = pFontArrus->CalcTextHeight(*v18, &v144, 0, 0);
2816 ++v18;
2817 v17 += v19;
2818 }
2819 while ( (signed int)v18 < (signed int)&unk_F8B1C8 );
2820 v20 = pDialogueWindow;
2821 v146 = (174 - v17) / 4;
2822 v21 = pDialogueWindow->pStartingPosActiveItem;
2823 v22 = v21 + pDialogueWindow->pNumPresenceButton;
2824 v23 = (174 - 4 * (174 - v17) / 4 - v17) / 2 - (174 - v17) / 4 / 2 + 138;
2825 v24 = -pDialogueWindow->pNumPresenceButton < 0;
2826 v152 = pDialogueWindow->pStartingPosActiveItem;
2827 if ( v24 ^ __OFSUB__(v21, v22) )
2828 {
2829 _this = (Player *)2;
2830 do
2831 {
2832 v25 = v20->GetControl(v152);
2833 v26 = v25;
2834 v25->uY = v146 + v23;
2835 v27 = pFontArrus->CalcTextHeight(*v16, &v144, 0, 0);
2836 v28 = v26->uY;
2837 v29 = _this;
2838 v26->uHeight = v27;
2839 v23 = v28 + v27 - 1;
2840 v26->uW = v23;
2841 v30 = v147;
2842 if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v29 )
2843 v30 = v148;
2844 v144.DrawTitleText(pFontArrus, 0, v28, v30, *v16, 3u);
2845 v20 = pDialogueWindow;
2846 _this = (Player *)((char *)_this + 1);
2847 ++v16;
2848 ++v152;
2849 }
2850 while ( v152 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
2851 }
2852 }
2853 return;
2854 }
2855 if ( dword_F8B19C == 2 )
2856 goto LABEL_64;
2857 if ( dword_F8B19C == 3 )
2858 {
2859 draw_leather();
2860 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
2861 sub_4B46A5(pGlobalTXT_LocalizationStrings[199], 0);
2862 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
2863 || (v9 = pMouse->GetCursorPos(&v139)->x - 14,
2864 v149 = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5),
2865 pMouse->GetCursorPos(&v137)->x <= 13)
2866 || pMouse->GetCursorPos(&v129)->x >= 462
2867 || (v10 = v0->GetItemIDAtInventoryIndex((int *)&v149), v11 = 0, !v10) )
2868 return;
2869 v124 = 0;
2870 v122 = 3;
2871 v120 = ptr_507BC0->ptr_1C;
2872 v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5];
2873 v12 = (int)ptr_507BC0->ptr_1C;
2874 uPlayerID = uActiveCharacter - 1;
2875 v13 = v0->_490EEE(v116, 2, v12, 3);
2876 v14 = uPlayerID;
2877 v15 = (char *)pMerchantsSellPhrases[v13];
2878 goto LABEL_36;
2879 }
2880 if ( dword_F8B19C == 4 )
2881 {
2882 draw_leather();
2883 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
2884 sub_4B46A5(pGlobalTXT_LocalizationStrings[197], 0);
2885 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2886 {
2887 v1 = pMouse->GetCursorPos(&a2)->x - 14;
2888 v149 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5);
2889 if ( pMouse->GetCursorPos(&v141)->x > 13 )
2890 {
2891 if ( pMouse->GetCursorPos(&v143)->x < 462 )
2892 {
2893 v2 = v0->GetItemIDAtInventoryIndex((int *)&v149);
2894 if ( v2 )
2895 {
2896 v3 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
2897 if ( v3->uAttributes & 1 )
2898 {
2899 v118 = ptr_507BC0->ptr_1C;
2900 v4 = uActiveCharacter - 1;
2901 v5 = "%24";
2902 v114 = v3;
2903 }
2904 else
2905 {
2906 v118 = ptr_507BC0->ptr_1C;
2907 v114 = v3;
2908 v7 = (int)ptr_507BC0->ptr_1C;
2909 uPlayerID = uActiveCharacter - 1;
2910 v8 = v0->_490EEE(v3, 2, v7, 4);
2911 v4 = uPlayerID;
2912 v5 = (char *)pMerchantsIdentifyPhrases[v8];
2913 }
2914 v6 = sub_495461(v5, v4, v114, (char *)v118, 4, 0);
2915 v123 = 3;
2916 v121 = v6;
2917 v119 = v148;
2918 v115 = (174 - pFontArrus->CalcTextHeight(v6, &v144, 0, 0)) / 2 + 138;
2919 v112 = 0;
2920 goto LABEL_14;
2921 }
2922 }
2923 }
2924 }
2925 }
2926 }
2927
2928 //----- (004BB756) --------------------------------------------------------
2929 signed int __fastcall sub_4BB756(signed int a1)
2930 {
2931 unsigned int v1; // esi@8
2932 unsigned int v3; // ecx@10
2933 char *v4; // esi@15
2934 int v5; // ebx@16
2935 int v6; // ST38_4@16
2936 char *v7; // esi@18
2937 int v8; // ebx@19
2938 int v9; // ST30_4@19
2939 int v10; // ST44_4@19
2940 int v11; // ST48_4@19
2941 int v12; // ST4C_4@19
2942 int v13; // ST50_4@19
2943 int v14; // ST3C_4@19
2944 int v15; // ST40_4@19
2945 int v16; // ST34_4@19
2946 int v17; // ST38_4@19
2947 Player *v18; // esi@21
2948 int v19; // eax@26
2949 int v20; // eax@39
2950 SoundID v21; // [sp-20h] [bp-54h]@25
2951 signed int v22; // [sp-1Ch] [bp-50h]@25
2952 unsigned int v23; // [sp-18h] [bp-4Ch]@25
2953 signed int v24; // [sp-14h] [bp-48h]@25
2954 signed int v25; // [sp-10h] [bp-44h]@25
2955 int v26; // [sp-10h] [bp-44h]@32
2956 int v27; // [sp-Ch] [bp-40h]@25
2957 unsigned int v28; // [sp-Ch] [bp-40h]@32
2958 unsigned int v29; // [sp-8h] [bp-3Ch]@25
2959 __int16 v30; // [sp-8h] [bp-3Ch]@32
2960 int v31; // [sp-4h] [bp-38h]@25
2961 int v32; // [sp-4h] [bp-38h]@32
2962
2963 if ( a1 > 39 )
2964 {
2965 if ( a1 != 40 )
2966 {
2967 if ( a1 == 41 )
2968 {
2969 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2970 {
2971 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
2972 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
2973 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2974 ++pMessageQueue_50CBD0->uNumMessages;
2975 }
2976 dword_50C9DC = 195;
2977 ptr_50C9E0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
2978 return 0;
2979 }
2980 if ( a1 == 42 )
2981 {
2982 v32 = 0;
2983 v30 = 0;
2984 v28 = 133;
2985 v26 = 46;
2986 }
2987 else
2988 {
2989 if ( a1 == 43 )
2990 {
2991 v32 = 0;
2992 v30 = 0;
2993 v28 = 133;
2994 v26 = 51;
2995 }
2996 else
2997 {
2998 if ( a1 != 52 )
2999 return 0;
3000 v32 = 0;
3001 v30 = 0;
3002 v28 = 133;
3003 v26 = 86;
3004 }
3005 }
3006 _42777D_CastSpell_UseWand_ShootArrow(v26, 0, v28, v30, v32);
3007 return 0;
3008 }
3009 v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
3010 pParty->pPartyBuffs[18].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0);
3011 pParty->pPartyBuffs[18].uFlags |= 1u;
3012 v31 = 0;
3013 v29 = 0;
3014 v27 = 0;
3015 v25 = 0;
3016 v24 = -1;
3017 v23 = 0;
3018 v22 = 0;
3019 v21 = (SoundID)12040;
3020 LABEL_40:
3021 pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31);
3022 return 0;
3023 }
3024 if ( a1 == 39 )
3025 {
3026 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
3027 {
3028 ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2u);
3029 v31 = 0;
3030 v29 = 0;
3031 v27 = 0;
3032 v25 = 0;
3033 v24 = -1;
3034 v23 = 0;
3035 v22 = 0;
3036 v21 = (SoundID)203;
3037 }
3038 else
3039 {
3040 v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
3041 pParty->pPartyBuffs[7].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0);
3042 pParty->pPartyBuffs[7].uFlags |= 1u;
3043 v31 = 0;
3044 v29 = 0;
3045 v27 = 0;
3046 v25 = 0;
3047 v24 = -1;
3048 v23 = 0;
3049 v22 = 0;
3050 v21 = (SoundID)11090;
3051 }
3052 goto LABEL_40;
3053 }
3054 if ( a1 == 10 )
3055 {
3056 v18 = pParty->pPlayers;
3057 do
3058 {
3059 v18->sHealth = v18->GetMaxHealth();
3060 ++v18;
3061 }
3062 while ( (signed int)v18 < (signed int)pParty->pHirelings );
3063 return 0;
3064 }
3065 if ( a1 == 11 )
3066 {
3067 v7 = (char *)&pParty->pPlayers[0].pConditions[15];
3068 do
3069 {
3070 v8 = *((int *)v7 - 2);
3071 v9 = *((int *)v7 - 1);
3072 v10 = *(int *)v7;
3073 v11 = *((int *)v7 + 1);
3074 v12 = *((int *)v7 + 2);
3075 v13 = *((int *)v7 + 3);
3076 v14 = *((int *)v7 + 8);
3077 v15 = *((int *)v7 + 9);
3078 v16 = *((int *)v7 + 4);
3079 v17 = *((int *)v7 + 5);
3080 memset(v7 - 120, 0, 0xA0u);
3081 *((int *)v7 + 2) = v12;
3082 *((int *)v7 + 3) = v13;
3083 *(int *)v7 = v10;
3084 *((int *)v7 + 1) = v11;
3085 *((int *)v7 - 1) = v9;
3086 *((int *)v7 + 8) = v14;
3087 *((int *)v7 + 9) = v15;
3088 *((int *)v7 + 4) = v16;
3089 *((int *)v7 - 2) = v8;
3090 *((int *)v7 + 5) = v17;
3091 *((int *)v7 + 1585) = ((Player *)(v7 - 120))->GetMaxHealth();
3092 v7 += 6972;
3093 }
3094 while ( (signed int)v7 < (signed int)&pParty->pHirelings[1].evtb );
3095 return 0;
3096 }
3097 if ( a1 == 12 )
3098 {
3099 v4 = (char *)&pParty->pPlayers[0].pActiveSkills[8];
3100 do
3101 {
3102 v5 = *((int *)v4 - 32);
3103 v6 = *((int *)v4 - 31);
3104 memset(v4 - 280, 0, 0xA0u);
3105 *(int *)v4 = v5;
3106 *((int *)v4 + 1) = v6;
3107 *((int *)v4 + 1545) = ((Player *)(v4 - 280))->GetMaxHealth();
3108 v4 += 6972;
3109 }
3110 while ( (signed int)v4 < (signed int)&pParty->field_777C[22] );
3111 return 0;
3112 }
3113 if ( a1 == 33 )
3114 {
3115 v1 = 14;
3116 if ( pParty->uNumFoodRations >= 0xE )
3117 return 1;
3118 v3 = 1;
3119 LABEL_13:
3120 Party::GiveFood(v3);
3121 if ( pParty->uNumFoodRations > v1 )
3122 pParty->uNumFoodRations = v1;
3123 return 0;
3124 }
3125 if ( a1 == 34 )
3126 {
3127 v1 = 14;
3128 if ( pParty->uNumFoodRations >= 0xE )
3129 return 1;
3130 v3 = 2;
3131 goto LABEL_13;
3132 }
3133 return 0;
3134 }
3135 // 50C9DC: using guessed type int dword_50C9DC;
3136
3137 //----- (004BBA85) --------------------------------------------------------
3138 const char *sub_4BBA85_bounties()
3139 {
3140 int v0; // edi@1
3141 signed __int64 v1; // qax@2
3142 int i; // eax@2
3143 int v3; // edx@3
3144 int v4; // edi@14
3145 __int16 v5; // ax@14
3146 char v6; // zf@14
3147 Player *v7; // ebx@16
3148 const char *result; // eax@19
3149
3150 uDialogueType = 83;
3151 pDialogueWindow->Release();
3152 pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
3153 pBtn_ExitCancel = pDialogueWindow->CreateButton(
3154 471u,
3155 445u,
3156 169u,
3157 35u,
3158 1,
3159 0,
3160 0x71u,
3161 0,
3162 0,
3163 pGlobalTXT_LocalizationStrings[34],// "Cancel"
3164 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
3165 0);
3166 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
3167 pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
3168 pDialogueWindow->_41D08F(1, 1, 0, 2);
3169 dword_F8B19C = -1;
3170 v0 = (int)((char *)ptr_507BC0->ptr_1C - 102);
3171 if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed )
3172 {
3173 pParty->field_75A[v0] = 0;
3174 v1 = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015))
3175 * 0.033333335);
3176 pParty->field_3C.field_0[2 * v0] = v1;
3177 pParty->field_3C.field_0[2 * v0 + 1] = HIDWORD(v1);
3178 for ( i = rand(); ; i = rand() )
3179 {
3180 v3 = i % 258 + 1;
3181 pParty->field_750[v0] = v3;
3182 if ( (unsigned __int16)v3 < 0x73u || (unsigned __int16)v3 > 0x84u )
3183 {
3184 if ( ((unsigned __int16)v3 < 0xEBu || (unsigned __int16)v3 > 0xFCu)
3185 && ((unsigned __int16)v3 < 0x85u || (unsigned __int16)v3 > 0x96u)
3186 && ((unsigned __int16)v3 < 0x97u || (unsigned __int16)v3 > 0xBAu)
3187 && ((unsigned __int16)v3 < 0xC4u || (unsigned __int16)v3 > 0xC6u) )
3188 break;
3189 }
3190 }
3191 }
3192 v4 = v0;
3193 v5 = pParty->field_750[v4];
3194 v6 = pParty->field_75A[v4] == 0;
3195 word_F8B1A0 = pParty->field_750[v4];
3196 if ( v6 )
3197 {
3198 v6 = v5 == 0;
3199 result = pNPCTopics[351].pText;
3200 if ( v6 )
3201 result = pNPCTopics[353].pText;
3202 }
3203 else
3204 {
3205 if ( v5 )
3206 {
3207 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v5].uLevel, 0);
3208 v7 = pParty->pPlayers;
3209 do
3210 {
3211 v7->SetVariable(VAR_Award, 86);
3212 ++v7;
3213 }
3214 while ( (signed int)v7 < (signed int)pParty->pHirelings );
3215 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v4]].uLevel;
3216 pParty->field_750[v4] = 0;
3217 pParty->field_75A[v4] = 0;
3218 }
3219 result = pNPCTopics[352].pText;
3220 }
3221 dword_F8B1A4 = (char *)result;
3222 return result;
3223 }
3224
3225 //----- (004BBCDD) --------------------------------------------------------
3226 void __cdecl sub_4BBCDD()
3227 {
3228 signed int v0; // ebp@3
3229 char *v1; // eax@4
3230 __int16 v2; // cx@5
3231 int v3; // esi@8
3232 Player *v4; // esi@14
3233 GUIButton *v5; // eax@18
3234 GUIButton *v6; // esi@19
3235 size_t v7; // [sp+10h] [bp-4h]@4
3236
3237 if ( pParty->field_7B5_in_arena_quest )
3238 {
3239 if ( pParty->field_7B5_in_arena_quest == -1 )
3240 {
3241 uDialogueType = 92;
3242 }
3243 else
3244 {
3245 v0 = 0;
3246 if ( (signed int)uNumActors <= 0 )
3247 goto LABEL_23;
3248 v1 = (char *)&pActors[0].uAIState;
3249 v7 = uNumActors;
3250 do
3251 {
3252 v2 = *(short *)v1;
3253 if ( *(short *)v1 == 5 || v2 == 11 || v2 == 19 || (v3 = *((int *)v1 + 159)) != 0 && (v3 & 7) == 4 )
3254 ++v0;
3255 v1 += 836;
3256 --v7;
3257 }
3258 while ( v7 );
3259 if ( v0 >= (signed int)uNumActors )
3260 {
3261 LABEL_23:
3262 uDialogueType = 91;
3263 v4 = pParty->pPlayers;
3264 ++*((char *)&pParty->field_75A[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1);
3265 do
3266 {
3267 v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3);
3268 ++v4;
3269 }
3270 while ( (signed int)v4 < (signed int)pParty->pHirelings );
3271 party_finds_gold(dword_F8B1B4, 0);
3272 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0);
3273 pParty->field_7B5_in_arena_quest = -1;
3274 }
3275 else
3276 {
3277 uDialogueType = 90;
3278 pParty->vPosition.x = 3849;
3279 pParty->vPosition.y = 5770;
3280 pParty->vPosition.z = 1;
3281 pParty->uFallStartY = 1;
3282 pParty->sRotationY = 512;
3283 pParty->sRotationX = 0;
3284 pParty->uFallSpeed = 0;
3285 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0);
3286 }
3287 }
3288 }
3289 else
3290 {
3291 uDialogueType = 89;
3292 v5 = pDialogueWindow->pControlsHead;
3293 if ( v5 )
3294 {
3295 do
3296 {
3297 v6 = v5->pNext;
3298 pAllocator->FreeChunk(v5);
3299 v5 = v6;
3300 }
3301 while ( v6 );
3302 }
3303 pDialogueWindow->pControlsHead = 0;
3304 pDialogueWindow->pControlsTail = 0;
3305 pDialogueWindow->uNumControls = 0;
3306 pBtn_ExitCancel = pDialogueWindow->CreateButton(
3307 0x1D7u,
3308 0x1BDu,
3309 0xA9u,
3310 0x23u,
3311 1,
3312 0,
3313 0x71u,
3314 0,
3315 0,
3316 pGlobalTXT_LocalizationStrings[79],
3317 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
3318 0);
3319 pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0);
3320 pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0);
3321 pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0);
3322 pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x58u, 0, "", 0);
3323 pDialogueWindow->_41D08F(4, 1, 0, 1);
3324 }
3325 }
3326 // F8B1B4: using guessed type int dword_F8B1B4;
3327
3328 //----- (004BBF61) --------------------------------------------------------
3329 void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z)
3330 {
3331 size_t v4; // esi@1
3332 int monster_id; // edi@1
3333 __int16 v6; // ax@4
3334 Actor *v7; // esi@5
3335 int v8; // eax@5
3336 MonsterInfo *v9; // edi@5
3337 MonsterDesc *v10; // ebx@5
3338 unsigned __int16 *v11; // ebx@5
3339 int v12; // ebx@7
3340 int v13; // eax@8
3341 __int16 x_; // [sp+8h] [bp-Ch]@1
3342 __int16 v15; // [sp+Ch] [bp-8h]@1
3343 __int16 v16; // [sp+10h] [bp-4h]@3
3344 signed int ya; // [sp+1Ch] [bp+8h]@5
3345
3346 v4 = uNumActors;
3347 monster_id = a1;
3348 x_ = x;
3349 v15 = a1;
3350 if ( (signed int)uNumActors < 500
3351 && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 )
3352 {
3353 v16 = 0;
3354 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
3355 {
3356 v6 = pIndoor->GetSector(x, y, z);
3357 v4 = uNumActors;
3358 v16 = v6;
3359 }
3360 v7 = &pActors[v4];
3361 v7->Reset();
3362 v8 = monster_id;
3363 v9 = &pMonsterStats->pInfos[monster_id];
3364 v10 = &pMonsterList->pMonsters[v8 - 1];
3365 strcpy(v7->pActorName, v9->pName);
3366 v7->sCurrentHP = LOWORD(v9->uHP);
3367 memcpy(&v7->pMonsterInfo, v9, 0x58u);
3368 v7->word_000086_some_monster_id = v15;
3369 v7->uActorRadius = v10->uMonsterRadius;
3370 v7->uActorHeight = v10->uMonsterHeight;
3371 v7->uMovementSpeed = v10->uMovementSpeed;
3372 v7->vInitialPosition.x = x_;
3373 v7->vPosition.x = x_;
3374 BYTE2(v7->uAttributes) |= 8u;
3375 v7->pMonsterInfo.uTreasureType = 0;
3376 v7->pMonsterInfo.uTreasureLevel = 0;
3377 v7->pMonsterInfo.uTreasureDiceSides = 0;
3378 v7->pMonsterInfo.uTreasureDiceRolls = 0;
3379 v7->pMonsterInfo.uTreasureDropChance = 0;
3380 v7->vInitialPosition.y = y;
3381 v7->vPosition.y = y;
3382 v7->vInitialPosition.z = z;
3383 v7->vPosition.z = z;
3384 v7->uTetherDistance = 256;
3385 v7->uSectorID = v16;
3386 v7->uGroup = 1;
3387 v7->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
3388 v7->PrepareSprites(0);
3389 v11 = v10->pSoundSampleIDs;
3390 ya = 4;
3391 do
3392 {
3393 pSoundList->LoadSound((signed __int16)*v11, 0);
3394 ++v11;
3395 --ya;
3396 }
3397 while ( ya );
3398 v12 = 0;
3399 do
3400 LOWORD(v13) = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v9->uSpell1ID], 1u);
3401 while ( v13 );
3402 ++uNumActors;
3403 }
3404 }
3405 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
3406
3407 //----- (004BC109) --------------------------------------------------------
3408 void __cdecl ArenaFight()
3409 {
3410 int v0; // edi@1
3411 char *v1; // eax@7
3412 Player *v2; // edi@9
3413 int v3; // eax@10
3414 signed int v4; // esi@10
3415 signed __int64 v5; // qax@18
3416 signed int v6; // ebx@34
3417 char *v7; // edi@34
3418 int v8; // eax@37
3419 int v9; // esi@43
3420 int v10; // eax@44
3421 unsigned __int8 v11; // sf@44
3422 unsigned __int8 v12; // of@44
3423 signed int v13; // eax@49
3424 int v14; // esi@49
3425 int v15; // edx@50
3426 int v16; // eax@51
3427 signed int v17; // ecx@51
3428 int v18; // edx@53
3429 int i; // edi@55
3430 int monster_y; // ST18_4@56
3431 int v21; // eax@56
3432 signed int v22; // [sp-4h] [bp-144h]@51
3433 __int16 v23[100]; // [sp+Ch] [bp-134h]@39
3434 GUIWindow window; // [sp+D4h] [bp-6Ch]@1
3435 __int16 monster_ids[6]; // [sp+128h] [bp-18h]@56
3436 int v26; // [sp+134h] [bp-Ch]@1
3437 int v27; // [sp+138h] [bp-8h]@23
3438 int num_monsters; // [sp+13Ch] [bp-4h]@17
3439
3440 v26 = 0;
3441 pParty->field_7B5_in_arena_quest = uDialogueType;
3442 memcpy(&window, pDialogueWindow, sizeof(window));
3443 window.uFrameWidth = 460;
3444 window.uFrameZ = 452;
3445 v0 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[575], &window, 13, 0) + 7;
3446 pRenderer->BeginSceneD3D();
3447
3448 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
3449 pIndoor->Draw();
3450 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
3451 pOutdoor->Draw();
3452
3453 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
3454 pRenderer->BeginScene();
3455 if ( pRenderer->pRenderD3D )
3456 pRenderer->FillRectFast(
3457 pViewport->uViewportX,
3458 pViewport->uViewportY,
3459 pViewport->uViewportZ - pViewport->uViewportX,
3460 pViewport->uViewportW - pViewport->uViewportY + 1,
3461 pRenderer->uTargetGMask | pRenderer->uTargetBMask);
3462
3463 auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
3464 pRenderer->_4A6A68(
3465 8u,
3466 352 - v0,
3467 pTex,
3468 (pTex ? pTex->uTextureHeight : 26) - v0);
3469
3470 pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428);
3471 v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);
3472 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v0, 0, v1, 0, 0, 0);
3473 pRenderer->EndScene();
3474 pRenderer->Present();
3475 pParty->vPosition.x = 3849;
3476 pParty->vPosition.y = 5770;
3477 pParty->vPosition.z = 1;
3478 pParty->uFallStartY = 1;
3479 pParty->sRotationY = 512;
3480 pParty->sRotationX = 0;
3481 pParty->uFallSpeed = 0;
3482 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3483 {
3484 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
3485 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
3486 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
3487 ++pMessageQueue_50CBD0->uNumMessages;
3488 }
3489 v2 = pParty->pPlayers;
3490 do
3491 {
3492 v3 = v2->GetActualLevel();
3493 v4 = v26;
3494 if ( v3 > v26 )
3495 {
3496 v26 = v2->GetActualLevel();
3497 v4 = v26;
3498 }
3499 ++v2;
3500 }
3501 while ( (signed int)v2 < (signed int)pParty->pHirelings );
3502 if ( uDialogueType == 85 )
3503 {
3504 num_monsters = v4;
3505 goto LABEL_22;
3506 }
3507 if ( uDialogueType == 86 )
3508 {
3509 v5 = (signed __int64)((double)v26 * 1.5);
3510 goto LABEL_20;
3511 }
3512 if ( uDialogueType == 87 )
3513 {
3514 LODWORD(v5) = 2 * v4;
3515 LABEL_20:
3516 num_monsters = v5;
3517 LABEL_22:
3518 v4 /= 2;
3519 goto LABEL_24;
3520 }
3521 if ( uDialogueType == 88 )
3522 num_monsters = 2 * v4;
3523 else
3524 v4 = v27;
3525 LABEL_24:
3526 if ( v4 < 1 )
3527 v4 = 1;
3528 if ( v4 > 100 )
3529 v4 = 100;
3530 if ( num_monsters > 100 )
3531 num_monsters = 100;
3532 if ( v4 < 2 )
3533 v4 = 2;
3534 if ( num_monsters < 2 )
3535 num_monsters = 2;
3536 v6 = 0;
3537 v27 = 1;
3538 v7 = (char *)&pMonsterStats->pInfos[1].uLevel;
3539 do
3540 {
3541 if ( v7[8] != 1 )
3542 {
3543 if ( !MonsterStats::BelongsToSupertype(*((short *)v7 + 22), MONSTER_SUPERTYPE_8) )
3544 {
3545 v8 = (unsigned __int8)*v7;
3546 if ( v8 >= v4 )
3547 {
3548 if ( v8 <= num_monsters )
3549 v23[v6++] = v27;
3550 }
3551 }
3552 }
3553 ++v27;
3554 v7 += 88;
3555 }
3556 while ( (signed int)v7 <= (signed int)&pMonsterStats->pInfos[258].uLevel );
3557 num_monsters = 6;
3558 if ( v6 < 6 )
3559 num_monsters = v6;
3560 v9 = 0;
3561 if ( num_monsters > 0 )
3562 {
3563 do
3564 {
3565 v10 = rand();
3566 ++v9;
3567 v12 = __OFSUB__(v9, num_monsters);
3568 v11 = v9 - num_monsters < 0;
3569 *((short *)&window.pControlsTail + v9 + 1) = v23[v10 % v6];
3570 }
3571 while ( v11 ^ v12 );
3572 }
3573 if ( uDialogueType == 85 )
3574 {
3575 v16 = rand();
3576 v17 = 3;
3577 v22 = 50;
3578 goto LABEL_53;
3579 }
3580 if ( uDialogueType == 86 )
3581 {
3582 v16 = rand();
3583 v17 = 7;
3584 v22 = 100;
3585 LABEL_53:
3586 v18 = v16 % v17;
3587 v13 = v22;
3588 v14 = v18 + 6;
3589 goto LABEL_55;
3590 }
3591 if ( uDialogueType == 87 )
3592 {
3593 v15 = rand() % 11;
3594 v13 = 200;
3595 v14 = v15 + 10;
3596 }
3597 else
3598 {
3599 if ( uDialogueType == 88 )
3600 {
3601 v13 = 500;
3602 v14 = 20;
3603 }
3604 else
3605 {
3606 v14 = v27;
3607 v13 = dword_F8B1B4;
3608 }
3609 }
3610 LABEL_55:
3611 i = 0;
3612 for ( dword_F8B1B4 = v26 * v13; i < v14; ++i )
3613 {
3614 monster_y = pMonsterArenaPlacements[i].y;
3615 v21 = rand();
3616 _4BBF61_summon_actor((unsigned __int16)monster_ids[v21 % num_monsters], pMonsterArenaPlacements[i].x, monster_y, 1);
3617 }
3618 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0);
3619 }
3620
3621
3622
3623
3624
3625 //----- (004BC8D5) --------------------------------------------------------
3626 Texture *__cdecl sub_4BC8D5()
3627 {
3628 int v0; // esi@1
3629 char *v1; // ebx@1
3630 signed int v2; // edi@1
3631 signed int v3; // eax@2
3632 int v4; // esi@7
3633 GUIWindow *v5; // ebp@15
3634 Texture *result; // eax@15
3635 int v7; // [sp+10h] [bp-4h]@0
3636
3637 v0 = v7;
3638 v1 = (char *)ptr_507BC0->ptr_1C - 139;
3639 v2 = 0;
3640 do
3641 {
3642 //v3 = p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C];
3643 v3 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].uType;
3644 if ( v3 < 5 )
3645 goto LABEL_12;
3646 if ( v3 <= 13 )
3647 {
3648 v0 = rand() % word_4F0F30[(signed int)v1]
3649 //+ 11 * p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]
3650 + 11 * p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].uType
3651 + 345;
3652 }
3653 else
3654 {
3655 if ( v3 == 14 )
3656 {
3657 v4 = rand() % 4;
3658 }
3659 else
3660 {
3661 if ( v3 == 15 )
3662 {
3663 v4 = rand() % 3 + 4;
3664 }
3665 else
3666 {
3667 if ( v3 != 16 )
3668 goto LABEL_12;
3669 v4 = rand() % 2 + 7;
3670 }
3671 }
3672 v0 = rand() % word_4F0F30[(signed int)v1] + 11 * v4 + 400;
3673 }
3674 LABEL_12:
3675 if ( v0 == 487 )
3676 {
3677 if ( !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) )
3678 v0 = 486;
3679 }
3680 v5 = ptr_507BC0;
3681
3682 auto _u = (ItemGen *)&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + v2 + 12 * (unsigned int)ptr_507BC0->ptr_1C;
3683 _u->Reset();
3684 *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v2 + 12 * (unsigned int)v5->ptr_1C)) = v0;
3685 *(&pParty->pPlayers[1].pInstalledBeacons[1].field_10 + 9 * (v2++ + 12 * (unsigned int)v5->ptr_1C)) = 1;
3686 result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[v0].pIconName, TEXTURE_16BIT_PALETTE)];
3687 *(&dword_F8B164 + v2) = result;
3688 }
3689 while ( v2 < 12 );
3690 return result;
3691 }
3692
3693
3694 //----- (004BCA33) --------------------------------------------------------
3695 GUIButton *__cdecl sub_4BCA33()
3696 {
3697 pDialogueWindow->Release();
3698 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
3699 pBtn_ExitCancel = pDialogueWindow->CreateButton(
3700 0x1D7u,
3701 0x1BDu,
3702 0xA9u,
3703 0x23u,
3704 1,
3705 0,
3706 0x71u,
3707 0,
3708 0,
3709 pGlobalTXT_LocalizationStrings[74],
3710 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
3711 0);
3712 return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
3713 }
3714
3715 //----- (004BCACC) --------------------------------------------------------
3716 void __fastcall sub_4BCACC_bounties(signed int a1)
3717 {
3718 unsigned int v1; // edi@1
3719 signed int v2; // ebx@1
3720 signed int v3; // ecx@2
3721 int v4; // eax@5
3722 signed int v5; // esi@5
3723 Player *v6; // ecx@5
3724 signed int v7; // edx@5
3725 GUIWindow *v8; // esi@10
3726 unsigned int v9; // eax@12
3727 int v10; // esi@31
3728 int v11; // edi@31
3729 int v12; // esi@32
3730 __int16 v13; // bp@32
3731 int v14; // edx@32
3732 GUIWindow *v15; // eax@32
3733 int v16; // eax@32
3734 int v17; // eax@33
3735 int v18; // eax@34
3736 int v19; // eax@35
3737 __int16 v20; // ax@37
3738 __int16 v21; // ax@76
3739 __int16 v22; // ax@107
3740 __int16 v23; // ax@132
3741 __int16 v24; // ax@163
3742 int v25; // esi@190
3743 __int16 v26; // ax@190
3744 char v27; // zf@190
3745 Player *v28; // edi@192
3746 int v29; // eax@204
3747 void *v30; // esi@208
3748 unsigned __int64 v31; // qax@208
3749 signed int v32; // edi@209
3750 int v33; // eax@210
3751 unsigned int v34; // eax@211
3752 Player *v35; // edi@227
3753 signed int v36; // esi@227
3754 int v37; // ecx@227
3755 int v38; // esi@230
3756 int v39; // edx@235
3757 void *v40; // edi@243
3758 unsigned __int64 v41; // qax@243
3759 void *v42; // eax@244
3760 signed int v43; // edi@244
3761 int v44; // edx@244
3762 int v45; // eax@246
3763 unsigned int v46; // eax@247
3764 void *v47; // eax@250
3765 signed int v48; // edi@250
3766 int v49; // eax@252
3767 int v50; // eax@256
3768 unsigned int v51; // eax@257
3769 void *v52; // eax@260
3770 signed int v53; // edi@260
3771 int v54; // eax@262
3772 signed int v55; // [sp+10h] [bp-10h]@1
3773 int v56; // [sp+14h] [bp-Ch]@31
3774
3775 v1 = 0;
3776 v2 = a1;
3777 v55 = a1;
3778 if ( !pDialogueWindow->pNumPresenceButton )
3779 return;
3780 pRenderer->ClearZBuffer(0, 479);
3781 v3 = dword_F8B198;
3782 if ( dword_F8B19C != 1 )
3783 goto LABEL_13;
3784 if ( dword_F8B198 == 30 )
3785 {
3786 if ( v2 == 17 )
3787 {
3788 v4 = 0;
3789 v5 = 0;
3790 v6 = pPlayers[uActiveCharacter];
3791 v7 = v6->uLevel;
3792 if ( v7 > 0 )
3793 {
3794 do
3795 v4 += v5++ + 1;
3796 while ( v5 < v7 );
3797 }
3798 if ( v7 < (unsigned __int16)word_4F0866[(unsigned int)ptr_507BC0->ptr_1C]
3799 && (signed __int64)v6->uExperience < 1000 * v4 )
3800 return;
3801 }
3802 goto LABEL_9;
3803 }
3804 v8 = ptr_507BC0;
3805 if ( (dword_F8B198 == 27 || dword_F8B198 == 28)
3806 && (v1 = 0,
3807 *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)ptr_507BC0->ptr_1C] + v2)]
3808 + pParty->uDaysPlayed % 7))
3809 || dword_F8B198 != 23
3810 || v55 != 10 )
3811 {
3812 LABEL_9:
3813 pDialogueWindow->Release();
3814 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1);
3815 pBtn_ExitCancel = pDialogueWindow->CreateButton(
3816 526,
3817 445,
3818 75,
3819 33,
3820 1,
3821 v1,
3822 0x71u,
3823 v1,
3824 v1,
3825 pGlobalTXT_LocalizationStrings[74],// "End Conversation"
3826 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
3827 v1);
3828 pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1);
3829 LABEL_10:
3830 v3 = dword_F8B198;
3831 v8 = ptr_507BC0;
3832 goto LABEL_11;
3833 }
3834 if ( uActiveCharacter != v1 )
3835 {
3836 if ( !pPlayers[uActiveCharacter]->_4B6FF9() )
3837 return;
3838 goto LABEL_10;
3839 }
3840 LABEL_11:
3841 dword_F8B19C = v55;
3842 if ( v3 < 19 )
3843 {
3844 v9 = pIcons_LOD->LoadTexture(off_4F03B8[v3], TEXTURE_16BIT_PALETTE);
3845 v3 = dword_F8B198;
3846 dword_F8B164 = &pIcons_LOD->pTextures[v9];
3847 LABEL_13:
3848 v8 = ptr_507BC0;
3849 }
3850 if ( v3 > 21 )
3851 {
3852 if ( v3 == 22 )
3853 {
3854 if ( dword_F8B19C >= 7 && dword_F8B19C <= 8 )
3855 pKeyActionMap->_459E5A(1, 10, v8);
3856 return;
3857 }
3858 if ( v3 != 23 && v3 != 30 )
3859 return;
3860 }
3861 else
3862 {
3863 if ( v3 != 21 )
3864 {
3865 if ( v3 <= (signed int)v1 )
3866 return;
3867 if ( v3 > 4 )
3868 {
3869 if ( v3 <= 16 )
3870 {
3871 if ( (signed __int64)__PAIR__(
3872 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
3873 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed )
3874 {
3875 v32 = 0;
3876 do
3877 {
3878 v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
3879 if ( v33 )
3880 {
3881 v34 = pIcons_LOD->LoadTexture(
3882 pItemsTable->pItems[v33].pIconName,
3883 TEXTURE_16BIT_PALETTE);
3884 v8 = ptr_507BC0;
3885 dword_F8B168[v32] = &pIcons_LOD->pTextures[v34];
3886 }
3887 ++v32;
3888 }
3889 while ( v32 < 12 );
3890 }
3891 else
3892 {
3893 sub_4BC8D5();
3894 v30 = ptr_507BC0->ptr_1C;
3895 v31 = pParty->uTimePlayed
3896 + (signed __int64)((double)(0xA8C000
3897 //* (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
3898 * (signed int)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].field_1C)
3899 * 0.033333335);
3900 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31;
3901 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31);
3902 }
3903 return;
3904 }
3905 if ( v3 != 17 )
3906 return;
3907 if ( v55 == 99 )
3908 {
3909 v10 = (int)((char *)v8->ptr_1C - 102);
3910 v56 = v10;
3911 v11 = 8 * v10 + 11325428;
3912 if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed )
3913 {
3914 v13 = 0;
3915 }
3916 else
3917 {
3918 v12 = v10;
3919 v13 = 0;
3920 pParty->field_75A[v12] = 0;
3921 *(_QWORD *)v11 = (signed __int64)((double)(309657600
3922 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015))
3923 * 0.033333335);
3924 v14 = rand() % 258;
3925 v15 = ptr_507BC0;
3926 pParty->field_750[v12] = v14 + 1;
3927 v16 = (int)((char *)v15->ptr_1C - 102);
3928 if ( v16 )
3929 {
3930 v17 = v16 - 1;
3931 if ( v17 )
3932 {
3933 v18 = v17 - 1;
3934 if ( v18 )
3935 {
3936 v19 = v18 - 1;
3937 if ( v19 )
3938 {
3939 if ( v19 == 1 )
3940 {
3941 while ( 1 )
3942 {
3943 v20 = pParty->field_750[v12];
3944 if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
3945 {
3946 if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
3947 && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
3948 && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
3949 && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
3950 && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
3951 && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
3952 && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
3953 && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
3954 && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
3955 && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
3956 && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
3957 && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
3958 && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
3959 && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
3960 && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
3961 && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
3962 && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
3963 && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
3964 break;
3965 }
3966 pParty->field_750[v12] = rand() % 258 + 1;
3967 }
3968 }
3969 }
3970 else
3971 {
3972 while ( 1 )
3973 {
3974 v21 = pParty->field_750[v12];
3975 if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
3976 {
3977 if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
3978 && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
3979 && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
3980 && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
3981 && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
3982 && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
3983 && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
3984 && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
3985 && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
3986 && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
3987 && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
3988 && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
3989 && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
3990 && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
3991 break;
3992 }
3993 pParty->field_750[v12] = rand() % 258 + 1;
3994 }
3995 }
3996 }
3997 else
3998 {
3999 while ( 1 )
4000 {
4001 v22 = pParty->field_750[v12];
4002 if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
4003 {
4004 if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
4005 && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
4006 && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
4007 && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
4008 && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
4009 && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
4010 && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
4011 && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
4012 && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
4013 && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
4014 && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
4015 break;
4016 }
4017 pParty->field_750[v12] = rand() % 258 + 1;
4018 }
4019 }
4020 }
4021 else
4022 {
4023 while ( 1 )
4024 {
4025 v23 = pParty->field_750[v12];
4026 if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
4027 {
4028 if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
4029 && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
4030 && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
4031 && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
4032 && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
4033 && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
4034 && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
4035 && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
4036 && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
4037 && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
4038 && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
4039 && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
4040 && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
4041 && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
4042 break;
4043 }
4044 pParty->field_750[v12] = rand() % 258 + 1;
4045 }
4046 }
4047 }
4048 else
4049 {
4050 while ( 1 )
4051 {
4052 v24 = pParty->field_750[v12];
4053 if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
4054 {
4055 if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
4056 && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
4057 && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
4058 && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
4059 && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
4060 && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
4061 && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
4062 && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
4063 && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
4064 && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
4065 && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
4066 break;
4067 }
4068 pParty->field_750[v12] = rand() % 258 + 1;
4069 }
4070 }
4071 v10 = v56;
4072 }
4073 v25 = v10;
4074 v26 = pParty->field_750[v25];
4075 v27 = pParty->field_75A[v25] == v13;
4076 word_F8B1A0 = pParty->field_750[v25];
4077 if ( v27 )
4078 {
4079 v1 = 0;
4080 v27 = v26 == v13;
4081 v29 = (int)pNPCTopics[351].pText;
4082 if ( v27 )
4083 v29 = (int)pNPCTopics[353].pText;
4084 dword_F8B1A4 = (char *)v29;
4085 }
4086 else
4087 {
4088 if ( v26 != v13 )
4089 {
4090 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
4091 v28 = pParty->pPlayers;
4092 do
4093 {
4094 v28->SetVariable(VAR_Award, 86);
4095 ++v28;
4096 }
4097 while ( (signed int)v28 < (signed int)pParty->pHirelings );
4098 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
4099 pParty->field_750[v25] = v13;
4100 pParty->field_75A[v25] = v13;
4101 }
4102 v1 = 0;
4103 dword_F8B1A4 = pNPCTopics[352].pText;
4104 }
4105 goto LABEL_196;
4106 }
4107 if ( v55 == 100 )
4108 {
4109 pKeyActionMap->_459E5A(1, 10, v8);
4110 goto LABEL_196;
4111 }
4112 }
4113 }
4114 }
4115 if ( v55 > 95 )
4116 {
4117 LABEL_196:
4118 switch ( v55 )
4119 {
4120 case 96:
4121 pDialogueWindow->eWindowType = WINDOW_MainMenu;
4122 sub_4BCA33();
4123 sub_4B3703((void *)dword_F8B198);
4124 break;
4125 case 101:
4126 pDialogueWindow->eWindowType = WINDOW_MainMenu;
4127 sub_4BCA33();
4128 sub_4B3A72(dword_F8B198);
4129 break;
4130 case 102:
4131 dword_F8B19C = 102;
4132 break;
4133 case 103:
4134 dword_F8B19C = 103;
4135 break;
4136 case 104:
4137 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
4138 {
4139 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)29;
4140 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v1;
4141 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
4142 ++pMessageQueue_50CBD0->uNumMessages;
4143 }
4144 dword_F8B19C = 104;
4145 break;
4146 }
4147 return;
4148 }
4149 if ( v55 != 95 && v55 != 2 )
4150 {
4151 if ( v55 == 3 )
4152 {
4153 dword_F8B19C = 3;
4154 }
4155 else
4156 {
4157 if ( v55 == 4 )
4158 {
4159 dword_F8B19C = 4;
4160 }
4161 else
4162 {
4163 if ( v55 != 5 )
4164 {
4165 if ( v55 > 35 )
4166 {
4167 if ( v55 <= 72 )
4168 {
4169 v35 = pPlayers[uActiveCharacter];
4170 //v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0);
4171 v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0);
4172 v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
4173 if ( v37 < v36 / 3 )
4174 v37 = v36 / 3;
4175
4176 __debugbreak();
4177 //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
4178 // or
4179 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
4180 // or
4181 //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
4182
4183 if (false)
4184 //if ( *(&byte_4ED94C[37 * v35->uClass] + v55) )
4185 {
4186 v38 = (int)(&v35->uIntelligence + v55);
4187 if ( !*(short *)v38 )
4188 {
4189 if ( pParty->uNumGold < v37 )
4190 {
4191 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
4192 if ( dword_F8B198 == 30 || dword_F8B198 == 21 )
4193 v39 = 4;
4194 else
4195 v39 = 2;
4196 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v39);
4197 }
4198 else
4199 {
4200 Party::TakeGold(v37);
4201 dword_F8B1E4 = 1;
4202 *(short *)v38 = 1;
4203 v35->PlaySound(78, 0);
4204 }
4205 }
4206 }
4207 }
4208 else
4209 {
4210 if ( v55 == 94 )
4211 {
4212 pDialogueWindow->eWindowType = WINDOW_MainMenu;
4213 sub_4BCA33();
4214 sub_4B3AD4(dword_F8B198);
4215 }
4216 }
4217 }
4218 return;
4219 }
4220 dword_F8B19C = 5;
4221 }
4222 }
4223 sub_421B2C_PlaceInInventory_or_DropPickedItem();
4224 return;
4225 }
4226 if ( (signed __int64)__PAIR__(
4227 pParty->field_3C.field_50[2 * (unsigned int)v8->ptr_1C + 1],
4228 pParty->field_3C.field_50[2 * (unsigned int)v8->ptr_1C]) < (signed __int64)pParty->uTimePlayed )
4229 {
4230 GenerateShopItems();
4231 sub_4B8F94();
4232 v8 = ptr_507BC0;
4233 v40 = ptr_507BC0->ptr_1C;
4234 v3 = dword_F8B198;
4235 v41 = pParty->uTimePlayed
4236 //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
4237 + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].field_1C)
4238 * 0.033333335);
4239 pParty->field_3C.field_50[2 * (int)v40] = v41;
4240 pParty->field_3C.field_50[2 * (int)v40 + 1] = HIDWORD(v41);
4241 }
4242 v42 = v8->ptr_1C;
4243 v43 = 0;
4244 //v44 = p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C];
4245 v44 = p2DEvents[(unsigned int)v8->ptr_1C - 1].uType;
4246 if ( v55 == 2 )
4247 {
4248 if ( _4F063C_smthn_by_2da_uType[v44] )
4249 {
4250 do
4251 {
4252 v45 = pParty->field_777C[9 * (v43 + 12 * (int)v42)];
4253 if ( v45 )
4254 {
4255 v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v45].pIconName, TEXTURE_16BIT_PALETTE);
4256 v3 = dword_F8B198;
4257 v8 = ptr_507BC0;
4258 dword_F8B168[v43] = &pIcons_LOD->pTextures[v46];
4259 }
4260 v42 = v8->ptr_1C;
4261 ++v43;
4262 }
4263 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
4264 while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
4265 }
4266 if ( v3 == 1 )
4267 {
4268 v47 = v8->ptr_1C;
4269 v48 = 0;
4270 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
4271 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
4272 {
4273 do
4274 {
4275 if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] )
4276 {
4277 v49 = rand();
4278 v8 = ptr_507BC0;
4279 word_F8B158[v48] = v49 % (300 - dword_F8B168[v48]->uTextureHeight);
4280 }
4281 v47 = v8->ptr_1C;
4282 ++v48;
4283 }
4284 //while ( v48 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
4285 while ( v48 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
4286 }
4287 }
4288 }
4289 else
4290 {
4291 if ( _4F063C_smthn_by_2da_uType[v44] )
4292 {
4293 do
4294 {
4295 v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724];
4296 if ( v50 )
4297 {
4298 v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v50].pIconName, TEXTURE_16BIT_PALETTE);
4299 v3 = dword_F8B198;
4300 v8 = ptr_507BC0;
4301 dword_F8B168[v43] = &pIcons_LOD->pTextures[v51];
4302 }
4303 v42 = v8->ptr_1C;
4304 ++v43;
4305 }
4306 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
4307 while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
4308 }
4309 if ( v3 == 1 )
4310 {
4311 v52 = v8->ptr_1C;
4312 v53 = 0;
4313 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
4314 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
4315 {
4316 do
4317 {
4318 if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] )
4319 {
4320 v54 = rand();
4321 v8 = ptr_507BC0;
4322 word_F8B158[v53] = v54 % (300 - dword_F8B168[v53]->uTextureHeight);
4323 }
4324 v52 = v8->ptr_1C;
4325 ++v53;
4326 }
4327 //while ( v53 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
4328 while ( v53 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType ] );
4329 }
4330 }
4331 }
4332 }
4333
4334 //----- (004BD8B5) --------------------------------------------------------
4335 signed int __cdecl sub_4BD8B5()
4336 {
4337 int v0; // eax@4
4338 int v1; // eax@29
4339 unsigned int v2; // esi@30
4340 const char *v3; // ebx@31
4341
4342 if ( pMessageQueue_50CBD0->uNumMessages )
4343 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
4344 pKeyActionMap->_459ED1(3);
4345 pKeyActionMap->ResetKeys();
4346 _5C3420_pDecoration = 0;
4347 ptr_F8B1E8 = 0;
4348 if ( array_5913D8[6] )
4349 {
4350 v0 = dword_F8B19C;
4351 if ( dword_F8B19C != 2
4352 && dword_F8B19C != 3
4353 && dword_F8B19C != 97
4354 && dword_F8B19C != 5
4355 && dword_F8B19C != 4
4356 && dword_F8B164 )
4357 {
4358 dword_F8B164->Release();
4359 v0 = dword_F8B19C;
4360 dword_F8B164 = 0;
4361 }
4362 if ( v0 && v0 != 1 )
4363 {
4364 if ( v0 == -1 )
4365 {
4366 _4B4224_UpdateNPCTopics((int)((char *)array_5913D8[6] - 1));
4367 LABEL_33:
4368 pVideoPlayer->_4BF5B2();
4369 return 1;
4370 }
4371 if ( v0 != 94 && v0 != 96 && v0 != 101 )
4372 {
4373 if ( v0 == 3 || v0 == 5 || v0 == 4 )
4374 {
4375 sub_4BCA33();
4376 dword_F8B19C = 94;
4377 sub_4B3AD4(dword_F8B198);
4378 }
4379 else
4380 {
4381 if ( v0 != 102 && v0 != 103 && v0 != 104 )
4382 {
4383 pVideoPlayer->_4BF5B2();
4384 LABEL_28:
4385 dword_F8B19C = 1;
4386 sub_4B3B42(dword_F8B198);
4387 return 1;
4388 }
4389 pVideoPlayer->_4BF5B2();
4390 sub_4BCA33();
4391 dword_F8B19C = 101;
4392 sub_4B3A72(dword_F8B198);
4393 }
4394 return 1;
4395 }
4396 pVideoPlayer->_4BF5B2();
4397 sub_4BCA33();
4398 goto LABEL_28;
4399 }
4400 array_5913D8[6] = 0;
4401 pDialogueWindow->Release();
4402 dword_F8B19C = 0;
4403 pDialogueWindow = 0;
4404 pIcons_LOD->_40F9C5();
4405 v1 = uNumDialogueNPCPortraits;
4406 if ( uNumDialogueNPCPortraits != 1 )
4407 {
4408 v2 = 0;
4409 pBtn_ExitCancel = ptr_507BC0->pControlsHead;
4410 if ( uNumDialogueNPCPortraits > 0 )
4411 {
4412 v3 = byte_591180;
4413 do
4414 {
4415 array_5913D8[v2 + 7] = (NPCData *)ptr_507BC0->CreateButton(
4416 *(&_4E5E50_transui_x + v2 + 6 * v1 - 6),
4417 *(&_4E5EE0_transui_y + v2 + 6 * v1 - 6),
4418 0x3Fu,
4419 0x49u,
4420 1,
4421 0,
4422 0x19Au,
4423 v2,
4424 0,
4425 v3,
4426 0,
4427 0,
4428 0);
4429 v1 = uNumDialogueNPCPortraits;
4430 ++v2;
4431 v3 += 100;
4432 }
4433 while ( (signed int)v2 < uNumDialogueNPCPortraits );
4434 }
4435 goto LABEL_33;
4436 }
4437 }
4438 return 0;
4439 }
4440
4441
4442
4443
4444
4445 //----- (004BDB56) --------------------------------------------------------
4446 void __cdecl sub_4BDB56_buy_skill____()
4447 {
4448 Player *v0; // edi@1
4449 signed int v1; // esi@9
4450 unsigned int v2; // eax@11
4451 int v3; // esi@12
4452 float v4; // ST1C_4@12
4453 signed int v5; // eax@12
4454 signed int v6; // eax@12
4455 char v7; // zf@12
4456 int v8; // eax@15
4457 const char *v9; // ecx@15
4458 signed int v10; // esi@18
4459 unsigned int v11; // esi@20
4460 int v12; // esi@21
4461 void *v13; // ecx@26
4462 signed int v14; // esi@31
4463 unsigned int v15; // eax@33
4464 GUIWindow *v16; // esi@34
4465 POINT *v17; // esi@37
4466 int v18; // ecx@37
4467 void *v19; // eax@38
4468 ItemGen *v20; // esi@38
4469 float v21; // ST1C_4@38
4470 signed int v22; // eax@38
4471 int v23; // ebx@38
4472 int v24; // edx@39
4473 int v25; // eax@40
4474 int v26; // ebx@41
4475 Player *v27; // ecx@43
4476 POINT *v28; // esi@49
4477 int v29; // ecx@49
4478 void *v30; // eax@50
4479 int v31; // ecx@50
4480 ItemGen *v32; // esi@51
4481 float v33; // ST1C_4@53
4482 signed int v34; // eax@53
4483 int v35; // eax@53
4484 bool v36; // eax@53
4485 unsigned int v37; // eax@53
4486 int v38; // eax@55
4487 int v39; // eax@63
4488 int v40; // eax@64
4489 int v41; // edx@66
4490 int v42; // esi@74
4491 signed int v43; // ebx@74
4492 int v44; // ecx@74
4493 unsigned __int16 *pSkill; // esi@77
4494 signed int v46; // [sp-18h] [bp-CCh]@36
4495 unsigned int v47; // [sp-14h] [bp-C8h]@36
4496 signed int v48; // [sp-10h] [bp-C4h]@36
4497 signed int v49; // [sp-Ch] [bp-C0h]@36
4498 int v50; // [sp-8h] [bp-BCh]@36
4499 int v51; // [sp-4h] [bp-B8h]@28
4500 unsigned int v52; // [sp-4h] [bp-B8h]@36
4501 int v53; // [sp+0h] [bp-B4h]@16
4502 unsigned int v54; // [sp+0h] [bp-B4h]@25
4503 int v55; // [sp+0h] [bp-B4h]@26
4504 int v56; // [sp+0h] [bp-B4h]@36
4505 POINT v57; // [sp+10h] [bp-A4h]@49
4506 POINT v58; // [sp+18h] [bp-9Ch]@18
4507 POINT v59; // [sp+20h] [bp-94h]@49
4508 POINT v60; // [sp+28h] [bp-8Ch]@9
4509 POINT v61; // [sp+30h] [bp-84h]@37
4510 POINT v62; // [sp+38h] [bp-7Ch]@18
4511 POINT v63; // [sp+40h] [bp-74h]@37
4512 POINT v64; // [sp+48h] [bp-6Ch]@19
4513 POINT v65; // [sp+50h] [bp-64h]@32
4514 POINT v66; // [sp+58h] [bp-5Ch]@18
4515 POINT v67; // [sp+60h] [bp-54h]@31
4516 POINT a2; // [sp+68h] [bp-4Ch]@9
4517 POINT v69; // [sp+70h] [bp-44h]@31
4518 POINT v70; // [sp+78h] [bp-3Ch]@9
4519 POINT v71; // [sp+80h] [bp-34h]@31
4520 POINT v72; // [sp+88h] [bp-2Ch]@10
4521 bool v73; // [sp+90h] [bp-24h]@53
4522 int v74; // [sp+94h] [bp-20h]@53
4523 int a6; // [sp+98h] [bp-1Ch]@57
4524 int a3; // [sp+9Ch] [bp-18h]@53
4525 Player *v77; // [sp+A0h] [bp-14h]@1
4526 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53
4527 unsigned int v79; // [sp+A8h] [bp-Ch]@9
4528 int v80; // [sp+ACh] [bp-8h]@12
4529 ItemGen *_this; // [sp+B0h] [bp-4h]@13
4530
4531 v0 = pPlayers[uActiveCharacter];
4532 v77 = pPlayers[uActiveCharacter];
4533 if ( pCurrentScreen == 14 )
4534 goto LABEL_73;
4535 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4536 {
4537 v56 = 0;
4538 v52 = 0;
4539 v50 = 0;
4540 v49 = 0;
4541 v48 = -1;
4542 v47 = 0;
4543 v46 = 0;
4544 goto LABEL_87;
4545 }
4546 if ( dword_F8B19C > 18 )
4547 {
4548 if ( dword_F8B19C < 36 )
4549 return;
4550 if ( dword_F8B19C <= 72 )
4551 {
4552 v42 = dword_F8B19C - 36;
4553 //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
4554 v43 = (signed __int64)(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].flt_24 * 500.0);
4555 v44 = v43 * (100 - v0->GetMerchant()) / 100;
4556 if ( v44 < v43 / 3 )
4557 v44 = v43 / 3;
4558 if ( byte_4ED970_skill_learn_ability_by_class_table[v0->uClass][v42] )
4559 {
4560 pSkill = &v0->pActiveSkills[v42];
4561 if ( !*pSkill )
4562 {
4563 if ( pParty->uNumGold < v44 )
4564 {
4565 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
4566 v13 = ptr_507BC0->ptr_1C;
4567 if ( dword_F8B198 == 30 )
4568 v55 = 4;
4569 else
4570 v55 = 2;
4571 goto LABEL_84;
4572 }
4573 Party::TakeGold(v44);
4574 v53 = 0;
4575 dword_F8B1E4 = 1;
4576 *pSkill = 1;
4577 v51 = 78;
4578 goto LABEL_80;
4579 }
4580 }
4581 return;
4582 }
4583 if ( dword_F8B19C != 94 )
4584 {
4585 if ( dword_F8B19C != 95 )
4586 return;
4587 goto LABEL_49;
4588 }
4589 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
4590 LABEL_73:
4591 sub_421EA6_OnInventoryLeftClick();
4592 return;
4593 }
4594 if ( dword_F8B19C == 18 )
4595 {
4596 v17 = pMouse->GetCursorPos(&v63);
4597 v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
4598 if ( !v18 )
4599 return;
4600 v19 = ptr_507BC0->ptr_1C;
4601 v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)v19));
4602 //v21 = p2DEvents_minus1__20[13 * (signed int)v19];
4603 v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier;
4604 _this = v20;
4605 v22 = v20->GetValue();
4606 v23 = v0->_4B8142(v22, v21);
4607 v80 = v23;
4608 GetAsyncKeyState(VK_CONTROL);
4609 if ( pParty->uNumGold < v23 )
4610 {
4611 v24 = 2;
4612 LABEL_62:
4613 HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v24);
4614 v9 = pGlobalTXT_LocalizationStrings[155];
4615 v54 = 2;
4616 goto LABEL_71;
4617 }
4618 v25 = v0->AddItem(0xFFFFFFFFu, v20->uItemID);
4619 if ( v25 )
4620 {
4621 v26 = 1;
4622 v20->uAttributes |= 1u;
4623 memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u);
4624 goto LABEL_42;
4625 }
4626 v0->PlaySound(15, 0);
4627 v54 = 5;
4628 LABEL_70:
4629 v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!"
4630 goto LABEL_71;
4631 }
4632 if ( dword_F8B19C == 2 )
4633 {
4634 LABEL_49:
4635 v28 = pMouse->GetCursorPos(&v59);
4636 v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v57)->y]] & 0xFFFF;
4637 if ( !v29 )
4638 return;
4639 v30 = ptr_507BC0->ptr_1C;
4640 v31 = 9 * (v29 - 1 + 12 * (int)v30);
4641 if ( dword_F8B19C == 2 )
4642 {
4643 v32 = (ItemGen *)&pParty->field_777C[v31];
4644 _this = (ItemGen *)&pParty->field_777C[v31];
4645 }
4646 else
4647 {
4648 _this = (ItemGen *)&pParty->field_C59C[v31 + 724];
4649 v32 = (ItemGen *)&pParty->field_C59C[v31 + 724];
4650 }
4651 //v33 = p2DEvents_minus1__20[13 * (signed int)v30];
4652 v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
4653 v34 = v32->GetValue();
4654 v80 = v0->_4B8142(v34, v33);
4655 LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
4656 v74 = v35;
4657 v36 = v0->CanSteal();
4658 uNumSeconds = 0;
4659 a3 = 0;
4660 v73 = v36;
4661 v37 = pMapStats->GetMapInfo(pCurrentMapName);
4662 if ( v37 )
4663 a3 = pMapStats->pInfos[v37]._steal_perm;
4664 v38 = GetPartyReputation();
4665 v26 = 1;
4666 if ( v73 == 1 )
4667 {
4668 if ( (short)v74 )
4669 {
4670 uNumSeconds = v0->StealFromShop(v32, a3, v38, 0, &a6);
4671 if ( !uNumSeconds )
4672 {
4673 sub_4B1447_party_fine((int)ptr_507BC0->ptr_1C, 0, a6);
4674 return;
4675 }
4676 }
4677 }
4678 if ( pParty->uNumGold < v80 )
4679 {
4680 v24 = 2;
4681 if ( uNumSeconds != 2 )
4682 {
4683 if ( uNumSeconds != 1 )
4684 goto LABEL_62;
4685 }
4686 }
4687 v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID);
4688 if ( v39 )
4689 {
4690 v32->uAttributes |= 1u;
4691 v7 = v73 == 1;
4692 v40 = (int)((char *)v0 + 36 * v39);
4693 memcpy((void *)(v40 + 496), v32, 0x24u);
4694 if ( v7 )
4695 {
4696 if ( (short)v74 )
4697 {
4698 v41 = uNumSeconds;
4699 if ( uNumSeconds == 1 || uNumSeconds == 2 )
4700 {
4701 *(char *)(v40 + 517) |= 1u;
4702 sub_4B1447_party_fine((int)ptr_507BC0->ptr_1C, v41, a6);
4703 goto LABEL_43;
4704 }
4705 }
4706 }
4707 LABEL_42:
4708 dword_F8B1E4 = v26;
4709 Party::TakeGold(v80);
4710 LABEL_43:
4711 viewparams->bRedrawGameUI = v26;
4712 _this->Reset();
4713 pRenderer->ClearZBuffer(0, 479);
4714 v27 = v77;
4715 v53 = 0;
4716 v51 = 75;
4717 LABEL_81:
4718 v27->PlaySound(v51, v53);
4719 return;
4720 }
4721 v0->PlaySound(15, 0);
4722 v54 = 2;
4723 goto LABEL_70;
4724 }
4725 if ( dword_F8B19C == 3 )
4726 {
4727 v14 = pMouse->GetCursorPos(&v71)->x - 14;
4728 v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5);
4729 if ( pMouse->GetCursorPos(&v67)->x <= 13
4730 || pMouse->GetCursorPos(&v65)->x >= 462
4731 || (v15 = v0->GetItemIDAtInventoryIndex((int *)&v79), (v77 = (Player *)v15) == 0) )
4732 return;
4733 v16 = ptr_507BC0;
4734 if ( sub_4BDAAF((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5], (int)ptr_507BC0->ptr_1C) )
4735 {
4736 dword_F8B1E4 = 1;
4737 v0->_4BE2DD(v79, (int)((char *)v77 - 1), (int)v16->ptr_1C);
4738 viewparams->bRedrawGameUI = 1;
4739 pRenderer->ClearZBuffer(0, 479);
4740 v53 = 0;
4741 v51 = 77;
4742 goto LABEL_80;
4743 }
4744 v0->PlaySound(79, 0);
4745 v56 = 0;
4746 v52 = 0;
4747 v50 = 0;
4748 v49 = 0;
4749 v48 = -1;
4750 v47 = 0;
4751 v46 = 0;
4752 LABEL_87:
4753 pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56);
4754 return;
4755 }
4756 if ( dword_F8B19C == 4 )
4757 {
4758 v10 = pMouse->GetCursorPos(&v62)->x - 14;
4759 v79 = (v10 >> 5) + 14 * ((pMouse->GetCursorPos(&v66)->y - 17) >> 5);
4760 if ( pMouse->GetCursorPos(&v58)->x > 13 )
4761 {
4762 if ( pMouse->GetCursorPos(&v64)->x < 462 )
4763 {
4764 v11 = v0->GetItemIDAtInventoryIndex((int *)&v79);
4765 if ( v11 )
4766 {
4767 //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
4768 v80 = v0->_4B8179(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier);
4769 v12 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v11 + 5];
4770 if ( !(*(char *)(v12 + 20) & 1) )
4771 {
4772 _this = (ItemGen *)ptr_507BC0->ptr_1C;
4773 if ( sub_4BDAAF((ItemGen *)v12, (int)_this) )
4774 {
4775 if ( pParty->uNumGold >= v80 )
4776 {
4777 dword_F8B1E4 = 1;
4778 Party::TakeGold(v80);
4779 *(int *)(v12 + 20) |= 1u;
4780 v0->PlaySound(73, 0);
4781 v9 = pGlobalTXT_LocalizationStrings[569];
4782 goto LABEL_25;
4783 }
4784 goto LABEL_26;
4785 }
4786 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
4787 v53 = 0;
4788 goto LABEL_28;
4789 }
4790 v53 = 0;
4791 LABEL_30:
4792 v51 = 76;
4793 goto LABEL_80;
4794 }
4795 }
4796 }
4797 }
4798 else
4799 {
4800 if ( dword_F8B19C == 5 )
4801 {
4802 v1 = pMouse->GetCursorPos(&a2)->x - 14;
4803 v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5);
4804 if ( pMouse->GetCursorPos(&v60)->x > 13 )
4805 {
4806 if ( pMouse->GetCursorPos(&v72)->x < 462 )
4807 {
4808 v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
4809 if ( v2 )
4810 {
4811 v3 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
4812 //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
4813 v4 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
4814
4815 auto _v = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
4816 v5 = _v->GetValue();
4817
4818 v6 = v0->_4B81C3(v5, v4);
4819 v7 = (*(char *)(v3 + 20) & 2) == 0;
4820 v80 = v6;
4821 if ( !v7 )
4822 {
4823 _this = (ItemGen *)ptr_507BC0->ptr_1C;
4824 if ( sub_4BDAAF((ItemGen *)v3, (int)_this) )
4825 {
4826 if ( pParty->uNumGold >= v80 )
4827 {
4828 dword_F8B1E4 = 1;
4829 Party::TakeGold(v80);
4830 v8 = *(int *)(v3 + 20);
4831 LOBYTE(v8) = v8 & 0xFD;
4832 *(int *)(v3 + 20) = v8 | 1;
4833 v0->PlaySound(74, 0);
4834 v9 = pGlobalTXT_LocalizationStrings[570];
4835 LABEL_25:
4836 v54 = 2;
4837 LABEL_71:
4838 ShowStatusBarString(v9, v54);
4839 return;
4840 }
4841 LABEL_26:
4842 v13 = _this;
4843 v55 = 2;
4844 LABEL_84:
4845 HousePlaySomeSound((unsigned int)v13, v55);
4846 return;
4847 }
4848 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
4849 v53 = 0;
4850 LABEL_28:
4851 v51 = 79;
4852 LABEL_80:
4853 v27 = v0;
4854 goto LABEL_81;
4855 }
4856 v53 = 0;
4857 goto LABEL_30;
4858 }
4859 }
4860 }
4861 }
4862 }
4863 }
4864
4865
4866
4867 //----- (004BE386) --------------------------------------------------------
4868 void __fastcall log_error(const char *pMessage)
4869 {
4870 const char *v1; // edi@1
4871 FILE *f; // eax@1
4872 FILE *v3; // esi@1
4873
4874 v1 = pMessage;
4875 f = fopen("errorlog.txt", "a");
4876 v3 = f;
4877 if ( f )
4878 {
4879 fprintf(f, "%s\n", v1);
4880 fclose(v3);
4881 fflush(v3);
4882 }
4883 }
4884
4885 //----- (004BE3BF) --------------------------------------------------------
4886 FrameTableTxtLine *texture_frame_table_txt_parser(const char *_this, FrameTableTxtLine *a2)
4887 {
4888 char *v2; // eax@3
4889 signed int v3; // edx@3
4890 unsigned int v4; // edi@3
4891 char v5; // cl@4
4892 FrameTableTxtLine *result; // eax@21
4893 signed int v7; // [sp+Ch] [bp-4h]@3
4894
4895 static struct FrameTableTxtLine static_stru_F8BA58; // weak
4896 static_stru_F8BA58.field_0 = 0;
4897 if ( _this && *_this )
4898 {
4899 v2 = (char *)&unk_F8B668;
4900 v3 = 1;
4901 v7 = 0;
4902 v4 = _this - (char *)&unk_F8B668;
4903 do
4904 {
4905 v5 = v2[v4];
4906 *v2 = v5;
4907 if ( !v5 )
4908 break;
4909 if ( v5 != 32 && v5 != 44 && v5 != 9 || v7 )
4910 {
4911 if ( v5 == 34 )
4912 {
4913 *v2 = 0;
4914 v3 = 1;
4915 if ( v7 )
4916 {
4917 v7 = 0;
4918 }
4919 else
4920 {
4921 v7 = 1;
4922 if ( v2[v4 + 1] == 34 )
4923 {
4924 static_stru_F8BA58.pProperties[static_stru_F8BA58.field_0] = v2;
4925 ++static_stru_F8BA58.field_0;
4926 }
4927 }
4928 }
4929 else
4930 {
4931 if ( v3 )
4932 {
4933 static_stru_F8BA58.pProperties[static_stru_F8BA58.field_0] = v2;
4934 ++static_stru_F8BA58.field_0;
4935 }
4936 v3 = 0;
4937 }
4938 }
4939 else
4940 {
4941 *v2 = 0;
4942 v3 = 1;
4943 }
4944 if ( static_stru_F8BA58.field_0 >= 30 )
4945 break;
4946 ++v2;
4947 }
4948 while ( (unsigned int)v2 < (unsigned int)&unk_F8BA50 );
4949 *v2 = 0;
4950 }
4951 result = a2;
4952 memcpy(a2, &static_stru_F8BA58, 0x7Cu);
4953 return result;
4954 }
4955 // F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58;
4956
4957 //----- (004BE485) --------------------------------------------------------
4958 FrameTableTxtLine *__thiscall frame_table_txt_parser(const char *pString, FrameTableTxtLine *a2)
4959 {
4960 char *v2; // eax@3
4961 signed int v3; // edi@3
4962 signed int v4; // edx@3
4963 char v5; // cl@4
4964 FrameTableTxtLine *result; // eax@24
4965 unsigned int v7; // [sp+Ch] [bp-4h]@3
4966
4967 stru_F8B5E8.field_0 = 0;
4968 if ( pString && *pString )
4969 {
4970 v2 = (char *)&unk_F8B1F8;
4971 v3 = 0;
4972 v7 = pString - (const char *)&unk_F8B1F8;
4973 v4 = 1;
4974 while ( 1 )
4975 {
4976 v5 = v2[v7];
4977 *v2 = v5;
4978 if ( !v5 )
4979 {
4980 LABEL_23:
4981 *v2 = 0;
4982 break;
4983 }
4984 if ( v5 == ',' )
4985 {
4986 if ( v3 )
4987 goto LABEL_18;
4988 *v2 = 0;
4989 }
4990 else
4991 {
4992 if ( v5 != '\t' )
4993 {
4994 if ( v5 == '"' )
4995 {
4996 *v2 = 0;
4997 v4 = 1;
4998 if ( v3 )
4999 {
5000 v3 = 0;
5001 }
5002 else
5003 {
5004 v3 = 1;
5005 if ( v2[v7 + 1] == 34 )
5006 {
5007 stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2;
5008 ++stru_F8B5E8.field_0;
5009 }
5010 }
5011 goto LABEL_21;
5012 }
5013 LABEL_18:
5014 if ( v4 )
5015 {
5016 stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2;
5017 ++stru_F8B5E8.field_0;
5018 }
5019 v4 = 0;
5020 goto LABEL_21;
5021 }
5022 if ( v3 )
5023 goto LABEL_18;
5024 *v2 = 0;
5025 if ( v4 )
5026 {
5027 stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2;
5028 ++stru_F8B5E8.field_0;
5029 }
5030 }
5031 v4 = 1;
5032 LABEL_21:
5033 if ( stru_F8B5E8.field_0 < 30 )
5034 {
5035 ++v2;
5036 if ( (unsigned int)v2 < (unsigned int)&unk_F8B5E0 )
5037 continue;
5038 }
5039 goto LABEL_23;
5040 }
5041 }
5042 result = a2;
5043 memcpy(a2, &stru_F8B5E8, 0x7Cu);
5044 return result;
5045 }
5046 // F8B5E8: using guessed type FrameTableTxtLine stru_F8B5E8;
5047
5048 //----- (004BE571) --------------------------------------------------------
5049 int __fastcall sub_4BE571(int a1, int *a2, int a3, int a4)
5050 {
5051 int result; // eax@1
5052 int i; // esi@3
5053
5054 result = a3;
5055 if ( a3 < a4 )
5056 {
5057 for ( i = 0; i < a3; ++i )
5058 {
5059 if ( a1 == a2[i] )
5060 break;
5061 }
5062 if ( i == a3 )
5063 {
5064 a2[a3] = a1;
5065 result = a3 + 1;
5066 }
5067 }
5068 else
5069 {
5070 result = a4;
5071 }
5072 return result;
5073 }
5074
5075
5076
5077 //----- (004BF91E) --------------------------------------------------------
5078 unsigned int __thiscall GameOverMenu(void *ecx0)
5079 {
5080 char *v1; // eax@2
5081 unsigned int result; // eax@3
5082 char *v3; // eax@7
5083 char *v4; // ST24_4@9
5084 int v5; // eax@9
5085 char *v6; // eax@10
5086 char *v7; // edx@10
5087 char *v8; // ecx@12
5088 char *v9; // eax@14
5089 unsigned int v10; // eax@25
5090 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1
5091 MSG Msg; // [sp+88h] [bp-48h]@22
5092 unsigned int v14; // [sp+A4h] [bp-2Ch]@5
5093 void *v15; // [sp+A8h] [bp-28h]@1
5094 char *pInString; // [sp+ACh] [bp-24h]@5
5095 unsigned int v17; // [sp+B0h] [bp-20h]@5
5096 unsigned int v18; // [sp+B4h] [bp-1Ch]@5
5097 unsigned int v19; // [sp+B8h] [bp-18h]@5
5098 int v20; // [sp+BCh] [bp-14h]@7
5099 int i; // [sp+C0h] [bp-10h]@7
5100 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1
5101 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5
5102
5103 v15 = ecx0;
5104
5105 RGBTexture _this; // [sp+Ch] [bp-C4h]@1
5106 //RGBTexture::RGBTexture(&this);
5107
5108 BYTE1(dword_6BE364_game_settings_1) &= 0xBFu;
5109 bGameoverLoop = 1;
5110 pVideoPlayer->bStopBeforeSchedule = 0;
5111 pAudioPlayer->StopChannels(-1, -1);
5112 pRenderer->BeginScene();
5113 pRenderer->ClearBlack();
5114 pRenderer->EndScene();
5115 pRenderer->Present();
5116 pVideoPlayer->field_40 = 0;
5117 _449B57_test_bit(pParty->_award_bits, 99);
5118 _this.Load("winbg.pcx", 2);
5119 pRenderer->BeginScene();
5120 pRenderer->DrawTextureRGB(0, 0, &_this);
5121 pRenderer->EndScene();
5122 free(_this.pPixels);
5123 _this.pPixels = 0;
5124 ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
5125 pWindow.uFrameX = 75;
5126 pWindow.uFrameY = 60;
5127 pWindow.uFrameWidth = 469;
5128 pWindow.uFrameHeight = 338;
5129 pWindow.uFrameZ = 543;
5130 pWindow.uFrameW = 397;
5131 pFont = LoadFont("endgame.fnt", "FONTPAL", 0);
5132 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 99) )
5133 {
5134 v1 = pGlobalTXT_LocalizationStrings[675];
5135 }
5136 else
5137 {
5138 result = _449B57_test_bit(pParty->_award_bits, 100);
5139 if ( !(short)result )
5140 return result;
5141 v1 = pGlobalTXT_LocalizationStrings[676];
5142 }
5143 pInString = v1;
5144 v23 = pParty->uTimePlayed - 138240;
5145 v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18;
5146 v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18 / 0x1C / 0xC;
5147 v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18 / 0x1C % 0xC;
5148 v17 = v19 % 0x1C;
5149 if ( !v19 )
5150 v19 = 1;
5151 pRenderer->BeginScene();
5152 pWindow.DrawTitleText(pFont, 1u, 0x23u, 1u, pGlobalTXT_LocalizationStrings[9], 3u);
5153 v3 = pParty->pPlayers[0].pName;
5154 v23 = 0i64;
5155 v20 = 0;
5156 for ( i = (int)pParty->pPlayers[0].pName; ; v3 = (char *)i )
5157 {
5158 v4 = pClassNames[(unsigned __int8)v3[17]];
5159 v5 = ((Player *)(v3 - 168))->GetBaseLevel();
5160 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[129], i, v5, v4);
5161 pWindow.DrawTitleText(
5162 pFont,
5163 1u,
5164 v20 * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46,
5165 1u,
5166 pTmpBuf,
5167 3u);
5168 v23 += __PAIR__(*(int *)(i - 4), *(int *)(i - 8));
5169 ++v20;
5170 i += 6972;
5171 if ( i >= (signed int)&pParty->pPickedItem.uNumCharges )
5172 break;
5173 }
5174 v23 = (signed __int64)v23 / v19;
5175 v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xCu, 0);
5176 pWindow.DrawTitleText(pFont, 1u, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1u, v6, 0);
5177 strcpy(pTmpBuf, pGlobalTXT_LocalizationStrings[37]);
5178 v7 = pGlobalTXT_LocalizationStrings[56];
5179 if ( v17 != 1 )
5180 v7 = pGlobalTXT_LocalizationStrings[57];
5181 v8 = pGlobalTXT_LocalizationStrings[146];
5182 if ( v18 != 1 )
5183 v8 = pGlobalTXT_LocalizationStrings[148];
5184 v9 = pGlobalTXT_LocalizationStrings[245];
5185 if ( v14 != 1 )
5186 v9 = pGlobalTXT_LocalizationStrings[132];
5187 sprintf(pTmpBuf2, " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7);
5188 strcat(pTmpBuf, pTmpBuf2);
5189 pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1u, pTmpBuf, 3u);
5190 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[94], v23);
5191 pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight, 1u, pTmpBuf, 3u);
5192 BYTE1(dword_6BE364_game_settings_1) |= 0x40u;
5193 pRenderer->EndScene();
5194 pRenderer->Present();
5195 if ( pRenderer->pRenderD3D )
5196 pRenderer->pBeforePresentFunction();
5197 pRenderer->_49F1BC("MM7_Win.Pcx");
5198 pAllocator->FreeChunk(pFont);
5199 ptr_507BC0->Release();
5200 ptr_507BC0 = 0;
5201 if ( v15 == (void *)2 )
5202 {
5203 result = pMessageQueue_50CBD0->uNumMessages;
5204 }
5205 else
5206 {
5207 LODWORD(v23) = GetTickCount() + 5000;
5208 while ( (unsigned int)v23 > GetTickCount() )
5209 ;
5210 while ( 1 )
5211 {
5212 v10 = PeekMessageA(&Msg, 0, 0, 0, 1u);
5213 if ( !v10 )
5214 break;
5215 if ( Msg.message == 18 )
5216 Game_DeinitializeAndTerminate(0);
5217 TranslateMessage(&Msg);
5218 DispatchMessageA(&Msg);
5219 }
5220 if ( pMessageQueue_50CBD0->uNumMessages )
5221 {
5222 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5223 pMessageQueue_50CBD0->uNumMessages = v10;
5224 }
5225 pKeyActionMap->ResetKeys();
5226 pKeyActionMap->uLastKeyPressed = 0;
5227 do
5228 {
5229 while ( PeekMessageA(&Msg, 0, 0, 0, 1u) )
5230 {
5231 if ( Msg.message == 18 )
5232 Game_DeinitializeAndTerminate(0);
5233 TranslateMessage(&Msg);
5234 DispatchMessageA(&Msg);
5235 }
5236 }
5237 while ( !pKeyActionMap->uLastKeyPressed );
5238 result = pMessageQueue_50CBD0->uNumMessages;
5239 if ( pMessageQueue_50CBD0->uNumMessages )
5240 {
5241 result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5242 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5243 }
5244 }
5245 if ( v15 )
5246 {
5247 if ( (signed int)result < 40 )
5248 {
5249 pMessageQueue_50CBD0->pMessages[result].eType = (UIMessageType)132;
5250 goto LABEL_42;
5251 }
5252 }
5253 else
5254 {
5255 if ( (signed int)result < 40 )
5256 {
5257 pMessageQueue_50CBD0->pMessages[result].eType = (UIMessageType)197;
5258 LABEL_42:
5259 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
5260 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
5261 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
5262 ++pMessageQueue_50CBD0->uNumMessages;
5263 goto LABEL_43;
5264 }
5265 }
5266 LABEL_43:
5267 bGameoverLoop = 0;
5268 return result;
5269 }
5270
5271
5272 //----- (004C0262) --------------------------------------------------------
5273 void Viewport::SetScreen(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
5274 {
5275 unsigned int x; // edx@1
5276 unsigned int z; // esi@1
5277 unsigned int y; // edi@3
5278 unsigned int w; // eax@3
5279 char no_3d; // zf@5
5280 int v10; // eax@7
5281
5282 x = uX;
5283 z = uZ;
5284 if ( (signed int)uX > (signed int)uZ )
5285 {
5286 z = uZ ^ uX ^ uZ; // swap x and z
5287 x = z ^ uZ ^ uX;
5288 }
5289 y = uY;
5290 w = uW;
5291 if ( (signed int)uY > (signed int)uW )
5292 {
5293 w = uW ^ uY ^ uW; // swap y and w
5294 y = w ^ uW ^ uY;
5295 }
5296 this->uScreenX = x;
5297 this->uScreenY = y;
5298 this->uScreenZ = z;
5299 this->uScreenW = w;
5300 no_3d = pRenderer->pRenderD3D == 0;
5301 this->uScreenWidth = z - x + 1;
5302 this->uScreenCenterX = (signed int)(z + x) >> 1;
5303 if ( no_3d )
5304 {
5305 v10 = w - y + 1;
5306 this->uScreenHeight = v10;
5307 this->uScreenCenterY = this->uScreenW - ((unsigned __int64)(this->field_30 * (signed __int64)v10) >> 16);
5308 }
5309 else
5310 {
5311 this->uScreenHeight = w - y + 1;
5312 this->uScreenCenterY = (signed int)(w + y) >> 1;
5313 }
5314 SetViewport(this->uScreenX, this->uScreenY, this->uScreenZ, this->uScreenW);
5315 }
5316
5317 //----- (004C02F8) --------------------------------------------------------
5318 void Viewport::_4C02F8(int a2)
5319 {
5320 unsigned int v2; // ST0C_4@1
5321
5322 v2 = this->uScreenW;
5323 this->field_30 = a2;
5324 SetScreen(this->uScreenX, this->uScreenY, this->uScreenZ, v2);
5325 }
5326
5327 //----- (004C0312) --------------------------------------------------------
5328 void Viewport::SetViewport(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
5329 {
5330 unsigned int x; // ebx@1
5331 unsigned int y; // edi@3
5332 unsigned int z; // edx@5
5333 unsigned int w; // eax@7
5334
5335 x = uX;
5336 if ( (signed int)uX < (signed int)this->uScreenX )
5337 x = this->uScreenX;
5338 y = uY;
5339 if ( (signed int)uY < (signed int)this->uScreenY )
5340 y = this->uScreenY;
5341 z = uZ;
5342 if ( (signed int)uZ > (signed int)this->uScreenZ )
5343 z = this->uScreenZ;
5344 w = uW;
5345 if ( (signed int)uW > (signed int)this->uScreenW )
5346 w = this->uScreenW;
5347 this->uViewportY = y;
5348 this->uViewportX = x;
5349 this->uViewportZ = z;
5350 this->uViewportW = w;
5351 }
5352
5353
5354
5355
5356
5357
5358 //----- (004D6FB0) --------------------------------------------------------
5359 int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(stru315 *a1/*<ebp>*/)
5360 {
5361 int v1; // ebp@1
5362 unsigned int v2; // esi@1
5363 unsigned int v3; // edi@1
5364 int result; // eax@1
5365 int v5; // ebx@2
5366 int v6; // edx@2
5367 int v7; // ebx@3
5368 __int16 v8; // cx@3
5369 int v9; // ebx@4
5370 unsigned __int8 v10; // sf@5
5371 unsigned __int8 v11; // of@5
5372
5373 v1 = a1->field_8;
5374 v2 = *(int *)(v1 + 48);
5375 v3 = *(int *)(v1 + 44);
5376 result = *(int *)(v1 + 64);
5377 if ( !(*(int *)(v1 + 40) & 1) )
5378 goto LABEL_5;
5379 --*(int *)(v1 + 40);
5380 result -= 2;
5381 v5 = *(int *)(v1 + 60);
5382 v6 = *(int *)(v1 + 36);
5383 *(int *)(v1 + 60) += 4;
5384 while ( 1 )
5385 {
5386 *(int *)v5 = v6;
5387 v9 = *(char *)(*(int *)(v1 + 56)
5388 + (*(int *)(v1 + 12) & (v2 >> 16))
5389 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)));
5390 result += 4;
5391 v2 += *(int *)(v1 + 4);
5392 v3 += *(int *)v1;
5393 *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v9);
5394 LABEL_5:
5395 v11 = __OFSUB__(*(int *)(v1 + 40), 2);
5396 v10 = *(int *)(v1 + 40) - 2 < 0;
5397 *(int *)(v1 + 40) -= 2;
5398 if ( v10 ^ v11 )
5399 break;
5400 v7 = *(char *)(*(int *)(v1 + 56)
5401 + (*(int *)(v1 + 12) & (v2 >> 16))
5402 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)));
5403 v2 += *(int *)(v1 + 4);
5404 v8 = *(short *)(*(int *)(v1 + 52) + 2 * v7);
5405 v3 += *(int *)v1;
5406 v5 = *(int *)(v1 + 60);
5407 v6 = *(int *)(v1 + 36);
5408 *(short *)result = v8;
5409 *(int *)(v1 + 60) += 8;
5410 *(int *)(v5 + 4) = v6;
5411 }
5412 *(int *)(v1 + 64) = result;
5413 *(int *)(v1 + 48) = v2;
5414 *(int *)(v1 + 44) = v3;
5415 return result;
5416 }
5417
5418 //----- (004D705A) --------------------------------------------------------
5419 int /*__usercall*/ sr_sub_4D705A/*<eax>*/(stru315 *a1/*<ebp>*/)
5420 {
5421 int v1; // ebp@1
5422 unsigned int v2; // esi@1
5423 unsigned int v3; // edi@1
5424 int result; // eax@1
5425 int v5; // ebx@2
5426 int v6; // edx@2
5427 unsigned int v7; // ebx@3
5428 unsigned int v8; // edx@3
5429 __int16 v9; // cx@11
5430 unsigned int v10; // ebx@12
5431 unsigned int v11; // edx@12
5432 unsigned __int8 v12; // sf@21
5433 unsigned __int8 v13; // of@21
5434
5435 v1 = a1->field_8;
5436 v2 = *(int *)(v1 + 48);
5437 v3 = *(int *)(v1 + 44);
5438 result = *(int *)(v1 + 64);
5439 if ( !(*(int *)(v1 + 40) & 1) )
5440 goto LABEL_21;
5441 --*(int *)(v1 + 40);
5442 result -= 2;
5443 v5 = *(int *)(v1 + 60);
5444 v6 = *(int *)(v1 + 36);
5445 *(int *)(v1 + 60) += 4;
5446 while ( 1 )
5447 {
5448 *(int *)v5 = v6;
5449 v10 = v3;
5450 v11 = v2;
5451 if ( (signed int)v2 < *(int *)(v1 + 20) )
5452 v11 = *(int *)(v1 + 20);
5453 if ( (signed int)v3 < *(int *)(v1 + 28) )
5454 v10 = *(int *)(v1 + 28);
5455 if ( (signed int)v11 > *(int *)(v1 + 24) )
5456 v11 = *(int *)(v1 + 24);
5457 if ( (signed int)v10 > *(int *)(v1 + 32) )
5458 v10 = *(int *)(v1 + 32);
5459 result += 4;
5460 v2 += *(int *)(v1 + 4);
5461 v3 += *(int *)v1;
5462 *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52)
5463 + 2
5464 * *(char *)(*(int *)(v1 + 56)
5465 + (*(int *)(v1 + 12) & (v11 >> 16))
5466 + ((*(int *)(v1 + 8) & v10) >> *(char *)(v1 + 16))));
5467 LABEL_21:
5468 v13 = __OFSUB__(*(int *)(v1 + 40), 2);
5469 v12 = *(int *)(v1 + 40) - 2 < 0;
5470 *(int *)(v1 + 40) -= 2;
5471 if ( v12 ^ v13 )
5472 break;
5473 v7 = v3;
5474 v8 = v2;
5475 if ( (signed int)v2 < *(int *)(v1 + 20) )
5476 v8 = *(int *)(v1 + 20);
5477 if ( (signed int)v3 < *(int *)(v1 + 28) )
5478 v7 = *(int *)(v1 + 28);
5479 if ( (signed int)v8 > *(int *)(v1 + 24) )
5480 v8 = *(int *)(v1 + 24);
5481 if ( (signed int)v7 > *(int *)(v1 + 32) )
5482 v7 = *(int *)(v1 + 32);
5483 v2 += *(int *)(v1 + 4);
5484 v9 = *(short *)(*(int *)(v1 + 52)
5485 + 2
5486 * *(char *)(*(int *)(v1 + 56)
5487 + (*(int *)(v1 + 12) & (v8 >> 16))
5488 + ((*(int *)(v1 + 8) & v7) >> *(char *)(v1 + 16))));
5489 v3 += *(int *)v1;
5490 v5 = *(int *)(v1 + 60);
5491 v6 = *(int *)(v1 + 36);
5492 *(short *)result = v9;
5493 *(int *)(v1 + 60) += 8;
5494 *(int *)(v5 + 4) = v6;
5495 }
5496 *(int *)(v1 + 64) = result;
5497 *(int *)(v1 + 48) = v2;
5498 *(int *)(v1 + 44) = v3;
5499 return result;
5500 }
5501
5502 //----- (004D714C) --------------------------------------------------------
5503 int __cdecl sr_sub_4D714C(stru315 *a1)
5504 {
5505 stru315 *v1; // ebp@0
5506 stru315 *v2; // ebp@1
5507 unsigned int v3; // esi@1
5508 int v4; // edi@1
5509 int result; // eax@1
5510 unsigned int *v6; // ebx@2
5511 int v7; // edx@2
5512 int v8; // ebx@3
5513 unsigned __int16 v9; // cx@3
5514 unsigned int *v10; // ebx@3
5515 int v11; // edx@3
5516 int v12; // ebx@4
5517 unsigned __int8 v13; // sf@5
5518 unsigned __int8 v14; // of@5
5519
5520 v2 = (stru315 *)v1->field_8;
5521 v3 = v2->field_30;
5522 v4 = v2->field_2C;
5523 result = (int)v2->pColorBuffer;
5524 if ( !(v2->field_28 & 1) )
5525 goto LABEL_5;
5526 --v2->field_28;
5527 result += 2;
5528 v6 = v2->pDepthBuffer;
5529 v7 = v2->field_24;
5530 --v2->pDepthBuffer;
5531 *v6 = v7;
5532 while ( 1 )
5533 {
5534 v12 = *((char *)v2->pTextureLOD
5535 + (v2->field_C & (v3 >> 16))
5536 + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10)));
5537 result -= 4;
5538 v3 += v2->field_4;
5539 v4 += v2->field_0;
5540 *(short *)(result + 2) = v2->field_34_palette[v12];
5541 LABEL_5:
5542 v14 = __OFSUB__(v2->field_28, 2);
5543 v13 = v2->field_28 - 2 < 0;
5544 v2->field_28 -= 2;
5545 if ( v13 ^ v14 )
5546 break;
5547 v8 = *((char *)v2->pTextureLOD
5548 + (v2->field_C & (v3 >> 16))
5549 + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10)));
5550 v3 += v2->field_4;
5551 v9 = v2->field_34_palette[v8];
5552 v4 += v2->field_0;
5553 v10 = v2->pDepthBuffer;
5554 v11 = v2->field_24;
5555 *(short *)result = v9;
5556 v2->pDepthBuffer -= 2;
5557 *v10 = v11;
5558 *(v10 - 1) = v11;
5559 }
5560 v2->pColorBuffer = (unsigned __int16 *)result;
5561 v2->field_30 = v3;
5562 v2->field_2C = v4;
5563 return result;
5564 }
5565 // 4D714C: inconsistent function type and number of purged bytes
5566
5567 //----- (004D71F8) --------------------------------------------------------
5568 int __cdecl sr_sub_4D71F8(stru315 *a1)
5569 {
5570 stru315 *v1; // ebp@0
5571 stru315 *v2; // ebp@1
5572 int v3; // esi@1
5573 int v4; // edi@1
5574 int result; // eax@1
5575 unsigned int *v6; // ebx@2
5576 int v7; // edx@2
5577 int v8; // ebx@3
5578 unsigned int v9; // edx@3
5579 unsigned __int16 v10; // cx@11
5580 unsigned int *v11; // ebx@11
5581 int v12; // edx@11
5582 int v13; // ebx@12
5583 unsigned int v14; // edx@12
5584 unsigned __int8 v15; // sf@21
5585 unsigned __int8 v16; // of@21
5586
5587 v2 = (stru315 *)v1->field_8;
5588 v3 = v2->field_30;
5589 v4 = v2->field_2C;
5590 result = (int)v2->pColorBuffer;
5591 if ( !(v2->field_28 & 1) )
5592 goto LABEL_21;
5593 --v2->field_28;
5594 result += 2;
5595 v6 = v2->pDepthBuffer;
5596 v7 = v2->field_24;
5597 --v2->pDepthBuffer;
5598 *v6 = v7;
5599 while ( 1 )
5600 {
5601 v13 = v4;
5602 v14 = v3;
5603 if ( v3 < v2->field_14 )
5604 v14 = v2->field_14;
5605 if ( v4 < v2->field_1C )
5606 v13 = v2->field_1C;
5607 if ( (signed int)v14 > v2->field_18 )
5608 v14 = v2->field_18;
5609 if ( v13 > v2->field_20 )
5610 v13 = v2->field_20;
5611 result -= 4;
5612 v3 += v2->field_4;
5613 v4 += v2->field_0;
5614 *(short *)(result + 2) = v2->field_34_palette[*((char *)v2->pTextureLOD
5615 + (v2->field_C & (v14 >> 16))
5616 + ((v2->field_8 & (unsigned int)v13) >> LOBYTE(v2->field_10)))];
5617 LABEL_21:
5618 v16 = __OFSUB__(v2->field_28, 2);
5619 v15 = v2->field_28 - 2 < 0;
5620 v2->field_28 -= 2;
5621 if ( v15 ^ v16 )
5622 break;
5623 v8 = v4;
5624 v9 = v3;
5625 if ( v3 < v2->field_14 )
5626 v9 = v2->field_14;
5627 if ( v4 < v2->field_1C )
5628 v8 = v2->field_1C;
5629 if ( (signed int)v9 > v2->field_18 )
5630 v9 = v2->field_18;
5631 if ( v8 > v2->field_20 )
5632 v8 = v2->field_20;
5633 v3 += v2->field_4;
5634 v10 = v2->field_34_palette[*((char *)v2->pTextureLOD
5635 + (v2->field_C & (v9 >> 16))
5636 + ((v2->field_8 & (unsigned int)v8) >> LOBYTE(v2->field_10)))];
5637 v4 += v2->field_0;
5638 v11 = v2->pDepthBuffer;
5639 v12 = v2->field_24;
5640 *(short *)result = v10;
5641 v2->pDepthBuffer -= 2;
5642 *v11 = v12;
5643 *(v11 - 1) = v12;
5644 }
5645 v2->pColorBuffer = (unsigned __int16 *)result;
5646 v2->field_30 = v3;
5647 v2->field_2C = v4;
5648 return result;
5649 }
5650 // 4D71F8: inconsistent function type and number of purged bytes
5651
5652 //----- (004D72EC) --------------------------------------------------------
5653 int /*__usercall*/ sr_sub_4D72EC/*<eax>*/(int a1/*<ebp>*/)
5654 {
5655 int v1; // ebp@1
5656 unsigned int v2; // esi@1
5657 unsigned int v3; // edi@1
5658 int result; // eax@1
5659 int v5; // ebx@2
5660 int v6; // edx@2
5661 unsigned int v7; // edx@3
5662 unsigned int v8; // ebx@3
5663 int v9; // ebx@11
5664 unsigned int v10; // edx@14
5665 unsigned int v11; // ebx@14
5666 int v12; // ebx@22
5667 unsigned __int8 v13; // sf@25
5668 unsigned __int8 v14; // of@25
5669
5670 v1 = *(int *)(a1 + 8);
5671 v2 = *(int *)(v1 + 48);
5672 v3 = *(int *)(v1 + 44);
5673 result = *(int *)(v1 + 64);
5674 if ( !(*(int *)(v1 + 40) & 1) )
5675 goto LABEL_25;
5676 --*(int *)(v1 + 40);
5677 result -= 2;
5678 v5 = *(int *)(v1 + 60);
5679 v6 = *(int *)(v1 + 36);
5680 *(int *)(v1 + 60) += 4;
5681 while ( 1 )
5682 {
5683 *(int *)v5 = v6;
5684 v10 = v2;
5685 v11 = v3;
5686 if ( (signed int)v2 < *(int *)(v1 + 20) )
5687 v10 = *(int *)(v1 + 20);
5688 if ( (signed int)v3 < *(int *)(v1 + 28) )
5689 v11 = *(int *)(v1 + 28);
5690 if ( (signed int)v10 > *(int *)(v1 + 24) )
5691 v10 = *(int *)(v1 + 24);
5692 if ( (signed int)v11 > *(int *)(v1 + 32) )
5693 v11 = *(int *)(v1 + 32);
5694 v12 = *(char *)(*(int *)(v1 + 56)
5695 + (*(int *)(v1 + 12) & (v10 >> 16))
5696 + ((*(int *)(v1 + 8) & v11) >> *(char *)(v1 + 16)));
5697 result += 4;
5698 v2 += *(int *)(v1 + 4);
5699 if ( v12 )
5700 *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v12);
5701 v3 += *(int *)v1;
5702 LABEL_25:
5703 v14 = __OFSUB__(*(int *)(v1 + 40), 2);
5704 v13 = *(int *)(v1 + 40) - 2 < 0;
5705 *(int *)(v1 + 40) -= 2;
5706 if ( v13 ^ v14 )
5707 break;
5708 v7 = v2;
5709 v8 = v3;
5710 if ( (signed int)v2 < *(int *)(v1 + 20) )
5711 v7 = *(int *)(v1 + 20);
5712 if ( (signed int)v3 < *(int *)(v1 + 28) )
5713 v8 = *(int *)(v1 + 28);
5714 if ( (signed int)v7 > *(int *)(v1 + 24) )
5715 v7 = *(int *)(v1 + 24);
5716 if ( (signed int)v8 > *(int *)(v1 + 32) )
5717 v8 = *(int *)(v1 + 32);
5718 v9 = *(char *)(*(int *)(v1 + 56)
5719 + (*(int *)(v1 + 12) & (v7 >> 16))
5720 + ((*(int *)(v1 + 8) & v8) >> *(char *)(v1 + 16)));
5721 v2 += *(int *)(v1 + 4);
5722 if ( v9 )
5723 *(short *)result = *(short *)(*(int *)(v1 + 52) + 2 * v9);
5724 v3 += *(int *)v1;
5725 v5 = *(int *)(v1 + 60);
5726 v6 = *(int *)(v1 + 36);
5727 *(int *)(v1 + 60) += 8;
5728 *(int *)(v5 + 4) = v6;
5729 }
5730 return result;
5731 }
5732
5733 //----- (004D73DF) --------------------------------------------------------
5734 int /*__usercall*/ sr_sub_4D73DF/*<eax>*/(int a1/*<ebp>*/)
5735 {
5736 int v1; // ebp@1
5737 unsigned int v2; // esi@1
5738 unsigned int v3; // edi@1
5739 int result; // eax@1
5740 int v5; // ebx@2
5741 int v6; // edx@2
5742 int v7; // edx@3
5743 int v8; // edx@6
5744 unsigned __int8 v9; // sf@9
5745 unsigned __int8 v10; // of@9
5746
5747 v1 = *(int *)(a1 + 8);
5748 v2 = *(int *)(v1 + 48);
5749 v3 = *(int *)(v1 + 44);
5750 result = *(int *)(v1 + 64);
5751 if ( !(*(int *)(v1 + 40) & 1) )
5752 goto LABEL_9;
5753 --*(int *)(v1 + 40);
5754 result -= 2;
5755 v5 = *(int *)(v1 + 60);
5756 v6 = *(int *)(v1 + 36);
5757 *(int *)(v1 + 60) += 4;
5758 while ( 1 )
5759 {
5760 *(int *)v5 = v6;
5761 v8 = *(int *)(v1 + 12) & (v2 >> 16);
5762 result += 4;
5763 v2 += *(int *)(v1 + 4);
5764 if ( *(char *)(*(int *)(v1 + 56) + v8 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) )
5765 *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52)
5766 + 2
5767 * *(char *)(*(int *)(v1 + 56)
5768 + v8
5769 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))));
5770 v3 += *(int *)v1;
5771 LABEL_9:
5772 v10 = __OFSUB__(*(int *)(v1 + 40), 2);
5773 v9 = *(int *)(v1 + 40) - 2 < 0;
5774 *(int *)(v1 + 40) -= 2;
5775 if ( v9 ^ v10 )
5776 break;
5777 v7 = *(int *)(v1 + 12) & (v2 >> 16);
5778 v2 += *(int *)(v1 + 4);
5779 if ( *(char *)(*(int *)(v1 + 56) + v7 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) )
5780 *(short *)result = *(short *)(*(int *)(v1 + 52)
5781 + 2
5782 * *(char *)(*(int *)(v1 + 56)
5783 + v7
5784 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))));
5785 v3 += *(int *)v1;
5786 v5 = *(int *)(v1 + 60);
5787 v6 = *(int *)(v1 + 36);
5788 *(int *)(v1 + 60) += 8;
5789 *(int *)(v5 + 4) = v6;
5790 }
5791 return result;
5792 }
5793
5794 //----- (004D754B) --------------------------------------------------------
5795 void __cdecl sr_sub_4D754B(stru315 *a1, stru316 *a2)
5796 {
5797 int v2; // ecx@1
5798 unsigned int v3; // eax@2
5799 int v4; // ecx@2
5800 int v5; // eax@10
5801 unsigned __int16 *v6; // edx@10
5802 int v7; // ebx@11
5803 int v8; // ecx@13
5804 unsigned __int16 v9; // bx@16
5805 int v10; // ecx@16
5806 unsigned __int16 *v11; // eax@16
5807 unsigned int *v12; // edx@16
5808 int v13; // ecx@16
5809 int v14; // eax@16
5810 int v15; // ebx@16
5811 int v16; // [sp-4h] [bp-Ch]@2
5812
5813 v2 = a1->field_28;
5814 if ( v2 )
5815 {
5816 do
5817 {
5818 v16 = v2;
5819 v3 = a1->field_30;
5820 v4 = a1->field_2C;
5821 if ( (signed int)v3 >= a1->field_18 )
5822 v3 = a1->field_18;
5823 if ( (signed int)v3 <= a1->field_14 )
5824 v3 = a1->field_14;
5825 if ( v4 >= a1->field_20 )
5826 v4 = a1->field_20;
5827 if ( v4 <= a1->field_1C )
5828 v4 = a1->field_1C;
5829 v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10));
5830 v6 = a1->field_34_palette;
5831 if ( a2->field_20 )
5832 {
5833 v7 = (unsigned int)a2->field_10 >> 16;
5834 if ( v7 >= a2->field_C )
5835 v7 = a2->field_C;
5836 v8 = 0;
5837 if ( a2->field_8 - v7 >= 0 )
5838 v8 = a2->field_8 - v7;
5839 v5 += v8 << 8;
5840 v6 = a2->field_24_palette;
5841 }
5842 v9 = v6[v5];
5843 v10 = a1->field_24;
5844 v11 = a1->pColorBuffer;
5845 v12 = a1->pDepthBuffer;
5846 *v11 = v9;
5847 *v12 = v10;
5848 a1->pColorBuffer = v11 + 1;
5849 a1->pDepthBuffer = v12 + 1;
5850 v13 = a1->field_30;
5851 a2->field_10 += a2->field_18;
5852 v14 = a1->field_2C;
5853 v15 = a1->field_0;
5854 a1->field_30 = a1->field_4 + v13;
5855 a1->field_2C = v15 + v14;
5856 v2 = v16 - 1;
5857 }
5858 while ( v16 != 1 );
5859 }
5860 }
5861
5862 //----- (004D7630) --------------------------------------------------------
5863 void __cdecl sr_sub_4D7630(stru315 *a1, stru316 *a2)
5864 {
5865 int v2; // ecx@1
5866 int v3; // eax@2
5867 unsigned __int16 *v4; // edx@2
5868 int v5; // ebx@3
5869 int v6; // ecx@5
5870 unsigned __int16 v7; // bx@8
5871 int v8; // ecx@8
5872 unsigned __int16 *v9; // eax@8
5873 unsigned int *v10; // edx@8
5874 int v11; // ecx@8
5875 int v12; // eax@8
5876 int v13; // ebx@8
5877 int v14; // [sp-4h] [bp-Ch]@2
5878
5879 v2 = a1->field_28;
5880 if ( v2 )
5881 {
5882 do
5883 {
5884 v14 = v2;
5885 v3 = *((char *)a1->pTextureLOD
5886 + (a1->field_C & ((unsigned int)a1->field_30 >> 16))
5887 + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10));
5888 v4 = a1->field_34_palette;
5889 if ( a2->field_20 )
5890 {
5891 v5 = (unsigned int)a2->field_14 >> 16;
5892 if ( v5 >= a2->field_C )
5893 v5 = a2->field_C;
5894 v6 = 0;
5895 if ( a2->field_8 - v5 >= 0 )
5896 v6 = a2->field_8 - v5;
5897 v3 += v6 << 8;
5898 v4 = a2->field_24_palette;
5899 }
5900 v7 = v4[v3];
5901 v8 = a1->field_24;
5902 v9 = a1->pColorBuffer;
5903 v10 = a1->pDepthBuffer;
5904 *v9 = v7;
5905 *v10 = v8;
5906 a1->pColorBuffer = v9 - 1;
5907 a1->pDepthBuffer = v10 - 1;
5908 v11 = a1->field_30;
5909 a2->field_14 -= a2->field_18;
5910 v12 = a1->field_2C;
5911 v13 = a1->field_0;
5912 a1->field_30 = a1->field_4 + v11;
5913 a1->field_2C = v13 + v12;
5914 v2 = v14 - 1;
5915 }
5916 while ( v14 != 1 );
5917 }
5918 }
5919
5920 //----- (004D76ED) --------------------------------------------------------
5921 void __cdecl sr_sub_4D76ED(stru315 *a1, stru316 *a2)
5922 {
5923 int v2; // ecx@1
5924 unsigned int v3; // eax@2
5925 int v4; // ecx@2
5926 int v5; // eax@10
5927 unsigned __int16 *v6; // edx@10
5928 int v7; // ebx@11
5929 int v8; // ecx@13
5930 unsigned __int16 v9; // bx@16
5931 int v10; // ecx@16
5932 unsigned __int16 *v11; // eax@16
5933 unsigned int *v12; // edx@16
5934 int v13; // ecx@16
5935 int v14; // eax@16
5936 int v15; // ebx@16
5937 int v16; // [sp-4h] [bp-Ch]@2
5938
5939 v2 = a1->field_28;
5940 if ( v2 )
5941 {
5942 do
5943 {
5944 v16 = v2;
5945 v3 = a1->field_30;
5946 v4 = a1->field_2C;
5947 if ( (signed int)v3 >= a1->field_18 )
5948 v3 = a1->field_18;
5949 if ( (signed int)v3 <= a1->field_14 )
5950 v3 = a1->field_14;
5951 if ( v4 >= a1->field_20 )
5952 v4 = a1->field_20;
5953 if ( v4 <= a1->field_1C )
5954 v4 = a1->field_1C;
5955 v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10));
5956 v6 = a1->field_34_palette;
5957 if ( a2->field_20 )
5958 {
5959 v7 = (unsigned int)a2->field_14 >> 16;
5960 if ( v7 >= a2->field_C )
5961 v7 = a2->field_C;
5962 v8 = 0;
5963 if ( a2->field_8 - v7 >= 0 )
5964 v8 = a2->field_8 - v7;
5965 v5 += v8 << 8;
5966 v6 = a2->field_24_palette;
5967 }
5968 v9 = v6[v5];
5969 v10 = a1->field_24;
5970 v11 = a1->pColorBuffer;
5971 v12 = a1->pDepthBuffer;
5972 *v11 = v9;
5973 *v12 = v10;
5974 a1->pColorBuffer = v11 - 1;
5975 a1->pDepthBuffer = v12 - 1;
5976 v13 = a1->field_30;
5977 a2->field_14 -= a2->field_18;
5978 v14 = a1->field_2C;
5979 v15 = a1->field_0;
5980 a1->field_30 = a1->field_4 + v13;
5981 a1->field_2C = v15 + v14;
5982 v2 = v16 - 1;
5983 }
5984 while ( v16 != 1 );
5985 }
5986 }
5987
5988 //----- (004D77D2) --------------------------------------------------------
5989 void __cdecl sr_sub_4D77D2(stru315 *a1, stru316 *a2)
5990 {
5991 int v2; // ecx@1
5992 unsigned __int16 *v3; // ebx@2
5993 int v4; // eax@2
5994 unsigned __int16 *v5; // edx@2
5995 int v6; // ebx@4
5996 int v7; // ecx@6
5997 unsigned __int16 v8; // bx@9
5998 int v9; // ecx@9
5999 unsigned int *v10; // edx@9
6000 unsigned int *v11; // edx@10
6001 int v12; // ecx@10
6002 int v13; // eax@10
6003 int v14; // ebx@10
6004 int v15; // [sp-4h] [bp-Ch]@2
6005
6006 v2 = a1->field_28;
6007 if ( v2 )
6008 {
6009 do
6010 {
6011 v15 = v2;
6012 v3 = a1->pTextureLOD;
6013 v4 = *((char *)v3
6014 + (a1->field_C & ((unsigned int)a1->field_30 >> 16))
6015 + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10));
6016 v5 = a1->field_34_palette;
6017 if ( *((char *)v3
6018 + (a1->field_C & ((unsigned int)a1->field_30 >> 16))
6019 + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)) )
6020 {
6021 if ( a2->field_20 )
6022 {
6023 v6 = (unsigned int)a2->field_10 >> 16;
6024 if ( v6 >= a2->field_C )
6025 v6 = a2->field_C;
6026 v7 = 0;
6027 if ( a2->field_8 - v6 >= 0 )
6028 v7 = a2->field_8 - v6;
6029 v4 += v7 << 8;
6030 v5 = a2->field_24_palette;
6031 }
6032 v8 = v5[v4];
6033 v9 = a1->field_24;
6034 v10 = a1->pDepthBuffer;
6035 *a1->pColorBuffer = v8;
6036 *v10 = v9;
6037 }
6038 v11 = a1->pDepthBuffer + 1;
6039 ++a1->pColorBuffer;
6040 a1->pDepthBuffer = v11;
6041 v12 = a1->field_30;
6042 a2->field_10 += a2->field_18;
6043 v13 = a1->field_2C;
6044 v14 = a1->field_0;
6045 a1->field_30 = a1->field_4 + v12;
6046 a1->field_2C = v14 + v13;
6047 v2 = v15 - 1;
6048 }
6049 while ( v15 != 1 );
6050 }
6051 }
6052
6053 //----- (004D789A) --------------------------------------------------------
6054 void __cdecl sr_sub_4D789A(stru315 *a1, stru316 *a2)
6055 {
6056 int v2; // ecx@1
6057 unsigned int v3; // eax@2
6058 int v4; // ecx@2
6059 int v5; // eax@10
6060 unsigned __int16 *v6; // edx@10
6061 int v7; // ebx@12
6062 int v8; // ecx@14
6063 unsigned __int16 v9; // bx@17
6064 int v10; // ecx@17
6065 unsigned int *v11; // edx@17
6066 unsigned int *v12; // edx@18
6067 int v13; // ecx@18
6068 int v14; // eax@18
6069 int v15; // ebx@18
6070 int v16; // [sp-4h] [bp-Ch]@2
6071
6072 v2 = a1->field_28;
6073 if ( v2 )
6074 {
6075 do
6076 {
6077 v16 = v2;
6078 v3 = a1->field_30;
6079 v4 = a1->field_2C;
6080 if ( (signed int)v3 >= a1->field_18 )
6081 v3 = a1->field_18;
6082 if ( (signed int)v3 <= a1->field_14 )
6083 v3 = a1->field_14;
6084 if ( v4 >= a1->field_20 )
6085 v4 = a1->field_20;
6086 if ( v4 <= a1->field_1C )
6087 v4 = a1->field_1C;
6088 v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10));
6089 v6 = a1->field_34_palette;
6090 if ( v5 )
6091 {
6092 if ( a2->field_20 )
6093 {
6094 v7 = (unsigned int)a2->field_10 >> 16;
6095 if ( v7 >= a2->field_C )
6096 v7 = a2->field_C;
6097 v8 = 0;
6098 if ( a2->field_8 - v7 >= 0 )
6099 v8 = a2->field_8 - v7;
6100 v5 += v8 << 8;
6101 v6 = a2->field_24_palette;
6102 }
6103 v9 = v6[v5];
6104 v10 = a1->field_24;
6105 v11 = a1->pDepthBuffer;
6106 *a1->pColorBuffer = v9;
6107 *v11 = v10;
6108 }
6109 v12 = a1->pDepthBuffer + 1;
6110 ++a1->pColorBuffer;
6111 a1->pDepthBuffer = v12;
6112 v13 = a1->field_30;
6113 a2->field_10 += a2->field_18;
6114 v14 = a1->field_2C;
6115 v15 = a1->field_0;
6116 a1->field_30 = a1->field_4 + v13;
6117 a1->field_2C = v15 + v14;
6118 v2 = v16 - 1;
6119 }
6120 while ( v16 != 1 );
6121 }
6122 }
6123
6124
6125
6126
6127 //----- (00451007) --------------------------------------------------------
6128 int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch,
6129 unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch,
6130 int a10, int a11)
6131 {
6132 int v11; // esi@1
6133 int result; // eax@1
6134 int v13; // edi@8
6135 int v14; // ecx@10
6136 double v15; // st7@11
6137 double v16; // st6@11
6138 float v17; // ST3C_4@12
6139 float v18; // ST38_4@12
6140 unsigned int v19; // esi@12
6141 int v20; // eax@16
6142 int v21; // eax@18
6143 unsigned int v22; // ecx@25
6144 unsigned int v23; // eax@29
6145 unsigned __int16 *v24; // ecx@29
6146 int v25; // edi@33
6147 int v26; // ecx@35
6148 double v27; // st7@36
6149 double v28; // st6@36
6150 float v29; // ST34_4@37
6151 float v30; // ST30_4@37
6152 unsigned int v31; // esi@37
6153 int v32; // eax@41
6154 int v33; // eax@43
6155 unsigned int v34; // ecx@50
6156 unsigned __int16 v35; // ax@54
6157 unsigned __int16 *v36; // ecx@54
6158 int v37; // edi@58
6159 int v38; // ecx@60
6160 double v39; // st7@61
6161 double v40; // st6@61
6162 float v41; // ST34_4@62
6163 float v42; // ST30_4@62
6164 unsigned int v43; // esi@62
6165 int v44; // eax@66
6166 int v45; // eax@68
6167 unsigned int v46; // ecx@75
6168 char v47; // al@79
6169 unsigned __int16 *v48; // ecx@79
6170 int v49; // edi@86
6171 int v50; // ecx@88
6172 double v51; // st7@89
6173 double v52; // st6@89
6174 float v53; // ST34_4@90
6175 float v54; // ST30_4@90
6176 unsigned int v55; // esi@90
6177 int v56; // eax@94
6178 int v57; // eax@96
6179 unsigned int v58; // ecx@103
6180 unsigned int v59; // eax@107
6181 unsigned __int16 *v60; // ecx@107
6182 int v61; // edi@111
6183 int v62; // ecx@113
6184 double v63; // st7@114
6185 double v64; // st6@114
6186 float v65; // ST34_4@115
6187 float v66; // ST30_4@115
6188 unsigned int v67; // esi@115
6189 int v68; // eax@119
6190 int v69; // eax@121
6191 unsigned int v70; // ecx@128
6192 unsigned __int16 v71; // ax@132
6193 unsigned __int16 *v72; // ecx@132
6194 int v73; // edi@136
6195 int v74; // ecx@138
6196 double v75; // st7@139
6197 double v76; // st6@139
6198 float v77; // ST34_4@140
6199 float v78; // ST30_4@140
6200 unsigned int v79; // esi@140
6201 int v80; // eax@144
6202 int v81; // eax@146
6203 unsigned int v82; // ecx@153
6204 char v83; // al@157
6205 unsigned __int16 *v84; // ecx@157
6206 int v85; // edi@164
6207 int v86; // ecx@166
6208 double v87; // st7@167
6209 double v88; // st6@167
6210 float v89; // ST34_4@168
6211 float v90; // ST30_4@168
6212 unsigned int v91; // esi@168
6213 signed int v92; // eax@170
6214 int v93; // eax@171
6215 int v94; // eax@173
6216 unsigned int v95; // ecx@181
6217 unsigned int v96; // eax@185
6218 unsigned __int16 *v97; // ecx@185
6219 int v98; // edi@189
6220 int v99; // ecx@191
6221 double v100; // st7@192
6222 double v101; // st6@192
6223 float v102; // ST34_4@193
6224 float v103; // ST30_4@193
6225 unsigned int v104; // esi@193
6226 signed int v105; // eax@195
6227 int v106; // eax@196
6228 int v107; // eax@198
6229 unsigned int v108; // ecx@206
6230 unsigned __int16 v109; // ax@210
6231 unsigned __int16 *v110; // ecx@210
6232 int v111; // edi@214
6233 int v112; // ecx@216
6234 double v113; // st7@217
6235 double v114; // st6@217
6236 float v115; // ST34_4@218
6237 float v116; // ST30_4@218
6238 unsigned int v117; // esi@218
6239 signed int v118; // eax@220
6240 int v119; // eax@221
6241 int v120; // eax@223
6242 unsigned int v121; // ecx@231
6243 char v122; // al@235
6244 unsigned __int16 *v123; // ecx@235
6245 double v124; // [sp+Ch] [bp-7Ch]@12
6246 double v125; // [sp+Ch] [bp-7Ch]@37
6247 double v126; // [sp+Ch] [bp-7Ch]@62
6248 double v127; // [sp+Ch] [bp-7Ch]@90
6249 //double v128; // [sp+Ch] [bp-7Ch]@115
6250 uint _v128;
6251 double v129; // [sp+Ch] [bp-7Ch]@140
6252 double v130; // [sp+Ch] [bp-7Ch]@168
6253 double v131; // [sp+Ch] [bp-7Ch]@193
6254 double v132; // [sp+Ch] [bp-7Ch]@218
6255 double v133; // [sp+14h] [bp-74h]@12
6256 double v134; // [sp+14h] [bp-74h]@37
6257 double v135; // [sp+14h] [bp-74h]@62
6258 double v136; // [sp+14h] [bp-74h]@90
6259 //double v137; // [sp+14h] [bp-74h]@115
6260 uint _v137;
6261 double v138; // [sp+14h] [bp-74h]@140
6262 double v139; // [sp+14h] [bp-74h]@168
6263 double v140; // [sp+14h] [bp-74h]@193
6264 double v141; // [sp+14h] [bp-74h]@218
6265 double v142; // [sp+1Ch] [bp-6Ch]@12
6266 double v143; // [sp+1Ch] [bp-6Ch]@37
6267 double v144; // [sp+1Ch] [bp-6Ch]@62
6268 double v145; // [sp+1Ch] [bp-6Ch]@90
6269 //double v146; // [sp+1Ch] [bp-6Ch]@115
6270 uint _v146;
6271 double v147; // [sp+1Ch] [bp-6Ch]@140
6272 double v148; // [sp+1Ch] [bp-6Ch]@168
6273 double v149; // [sp+1Ch] [bp-6Ch]@193
6274 double v150; // [sp+1Ch] [bp-6Ch]@218
6275 double v151; // [sp+24h] [bp-64h]@12
6276 double v152; // [sp+24h] [bp-64h]@37
6277 double v153; // [sp+24h] [bp-64h]@62
6278 double v154; // [sp+24h] [bp-64h]@90
6279 //double v155; // [sp+24h] [bp-64h]@115
6280 uint _v155;
6281 double v156; // [sp+24h] [bp-64h]@140
6282 double v157; // [sp+24h] [bp-64h]@168
6283 double v158; // [sp+24h] [bp-64h]@193
6284 double v159; // [sp+24h] [bp-64h]@218
6285 int v160; // [sp+3Ch] [bp-4Ch]@13
6286 int v161; // [sp+40h] [bp-48h]@15
6287 int v162; // [sp+44h] [bp-44h]@40
6288 int v163; // [sp+44h] [bp-44h]@65
6289 int v164; // [sp+44h] [bp-44h]@93
6290 int v165; // [sp+44h] [bp-44h]@118
6291 int v166; // [sp+44h] [bp-44h]@143
6292 int v167; // [sp+44h] [bp-44h]@169
6293 int v168; // [sp+44h] [bp-44h]@194
6294 int v169; // [sp+44h] [bp-44h]@219
6295 int v170; // [sp+48h] [bp-40h]@38
6296 int v171; // [sp+48h] [bp-40h]@63
6297 int v172; // [sp+48h] [bp-40h]@91
6298 int v173; // [sp+48h] [bp-40h]@116
6299 int v174; // [sp+48h] [bp-40h]@141
6300 unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
6301 int *v176; // [sp+50h] [bp-38h]@15
6302 int *v177; // [sp+50h] [bp-38h]@40
6303 int *v178; // [sp+50h] [bp-38h]@65
6304 int *v179; // [sp+50h] [bp-38h]@93
6305 int *v180; // [sp+50h] [bp-38h]@118
6306 int *v181; // [sp+50h] [bp-38h]@143
6307 char *v182; // [sp+50h] [bp-38h]@169
6308 char *v183; // [sp+50h] [bp-38h]@194
6309 char *v184; // [sp+50h] [bp-38h]@219
6310 unsigned __int16 *v185; // [sp+54h] [bp-34h]@38
6311 unsigned __int16 *v186; // [sp+54h] [bp-34h]@63
6312 unsigned __int16 *v187; // [sp+54h] [bp-34h]@91
6313 unsigned __int16 *v188; // [sp+54h] [bp-34h]@116
6314 unsigned __int16 *v189; // [sp+54h] [bp-34h]@141
6315 signed int v190; // [sp+54h] [bp-34h]@170
6316 signed int v191; // [sp+54h] [bp-34h]@195
6317 signed int v192; // [sp+54h] [bp-34h]@220
6318 unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
6319 unsigned __int16 *v194; // [sp+5Ch] [bp-2Ch]@32
6320 unsigned __int16 *v195; // [sp+5Ch] [bp-2Ch]@57
6321 unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85
6322 unsigned __int16 *v197; // [sp+5Ch] [bp-2Ch]@110
6323 unsigned __int16 *v198; // [sp+5Ch] [bp-2Ch]@135
6324 unsigned __int16 *v199; // [sp+5Ch] [bp-2Ch]@163
6325 unsigned __int16 *v200; // [sp+5Ch] [bp-2Ch]@188
6326 unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213
6327 //stru350 *v202; // [sp+60h] [bp-28h]@1
6328 int v203; // [sp+64h] [bp-24h]@12
6329 int v204; // [sp+64h] [bp-24h]@37
6330 int v205; // [sp+64h] [bp-24h]@62
6331 int v206; // [sp+64h] [bp-24h]@90
6332 int v207; // [sp+64h] [bp-24h]@115
6333 int v208; // [sp+64h] [bp-24h]@140
6334 int v209; // [sp+64h] [bp-24h]@168
6335 int v210; // [sp+64h] [bp-24h]@193
6336 int v211; // [sp+64h] [bp-24h]@218
6337 float v212; // [sp+6Ch] [bp-1Ch]@11
6338 float v213; // [sp+6Ch] [bp-1Ch]@36
6339 float v214; // [sp+6Ch] [bp-1Ch]@61
6340 float v215; // [sp+6Ch] [bp-1Ch]@89
6341 float v216; // [sp+6Ch] [bp-1Ch]@114
6342 float v217; // [sp+6Ch] [bp-1Ch]@139
6343 float v218; // [sp+6Ch] [bp-1Ch]@167
6344 float v219; // [sp+6Ch] [bp-1Ch]@192
6345 float v220; // [sp+6Ch] [bp-1Ch]@217
6346 float v221; // [sp+70h] [bp-18h]@11
6347 float v222; // [sp+70h] [bp-18h]@36
6348 float v223; // [sp+70h] [bp-18h]@61
6349 float v224; // [sp+70h] [bp-18h]@89
6350 float v225; // [sp+70h] [bp-18h]@114
6351 float v226; // [sp+70h] [bp-18h]@139
6352 float v227; // [sp+70h] [bp-18h]@167
6353 float v228; // [sp+70h] [bp-18h]@192
6354 float v229; // [sp+70h] [bp-18h]@217
6355 signed int v230; // [sp+74h] [bp-14h]@1
6356 signed int v231; // [sp+78h] [bp-10h]@7
6357 signed int v232; // [sp+78h] [bp-10h]@32
6358 signed int v233; // [sp+78h] [bp-10h]@57
6359 signed int v234; // [sp+78h] [bp-10h]@85
6360 signed int v235; // [sp+78h] [bp-10h]@110
6361 signed int v236; // [sp+78h] [bp-10h]@135
6362 signed int v237; // [sp+78h] [bp-10h]@163
6363 signed int v238; // [sp+78h] [bp-10h]@188
6364 signed int v239; // [sp+78h] [bp-10h]@213
6365 __int64 v240; // [sp+7Ch] [bp-Ch]@12
6366 __int64 v241; // [sp+7Ch] [bp-Ch]@37
6367 __int64 v242; // [sp+7Ch] [bp-Ch]@62
6368 __int64 v243; // [sp+7Ch] [bp-Ch]@90
6369 __int64 v244; // [sp+7Ch] [bp-Ch]@115
6370 __int64 v245; // [sp+7Ch] [bp-Ch]@140
6371 unsigned int v246; // [sp+7Ch] [bp-Ch]@168
6372 unsigned int v247; // [sp+7Ch] [bp-Ch]@193
6373 unsigned int v248; // [sp+7Ch] [bp-Ch]@218
6374 unsigned int v249; // [sp+80h] [bp-8h]@168
6375 unsigned int v250; // [sp+80h] [bp-8h]@193
6376 unsigned int v251; // [sp+80h] [bp-8h]@218
6377 unsigned int v252; // [sp+84h] [bp-4h]@12
6378 unsigned int v253; // [sp+84h] [bp-4h]@37
6379 unsigned int v254; // [sp+84h] [bp-4h]@62
6380 unsigned int v255; // [sp+84h] [bp-4h]@90
6381 unsigned int v256; // [sp+84h] [bp-4h]@115
6382 unsigned int v257; // [sp+84h] [bp-4h]@140
6383 unsigned int v258; // [sp+84h] [bp-4h]@168
6384 unsigned int v259; // [sp+84h] [bp-4h]@193
6385 unsigned int v260; // [sp+84h] [bp-4h]@218
6386 signed int a6a; // [sp+A0h] [bp+18h]@10
6387 float a6s; // [sp+A0h] [bp+18h]@12
6388 float a6t; // [sp+A0h] [bp+18h]@12
6389 unsigned int a6b; // [sp+A0h] [bp+18h]@12
6390 signed int a6c; // [sp+A0h] [bp+18h]@35
6391 float a6u; // [sp+A0h] [bp+18h]@37
6392 float a6v; // [sp+A0h] [bp+18h]@37
6393 unsigned int a6d; // [sp+A0h] [bp+18h]@37
6394 signed int a6e; // [sp+A0h] [bp+18h]@60
6395 float a6w; // [sp+A0h] [bp+18h]@62
6396 float a6x; // [sp+A0h] [bp+18h]@62
6397 unsigned int a6f; // [sp+A0h] [bp+18h]@62
6398 signed int a6g; // [sp+A0h] [bp+18h]@88
6399 float a6y; // [sp+A0h] [bp+18h]@90
6400 float a6z; // [sp+A0h] [bp+18h]@90
6401 unsigned int a6h; // [sp+A0h] [bp+18h]@90
6402 signed int a6i; // [sp+A0h] [bp+18h]@113
6403 float a6ba; // [sp+A0h] [bp+18h]@115
6404 float a6bb; // [sp+A0h] [bp+18h]@115
6405 unsigned int a6j; // [sp+A0h] [bp+18h]@115
6406 signed int a6k; // [sp+A0h] [bp+18h]@138
6407 float a6bc; // [sp+A0h] [bp+18h]@140
6408 float a6bd; // [sp+A0h] [bp+18h]@140
6409 unsigned int a6l; // [sp+A0h] [bp+18h]@140
6410 signed int a6m; // [sp+A0h] [bp+18h]@166
6411 float a6be; // [sp+A0h] [bp+18h]@168
6412 float a6bf; // [sp+A0h] [bp+18h]@168
6413 unsigned int a6n; // [sp+A0h] [bp+18h]@168
6414 signed int a6o; // [sp+A0h] [bp+18h]@191
6415 float a6bg; // [sp+A0h] [bp+18h]@193
6416 float a6bh; // [sp+A0h] [bp+18h]@193
6417 unsigned int a6p; // [sp+A0h] [bp+18h]@193
6418 signed int a6q; // [sp+A0h] [bp+18h]@216
6419 float a6bi; // [sp+A0h] [bp+18h]@218
6420 float a6bj; // [sp+A0h] [bp+18h]@218
6421 unsigned int a6r; // [sp+A0h] [bp+18h]@218
6422 int a9a; // [sp+ACh] [bp+24h]@8
6423 int a9b; // [sp+ACh] [bp+24h]@33
6424 int a9c; // [sp+ACh] [bp+24h]@86
6425 int a9d; // [sp+ACh] [bp+24h]@111
6426 int a9e; // [sp+ACh] [bp+24h]@164
6427 int a9f; // [sp+ACh] [bp+24h]@189
6428
6429 v11 = 0;
6430 result = this->field_0.field_C;
6431 //v202 = this;
6432 v230 = 0;
6433 if ( result != 8 )
6434 {
6435 if ( result != 16 )
6436 {
6437 if ( result != 32 )
6438 return result;
6439 result = this->field_20.field_C;
6440 if ( result != 8 )
6441 {
6442 if ( result != 16 )
6443 {
6444 if ( result != 32 || (result = (int)pDst, v193 = pDst, v231 = 0, dstHeight <= 0) )
6445 return result;
6446 v13 = dstWidth;
6447 a9a = 4 * (dstPitch - dstWidth);
6448 while ( 1 )
6449 {
6450 v14 = 0;
6451 a6a = 0;
6452 if ( dstWidth > v11 )
6453 break;
6454 LABEL_30:
6455 v193 = (unsigned __int16 *)((char *)v193 + a9a);
6456 ++v231;
6457 result = v231;
6458 if ( v231 >= dstHeight )
6459 return result;
6460 v11 = 0;
6461 }
6462 v221 = (double)dstWidth;
6463 v212 = (double)srcWidth;
6464 v15 = (double)dstHeight;
6465 v16 = (double)srcHeight;
6466 while ( 1 )
6467 {
6468 a6s = (double)a6a / v221 * v212;
6469 v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
6470 v203 = v14 + 1;
6471 a6t = (double)(v14 + 1) / v221 * v212;
6472 v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
6473 v17 = (double)v231 / v15 * v16;
6474 v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
6475 v18 = (double)(v231 + 1) / v15 * v16;
6476 v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
6477 v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
6478 v252 = 0;
6479 a6b = 0;
6480 v240 = 0i64;
6481 if ( SLODWORD(v133) < SLODWORD(v124) )
6482 break;
6483 LABEL_25:
6484 v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
6485 if ( v19 )
6486 {
6487 a6b /= v19;
6488 v252 /= v19;
6489 HIDWORD(v240) /= v19;
6490 }
6491 if ( v22 != 255 )
6492 v22 &= 0x7FFFFFFFu;
6493 v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
6494 v24 = v193;
6495 v193 += 2;
6496 *(_DWORD *)v24 = v23;
6497 v14 = v203;
6498 a6a = v203;
6499 if ( v203 >= dstWidth )
6500 goto LABEL_30;
6501 }
6502 v160 = LODWORD(v124) - LODWORD(v133);
6503 v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
6504 while ( SLODWORD(v151) >= SLODWORD(v142) )
6505 {
6506 LABEL_24:
6507 v175 += 2 * srcPitch;
6508 --v160;
6509 if ( !v160 )
6510 goto LABEL_25;
6511 }
6512 v176 = (int *)v175;
6513 v161 = LODWORD(v142) - LODWORD(v151);
6514 while ( 1 )
6515 {
6516 v20 = *v176;
6517 if ( a10 )
6518 {
6519 v230 = 1;
6520 v13 = v20 != a11 ? 0xFF : 0;
6521 }
6522 v21 = _450FB1(v20);
6523 if ( !v230 )
6524 break;
6525 LODWORD(v240) = v13 + v240;
6526 v230 = 0;
6527 if ( v13 )
6528 goto LABEL_22;
6529 --v19;
6530 LABEL_23:
6531 ++v176;
6532 --v161;
6533 if ( !v161 )
6534 goto LABEL_24;
6535 }
6536 LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
6537 LABEL_22:
6538 a6b += BYTE2(v21);
6539 v252 += BYTE1(v21);
6540 HIDWORD(v240) += (unsigned __int8)v21;
6541 goto LABEL_23;
6542 }
6543 result = (int)pDst;
6544 v194 = pDst;
6545 v232 = 0;
6546 if ( dstHeight <= 0 )
6547 return result;
6548 v25 = dstWidth;
6549 a9b = 2 * (dstPitch - dstWidth);
6550 while ( 1 )
6551 {
6552 v26 = 0;
6553 a6c = 0;
6554 if ( dstWidth > v11 )
6555 break;
6556 LABEL_55:
6557 v194 = (unsigned __int16 *)((char *)v194 + a9b);
6558 ++v232;
6559 result = v232;
6560 if ( v232 >= dstHeight )
6561 return result;
6562 v11 = 0;
6563 }
6564 v222 = (double)dstWidth;
6565 v213 = (double)srcWidth;
6566 v27 = (double)dstHeight;
6567 v28 = (double)srcHeight;
6568 while ( 1 )
6569 {
6570 a6u = (double)a6c / v222 * v213;
6571 v125 = a6u + 6.7553994e15;
6572 v204 = v26 + 1;
6573 a6v = (double)(v26 + 1) / v222 * v213;
6574 v134 = a6v + 6.7553994e15;
6575 v29 = (double)v232 / v27 * v28;
6576 v143 = v29 + 6.7553994e15;
6577 v30 = (double)(v232 + 1) / v27 * v28;
6578 v152 = v30 + 6.7553994e15;
6579 v31 = (LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125));
6580 v253 = 0;
6581 a6d = 0;
6582 v241 = 0i64;
6583 if ( SLODWORD(v143) < SLODWORD(v152) )
6584 break;
6585 LABEL_50:
6586 v34 = (unsigned int)v241 / ((LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125)));
6587 if ( v31 )
6588 {
6589 a6d /= v31;
6590 v253 /= v31;
6591 HIDWORD(v241) /= v31;
6592 }
6593 if ( v34 != 255 )
6594 v34 &= 0x7FFFFFFFu;
6595 v35 = _450F55(HIDWORD(v241) | ((v253 | ((a6d | (v34 << 8)) << 8)) << 8));
6596 v36 = v194;
6597 ++v194;
6598 *v36 = v35;
6599 v26 = v204;
6600 a6c = v204;
6601 if ( v204 >= dstWidth )
6602 goto LABEL_55;
6603 }
6604 v170 = LODWORD(v152) - LODWORD(v143);
6605 v185 = &pSrc[2 * (LODWORD(v125) + srcPitch * LODWORD(v143))];
6606 while ( SLODWORD(v125) >= SLODWORD(v134) )
6607 {
6608 LABEL_49:
6609 v185 += 2 * srcPitch;
6610 --v170;
6611 if ( !v170 )
6612 goto LABEL_50;
6613 }
6614 v177 = (int *)v185;
6615 v162 = LODWORD(v134) - LODWORD(v125);
6616 while ( 1 )
6617 {
6618 v32 = *v177;
6619 if ( a10 )
6620 {
6621 v230 = 1;
6622 v25 = v32 != a11 ? 0xFF : 0;
6623 }
6624 v33 = _450FB1(v32);
6625 if ( !v230 )
6626 break;
6627 LODWORD(v241) = v25 + v241;
6628 v230 = 0;
6629 if ( v25 )
6630 goto LABEL_47;
6631 --v31;
6632 LABEL_48:
6633 ++v177;
6634 --v162;
6635 if ( !v162 )
6636 goto LABEL_49;
6637 }
6638 LODWORD(v241) = ((unsigned int)v33 >> 24) + v241;
6639 LABEL_47:
6640 a6d += BYTE2(v33);
6641 v253 += BYTE1(v33);
6642 HIDWORD(v241) += (unsigned __int8)v33;
6643 goto LABEL_48;
6644 }
6645 result = (int)pDst;
6646 v195 = pDst;
6647 v233 = 0;
6648 if ( dstHeight <= 0 )
6649 return result;
6650 v37 = dstWidth;
6651 while ( 1 )
6652 {
6653 v38 = 0;
6654 a6e = 0;
6655 if ( dstWidth > v11 )
6656 break;
6657 LABEL_80:
6658 v195 = (unsigned __int16 *)((char *)v195 + dstPitch - dstWidth);
6659 ++v233;
6660 result = v233;
6661 if ( v233 >= dstHeight )
6662 return result;
6663 v11 = 0;
6664 }
6665 v223 = (double)dstWidth;
6666 v214 = (double)srcWidth;
6667 v39 = (double)dstHeight;
6668 v40 = (double)srcHeight;
6669 while ( 1 )
6670 {
6671 a6w = (double)a6e / v223 * v214;
6672 v126 = a6w + 6.7553994e15;
6673 v205 = v38 + 1;
6674 a6x = (double)(v38 + 1) / v223 * v214;
6675 v135 = a6x + 6.7553994e15;
6676 v41 = (double)v233 / v39 * v40;
6677 v144 = v41 + 6.7553994e15;
6678 v42 = (double)(v233 + 1) / v39 * v40;
6679 v153 = v42 + 6.7553994e15;
6680 v43 = (LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126));
6681 v254 = 0;
6682 a6f = 0;
6683 v242 = 0i64;
6684 if ( SLODWORD(v144) < SLODWORD(v153) )
6685 break;
6686 LABEL_75:
6687 v46 = (unsigned int)v242 / ((LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126)));
6688 if ( v43 )
6689 {
6690 a6f /= v43;
6691 v254 /= v43;
6692 HIDWORD(v242) /= v43;
6693 }
6694 if ( v46 != 255 )
6695 v46 &= 0x7FFFFFFFu;
6696 v47 = _450F55(HIDWORD(v242) | ((v254 | ((a6f | (v46 << 8)) << 8)) << 8));
6697 v48 = v195;
6698 v195 = (unsigned __int16 *)((char *)v195 + 1);
6699 *(_BYTE *)v48 = v47;
6700 v38 = v205;
6701 a6e = v205;
6702 if ( v205 >= dstWidth )
6703 goto LABEL_80;
6704 }
6705 v171 = LODWORD(v153) - LODWORD(v144);
6706 v186 = &pSrc[2 * (LODWORD(v126) + srcPitch * LODWORD(v144))];
6707 while ( SLODWORD(v126) >= SLODWORD(v135) )
6708 {
6709 LABEL_74:
6710 v186 += 2 * srcPitch;
6711 --v171;
6712 if ( !v171 )
6713 goto LABEL_75;
6714 }
6715 v178 = (int *)v186;
6716 v163 = LODWORD(v135) - LODWORD(v126);
6717 while ( 1 )
6718 {
6719 v44 = *v178;
6720 if ( a10 )
6721 {
6722 v230 = 1;
6723 v37 = v44 != a11 ? 0xFF : 0;
6724 }
6725 v45 = _450FB1(v44);
6726 if ( !v230 )
6727 break;
6728 LODWORD(v242) = v37 + v242;
6729 v230 = 0;
6730 if ( v37 )
6731 goto LABEL_72;
6732 --v43;
6733 LABEL_73:
6734 ++v178;
6735 --v163;
6736 if ( !v163 )
6737 goto LABEL_74;
6738 }
6739 LODWORD(v242) = ((unsigned int)v45 >> 24) + v242;
6740 LABEL_72:
6741 a6f += BYTE2(v45);
6742 v254 += BYTE1(v45);
6743 HIDWORD(v242) += (unsigned __int8)v45;
6744 goto LABEL_73;
6745 }
6746 result = this->field_20.field_C;
6747 if ( result != 8 )
6748 {
6749 if ( result != 16 )
6750 {
6751 if ( result != 32 || (result = (int)pDst, v196 = pDst, v234 = 0, dstHeight <= 0) )
6752 return result;
6753 v49 = dstWidth;
6754 a9c = 4 * (dstPitch - dstWidth);
6755 while ( 1 )
6756 {
6757 v50 = 0;
6758 a6g = 0;
6759 if ( dstWidth > v11 )
6760 break;
6761 LABEL_108:
6762 v196 = (unsigned __int16 *)((char *)v196 + a9c);
6763 ++v234;
6764 result = v234;
6765 if ( v234 >= dstHeight )
6766 return result;
6767 v11 = 0;
6768 }
6769 v224 = (double)dstWidth;
6770 v215 = (double)srcWidth;
6771 v51 = (double)dstHeight;
6772 v52 = (double)srcHeight;
6773 while ( 1 )
6774 {
6775 a6y = (double)a6g / v224 * v215;
6776 v127 = a6y + 6.7553994e15;
6777 v206 = v50 + 1;
6778 a6z = (double)(v50 + 1) / v224 * v215;
6779 v136 = a6z + 6.7553994e15;
6780 v53 = (double)v234 / v51 * v52;
6781 v145 = v53 + 6.7553994e15;
6782 v54 = (double)(v234 + 1) / v51 * v52;
6783 v154 = v54 + 6.7553994e15;
6784 v55 = (LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127));
6785 v255 = 0;
6786 a6h = 0;
6787 v243 = 0i64;
6788 if ( SLODWORD(v145) < SLODWORD(v154) )
6789 break;
6790 LABEL_103:
6791 v58 = (unsigned int)v243 / ((LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127)));
6792 if ( v55 )
6793 {
6794 a6h /= v55;
6795 v255 /= v55;
6796 HIDWORD(v243) /= v55;
6797 }
6798 if ( v58 != 255 )
6799 v58 &= 0x7FFFFFFFu;
6800 v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
6801 v60 = v196;
6802 v196 += 2;
6803 *(_DWORD *)v60 = v59;
6804 v50 = v206;
6805 a6g = v206;
6806 if ( v206 >= dstWidth )
6807 goto LABEL_108;
6808 }
6809 v172 = LODWORD(v154) - LODWORD(v145);
6810 v187 = &pSrc[LODWORD(v127) + srcPitch * LODWORD(v145)];
6811 while ( SLODWORD(v127) >= SLODWORD(v136) )
6812 {
6813 LABEL_102:
6814 v187 += srcPitch;
6815 --v172;
6816 if ( !v172 )
6817 goto LABEL_103;
6818 }
6819 v179 = (int *)v187;
6820 v164 = LODWORD(v136) - LODWORD(v127);
6821 while ( 1 )
6822 {
6823 v56 = *(_WORD *)v179;
6824 if ( a10 )
6825 {
6826 v230 = 1;
6827 v49 = v56 != a11 ? 0xFF : 0;
6828 }
6829 v57 = _450FB1(v56);
6830 if ( !v230 )
6831 break;
6832 LODWORD(v243) = v49 + v243;
6833 v230 = 0;
6834 if ( v49 )
6835 goto LABEL_100;
6836 --v55;
6837 LABEL_101:
6838 v179 = (int *)((char *)v179 + 2);
6839 --v164;
6840 if ( !v164 )
6841 goto LABEL_102;
6842 }
6843 LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
6844 LABEL_100:
6845 a6h += BYTE2(v57);
6846 v255 += BYTE1(v57);
6847 HIDWORD(v243) += (unsigned __int8)v57;
6848 goto LABEL_101;
6849 }
6850 result = (int)pDst;
6851 v197 = pDst;
6852 v235 = 0;
6853 if ( dstHeight <= 0 )
6854 return result;
6855 v61 = dstWidth;
6856 a9d = 2 * (dstPitch - dstWidth);
6857 while ( 1 )
6858 {
6859 v62 = 0;
6860 a6i = 0;
6861 if ( dstWidth > v11 )
6862 break;
6863 LABEL_133:
6864 v197 = (unsigned __int16 *)((char *)v197 + a9d);
6865 ++v235;
6866 result = v235;
6867 if ( v235 >= dstHeight )
6868 return result;
6869 v11 = 0;
6870 }
6871 v225 = (double)dstWidth;
6872 v216 = (double)srcWidth;
6873 v63 = (double)dstHeight;
6874 v64 = (double)srcHeight;
6875 while ( 1 )
6876 {
6877 a6ba = (double)a6i / v225 * v216;
6878 _v128 = floorf(a6ba + 0.5f);
6879 //v128 = a6ba + 6.7553994e15;
6880 v207 = v62 + 1;
6881 a6bb = (double)(v62 + 1) / v225 * v216;
6882 //v137 = a6bb + 6.7553994e15;
6883 _v137 = floorf(a6bb + 0.5f);
6884 v65 = (double)v235 / v63 * v64;
6885 //v146 = v65 + 6.7553994e15;
6886 _v146 = floorf(v65 + 0.5f);
6887 v66 = (double)(v235 + 1) / v63 * v64;
6888 //v155 = v66 + 6.7553994e15;
6889 _v155 = floorf(v66 + 0.5f);
6890 //v67 = (LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128));
6891 v67 = (_v155 - _v146) * (_v137 - _v128);
6892 v256 = 0;
6893 a6j = 0;
6894 v244 = 0i64;
6895 //if ( SLODWORD(v146) < SLODWORD(v155) )
6896 if (_v146 < _v155)
6897 break;
6898 LABEL_128:
6899 //v70 = (unsigned int)v244 / ((LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128)));
6900 v70 = (unsigned int)v244 / ((_v155 - _v146) * (_v137 - _v128));
6901 if ( v67 )
6902 {
6903 a6j /= v67;
6904 v256 /= v67;
6905 HIDWORD(v244) /= v67;
6906 }
6907 if ( v70 != 255 )
6908 v70 &= 0x7FFFFFFFu;
6909 v71 = _450F55(HIDWORD(v244) | ((v256 | ((a6j | (v70 << 8)) << 8)) << 8));
6910 v72 = v197;
6911 ++v197;
6912 *v72 = v71;
6913 v62 = v207;
6914 a6i = v207;
6915 if ( v207 >= dstWidth )
6916 goto LABEL_133;
6917 }
6918 //v173 = LODWORD(v155) - LODWORD(v146);
6919 v173 = _v155 - _v146;
6920 //v188 = &pSrc[LODWORD(v128) + srcPitch * LODWORD(v146)];
6921 v188 = &pSrc[_v128 + srcPitch * _v146];
6922 //while ( SLODWORD(v128) >= SLODWORD(v137) )
6923 while (_v128 >= _v137)
6924 {
6925 LABEL_127:
6926 v188 += srcPitch;
6927 --v173;
6928 if ( !v173 )
6929 goto LABEL_128;
6930 }
6931 v180 = (int *)v188;
6932 //v165 = LODWORD(v137) - LODWORD(v128);
6933 v165 = _v137 - _v128;
6934 while ( 1 )
6935 {
6936 v68 = *(_WORD *)v180;
6937 if ( a10 )
6938 {
6939 v230 = 1;
6940 v61 = v68 != a11 ? 0xFF : 0;
6941 }
6942 v69 = _450FB1(v68);
6943 if ( !v230 )
6944 break;
6945 LODWORD(v244) = v61 + v244;
6946 v230 = 0;
6947 if ( v61 )
6948 goto LABEL_125;
6949 --v67;
6950 LABEL_126:
6951 v180 = (int *)((char *)v180 + 2);
6952 --v165;
6953 if ( !v165 )
6954 goto LABEL_127;
6955 }
6956 LODWORD(v244) = ((unsigned int)v69 >> 24) + v244;
6957 LABEL_125:
6958 a6j += BYTE2(v69);
6959 v256 += BYTE1(v69);
6960 HIDWORD(v244) += (unsigned __int8)v69;
6961 goto LABEL_126;
6962 }
6963 result = (int)pDst;
6964 v198 = pDst;
6965 v236 = 0;
6966 if ( dstHeight <= 0 )
6967 return result;
6968 v73 = dstWidth;
6969 while ( 1 )
6970 {
6971 v74 = 0;
6972 a6k = 0;
6973 if ( dstWidth > v11 )
6974 break;
6975 LABEL_158:
6976 v198 = (unsigned __int16 *)((char *)v198 + dstPitch - dstWidth);
6977 ++v236;
6978 result = v236;
6979 if ( v236 >= dstHeight )
6980 return result;
6981 v11 = 0;
6982 }
6983 v226 = (double)dstWidth;
6984 v217 = (double)srcWidth;
6985 v75 = (double)dstHeight;
6986 v76 = (double)srcHeight;
6987 while ( 1 )
6988 {
6989 a6bc = (double)a6k / v226 * v217;
6990 v129 = a6bc + 6.7553994e15;
6991 v208 = v74 + 1;
6992 a6bd = (double)(v74 + 1) / v226 * v217;
6993 v138 = a6bd + 6.7553994e15;
6994 v77 = (double)v236 / v75 * v76;
6995 v147 = v77 + 6.7553994e15;
6996 v78 = (double)(v236 + 1) / v75 * v76;
6997 v156 = v78 + 6.7553994e15;
6998 v257 = 0;
6999 v79 = (LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129));
7000 a6l = 0;
7001 v245 = 0i64;
7002 if ( SLODWORD(v147) < SLODWORD(v156) )
7003 break;
7004 LABEL_153:
7005 v82 = (unsigned int)v245 / ((LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129)));
7006 if ( v79 )
7007 {
7008 a6l /= v79;
7009 v257 /= v79;
7010 HIDWORD(v245) /= v79;
7011 }
7012 if ( v82 != 255 )
7013 v82 &= 0x7FFFFFFFu;
7014 v83 = _450F55(HIDWORD(v245) | ((v257 | ((a6l | (v82 << 8)) << 8)) << 8));
7015 v84 = v198;
7016 v198 = (unsigned __int16 *)((char *)v198 + 1);
7017 *(_BYTE *)v84 = v83;
7018 v74 = v208;
7019 a6k = v208;
7020 if ( v208 >= dstWidth )
7021 goto LABEL_158;
7022 }
7023 v174 = LODWORD(v156) - LODWORD(v147);
7024 v189 = &pSrc[LODWORD(v129) + srcPitch * LODWORD(v147)];
7025 while ( SLODWORD(v129) >= SLODWORD(v138) )
7026 {
7027 LABEL_152:
7028 v189 += srcPitch;
7029 --v174;
7030 if ( !v174 )
7031 goto LABEL_153;
7032 }
7033 v166 = LODWORD(v138) - LODWORD(v129);
7034 v181 = (int *)v189;
7035 while ( 1 )
7036 {
7037 v80 = *(_WORD *)v181;
7038 if ( a10 )
7039 {
7040 v230 = 1;
7041 v73 = v80 != a11 ? 0xFF : 0;
7042 }
7043 v81 = _450FB1(v80);
7044 if ( !v230 )
7045 break;
7046 LODWORD(v245) = v73 + v245;
7047 v230 = 0;
7048 if ( v73 )
7049 goto LABEL_150;
7050 --v79;
7051 LABEL_151:
7052 v181 = (int *)((char *)v181 + 2);
7053 --v166;
7054 if ( !v166 )
7055 goto LABEL_152;
7056 }
7057 LODWORD(v245) = ((unsigned int)v81 >> 24) + v245;
7058 LABEL_150:
7059 a6l += BYTE2(v81);
7060 v257 += BYTE1(v81);
7061 HIDWORD(v245) += (unsigned __int8)v81;
7062 goto LABEL_151;
7063 }
7064 result = this->field_20.field_C;
7065 if ( result == 8 )
7066 {
7067 result = (int)pDst;
7068 v201 = pDst;
7069 v239 = 0;
7070 if ( dstHeight <= 0 )
7071 return result;
7072 v111 = dstWidth;
7073 while ( 1 )
7074 {
7075 v112 = 0;
7076 a6q = 0;
7077 if ( dstWidth <= v11 )
7078 goto LABEL_236;
7079 v229 = (double)dstWidth;
7080 v220 = (double)srcWidth;
7081 v113 = (double)dstHeight;
7082 v114 = (double)srcHeight;
7083 do
7084 {
7085 a6bi = (double)a6q / v229 * v220;
7086 v132 = a6bi + 6.7553994e15;
7087 v211 = v112 + 1;
7088 a6bj = (double)(v112 + 1) / v229 * v220;
7089 v141 = a6bj + 6.7553994e15;
7090 v115 = (double)v239 / v113 * v114;
7091 v150 = v115 + 6.7553994e15;
7092 v116 = (double)(v239 + 1) / v113 * v114;
7093 v159 = v116 + 6.7553994e15;
7094 v251 = 0;
7095 v117 = (LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132));
7096 v260 = 0;
7097 a6r = 0;
7098 v248 = 0;
7099 if ( SLODWORD(v150) >= SLODWORD(v159) )
7100 goto LABEL_231;
7101 v169 = LODWORD(v159) - LODWORD(v150);
7102 v184 = (char *)pSrc + srcPitch * LODWORD(v150);
7103 do
7104 {
7105 v118 = LODWORD(v132);
7106 v192 = LODWORD(v132);
7107 while ( v118 < SLODWORD(v141) )
7108 {
7109 v119 = (unsigned __int8)v184[v192];
7110 if ( a10 )
7111 {
7112 v230 = 1;
7113 v111 = v119 != a11 ? 0xFF : 0;
7114 }
7115 v120 = _450FB1(v119);
7116 if ( v230 )
7117 {
7118 v248 += v111;
7119 v230 = 0;
7120 if ( !v111 )
7121 {
7122 --v117;
7123 goto LABEL_228;
7124 }
7125 }
7126 else
7127 {
7128 v248 += (unsigned int)v120 >> 24;
7129 }
7130 a6r += BYTE2(v120);
7131 v260 += BYTE1(v120);
7132 v251 += (unsigned __int8)v120;
7133 LABEL_228:
7134 ++v192;
7135 v118 = v192;
7136 }
7137 v184 += srcPitch;
7138 --v169;
7139 }
7140 while ( v169 );
7141 LABEL_231:
7142 v121 = v248 / ((LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132)));
7143 if ( v117 )
7144 {
7145 a6r /= v117;
7146 v260 /= v117;
7147 v251 /= v117;
7148 }
7149 if ( v121 != 255 )
7150 v121 &= 0x7FFFFFFFu;
7151 v122 = _450F55(v251 | ((v260 | ((a6r | (v121 << 8)) << 8)) << 8));
7152 v123 = v201;
7153 v201 = (unsigned __int16 *)((char *)v201 + 1);
7154 *(_BYTE *)v123 = v122;
7155 v112 = v211;
7156 a6q = v211;
7157 }
7158 while ( v211 < dstWidth );
7159 LABEL_236:
7160 v201 = (unsigned __int16 *)((char *)v201 + dstPitch - dstWidth);
7161 ++v239;
7162 result = v239;
7163 if ( v239 >= dstHeight )
7164 return result;
7165 v11 = 0;
7166 }
7167 }
7168 if ( result == 16 )
7169 {
7170 result = (int)pDst;
7171 v200 = pDst;
7172 v238 = 0;
7173 if ( dstHeight <= 0 )
7174 return result;
7175 v98 = dstWidth;
7176 a9f = 2 * (dstPitch - dstWidth);
7177 while ( 1 )
7178 {
7179 v99 = 0;
7180 a6o = 0;
7181 if ( dstWidth <= v11 )
7182 goto LABEL_211;
7183 v228 = (double)dstWidth;
7184 v219 = (double)srcWidth;
7185 v100 = (double)dstHeight;
7186 v101 = (double)srcHeight;
7187 do
7188 {
7189 a6bg = (double)a6o / v228 * v219;
7190 v131 = a6bg + 6.7553994e15;
7191 v210 = v99 + 1;
7192 a6bh = (double)(v99 + 1) / v228 * v219;
7193 v140 = a6bh + 6.7553994e15;
7194 v102 = (double)v238 / v100 * v101;
7195 v149 = v102 + 6.7553994e15;
7196 v103 = (double)(v238 + 1) / v100 * v101;
7197 v158 = v103 + 6.7553994e15;
7198 v250 = 0;
7199 v104 = (LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131));
7200 v259 = 0;
7201 a6p = 0;
7202 v247 = 0;
7203 if ( SLODWORD(v149) >= SLODWORD(v158) )
7204 goto LABEL_206;
7205 v168 = LODWORD(v158) - LODWORD(v149);
7206 v183 = (char *)pSrc + srcPitch * LODWORD(v149);
7207 do
7208 {
7209 v105 = LODWORD(v131);
7210 v191 = LODWORD(v131);
7211 while ( v105 < SLODWORD(v140) )
7212 {
7213 v106 = (unsigned __int8)v183[v191];
7214 if ( a10 )
7215 {
7216 v230 = 1;
7217 v98 = v106 != a11 ? 0xFF : 0;
7218 }
7219 v107 = _450FB1(v106);
7220 if ( v230 )
7221 {
7222 v247 += v98;
7223 v230 = 0;
7224 if ( !v98 )
7225 {
7226 --v104;
7227 goto LABEL_203;
7228 }
7229 }
7230 else
7231 {
7232 v247 += (unsigned int)v107 >> 24;
7233 }
7234 a6p += BYTE2(v107);
7235 v259 += BYTE1(v107);
7236 v250 += (unsigned __int8)v107;
7237 LABEL_203:
7238 ++v191;
7239 v105 = v191;
7240 }
7241 v183 += srcPitch;
7242 --v168;
7243 }
7244 while ( v168 );
7245 LABEL_206:
7246 v108 = v247 / ((LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131)));
7247 if ( v104 )
7248 {
7249 a6p /= v104;
7250 v259 /= v104;
7251 v250 /= v104;
7252 }
7253 if ( v108 != 255 )
7254 v108 &= 0x7FFFFFFFu;
7255 v109 = _450F55(v250 | ((v259 | ((a6p | (v108 << 8)) << 8)) << 8));
7256 v110 = v200;
7257 ++v200;
7258 *v110 = v109;
7259 v99 = v210;
7260 a6o = v210;
7261 }
7262 while ( v210 < dstWidth );
7263 LABEL_211:
7264 v200 = (unsigned __int16 *)((char *)v200 + a9f);
7265 ++v238;
7266 result = v238;
7267 if ( v238 >= dstHeight )
7268 return result;
7269 v11 = 0;
7270 }
7271 }
7272 if ( result != 32 || (result = (int)pDst, v199 = pDst, v237 = 0, dstHeight <= 0) )
7273 return result;
7274 v85 = dstWidth;
7275 a9e = 4 * (dstPitch - dstWidth);
7276 while ( 2 )
7277 {
7278 v86 = 0;
7279 a6m = 0;
7280 if ( dstWidth <= v11 )
7281 goto LABEL_186;
7282 v227 = (double)dstWidth;
7283 v218 = (double)srcWidth;
7284 v87 = (double)dstHeight;
7285 v88 = (double)srcHeight;
7286 do
7287 {
7288 a6be = (double)a6m / v227 * v218;
7289 v130 = a6be + 6.7553994e15;
7290 v209 = v86 + 1;
7291 a6bf = (double)(v86 + 1) / v227 * v218;
7292 v139 = a6bf + 6.7553994e15;
7293 v89 = (double)v237 / v87 * v88;
7294 v148 = v89 + 6.7553994e15;
7295 v90 = (double)(v237 + 1) / v87 * v88;
7296 v157 = v90 + 6.7553994e15;
7297 v249 = 0;
7298 v91 = (LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130));
7299 v258 = 0;
7300 a6n = 0;
7301 v246 = 0;
7302 if ( SLODWORD(v148) >= SLODWORD(v157) )
7303 goto LABEL_181;
7304 v167 = LODWORD(v157) - LODWORD(v148);
7305 v182 = (char *)pSrc + srcPitch * LODWORD(v148);
7306 do
7307 {
7308 v92 = LODWORD(v130);
7309 v190 = LODWORD(v130);
7310 while ( v92 < SLODWORD(v139) )
7311 {
7312 v93 = (unsigned __int8)v182[v190];
7313 if ( a10 )
7314 {
7315 v230 = 1;
7316 v85 = v93 != a11 ? 0xFF : 0;
7317 }
7318 v94 = _450FB1(v93);
7319 if ( v230 )
7320 {
7321 v246 += v85;
7322 v230 = 0;
7323 if ( !v85 )
7324 {
7325 --v91;
7326 goto LABEL_178;
7327 }
7328 }
7329 else
7330 {
7331 v246 += (unsigned int)v94 >> 24;
7332 }
7333 a6n += BYTE2(v94);
7334 v258 += BYTE1(v94);
7335 v249 += (unsigned __int8)v94;
7336 LABEL_178:
7337 ++v190;
7338 v92 = v190;
7339 }
7340 v182 += srcPitch;
7341 --v167;
7342 }
7343 while ( v167 );
7344 LABEL_181:
7345 v95 = v246 / ((LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130)));
7346 if ( v91 )
7347 {
7348 a6n /= v91;
7349 v258 /= v91;
7350 v249 /= v91;
7351 }
7352 if ( v95 != 255 )
7353 v95 &= 0x7FFFFFFFu;
7354 v96 = _450F55(v249 | ((v258 | ((a6n | (v95 << 8)) << 8)) << 8));
7355 v97 = v199;
7356 v199 += 2;
7357 *(_DWORD *)v97 = v96;
7358 v86 = v209;
7359 a6m = v209;
7360 }
7361 while ( v209 < dstWidth );
7362 LABEL_186:
7363 v199 = (unsigned __int16 *)((char *)v199 + a9e);
7364 ++v237;
7365 result = v237;
7366 if ( v237 < dstHeight )
7367 {
7368 v11 = 0;
7369 continue;
7370 }
7371 return result;
7372 }
7373 }
7374
7375
7376
7377
7378
7379
7380
7381 //----- (0044E1EC) --------------------------------------------------------
7382 int TextureFrameTable::FromFileTxt(const char *Args)
7383 {
7384 TextureFrameTable *v2; // ebx@1
7385 FILE *v3; // eax@1
7386 int v4; // esi@3
7387 const void *v5; // ST0C_4@10
7388 void *v6; // eax@10
7389 FILE *v7; // ST0C_4@12
7390 char *i; // eax@12
7391 signed int v9; // esi@15
7392 int v10; // eax@17
7393 int v11; // edx@22
7394 int v12; // ecx@23
7395 int v13; // eax@24
7396 signed int j; // eax@27
7397 TextureFrame *v15; // edx@28
7398 int v16; // esi@28
7399 int k; // ecx@29
7400 char Buf; // [sp+Ch] [bp-2F8h]@3
7401 FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4
7402 int v21; // [sp+27Ch] [bp-88h]@4
7403 char *Str1; // [sp+280h] [bp-84h]@5
7404 char *Str; // [sp+284h] [bp-80h]@15
7405 int v24; // [sp+2F8h] [bp-Ch]@3
7406 int v25; // [sp+2FCh] [bp-8h]@3
7407 FILE *File; // [sp+300h] [bp-4h]@1
7408 int Argsa; // [sp+30Ch] [bp+8h]@28
7409
7410 v2 = this;
7411 v3 = fopen(Args, "r");
7412 File = v3;
7413 if ( !v3 )
7414 Abortf("CTextureFrameTable::load - Unable to open file: %s.", Args);
7415 v4 = 0;
7416 v24 = 0;
7417 v25 = 1;
7418 if ( fgets(&Buf, 490, v3) )
7419 {
7420 do
7421 {
7422 *strchr(&Buf, 10) = 0;
7423 memcpy(&v21, texture_frame_table_txt_parser(&Buf, &v20), 0x7Cu);
7424 if ( v21 && *Str1 != 47 )
7425 {
7426 if ( v21 < 2 )
7427 Abortf("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25);
7428 ++v24;
7429 }
7430 ++v25;
7431 }
7432 while ( fgets(&Buf, 490, File) );
7433 v4 = v24;
7434 }
7435 v5 = v2->pTextures;
7436 v2->uNumTextures = v4;
7437 v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames");
7438 v2->pTextures = (TextureFrame *)v6;
7439 if ( !v6 )
7440 Abortf("CTextureFrameTable::load - Out of Memory!");
7441 v7 = File;
7442 v2->uNumTextures = 0;
7443 fseek(v7, 0, 0);
7444 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
7445 {
7446 *strchr(&Buf, 10) = 0;
7447 memcpy(&v21, texture_frame_table_txt_parser(&Buf, &v20), 0x7Cu);
7448 if ( v21 && *Str1 != 47 )
7449 {
7450 strcpy(v2->pTextures[v2->uNumTextures].pTextureName, Str1);
7451 v2->pTextures[v2->uNumTextures].uAnimTime = atoi(Str);
7452 v9 = 2;
7453 for ( v2->pTextures[v2->uNumTextures].uFlags = 0; v9 < v21; ++v9 )
7454 {
7455 if ( !_strcmpi((&Str1)[4 * v9], "New") )
7456 {
7457 v10 = (int)&v2->pTextures[v2->uNumTextures].uFlags;
7458 *(char *)v10 |= 2u;
7459 }
7460 }
7461 ++v2->uNumTextures;
7462 }
7463 }
7464 fclose(File);
7465 v11 = 0;
7466 if ( (signed int)(v2->uNumTextures - 1) > 0 )
7467 {
7468 v12 = 0;
7469 do
7470 {
7471 v13 = (int)&v2->pTextures[v12];
7472 if ( !(*(char *)(v13 + 38) & 2) )
7473 *(char *)(v13 + 18) |= 1u;
7474 ++v11;
7475 ++v12;
7476 }
7477 while ( v11 < (signed int)(v2->uNumTextures - 1) );
7478 }
7479 for ( j = 0; j < (signed int)v2->uNumTextures; *(short *)(Argsa + 16) = v16 )
7480 {
7481 v15 = v2->pTextures;
7482 Argsa = (int)&v15[j];
7483 v16 = *(short *)(Argsa + 14);
7484 if ( *(char *)(Argsa + 18) & 1 )
7485 {
7486 ++j;
7487 for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 )
7488 {
7489 v16 += *(short *)(k + 14);
7490 ++j;
7491 }
7492 LOWORD(v16) = v15[j].uAnimTime + v16;
7493 }
7494 ++j;
7495 }
7496 return 1;
7497 }
7498
7499
7500
7501
7502
7503
7504
7505
7506 //----- (0044F57C) --------------------------------------------------------
7507 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5)
7508 {
7509 //MapInfo *v5; // esi@1
7510 //SpawnPointMM7 *v6; // ebx@1
7511 int v7; // eax@2
7512 char v8; // zf@5
7513 int v9; // edi@9
7514 int v10; // eax@9
7515 int v11; // ecx@9
7516 int v12; // edx@9
7517 int v13; // eax@9
7518 int v14; // eax@14
7519 int v15; // ecx@14
7520 int v16; // eax@19
7521 int v17; // ecx@19
7522 int v18; // esi@31
7523 //int pPosX; // ecx@32
7524 //int v20; // edx@32
7525 //int v21; // eax@32
7526 Actor *pMonster; // esi@35
7527 int v23; // edx@36
7528 signed int v24; // edi@36
7529 int v25; // ecx@36
7530 unsigned __int16 v26; // ax@47
7531 MonsterDesc *v27; // edi@48
7532 signed int v28; // eax@48
7533 __int16 v29; // cx@50
7534 __int16 v30; // ax@50
7535 __int16 v31; // ax@50
7536 int v32; // eax@50
7537 int v33; // edi@50
7538 int v34; // eax@50
7539 int v35; // eax@50
7540 int v36; // eax@50
7541 int v37; // eax@51
7542 int v38; // eax@52
7543 int v39; // edi@52
7544 std::string v40; // [sp-18h] [bp-100h]@60
7545 void *v41; // [sp-14h] [bp-FCh]@50
7546 //void *v42; // [sp-10h] [bp-F8h]@50
7547 //size_t v43; // [sp-Ch] [bp-F4h]@50
7548 const char *v44; // [sp-8h] [bp-F0h]@13
7549 char *pTexture; // [sp-4h] [bp-ECh]@9
7550 char Str[32]; // [sp+Ch] [bp-DCh]@60
7551 char Str2[120]; // [sp+2Ch] [bp-BCh]@29
7552 unsigned int uFaceID; // [sp+A4h] [bp-44h]@52
7553 MonsterInfo *Src; // [sp+A8h] [bp-40h]@50
7554 int v50; // [sp+ACh] [bp-3Ch]@47
7555 char Source[32]; // [sp+B0h] [bp-38h]@20
7556 int v52; // [sp+D0h] [bp-18h]@34
7557 int v53; // [sp+D4h] [bp-14h]@34
7558 int pSector; // [sp+D8h] [bp-10h]@32
7559 int pPosX; // [sp+DCh] [bp-Ch]@32
7560 int v56; // [sp+E0h] [bp-8h]@8
7561 int v57; // [sp+E4h] [bp-4h]@1
7562
7563 //auto a2 = spawn;
7564 v57 = 0;
7565 //v5 = pMapInfo;
7566 //v6 = spawn;
7567 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7568 v7 = pOutdoor->ddm.field_C_alert;
7569 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
7570 v7 = pIndoor->dlv.field_C_alert;
7571 else
7572 v7 = 0;
7573 if (v7)
7574 v8 = (spawn->uAttributes & 1) == 0;
7575 else
7576 v8 = (spawn->uAttributes & 1) == 1;
7577 if (v8)
7578 return;
7579 //result = (void *)(spawn->uIndex - 1);
7580 v56 = 1;
7581 switch (spawn->uIndex - 1)
7582 {
7583 case 0u:
7584 v9 = pMapInfo->uEncounterMonster1AtLeast;
7585 v10 = rand();
7586 v11 = pMapInfo->uEncounterMonster1AtMost;
7587 pTexture = pMapInfo->pEncounterMonster1Texture;
7588 v12 = v10 % (v11 - v9 + 1);
7589 v13 = pMapInfo->field_34;
7590 goto LABEL_20;
7591 case 3u:
7592 pTexture = pMapInfo->pEncounterMonster1Texture;
7593 v44 = "%s A";
7594 goto LABEL_25;
7595 case 4u:
7596 pTexture = pMapInfo->pEncounterMonster2Texture;
7597 v44 = "%s A";
7598 goto LABEL_25;
7599 case 5u:
7600 pTexture = pMapInfo->pEncounterMonster3Texture;
7601 v44 = "%s A";
7602 goto LABEL_25;
7603 case 1u:
7604 v9 = pMapInfo->uEncounterMonster2AtLeast;
7605 v14 = rand();
7606 v15 = pMapInfo->uEncounterMonster2AtMost;
7607 pTexture = pMapInfo->pEncounterMonster2Texture;
7608 v12 = v14 % (v15 - v9 + 1);
7609 v13 = pMapInfo->field_37;
7610 goto LABEL_20;
7611 case 6u:
7612 pTexture = pMapInfo->pEncounterMonster1Texture;
7613 v44 = "%s B";
7614 goto LABEL_25;
7615 case 7u:
7616 pTexture = pMapInfo->pEncounterMonster2Texture;
7617 v44 = "%s B";
7618 goto LABEL_25;
7619 case 8u:
7620 pTexture = pMapInfo->pEncounterMonster3Texture;
7621 v44 = "%s B";
7622 goto LABEL_25;
7623 case 2u:
7624 v9 = pMapInfo->uEncounterMonster3AtLeast;
7625 v16 = rand();
7626 v17 = pMapInfo->uEncounterMonster3AtMost;
7627 pTexture = pMapInfo->pEncounterMonster3Texture;
7628 v12 = v16 % (v17 - v9 + 1);
7629 v13 = pMapInfo->field_3A;
7630 LABEL_20:
7631 v57 = v13;
7632 v56 = v9 + v12;
7633 strcpy(Source, pTexture);
7634 goto LABEL_26;
7635 case 9u:
7636 pTexture = pMapInfo->pEncounterMonster1Texture;
7637 v44 = "%s C";
7638 goto LABEL_25;
7639 case 0xAu:
7640 pTexture = pMapInfo->pEncounterMonster2Texture;
7641 v44 = "%s C";
7642 goto LABEL_25;
7643 case 0xBu:
7644 pTexture = pMapInfo->pEncounterMonster3Texture;
7645 v44 = "%s C";
7646 LABEL_25:
7647 sprintf(Source, v44, pTexture);
7648 LABEL_26:
7649 if (Source[0] == '0')
7650 return;
7651 v57 += a3;
7652 if ( v57 > 4 )
7653 v57 = 4;
7654 strcpy(Str2, Source);
7655 if ( a4 )
7656 v56 = a4;
7657 v18 = v56;
7658 if ( (signed int)(v56 + uNumActors) >= 500 )
7659 return;
7660 pSector = 0;
7661 pPosX = spawn->vPosition.x;
7662 a4 = spawn->vPosition.y;
7663 a3 = spawn->vPosition.z;
7664 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7665 pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
7666 v53 = 0;
7667 v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
7668 if ( v18 <= 0 )
7669 return;
7670 break;
7671 default:
7672 return;
7673 }
7674 for (uint i = v53; i < v56; ++i)
7675 {
7676 pMonster = &pActors[uNumActors];
7677 pActors[uNumActors].Reset();
7678 if ( v57 )
7679 {
7680 v23 = rand() % 100;
7681 v24 = 3;
7682 v25 = (unsigned __int16)word_4E8152[3 * v57];
7683 if ( v23 >= v25 )
7684 {
7685 if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] )
7686 v24 = 2;
7687 }
7688 else
7689 {
7690 v24 = 1;
7691 }
7692 if ( v24 == 1 )
7693 {
7694 pTexture = Source;
7695 v44 = "%s A";
7696 }
7697 else
7698 {
7699 if ( v24 == 2 )
7700 {
7701 pTexture = Source;
7702 v44 = "%s B";
7703 }
7704 else
7705 {
7706 if ( v24 != 3 )
7707 goto LABEL_58;
7708 pTexture = Source;
7709 v44 = "%s C";
7710 }
7711 }
7712 sprintf(Str2, v44, pTexture);
7713 }
7714 v26 = pMonsterList->GetMonsterByName(Str2);
7715 v50 = (signed __int16)v26;
7716 pTexture = Str2;
7717 if ( (signed __int16)v26 == -1 )
7718 {
7719 sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture);
7720 MessageBoxA(nullptr, Str, nullptr, 0);
7721 ExitProcess(0);
7722 }
7723 v27 = &pMonsterList->pMonsters[(signed __int16)v26];
7724 v28 = pMonsterStats->_4563FF(pTexture);
7725 if ( !v28 )
7726 v28 = 1;
7727 Src = &pMonsterStats->pInfos[v28];
7728 strcpy(pMonster->pActorName, Src->pName);
7729 pMonster->sCurrentHP = Src->uHP;
7730 assert(sizeof(MonsterInfo) == 88);
7731 memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));
7732 pMonster->word_000086_some_monster_id = v50 + 1;
7733 pMonster->uActorRadius = v27->uMonsterRadius;
7734 pMonster->uActorHeight = v27->uMonsterHeight;
7735 pMonster->uMovementSpeed = v27->uMovementSpeed;
7736 pMonster->vInitialPosition.x = spawn->vPosition.x;
7737 pMonster->vPosition.x = spawn->vPosition.x;
7738 pMonster->uTetherDistance = 256;
7739 pMonster->vInitialPosition.y = a4;
7740 pMonster->vPosition.y = a4;
7741 pTexture = 0;
7742 pMonster->vInitialPosition.z = a3;
7743 pMonster->vPosition.z = a3;
7744 pMonster->uSectorID = pSector;
7745 pMonster->uGroup = spawn->uGroup;
7746 pMonster->PrepareSprites((char)pTexture);
7747 pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
7748 v32 = rand();
7749 v33 = v32 % 2048;
7750 v34 = stru_5C6E00->SinCos(v32 % 2048);
7751 a4 = v34;
7752 a3 = (unsigned __int64)(v34 * (signed __int64)v52) >> 16;
7753 pPosX = a3 + spawn->vPosition.x;
7754 v35 = stru_5C6E00->SinCos(v33 - stru_5C6E00->uIntegerHalfPi);
7755 a4 = v35;
7756 a3 = (unsigned __int64)(v35 * (signed __int64)v52) >> 16;
7757 a4 = a3 + spawn->vPosition.y;
7758 v36 = spawn->vPosition.z;
7759 a3 = spawn->vPosition.z;
7760 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
7761 goto LABEL_55;
7762 v37 = pIndoor->GetSector(pPosX, a4, v36);
7763 if ( v37 == pSector )
7764 {
7765 v38 = _46CEC3_get_floor_level(pPosX, a4, a3, v37, &uFaceID);
7766 v39 = v38;
7767 if ( v38 != -30000 )
7768 {
7769 if ( abs(v38 - a3) <= 1024 )
7770 {
7771 a3 = v39;
7772 LABEL_55:
7773 if ( a5 )
7774 pMonster->uAttributes |= 0x080000;
7775 ++uNumActors;
7776 goto LABEL_58;
7777 }
7778 }
7779 }
7780 LABEL_58:
7781 ;
7782 //v53 = (char *)v53 + 1;
7783 //result = v53;
7784 }
7785 //while ( (signed int)v53 < v56 );
7786 }
7787
7788
7789
7790
7791 //----- (0044FA4C) --------------------------------------------------------
7792 signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3)
7793 {
7794 signed int v3; // ecx@6
7795 char *v4; // edx@7
7796 signed int result; // eax@13
7797 Actor *v6; // esi@16
7798 char *v7; // ebx@16
7799 MonsterDesc *v8; // edi@16
7800 unsigned __int16 v9; // ax@16
7801 int v10; // ebx@16
7802 int v11; // edi@16
7803 int v12; // eax@16
7804 int v13; // ecx@16
7805 int v14; // ebx@16
7806 const char *v15; // [sp-4h] [bp-24h]@2
7807 unsigned __int16 v16; // [sp+0h] [bp-20h]@1
7808 int v17; // [sp+4h] [bp-1Ch]@1
7809 unsigned int uFaceID; // [sp+8h] [bp-18h]@16
7810 int v19; // [sp+Ch] [bp-14h]@16
7811 size_t v20; // [sp+10h] [bp-10h]@6
7812 int v21; // [sp+14h] [bp-Ch]@14
7813 int v22; // [sp+18h] [bp-8h]@14
7814 unsigned int v23; // [sp+1Ch] [bp-4h]@6
7815
7816 v16 = a2;
7817 v17 = a1;
7818 if ( a2 == 4 )
7819 {
7820 v15 = "Elemental Light C";
7821 }
7822 else
7823 {
7824 if ( a2 == 3 )
7825 v15 = "Elemental Light B";
7826 else
7827 v15 = "Elemental Light A";
7828 }
7829 v23 = (signed __int16)pMonsterList->GetMonsterByName(v15);
7830 v3 = 0;
7831 v20 = uNumActors;
7832 if ( (signed int)uNumActors > 0 )
7833 {
7834 v4 = (char *)&pActors[0].uAIState;
7835 while ( *(short *)v4 != Removed )
7836 {
7837 ++v3;
7838 v4 += 836;
7839 if ( v3 >= (signed int)uNumActors )
7840 goto LABEL_12;
7841 }
7842 v20 = v3;
7843 }
7844 LABEL_12:
7845 if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) )
7846 {
7847 v21 = 0;
7848 v22 = pParty->vPosition.z;
7849 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
7850 v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
7851 v6 = &pActors[v20];
7852 v7 = (char *)&pMonsterStats->pInfos[v23 + 1];
7853 v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
7854 v6->Reset();
7855 v8 = &pMonsterList->pMonsters[v23];
7856 strcpy(v6->pActorName, *(const char **)v7);
7857 v6->sCurrentHP = *((short *)v7 + 32);
7858 memcpy(&v6->pMonsterInfo, v7, 0x58u);
7859 v6->word_000086_some_monster_id = v23 + 1;
7860 v6->uActorRadius = v8->uMonsterRadius;
7861 v6->uActorHeight = v8->uMonsterHeight;
7862 v9 = v8->uMovementSpeed;
7863 v6->pMonsterInfo.uTreasureDiceRolls = 0;
7864 v6->pMonsterInfo.uTreasureType = 0;
7865 v6->pMonsterInfo.uExp = 0;
7866 v6->uMovementSpeed = v9;
7867 v10 = rand() % 2048;
7868 v11 = ((unsigned __int64)(stru_5C6E00->SinCos(v10) * (signed __int64)v19) >> 16) + pParty->vPosition.x;
7869 uFaceID = stru_5C6E00->SinCos(v10 - stru_5C6E00->uIntegerHalfPi);
7870 v23 = (unsigned __int64)(uFaceID * (signed __int64)v19) >> 16;
7871 v12 = pParty->vPosition.y;
7872 v13 = (unsigned __int64)(uFaceID * (signed __int64)v19) >> 16;
7873 v6->vInitialPosition.x = v11;
7874 v14 = v13 + v12;
7875 LOWORD(v12) = v22;
7876 v6->vInitialPosition.z = v22;
7877 v6->vPosition.z = v12;
7878 LOWORD(v12) = v21;
7879 v6->vPosition.x = v11;
7880 v6->vInitialPosition.y = v14;
7881 v6->vPosition.y = v14;
7882 v6->uTetherDistance = 256;
7883 v6->uSectorID = v12;
7884 v6->PrepareSprites(0);
7885 v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
7886 v6->uAlly = 9999;
7887 v6->uGroup = 0;
7888 v6->uCurrentActionTime = 0;
7889 v6->uAIState = Summoned;
7890 v6->uCurrentActionLength = 256;
7891 v6->UpdateAnimation();
7892 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
7893 || (v22 = pParty->vPosition.z,
7894 result = pIndoor->GetSector(v11, v14, pParty->vPosition.z),
7895 result == v21)
7896 && (result = _46CEC3_get_floor_level(v11, v14, v22, result, &uFaceID), result != -30000)
7897 && (result = abs(result - v22), result <= 1024) )
7898 {
7899 if ( v20 == uNumActors )
7900 ++uNumActors;
7901 v6->uSummonerID = 8 * v17 | 4;
7902 result = v6->pActorBuffs[2].Apply(
7903 pParty->uTimePlayed + (signed __int64)((double)(a3 << 7) * 0.033333335),
7904 v16,
7905 v17,
7906 0,
7907 0);
7908 }
7909 }
7910 return result;
7911 }
7912
7913
7914 //----- (0044FFD8) --------------------------------------------------------
7915 int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2)
7916 {
7917 MapInfo *v2; // ebx@1
7918 SpawnPointMM7 *v3; // esi@1
7919 int v4; // eax@1
7920 int v5; // edx@1
7921 int v6; // eax@1
7922 int v7; // ecx@1
7923 int v8; // ebx@1
7924 int v9; // eax@1
7925 signed int v10; // ebx@1
7926 signed int result; // eax@1
7927 signed __int64 v12; // qtt@1
7928 int v13; // ebx@1
7929 int v14; // edx@10
7930 signed int v15; // ebx@20
7931 unsigned __int16 v16; // dx@20
7932 char *v17; // ecx@21
7933 unsigned __int16 v18; // ax@24
7934 int v19; // ST0C_4@27
7935 int v20; // ST08_4@27
7936 int v21; // ST04_4@27
7937 int v22; // eax@27
7938 signed int v23; // ebx@29
7939 unsigned __int16 v24; // dx@29
7940 char *v25; // ecx@30
7941 unsigned __int16 v26; // ax@33
7942 int v27; // ecx@35
7943 int v28; // eax@35
7944 int v29; // esi@35
7945 __int16 v30; // ax@35
7946 LayingItem a1a; // [sp+Ch] [bp-7Ch]@1
7947 int v32; // [sp+7Ch] [bp-Ch]@1
7948 int v33; // [sp+80h] [bp-8h]@1
7949 int v34; // [sp+84h] [bp-4h]@1
7950
7951 __debugbreak();
7952
7953 auto a1 = this;
7954
7955 v2 = a1;
7956 v3 = a2;
7957 v4 = rand();
7958 v34 = 0;
7959 v5 = v4 % 100;
7960 v6 = 2 * (v2->field_2F + 7 * v3->uIndex) - 14;
7961 v7 = (unsigned __int8)byte_4E8168[v6 + 16];
7962 v8 = (unsigned __int8)byte_4E8168[v6 + 17];
7963 v32 = v5;
7964 v33 = v7;
7965 v9 = rand();
7966 v10 = v8 - v33 + 1;
7967 v12 = v9;
7968 result = v9 / v10;
7969 v13 = v33 + (unsigned __int64)(v12 % v10);
7970 if ( v13 < 7 )
7971 {
7972 if ( v32 < 20 )
7973 return result;
7974 if ( v32 >= 60 )
7975 {
7976 v19 = v3->vPosition.z;
7977 v20 = v3->vPosition.y;
7978 v21 = v3->vPosition.x;
7979 v22 = rand();
7980 return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0);
7981 }
7982 if ( v3->uIndex == 1 )
7983 {
7984 v14 = rand() % 51 + 50;
7985 }
7986 else
7987 {
7988 if ( v3->uIndex != 2 )
7989 {
7990 if ( v3->uIndex == 3 )
7991 {
7992 v14 = rand() % 301 + 200;
7993 }
7994 else
7995 {
7996 if ( v3->uIndex != 4 )
7997 {
7998 if ( v3->uIndex == 5 )
7999 {
8000 v14 = rand() % 1001 + 1000;
8001 }
8002 else
8003 {
8004 if ( v3->uIndex != 6 )
8005 {
8006 LABEL_20:
8007 v15 = 0;
8008 v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
8009 a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
8010 if ( (signed int)pObjectList->uNumObjects <= 0 )
8011 {
8012 LABEL_24:
8013 v18 = 0;
8014 }
8015 else
8016 {
8017 v17 = (char *)&pObjectList->pObjects->uObjectID;
8018 while ( v16 != *(short *)v17 )
8019 {
8020 ++v15;
8021 v17 += 56;
8022 if ( v15 >= (signed int)pObjectList->uNumObjects )
8023 goto LABEL_24;
8024 }
8025 v18 = v15;
8026 }
8027 a1a.stru_24.uAttributes |= 1u;
8028 a1a.uObjectDescID = v18;
8029 a1a.stru_24.uAdditionalValue = v34;
8030 goto LABEL_35;
8031 }
8032 v14 = rand() % 3001 + 2000;
8033 }
8034 a1a.stru_24.uItemID = 199;
8035 LABEL_19:
8036 v34 = v14;
8037 goto LABEL_20;
8038 }
8039 v14 = rand() % 501 + 500;
8040 }
8041 a1a.stru_24.uItemID = 198;
8042 goto LABEL_19;
8043 }
8044 v14 = rand() % 101 + 100;
8045 }
8046 a1a.stru_24.uItemID = 197;
8047 goto LABEL_19;
8048 }
8049 result = a1a.stru_24.GenerateArtifact();
8050 if ( !result )
8051 return result;
8052 v23 = 0;
8053 v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
8054 a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
8055 if ( (signed int)pObjectList->uNumObjects <= 0 )
8056 {
8057 LABEL_33:
8058 v26 = 0;
8059 }
8060 else
8061 {
8062 v25 = (char *)&pObjectList->pObjects->uObjectID;
8063 while ( v24 != *(short *)v25 )
8064 {
8065 ++v23;
8066 v25 += 56;
8067 if ( v23 >= (signed int)pObjectList->uNumObjects )
8068 goto LABEL_33;
8069 }
8070 v26 = v23;
8071 }
8072 a1a.uObjectDescID = v26;
8073 a1a.stru_24.Reset();
8074 LABEL_35:
8075 v27 = v3->vPosition.y;
8076 v28 = v3->vPosition.x;
8077 v29 = v3->vPosition.z;
8078 a1a.vPosition.y = v27;
8079 a1a.uAttributes = 0;
8080 a1a.uSoundID = 0;
8081 a1a.uFacing = 0;
8082 a1a.vPosition.z = v29;
8083 a1a.vPosition.x = v28;
8084 a1a.field_50 = 0;
8085 a1a.field_4C = 0;
8086 a1a.field_48 = 0;
8087 v30 = pIndoor->GetSector(v28, v27, v29);
8088 a1a.field_5C = 0;
8089 a1a.field_58 = 0;
8090 a1a.uSpriteFrameID = 0;
8091 a1a.uSectorID = v30;
8092 return a1a.Create(0, 0, 0, 0);
8093 }
8094
8095 //----- (00450218) --------------------------------------------------------
8096 void __cdecl sub_450218_prolly_generate_chests_loot()
8097 {
8098 unsigned int v0; // eax@1
8099 Chest *v1; // ebx@1
8100 MapInfo *v2; // esi@1
8101 ItemGen *v3; // ebx@2
8102 int v4; // ebp@4
8103 int v5; // edi@4
8104 int v6; // esi@4
8105 int v7; // eax@4
8106 signed int v8; // esi@4
8107 int v9; // edx@4
8108 int v10; // esi@8
8109 int v11; // ebp@25
8110 int v12; // esi@25
8111 signed int v13; // ebp@27
8112 ItemGen *v14; // edi@28
8113 signed int v15; // edx@32
8114 signed __int64 v16; // qtt@32
8115 int v17; // esi@34
8116 signed int v18; // [sp+10h] [bp-18h]@1
8117 int v19; // [sp+14h] [bp-14h]@4
8118 MapInfo *v20; // [sp+18h] [bp-10h]@1
8119 Chest *v21; // [sp+1Ch] [bp-Ch]@1
8120 int v22; // [sp+20h] [bp-8h]@26
8121 signed int v23; // [sp+24h] [bp-4h]@2
8122
8123 v18 = rand() % 100;
8124 v0 = pMapStats->GetMapInfo(pCurrentMapName);
8125 v1 = pChests;
8126 v2 = &pMapStats->pInfos[v0];
8127 v21 = pChests;
8128 v20 = &pMapStats->pInfos[v0];
8129 do
8130 {
8131 v3 = v1->mm7__vector_pItems;
8132 v23 = 140;
8133 do
8134 {
8135 if ( (v3->uItemID & 0x80000000u) == 0 )
8136 goto LABEL_56;
8137 v4 = rand() % 5 + 1;
8138 v5 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 2];
8139 v6 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 3];
8140 v7 = rand();
8141 v8 = v6 - v5 + 1;
8142 v9 = v5 + v7 % v8;
8143 v19 = v5 + v7 % v8;
8144 if ( v9 < 7 )
8145 {
8146 if ( v18 < 20 )
8147 {
8148 v3->Reset();
8149 goto LABEL_25;
8150 }
8151 if ( v18 < 60 )
8152 {
8153 v10 = 0;
8154 v3->Reset();
8155 if ( v19 == 1 )
8156 {
8157 v10 = rand() % 51 + 50;
8158 }
8159 else
8160 {
8161 if ( v19 != 2 )
8162 {
8163 if ( v19 == 3 )
8164 {
8165 v10 = rand() % 301 + 200;
8166 }
8167 else
8168 {
8169 if ( v19 != 4 )
8170 {
8171 if ( v19 == 5 )
8172 {
8173 v10 = rand() % 1001 + 1000;
8174 LABEL_15:
8175 v3->uItemID = 199;
8176 }
8177 else
8178 {
8179 if ( v19 == 6 )
8180 {
8181 v10 = rand() % 3001 + 2000;
8182 goto LABEL_15;
8183 }
8184 }
8185 LABEL_23:
8186 v3->uAttributes |= 1u;
8187 v3->uAdditionalValue = v10;
8188 LABEL_25:
8189 v11 = v4 - 1;
8190 v12 = 0;
8191 if ( v11 > 0 )
8192 {
8193 v22 = v11;
8194 while ( 1 )
8195 {
8196 v13 = v12;
8197 if ( v12 >= 140 )
8198 goto LABEL_52;
8199 v14 = &v21->mm7__vector_pItems[v12];
8200 while ( v14->uItemID )
8201 {
8202 ++v13;
8203 ++v14;
8204 if ( v13 >= 140 )
8205 goto LABEL_52;
8206 }
8207 v16 = rand();
8208 v15 = v16 % 100;
8209 v18 = v16 % 100;
8210 if ( v15 < 20 )
8211 goto LABEL_52;
8212 if ( v15 >= 60 )
8213 {
8214 pItemsTable->GenerateItem(v19, 0, v14);
8215 goto LABEL_51;
8216 }
8217 v17 = 0;
8218 v14->Reset();
8219 if ( v19 == 1 )
8220 {
8221 v17 = rand() % 51 + 50;
8222 goto LABEL_48;
8223 }
8224 if ( v19 == 2 )
8225 {
8226 v17 = rand() % 101 + 100;
8227 LABEL_48:
8228 v14->uItemID = 197;
8229 goto LABEL_49;
8230 }
8231 if ( v19 == 3 )
8232 {
8233 v17 = rand() % 301 + 200;
8234 goto LABEL_44;
8235 }
8236 if ( v19 == 4 )
8237 {
8238 v17 = rand() % 501 + 500;
8239 LABEL_44:
8240 v14->uItemID = 198;
8241 goto LABEL_49;
8242 }
8243 if ( v19 == 5 )
8244 break;
8245 if ( v19 == 6 )
8246 {
8247 v17 = rand() % 3001 + 2000;
8248 LABEL_41:
8249 v14->uItemID = 199;
8250 }
8251 LABEL_49:
8252 v14->uAdditionalValue = v17;
8253 LABEL_51:
8254 v12 = v13 + 1;
8255 LABEL_52:
8256 --v22;
8257 if ( !v22 )
8258 goto LABEL_55;
8259 }
8260 v17 = rand() % 1001 + 1000;
8261 goto LABEL_41;
8262 }
8263 goto LABEL_55;
8264 }
8265 v10 = rand() % 501 + 500;
8266 }
8267 v3->uItemID = 198;
8268 goto LABEL_23;
8269 }
8270 v10 = rand() % 101 + 100;
8271 }
8272 v3->uItemID = 197;
8273 goto LABEL_23;
8274 }
8275 pItemsTable->GenerateItem(v9, 0, v3);
8276 goto LABEL_25;
8277 }
8278 v3->GenerateArtifact();
8279 LABEL_55:
8280 v2 = v20;
8281 LABEL_56:
8282 ++v3;
8283 --v23;
8284 }
8285 while ( v23 );
8286 v1 = v21 + 1;
8287 ++v21;
8288 }
8289 while ( (signed int)v21 < (signed int)&uNumChests );
8290 }
8291
8292 //----- (00450521) --------------------------------------------------------
8293 signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6)
8294 {
8295 int v6; // edi@1
8296 int v7; // esi@1
8297 signed int v8; // edi@1
8298 unsigned __int16 v9; // cx@1
8299 char *v10; // edx@2
8300 unsigned __int16 v11; // ax@5
8301 LayingItem a1; // [sp+8h] [bp-70h]@1
8302
8303 v6 = ecx0;
8304 v7 = a2;
8305 pItemsTable->GenerateItem(v6, v7, &a1.stru_24);
8306 v8 = 0;
8307 v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
8308 a1.uItemType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
8309 if ( (signed int)pObjectList->uNumObjects <= 0 )
8310 {
8311 LABEL_5:
8312 v11 = 0;
8313 }
8314 else
8315 {
8316 v10 = (char *)&pObjectList->pObjects->uObjectID;
8317 while ( v9 != *(short *)v10 )
8318 {
8319 ++v8;
8320 v10 += 56;
8321 if ( v8 >= (signed int)pObjectList->uNumObjects )
8322 goto LABEL_5;
8323 }
8324 v11 = v8;
8325 }
8326 a1.uObjectDescID = v11;
8327 a1.vPosition.y = a4;
8328 a1.vPosition.x = a3;
8329 a1.vPosition.z = a5;
8330 a1.uFacing = a6;
8331 a1.uAttributes = 0;
8332 a1.uSectorID = pIndoor->GetSector(a3, a4, a5);
8333 a1.uSpriteFrameID = 0;
8334 return a1.Create(0, 0, 0, 0);
8335 }
8336
8337
8338
8339
8340 //----- (0045063B) --------------------------------------------------------
8341 int __fastcall sub_45063B(MapInfo *a1, int a2)
8342 {
8343 signed int v2; // edi@1
8344 Actor *v3; // esi@2
8345 signed __int64 v4; // qax@3
8346 int result; // eax@8
8347 int v6; // edi@11
8348 int v7; // ebx@11
8349 int v8; // edi@11
8350 int v9; // ebx@12
8351 int v10; // eax@12
8352 char v11; // zf@16
8353 int v12; // edi@20
8354 int v13; // eax@20
8355 int v14; // ebx@20
8356 int v15; // eax@20
8357 int v16; // eax@20
8358 int v17; // eax@20
8359 int v18; // eax@21
8360 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1
8361 int v20; // [sp+24h] [bp-20h]@11
8362 MapInfo *v21; // [sp+28h] [bp-1Ch]@1
8363 int v22; // [sp+2Ch] [bp-18h]@3
8364 int v23; // [sp+30h] [bp-14h]@11
8365 int v24; // [sp+34h] [bp-10h]@1
8366 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10
8367 int v26; // [sp+3Ch] [bp-8h]@11
8368 int v27; // [sp+40h] [bp-4h]@11
8369
8370 v21 = a1;
8371 v24 = a2;
8372 v2 = 0;
8373 if ( (signed int)uNumActors <= 0 )
8374 goto LABEL_8;
8375 v3 = pActors;
8376 while ( 1 )
8377 {
8378 v22 = v3->pMonsterInfo.uID - 1;
8379 v4 = (signed __int64)((double)v22 * 0.3333333333333333);
8380 if ( (int)v4 != 40 )
8381 {
8382 if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() )
8383 break;
8384 }
8385 ++v2;
8386 ++v3;
8387 if ( v2 >= (signed int)uNumActors )
8388 goto LABEL_8;
8389 }
8390 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
8391 {
8392 v22 = 0;
8393 uFaceID = 0;
8394 while ( 1 )
8395 {
8396 ++uFaceID;
8397 v6 = rand() % 1024 + 512;
8398 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
8399 v20 = stru_5C6E00->SinCos(v7);
8400 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16;
8401 v19.vPosition.x = pParty->vPosition.x + v23;
8402 v20 = stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi);
8403 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16;
8404 v8 = 0;
8405 v19.uIndex = v24;
8406 v19.vPosition.y = v23 + pParty->vPosition.y;
8407 v19.vPosition.z = pParty->vPosition.z;
8408 v26 = 0;
8409 v27 = 0;
8410 v19.vPosition.z = sub_46D49E_prolly_get_world_y_under_party(
8411 v19.vPosition.x,
8412 v23 + pParty->vPosition.y,
8413 pParty->vPosition.z,
8414 0,
8415 &v26,
8416 &v27,
8417 0);
8418 v23 = 0;
8419 if ( (signed int)pOutdoor->uNumBModels > 0 )
8420 {
8421 while ( 1 )
8422 {
8423 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y);
8424 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x);
8425 if ( sub_4621DA(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 )
8426 break;
8427 ++v23;
8428 ++v8;
8429 if ( v23 >= (signed int)pOutdoor->uNumBModels )
8430 goto LABEL_16;
8431 }
8432 v22 = 1;
8433 }
8434 LABEL_16:
8435 v11 = uFaceID == 100;
8436 if ( uFaceID >= 100 )
8437 break;
8438 if ( v22 )
8439 {
8440 v11 = uFaceID == 100;
8441 break;
8442 }
8443 }
8444 }
8445 else
8446 {
8447 v26 = 0;
8448 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
8449 do
8450 {
8451 ++v26;
8452 v12 = rand() % 512 + 256;
8453 v13 = rand();
8454 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi;
8455 v15 = stru_5C6E00->SinCos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi);
8456 v20 = v15;
8457 v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16;
8458 v19.vPosition.x = pParty->vPosition.x + v23;
8459 v16 = stru_5C6E00->SinCos(v14 - stru_5C6E00->uIntegerHalfPi);
8460 v20 = v16;
8461 v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16;
8462 v19.vPosition.y = v23 + pParty->vPosition.y;
8463 v19.vPosition.z = pParty->vPosition.z;
8464 v19.uIndex = v24;
8465 v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z);
8466 if ( v17 == v22 )
8467 {
8468 v18 = _46CEC3_get_floor_level(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID);
8469 v19.vPosition.z = v18;
8470 if ( v18 != -30000 )
8471 {
8472 if ( abs(v18 - pParty->vPosition.z) <= 1024 )
8473 break;
8474 }
8475 }
8476 }
8477 while ( v26 < 100 );
8478 v11 = v26 == 100;
8479 }
8480 if ( v11 )
8481 {
8482 LABEL_8:
8483 result = 0;
8484 }
8485 else
8486 {
8487 SpawnEncounter(v21, &v19, 0, 0, 1);
8488 result = v24;
8489 }
8490 return result;
8491 }
8492
8493
8494
8495 //----- (00450929) --------------------------------------------------------
8496 int LevelDecoration::GetGlobalEvent()
8497 {
8498 LevelDecoration *v1; // esi@1
8499 signed int v2; // eax@1
8500 int v3; // eax@5
8501 int v4; // eax@6
8502 int v5; // eax@7
8503 int v6; // eax@8
8504 int v7; // eax@9
8505 int result; // eax@14
8506 int v9; // eax@18
8507 int v10; // eax@19
8508 int v11; // eax@20
8509 int v12; // eax@21
8510 int v13; // eax@22
8511
8512 v1 = this;
8513 rand();
8514 v2 = v1->uDecorationDescID;
8515 if ( v2 > 208 )
8516 {
8517 switch ( v2 )
8518 {
8519 case 209:
8520 result = rand() % 7 + 183;
8521 break;
8522 case 210:
8523 result = 150;
8524 break;
8525 case 211:
8526 result = 151;
8527 break;
8528 case 212:
8529 result = 152;
8530 break;
8531 case 213:
8532 result = 153;
8533 break;
8534 case 214:
8535 result = 154;
8536 break;
8537 case 215:
8538 result = 155;
8539 break;
8540 case 216:
8541 result = 156;
8542 break;
8543 case 217:
8544 result = 157;
8545 break;
8546 case 218:
8547 result = 158;
8548 break;
8549 case 219:
8550 result = 159;
8551 break;
8552 case 220:
8553 result = 160;
8554 break;
8555 case 221:
8556 result = 161;
8557 break;
8558 default:
8559 goto LABEL_45;
8560 }
8561 }
8562 else
8563 {
8564 if ( v2 == 208 )
8565 {
8566 result = rand() % 7 + 176;
8567 }
8568 else
8569 {
8570 if ( v2 > 24 )
8571 {
8572 v9 = v2 - 34;
8573 if ( !v9 )
8574 return rand() % 6 + 4;
8575 v10 = v9 - 150;
8576 if ( !v10 )
8577 return 33;
8578 v11 = v10 - 3;
8579 if ( !v11 || (v12 = v11 - 3) == 0 )
8580 return 37;
8581 v13 = v12 - 16;
8582 if ( !v13 )
8583 return rand() % 7 + 162;
8584 if ( v13 == 1 )
8585 return rand() % 7 + 169;
8586 }
8587 else
8588 {
8589 if ( v2 == 24 )
8590 return 36;
8591 v3 = v2 - 4;
8592 if ( !v3 )
8593 return 16;
8594 v4 = v3 - 1;
8595 if ( !v4 )
8596 return 32;
8597 v5 = v4 - 1;
8598 if ( !v5 )
8599 return rand() % 4 + 12;
8600 v6 = v5 - 5;
8601 if ( !v6 )
8602 return 34;
8603 v7 = v6 - 2;
8604 if ( !v7 )
8605 return 17;
8606 if ( v7 == 1 )
8607 return 18;
8608 }
8609 LABEL_45:
8610 result = 0;
8611 }
8612 }
8613 return result;
8614 }
8615
8616 //----- (00450AAA) --------------------------------------------------------
8617 void RespawnGlobalDecorations()
8618 {
8619 memset(stru_5E4C90._decor_events, 0, 125);
8620
8621 uint decorEventIdx = 0;
8622 for (uint i = 0; i < uNumLevelDecorations; ++i)
8623 {
8624 auto decor = pLevelDecorations + i;
8625
8626 if (!decor->field_16_event_id)
8627 {
8628 if (decor->IsInteractive())
8629 {
8630 if (decorEventIdx < 124)
8631 {
8632 decor->_idx_in_stru123 = decorEventIdx + 75;
8633 stru_5E4C90._decor_events[decorEventIdx++] = decor->GetGlobalEvent();
8634 }
8635 }
8636 }
8637 }
8638 }
8639
8640 //----- (00450B0A) --------------------------------------------------------
8641 bool __fastcall SpawnActor(unsigned int uMonsterID)
8642 {
8643 unsigned int v1; // ebx@1
8644 bool result; // eax@2
8645 MonsterDesc *v3; // esi@5
8646 MonsterInfo *v4; // edi@5
8647 Vec3_int_ v5; // ST08_12@5
8648 unsigned int v6; // ecx@5
8649 Actor *v7; // eax@7
8650 Actor actor; // [sp+4h] [bp-350h]@5
8651 Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5
8652
8653 v1 = uMonsterID;
8654 if ( uNumActors == 499 )
8655 {
8656 result = 0;
8657 }
8658 else
8659 {
8660 if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters )
8661 v1 = 0;
8662 v3 = &pMonsterList->pMonsters[v1];
8663 v4 = &pMonsterStats->pInfos[v1 + 1];
8664 memset(&actor, 0, 0x344u);
8665 strcpy(actor.pActorName, v4->pName);
8666 actor.sCurrentHP = LOWORD(v4->uHP);
8667 memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u);
8668 actor.word_000086_some_monster_id = v1 + 1;
8669 actor.uActorRadius = v3->uMonsterRadius;
8670 actor.uActorHeight = v3->uMonsterHeight;
8671 actor.uMovementSpeed = v3->uMovementSpeed;
8672 v5 = pParty->vPosition;
8673 Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y);
8674 actor.vInitialPosition.x = pOut.x;
8675 actor.vPosition.x = pOut.x;
8676 actor.uTetherDistance = 256;
8677 actor.vInitialPosition.y = LOWORD(pOut.z);
8678 actor.vPosition.y = LOWORD(pOut.z);
8679 actor.vInitialPosition.z = LOWORD(pOut.y);
8680 actor.vPosition.z = LOWORD(pOut.y);
8681 pSprites_LOD->DeleteSomeSprites();
8682 pPaletteManager->ResetNonTestLocked();
8683 v6 = uNumActors - 1;
8684 if ( dword_5C6DF8 == 1 )
8685 {
8686 dword_5C6DF8 = 0;
8687 v6 = uNumActors++;
8688 }
8689 v7 = &pActors[v6];
8690 memcpy(v7, &actor, 0x344u);
8691 v7->PrepareSprites(1);
8692 result = 1;
8693 }
8694 return result;
8695 }
8696 // 5C6DF8: using guessed type int dword_5C6DF8;
8697
8698
8699 //----- (00450DA3) --------------------------------------------------------
8700 int __cdecl GetAlertStatus()
8701 {
8702 int result; // eax@2
8703
8704 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
8705 result = pOutdoor->ddm.field_C_alert;
8706 else
8707 result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0;
8708 return result;
8709 }
8710
8711
8712
8713 //----- (00450DDE) --------------------------------------------------------
8714 stru350 *stru350::_450DDE()
8715 {
8716 _450DF1(&stru_4E82A4, &stru_4E82A4);
8717 return this;
8718 }
8719
8720
8721 //----- (00450DF1) --------------------------------------------------------
8722 bool stru350::_450DF1(const stru355 *p1, const stru355 *p2)
8723 {
8724 //stru350 *v3; // esi@1
8725 //void *result; // eax@1
8726 unsigned int v5; // ecx@2
8727 int v6; // edi@2
8728 int v7; // edx@2
8729 unsigned int v8; // ecx@8
8730 int v9; // edi@8
8731 int v10; // edx@8
8732 int v11; // ecx@12
8733 int v12; // edi@12
8734 unsigned int v13; // ecx@12
8735 int v14; // edx@12
8736 int v15; // ecx@16
8737 unsigned int v16; // edx@16
8738 int v17; // ecx@16
8739 int v18; // edi@16
8740 char v19; // zf@20
8741 unsigned int v20; // ecx@21
8742 int v21; // edi@21
8743 int v22; // edx@21
8744 unsigned int v23; // ecx@27
8745 int v24; // edi@27
8746 int v25; // edx@27
8747 int v26; // ecx@31
8748 int v27; // edi@31
8749 unsigned int v28; // ecx@31
8750 int v29; // edx@31
8751 int v30; // ebx@35
8752 int v31; // ecx@35
8753 int v32; // edi@35
8754 int v33; // edx@35
8755 unsigned int i; // ecx@35
8756 int v35; // ecx@39
8757 unsigned int v36; // edx@39
8758 int v37; // ecx@39
8759 int v38; // ebx@39
8760
8761 //v3 = this;
8762 memcpy(&field_0, p1, sizeof(stru355));
8763 memcpy(&field_20, p2, sizeof(stru355));
8764 //result = memcpy(&v3->field_20, p2, 0x20u);
8765 //LOBYTE(result) = 1;
8766 if (field_0.field_4 & 1)
8767 {
8768 v5 = field_0.field_1C;
8769 v6 = 0;
8770 v7 = 0;
8771 while ( !(v5 & 1) )
8772 {
8773 ++v6;
8774 v5 >>= 1;
8775 }
8776 do
8777 {
8778 v5 >>= 1;
8779 ++v7;
8780 }
8781 while ( v5 & 1 );
8782 field_40 = 32 - v7 - v6;
8783 }
8784 else
8785 {
8786 field_40 = 0;
8787 }
8788 v8 = field_0.field_10;
8789 v9 = 0;
8790 v10 = 0;
8791 while ( !(v8 & 1) )
8792 {
8793 ++v9;
8794 v8 >>= 1;
8795 }
8796 do
8797 {
8798 v8 >>= 1;
8799 ++v10;
8800 }
8801 while ( v8 & 1 );
8802 v11 = 24 - v10 - v9;
8803 v12 = 0;
8804 field_48 = v11;
8805 v13 = field_0.field_14;
8806 v14 = 0;
8807 while ( !(v13 & 1) )
8808 {
8809 ++v12;
8810 v13 >>= 1;
8811 }
8812 do
8813 {
8814 v13 >>= 1;
8815 ++v14;
8816 }
8817 while ( v13 & 1 );
8818 v15 = 16 - v14;
8819 v16 = field_0.field_18;
8820 field_50 = v15 - v12;
8821 v17 = 0;
8822 v18 = 0;
8823 while ( !(v16 & 1) )
8824 {
8825 ++v17;
8826 v16 >>= 1;
8827 }
8828 do
8829 {
8830 v16 >>= 1;
8831 ++v18;
8832 }
8833 while ( v16 & 1 );
8834 v19 = (field_20.field_4 & 1) == 0;
8835 field_58 = v17 - v18 + 8;
8836 if ( v19 )
8837 {
8838 field_44 = 0;
8839 }
8840 else
8841 {
8842 v20 = field_20.field_1C;
8843 v21 = 0;
8844 v22 = 0;
8845 while ( !(v20 & 1) )
8846 {
8847 ++v21;
8848 v20 >>= 1;
8849 }
8850 do
8851 {
8852 v20 >>= 1;
8853 ++v22;
8854 }
8855 while ( v20 & 1 );
8856 field_44 = 32 - v22 - v21;
8857 }
8858 v23 = field_20.field_10;
8859 v24 = 0;
8860 v25 = 0;
8861 while ( !(v23 & 1) )
8862 {
8863 ++v24;
8864 v23 >>= 1;
8865 }
8866 do
8867 {
8868 v23 >>= 1;
8869 ++v25;
8870 }
8871 while ( v23 & 1 );
8872 v26 = 24 - v25 - v24;
8873 v27 = 0;
8874 field_4C = v26;
8875 v28 = field_20.field_14;
8876 v29 = 0;
8877 while ( !(v28 & 1) )
8878 {
8879 ++v27;
8880 v28 >>= 1;
8881 }
8882 do
8883 {
8884 v28 >>= 1;
8885 ++v29;
8886 }
8887 while ( v28 & 1 );
8888 v30 = 0;
8889 v31 = 16 - v29 - v27;
8890 v32 = field_20.field_18;
8891 field_54 = v31;
8892 v33 = 0;
8893 for ( i = v32; !(i & 1); i >>= 1 )
8894 ++v30;
8895 do
8896 {
8897 i >>= 1;
8898 ++v33;
8899 }
8900 while ( i & 1 );
8901 v35 = 32 - v33;
8902 v36 = v32;
8903 field_5C = v35 - v30;
8904 v37 = 0;
8905 v38 = 0;
8906 while ( !(v36 & 1) )
8907 {
8908 ++v37;
8909 v36 >>= 1;
8910 }
8911 do
8912 {
8913 v36 >>= 1;
8914 ++v38;
8915 }
8916 while ( v36 & 1 );
8917 field_5C = v37 - v38 + 8;
8918 return true;
8919 }
8920
8921
8922
8923
8924 //----- (00450F55) --------------------------------------------------------
8925 unsigned int stru350::_450F55(int a2)
8926 {
8927 int v2 = a2 & stru_4E82A4.field_1C;
8928 if (field_20.field_4 & 1)
8929 v2 = (unsigned int)v2 >> this->field_44;
8930 return v2 & field_20.field_1C |
8931 field_20.field_10 & ((a2 & (unsigned int)stru_4E82A4.field_10) >> field_4C) |
8932 field_20.field_14 & ((a2 & (unsigned int)stru_4E82A4.field_14) >> field_54) |
8933 field_20.field_18 & ((a2 & (unsigned int)stru_4E82A4.field_18) >> field_5C);
8934 }
8935
8936 //----- (00450FB1) --------------------------------------------------------
8937 int stru350::_450FB1(int a2)
8938 {
8939 int v2 = 0;
8940 int v4 = field_0.field_4 & 1;
8941 if ( v4 )
8942 v2 = a2 & field_0.field_1C;
8943 if ( v4 )
8944 v2 <<= field_40;
8945 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58);
8946 }
8947
8948
8949 //----- (00452442) --------------------------------------------------------
8950 unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4)
8951 {
8952 int v4; // ebx@0
8953 __int16 v5; // ST14_2@1
8954 __int16 v6; // dx@1
8955 int v7; // ecx@1
8956 __int16 v8; // ST10_2@1
8957 int v9; // edi@1
8958 unsigned __int16 v10; // dh@1@1
8959 int v11; // ebx@1
8960 int v12; // ebx@1
8961 __int16 a3a; // [sp+1Ch] [bp+8h]@1
8962
8963 v5 = a2 >> 2;
8964 v6 = (unsigned __int16)a4 >> 2;
8965 v8 = a1 >> 2;
8966 a3a = (unsigned __int16)a3 >> 2;
8967 LOWORD(v7) = a3a;
8968 v9 = v7;
8969 LOWORD(v4) = ((unsigned __int16)a4 >> 2) & 0xE0;
8970 LOWORD(v7) = a3a & 0xE0;
8971 LOWORD(v9) = v9 & 0x1C00;
8972 v11 = v7 + v4;
8973 LOWORD(v7) = v5 & 0xE0;
8974 v12 = v7 + v11;
8975 LOWORD(v7) = v8 & 0xE0;
8976 return ((v8 & 7) + (v5 & 7) + (a3a & 7) + (v6 & 7)) | (v7 + v12) | ((v8 & 0x1C00)
8977 + (v5 & 0x1C00)
8978 + v9
8979 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
8980 }
8981
8982
8983
8984 //----- (0045281E) --------------------------------------------------------
8985 // Calculates atan2(y/x)
8986 // return value: angle in integer format (multiplier of Pi/1024)
8987 unsigned int stru193_math::Atan2(int x, int y)
8988 {
8989 signed int quadrant;
8990 __int64 dividend;
8991 int quotient;
8992 int lowIdx;
8993 int highIdx;
8994 int angle;
8995
8996 auto X = x;
8997 auto Y = y;
8998
8999 if ( abs(X) < 65536 )
9000 {
9001 if ( (abs(Y) >> 15) >= abs(X) )
9002 X = 0;
9003 }
9004
9005 if ( !X )
9006 {
9007 if ( Y > 0 )
9008 {
9009 return uIntegerHalfPi; //Pi/2
9010 }
9011 else
9012 {
9013 return uIntegerHalfPi + uIntegerPi; //3*(Pi/2)
9014 }
9015 }
9016
9017 if ( Y )
9018 {
9019 if ( X < 0 )
9020 {
9021 X = -X;
9022 if ( Y > 0 )
9023 {
9024 quadrant = 4;
9025 }
9026 else
9027 {
9028 quadrant = 3;
9029 }
9030 }
9031 else
9032 {
9033 if ( Y > 0 )
9034 {
9035 quadrant = 1;
9036 }
9037 else
9038 {
9039 quadrant = 2;
9040 }
9041 }
9042
9043 if ( Y < 0 )
9044 Y = -Y;
9045
9046 LODWORD(dividend) = Y << 16;
9047 HIDWORD(dividend) = Y >> 16;
9048 quotient = dividend / X;
9049
9050 //looks like binary search
9051 {
9052 int i;
9053 highIdx = uIntegerHalfPi;
9054 lowIdx = 0;
9055
9056 for (i = 0; i < 6; ++i)
9057 {
9058 if (quotient <= pTanTable[(lowIdx + highIdx) / 2])
9059 highIdx = (lowIdx + highIdx) / 2;
9060 else
9061 lowIdx = (lowIdx + highIdx) / 2;
9062 }
9063 }
9064
9065 angle = lowIdx + 1;
9066 while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] )
9067 ++angle;
9068
9069 switch (quadrant)
9070 {
9071 case 1: //X > 0, Y > 0
9072 return angle;
9073
9074 case 2: //X > 0, Y < 0
9075 return uIntegerDoublePi - angle; //2*Pi - angle
9076
9077 case 3: //X > 0, Y < 0
9078 return uIntegerPi + angle; //Pi + angle
9079
9080 case 4: //X < 0, Y > 0
9081 return uIntegerPi - angle; //Pi - angle
9082 }
9083
9084 //should newer get here
9085 return 0;
9086 }
9087
9088 if ( X < 0 ) //Y == 0, X < 0
9089 return uIntegerPi;
9090
9091 return 0;
9092 }
9093
9094
9095
9096
9097 //----- (00452969) --------------------------------------------------------
9098 stru193_math::stru193_math()
9099 {
9100 stru193_math *v1; // esi@1
9101 char *v2; // edi@1
9102 double v3; // ST18_8@2
9103 signed int v4; // edx@3
9104 int v5; // eax@4
9105 int v6; // ecx@4
9106 signed int v7; // [sp+20h] [bp-4h]@1
9107
9108 v1 = this;
9109 this->uIntegerDoublePi = 2048;
9110 this->uIntegerPi = 1024;
9111 this->uIntegerHalfPi = 512;
9112 this->uDoublePiMask = 2047;
9113 this->uPiMask = 1023;
9114 this->uHalfPiMask = 511;
9115 this->pTanTable[0] = 0;
9116 this->pCosTable[0] = 65536;
9117 this->pInvCosTable[0] = 65536;
9118 v7 = 1;
9119 v2 = (char *)&this->pInvCosTable[1];
9120 do
9121 {
9122 v3 = (double)v7 * 3.141592653589793 * 0.0009765625;
9123 *((int *)v2 - 1040) = (signed __int64)(tan(v3) * (double)v1->pCosTable[0] + 0.5);
9124 *((int *)v2 - 520) = (signed __int64)(cos(v3) * (double)v1->pCosTable[0] + 0.5);
9125 ++v7;
9126 *(int *)v2 = (signed __int64)(1.0 / cos(v3) * (double)v1->pCosTable[0] + 0.5);
9127 v2 += 4;
9128 }
9129 while ( v7 < (signed int)v1->uIntegerHalfPi );
9130 v4 = v1->uIntegerHalfPi;
9131 if ( v4 < 520 )
9132 {
9133 v5 = (int)&v1->pCosTable[v4];
9134 v6 = 520 - v4;
9135 do
9136 {
9137 *(int *)v5 = 0;
9138 *(int *)(v5 + 2080) = 0xEFFFFFFFu;
9139 *(int *)(v5 - 2080) = 0xEFFFFFFFu;
9140 v5 += 4;
9141 --v6;
9142 }
9143 while ( v6 );
9144 }
9145 }
9146
9147 //----- (00452A9E) --------------------------------------------------------
9148 signed int __fastcall sub_452A9E(signed int a1)
9149 {
9150 signed int result; // eax@2
9151 int v2; // edx@3
9152 signed int v3; // edi@3
9153 signed int v4; // ebx@3
9154 int v5; // esi@4
9155
9156 if ( a1 > 1 )
9157 {
9158 v2 = 0;
9159 v3 = a1;
9160 result = 0;
9161 v4 = 16;
9162 do
9163 {
9164 result *= 2;
9165 v2 = ((unsigned int)v3 >> 30) | 4 * v2;
9166 v5 = 2 * result + 1;
9167 v3 *= 4;
9168 if ( v2 >= (unsigned int)v5 )
9169 {
9170 ++result;
9171 v2 -= v5;
9172 }
9173 --v4;
9174 }
9175 while ( v4 );
9176 if ( a1 - result * result >= (unsigned int)(result - 1) )
9177 ++result;
9178 }
9179 else
9180 {
9181 result = a1;
9182 }
9183 return result;
9184 }
9185
9186 //----- (00452AE2) --------------------------------------------------------
9187 int __fastcall MakeColorMaskFromBitDepth(int a1)
9188 {
9189 signed __int64 v1; // qax@1
9190
9191 v1 = 4294967296i64;
9192 if ( a1 > 0 )
9193 {
9194 do
9195 {
9196 LODWORD(v1) = HIDWORD(v1) + v1;
9197 HIDWORD(v1) *= 2;
9198 --a1;
9199 }
9200 while ( a1 );
9201 }
9202 return v1;
9203 }
9204
9205 //----- (00452AF3) --------------------------------------------------------
9206 void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels)
9207 {
9208 void *v3; // edi@1
9209 unsigned int v4; // eax@1
9210 unsigned __int16 *v5; // edi@3
9211 unsigned int i; // ecx@3
9212
9213 v3 = pPixels;
9214 v4 = a1 | (a1 << 16);
9215 if ( (unsigned __int8)pPixels & 2 ) // first 2 pixels
9216 {
9217 *pPixels = v4;
9218 v3 = pPixels + 1;
9219 --uNumPixels;
9220 }
9221 memset32(v3, v4, uNumPixels >> 1); // 4 pixels at once
9222 v5 = (unsigned __int16 *)((char *)v3 + 4 * (uNumPixels >> 1));
9223 for ( i = uNumPixels & 1; i; --i ) // leftover pixels
9224 {
9225 *v5 = v4;
9226 ++v5;
9227 }
9228 }
9229
9230 //----- (00452B2E) --------------------------------------------------------
9231 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides)
9232 {
9233 signed int v2; // edi@1
9234 int v3; // esi@1
9235 int result; // eax@2
9236 unsigned int v5; // ebx@4
9237
9238 v2 = uDiceSides;
9239 v3 = 0;
9240 if ( uDiceSides )
9241 {
9242 if ( (signed int)uNumDice > 0 )
9243 {
9244 v5 = uNumDice;
9245 do
9246 {
9247 --v5;
9248 v3 += rand() % v2 + 1;
9249 }
9250 while ( v5 );
9251 }
9252 result = v3;
9253 }
9254 else
9255 {
9256 result = 0;
9257 }
9258 return result;
9259 }
9260
9261
9262 //----- (00452B95) --------------------------------------------------------
9263 void __cdecl SetSomeItemsNames()
9264 {
9265 pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
9266 pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
9267 pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
9268 pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273];
9269 pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274];
9270 pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275];
9271 pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276];
9272 pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277];
9273 pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278];
9274 pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279];
9275 pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280];
9276 pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
9277 pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
9278 pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
9279 memset(&stru_5E4C50, 0, sizeof(stru_5E4C50));
9280 }
9281
9282 //----- (00452C30) --------------------------------------------------------
9283 char *RemoveQuotes(char *Str)
9284 {
9285 char *v1; // esi@1
9286
9287 v1 = Str;
9288 if ( *Str == '"' )
9289 {
9290 Str[strlen(Str) - 1] = 0;
9291 v1 = Str + 1;
9292 }
9293 return v1;
9294 }
9295
9296 //----- (00452C49) --------------------------------------------------------
9297 void InitializeGameText()
9298 {
9299 //char *v0; // ebx@1
9300 char *v1; // eax@3
9301 int v2; // ebp@4
9302 char v3; // dl@5
9303 char *v4; // ecx@5
9304 int v5; // esi@9
9305 //char **v6; // [sp+10h] [bp-8h]@3
9306 signed int v7; // [sp+14h] [bp-4h]@4
9307
9308 //v0 = 0;
9309 if (pGlobalTXT_Raw)
9310 pAllocator->FreeChunk(pGlobalTXT_Raw);
9311
9312 pGlobalTXT_Raw = nullptr;
9313 pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0);
9314
9315 strtok(pGlobalTXT_Raw, "\r");
9316 strtok(nullptr, "\r");
9317 v1 = strtok(nullptr, "\r") + 1;
9318
9319 for (uint i = 0; i < 677; ++i)
9320 {
9321 char *p = v1;
9322 while (*++p != '\t' && *p);
9323
9324 pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(p + 1);
9325
9326 v1 = strtok(nullptr, "\r") + 1;
9327 }
9328
9329 aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
9330 aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
9331 aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
9332 pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280];
9333 aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
9334 pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
9335 aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
9336 pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
9337 aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
9338 pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
9339 aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
9340 aCharacterConditionNames[0] = pGlobalTXT_LocalizationStrings[52];
9341 aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
9342 aCharacterConditionNames[1] = pGlobalTXT_LocalizationStrings[241];
9343 aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
9344 aCharacterConditionNames[2] = pGlobalTXT_LocalizationStrings[14];
9345 aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
9346 aCharacterConditionNames[3] = pGlobalTXT_LocalizationStrings[4];
9347 aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
9348 aCharacterConditionNames[4] = pGlobalTXT_LocalizationStrings[69];
9349 aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
9350 aCharacterConditionNames[5] = pGlobalTXT_LocalizationStrings[117];
9351 pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
9352 aCharacterConditionNames[6] = pGlobalTXT_LocalizationStrings[166];
9353 aCharacterConditionNames[8] = pGlobalTXT_LocalizationStrings[166];
9354 aCharacterConditionNames[10] = pGlobalTXT_LocalizationStrings[166];
9355 pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275];
9356 aCharacterConditionNames[12] = pGlobalTXT_LocalizationStrings[162];
9357 pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276];
9358 aCharacterConditionNames[13] = pGlobalTXT_LocalizationStrings[231];
9359 pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277];
9360 aCharacterConditionNames[14] = pGlobalTXT_LocalizationStrings[58];
9361 pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278];
9362 aCharacterConditionNames[15] = pGlobalTXT_LocalizationStrings[220];
9363 pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
9364 pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
9365 pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273];
9366 pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274];
9367 pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279];
9368 aCharacterConditionNames[7] = pGlobalTXT_LocalizationStrings[65];
9369 aCharacterConditionNames[9] = pGlobalTXT_LocalizationStrings[65];
9370 aCharacterConditionNames[11] = pGlobalTXT_LocalizationStrings[65];
9371 aCharacterConditionNames[16] = pGlobalTXT_LocalizationStrings[76];
9372 pClassNames[9] = pGlobalTXT_LocalizationStrings[26];
9373 pClassNames[10] = pGlobalTXT_LocalizationStrings[432];
9374 pClassNames[11] = pGlobalTXT_LocalizationStrings[27];
9375 pClassNames[12] = pGlobalTXT_LocalizationStrings[262];
9376 pClassNames[13] = pGlobalTXT_LocalizationStrings[263];
9377 pClassNames[14] = pGlobalTXT_LocalizationStrings[264];
9378 pClassNames[15] = pGlobalTXT_LocalizationStrings[28];
9379 pClassNames[16] = pGlobalTXT_LocalizationStrings[265];
9380 pClassNames[17] = pGlobalTXT_LocalizationStrings[267];
9381 pClassNames[18] = pGlobalTXT_LocalizationStrings[119];
9382 pClassNames[19] = pGlobalTXT_LocalizationStrings[124];
9383 pClassNames[20] = pGlobalTXT_LocalizationStrings[31];
9384 pClassNames[21] = pGlobalTXT_LocalizationStrings[370];
9385 pClassNames[22] = pGlobalTXT_LocalizationStrings[33];
9386 aCharacterConditionNames[17] = pGlobalTXT_LocalizationStrings[601];
9387 pClassNames[23] = pGlobalTXT_LocalizationStrings[40];
9388 aCharacterConditionNames[18] = pGlobalTXT_LocalizationStrings[98];
9389 pClassNames[24] = pGlobalTXT_LocalizationStrings[256];
9390 pClassNames[0] = pGlobalTXT_LocalizationStrings[253];
9391 pClassNames[25] = pGlobalTXT_LocalizationStrings[257];
9392 pClassNames[1] = pGlobalTXT_LocalizationStrings[254];
9393 pClassNames[26] = pGlobalTXT_LocalizationStrings[44];
9394 pClassNames[2] = pGlobalTXT_LocalizationStrings[255];
9395 pClassNames[27] = pGlobalTXT_LocalizationStrings[46];
9396 pClassNames[3] = pGlobalTXT_LocalizationStrings[2];
9397 pClassNames[28] = pGlobalTXT_LocalizationStrings[268];
9398 pClassNames[4] = pGlobalTXT_LocalizationStrings[307];
9399 pClassNames[29] = pGlobalTXT_LocalizationStrings[269];
9400 pClassNames[5] = pGlobalTXT_LocalizationStrings[114];
9401 pClassNames[30] = pGlobalTXT_LocalizationStrings[270];
9402 pClassNames[6] = pGlobalTXT_LocalizationStrings[3];
9403 pClassNames[31] = pGlobalTXT_LocalizationStrings[48];
9404 pClassNames[7] = pGlobalTXT_LocalizationStrings[13];
9405 pClassNames[32] = pGlobalTXT_LocalizationStrings[259];
9406 pClassNames[8] = pGlobalTXT_LocalizationStrings[21];
9407 pClassNames[33] = pGlobalTXT_LocalizationStrings[260];
9408 pClassNames[34] = pGlobalTXT_LocalizationStrings[261];
9409 pClassNames[35] = pGlobalTXT_LocalizationStrings[49];
9410 pSkillNames[0] = pGlobalTXT_LocalizationStrings[271];
9411 pSkillNames[1] = pGlobalTXT_LocalizationStrings[272];
9412 pSkillNames[2] = pGlobalTXT_LocalizationStrings[273];
9413 pSkillNames[3] = pGlobalTXT_LocalizationStrings[274];
9414 pSkillNames[4] = pGlobalTXT_LocalizationStrings[275];
9415 pSkillNames[5] = pGlobalTXT_LocalizationStrings[276];
9416 pSkillNames[6] = pGlobalTXT_LocalizationStrings[277];
9417 pSkillNames[7] = pGlobalTXT_LocalizationStrings[278];
9418 pSkillNames[23] = pGlobalTXT_LocalizationStrings[294];
9419 pSkillNames[9] = pGlobalTXT_LocalizationStrings[280];
9420 pSkillNames[24] = pGlobalTXT_LocalizationStrings[295];
9421 pSkillNames[10] = pGlobalTXT_LocalizationStrings[281];
9422 pSkillNames[25] = pGlobalTXT_LocalizationStrings[296];
9423 pSkillNames[11] = pGlobalTXT_LocalizationStrings[282];
9424 pSkillNames[26] = pGlobalTXT_LocalizationStrings[297];
9425 pSkillNames[12] = pGlobalTXT_LocalizationStrings[283];
9426 pSkillNames[27] = pGlobalTXT_LocalizationStrings[298];
9427 pSkillNames[13] = pGlobalTXT_LocalizationStrings[284];
9428 pSkillNames[28] = pGlobalTXT_LocalizationStrings[299];
9429 pSkillNames[14] = pGlobalTXT_LocalizationStrings[285];
9430 pSkillNames[29] = pGlobalTXT_LocalizationStrings[300];
9431 pSkillNames[15] = pGlobalTXT_LocalizationStrings[286];
9432 pSkillNames[30] = pGlobalTXT_LocalizationStrings[50];
9433 pSkillNames[16] = pGlobalTXT_LocalizationStrings[289];
9434 pSkillNames[31] = pGlobalTXT_LocalizationStrings[77];
9435 aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
9436 pSkillNames[17] = pGlobalTXT_LocalizationStrings[290];
9437 pSkillNames[32] = pGlobalTXT_LocalizationStrings[88];
9438 aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
9439 pSkillNames[18] = pGlobalTXT_LocalizationStrings[291];
9440 pSkillNames[33] = pGlobalTXT_LocalizationStrings[89];
9441 aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
9442 pSkillNames[19] = pGlobalTXT_LocalizationStrings[287];
9443 pSkillNames[34] = pGlobalTXT_LocalizationStrings[90];
9444 aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
9445 pSkillNames[20] = pGlobalTXT_LocalizationStrings[288];
9446 pSkillNames[35] = pGlobalTXT_LocalizationStrings[95];
9447 aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
9448 pSkillNames[21] = pGlobalTXT_LocalizationStrings[292];
9449 pSkillNames[36] = pGlobalTXT_LocalizationStrings[301];
9450 aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
9451 pSkillNames[8] = pGlobalTXT_LocalizationStrings[279];
9452 pSkillNames[22] = pGlobalTXT_LocalizationStrings[293];
9453 pSkillNames[37] = pGlobalTXT_LocalizationStrings[153];
9454 aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
9455 aNPCProfessionNames[0] = pGlobalTXT_LocalizationStrings[153];
9456 aNPCProfessionNames[1] = pGlobalTXT_LocalizationStrings[308];
9457 aNPCProfessionNames[2] = pGlobalTXT_LocalizationStrings[309];
9458 aNPCProfessionNames[3] = pGlobalTXT_LocalizationStrings[7];
9459 aNPCProfessionNames[4] = pGlobalTXT_LocalizationStrings[306];
9460 aNPCProfessionNames[5] = pGlobalTXT_LocalizationStrings[310];
9461 aNPCProfessionNames[6] = pGlobalTXT_LocalizationStrings[311];
9462 aNPCProfessionNames[7] = pGlobalTXT_LocalizationStrings[312];
9463 aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
9464 aNPCProfessionNames[8] = pGlobalTXT_LocalizationStrings[313];
9465 aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
9466 aNPCProfessionNames[9] = pGlobalTXT_LocalizationStrings[314];
9467 aNPCProfessionNames[21] = pGlobalTXT_LocalizationStrings[293];
9468 aNPCProfessionNames[10] = pGlobalTXT_LocalizationStrings[105];
9469 aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
9470 aNPCProfessionNames[11] = pGlobalTXT_LocalizationStrings[315];
9471 aNPCProfessionNames[22] = pGlobalTXT_LocalizationStrings[324];
9472 aNPCProfessionNames[12] = pGlobalTXT_LocalizationStrings[316];
9473 aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
9474 aNPCProfessionNames[13] = pGlobalTXT_LocalizationStrings[317];
9475 aNPCProfessionNames[23] = pGlobalTXT_LocalizationStrings[498];
9476 aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
9477 aNPCProfessionNames[14] = pGlobalTXT_LocalizationStrings[115];
9478 aNPCProfessionNames[24] = pGlobalTXT_LocalizationStrings[525];
9479 aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
9480 aNPCProfessionNames[15] = pGlobalTXT_LocalizationStrings[318];
9481 aNPCProfessionNames[25] = pGlobalTXT_LocalizationStrings[327];
9482 aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
9483 aNPCProfessionNames[16] = pGlobalTXT_LocalizationStrings[319];
9484 aNPCProfessionNames[26] = pGlobalTXT_LocalizationStrings[328];
9485 aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
9486 aNPCProfessionNames[17] = pGlobalTXT_LocalizationStrings[320];
9487 aNPCProfessionNames[27] = pGlobalTXT_LocalizationStrings[329];
9488 aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
9489 aNPCProfessionNames[18] = pGlobalTXT_LocalizationStrings[321];
9490 aNPCProfessionNames[28] = pGlobalTXT_LocalizationStrings[330];
9491 aAMPMNames[0] = pGlobalTXT_LocalizationStrings[472];
9492 aNPCProfessionNames[19] = pGlobalTXT_LocalizationStrings[322];
9493 aNPCProfessionNames[29] = pGlobalTXT_LocalizationStrings[331];
9494 aAMPMNames[1] = pGlobalTXT_LocalizationStrings[473];
9495 aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[323];
9496 aNPCProfessionNames[30] = pGlobalTXT_LocalizationStrings[332];
9497 aNPCProfessionNames[31] = pGlobalTXT_LocalizationStrings[333];
9498 aNPCProfessionNames[32] = pGlobalTXT_LocalizationStrings[334];
9499 aNPCProfessionNames[33] = pGlobalTXT_LocalizationStrings[335];
9500 aNPCProfessionNames[34] = pGlobalTXT_LocalizationStrings[336];
9501 aNPCProfessionNames[35] = pGlobalTXT_LocalizationStrings[337];
9502 aNPCProfessionNames[36] = pGlobalTXT_LocalizationStrings[338];
9503 aNPCProfessionNames[37] = pGlobalTXT_LocalizationStrings[339];
9504 aNPCProfessionNames[38] = pGlobalTXT_LocalizationStrings[340];
9505 aNPCProfessionNames[39] = pGlobalTXT_LocalizationStrings[341];
9506 aNPCProfessionNames[40] = pGlobalTXT_LocalizationStrings[342];
9507 aNPCProfessionNames[56] = pGlobalTXT_LocalizationStrings[21];
9508 aNPCProfessionNames[41] = pGlobalTXT_LocalizationStrings[343];
9509 aNPCProfessionNames[57] = pGlobalTXT_LocalizationStrings[600];
9510 aNPCProfessionNames[42] = pGlobalTXT_LocalizationStrings[596];
9511 aNPCProfessionNames[58] = pGlobalTXT_LocalizationStrings[370];
9512 aNPCProfessionNames[43] = pGlobalTXT_LocalizationStrings[345];
9513 aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
9514 aNPCProfessionNames[44] = pGlobalTXT_LocalizationStrings[346];
9515 aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
9516 aNPCProfessionNames[45] = pGlobalTXT_LocalizationStrings[347];
9517 aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
9518 aNPCProfessionNames[46] = pGlobalTXT_LocalizationStrings[348];
9519 aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
9520 aNPCProfessionNames[47] = pGlobalTXT_LocalizationStrings[349];
9521 aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
9522 aNPCProfessionNames[48] = pGlobalTXT_LocalizationStrings[350];
9523 aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
9524 aNPCProfessionNames[49] = pGlobalTXT_LocalizationStrings[597];
9525 aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
9526 aNPCProfessionNames[50] = pGlobalTXT_LocalizationStrings[352];
9527 aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
9528 aNPCProfessionNames[51] = pGlobalTXT_LocalizationStrings[353];
9529 aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
9530 aNPCProfessionNames[52] = pGlobalTXT_LocalizationStrings[598];
9531 aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
9532 aNPCProfessionNames[53] = pGlobalTXT_LocalizationStrings[344];
9533 aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
9534 aNPCProfessionNames[54] = pGlobalTXT_LocalizationStrings[26];
9535 aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
9536 aNPCProfessionNames[55] = pGlobalTXT_LocalizationStrings[599];
9537 aSpellNames[14] = pGlobalTXT_LocalizationStrings[279];
9538 aSpellNames[33] = pGlobalTXT_LocalizationStrings[279];
9539 aSpellNames[9] = pGlobalTXT_LocalizationStrings[440];
9540 aSpellNames[34] = pGlobalTXT_LocalizationStrings[442];
9541 aSpellNames[0] = pGlobalTXT_LocalizationStrings[202];
9542 aSpellNames[10] = pGlobalTXT_LocalizationStrings[218];
9543 aSpellNames[20] = pGlobalTXT_LocalizationStrings[202];
9544 aSpellNames[35] = pGlobalTXT_LocalizationStrings[235];
9545 aSpellNames[11] = pGlobalTXT_LocalizationStrings[217];
9546 aSpellNames[21] = pGlobalTXT_LocalizationStrings[443];
9547 aSpellNames[36] = pGlobalTXT_LocalizationStrings[246];
9548 aSpellNames[12] = pGlobalTXT_LocalizationStrings[213];
9549 aSpellNames[24] = pGlobalTXT_LocalizationStrings[221];
9550 aSpellNames[37] = pGlobalTXT_LocalizationStrings[247];
9551 aSpellNames[13] = pGlobalTXT_LocalizationStrings[462];
9552 aSpellNames[26] = pGlobalTXT_LocalizationStrings[228];
9553 aSpellNames[38] = pGlobalTXT_LocalizationStrings[248];
9554 aSpellNames[15] = pGlobalTXT_LocalizationStrings[442];
9555 aSpellNames[28] = pGlobalTXT_LocalizationStrings[440];
9556 aSpellNames[39] = pGlobalTXT_LocalizationStrings[674];
9557 aSpellNames[16] = pGlobalTXT_LocalizationStrings[452];
9558 aSpellNames[29] = pGlobalTXT_LocalizationStrings[213];
9559 aSpellNames[40] = pGlobalTXT_LocalizationStrings[249];
9560 aSpellNames[2] = pGlobalTXT_LocalizationStrings[219];
9561 aSpellNames[17] = pGlobalTXT_LocalizationStrings[194];
9562 aSpellNames[30] = pGlobalTXT_LocalizationStrings[229];
9563 aSpellNames[41] = pGlobalTXT_LocalizationStrings[258];
9564 aSpellNames[5] = pGlobalTXT_LocalizationStrings[454];
9565 aSpellNames[3] = pGlobalTXT_LocalizationStrings[215];
9566 aSpellNames[7] = pGlobalTXT_LocalizationStrings[455];
9567 aSpellNames[18] = pGlobalTXT_LocalizationStrings[456];
9568 aSpellNames[31] = pGlobalTXT_LocalizationStrings[233];
9569 aSpellNames[42] = pGlobalTXT_LocalizationStrings[194];
9570 aSpellNames[6] = pGlobalTXT_LocalizationStrings[24];
9571 aSpellNames[25] = pGlobalTXT_LocalizationStrings[24];
9572 aSpellNames[1] = pGlobalTXT_LocalizationStrings[204];
9573 aSpellNames[4] = pGlobalTXT_LocalizationStrings[208];
9574 aSpellNames[8] = pGlobalTXT_LocalizationStrings[441];
9575 aSpellNames[19] = pGlobalTXT_LocalizationStrings[453];
9576 aSpellNames[22] = pGlobalTXT_LocalizationStrings[204];
9577 aSpellNames[23] = pGlobalTXT_LocalizationStrings[208];
9578 aSpellNames[27] = pGlobalTXT_LocalizationStrings[441];
9579 aSpellNames[32] = pGlobalTXT_LocalizationStrings[234];
9580 aSpellNames[43] = pGlobalTXT_LocalizationStrings[657];
9581 }
9582
9583
9584
9585
9586
9587
9588
9589 //----- (00453E6D) --------------------------------------------------------
9590 void StorylineText::Initialize()
9591 {
9592 char *v1; // ebx@1
9593 StorylineText *v2; // esi@1
9594 char *v3; // ecx@4
9595 char v4; // dl@5
9596 char *v5; // eax@5
9597 int v6; // esi@9
9598 int v7; // [sp+Ch] [bp-10h]@3
9599 int v8; // [sp+10h] [bp-Ch]@4
9600 char *v9; // [sp+14h] [bp-8h]@4
9601 int Str; // [sp+18h] [bp-4h]@3
9602
9603 v1 = 0;
9604 v2 = this;
9605 if ( pHistoryTXT_Raw )
9606 pAllocator->FreeChunk(pHistoryTXT_Raw);
9607 pHistoryTXT_Raw = 0;
9608 pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0);
9609 strtok(pHistoryTXT_Raw, "\r");
9610 Str = (int)&v2->field_4[4];
9611 v7 = 29;
9612 do
9613 {
9614 v9 = v1;
9615 v8 = (signed int)v1;
9616 v3 = strtok(v1, "\r");
9617 do
9618 {
9619 v4 = *v3;
9620 v5 = 0;
9621 if ( *v3 != 9 )
9622 {
9623 v1 = 0;
9624 do
9625 {
9626 if ( !v4 )
9627 break;
9628 ++v5;
9629 v4 = v3[(int)v5];
9630 }
9631 while ( v4 != 9 );
9632 }
9633 v6 = (int)&v3[(int)v5];
9634 if ( v3[(int)v5] == (char)v1 )
9635 v8 = 1;
9636 *(char *)v6 = (char)v1;
9637 if ( v5 == v1 )
9638 {
9639 v8 = 1;
9640 }
9641 else
9642 {
9643 if ( v9 == (char *)1 )
9644 {
9645 *(char **)(Str - 8) = RemoveQuotes(v3);
9646 }
9647 else
9648 {
9649 if ( v9 == (char *)2 )
9650 {
9651 *(char *)Str = atoi(v3);
9652 }
9653 else
9654 {
9655 if ( v9 - 2 == (char *)1 )
9656 *(char * *)(Str - 4) = RemoveQuotes(v3);
9657 }
9658 }
9659 }
9660 ++v9;
9661 v3 = (char *)(v6 + 1);
9662 }
9663 while ( (signed int)(v9 - 1) <= 3 && (char *)v8 == v1 );
9664 Str += 12;
9665 --v7;
9666 }
9667 while ( v7 );
9668 }
9669
9670 //----- (00453F62) --------------------------------------------------------
9671 void MapStats::Initialize()
9672 {
9673 MapStats *v1; // esi@1
9674 unsigned int v2; // ebx@3
9675 char *v3; // eax@4
9676 char *v4; // edi@4
9677 char v5; // cl@5
9678 int v6; // eax@5
9679 size_t v7; // eax@32
9680 size_t v8; // eax@35
9681 size_t v9; // eax@42
9682 size_t v10; // eax@45
9683 size_t v11; // eax@52
9684 size_t v12; // eax@55
9685 char Str[32]; // [sp+Ch] [bp-34h]@30
9686 char *v14; // [sp+2Ch] [bp-14h]@9
9687 int v15; // [sp+30h] [bp-10h]@4
9688 int v16; // [sp+34h] [bp-Ch]@4
9689 unsigned int v17; // [sp+38h] [bp-8h]@30
9690 MapStats *v18; // [sp+3Ch] [bp-4h]@30
9691
9692 v1 = this;
9693 if ( pMapStatsTXT_Raw )
9694 pAllocator->FreeChunk(pMapStatsTXT_Raw);
9695 pMapStatsTXT_Raw = 0;
9696 pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0);
9697 strtok(pMapStatsTXT_Raw, "\r");
9698 strtok(0, "\r");
9699 strtok(0, "\r");
9700 v2 = 1;
9701 v1->uNumMaps = 77;
9702 do
9703 {
9704 v3 = strtok(0, "\r");
9705 v16 = 0;
9706 v15 = 0;
9707 v4 = v3;
9708 do
9709 {
9710 v5 = *v4;
9711 v6 = 0;
9712 while ( v5 != 9 && v5 )
9713 {
9714 ++v6;
9715 v5 = v4[v6];
9716 }
9717 v14 = &v4[v6];
9718 if ( !v4[v6] )
9719 v15 = 1;
9720 v4[v6] = 0;
9721 if ( v6 )
9722 {
9723 switch ( v16 )
9724 {
9725 case 1:
9726 v1->pInfos[v2].pName = (char *)RemoveQuotes(v4);
9727 break;
9728 case 2:
9729 v1->pInfos[v2].pFilename = (char *)RemoveQuotes(v4);
9730 break;
9731 case 3:
9732 v1->pInfos[v2].uNumResets = atoi(v4);
9733 break;
9734 case 4:
9735 v1->pInfos[v2].uFirstVisitedAt = atoi(v4);
9736 break;
9737 case 5:
9738 v1->pInfos[v2]._per = atoi(v4);
9739 break;
9740 case 6:
9741 v1->pInfos[v2].uRespawnIntervalDays = atoi(v4);
9742 break;
9743 case 7:
9744 v1->pInfos[v2]._alert_days = atoi(v4);
9745 break;
9746 case 8:
9747 v1->pInfos[v2]._steal_perm = atoi(v4);
9748 break;
9749 case 9:
9750 v1->pInfos[v2].field_2D = atoi(v4);
9751 break;
9752 case 10:
9753 v1->pInfos[v2].field_2E = atoi(v4);
9754 break;
9755 case 11:
9756 v1->pInfos[v2].field_2F = atoi(v4);
9757 break;
9758 case 12:
9759 v1->pInfos[v2].field_30 = atoi(v4);
9760 break;
9761 case 13:
9762 v1->pInfos[v2].field_31 = atoi(v4);
9763 break;
9764 case 14:
9765 v1->pInfos[v2].field_32 = atoi(v4);
9766 break;
9767 case 15:
9768 v1->pInfos[v2].field_33 = atoi(v4);
9769 break;
9770 case 16:
9771 v1->pInfos[v2].pEncounterMonster1Texture = (char *)RemoveQuotes(v4);
9772 break;
9773 case 18:
9774 v1->pInfos[v2].field_34 = atoi(v4);
9775 break;
9776 case 19:
9777 v18 = (MapStats *)((char *)v1 + 68 * v2);
9778 v18->pInfos[0].uEncounterMonster1AtLeast = 1;
9779 strcpy(Str, v4);
9780 v17 = 0;
9781 if ( strlen(Str) )
9782 {
9783 while ( Str[v17] != 45 )
9784 {
9785 ++v17;
9786 v7 = strlen(Str);
9787 if ( v17 >= v7 )
9788 goto LABEL_35;
9789 }
9790 Str[v17] = 0;
9791 v18->pInfos[0].uEncounterMonster1AtLeast = atoi(Str);
9792 }
9793 LABEL_35:
9794 v8 = strlen(Str);
9795 if ( v17 == v8 )
9796 v18->pInfos[0].uEncounterMonster1AtMost = atoi(&v4[v17 + 1]);
9797 else
9798 v18->pInfos[0].uEncounterMonster1AtMost = v18->pInfos[0].uEncounterMonster1AtLeast;
9799 break;
9800 case 20:
9801 v1->pInfos[v2].pEncounterMonster2Texture = (char *)RemoveQuotes(v4);
9802 break;
9803 case 22:
9804 v1->pInfos[v2].field_37 = atoi(v4);
9805 break;
9806 case 23:
9807 v18 = (MapStats *)((char *)v1 + 68 * v2);
9808 v18->pInfos[0].uEncounterMonster2AtLeast = 1;
9809 strcpy(Str, v4);
9810 v17 = 0;
9811 if ( strlen(Str) )
9812 {
9813 while ( Str[v17] != 45 )
9814 {
9815 ++v17;
9816 v9 = strlen(Str);
9817 if ( v17 >= v9 )
9818 goto LABEL_45;
9819 }
9820 Str[v17] = 0;
9821 v18->pInfos[0].uEncounterMonster2AtLeast = atoi(Str);
9822 }
9823 LABEL_45:
9824 v10 = strlen(Str);
9825 if ( v17 == v10 )
9826 v18->pInfos[0].uEncounterMonster2AtMost = atoi(&v4[v17 + 1]);
9827 else
9828 v18->pInfos[0].uEncounterMonster2AtMost = v18->pInfos[0].uEncounterMonster2AtLeast;
9829 break;
9830 case 24:
9831 v1->pInfos[v2].pEncounterMonster3Texture = (char *)RemoveQuotes(v4);
9832 break;
9833 case 26:
9834 v1->pInfos[v2].field_3A = atoi(v4);
9835 break;
9836 case 27:
9837 v18 = (MapStats *)((char *)v1 + 68 * v2);
9838 v18->pInfos[0].uEncounterMonster3AtLeast = 1;
9839 strcpy(Str, v4);
9840 v17 = 0;
9841 if ( strlen(Str) )
9842 {
9843 while ( Str[v17] != 45 )
9844 {
9845 ++v17;
9846 v11 = strlen(Str);
9847 if ( v17 >= v11 )
9848 goto LABEL_55;
9849 }
9850 Str[v17] = 0;
9851 v18->pInfos[0].uEncounterMonster3AtLeast = atoi(Str);
9852 }
9853 LABEL_55:
9854 v12 = strlen(Str);
9855 if ( v17 == v12 )
9856 v18->pInfos[0].uEncounterMonster3AtMost = atoi(&v4[v17 + 1]);
9857 else
9858 v18->pInfos[0].uEncounterMonster3AtMost = v18->pInfos[0].uEncounterMonster3AtLeast;
9859 break;
9860 case 28:
9861 v1->pInfos[v2].uRedbookTrackID = atoi(v4);
9862 break;
9863 case 29:
9864 if ( strcmp(v4, "GENERIC") )
9865 {
9866 if ( strcmp(v4, "PADDEDCELL") )
9867 {
9868 if ( strcmp(v4, "ROOM") )
9869 {
9870 if ( strcmp(v4, "BATHROOM") )
9871 {
9872 if ( strcmp(v4, "LIVINGROOM") )
9873 {
9874 if ( strcmp(v4, "STONEROOM") )
9875 {
9876 if ( strcmp(v4, "AUDITORIUM") )
9877 {
9878 if ( strcmp(v4, "CONCERTHALL") )
9879 {
9880 if ( strcmp(v4, "CAVE") )
9881 {
9882 if ( strcmp(v4, "ARENA") )
9883 {
9884 if ( strcmp(v4, "HANGAR") )
9885 {
9886 if ( strcmp(v4, "CARPETEDHALLWAY") )
9887 {
9888 if ( strcmp(v4, "HALLWAY") )
9889 {
9890 if ( strcmp(v4, "STONECORRIDOR") )
9891 {
9892 if ( strcmp(v4, "ALLEY") )
9893 {
9894 if ( strcmp(v4, "FOREST") )
9895 {
9896 if ( strcmp(v4, "CITY") )
9897 {
9898 if ( strcmp(v4, "MOUNTAINS") )
9899 {
9900 if ( strcmp(v4, "QUARRY") )
9901 {
9902 if ( strcmp(v4, "PLAIN") )
9903 {
9904 if ( strcmp(v4, "PARKINGLOT") )
9905 {
9906 if ( strcmp(v4, "SEWERPIPE") )
9907 {
9908 if ( strcmp(v4, "UNDERWATER") )
9909 {
9910 if ( strcmp(v4, "DRUGGED") )
9911 {
9912 if ( strcmp(v4, "DIZZY") )
9913 {
9914 if ( strcmp(v4, "PSYCHOTIC") )
9915 v1->pInfos[v2].uEAXEnv = 26;
9916 else
9917 v1->pInfos[v2].uEAXEnv = 25;
9918 }
9919 else
9920 {
9921 v1->pInfos[v2].uEAXEnv = 24;
9922 }
9923 }
9924 else
9925 {
9926 v1->pInfos[v2].uEAXEnv = 23;
9927 }
9928 }
9929 else
9930 {
9931 v1->pInfos[v2].uEAXEnv = 22;
9932 }
9933 }
9934 else
9935 {
9936 v1->pInfos[v2].uEAXEnv = 21;
9937 }
9938 }
9939 else
9940 {
9941 v1->pInfos[v2].uEAXEnv = 20;
9942 }
9943 }
9944 else
9945 {
9946 v1->pInfos[v2].uEAXEnv = 19;
9947 }
9948 }
9949 else
9950 {
9951 v1->pInfos[v2].uEAXEnv = 18;
9952 }
9953 }
9954 else
9955 {
9956 v1->pInfos[v2].uEAXEnv = 17;
9957 }
9958 }
9959 else
9960 {
9961 v1->pInfos[v2].uEAXEnv = 16;
9962 }
9963 }
9964 else
9965 {
9966 v1->pInfos[v2].uEAXEnv = 15;
9967 }
9968 }
9969 else
9970 {
9971 v1->pInfos[v2].uEAXEnv = 14;
9972 }
9973 }
9974 else
9975 {
9976 v1->pInfos[v2].uEAXEnv = 13;
9977 }
9978 }
9979 else
9980 {
9981 v1->pInfos[v2].uEAXEnv = 12;
9982 }
9983 }
9984 else
9985 {
9986 v1->pInfos[v2].uEAXEnv = 11;
9987 }
9988 }
9989 else
9990 {
9991 v1->pInfos[v2].uEAXEnv = 10;
9992 }
9993 }
9994 else
9995 {
9996 v1->pInfos[v2].uEAXEnv = 9;
9997 }
9998 }
9999 else
10000 {
10001 v1->pInfos[v2].uEAXEnv = 8;
10002 }
10003 }
10004 else
10005 {
10006 v1->pInfos[v2].uEAXEnv = 7;
10007 }
10008 }
10009 else
10010 {
10011 v1->pInfos[v2].uEAXEnv = 6;
10012 }
10013 }
10014 else
10015 {
10016 v1->pInfos[v2].uEAXEnv = 5;
10017 }
10018 }
10019 else
10020 {
10021 v1->pInfos[v2].uEAXEnv = 4;
10022 }
10023 }
10024 else
10025 {
10026 v1->pInfos[v2].uEAXEnv = 3;
10027 }
10028 }
10029 else
10030 {
10031 v1->pInfos[v2].uEAXEnv = 2;
10032 }
10033 }
10034 else
10035 {
10036 v1->pInfos[v2].uEAXEnv = 1;
10037 }
10038 }
10039 else
10040 {
10041 v1->pInfos[v2].uEAXEnv = 0;
10042 }
10043 break;
10044 default:
10045 break;
10046 }
10047 }
10048 else
10049 {
10050 v15 = 1;
10051 }
10052 ++v16;
10053 v4 = v14 + 1;
10054 }
10055 while ( v16 - 1 <= 29 && !v15 );
10056 ++v2;
10057 }
10058 while ( (signed int)v2 < 77 );
10059 v1->uNumMaps = v2;
10060 }
10061 // 453F62: using guessed type char Str[32];
10062
10063
10064
10065
10066
10067
10068 //----- (004547A3) --------------------------------------------------------
10069 unsigned int MapStats::GetMapInfo(const char *Str2)
10070 {
10071 MapStats *v2; // esi@1
10072 unsigned int v3; // edi@1
10073 const char **v4; // ebx@2
10074 unsigned int result; // eax@6
10075
10076 v2 = this;
10077 v3 = 1;
10078 if ( (signed int)this->uNumMaps <= 1 )
10079 {
10080 LABEL_6:
10081 result = 0;
10082 }
10083 else
10084 {
10085 v4 = (const char **)&this->pInfos[1].pFilename;
10086 while ( !*v4 || _strcmpi(*v4, Str2) )
10087 {
10088 ++v3;
10089 v4 += 17;
10090 if ( (signed int)v3 >= (signed int)v2->uNumMaps )
10091 goto LABEL_6;
10092 }
10093 result = v3;
10094 }
10095 return result;
10096 }
10097
10098 //----- (004547E4) --------------------------------------------------------
10099 void FactionTable::Initialize()
10100 {
10101 char *v1; // ebx@1
10102 char *v2; // eax@4
10103 signed int v3; // edi@4
10104 int v4; // ebp@4
10105 char v5; // dl@5
10106 char *v6; // ecx@5
10107 int v7; // esi@9
10108 signed int v8; // [sp+4h] [bp-Ch]@3
10109 signed int v9; // [sp+8h] [bp-8h]@4
10110 FactionTable *v10; // [sp+Ch] [bp-4h]@1
10111
10112 v1 = 0;
10113 v10 = this;
10114 if ( pHostileTXT_Raw )
10115 pAllocator->FreeChunk(pHostileTXT_Raw);
10116 pHostileTXT_Raw = 0;
10117 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0);
10118 strtok(pHostileTXT_Raw, "\r");
10119 v8 = 0;
10120 do
10121 {
10122 v2 = strtok(v1, "\r") + 1;
10123 v3 = 0;
10124 v9 = (signed int)v1;
10125 v4 = (int)((char *)&v10[-7] + v8 - 5);
10126 do
10127 {
10128 v5 = *v2;
10129 v6 = 0;
10130 if ( *v2 != 9 )
10131 {
10132 v1 = 0;
10133 do
10134 {
10135 if ( !v5 )
10136 break;
10137 ++v6;
10138 v5 = v2[(int)v6];
10139 }
10140 while ( v5 != 9 );
10141 }
10142 v7 = (int)&v2[(int)v6];
10143 if ( v2[(int)v6] == (char)v1 )
10144 v9 = 1;
10145 *(char *)v7 = (char)v1;
10146 if ( v6 == v1 )
10147 {
10148 v9 = 1;
10149 }
10150 else
10151 {
10152 if ( v3 >= 1 && v3 <= 90 )
10153 *(char *)v4 = atoi(v2);
10154 }
10155 ++v3;
10156 v4 += 89;
10157 v2 = (char *)(v7 + 1);
10158 }
10159 while ( v3 - 1 <= 90 && (char *)v9 == v1 );
10160 ++v8;
10161 }
10162 while ( v8 < 89 );
10163
10164 if ( pHostileTXT_Raw != v1 )
10165 {
10166 pAllocator->FreeChunk(pHostileTXT_Raw);
10167 pHostileTXT_Raw = v1;
10168 }
10169 }
10170
10171 //----- (004548E2) --------------------------------------------------------
10172 unsigned int __fastcall ParseSpellType(FrameTableTxtLine *a1, int a2)
10173 {
10174 int v2; // edi@1
10175 int v3; // esi@1
10176 unsigned int result; // eax@1
10177 std::string v5; // [sp-18h] [bp-28h]@75
10178 const char *v6; // [sp-8h] [bp-18h]@75
10179 signed int v7; // [sp-4h] [bp-14h]@3
10180 std::string *v8; // [sp+8h] [bp-8h]@75
10181 int a3; // [sp+Fh] [bp-1h]@75
10182
10183 v2 = (int)a1;
10184 v3 = a2;
10185 result = (int)a1->pProperties[0];
10186 if ( result )
10187 {
10188 if ( !_strcmpi((const char *)result, "Dispel") )
10189 {
10190 v7 = 80;
10191 LABEL_71:
10192 result = v7;
10193 LABEL_76:
10194 ++*(int *)v3;
10195 return result;
10196 }
10197 if ( _strcmpi(*(const char **)(v2 + 4), "Day") )
10198 {
10199 if ( _strcmpi(*(const char **)(v2 + 4), "Hour") )
10200 {
10201 if ( _strcmpi(*(const char **)(v2 + 4), "Shield") )
10202 {
10203 if ( !_strcmpi(*(const char **)(v2 + 4), "Spirit") )
10204 {
10205 v7 = 52;
10206 goto LABEL_71;
10207 }
10208 if ( !_strcmpi(*(const char **)(v2 + 4), "Power") )
10209 {
10210 v7 = 77;
10211 goto LABEL_71;
10212 }
10213 if ( !_strcmpi(*(const char **)(v2 + 4), "Meteor") )
10214 {
10215 v7 = 9;
10216 goto LABEL_71;
10217 }
10218 if ( !_strcmpi(*(const char **)(v2 + 4), "Lightning") )
10219 {
10220 v7 = 18;
10221 goto LABEL_71;
10222 }
10223 if ( _strcmpi(*(const char **)(v2 + 4), "Implosion") )
10224 {
10225 if ( !_strcmpi(*(const char **)(v2 + 4), "Stone") )
10226 {
10227 v7 = 38;
10228 goto LABEL_71;
10229 }
10230 if ( _strcmpi(*(const char **)(v2 + 4), "Haste") )
10231 {
10232 if ( _strcmpi(*(const char **)(v2 + 4), "Heroism") )
10233 {
10234 if ( !_strcmpi(*(const char **)(v2 + 4), "Pain") )
10235 {
10236 v7 = 95;
10237 goto LABEL_71;
10238 }
10239 if ( _strcmpi(*(const char **)(v2 + 4), "Sparks") )
10240 {
10241 if ( !_strcmpi(*(const char **)(v2 + 4), "Light") )
10242 {
10243 v7 = 78;
10244 goto LABEL_71;
10245 }
10246 if ( !_strcmpi(*(const char **)(v2 + 4), "Toxic") )
10247 {
10248 v7 = 90;
10249 goto LABEL_71;
10250 }
10251 if ( _strcmpi(*(const char **)(v2 + 4), "ShrapMetal") )
10252 {
10253 if ( _strcmpi(*(const char **)(v2 + 4), "Paralyze") )
10254 {
10255 if ( _strcmpi(*(const char **)(v2 + 4), "Fireball") )
10256 {
10257 if ( _strcmpi(*(const char **)(v2 + 4), "Incinerate") )
10258 {
10259 if ( !_strcmpi(*(const char **)(v2 + 4), "Fire") )
10260 {
10261 v7 = 2;
10262 goto LABEL_71;
10263 }
10264 if ( !_strcmpi(*(const char **)(v2 + 4), "Rock") )
10265 {
10266 v7 = 41;
10267 goto LABEL_71;
10268 }
10269 if ( !_strcmpi(*(const char **)(v2 + 4), "Mass") )
10270 {
10271 v7 = 44;
10272 goto LABEL_71;
10273 }
10274 if ( !_strcmpi(*(const char **)(v2 + 4), "Ice") )
10275 {
10276 v7 = 26;
10277 goto LABEL_71;
10278 }
10279 if ( !_strcmpi(*(const char **)(v2 + 4), "Acid") )
10280 {
10281 v7 = 29;
10282 goto LABEL_71;
10283 }
10284 if ( _strcmpi(*(const char **)(v2 + 4), "Bless") )
10285 {
10286 if ( !_strcmpi(*(const char **)(v2 + 4), "Dragon") )
10287 {
10288 v7 = 97;
10289 goto LABEL_71;
10290 }
10291 if ( _strcmpi(*(const char **)(v2 + 4), "Reanimate") )
10292 {
10293 if ( !_strcmpi(*(const char **)(v2 + 4), "Summon") )
10294 {
10295 v7 = 82;
10296 goto LABEL_71;
10297 }
10298 if ( _strcmpi(*(const char **)(v2 + 4), "Fate") )
10299 {
10300 if ( _strcmpi(*(const char **)(v2 + 4), "Harm") )
10301 {
10302 if ( !_strcmpi(*(const char **)(v2 + 4), "Mind") )
10303 {
10304 v7 = 57;
10305 goto LABEL_71;
10306 }
10307 if ( _strcmpi(*(const char **)(v2 + 4), "Blades") )
10308 {
10309 if ( !_strcmpi(*(const char **)(v2 + 4), "Psychic") )
10310 {
10311 v7 = 65;
10312 goto LABEL_71;
10313 }
10314 if ( _strcmpi(*(const char **)(v2 + 4), "Hammerhands") )
10315 {
10316 sprintf(pTmpBuf, "Unknown monster spell %s", *(int *)(v2 + 4));
10317 MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0);
10318 result = 0;
10319 goto LABEL_76;
10320 }
10321 v7 = 73;
10322 }
10323 else
10324 {
10325 v7 = 39;
10326 }
10327 }
10328 else
10329 {
10330 v7 = 70;
10331 }
10332 }
10333 else
10334 {
10335 v7 = 47;
10336 }
10337 }
10338 else
10339 {
10340 v7 = 89;
10341 }
10342 }
10343 else
10344 {
10345 v7 = 46;
10346 }
10347 }
10348 else
10349 {
10350 v7 = 11;
10351 }
10352 }
10353 else
10354 {
10355 v7 = 6;
10356 }
10357 }
10358 else
10359 {
10360 v7 = 81;
10361 }
10362 }
10363 else
10364 {
10365 v7 = 93;
10366 }
10367 }
10368 else
10369 {
10370 v7 = 15;
10371 }
10372 }
10373 else
10374 {
10375 v7 = 51;
10376 }
10377 }
10378 else
10379 {
10380 v7 = 5;
10381 }
10382 }
10383 else
10384 {
10385 v7 = 20;
10386 }
10387 }
10388 else
10389 {
10390 v7 = 17;
10391 }
10392 return v7;
10393 }
10394 v7 = 86;
10395 }
10396 else
10397 {
10398 v7 = 85;
10399 }
10400 *(int *)v3 += 2;
10401 result = v7;
10402 }
10403 return result;
10404 }
10405
10406 //----- (00454CB4) --------------------------------------------------------
10407 int __thiscall ParseAttackType(unsigned __int8 *a1)
10408 {
10409 unsigned __int8 *v1; // esi@1
10410 int result; // eax@4
10411 int v3; // eax@15
10412 int v4; // eax@18
10413
10414 v1 = a1;
10415 if ( !a1 )
10416 return 4;
10417 if ( tolower(*a1) == 'f' )
10418 return 0;
10419 if ( tolower(*v1) == 'a' )
10420 return 1;
10421 if ( tolower(*v1) == 'w' )
10422 return 2;
10423 if ( tolower(*v1) == 'e' )
10424 {
10425 tolower(v1[1]);
10426 return 3;
10427 }
10428 if ( tolower(*v1) == 's' )
10429 return 6;
10430 if ( tolower(*v1) == 'm' )
10431 {
10432 v3 = -(tolower(v1[1]) != 'i');
10433 LOBYTE(v3) = v3 & 0xFE;
10434 result = v3 + 7;
10435 }
10436 else
10437 {
10438 if ( tolower(*v1) == 'l' )
10439 return 9;
10440 v4 = -(tolower(*v1) != 'd');
10441 LOBYTE(v4) = v4 & 0xFA;
10442 result = v4 + 10;
10443 }
10444 return result;
10445 }
10446
10447 //----- (00454D7D) --------------------------------------------------------
10448 char __fastcall ParseDamage(const char *Str, int a2, int a3, int a4)
10449 {
10450 int v4; // esi@1
10451 const char *v5; // edi@1
10452 signed int v6; // ebx@1
10453 int *v7; // esi@2
10454 int v8; // eax@3
10455 size_t v10; // [sp+Ch] [bp-Ch]@1
10456 int v11; // [sp+10h] [bp-8h]@1
10457 signed int v12; // [sp+14h] [bp-4h]@1
10458
10459 v4 = a2;
10460 v5 = Str;
10461 *(char *)a2 = 0;
10462 *(char *)a3 = 1;
10463 v11 = a2;
10464 *(char *)a4 = 0;
10465 v6 = 0;
10466 v10 = strlen(Str);
10467 v12 = 0;
10468 if ( (signed int)v10 <= 0 )
10469 {
10470 LABEL_9:
10471 LOBYTE(v8) = *v5;
10472 if ( (unsigned __int8)*v5 >= 0x30u && (unsigned __int8)v8 <= 0x39u )
10473 {
10474 *(char *)v4 = atoi(v5);
10475 LOBYTE(v8) = a3;
10476 *(char *)a3 = 1;
10477 }
10478 return v8;
10479 }
10480 do
10481 {
10482 v7 = (int *)&v5[v6];
10483 if ( tolower((unsigned __int8)v5[v6]) == 100 )
10484 {
10485 *(char *)v7 = 0;
10486 *(char *)v11 = atoi(v5);
10487 LOBYTE(v8) = atoi(&v5[v6 + 1]);
10488 v12 = 1;
10489 *(char *)a3 = v8;
10490 *(char *)v7 = 100;
10491 }
10492 else
10493 {
10494 v8 = tolower(*(char *)v7);
10495 if ( v8 == 43 )
10496 {
10497 LOBYTE(v8) = atoi(&v5[v6 + 1]);
10498 *(char *)a4 = v8;
10499 }
10500 }
10501 ++v6;
10502 }
10503 while ( v6 < (signed int)v10 );
10504 if ( !v12 )
10505 {
10506 v4 = v11;
10507 goto LABEL_9;
10508 }
10509 return v8;
10510 }
10511
10512 //----- (00454E3A) --------------------------------------------------------
10513 int __fastcall ParseMissleAttackType(const char *Str1)
10514 {
10515 const char *v1; // esi@1
10516 int v2; // edi@1
10517 int v4; // [sp-4h] [bp-Ch]@4
10518
10519 v1 = Str1;
10520 v2 = 0;
10521 if ( _strcmpi(Str1, "ARROW") )
10522 {
10523 if ( _strcmpi(v1, "ARROWF") )
10524 {
10525 if ( _strcmpi(v1, "FIRE") )
10526 {
10527 if ( _strcmpi(v1, "AIR") )
10528 {
10529 if ( _strcmpi(v1, "WATER") )
10530 {
10531 if ( _strcmpi(v1, "EARTH") )
10532 {
10533 if ( _strcmpi(v1, "SPIRIT") )
10534 {
10535 if ( _strcmpi(v1, "MIND") )
10536 {
10537 if ( _strcmpi(v1, "BODY") )
10538 {
10539 if ( _strcmpi(v1, "LIGHT") )
10540 {
10541 if ( _strcmpi(v1, "DARK") )
10542 {
10543 if ( _strcmpi(v1, "ENER") )
10544 return v2;
10545 v4 = 13;
10546 }
10547 else
10548 {
10549 v4 = 11;
10550 }
10551 }
10552 else
10553 {
10554 v4 = 10;
10555 }
10556 }
10557 else
10558 {
10559 v4 = 9;
10560 }
10561 }
10562 else
10563 {
10564 v4 = 8;
10565 }
10566 }
10567 else
10568 {
10569 v4 = 7;
10570 }
10571 }
10572 else
10573 {
10574 v4 = 6;
10575 }
10576 }
10577 else
10578 {
10579 v4 = 5;
10580 }
10581 }
10582 else
10583 {
10584 v4 = 4;
10585 }
10586 }
10587 else
10588 {
10589 v4 = 3;
10590 }
10591 }
10592 else
10593 {
10594 v4 = 2;
10595 }
10596 return v4;
10597 }
10598 return 1;
10599 }
10600
10601
10602
10603
10604
10605
10606 //----- (00458244) --------------------------------------------------------
10607 unsigned int __fastcall SkillToMastery(unsigned __int16 a1)
10608 {
10609 unsigned int result; // eax@1
10610
10611 result = 1; // Normal
10612 if ( HIBYTE(a1) & 1 )
10613 {
10614 result = 4; // Grandmaster
10615 }
10616 else
10617 {
10618 if ( (a1 & 0x80u) == 0 )
10619 {
10620 if ( a1 & 0x40 )
10621 result = 2; // Expert
10622 }
10623 else
10624 {
10625 result = 3; // Master
10626 }
10627 }
10628 return result;
10629 }
10630
10631
10632 //----- (0045828B) --------------------------------------------------------
10633 unsigned int __fastcall GetSpellColor(signed int a1)
10634 {
10635 unsigned __int16 v1; // dx@3
10636 unsigned __int16 v2; // cx@6
10637 unsigned __int16 v4; // [sp-4h] [bp-4h]@3
10638
10639 if ( a1 < 1 )
10640 {
10641 if ( a1 < 12 )
10642 {
10643 if ( a1 < 23 )
10644 {
10645 if ( a1 < 34 )
10646 {
10647 if ( a1 < 45 )
10648 {
10649 if ( a1 < 56 )
10650 {
10651 if ( a1 < 67 )
10652 {
10653 if ( a1 < 78 )
10654 {
10655 if ( a1 < 89 )
10656 goto LABEL_31;
10657 goto LABEL_28;
10658 }
10659 LABEL_25:
10660 if ( a1 < 89 )
10661 {
10662 v4 = 155;
10663 v2 = 255;
10664 goto LABEL_30;
10665 }
10666 LABEL_28:
10667 if ( a1 < 100 )
10668 {
10669 v4 = 240;
10670 v2 = 192;
10671 goto LABEL_30;
10672 }
10673 LABEL_31:
10674 v4 = 0;
10675 v1 = 0;
10676 goto LABEL_32;
10677 }
10678 LABEL_21:
10679 if ( a1 < 78 )
10680 {
10681 v4 = 0;
10682 v1 = 128;
10683 goto LABEL_23;
10684 }
10685 goto LABEL_25;
10686 }
10687 LABEL_18:
10688 if ( a1 < 67 )
10689 {
10690 v4 = 255;
10691 v1 = 15;
10692 v2 = 235;
10693 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
10694 }
10695 goto LABEL_21;
10696 }
10697 LABEL_15:
10698 if ( a1 < 56 )
10699 {
10700 v2 = 225;
10701 goto LABEL_13;
10702 }
10703 goto LABEL_18;
10704 }
10705 LABEL_11:
10706 if ( a1 < 45 )
10707 {
10708 v2 = 128;
10709 LABEL_13:
10710 v4 = v2;
10711 LABEL_30:
10712 v1 = v2;
10713 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
10714 }
10715 goto LABEL_15;
10716 }
10717 LABEL_8:
10718 if ( a1 < 34 )
10719 {
10720 v4 = 255;
10721 v1 = 128;
10722 LABEL_32:
10723 v2 = 0;
10724 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
10725 }
10726 goto LABEL_11;
10727 }
10728 }
10729 else
10730 {
10731 if ( a1 < 12 )
10732 {
10733 v4 = 0;
10734 v1 = 85;
10735 LABEL_23:
10736 v2 = 255;
10737 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
10738 }
10739 }
10740 if ( a1 >= 23 )
10741 goto LABEL_8;
10742 v4 = 255;
10743 v1 = 212;
10744 v2 = 150;
10745 return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
10746 }
10747
10748
10749 //----- (004583B0) --------------------------------------------------------
10750 LevelDecoration::LevelDecoration()
10751 {
10752 this->field_1A = 0;
10753 this->field_18 = 0;
10754 this->vPosition.z = 0;
10755 this->vPosition.y = 0;
10756 this->vPosition.x = 0;
10757 this->uDecorationDescID = 0;
10758 this->field_2 = 0;
10759 this->field_16_event_id = 0;
10760 this->uCog = 0;
10761 }
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771 //----- (00458600) --------------------------------------------------------
10772 void DecorationList::ToFile()
10773 {
10774 DecorationList *v1; // esi@1
10775 FILE *v2; // eax@1
10776 FILE *v3; // edi@1
10777
10778 v1 = this;
10779 v2 = fopen("data\\ddeclist.bin", "wb");
10780 v3 = v2;
10781 if ( !v2 )
10782 Abortf("Unable to save ddeclist.bin!");
10783 fwrite(v1, 4u, 1u, v2);
10784 fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3);
10785 fclose(v3);
10786 }
10787
10788 //----- (0045864C) --------------------------------------------------------
10789 void DecorationList::FromFile(void *pSerialized)
10790 {
10791 uNumDecorations = *(int *)pSerialized;
10792 pDecorations = (DecorationDesc *)pAllocator->AllocNamedChunk(pDecorations,
10793 84 * uNumDecorations, "Dec Descrip");
10794 memcpy(pDecorations, (char *)pSerialized + 4, 84 * uNumDecorations);
10795 }
10796
10797 //----- (00458693) --------------------------------------------------------
10798 void DecorationList::InitializeDecorationSprite(unsigned int uDecID)
10799 {
10800 pSpriteFrameTable->InitializeSprite(this->pDecorations[uDecID].uSpriteID);
10801 }
10802
10803 //----- (004586B0) --------------------------------------------------------
10804 bool DecorationList::FromFileTxt(const char *Args)
10805 {
10806 DecorationList *v2; // ebx@1
10807 FILE *v3; // eax@1
10808 unsigned int v4; // esi@3
10809 void *v5; // eax@10
10810 FILE *v6; // ST18_4@12
10811 char *i; // eax@12
10812 unsigned __int16 v8; // ax@16
10813 const char *v9; // ST20_4@16
10814 const char *v10; // ST18_4@16
10815 __int16 v11; // ax@16
10816 const char *v12; // ST14_4@16
10817 unsigned __int16 v13; // ax@16
10818 const char *v14; // ST10_4@16
10819 __int16 v15; // ax@16
10820 const char *v16; // ST0C_4@16
10821 unsigned __int8 v17; // al@16
10822 const char *v18; // ST08_4@16
10823 unsigned __int8 v19; // al@16
10824 const char *v20; // ST04_4@16
10825 unsigned __int8 v21; // al@16
10826 const char *v22; // ST00_4@16
10827 unsigned __int8 v23; // zf@16
10828 char v24; // sf@16
10829 unsigned __int8 v25; // of@16
10830 int j; // edi@17
10831 const char *v27; // esi@18
10832 int v28; // eax@19
10833 int v29; // eax@21
10834 int v30; // eax@23
10835 int v31; // eax@25
10836 int v32; // eax@27
10837 int v33; // eax@29
10838 int v34; // eax@31
10839 int v35; // eax@33
10840 FrameTableTxtLine v37; // [sp+Ch] [bp-460h]@17
10841 FrameTableTxtLine v38; // [sp+88h] [bp-3E4h]@13
10842 char Dest; // [sp+104h] [bp-368h]@17
10843 char Buf; // [sp+17Ch] [bp-2F0h]@3
10844 FrameTableTxtLine v41; // [sp+370h] [bp-FCh]@4
10845 FrameTableTxtLine v42; // [sp+3ECh] [bp-80h]@4
10846 FILE *File; // [sp+468h] [bp-4h]@1
10847 unsigned int Argsa; // [sp+474h] [bp+8h]@3
10848
10849 v2 = this;
10850 v3 = fopen(Args, "r");
10851 File = v3;
10852 if ( !v3 )
10853 Abortf("DecorationDescriptionList::load - Unable to open file: %s.");
10854 v4 = 0;
10855 Argsa = 0;
10856 if ( fgets(&Buf, 490, v3) )
10857 {
10858 do
10859 {
10860 *strchr(&Buf, 10) = 0;
10861 memcpy(&v42, frame_table_txt_parser(&Buf, &v41), sizeof(v42));
10862 if ( v42.field_0 && *v42.pProperties[0] != 47 && v42.field_0 >= 3 )
10863 ++Argsa;
10864 }
10865 while ( fgets(&Buf, 490, File) );
10866 v4 = Argsa;
10867 }
10868 v2->uNumDecorations = v4;
10869 v5 = pAllocator->AllocNamedChunk(v2->pDecorations, 84 * v4, "Dec Descrip");
10870 v2->pDecorations = (DecorationDesc *)v5;
10871 if ( !v5 )
10872 Abortf("DecorationDescriptionList::load - Out of Memory!");
10873 v6 = File;
10874 v2->uNumDecorations = 0;
10875 fseek(v6, 0, 0);
10876 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
10877 {
10878 *strchr(&Buf, 10) = 0;
10879 memcpy(&v42, frame_table_txt_parser(&Buf, &v38), sizeof(v42));
10880 if ( v42.field_0 && *v42.pProperties[0] != 47 && v42.field_0 >= 3 )
10881 {
10882 strcpy(v2->pDecorations[v2->uNumDecorations].pName, v42.pProperties[1]);
10883 v8 = pSpriteFrameTable->FastFindSprite(v2->pDecorations[v2->uNumDecorations].pName);
10884 v9 = v42.pProperties[2];
10885 v2->pDecorations[v2->uNumDecorations].uSpriteID = v8;
10886 strcpy(v2->pDecorations[v2->uNumDecorations].field_20, v9);
10887 v10 = v42.pProperties[3];
10888 v2->pDecorations[v2->uNumDecorations].uType = 0;
10889 v11 = atoi(v10);
10890 v12 = v42.pProperties[4];
10891 v2->pDecorations[v2->uNumDecorations].uRadius = v11;
10892 v13 = atoi(v12);
10893 v14 = v42.pProperties[5];
10894 v2->pDecorations[v2->uNumDecorations].uDecorationHeight = v13;
10895 v15 = atoi(v14);
10896 v16 = v42.pProperties[6];
10897 v2->pDecorations[v2->uNumDecorations].uLightRadius = v15;
10898 v17 = atoi(v16);
10899 v18 = v42.pProperties[7];
10900 v2->pDecorations[v2->uNumDecorations].uColoredLightRed = v17;
10901 v19 = atoi(v18);
10902 v20 = v42.pProperties[8];
10903 v2->pDecorations[v2->uNumDecorations].uColoredLightGreen = v19;
10904 v21 = atoi(v20);
10905 v22 = v42.pProperties[9];
10906 v2->pDecorations[v2->uNumDecorations].uColoredLightBlue = v21;
10907 v2->pDecorations[v2->uNumDecorations].uSoundID = atoi(v22);
10908 v25 = __OFSUB__(v42.field_0, 10);
10909 v23 = v42.field_0 == 10;
10910 v24 = v42.field_0 - 10 < 0;
10911 v2->pDecorations[v2->uNumDecorations].uFlags = 0;
10912 if ( !((unsigned __int8)(v24 ^ v25) | v23) )
10913 {
10914 strcpy(&Dest, v42.pProperties[10]);
10915 memcpy(&v41, frame_table_txt_parser(&Dest, &v37), sizeof(v41));
10916 for ( j = 0; j < v41.field_0; ++j )
10917 {
10918 v27 = v41.pProperties[j];
10919 if ( _strcmpi(v41.pProperties[j], "NBM") )
10920 {
10921 if ( _strcmpi(v27, "Invisible") )
10922 {
10923 if ( _strcmpi(v27, "FS") )
10924 {
10925 if ( _strcmpi(v27, "FM") )
10926 {
10927 if ( _strcmpi(v27, "FF") )
10928 {
10929 if ( _strcmpi(v27, "Marker") )
10930 {
10931 if ( _strcmpi(v27, "LoopSlow") )
10932 {
10933 if ( _strcmpi(v27, "EmitFire") )
10934 {
10935 if ( _strcmpi(v27, "Dawn") )
10936 {
10937 if ( !_strcmpi(v27, "Dusk") )
10938 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u;
10939 }
10940 else
10941 {
10942 HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 1u;
10943 }
10944 }
10945 else
10946 {
10947 v35 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10948 *(char *)v35 |= 0x80u;
10949 }
10950 }
10951 else
10952 {
10953 v34 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10954 *(char *)v34 |= 0x40u;
10955 }
10956 }
10957 else
10958 {
10959 v33 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10960 *(char *)v33 |= 0x20u;
10961 }
10962 }
10963 else
10964 {
10965 v32 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10966 *(char *)v32 |= 0x10u;
10967 }
10968 }
10969 else
10970 {
10971 v31 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10972 *(char *)v31 |= 8u;
10973 }
10974 }
10975 else
10976 {
10977 v30 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10978 *(char *)v30 |= 4u;
10979 }
10980 }
10981 else
10982 {
10983 v29 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10984 *(char *)v29 |= 2u;
10985 }
10986 }
10987 else
10988 {
10989 v28 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags;
10990 *(char *)v28 |= 1u;
10991 }
10992 }
10993 }
10994 ++v2->uNumDecorations;
10995 }
10996 }
10997 fclose(File);
10998 return 1;
10999 }
11000
11001
11002
11003
11004
11005 //----- (00459064) --------------------------------------------------------
11006 void ObjectList::InitializeSprites()
11007 {
11008 for (uint i = 0; i < uNumObjects; ++i)
11009 pSpriteFrameTable->InitializeSprite(pObjects[i].uSpriteID);
11010 }
11011
11012 //----- (00459090) --------------------------------------------------------
11013 void ObjectList::ToFile()
11014 {
11015 ObjectList *v1; // esi@1
11016 FILE *v2; // eax@1
11017 FILE *v3; // edi@1
11018
11019 v1 = this;
11020 v2 = fopen("data\\dobjlist.bin", "wb");
11021 v3 = v2;
11022 if ( !v2 )
11023 Abortf("Unable to save dobjlist.bin!");
11024 fwrite(v1, 4u, 1u, v2);
11025 fwrite(v1->pObjects, 0x38u, v1->uNumObjects, v3);
11026 fclose(v3);
11027 }
11028
11029 //----- (004590DC) --------------------------------------------------------
11030 void ObjectList::FromFile(void *pSerialized)
11031 {
11032 uNumObjects = *(int *)pSerialized;
11033 pObjects = (ObjectDesc *)pAllocator->AllocNamedChunk(pObjects, 56 * uNumObjects, "Obj Descrip");
11034 memcpy(pObjects, (char *)pSerialized + 4, 56 * uNumObjects);
11035 }
11036
11037 //----- (00459123) --------------------------------------------------------
11038 bool ObjectList::FromFileTxt(const char *Args)
11039 {
11040 ObjectList *v2; // ebx@1
11041 __int32 v3; // edi@1
11042 FILE *v4; // eax@1
11043 unsigned int v5; // esi@3
11044 void *v6; // eax@9
11045 FILE *v7; // ST0C_4@11
11046 char *i; // eax@11
11047 unsigned __int16 v9; // ax@14
11048 const char *v10; // ST20_4@14
11049 __int16 v11; // ax@14
11050 const char *v12; // ST1C_4@14
11051 __int16 v13; // ax@14
11052 const char *v14; // ST18_4@14
11053 __int16 v15; // ax@14
11054 const char *v16; // ST14_4@14
11055 __int16 v17; // ax@14
11056 const char *v18; // ST10_4@14
11057 __int16 v19; // ax@14
11058 const char *v20; // ST0C_4@14
11059 int v21; // esi@16
11060 const char *v22; // edi@16
11061 int v23; // eax@17
11062 int v24; // eax@19
11063 int v25; // eax@21
11064 int v26; // eax@21
11065 int v27; // eax@21
11066 int v28; // eax@23
11067 int v29; // eax@25
11068 int v30; // eax@27
11069 int v31; // eax@29
11070 const char *v32; // edi@30
11071 const char *v33; // ST20_4@35
11072 int v34; // eax@35
11073 char v35; // al@35
11074 const char *v36; // ST1C_4@35
11075 char v37; // al@35
11076 const char *v38; // ST18_4@35
11077 FrameTableTxtLine v40; // [sp+8h] [bp-460h]@14
11078 FrameTableTxtLine v41; // [sp+84h] [bp-3E4h]@12
11079 char Dest; // [sp+100h] [bp-368h]@14
11080 char Buf; // [sp+178h] [bp-2F0h]@3
11081 FrameTableTxtLine v44; // [sp+36Ch] [bp-FCh]@4
11082 FrameTableTxtLine v45; // [sp+3E8h] [bp-80h]@4
11083 FILE *File; // [sp+464h] [bp-4h]@1
11084 unsigned int Argsa; // [sp+470h] [bp+8h]@3
11085 int Argsb; // [sp+470h] [bp+8h]@15
11086
11087 v2 = this;
11088 pAllocator->FreeChunk(this->pObjects);
11089 v3 = 0;
11090 v2->pObjects = 0;
11091 v2->uNumObjects = 0;
11092 v4 = fopen(Args, "r");
11093 File = v4;
11094 if ( !v4 )
11095 Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
11096 v5 = 0;
11097 Argsa = 0;
11098 if ( fgets(&Buf, 490, v4) )
11099 {
11100 do
11101 {
11102 *strchr(&Buf, 10) = 0;
11103 memcpy(&v45, frame_table_txt_parser(&Buf, &v44), sizeof(v45));
11104 if ( v45.field_0 && *v45.pProperties[0] != '/' )
11105 ++Argsa;
11106 }
11107 while ( fgets(&Buf, 490, File) );
11108 v5 = Argsa;
11109 v3 = 0;
11110 }
11111 v2->uNumObjects = v5;
11112 v6 = pAllocator->AllocNamedChunk(v2->pObjects, 56 * v5, "Obj Descrip");
11113 v2->pObjects = (ObjectDesc *)v6;
11114 if ( v6 == (void *)v3 )
11115 Abortf("ObjectDescriptionList::load - Out of Memory!");
11116 memset(v6, v3, 56 * v2->uNumObjects);
11117 v7 = File;
11118 v2->uNumObjects = v3;
11119 fseek(v7, v3, v3);
11120 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
11121 {
11122 *strchr(&Buf, 10) = 0;
11123 memcpy(&v45, frame_table_txt_parser(&Buf, &v41), sizeof(v45));
11124 if ( v45.field_0 && *v45.pProperties[0] != 47 )
11125 {
11126 strcpy(v2->pObjects[v2->uNumObjects].field_0, v45.pProperties[0]);
11127 v9 = pSpriteFrameTable->FastFindSprite((char *)v45.pProperties[1]);
11128 v10 = v45.pProperties[2];
11129 v2->pObjects[v2->uNumObjects].uSpriteID = v9;
11130 v11 = atoi(v10);
11131 v12 = v45.pProperties[3];
11132 v2->pObjects[v2->uNumObjects].uObjectID = v11;
11133 v13 = atoi(v12);
11134 v14 = v45.pProperties[4];
11135 v2->pObjects[v2->uNumObjects].uRadius = v13;
11136 v15 = atoi(v14);
11137 v16 = v45.pProperties[5];
11138 v2->pObjects[v2->uNumObjects].uHeight = v15;
11139 v17 = atoi(v16);
11140 v18 = v45.pProperties[6];
11141 v2->pObjects[v2->uNumObjects].uLifetime = v17;
11142 v19 = atoi(v18);
11143 v20 = v45.pProperties[7];
11144 v2->pObjects[v2->uNumObjects].uSpeed = v19;
11145 strcpy(&Dest, v20);
11146 memcpy(&v44, frame_table_txt_parser(&Dest, &v40), sizeof(v44));
11147 if ( v45.field_0 > 7 )
11148 {
11149 for ( Argsb = 0; Argsb < v44.field_0; ++Argsb )
11150 {
11151 v21 = Argsb;
11152 v22 = v44.pProperties[Argsb];
11153 if ( !_strcmpi(v44.pProperties[Argsb], "NoDraw") )
11154 {
11155 v23 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11156 *(char *)v23 |= 1u;
11157 }
11158 if ( !_strcmpi(v22, "Lifetime") )
11159 {
11160 v24 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11161 *(char *)v24 |= 4u;
11162 }
11163 if ( !_strcmpi(v22, "FTLifetime") )
11164 {
11165 v25 = (int)&v2->pObjects[v2->uNumObjects];
11166 *(short *)(v25 + 42) = 8 * pSpriteFrameTable->pSpriteSFrames[*(short *)(v25 + 40)].uAnimLength;
11167 v26 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11168 *(char *)v26 |= 8u;
11169 v27 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11170 *(char *)v27 |= 4u;
11171 }
11172 if ( !_strcmpi(v22, "NoPickup") )
11173 {
11174 v28 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11175 *(char *)v28 |= 0x10u;
11176 }
11177 if ( !_strcmpi(v22, "NoGravity") )
11178 {
11179 v29 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11180 *(char *)v29 |= 0x20u;
11181 }
11182 if ( !_strcmpi(v22, "FlagOnIntercept") )
11183 {
11184 v30 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11185 *(char *)v30 |= 0x40u;
11186 }
11187 if ( !_strcmpi(v22, "Bounce") )
11188 {
11189 v31 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11190 *(char *)v31 |= 0x80u;
11191 }
11192 v32 = v45.pProperties[v21];
11193 if ( !_strcmpi(v45.pProperties[v21], "Fire") )
11194 HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 2u;
11195 if ( !_strcmpi(v32, "Lines") )
11196 HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 4u;
11197 if ( !_strcmpi(v44.pProperties[v21], "bits") )
11198 {
11199 v33 = v44.pProperties[v21 + 1];
11200 v34 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
11201 *(char *)(v34 + 1) |= 1u;
11202 v35 = atoi(v33);
11203 v36 = v44.pProperties[v21 + 2];
11204 v2->pObjects[v2->uNumObjects].uParticleTrailColorR = v35;
11205 v37 = atoi(v36);
11206 v38 = v44.pProperties[v21 + 3];
11207 v2->pObjects[v2->uNumObjects].uParticleTrailColorG = v37;
11208 v2->pObjects[v2->uNumObjects].uParticleTrailColorB = atoi(v38);
11209 }
11210 }
11211 }
11212 ++v2->uNumObjects;
11213 }
11214 }
11215 fclose(File);
11216 return 1;
11217 }
11218
11219
11220 //----- (0045E03A) --------------------------------------------------------
11221 unsigned __int16 *__fastcall MakeScreenshot(signed int width, signed int height)
11222 {
11223 signed int v2; // edi@1
11224 unsigned __int16 *v3; // ebx@1
11225 int v4; // edx@7
11226 unsigned __int8 v5; // cf@9
11227 unsigned int v6; // ecx@9
11228 unsigned __int16 *v7; // edi@9
11229 int j; // ecx@9
11230 unsigned __int16 *v9; // edi@15
11231 int v10; // ecx@15
11232 LONG v11; // esi@15
11233 signed __int64 v12; // qax@18
11234 unsigned int v13; // ST10_4@21
11235 HRESULT v14; // eax@21
11236 int v15; // edi@29
11237 signed __int64 v16; // qax@30
11238 signed int v17; // edx@34
11239 unsigned __int16 *v18; // edi@36
11240 int k; // ecx@36
11241 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
11242 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
11243 float v23; // [sp+84h] [bp-20h]@1
11244 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21
11245 float v25; // [sp+8Ch] [bp-18h]@1
11246 unsigned int v26; // [sp+90h] [bp-14h]@17
11247 int v27; // [sp+94h] [bp-10h]@1
11248 int v28; // [sp+98h] [bp-Ch]@16
11249 int i; // [sp+9Ch] [bp-8h]@15
11250 int v30; // [sp+A0h] [bp-4h]@1
11251
11252 v30 = width;
11253 v2 = height;
11254 v27 = height;
11255 v23 = 452.0 / (double)width;
11256 v25 = 336.0 / (double)height;
11257 pPixels = (unsigned __int16 *)malloc(2 * height * width);
11258 v3 = pPixels;
11259 if ( pRenderer->pRenderD3D )
11260 {
11261 pRenderer->BeginSceneD3D();
11262 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
11263 {
11264 pIndoor->Draw();
11265 }
11266 else
11267 {
11268 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
11269 pOutdoor->Draw();
11270 }
11271 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
11272 memset(&Dst, 0, 0x7Cu);
11273 Dst.dwSize = 124;
11274 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) )
11275 {
11276 v9 = (unsigned __int16 *)Dst.lpSurface;
11277 v10 = 0;
11278 v11 = Dst.lPitch >> 1;
11279 for ( i = 0; i < v27; ++i )
11280 {
11281 v28 = v10;
11282 if ( v30 > v10 )
11283 {
11284 v26 = v11 * (unsigned __int64)(signed __int64)((double)i * v25 + 8.0);
11285 do
11286 {
11287 v12 = (signed __int64)((double)v28++ * v23 + 8.0);
11288 *v3 = v9[v26 + (int)v12];
11289 ++v3;
11290 }
11291 while ( v28 < v30 );
11292 v10 = 0;
11293 }
11294 }
11295 v13 = v10;
11296 ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
11297 }
11298 else
11299 {
11300 v4 = v27;
11301 if ( v27 > 0 )
11302 {
11303 do
11304 {
11305 if ( v30 > 0 )
11306 {
11307 v5 = v30 & 1;
11308 v6 = (unsigned int)v30 >> 1;
11309 memset(v3, 0, 4 * ((unsigned int)v30 >> 1));
11310 v7 = &v3[2 * v6];
11311 for ( j = v5; j; --j )
11312 {
11313 *v7 = 0;
11314 ++v7;
11315 }
11316 v3 += v30;
11317 }
11318 --v4;
11319 }
11320 while ( v4 );
11321 }
11322 }
11323 }
11324 else
11325 {
11326 pRenderer->BeginScene();
11327 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
11328 {
11329 pIndoor->Draw();
11330 }
11331 else
11332 {
11333 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
11334 pOutdoor->Draw();
11335 }
11336 _this = pRenderer->pTargetSurface;
11337 v26 = pRenderer->uTargetSurfacePitch;
11338 if ( pRenderer->pTargetSurface )
11339 {
11340 i = 0;
11341 if ( v2 > 0 )
11342 {
11343 do
11344 {
11345 v28 = 0;
11346 if ( v30 > 0 )
11347 {
11348 v15 = v26 * (unsigned __int64)(signed __int64)((double)i * v25 + 8.0);
11349 do
11350 {
11351 v16 = (signed __int64)((double)v28++ * v23 + 8.0);
11352 *v3 = _this[v15 + (int)v16];
11353 ++v3;
11354 }
11355 while ( v28 < v30 );
11356 }
11357 ++i;
11358 }
11359 while ( i < v27 );
11360 }
11361 }
11362 else
11363 {
11364 if ( v2 > 0 )
11365 {
11366 v17 = v2;
11367 do
11368 {
11369 if ( v30 > 0 )
11370 {
11371 memset(v3, 0, 4 * ((unsigned int)v30 >> 1));
11372 v18 = &v3[2 * ((unsigned int)v30 >> 1)];
11373 for ( k = v30 & 1; k; --k )
11374 {
11375 *v18 = 0;
11376 ++v18;
11377 }
11378 v3 += v30;
11379 }
11380 --v17;
11381 }
11382 while ( v17 );
11383 }
11384 }
11385 pRenderer->EndScene();
11386 }
11387 return pPixels;
11388 }
11389
11390 //----- (0045E26C) --------------------------------------------------------
11391 void __thiscall SaveScreenshot(const char *pFilename)
11392 {
11393 const char *v1; // edi@1
11394 unsigned __int16 *v2; // esi@1
11395
11396 v1 = pFilename;
11397 v2 = MakeScreenshot(92, 68);
11398 pRenderer->SavePCXImage(v1, (char *)v2, 92, 68);
11399 free(v2);
11400 }
11401
11402
11403
11404
11405 //----- (004601B7) --------------------------------------------------------
11406 void GameUI_MainMenu_DoDrawLoad(int a1)
11407 {
11408 unsigned __int16 v1; // bx@1
11409 unsigned int v2; // edi@4
11410 unsigned int v3; // eax@4
11411 unsigned int v4; // eax@8
11412 int v5; // edi@8
11413 unsigned int v6; // eax@8
11414 unsigned int pMapID; // eax@10
11415 signed __int64 v8; // qax@10
11416 unsigned int v9; // ebx@10
11417 unsigned __int64 v10; // qax@10
11418 __int64 v11; // qax@10
11419 char v12; // di@10
11420 unsigned __int64 v13; // qtt@10
11421 unsigned int v14; // ecx@10
11422 __int64 pOurHour; // qax@10
11423 int v16; // edi@10
11424 signed int pHour; // ebx@22
11425 //const char *v18; // ST14_4@32
11426 int v19; // eax@32
11427 const char *v20; // ST18_4@32
11428 int v21; // eax@32
11429 //const char *v22; // ST14_4@32
11430 int v23; // eax@32
11431 const char *pSlotName; // edi@36
11432 int v25; // eax@43
11433 GUIWindow pWindow; // [sp+Ch] [bp-78h]@8
11434 /*unsigned int Dst; // [sp+Ch] [bp-78h]@8
11435 unsigned int v27; // [sp+10h] [bp-74h]@8
11436 int v28; // [sp+14h] [bp-70h]@8
11437 int v29; // [sp+18h] [bp-6Ch]@8
11438 unsigned int v30; // [sp+1Ch] [bp-68h]@8
11439 unsigned int v31; // [sp+20h] [bp-64h]@8*/
11440 int pMinutes; // [sp+60h] [bp-24h]@10
11441 int pMonthNum; // [sp+68h] [bp-1Ch]@10
11442 unsigned int pSaveFiles; // [sp+70h] [bp-14h]@10
11443 __int64 pAMPM2; // [sp+74h] [bp-10h]@10
11444 int pYear; // [sp+7Ch] [bp-8h]@10
11445 int a4; // [sp+80h] [bp-4h]@1
11446 int pFilesID;
11447
11448 v1 = 255;
11449 a4 = a1;
11450 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
11451 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
11452 pRenderer->BeginScene();
11453 if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LOAD )
11454 {
11455 pRenderer->DrawTextureIndexed(8, 8, uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0);
11456 if ( a4 )
11457 {
11458 v2 = uTextureID_save_up;
11459 v3 = uTextureID_LS_saveU;
11460 }
11461 else
11462 {
11463 v2 = uTextureID_load_up;
11464 v3 = uTextureID_LS_loadU;
11465 }
11466 pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
11467 pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
11468 pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
11469 v1 = 255;
11470 }
11471 if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
11472 {
11473 memset(&pWindow, 0, 0x54);
11474 pWindow.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240;
11475 v4 = pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->uFontHeight;
11476 pWindow.uFrameWidth = 220;
11477 v4 += 157;
11478 pWindow.uFrameY = v4;
11479 v5 = pFontSmallnum->uFontHeight;
11480 pWindow.uFrameZ = pWindow.uFrameX + 219;
11481 pWindow.uFrameHeight = v5;
11482 pWindow.uFrameW = v5 + v4 - 1;
11483 v6 = uLoadGameUI_SelectedSlot;
11484 if (pSavegameThumbnails[uLoadGameUI_SelectedSlot].pPixels)
11485 {
11486 pRenderer->DrawTextureRGB(pGUIWindow_CurrentMenu->uFrameX + 276, pGUIWindow_CurrentMenu->uFrameY + 171, pSavegameThumbnails + uLoadGameUI_SelectedSlot);
11487 v6 = uLoadGameUI_SelectedSlot;
11488 }
11489 pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName);
11490 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3);
11491 v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60;
11492 pMinutes = (int)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32;
11493 v9 = v8;
11494 v8 /= 60i64;
11495 pAMPM2 = v8;
11496 v10 = (unsigned int)v8 / 24;
11497 pSaveFiles = v10;
11498 v11 = (unsigned int)(v10 / 7);
11499 v12 = v11;
11500 LODWORD(v13) = (unsigned int)v11 >> 2;
11501 HIDWORD(v13) = HIDWORD(v11);
11502 pMonthNum = v13 % 12;
11503 pYear = v13 / 12;
11504 pMinutes = (int)__PAIR__(pMinutes, v9) % 60;
11505 pOurHour = pAMPM2 % 24;
11506 v14 = (unsigned __int64)(pAMPM2 % 24) >> 32;
11507 LODWORD(pAMPM2) = pAMPM2 % 24;
11508 HIDWORD(pOurHour) = pSaveFiles % 28;
11509 pYear += 1168;//ãîä íà÷àëà
11510 v16 = v12 & 3;
11511 pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261;
11512 HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12)
11513 && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24);
11514 if ( v14 != 0 || (signed int)v14 <= 0 && (unsigned int)pOurHour <= 12 )
11515 {
11516 if ( !(v14 | (unsigned int)pOurHour) )
11517 {
11518 pSaveFiles = 0;
11519 pHour = 12;
11520 goto LABEL_23;
11521 }
11522 }
11523 else
11524 {
11525 v14 = (__PAIR__(v14, (unsigned int)pOurHour) - 12) >> 32;
11526 LODWORD(pOurHour) = pOurHour - 12;
11527 }
11528 pHour = pOurHour;
11529 pSaveFiles = v14;
11530 LABEL_23:
11531 auto day = aDayNames[HIDWORD(pOurHour) % 7];
11532 auto ampm = aAMPMNames[HIDWORD(pAMPM2)];
11533 auto month = aMonthNames[pMonthNum];
11534 //sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d", _d, v17, (int)32, _a, 3, _m, pFilesID);
11535 sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d", day, pHour, pMinutes, ampm, 7 * v16 + HIDWORD(pOurHour) % 7 + 1, month, pYear);
11536 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pTmpBuf, 3u);
11537 v1 = 255;
11538 }
11539 if ( pGUIWindow_CurrentMenu->field_40 == 2 )
11540 {
11541 pGUIWindow_CurrentMenu->field_40 = 0;
11542 strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer);
11543 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
11544 {
11545 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)83;
11546 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
11547 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
11548 ++pMessageQueue_50CBD0->uNumMessages;
11549 }
11550 }
11551 else
11552 {
11553 if ( pGUIWindow_CurrentMenu->field_40 == 3 )
11554 pGUIWindow_CurrentMenu->field_40 = 0;
11555 }
11556 if (GetCurrentMenuID() == MENU_LOAD)
11557 {
11558 //v18 = pGlobalTXT_LocalizationStrings[135];
11559 v19 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[135]);//"Çàãðóçêà"
11560 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v19 + 25, 220, 0, pGlobalTXT_LocalizationStrings[135], 0, 0, 0);
11561 v20 = (const char *)(pSavegameHeader + uLoadGameUI_SelectedSlot);
11562 v21 = pFontSmallnum->AlignText_Center(0xBA, (const char *)pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
11563 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v21 + 25, 0x106, 0, v20, 185, 0);
11564 //v22 = pGlobalTXT_LocalizationStrings[165];
11565 v23 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);//"Ïîæàëóéñòà, ïîæîæäèòå"
11566 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v23 + 25, 304, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0);
11567 }
11568 else
11569 {
11570 if ( a4 )
11571 pSaveFiles = 40;
11572 else
11573 pSaveFiles = uNumSavegameFiles;
11574 a4 = 199;
11575 pFilesID = dword_6A0C9C;
11576 pSlotName = (const char *)(&pSavegameHeader[dword_6A0C9C]);//draw name for save slot
11577 do
11578 {
11579 if ( pFilesID >= (signed int)pSaveFiles )
11580 break;
11581 short clr;
11582 HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, 0x64) : 0);
11583 if ( pGUIWindow_CurrentMenu->field_40 != 1 || pFilesID != uLoadGameUI_SelectedSlot )
11584 {
11585 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0);
11586 }
11587 else
11588 {
11589 v25 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, (const char *)pKeyActionMap->pPressedKeysBuffer, 175, 1);
11590 pGUIWindow_CurrentMenu->DrawFlashingInputCursor(v25 + 27, a4, pFontSmallnum);
11591 }
11592 a4 += 21;
11593 ++pFilesID;
11594 pSlotName += 100;
11595 }
11596 while ( a4 < 346 );
11597 }
11598 pRenderer->EndScene();
11599 }
11600 // 6A0C9C: using guessed type int dword_6A0C9C;
11601
11602 //----- (004606F7) --------------------------------------------------------
11603 void __cdecl GameUI_MainMenu_DrawLoad()
11604 {
11605 GameUI_MainMenu_DoDrawLoad(0);
11606 }
11607
11608 //----- (004606FE) --------------------------------------------------------
11609 void __cdecl sub_4606FE()
11610 {
11611 GameUI_MainMenu_DoDrawLoad(1);
11612 }
11613
11614 //----- (00460706) --------------------------------------------------------
11615 void TryLoadLevelFromLOD()
11616 {
11617 FILE *v0; // eax@1
11618 FILE *v1; // esi@1
11619 __int32 v2; // edi@2
11620 char Ext[256]; // [sp+4h] [bp-40Ch]@1
11621 char Dir[256]; // [sp+104h] [bp-30Ch]@1
11622 char Filename[256]; // [sp+204h] [bp-20Ch]@1
11623 char a1[260]; // [sp+304h] [bp-10Ch]@1
11624 char Drive[4]; // [sp+408h] [bp-8h]@1
11625 int DstBuf; // [sp+40Ch] [bp-4h]@2
11626
11627 strcpy(a1, pCurrentMapName);
11628 _splitpath(a1, Drive, Dir, Filename, Ext);
11629 sprintf(a1, "levels\\%s%s", Filename, ".lod");
11630 v0 = fopen(a1, "rb");
11631 v1 = v0;
11632 if ( v0 )
11633 {
11634 fseek(v0, 0, 2);
11635 v2 = ftell(v1);
11636 rewind(v1);
11637 ptr_6A0D08 = pAllocator->AllocNamedChunk(ptr_6A0D08, v2, "LevelLod");
11638 fread(ptr_6A0D08, v2, 1u, v1);
11639 fseek(v1, v2 - 6, 0);
11640 DstBuf = 0;
11641 fread(&DstBuf, 4u, 1u, v1);
11642 fread(&_6A0D10_txt_lod_loading__unused, 2u, 1u, v1);
11643 _6A0D0C_txt_lod_loading = (int)((char *)ptr_6A0D08 + DstBuf);
11644 fclose(v1);
11645 }
11646 }
11647
11648 //----- (0046080D) --------------------------------------------------------
11649 void __cdecl sub_46080D()
11650 {
11651 pAllocator->FreeChunk(ptr_6A0D08);
11652 ptr_6A0D08 = 0;
11653 _6A0D0C_txt_lod_loading = 0;
11654 }
11655
11656 //----- (0046082C) --------------------------------------------------------
11657 bool Initialize_GamesLOD_NewLOD()
11658 {
11659 pGames_LOD = new LODWriteableFile;
11660 pGames_LOD->AllocSubIndicesAndIO(300, 0);
11661 if (pGames_LOD->LoadFile("data\\games.lod", 1))
11662 {
11663 pNew_LOD = new LODWriteableFile;
11664 pNew_LOD->AllocSubIndicesAndIO(300, 0x186A0u);
11665 return true;
11666 }
11667 return false;
11668 }
11669
11670
11671
11672
11673
11674 //----- (0046086A) --------------------------------------------------------
11675 bool Autosave()
11676 {
11677 int flag; // esi@3
11678 FILE *v3; // eax@7
11679 LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3
11680 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4
11681 LOD::Directory v7; // [sp+12Ch] [bp-4Ch]@9
11682 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3
11683 void *pSave; // [sp+170h] [bp-8h]@3
11684
11685 if ( pVideoPlayer->AnyMovieLoaded() )
11686 pVideoPlayer->Unload();
11687 flag = 0;
11688 pSave = pAllocator->AllocNamedChunk(0, 0xF4240, 0);
11689 pNew_LOD->CloseWriteFile();
11690 remove("data\\new.lod");
11691 this_.Reset();
11692 strcpy(this_.LodVersion, "MMVII");
11693 strcpy(this_.LodDescription, "newmaps for MMVII");
11694 this_.LODSize = 100;
11695 this_.dword_0000A8 = 0;
11696 a3.dword_000018 = 0;
11697 a3.word_00001E = 0;
11698 strcpy(a3.pFilename, "current");
11699 pNew_LOD->_461492(&this_, &a3, "data\\new.lod");
11700 if ( pNew_LOD->LoadFile("data\\new.lod", 0) )
11701 {
11702 pNew_LOD->CreateTempFile();
11703 pNew_LOD->uNumSubIndices = 0;
11704 pDir.Reset();
11705
11706 for (int i = pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i)
11707 {
11708 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));
11709 v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1);
11710 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3);
11711 pNew_LOD->AppendDirectory(&pDir, pSave);
11712 }
11713 v7.Reset();
11714 strcpy(pSavegameHeader->pLocationName, "out01.odm");
11715 strcpy(v7.pFilename, "header.bin");
11716 v7.uDataSize = 100;
11717 pNew_LOD->AppendDirectory(&v7, &pSavegameHeader);
11718 pNew_LOD->Save();
11719 pParty->vPrevPosition.y = 0;
11720 pParty->vPrevPosition.x = 12552;
11721 pParty->vPosition.x = 12552;
11722 pParty->vPosition.z = 0;
11723 pParty->uFallStartY = 0;
11724 pParty->sPrevRotationX = 0;
11725 pParty->sRotationX = 0;
11726 pParty->vPrevPosition.z = 1816;
11727 pParty->vPosition.y = 1816;
11728 flag = 1;
11729 pParty->sPrevRotationY = 512;
11730 pParty->sRotationY = 512;
11731 SaveGame(1, (__int16 *)1);
11732 }
11733 pAllocator->FreeChunk(pSave);
11734 return flag;
11735 }
11736
11737
11738 //----- (004610AA) --------------------------------------------------------
11739 void __fastcall PrepareToLoadODM(unsigned int bLoading, OutdoorCamera *a2)
11740 {
11741 unsigned int v2; // edi@1
11742 OutdoorCamera *v3; // esi@1
11743
11744 v2 = bLoading;
11745 v3 = a2;
11746 pGameLoadingUI_ProgressBar->Reset(0x1Bu);
11747 pSoundList->_4A9D79(0);
11748 uCurrentlyLoadedLevelType = (LEVEL_TYPE)2;
11749 ODM_LoadAndInitialize(pCurrentMapName, v3);
11750 if ( !v2 )
11751 TeleportToStartingPoint(uLevel_StartingPointType);
11752 viewparams->_443365();
11753 PlayLevelMusic();
11754 }
11755 // 6BE35C: using guessed type int uLevel_StartingPointType;
11756
11757 //----- (00461103) --------------------------------------------------------
11758 void __cdecl sub_461103()
11759 {
11760 //GUIProgressBar *v0; // ebx@1
11761 //signed int v1; // ebp@1
11762 //char *v2; // esi@2
11763 __int16 v3; // cx@3
11764 int v4; // edx@8
11765 //size_t v5; // edi@14
11766 signed int v6; // esi@14
11767 //char *v7; // edx@15
11768 signed int v8; // ecx@16
11769 int v9; // ecx@23
11770 MonsterInfo *v10; // ebx@23
11771 //int *v11; // esi@23
11772 int v12; // esi@25
11773 int v13; // eax@26
11774 __int16 v14; // ax@41
11775 //signed int v15; // [sp+10h] [bp-4Ch]@1
11776 //signed int v16; // [sp+10h] [bp-4Ch]@14
11777 signed int v17; // [sp+14h] [bp-48h]@3
11778 signed int v18; // [sp+14h] [bp-48h]@23
11779 int v19; // [sp+18h] [bp-44h]@1
11780 signed int v20; // [sp+18h] [bp-44h]@14
11781 int v21[16]; // [sp+1Ch] [bp-40h]@17
11782
11783 sub_450218_prolly_generate_chests_loot();
11784 //v0 = pGameLoadingUI_ProgressBar;
11785 pGameLoadingUI_ProgressBar->Progress();
11786 pParty->uFlags |= 2u;
11787 pParty->field_7B5_in_arena_quest = 0;
11788 //v1 = 0;
11789 dword_5C6DF8 = 1;
11790 pNPCStats->field_17FC0 = 0;
11791 v19 = pMapStats->GetMapInfo(pCurrentMapName);
11792
11793 //v15 = 0;
11794 for (uint i = 0; i < uNumActors; ++i)
11795 //if ( (signed int)uNumActors > 0 )
11796 {
11797 auto pActor = pActors + i;
11798 //v2 = (char *)&pActors[0].uNPC_ID;
11799 //do
11800 //{
11801 v3 = pActor->pMonsterInfo.uID;
11802 v17 = 0;
11803 if ( v3 >= 115 && v3 <= 186 || v3 >= 232 && v3 <= 249 )
11804 v17 = 1;
11805 //v1 = 0;
11806 v4 = (v3 - 1) % 3;
11807 if ( 2 == v4 )
11808 {
11809 if ( pActor->uNPC_ID && pActor->uNPC_ID < 5000 )
11810 continue;
11811 }
11812 else
11813 {
11814 if ( v4 != 1 )
11815 {
11816 if ( v4 != 0 || pActor->uNPC_ID )
11817 continue;
11818 goto LABEL_12;
11819 }
11820 }
11821 if ( pActor->uNPC_ID > 0 && pActor->uNPC_ID < 5000 )
11822 continue;
11823 if ( v17 )
11824 {
11825 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->array_13EF4[pNPCStats->field_17FC0], v3, 0, v19);
11826 v14 = LOWORD(pNPCStats->field_17FC0) + 5000;
11827 ++pNPCStats->field_17FC0;
11828 pActor->uNPC_ID = v14;
11829 continue;
11830 }
11831 LABEL_12:
11832 pActor->uNPC_ID = 0;
11833 //LABEL_13:
11834 //++v15;
11835 //v2 += 836;
11836 //}
11837 //while ( v15 < (signed int)uNumActors );
11838 }
11839
11840 pGameLoadingUI_ProgressBar->Progress();
11841
11842 //v5 = uNumActors;
11843 v6 = 0;
11844 v20 = 0;
11845 //v16 = v1;
11846
11847 for (uint i = 0; i < uNumActors; ++i)
11848 {
11849 auto pActor = pActors + i;
11850 //v7 = (char *)&pActors[0].pMonsterInfo;
11851 //do
11852 //{
11853 v8 = 0;
11854 if ( v6 > 0 )
11855 {
11856 do
11857 {
11858 if ( v21[v8] == pActor->pMonsterInfo.uID - 1 )
11859 break;
11860 ++v8;
11861 }
11862 while ( v8 < v6 );
11863 }
11864
11865 if ( v8 == v6 )
11866 {
11867 v21[v6++] = pActor->pMonsterInfo.uID - 1;
11868 v20 = v6;
11869 if ( v6 == 16 )
11870 break;
11871 }
11872 //++v16;
11873 //v7 += 836;
11874 //}
11875 //while ( v16 < (signed int)v5 );
11876 }
11877
11878 pGameLoadingUI_ProgressBar->Progress();
11879
11880 if ( v6 > 0 )
11881 {
11882 int _v0 = 0;
11883 do
11884 {
11885 v9 = v21[_v0];
11886 v18 = 4;
11887 v10 = &pMonsterStats->pInfos[v9 + 1];
11888 //v11 = (int *)pMonsterList->pMonsters[v9].pSoundSampleIDs;
11889 auto v11 = &pMonsterList->pMonsters[v9];
11890 do
11891 {
11892 pSoundList->LoadSound(v11->pSoundSampleIDs[4 - v18], 0);
11893 //v11 = (int *)((char *)v11 + 2);
11894 --v18;
11895 }
11896 while ( v18 );
11897 v12 = 0;
11898 do
11899 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v10->uSpell1ID], 1);
11900 while ( v13 );
11901 ++_v0;
11902 }
11903 while ( _v0 < v6 );
11904 //v0 = pGameLoadingUI_ProgressBar;
11905 //v1 = 0;
11906 }
11907
11908 pGameLoadingUI_ProgressBar->Progress();
11909
11910 if ( dword_6BE368_debug_settings_2 & 4 )
11911 uNumActors = 0;
11912 if ( dword_6BE368_debug_settings_2 & 8 )
11913 uNumLevelDecorations = 0;
11914 sub_4613C4();
11915
11916 pGameLoadingUI_ProgressBar->Progress();
11917
11918 pIndoorCamera->pos.y = 0;
11919 pIndoorCamera->pos.x = 0;
11920 pIndoorCamera->pos.z = 100;
11921 pIndoorCamera->sRotationY = 0;
11922 pIndoorCamera->sRotationX = 0;
11923 viewparams->bRedrawGameUI = 1;
11924 uLevel_StartingPointType = 0;
11925 pSprites_LOD->_461397();
11926 pPaletteManager->LockTestAll();
11927 if ( pParty->pPickedItem.uItemID != 0 )
11928 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID);
11929 }
11930
11931
11932
11933 //----- (004613C4) --------------------------------------------------------
11934 int __cdecl sub_4613C4()
11935 {
11936 unsigned __int16 v0; // ax@1
11937 size_t v1; // ecx@1
11938 int v2; // esi@1
11939 int result; // eax@1
11940 LevelDecoration *v4; // edx@2
11941 int v5; // edi@4
11942
11943 _6836C8_num_decorations_6807E8 = 0;
11944 v0 = pDecorationList->GetDecorIdByName("Event Trigger");
11945 v1 = uNumLevelDecorations;
11946 v2 = (signed __int16)v0;
11947 result = 0;
11948 if ( (signed int)uNumLevelDecorations > 0 )
11949 {
11950 v4 = pLevelDecorations;
11951 do
11952 {
11953 if ( v4->uDecorationDescID == v2 )
11954 {
11955 v5 = _6836C8_num_decorations_6807E8++;
11956 _6807E8_level_decorations_ids[v5] = result;
11957 }
11958 ++result;
11959 ++v4;
11960 }
11961 while ( result < (signed int)v1 );
11962 }
11963 return result;
11964 }
11965 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8;
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979 //----- (004621DA) --------------------------------------------------------
11980 int __fastcall sub_4621DA(signed int a1, signed int a2, signed int a3)
11981 {
11982 signed int v3; // eax@2
11983 signed int v4; // eax@3
11984 signed int v5; // esi@4
11985 signed int v6; // esi@6
11986
11987 if ( a1 < a2 )
11988 {
11989 v3 = a1;
11990 a1 = a2;
11991 a2 = v3;
11992 }
11993 v4 = a3;
11994 if ( a1 < a3 )
11995 {
11996 v5 = a1;
11997 a1 = a3;
11998 v4 = v5;
11999 }
12000 if ( a2 < v4 )
12001 {
12002 v6 = a2;
12003 a2 = v4;
12004 v4 = v6;
12005 }
12006 return (11 * a2 >> 5) + a1 + (v4 >> 2);
12007 }
12008
12009
12010
12011
12012
12013
12014 OPENFILENAMEA ofn;
12015 //----- (0046271C) --------------------------------------------------------
12016 void __cdecl crt_init_globals_46271C()
12017 {
12018 ofn.lStructSize = 0x4Cu;
12019 ofn.hwndOwner = hWnd;
12020 ofn.hInstance = 0;
12021 ofn.lpstrFilter = "Indoor BLV Files (*.blv)";
12022 ofn.lpstrCustomFilter = 0;
12023 ofn.nMaxCustFilter = 0;
12024 ofn.nFilterIndex = 0;
12025 ofn.lpstrFile = 0;
12026 ofn.nMaxFile = 260;
12027 ofn.nMaxFileTitle = 512;
12028 ofn.lpstrInitialDir = "levels";
12029 ofn.lpstrTitle = "Might and Magic® VII - Load Which Level?";
12030 ofn.Flags = 4;
12031 ofn.nFileOffset = 0;
12032 ofn.nFileExtension = 0;
12033 ofn.lpstrDefExt = "blv";
12034 ofn.lCustData = 0;
12035 ofn.lpfnHook = 0;
12036 ofn.lpTemplateName = 0;
12037 ofn.lpstrFileTitle = pTmpBuf;
12038 }
12039
12040 //----- (004627B7) --------------------------------------------------------
12041 void __cdecl MainMenu_Loop()
12042 {
12043 GUIButton *pButton; // eax@27
12044 unsigned int pControlParam; // ecx@35
12045 int v10; // ecx@36
12046 int v11; // ecx@37
12047 unsigned int pY; // [sp-18h] [bp-54h]@39
12048 Texture *pTexture; // [sp-14h] [bp-50h]@39
12049 GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27
12050 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11
12051
12052 pCurrentScreen = 0; // îêíî Ãëàâíîå ìåíþ
12053 if (pAsyncMouse)
12054 pAsyncMouse->Resume();
12055 if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
12056 pAsyncKeyboard->Resume();
12057 pGUIWindow2 = 0;
12058 pAudioPlayer->StopChannels(-1, -1);
12059 pMouse->RemoveHoldingItem();
12060 ++pIcons_LOD->uTexturePacksCount;
12061 if ( !pIcons_LOD->uNumPrevLoadedFiles )
12062 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
12063 pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); // ñîçäàíèå îêíà
12064 auto pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); // ñîçäàíèå êíîïîê
12065 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0,
12066 UIMSG_MainMenu_ShowPartyCreationWnd, 0, 78, "", pNew, 0);
12067 auto pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
12068 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0,
12069 UIMSG_MainMenu_ShowLoadWindow, 1, 76, "", pLoad, 0);
12070 auto pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
12071 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0,
12072 UIMSG_ShowCredits, 2, 67, "", pCredits, 0);
12073 auto pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
12074 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0,
12075 UIMSG_ExitToWindows, 3, 0, "", pExit, 0);
12076 pTexture_PCX.Release();
12077 pTexture_PCX.Load("title.pcx", 0);
12078 SetCurrentMenuID(MENU_MAIN);
12079 SetForegroundWindow(hWnd);
12080 SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0);
12081 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD)
12082 {
12083 POINT pt;
12084 pMouse->GetCursorPos(&pt);
12085 pWindow = pWindow_MainMenu;
12086 if ( GetCurrentMenuID() == MENU_SAVELOAD)//åñëè ìåíþ çàãðóçêè
12087 {
12088 if ( pCurrentScreen != 12 )//åñëè íå îêíî çàãðóçêè èãðû
12089 {
12090 pTexture_PCX.Release();
12091 pTexture_PCX.Load("lsave640.pcx", 0);
12092 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
12093 pCurrentScreen = 12; //îêíî çàãðóçêè èãðû
12094 GameUI_DrawLoadMenu(0);//ïðîöåññ ïðîðèñîâêè îêíà Çàãðóçêà
12095 }
12096 pWindow = pGUIWindow_CurrentMenu;
12097 }
12098
12099 MSG msg;
12100 while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) )//îæèäàíèå ñîîáùåíèÿ èç âíåøíåãî èñòî÷íèêà
12101 {
12102 if (msg.message == WM_QUIT)
12103 Game_DeinitializeAndTerminate(0);
12104 TranslateMessage(&msg);
12105 DispatchMessageA(&msg);
12106 }
12107 if (dword_6BE364_game_settings_1 & 0x0100)
12108 {
12109 WaitMessage();
12110 }
12111 else
12112 {
12113 pRenderer->BeginScene();
12114 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
12115 if (pAsyncMouse)
12116 pAsyncMouse->_46B736_consume_click_lists(1);
12117 GUI_MainMenuMessageProc();//ïðîöåäóðà ïðîâåðêè ñîîáùåíèé ïîñòóïàþùèõ èç âíåøíèõ óñòðîéñòâ äëÿ âñåé ãðóïïû âñòóïèòåëüíûõ îêîí
12118 GUI_UpdateWindows();
12119 if (pAsyncMouse)
12120 pAsyncMouse->_46B736_consume_click_lists(1);
12121 if (GetCurrentMenuID() != MENU_MAIN)// åñëè íå Ãëàâíîå ìåíþ
12122 {
12123 if (GetCurrentMenuID() == MENU_LOAD)// åñëè ìåíþ Çàãðóçêà
12124 {
12125 pIcons_LOD->_4114F2();
12126 pGUIWindow_CurrentMenu->Release();
12127 pGUIWindow_CurrentMenu = 0;
12128 pCurrentScreen = 0;
12129 viewparams->bRedrawGameUI = 1;
12130 }
12131 }
12132 else
12133 {
12134 if ( !ptr_507BDC )// ???
12135 {
12136 pButton = pWindow->pControlsHead;
12137 for ( pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext )
12138 {
12139 if ( pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ
12140 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW
12141 && pWindow == pWindow_MainMenu )
12142 {
12143 pControlParam = pButton->uControlParam;
12144 switch (pControlParam) // ïîäñâåòêà êíîïîê
12145 {
12146 case 0:
12147 pTexture = pNew;
12148 pY = 172;
12149 break;
12150 case 1:
12151 pTexture = pLoad;
12152 pY = 227;
12153 break;
12154 case 2:
12155 pTexture = pCredits;
12156 pY = 282;
12157 break;
12158 case 3:
12159 pTexture = pExit;
12160 pY = 337;
12161 break;
12162 }
12163 pRenderer->DrawTextureIndexed(495, pY, pTexture); //ïîäñâåòêà êíîïîê
12164 }
12165 }
12166 }
12167 }
12168 pRenderer->EndScene();
12169 pRenderer->Present();
12170 }
12171 }
12172 /*GUI_MainMenuMessageProc(); //Ritor1: unknow
12173 pRenderer->BeginScene();
12174 GUI_UpdateWindows();
12175 pRenderer->EndScene();
12176 pRenderer->Present();
12177 pTexture_PCX.Release();*/
12178 if ( pGUIWindow2 )
12179 {
12180 pGUIWindow2->Release();
12181 pGUIWindow2 = 0;
12182 }
12183 pWindow_MainMenu->Release();
12184 pIcons_LOD->_4114F2();
12185 }
12186
12187
12188
12189
12190 //----- (004637EB) --------------------------------------------------------
12191 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam)
12192 {
12193 unsigned int v4; // esi@1
12194 Render *v5; // ecx@14
12195 HANDLE v6; // eax@32
12196 Keyboard *v7; // eax@33
12197 //HDC v9; // edi@41
12198 HDC v10; // edi@50
12199 int v11; // esi@50
12200 char v12; // zf@132
12201 signed int v13; // eax@135
12202 int v14; // eax@139
12203 int v15; // eax@140
12204 int v16; // eax@141
12205 int v17; // eax@142
12206 int v18; // eax@150
12207 int v19; // eax@151
12208 int v20; // eax@152
12209 int v21; // eax@161
12210 int v22; // eax@162
12211 int v23; // eax@163
12212 int v24; // eax@170
12213 int v25; // eax@171
12214 int v26; // eax@172
12215 char v27; // al@174
12216 bool v28; // ebx@201
12217 char v29; // dl@209
12218 char v30; // cl@210
12219 bool v31; // ebx@211
12220 void *v32; // ebx@214
12221 float v33; // ST04_4@246
12222 float v34; // ST04_4@254
12223 HWND v35; // [sp+8h] [bp-64h]@103
12224 UINT v36; // [sp+Ch] [bp-60h]@103
12225 WPARAM v37; // [sp+10h] [bp-5Ch]@103
12226 LPARAM v38; // [sp+14h] [bp-58h]@103
12227 struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
12228 int pXY[2]; // [sp+64h] [bp-8h]@261
12229 int a2; // [sp+7Ch] [bp+10h]@50
12230
12231 switch (Msg)
12232 {
12233 case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam);
12234 };
12235
12236 v4 = lParam;
12237 if ( Msg > WM_SYSCOMMAND )
12238 {
12239 switch ( Msg )
12240 {
12241 default:
12242 goto _def_wnd_proc;
12243 case WM_DEVICECHANGE:
12244 if ( wParam == 0x8000 )
12245 PostMessageA(hInsertCDWindow, WM_CHOOSEFONT_GETLOGFONT, 0, 0);
12246 return 0;
12247 case WM_SIZING:
12248 return 1;
12249 case WM_LBUTTONDOWN:
12250 v28 = 0;
12251 if ( pArcomageGame->bGameInProgress )
12252 {
12253 if (pAsyncMouse)
12254 goto _def_wnd_proc;
12255 pArcomageGame->stru1.field_0 = 7;
12256 v29 = 1;
12257 LABEL_210:
12258 v30 = 0;
12259 goto LABEL_263;
12260 }
12261 if ( pVideoPlayer->pVideoFrame.pPixels )
12262 pVideoPlayer->bStopBeforeSchedule = 1;
12263 if ( !pAsyncMouse )
12264 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
12265 if (GetCurrentMenuID() != MENU_CREATEPARTY)
12266 goto LABEL_230;
12267 goto LABEL_229;
12268 case WM_RBUTTONDOWN:
12269 v31 = 0;
12270 if ( !pArcomageGame->bGameInProgress )
12271 goto LABEL_240;
12272 if (pAsyncMouse)
12273 goto _def_wnd_proc;
12274 pArcomageGame->stru1.field_0 = 8;
12275 v29 = 1;
12276 goto LABEL_262;
12277 case WM_LBUTTONUP:
12278 v32 = 0;
12279 if ( !pArcomageGame->bGameInProgress )
12280 goto LABEL_218;
12281 if (pAsyncMouse)
12282 goto _def_wnd_proc;
12283 pArcomageGame->stru1.field_0 = 3;
12284 v29 = 0;
12285 goto LABEL_210;
12286 case WM_RBUTTONUP:
12287 v32 = 0;
12288 if ( !pArcomageGame->bGameInProgress )
12289 {
12290 LABEL_218:
12291 if ( pAsyncMouse != v32 )
12292 goto _def_wnd_proc;
12293 back_to_game();
12294 return DefWindowProcA(hWnd, Msg, wParam, v4);
12295 }
12296 if (pAsyncMouse)
12297 goto _def_wnd_proc;
12298 pArcomageGame->stru1.field_0 = 4;
12299 v29 = 0;
12300 goto LABEL_262;
12301 case WM_LBUTTONDBLCLK:
12302 v28 = 0;
12303 if ( pArcomageGame->bGameInProgress )
12304 {
12305 if (pAsyncMouse)
12306 goto _def_wnd_proc;
12307 pArcomageGame->stru1.field_0 = 7;
12308 return DefWindowProcA(hWnd, Msg, wParam, v4);
12309 }
12310 if ( pVideoPlayer->pVideoFrame.pPixels )
12311 pVideoPlayer->bStopBeforeSchedule = 1;
12312 if ( !pAsyncMouse )
12313 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
12314 if ( uCurrentMenuID != 6 )
12315 goto LABEL_230;
12316 if ( !pAsyncMouse )
12317 {
12318 LABEL_229:
12319 sub_41CD4F(0x29u);
12320 LABEL_230:
12321 if ( pAsyncMouse == (void *)v28 )
12322 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
12323 }
12324 if ( pGame != (Game *)v28 )
12325 {
12326 if ( pAsyncMouse != (void *)v28 )
12327 goto _def_wnd_proc;
12328 pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, v28, &a3, &a4);
12329 }
12330 if ( pAsyncMouse == (void *)v28 )
12331 {
12332 UI_OnMouseLeftClick(0);
12333 return DefWindowProcA(hWnd, Msg, wParam, v4);
12334 }
12335 goto _def_wnd_proc;
12336 case WM_RBUTTONDBLCLK:
12337 v31 = 0;
12338 if ( !pArcomageGame->bGameInProgress )
12339 {
12340 LABEL_240:
12341 if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
12342 pVideoPlayer->bStopBeforeSchedule = 1;
12343 if (!pAsyncMouse)
12344 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
12345 if (pGame)
12346 {
12347 if (pAsyncMouse)
12348 goto _def_wnd_proc;
12349 v33 = GetPickDepth();
12350 pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &stru_F93E30, &a4);
12351 }
12352 if (!pAsyncMouse)
12353 {
12354 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
12355 return DefWindowProcA(hWnd, Msg, wParam, v4);
12356 }
12357 goto _def_wnd_proc;
12358 }
12359 if (pAsyncMouse)
12360 goto _def_wnd_proc;
12361 pArcomageGame->stru1.field_0 = 8;
12362 return DefWindowProcA(hWnd, Msg, wParam, v4);
12363 case WM_MBUTTONDOWN:
12364 if ( pRenderer->pRenderD3D )
12365 {
12366 if ( pGame && !pAsyncMouse )
12367 {
12368 v34 = GetPickDepth();
12369 pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &a3, &a5);
12370 return DefWindowProcA(hWnd, Msg, wParam, v4);
12371 }
12372 goto _def_wnd_proc;
12373 }
12374 if ( !pGame )
12375 goto _def_wnd_proc;
12376 sub_417871(0);
12377 return DefWindowProcA(hWnd, Msg, wParam, v4);
12378 case WM_MOUSEMOVE:
12379 if ( pArcomageGame->bGameInProgress )
12380 {
12381 if (pAsyncMouse)
12382 goto _def_wnd_proc;
12383 pXY[0] = (unsigned __int16)lParam;
12384 pXY[1] = lParam >> 16;
12385 ArcomageGame::OnMouseMove((POINT *)pXY);
12386 ArcomageGame::OnMouseClick(0, wParam & 1);
12387 v29 = (wParam >> 1) & 1;
12388 LABEL_262:
12389 v30 = 1;
12390 LABEL_263:
12391 ArcomageGame::OnMouseClick(v30, v29);
12392 }
12393 else
12394 {
12395 if (pAsyncMouse)
12396 goto _def_wnd_proc;
12397 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
12398 }
12399 return DefWindowProcA(hWnd, Msg, wParam, v4);
12400 }
12401 }
12402 if ( Msg == WM_SYSCOMMAND )
12403 {
12404 if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
12405 return 0;
12406 goto _def_wnd_proc;
12407 }
12408 if ( Msg > WM_ACTIVATEAPP )
12409 {
12410 if ( Msg == WM_WINDOWPOSCHANGED )
12411 {
12412 if (pVideoPlayer)
12413 {
12414 if (pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
12415 {
12416 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
12417 return DefWindowProcA(hWnd, Msg, wParam, v4);
12418 }
12419 }
12420 goto _def_wnd_proc;
12421 }
12422 if ( Msg != WM_KEYFIRST )
12423 {
12424 if ( Msg == WM_KEYUP )
12425 {
12426 if ( wParam == VK_CONTROL )
12427 {
12428 dword_507B98_ctrl_pressed = 0;
12429 return DefWindowProcA(hWnd, Msg, wParam, v4);
12430 }
12431 goto _def_wnd_proc;
12432 }
12433 if ( Msg == WM_CHAR )
12434 {
12435 if ( !pKeyActionMap->_459F10(wParam) && !viewparams->field_4C )
12436 {
12437 GUI_HandleHotkey(wParam);
12438 return DefWindowProcA(hWnd, Msg, wParam, v4);
12439 }
12440 goto _def_wnd_proc;
12441 }
12442 if ( Msg != WM_COMMAND )
12443 goto _def_wnd_proc;
12444 if ( wParam != 101 )
12445 {
12446 if ( wParam == 103 )
12447 {
12448 pRenderer->SavePCXScreenshot();
12449 return 0;
12450 }
12451 if ( wParam == 104 )
12452 {
12453 pRenderer->ChangeBetweenWinFullscreenModes();
12454 if ( pArcomageGame->bGameInProgress )
12455 pArcomageGame->field_F6 = 1;
12456 return 0;
12457 }
12458 if ( wParam != 40001 )
12459 return DefWindowProcA(hWnd, Msg, wParam, v4);
12460 }
12461 v38 = 0;
12462 v37 = 0;
12463 v36 = 2;
12464 v35 = ::hWnd;
12465 LABEL_104:
12466 SendMessageA(v35, v36, v37, v38);
12467 return 0;
12468 }
12469 if ( dword_506E68 != -1 )
12470 {
12471 pKeyActionMap->_459F10(wParam);
12472 return DefWindowProcA(hWnd, Msg, wParam, v4);
12473 }
12474 if ( !pArcomageGame->bGameInProgress )
12475 {
12476 if ( pVideoPlayer->pVideoFrame.pPixels )
12477 pVideoPlayer->bStopBeforeSchedule = 1;
12478 if ( wParam != 13 )
12479 {
12480 if ( wParam == 17 )
12481 {
12482 dword_507B98_ctrl_pressed = 1;
12483 return 0;
12484 }
12485 if ( wParam == 27 )
12486 {
12487 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
12488 {
12489 v12 = ptr_507BC0 == 0;
12490 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
12491 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = !v12;
12492 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
12493 ++pMessageQueue_50CBD0->uNumMessages;
12494 }
12495 return 0;
12496 }
12497 if ( wParam <= 0x24 )
12498 return 0;
12499 if ( wParam > 0x28 )
12500 {
12501 if ( wParam != 115 || pVideoPlayer->AnyMovieLoaded() )
12502 return 0;
12503 v38 = 0;
12504 v37 = 104;
12505 LABEL_126:
12506 v36 = 273;
12507 v35 = hWnd;
12508 goto LABEL_104;
12509 }
12510 if ( pCurrentScreen
12511 && pCurrentScreen != 21 )
12512 return 0;
12513 }
12514 if ( !viewparams->field_4C )
12515 sub_41CD4F(wParam);
12516 return 0;
12517 }
12518 pArcomageGame->stru1.field_0 = 1;
12519 if ( (unsigned __int16)GetAsyncKeyState(VK_SHIFT) >> 8 >= 0 )
12520 {
12521 v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
12522 }
12523 else
12524 {
12525 v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u);
12526 if ( (signed int)(unsigned __int16)v13 > 54 )
12527 {
12528 if ( v13 > 61 )
12529 {
12530 v24 = v13 - 91;
12531 if ( !v24 )
12532 {
12533 LOBYTE(pArcomageGame->stru1.field_8) = 123;
12534 goto LABEL_181;
12535 }
12536 v25 = v24 - 1;
12537 if ( !v25 )
12538 {
12539 LOBYTE(pArcomageGame->stru1.field_8) = 124;
12540 goto LABEL_181;
12541 }
12542 v26 = v25 - 1;
12543 if ( !v26 )
12544 {
12545 LOBYTE(pArcomageGame->stru1.field_8) = 125;
12546 goto LABEL_181;
12547 }
12548 if ( v26 == 3 )
12549 {
12550 LOBYTE(pArcomageGame->stru1.field_8) = 126;
12551 goto LABEL_181;
12552 }
12553 }
12554 else
12555 {
12556 if ( v13 == 61 )
12557 {
12558 LOBYTE(pArcomageGame->stru1.field_8) = 43;
12559 goto LABEL_181;
12560 }
12561 v21 = v13 - 55;
12562 if ( !v21 )
12563 {
12564 LOBYTE(pArcomageGame->stru1.field_8) = 38;
12565 goto LABEL_181;
12566 }
12567 v22 = v21 - 1;
12568 if ( !v22 )
12569 {
12570 LOBYTE(pArcomageGame->stru1.field_8) = 42;
12571 goto LABEL_181;
12572 }
12573 v23 = v22 - 1;
12574 if ( !v23 )
12575 {
12576 LOBYTE(pArcomageGame->stru1.field_8) = 40;
12577 goto LABEL_181;
12578 }
12579 if ( v23 == 2 )
12580 {
12581 LOBYTE(pArcomageGame->stru1.field_8) = 58;
12582 goto LABEL_181;
12583 }
12584 }
12585 }
12586 else
12587 {
12588 if ( (unsigned __int16)v13 == 54 )
12589 {
12590 LOBYTE(pArcomageGame->stru1.field_8) = 94;
12591 goto LABEL_181;
12592 }
12593 if ( v13 > 49 )
12594 {
12595 v18 = v13 - 50;
12596 if ( !v18 )
12597 {
12598 LOBYTE(pArcomageGame->stru1.field_8) = 64;
12599 goto LABEL_181;
12600 }
12601 v19 = v18 - 1;
12602 if ( !v19 )
12603 {
12604 LOBYTE(pArcomageGame->stru1.field_8) = 35;
12605 goto LABEL_181;
12606 }
12607 v20 = v19 - 1;
12608 if ( !v20 )
12609 {
12610 LOBYTE(pArcomageGame->stru1.field_8) = 36;
12611 goto LABEL_181;
12612 }
12613 if ( v20 == 1 )
12614 {
12615 LOBYTE(pArcomageGame->stru1.field_8) = 37;
12616 goto LABEL_181;
12617 }
12618 }
12619 else
12620 {
12621 if ( v13 == 49 )
12622 {
12623 LOBYTE(pArcomageGame->stru1.field_8) = 33;
12624 goto LABEL_181;
12625 }
12626 v14 = v13 - 39;
12627 if ( !v14 )
12628 {
12629 LOBYTE(pArcomageGame->stru1.field_8) = 34;
12630 goto LABEL_181;
12631 }
12632 v15 = v14 - 5;
12633 if ( !v15 )
12634 {
12635 LOBYTE(pArcomageGame->stru1.field_8) = 60;
12636 goto LABEL_181;
12637 }
12638 v16 = v15 - 2;
12639 if ( !v16 )
12640 {
12641 LOBYTE(pArcomageGame->stru1.field_8) = 62;
12642 goto LABEL_181;
12643 }
12644 v17 = v16 - 1;
12645 if ( !v17 )
12646 {
12647 LOBYTE(pArcomageGame->stru1.field_8) = 63;
12648 goto LABEL_181;
12649 }
12650 if ( v17 == 1 )
12651 {
12652 LOBYTE(pArcomageGame->stru1.field_8) = 41;
12653 LABEL_181:
12654 if ( wParam == 27 )
12655 {
12656 pArcomageGame->field_F5 = 1;
12657 pArcomageGame->field_F4 = 1;
12658 pArcomageGame->uGameResult = 2;
12659 pArcomageGame->field_B0 = -2;
12660 goto _def_wnd_proc;
12661 }
12662 if ( wParam != 114 )
12663 {
12664 if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
12665 SendMessageA(hWnd, 0x111u, 0x68u, 0);
12666 goto _def_wnd_proc;
12667 }
12668 v38 = 0;
12669 v37 = 103;
12670 goto LABEL_126;
12671 }
12672 }
12673 }
12674 v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
12675 }
12676 LOBYTE(pArcomageGame->stru1.field_8) = v27;
12677 goto LABEL_181;
12678 }
12679 if ( Msg == WM_ACTIVATEAPP )
12680 {
12681 if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) )
12682 {
12683 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
12684 {
12685 dword_4E98BC_bApplicationActive = 1;
12686 if ( pRenderer->bWindowMode )
12687 {
12688 v10 = GetDC(0);
12689 a2 = GetDeviceCaps(v10, BITSPIXEL);
12690 v11 = GetDeviceCaps(v10, PLANES);
12691 ReleaseDC(0, v10);
12692 if ( a2 != 16 || v11 != 1 )
12693 Abortf(pGlobalTXT_LocalizationStrings[62]);
12694 }
12695 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
12696 if (pAsyncMouse)
12697 pAsyncMouse->Resume();
12698 if ( pArcomageGame->bGameInProgress )
12699 {
12700 pArcomageGame->field_F9 = 1;
12701 }
12702 else
12703 {
12704 if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
12705 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
12706 else
12707 pEventTimer->Resume();
12708 if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
12709 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
12710 else
12711 pMiscTimer->Resume();
12712 if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
12713 pAsyncKeyboard->Resume();
12714 viewparams->bRedrawGameUI = 1;
12715 if ( pVideoPlayer->pSmackerMovie )
12716 {
12717 pRenderer->RestoreFrontBuffer();
12718 pRenderer->_4A184C();
12719 pVideoPlayer->_4BF5B2();
12720 }
12721 }
12722 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
12723 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
12724 }
12725 }
12726 else
12727 {
12728 if ( !(dword_6BE364_game_settings_1 & 0x100) )
12729 {
12730 dword_4E98BC_bApplicationActive = 0;
12731 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
12732 pVideoPlayer->bStopBeforeSchedule = 1;
12733 if (pAsyncMouse)
12734 pAsyncMouse->Suspend();
12735 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
12736 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
12737 ClipCursor(0);
12738 dword_6BE364_game_settings_1 |= 0x100u;
12739 if ( pEventTimer->bPaused )
12740 BYTE1(dword_6BE364_game_settings_1) |= 2u;
12741 else
12742 pEventTimer->Pause();
12743 if ( pMiscTimer->bPaused )
12744 BYTE1(dword_6BE364_game_settings_1) |= 4u;
12745 else
12746 pMiscTimer->Pause();
12747 if ( pGame && LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
12748 pAsyncKeyboard->Suspend();
12749 pAudioPlayer->StopChannels(-1, -1);
12750 if ( pAudioPlayer->hAILRedbook )
12751 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
12752 }
12753 }
12754 return 0;
12755 }
12756 if (Msg == WM_CREATE)
12757 {
12758 auto hDC = GetDC(hWnd);
12759 {
12760 if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
12761 {
12762 ReleaseDC(hWnd, hDC);
12763 Log::Warning(L"You must be running in 256 color mode or higher.");
12764 Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon.");
12765 }
12766 }
12767 ReleaseDC(hWnd, hDC);
12768 return 0;
12769 }
12770 if ( Msg == WM_DESTROY )
12771 {
12772 v6 = GetCurrentProcess();
12773 SetPriorityClass(v6, 0x20u);
12774 if ( pGame )
12775 {
12776 v7 = pGame->pKeyboardInstance;
12777 if ( v7 )
12778 {
12779 if ( LOBYTE(v7->bUsingAsynKeyboard) && pAsyncKeyboard )
12780 pAsyncKeyboard->_45B3A4();
12781 }
12782 }
12783 if (pAsyncMouse)
12784 pAsyncMouse->_46B1DD();
12785 PostQuitMessage(0);
12786 return 0;
12787 }
12788 if ( Msg == WM_SETFOCUS )
12789 {
12790 if ( ::hWnd == (HWND)wParam )
12791 {
12792 dword_4E98BC_bApplicationActive = 0;
12793 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
12794 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
12795 ClipCursor(0);
12796 if (pAsyncMouse)
12797 {
12798 pAsyncMouse->Suspend();
12799 return DefWindowProcA(hWnd, Msg, wParam, v4);
12800 }
12801 }
12802 _def_wnd_proc:
12803 v4 = lParam;
12804 return DefWindowProcA(hWnd, Msg, wParam, v4);
12805 }
12806 if ( Msg != WM_KILLFOCUS )
12807 {
12808 if ( Msg == WM_PAINT )
12809 {
12810 if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
12811 return 0;
12812 BeginPaint(hWnd, &Paint);
12813 if ( pArcomageGame->bGameInProgress )
12814 {
12815 pArcomageGame->field_F9 = 1;
12816 v5 = pRenderer;
12817 }
12818 else
12819 {
12820 if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() )
12821 goto LABEL_20;
12822 v5 = pRenderer;
12823 }
12824 pRenderer->Present();
12825 LABEL_20:
12826 EndPaint(hWnd, &Paint);
12827 return 0;
12828 }
12829 goto _def_wnd_proc;
12830 }
12831 if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || !pAsyncMouse )
12832 return DefWindowProcA(hWnd, Msg, wParam, v4);
12833 pAsyncMouse->Resume();
12834 if ( !pAsyncMouse )
12835 goto _def_wnd_proc;
12836 pAsyncMouse->Clip();
12837 return DefWindowProcA(hWnd, Msg, wParam, v4);
12838 }
12839
12840 //----- (00464479) --------------------------------------------------------
12841 void __cdecl ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
12842 {
12843 int v0; // esi@9
12844
12845 if (pMouse)
12846 pMouse->SetCursorBitmap("MICON1");
12847
12848 pPaletteManager->ResetNonLocked();
12849 pBitmaps_LOD->ReleaseAll2();
12850 pSprites_LOD->DeleteSomeOtherSprites();
12851 pIcons_LOD->ReleaseAll2();
12852 if (pRenderer->pRenderD3D)
12853 {
12854 pRenderer->field_1036B8 = 0;
12855 pRenderer->_gpu_memory_used = 0;
12856 }
12857 sub_46080D();
12858 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
12859 pIndoor->Release();
12860 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
12861 pOutdoor->Release2();
12862
12863 pAudioPlayer->StopChannels(-1, -1);
12864 pSoundList->_4A9D79(0);
12865 uCurrentlyLoadedLevelType = LEVEL_null;
12866 pSpriteFrameTable->ResetSomeSpriteFlags();
12867 v0 = uNumVisibleWindows;
12868 pParty->field_1613C = 0;
12869 while ( v0 > 0 )
12870 pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release();
12871 }
12872
12873
12874
12875 //----- (004646F0) --------------------------------------------------------
12876 void PrepareWorld(unsigned int this_)
12877 {
12878 unsigned int v1; // ebx@1
12879
12880 v1 = this_;
12881 if ( pRenderer->pRenderD3D )
12882 pGame->pVisInstance->_4C1A02();
12883 pEventTimer->Pause();
12884 pMiscTimer->Pause();
12885 pParty->uFlags = 2;
12886 pStru277->_427D48(1);
12887 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
12888 DoPrepareWorld(0, (v1 == 0) + 1);
12889 pMiscTimer->Resume();
12890 pEventTimer->Resume();
12891 }
12892
12893 //----- (00464761) --------------------------------------------------------
12894 void __thiscall Game_DeinitializeAndTerminate(int exitCode)
12895 {
12896 int v1; // esi@1
12897 HANDLE v2; // eax@1
12898
12899 v1 = exitCode;
12900 v2 = GetCurrentProcess();
12901 SetPriorityClass(v2, 0x20u);
12902 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
12903 pGame->Deinitialize();
12904 pRenderer->Release2();
12905 if ( !DestroyWindow(hWnd) )
12906 GetLastError();
12907 hWnd = 0;
12908 exit(v1);
12909 }
12910
12911 //----- (004647AB) --------------------------------------------------------
12912 void __cdecl FinalInitialization()
12913 {
12914 pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW);
12915 pViewport->_4C02F8((signed __int64)(flt_6BE3A0 * 65536.0));
12916
12917 pIndoorCamera = new IndoorCamera;
12918 pIndoorCamera->Initialize(
12919 65,
12920 viewparams->uScreenZ - viewparams->uScreenX + 1,
12921 viewparams->uScreenW - viewparams->uScreenY + 1);
12922
12923 InitializeTurnBasedAnimations(&stru_50C198);
12924 pBitmaps_LOD->dword_11B84 = pBitmaps_LOD->uNumLoadedFiles;
12925 pSprites_LOD->field_ECA0 = pSprites_LOD->uNumLoadedSprites;
12926 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles;
12927 }
12928 // 6BE3A0: using guessed type float flt_6BE3A0;
12929
12930 //----- (00464839) --------------------------------------------------------
12931 char __cdecl Is_out15odm_underwater()
12932 {
12933 return _strcmpi(pCurrentMapName, "out15.odm") == 0;
12934 }
12935
12936 //----- (00464851) --------------------------------------------------------
12937 void __cdecl SetUnderwaterFog()
12938 {
12939 day_fogrange_1 = 50;
12940 day_fogrange_2 = 5000;
12941 }
12942
12943
12944
12945 //----- (00464866) --------------------------------------------------------
12946 void __fastcall DoPrepareWorld(unsigned int bLoading, int a2)
12947 {
12948 int v2; // esi@1
12949 char *v3; // eax@1
12950 //char *v4; // eax@1
12951 unsigned int v5; // eax@3
12952 //size_t v6; // ecx@10
12953 //char *v7; // eax@11
12954 char Str1[20]; // [sp+Ch] [bp-18h]@1
12955 unsigned int v9; // [sp+20h] [bp-4h]@1
12956
12957 v2 = a2;
12958 v9 = bLoading;
12959 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
12960 pDecalBuilder->Reset(0);
12961 pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)v2);
12962 strcpy(Str1, pCurrentMapName);
12963 v3 = strtok(Str1, ".");
12964 strcpy(Str1, v3);
12965 Level_LoadEvtAndStr(Str1);
12966 LoadLevel_InitializeLevelEvt();
12967 strcpy(Str1, pCurrentMapName);
12968 _strrev(Str1);
12969 strtok(Str1, ".");
12970 _strrev(Str1);
12971
12972 for (uint i = 0; i < 1000; ++i)
12973 pLayingItems[i].uObjectDescID = 0;
12974
12975 v5 = pMapStats->GetMapInfo(pCurrentMapName);
12976 bUnderwater = 0;
12977 uLevelMapStatsID = v5;
12978 pGame->uFlags2 &= 0xFFFFFFF7u;
12979 if ( !_strcmpi(pCurrentMapName, "out15.odm") )
12980 {
12981 bUnderwater = 1;
12982 pGame->uFlags2 |= 8u;
12983 }
12984 pParty->field_6F4_packedid = 0;
12985 if ( _strcmpi(Str1, "blv") )
12986 PrepareToLoadODM(v9, 0);
12987 else
12988 PrepareToLoadBLV(v9);
12989 pAudioPlayer->SetMapEAX();
12990 sub_461103();
12991 if ( !_strcmpi(pCurrentMapName, "d11.blv") || !_strcmpi(pCurrentMapName, "d10.blv") )
12992 {
12993 //spawning grounds & good analogue - no loot & exp from monsters
12994
12995 for (uint i = 0; i < uNumActors; ++i)
12996 {
12997 pActors[i].pMonsterInfo.uTreasureType = 0;
12998 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0;
12999 pActors[i].pMonsterInfo.uExp = 0;
13000 }
13001 }
13002 bDialogueUI_InitializeActor_NPC_ID = 0;
13003 OnMapLoad();
13004 pGameLoadingUI_ProgressBar->Progress();
13005 pGameLoadingUI_ProgressBar->Release();
13006 _flushall();
13007 }
13008
13009
13010 //----- (004649EF) --------------------------------------------------------
13011 int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue)
13012 {
13013 int v3; // [sp+4h] [bp-24h]@1
13014 DWORD cbData; // [sp+8h] [bp-20h]@1
13015 LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1
13016 DWORD dwDisposition; // [sp+10h] [bp-18h]@2
13017 BYTE Data[4]; // [sp+14h] [bp-14h]@5
13018 HKEY hKey; // [sp+18h] [bp-10h]@1
13019 HKEY phkResult; // [sp+1Ch] [bp-Ch]@1
13020 HKEY v10; // [sp+20h] [bp-8h]@1
13021 HKEY v11; // [sp+24h] [bp-4h]@1
13022
13023 v3 = uDefValue;
13024 lpValueName = pKey;
13025 v11 = 0;
13026 v10 = 0;
13027 hKey = 0;
13028 phkResult = 0;
13029 cbData = 4;
13030 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
13031 {
13032 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
13033 {
13034 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) )
13035 {
13036 if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) )
13037 {
13038 if ( RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) )
13039 {
13040 *(int *)Data = v3;
13041 RegSetValueExA(v11, lpValueName, 0, 4u, Data, 4u);
13042 }
13043 RegCloseKey(v11);
13044 }
13045 RegCloseKey(v10);
13046 }
13047 RegCloseKey(phkResult);
13048 }
13049 RegCloseKey(hKey);
13050 }
13051 return *(int *)Data;
13052 }
13053
13054 //----- (00464B02) --------------------------------------------------------
13055 void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString)
13056 {
13057 size_t v2; // eax@5
13058 const char *lpValueName; // [sp+4h] [bp-1Ch]@1
13059 const char *Str; // [sp+8h] [bp-18h]@1
13060 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
13061 HKEY hKey; // [sp+10h] [bp-10h]@1
13062 HKEY phkResult; // [sp+14h] [bp-Ch]@1
13063 HKEY v8; // [sp+18h] [bp-8h]@1
13064 HKEY v9; // [sp+1Ch] [bp-4h]@1
13065
13066 Str = pString;
13067 lpValueName = pKey;
13068 v9 = 0;
13069 v8 = 0;
13070 hKey = 0;
13071 phkResult = 0;
13072 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
13073 {
13074 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
13075 {
13076 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
13077 {
13078 if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) )
13079 {
13080 v2 = strlen(Str);
13081 RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1);
13082 RegCloseKey(v9);
13083 }
13084 RegCloseKey(v8);
13085 }
13086 RegCloseKey(phkResult);
13087 }
13088 RegCloseKey(hKey);
13089 }
13090 }
13091
13092 //----- (00464BEF) --------------------------------------------------------
13093 void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue)
13094 {
13095 LSTATUS (__stdcall *v4)(HKEY); // esi@1
13096 LSTATUS result; // eax@7
13097 DWORD Type; // [sp+Ch] [bp-24h]@5
13098 LPCSTR lpValueName; // [sp+10h] [bp-20h]@1
13099 DWORD cbData; // [sp+14h] [bp-1Ch]@1
13100 LPBYTE Dest; // [sp+18h] [bp-18h]@1
13101 DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2
13102 HKEY phkResult; // [sp+20h] [bp-10h]@1
13103 HKEY hKey; // [sp+24h] [bp-Ch]@1
13104 HKEY v13; // [sp+28h] [bp-8h]@1
13105 HKEY v14; // [sp+2Ch] [bp-4h]@1
13106
13107 cbData = uBufLen;
13108 Dest = (LPBYTE)pOutString;
13109 lpValueName = pKeyName;
13110 v14 = 0;
13111 v13 = 0;
13112 hKey = 0;
13113 phkResult = 0;
13114 v4 = RegCloseKey;
13115 if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey)
13116 || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
13117 || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
13118 || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
13119 goto LABEL_7;
13120 if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
13121 {
13122 RegCloseKey(v14);
13123 v14 = 0;
13124 LABEL_7:
13125 result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
13126 goto LABEL_8;
13127 }
13128 v4 = RegCloseKey;
13129 RegCloseKey(v14);
13130 v14 = 0;
13131 RegCloseKey(v13);
13132 v13 = 0;
13133 RegCloseKey(phkResult);
13134 phkResult = 0;
13135 result = RegCloseKey(hKey);
13136 hKey = 0;
13137 LABEL_8:
13138 if ( v14 )
13139 result = v4(v14);
13140 if ( v13 )
13141 result = v4(v13);
13142 if ( hKey )
13143 result = v4(hKey);
13144 if ( phkResult )
13145 result = v4(phkResult);
13146 }
13147
13148 //----- (00464D32) --------------------------------------------------------
13149 void __fastcall WriteWindowsRegistryInt(const char *pKey, int val)
13150 {
13151 const char *lpValueName; // [sp+4h] [bp-1Ch]@1
13152 BYTE Data[4]; // [sp+8h] [bp-18h]@1
13153 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
13154 HKEY hKey; // [sp+10h] [bp-10h]@1
13155 HKEY phkResult; // [sp+14h] [bp-Ch]@1
13156 HKEY v7; // [sp+18h] [bp-8h]@1
13157 HKEY v8; // [sp+1Ch] [bp-4h]@1
13158
13159 *(int *)Data = val;
13160 lpValueName = pKey;
13161 v8 = 0;
13162 v7 = 0;
13163 hKey = 0;
13164 phkResult = 0;
13165 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
13166 {
13167 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
13168 {
13169 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) )
13170 {
13171 if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
13172 {
13173 RegSetValueExA(v8, lpValueName, 0, 4u, Data, 4u);
13174 RegCloseKey(v8);
13175 }
13176 RegCloseKey(v7);
13177 }
13178 RegCloseKey(phkResult);
13179 }
13180 RegCloseKey(hKey);
13181 }
13182 }
13183
13184 //----- (00464E17) --------------------------------------------------------
13185 bool __fastcall CheckMM7CD(char c)
13186 {
13187 char DstBuf[256]; // [sp+Ch] [bp-218h]@1
13188 char strCommand[256]; // [sp+10Ch] [bp-118h]@1
13189 char Filename[20]; // [sp+20Ch] [bp-18h]@1
13190
13191
13192 wchar_t pMagicPath[1024];
13193 swprintf(pMagicPath, L"%C:\\anims\\magic7.vid", c);
13194 if (GetFileAttributesW(pMagicPath) == -1)
13195 return false;
13196
13197 wsprintfA(strCommand, "open %c: type cdaudio alias CD", c);
13198 if (!mciSendStringA(strCommand, DstBuf, 0xFFu, 0))
13199 {
13200 wsprintfA(strCommand, "info CD UPC wait");
13201 mciSendStringA(strCommand, DstBuf, 0xFFu, 0);
13202 wsprintfA(strCommand, "close CD");
13203 mciSendStringA(strCommand, DstBuf, 0xFFu, 0);
13204 }
13205
13206 memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename));
13207 *Filename = c;
13208
13209 auto f = fopen(Filename, "rb");
13210 if (!f)
13211 return false;
13212
13213 if (!fseek(f, 0, SEEK_END))
13214 {
13215 if (!fseek(f, -100, SEEK_CUR))
13216 fread(DstBuf, 1u, 0x64u, f);
13217
13218 fclose(f);
13219 return true;
13220 }
13221 fclose(f);
13222 return false;
13223 }
13224
13225 //----- (00464F1B) --------------------------------------------------------
13226 signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4)
13227 {
13228 char v4; // zf@3
13229 int v6; // eax@10
13230 int v7; // eax@11
13231 int v8; // eax@12
13232 int v9; // eax@13
13233 BOOL (__stdcall *v10)(HWND, int, LPCSTR); // edi@15
13234 const CHAR *v11; // [sp-Ch] [bp-Ch]@15
13235 INT_PTR v12; // [sp-4h] [bp-4h]@5
13236
13237 if ( a2 == 272 )
13238 {
13239 hInsertCDWindow = hDlg;
13240 v6 = (GetUserDefaultLangID() & 0x3FF) - 7;
13241 if ( v6 )
13242 {
13243 v7 = v6 - 3;
13244 if ( v7 )
13245 {
13246 v8 = v7 - 2;
13247 if ( v8 )
13248 {
13249 v9 = v8 - 4;
13250 if ( v9 )
13251 {
13252 if ( v9 != 5 )
13253 return 0;
13254 SetWindowTextA(hDlg, "Wloz CD-ROM numer 2");
13255 v10 = SetDlgItemTextA;
13256 SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII.");
13257 v11 = "Odwolaj";
13258 }
13259 else
13260 {
13261 SetWindowTextA(hDlg, "Inserire il secondo CD");
13262 v10 = SetDlgItemTextA;
13263 SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII.");
13264 v11 = "Annulla";
13265 }
13266 }
13267 else
13268 {
13269 SetWindowTextA(hDlg, "Insérez le CD 2");
13270 v10 = SetDlgItemTextA;
13271 SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2.");
13272 v11 = "Supprimer";
13273 }
13274 }
13275 else
13276 {
13277 SetWindowTextA(hDlg, "Por favor, inserte disco 2");
13278 v10 = SetDlgItemTextA;
13279 SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII.");
13280 v11 = "Cancelar";
13281 }
13282 }
13283 else
13284 {
13285 SetWindowTextA(hDlg, "Bitte CD 2 einlegen");
13286 v10 = SetDlgItemTextA;
13287 SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen.");
13288 v11 = "Abbrechen";
13289 }
13290 v10(hDlg, 2, v11);
13291 return 0;
13292 }
13293 if ( a2 == 273 )
13294 {
13295 if ( a3 == 2 )
13296 {
13297 v12 = 0;
13298 LABEL_9:
13299 EndDialog(hDlg, v12);
13300 return 1;
13301 }
13302 v4 = a3 == 1;
13303 }
13304 else
13305 {
13306 v4 = a2 == 1025;
13307 }
13308 if ( v4 )
13309 {
13310 v12 = 1;
13311 goto LABEL_9;
13312 }
13313 return 0;
13314 }
13315
13316 //----- (00465061) --------------------------------------------------------
13317 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive)
13318 {
13319 char drive[4] = {'X', ':', '\\', 0};
13320
13321 bool bGotCDFromRegistry = false;
13322
13323 HKEY hSoftware = nullptr,
13324 hNWC = nullptr,
13325 hMM7 = nullptr,
13326 hVersion = nullptr;
13327 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hSoftware))
13328 {
13329 if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, 0x2001Fu, &hNWC))
13330 {
13331 if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, 0x2001Fu, &hMM7))
13332 {
13333 if (!RegOpenKeyExA(hMM7, "1.0", 0, 0x2001Fu, &hVersion))
13334 {
13335 DWORD cbData = 3;
13336 if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData))
13337 bGotCDFromRegistry = true;
13338 }
13339 RegCloseKey(hVersion);
13340 }
13341 RegCloseKey(hMM7);
13342 }
13343 RegCloseKey(hNWC);
13344 }
13345 RegCloseKey(hSoftware);
13346
13347 if (bGotCDFromRegistry)
13348 if (CheckMM7CD(*drive))
13349 {
13350 cMM7GameCDDriveLetter = *drive;
13351 return true;
13352 }
13353
13354 while (true)
13355 {
13356 for (uint i = 0; i < 26; ++i)
13357 {
13358 drive[0] = 'A' + i;
13359
13360 if (GetDriveTypeA(drive) == DRIVE_CDROM)
13361 if (CheckMM7CD(*drive))
13362 {
13363 cMM7GameCDDriveLetter = *drive;
13364 WriteWindowsRegistryString("CDDrive", drive);
13365 return true;
13366 }
13367 }
13368
13369 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", ::hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0))
13370 continue;
13371 return false;
13372 }
13373 }
13374
13375 //----- (004651F4) --------------------------------------------------------
13376 bool MM7_Initialize()
13377 {
13378 wchar_t pCurrentDir[1024];
13379 _wgetcwd(pCurrentDir, 1024);
13380
13381 wchar_t pMM6IniFile[1024];
13382 wsprintf(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir);
13383
13384 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile);
13385 if (bNoCD)
13386 bCanLoadFromCD = false;
13387 if (bCanLoadFromCD)
13388 {
13389 if (!FindMM7CD(hWnd, &cMM7GameCDDriveLetter))
13390 return false;
13391 }
13392
13393
13394
13395 srand(GetTickCount());
13396 /*GetDiskFreeSpaceA(0, &SectorsPerCluster, &BytesPerSector, &hdc, &TotalNumberOfClusters);
13397 v4 = hdc * BytesPerSector * SectorsPerCluster;
13398 if ( (unsigned int)v4 < 0x1E00000 )
13399 {
13400 sprintfex(
13401 pTmpBuf,
13402 "Due to Window Virtual Memory requirements Might and Magic® VII\nrequires 30MB of free hard drive space to operate properly.\n\nAvailable on Current Drive = %luk",
13403 (unsigned int)v4 / 1024i64);
13404 v41 = 48;
13405 v40 = "More Hard Drive Space Required";
13406 v39 = pTmpBuf;
13407 */
13408
13409 WNDCLASSEXW wcxw;
13410 {
13411 wcxw.cbSize = sizeof(wcxw);
13412 wcxw.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
13413 wcxw.lpfnWndProc = (WNDPROC)aWinProc;
13414 wcxw.cbClsExtra = 0;
13415 wcxw.cbWndExtra = 0;
13416 wcxw.hInstance = GetModuleHandleW(nullptr);
13417 wcxw.hCursor = 0;
13418 wcxw.hIcon = wcxw.hIconSm = LoadIconW(wcxw.hInstance, L"MM7_ICON");
13419 wcxw.lpszMenuName = nullptr;
13420 wcxw.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
13421 wcxw.lpszClassName = L"M&MTrilogy";
13422 }
13423 if (!RegisterClassExW(&wcxw))
13424 {
13425 Log::Warning(L"Cannot register window class");
13426 return false;
13427 }
13428
13429 auto hDesktopDC = GetDC(nullptr);
13430 uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES);
13431 uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES);
13432
13433 if (GetDeviceCaps(hDesktopDC, BITSPIXEL) != 16 ||
13434 GetDeviceCaps(hDesktopDC, PLANES) != 1 )
13435 dword_6BE364_game_settings_1 |= 2;
13436
13437 ReleaseDC(nullptr, hDesktopDC);
13438
13439
13440 uint uTotalWinWidth = 2 * GetSystemMetrics(SM_CXFRAME) + 640;
13441 uint uTotalWinHeight = GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYFRAME) + 480;
13442
13443 uint uWinCenteredPosX = (uDesktopWidth - uTotalWinWidth) / 2;
13444 uint uWinCenteredPosY = (uDesktopHeight - uTotalWinHeight) / 2;
13445
13446 uWindowX = ReadWindowsRegistryInt("window X", uWinCenteredPosX);
13447 uWindowX = 0;
13448 WriteWindowsRegistryInt("window X", uWindowX);
13449
13450 uWindowY = ReadWindowsRegistryInt("window Y", uWinCenteredPosY);
13451 uWindowY = 0;
13452 WriteWindowsRegistryInt("window Y", uWindowY);
13453
13454 hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic® VII",
13455 uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
13456 uWindowX, uWindowY,
13457 640, 480,
13458 nullptr,
13459 hOSMenu = nullptr,
13460 wcxw.hInstance,
13461 nullptr);
13462 SetWindowTextW(hWnd, L"Might and Magic® VII");
13463
13464 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
13465
13466 pRenderer = Render::Create();
13467 if (!pRenderer)
13468 {
13469 Log::Warning(L"Render creation failed");
13470 return false;
13471 }
13472 else
13473 {
13474 bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false);
13475 uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1);
13476 bool bColoredLights = ReadWindowsRegistryInt("Colored Lights", false);
13477 uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1);
13478 uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0;
13479
13480 if (!pRenderer->Initialize(bWindowMode, uDefaultDevice, bColoredLights, uLevelOfDetail, bTinting))
13481 {
13482 Log::Warning(L"Render failed to initialize");
13483 return false;
13484 }
13485 }
13486
13487 pAllocator = Allocator::Create();
13488 if (!pAllocator->Initialize(26 * 1024))
13489 {
13490 MessageBoxW(nullptr,
13491 L"Unable to Allocate 26Mb of RAM",
13492 L"More RAM Memory Required", MB_ICONEXCLAMATION);
13493 return false;
13494 }
13495
13496
13497 pParty = new Party;
13498 pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile);
13499 pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile);
13500 pParty->sEyelevel = pParty->uDefaultEyelevel;
13501 pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile);
13502 pParty->uPartyHeight = pParty->uDefaultPartyHeight;
13503
13504 bUseRegistry = GetPrivateProfileIntW(L"settings", L"registry", 1, pMM6IniFile);
13505 MM6_Initialize(pMM6IniFile);
13506
13507 pKeyActionMap = new KeyboardActionMapping;
13508
13509 pEventTimer = Timer::Create();
13510 pEventTimer->Initialize();
13511
13512 OnTimer(1);
13513 GameUI_StatusBar_UpdateTimedString(1);
13514 pGame = Game::Create();
13515 pMouse = pGame->pMouseInstance;
13516
13517
13518 RECT rcWindow;
13519 GetWindowRect(hWnd, &rcWindow);
13520
13521 RECT rcClient;
13522 GetClientRect(hWnd, &rcClient);
13523 uWindowWidth = rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640;
13524 uWindowHeight = rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480;
13525 MoveWindow(hWnd, uWindowX, uWindowY,
13526 rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640,
13527 rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0);
13528 ShowWindow(hWnd, SW_SHOWNORMAL);
13529
13530 pIcons_LOD = new LODFile_IconsBitmaps;
13531 if (!pIcons_LOD->LoadIconsOrEvents("data\\icons.lod"))
13532 {
13533 MessageBoxW(nullptr,
13534 L"Some files are missing\n\nPlease Reinstall.",
13535 L"Files Missing", MB_ICONEXCLAMATION);
13536 return false;
13537 }
13538 pIcons_LOD->dword_011BA4 = 0;
13539
13540 pEvents_LOD = new LODFile_IconsBitmaps;
13541 if (!pEvents_LOD->LoadIconsOrEvents("data\\events.lod"))
13542 {
13543 MessageBoxW(nullptr,
13544 L"Some files are missing\n\nPlease Reinstall.",
13545 L"Files Missing", MB_ICONEXCLAMATION);
13546 return false;
13547 }
13548
13549 InitializeGameText();
13550
13551 pBitmaps_LOD = new LODFile_IconsBitmaps;
13552 if (!pBitmaps_LOD->LoadBitmaps("data\\bitmaps.lod"))
13553 {
13554 MessageBoxA(nullptr,
13555 pGlobalTXT_LocalizationStrings[63],
13556 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION);
13557 return false;
13558 }
13559
13560 if (bUseRegistry)
13561 bUseLoResSprites = ReadWindowsRegistryInt("resolution", 0);
13562 else
13563 bUseLoResSprites = GetPrivateProfileIntW(L"settings", L"resolution", 0, pMM6IniFile);
13564
13565 const char *pSpritesFile = nullptr;
13566 if (bUseLoResSprites)
13567 pSpritesFile = "data\\spriteLO.lod";
13568 else
13569 pSpritesFile = "data\\sprites.lod";
13570
13571 pSprites_LOD = new LODFile_Sprites;
13572 if (!pSprites_LOD->LoadSprites(pSpritesFile))
13573 {
13574 MessageBoxA(nullptr,
13575 pGlobalTXT_LocalizationStrings[63],
13576 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION);
13577 return false;
13578 }
13579
13580 if (bDebugResouces)
13581 {
13582 pSpriteFrameTable = new SpriteFrameTable;
13583 if (!pSpriteFrameTable->FromFileTxt("data\\sft.txt"))
13584 Abortf("Unable to open sft.txt");
13585
13586 pDecorationList = new DecorationList;
13587 if (!pDecorationList->FromFileTxt("data\\declist.txt"))
13588 Abortf("Unable to open declist.txt");
13589
13590 pObjectList = new ObjectList;
13591 if (!pObjectList->FromFileTxt("data\\objlist.txt"))
13592 Abortf("Unable to open objlist.txt");
13593
13594 pMonsterList = new MonsterList;
13595 if (!pMonsterList->FromFileTxt("data\\monlist.txt"))
13596 Abortf("Unable to open monlist.txt");
13597
13598 pIconsFrameTable = new IconFrameTable;
13599 if (!pIconsFrameTable->FromFileTxt("data\\ift.txt"))
13600 Abortf("Unable to open ift.txt");
13601
13602 pTextureFrameTable = new TextureFrameTable;
13603 if (!pTextureFrameTable->FromFileTxt("data\\tft.def"))
13604 Abortf("Unable to open tft.def");
13605
13606 pTileTable = new TileTable;
13607 if (!pTileTable->FromFileTxt("data\\tile.def"))
13608 Abortf("Unable to open tile.def");
13609
13610 pPlayerFrameTable = new PlayerFrameTable;
13611 if (!pPlayerFrameTable->FromFileTxt("data\\pft.def"))
13612 Abortf("Unable to open pft.def");
13613
13614 pChestList = new ChestList;
13615 if (!pChestList->FromFileTxt("data\\chest.def"))
13616 Abortf("Unable to open chest.def");
13617
13618 pOverlayList = new OverlayList;
13619 if (!pOverlayList->FromFileTxt("data\\overlay.def"))
13620 Abortf("Unable to open overlay.def");
13621
13622 pSoundList = new SoundList;
13623 if (!pSoundList->FromFileTxt("data\\sounds.def"))
13624 Abortf("Unable to open sounds.def");
13625 }
13626 else
13627 {
13628 auto pSFT = pEvents_LOD->LoadRaw("dsft.bin", 1);
13629 pSpriteFrameTable = new SpriteFrameTable;
13630 pSpriteFrameTable->FromFile(pSFT);
13631 free(pSFT);
13632
13633 auto pTFT = pEvents_LOD->LoadRaw("dtft.bin", 1);
13634 pTextureFrameTable = new TextureFrameTable;
13635 pTextureFrameTable->FromFile(pTFT);
13636 free(pTFT);
13637
13638 auto pTiles = pEvents_LOD->LoadRaw("dtile.bin", 1);
13639 pTileTable = new TileTable;
13640 pTileTable->FromFile(pTiles);
13641 free(pTiles);
13642
13643 auto pPFT = pEvents_LOD->LoadRaw("dpft.bin", 1);
13644 pPlayerFrameTable = new PlayerFrameTable;
13645 pPlayerFrameTable->FromFile(pPFT);
13646 free(pPFT);
13647
13648 auto pIFT = pEvents_LOD->LoadRaw("dift.bin", 1);
13649 pIconsFrameTable = new IconFrameTable;
13650 pIconsFrameTable->FromFile(pIFT);
13651 free(pIFT);
13652
13653 auto pDecs = pEvents_LOD->LoadRaw("ddeclist.bin", 1);
13654 pDecorationList = new DecorationList;
13655 pDecorationList->FromFile(pDecs);
13656 free(pDecs);
13657
13658 auto pObjs = pEvents_LOD->LoadRaw("dobjlist.bin", 1);
13659 pObjectList = new ObjectList;
13660 pObjectList->FromFile(pObjs);
13661 free(pObjs);
13662
13663 auto pMons = pEvents_LOD->LoadRaw("dmonlist.bin", 1);
13664 pMonsterList = new MonsterList;
13665 pMonsterList->FromFile(pMons);
13666 free(pMons);
13667
13668 auto pChests = pEvents_LOD->LoadRaw("dchest.bin", 1);
13669 pChestList = new ChestList;
13670 pChestList->FromFile(pChests);
13671 free(pChests);
13672
13673 auto pOverlays = pEvents_LOD->LoadRaw("doverlay.bin", 1);
13674 pOverlayList = new OverlayList;
13675 pOverlayList->FromFile(pOverlays);
13676 free(pOverlays);
13677
13678 auto pSounds = pEvents_LOD->LoadRaw("dsounds.bin", 1);
13679 pSoundList = new SoundList;
13680 pSoundList->FromFile(pSounds);
13681 free(pSounds);
13682 }
13683
13684
13685 if (bDebugResouces)
13686 {
13687 pSpriteFrameTable->ToFile();
13688 pDecorationList->ToFile();
13689 pObjectList->ToFile();
13690 pMonsterList->ToFile();
13691 pIconsFrameTable->ToFile();
13692 pTextureFrameTable->ToFile();
13693 pTileTable->ToFile();
13694 pPlayerFrameTable->ToFile();
13695 pChestList->ToFile();
13696 pOverlayList->ToFile();
13697 pSoundList->ToFile();
13698 }
13699
13700
13701 if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & 1))//
13702 // color depth != 16
13703 // or
13704 // not in window
13705 {
13706 SetMenu(hWnd, 0);
13707 SetWindowLongA(hWnd, GWL_EXSTYLE, 0);
13708 SetWindowLongA(hWnd, GWL_STYLE, WS_VISIBLE);
13709 if (pAsyncMouse)
13710 pAsyncMouse->Clip();
13711 pRenderer->InitializeFullscreen(hWnd);
13712 }
13713 else
13714 {
13715 ClipCursor(nullptr);
13716 pRenderer->SwitchToWindow(hWnd);
13717 }
13718
13719 uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9);
13720 if (uSoundVolumeMultiplier > 9)
13721 uSoundVolumeMultiplier = 9;
13722 uMusicVolimeMultiplier = ReadWindowsRegistryInt("musicflag", 9);
13723 if (uMusicVolimeMultiplier > 9)
13724 uMusicVolimeMultiplier = 9;
13725 uVoicesVolumeMultiplier = ReadWindowsRegistryInt("CharVoices", 9);
13726 if (uVoicesVolumeMultiplier > 9)
13727 uVoicesVolumeMultiplier = 9;
13728 bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0;
13729 byte_6BE388_graphicsmode = ReadWindowsRegistryInt("graphicsmode", 1);
13730 if (byte_6BE388_graphicsmode < 0 || byte_6BE388_graphicsmode > 2)
13731 byte_6BE388_graphicsmode = 0;
13732
13733 uGammaPos = ReadWindowsRegistryInt("GammaPos", 4);
13734 if (uGammaPos < 0 || uGammaPos > 9)
13735 uGammaPos = 4;
13736 pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6);
13737
13738 if ( ReadWindowsRegistryInt("Bloodsplats", 1) )
13739 pGame->uFlags2 |= 0x20u;
13740 else
13741 pGame->uFlags2 &= 0xFFFFFFDFu;
13742
13743 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0);
13744 dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0);
13745
13746 if (!bNoSound)
13747 pAudioPlayer->Initialize(hWnd);
13748
13749 pVideoPlayer = new VideoPlayer;
13750 pVideoPlayer->Initialize();
13751
13752 dword_6BE364_game_settings_1 |= 0x4000;
13753
13754 if ( uTurnSpeed )
13755 {
13756 switch ( uTurnSpeed )
13757 {
13758 case 1u:
13759 uTurnSpeed = 128;
13760 break;
13761 case 2u:
13762 uTurnSpeed = 64;
13763 break;
13764 case 3u:
13765 uTurnSpeed = 0;
13766 break;
13767 }
13768 }
13769 else
13770 {
13771 uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64;
13772 }
13773 return true;
13774 }
13775
13776
13777
13778
13779 //----- (00465D0B) --------------------------------------------------------
13780 void __cdecl SecondaryInitialization()
13781 {
13782 __int16 v4; // ax@4
13783 signed int v5; // esi@5
13784 int v6; // ecx@6
13785 int v7; // edx@7
13786 ObjectDesc *v8; // eax@7
13787 char pContainer[32]; // [sp+10h] [bp-Ch]@9
13788
13789 pMouse->Initialize(hWnd);
13790 CreateAsyncMouse();
13791 CreateAsyncKeyboard();
13792
13793 pItemsTable = new ItemsTable;
13794 pItemsTable->Initialize();
13795
13796 pBitmaps_LOD->dword_011BA8 = 1;
13797 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
13798 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
13799 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
13800 pPaletteManager->pPalette_mistColor[0] = 128;
13801 pPaletteManager->pPalette_mistColor[1] = 128;
13802 pPaletteManager->pPalette_mistColor[2] = 128;
13803 pPaletteManager->RecalculateAll();
13804 pSprites_LOD->field_ECAC = 1;
13805 pObjectList->InitializeSprites();
13806 pOverlayList->InitializeSprites();
13807 if (!bNoSound)
13808 pSoundList->Initialize();
13809
13810 static const char *pUIAnimNames[4] =
13811 {
13812 "glow03", "glow05",
13813 "torchA", "wizeyeA"
13814 };
13815 static unsigned short _4E98D0[4][4] =
13816 {
13817 {479, 0, 329, 0},
13818 {585, 0, 332, 0},
13819 {468, 0, 0, 0},
13820 {606, 0, 0, 0}
13821 };
13822
13823
13824 for (uint i = 0; i < 4; ++i)
13825 {
13826 pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]);
13827 pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID);
13828
13829 pUIAnims[i]->uAnimLength = 0;
13830 pUIAnims[i]->uAnimTime = 0;
13831 pUIAnims[i]->x = _4E98D0[i][0];
13832 pUIAnims[i]->y = _4E98D0[i][2];
13833 }
13834
13835 v5 = 0;
13836 if ( (signed int)pObjectList->uNumObjects > 0 )
13837 {
13838 v6 = 0;
13839 do
13840 {
13841 BYTE3(v7) = 0;
13842 v8 = &pObjectList->pObjects[v6];
13843 ++v6;
13844 *(short *)((char *)&v7 + 1) = v8->uParticleTrailColorR;
13845 LOBYTE(v7) = v8->uParticleTrailColorG;
13846 ++v5;
13847 v8->uParticleTrailColor = v8->uParticleTrailColorB | (v7 << 8);
13848 }
13849 while ( v5 < (signed int)pObjectList->uNumObjects );
13850 }
13851 flt_6BE3A0 = 0.55000001f;
13852 MainMenuUI_Create();
13853 pGame->pStru6Instance->LoadAnimations();
13854
13855 for (uint i = 0; i < 7; ++i)
13856 {
13857 sprintf(pContainer, "HDWTR%03u", i);
13858 pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(pContainer);
13859 }
13860
13861 pNPCStats = new NPCStats;
13862 pNPCStats->Initialize();
13863
13864 Initialize_GlobalEVT();
13865 pBitmaps_LOD->dword_11B80 = pBitmaps_LOD->uNumLoadedFiles;
13866 if ( pBitmaps_LOD->dword_11B84 < (signed int)pBitmaps_LOD->uNumLoadedFiles )
13867 pBitmaps_LOD->dword_11B84 = pBitmaps_LOD->uNumLoadedFiles;
13868 pSprites_LOD->field_ECA4 = pSprites_LOD->uNumLoadedSprites;
13869 if ( pSprites_LOD->field_ECA0 < (signed int)pSprites_LOD->uNumLoadedSprites )
13870 pSprites_LOD->field_ECA0 = pSprites_LOD->uNumLoadedSprites;
13871 pPaletteManager->LockAll();
13872
13873 _mkdir("Saves");
13874 for (uint i = 0; i < 5; ++i)
13875 for (uint j = 0; j < 6; ++j)
13876 {
13877 sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j);
13878 remove(pTmpBuf);
13879 }
13880 /*do
13881 {
13882 v11 = 1;
13883 do
13884 {
13885 sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", v10, v11);
13886 remove(pTmpBuf);
13887 ++v11;
13888 }
13889 while ( v11 < 6 );
13890 ++v10;
13891 }
13892 while ( v10 < 5 );*/
13893
13894 Initialize_GamesLOD_NewLOD();
13895 dword_576E2C = 512;
13896 dword_576E28 = 9;
13897 }
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907 //----- (00462C94) --------------------------------------------------------
13908 bool MM_Main(const wchar_t *pCmdLine)
13909 {
13910 HWND hPrevWnd; // eax@1
13911 HWND hPrevWnd_; // esi@1
13912 HWND v6; // eax@4
13913 int v8; // eax@15
13914 //bool v9; // edx@16
13915 //OtherOverlay *v10; // esi@44
13916 //signed int v11; // edi@44
13917 unsigned int v12; // ecx@56
13918 HANDLE v13; // eax@68
13919 unsigned int startms; // [sp+8h] [bp-24h]@55
13920 RECT Rect; // [sp+Ch] [bp-20h]@15
13921 int a2[4]; // [sp+1Ch] [bp-10h]@15
13922
13923 auto mm7text_dll = LoadLibraryW(L"mm7text.dll");
13924 sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex");
13925
13926 if (pCmdLine && *pCmdLine)
13927 {
13928 if (wcsstr(pCmdLine, L"-usedefs"))
13929 bDebugResouces = 1;
13930 if (wcsstr(pCmdLine, L"-window"))
13931 dword_6BE368_debug_settings_2 |= 1u;
13932
13933 if (wcsstr(pCmdLine, L"-nointro"))
13934 bNoIntro = true;//dword_6BE364_game_settings_1 |= 4;
13935 if (wcsstr(pCmdLine, L"-nologo"))
13936 bNoLogo = true;//dword_6BE364_game_settings_1 |= 8;
13937 if (wcsstr(pCmdLine, L"-nosound"))
13938 bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10;
13939
13940 bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
13941 if (wcsstr(pCmdLine, L"-nowalksound"))
13942 bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20;
13943 if (wcsstr(pCmdLine, L"-noanim"))
13944 {
13945 dword_6BE364_game_settings_1 |= 0x40;
13946 bNoVideo = true;
13947 }
13948 if (wcsstr(pCmdLine, L"-nocd"))
13949 bNoCD = true;
13950 }
13951 stru_51076C.registry_debug_flags = ReadWindowsRegistryInt("debug flags", 0);
13952
13953
13954 v8 = sub_4AC1C9(0, (Vec4_int_ *)a2);
13955 Rect.left = *(int *)v8;
13956 Rect.top = *(int *)(v8 + 4);
13957 Rect.right = *(int *)(v8 + 8);
13958 Rect.bottom = *(int *)(v8 + 12);
13959 uCPUSpeed = Rect.bottom;
13960
13961 if (MM7_Initialize())
13962 {
13963 Log::Warning(L"MM init: ok");
13964
13965 pEventTimer->Pause();
13966 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
13967 {
13968 SetWindowPos(hWnd, (HWND)((int)HWND_MESSAGE|0x2), 320, 240, 640, 480, 0);
13969 Rect.left = 325;
13970 Rect.top = 245;
13971 Rect.right = 326;
13972 Rect.bottom = 246;
13973 ClipCursor(&Rect);
13974 }
13975 SetUserInterface(1, false);
13976 ShowIntroVideo_and_LoadingScreen();
13977 WriteWindowsRegistryInt("Ran once", 1);
13978 dword_6BE364_game_settings_1 |= 0x4000;
13979 pGame->InitializeGammaController();
13980 SecondaryInitialization();
13981 pRenderer->Clip_v2(0, 0, 639u, 479u);
13982 FinalInitialization();
13983
13984 Log::Warning(L"MM: entering main loop");
13985 while ( 1 )
13986 {
13987 MainMenu_Loop(); // ïðîðèñîâêà Ãëàâíîãî ìåíþ è òóò æå ïðîðèñîâêà ìåíþ Çàãðóçêà
13988 uGameState = 0;
13989 //LABEL_21:
13990 while ( 1 )
13991 {
13992 switch (uGameState)
13993 {
13994 case GAME_FINISHED: // âûõîä èç èãðû
13995 pGame->Deinitialize();
13996 return true; // âûõîä èç ôóíêöèè MM_Main â Win_Main
13997 }
13998 if (GetCurrentMenuID() == MENU_FINISHED) // ìåíþ Âûõîä
13999 {
14000 uGameState = GAME_FINISHED;
14001 continue; // â íà÷àëî öèêëà
14002 }
14003 if (GetCurrentMenuID() == MENU_NEWGAME) // ìåíþ Íîâàÿ èãðà
14004 {
14005 if ( pAudioPlayer->hAILRedbook )
14006 AIL_redbook_stop(pAudioPlayer->hAILRedbook); // îñòàíîâèòü ìóçûêó
14007 pParty->Reset(); // ñáðîñ ãðóïïû
14008 for (uint k = 0; k < 50; ++k)
14009 pOtherOverlayList->pOverlays[k].Reset();
14010 strcpy(pCurrentMapName, pStartingMapName); // òåêóùàÿ êàðòà
14011 pParty->CreateDefaultParty(0); // ñîçäàòü ãðóïïó ïî óìîë÷àíèþ
14012 PlayerCreationUI_Initialize();
14013 if ( PlayerCreationUI_Loop() ) //ïðîöåññ ñîçäàíèÿ ãðóïïû
14014 {
14015 DeleteCCharFont();
14016 break;// âûõîä èç öèêëà
14017 }
14018 DeleteCCharFont();
14019 bFlashQuestBook = true;
14020 pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); //çàñòàâêà
14021 Autosave(); //àâòîñîõðàíåíèå
14022 //goto LABEL_48;
14023 pGame->Loop(); // ïðîöåññ èãðû
14024 break; // âûõîä èç öèêëà
14025 }
14026 if (GetCurrentMenuID() == MENU_CREDITS) // ìåíþ Ñîçäàòåëè
14027 {
14028 if ( pAudioPlayer->hAILRedbook )
14029 AIL_redbook_stop(pAudioPlayer->hAILRedbook);// îòêëþ÷èòü çâóê
14030 extern MENU_STATE __cdecl CreditsMenu__Loop();
14031 CreditsMenu__Loop(); // ïðîöåññ âîñïðîèçâåäåíèÿ îêíà Ñîçäàòåëè
14032 break;
14033 }
14034 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LOAD) //??? íåèçâåñòíî ÷òî ýòî
14035 __debugbreak();
14036 /*{
14037 uGameState = 0;
14038 }*/
14039 else
14040 __debugbreak();// ïîêà áðÿêïîèíòû
14041 /*{
14042 if (GetCurrentMenuID() != MENU_10)
14043 goto LABEL_49;
14044 pMouse->Activate(0);
14045 if (pAsyncMouse)
14046 pAsyncMouse->Suspend();
14047 if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
14048 pAsyncKeyboard->Suspend();
14049 pParty->Reset();
14050 pParty->CreateDefaultParty(1);
14051 crt_init_globals_46271C();
14052 extern OPENFILENAMEA ofn;
14053 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
14054 {
14055 pMouse->Activate(1);
14056 if (pAsyncMouse)
14057 pAsyncMouse->Resume();
14058 if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
14059 pAsyncKeyboard->Resume();
14060 break;
14061 }
14062 _chdir("..\\");
14063 strcpy(pCurrentMapName, ofn.lpstrFileTitle);
14064 pMouse->Activate(1);
14065 if (pAsyncMouse)
14066 pAsyncMouse->Resume();
14067 if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
14068 pAsyncKeyboard->Resume();
14069 }
14070 //LABEL_48:
14071 // pGame->Loop(); //game
14072 LABEL_49:*/
14073 if ( uGameState == 3 )
14074 __debugbreak();
14075 /*{
14076 v12 = 5;
14077 SetCurrentMenuID((MENU_STATE)v12);
14078 //goto LABEL_21;
14079 uGameState = 0;
14080 continue;
14081 }*/
14082 if ( uGameState == 4 )
14083 __debugbreak();
14084 /*{
14085 v12 = 1;
14086 SetCurrentMenuID((MENU_STATE)v12);
14087 //goto LABEL_21;
14088 uGameState = 0;
14089 continue;
14090 }*/
14091 if ( uGameState == 7 )
14092 __debugbreak();
14093 /*{
14094 pAudioPlayer->StopChannels(-1, -1);
14095 uGameState = 0;
14096 break;
14097 }*/
14098 }
14099 if (!bNoSound && pAudioPlayer->hAILRedbook)
14100 {
14101 pAudioPlayer->SetMusicVolume((pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
14102 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
14103 unsigned int end_ms;
14104 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms);
14105 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
14106 }
14107 }
14108 }
14109 else
14110 Log::Warning(L"MM init: failed");
14111 pGame->Deinitialize();
14112 }
14113
14114
14115
14116
14117
14118 //----- (004637E0) --------------------------------------------------------
14119 char __cdecl sub_4637E0_is_there_popup_onscreen()
14120 {
14121 return dword_507BF0_is_there_popup_onscreen == 1;
14122 }
14123 // 507BF0: using guessed type int dword_507BF0_is_there_popup_onscreen;
14124
14125
14126
14127 //----- (00465F5A) --------------------------------------------------------
14128 void __cdecl CreateAsyncMouse()
14129 {
14130 LOG_DECOMPILATION_WARNING();
14131 /*
14132 if (!pAsyncMouse &&
14133 pRenderer->bUserDirect3D &&
14134 pRenderer->uAcquiredDirect3DDevice == 1)
14135 {
14136 pAsyncMouse = new AsyncMouse(&pRenderer->pDirectDraw4);
14137 if (pAsyncMouse)
14138 pAsyncMouse->Resume();
14139 }*/
14140 }
14141
14142 //----- (00465FF0) --------------------------------------------------------
14143 void __cdecl CreateAsyncKeyboard()
14144 {
14145 LOG_DECOMPILATION_WARNING();
14146 /*
14147 if (!pAsyncKeyboard &&
14148 pGame->pKeyboardInstance->bUsingAsynKeyboard)
14149 {
14150 pAsyncKeyboard = new AsyncKeyboard;
14151 if (pAsyncKeyboard)
14152 pAsyncKeyboard->Resume();
14153 }*/
14154 }
14155
14156 //----- (00466082) --------------------------------------------------------
14157 void MM6_Initialize(const wchar_t *pIniFilename)
14158 {
14159 //int v0; // eax@1
14160 UINT v1; // eax@18
14161 size_t v2; // eax@31
14162 size_t v3; // ebx@32
14163 size_t v4; // edi@36
14164 //char v5[120]; // [sp+Ch] [bp-17Ch]@1
14165 //char String[120]; // [sp+84h] [bp-104h]@32
14166 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32
14167 //char pIniFilename[120]; // [sp+10Ch] [bp-7Ch]@1
14168 unsigned int v9; // [sp+184h] [bp-4h]@28
14169
14170 //_getcwd(v5, 120);
14171 //sprintfex(pIniFilename, "%s\\mm6.ini", v5);
14172 viewparams = new ViewingParams;
14173 viewparams->uScreenX = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
14174 viewparams->uScreenY = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
14175 viewparams->uScreenZ = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename);
14176 viewparams->uScreenW = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename);
14177
14178
14179 pAudioPlayer = new AudioPlayer;
14180 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename);
14181 if ( pAudioPlayer->uMixerChannels > 16 )
14182 pAudioPlayer->uMixerChannels = 16;
14183
14184
14185 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename))
14186 dword_6BE368_debug_settings_2 |= 4;
14187 if (bUseRegistry)
14188 v1 = ReadWindowsRegistryInt("startinwindow", 0);
14189 else
14190 v1 = GetPrivateProfileIntW(L"debug", L"startinwindow", 0, pIniFilename);
14191 if (v1)
14192 dword_6BE368_debug_settings_2 |= 1;
14193 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename))
14194 dword_6BE368_debug_settings_2 |= 2;
14195 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename))
14196 dword_6BE368_debug_settings_2 |= 0x10;
14197 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename))
14198 dword_6BE368_debug_settings_2 |= 8;
14199
14200 wchar_t pStartingMapNameW[1024];
14201 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename);
14202 sprintf(pStartingMapName, "%S", pStartingMapNameW);
14203
14204 v9 = 0;
14205 if ( strlen(pStartingMapName) )
14206 {
14207 do
14208 {
14209 if ( pStartingMapName[v9] == 32 )
14210 pStartingMapName[v9] = 0;
14211 ++v9;
14212 v2 = strlen(pStartingMapName);
14213 }
14214 while ( v9 < v2 );
14215 }
14216
14217 pOutdoorCamera = new OutdoorCamera;
14218 outdoor_day_top_r = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.r", 81, pIniFilename);
14219 outdoor_day_top_g = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.g", 121, pIniFilename);
14220 outdoor_day_top_b = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.b", 236, pIniFilename);
14221 outdoor_day_bottom_r = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.r", 153, pIniFilename);
14222 outdoor_day_bottom_g = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.g", 193, pIniFilename);
14223 outdoor_day_bottom_b = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.b", 237, pIniFilename);
14224 outdoor_night_top_r = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.r", 0, pIniFilename);
14225 outdoor_night_top_g = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.g", 0, pIniFilename);
14226 outdoor_night_top_b = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.b", 0, pIniFilename);
14227 outdoor_night_bottom_r = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.r", 11, pIniFilename);
14228 outdoor_night_bottom_g = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.g", 41, pIniFilename);
14229 outdoor_night_bottom_b = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.b", 129, pIniFilename);
14230 pOutdoorCamera->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename);
14231 pOutdoorCamera->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename);
14232 pOutdoorCamera->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename);
14233 pOutdoorCamera->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename);
14234 outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename);
14235 outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename);
14236 outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename);
14237 pOutdoorCamera->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename);
14238 pOutdoorCamera->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename);
14239 mipmapping_terrain_mm1 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm1", 2048, pIniFilename);
14240 mipmapping_terrain_mm2 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm2", 4096, pIniFilename);
14241 mipmapping_terrain_mm3 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm3", 8192, pIniFilename);
14242 mipmapping_building_mm1 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm1", 1024, pIniFilename);
14243 mipmapping_building_mm2 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm2", 2048, pIniFilename);
14244 mipmapping_building_mm3 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm3", 4096, pIniFilename);
14245 pOutdoorCamera->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename);
14246 pOutdoorCamera->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename);
14247 pOutdoorCamera->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 8192, pIniFilename);
14248
14249 wchar_t pDefaultSkyTextureW[1024];
14250 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename);
14251 sprintf(pDefaultSkyTexture, "%S", pDefaultSkyTextureW);
14252
14253 wchar_t pDefaultGroundTextureW[1024];
14254 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename);
14255 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW);
14256
14257 wchar_t pFloat[1024];
14258 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename);
14259 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1);
14260
14261 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename);
14262 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2);
14263
14264 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667;
14265
14266 v3 = 0;
14267 if ( strlen(pDefaultSkyTexture) )
14268 {
14269 do
14270 {
14271 if ( pDefaultSkyTexture[v3] == ' ' )
14272 pDefaultSkyTexture[v3] = 0;
14273 ++v3;
14274 }
14275 while ( v3 < strlen(pDefaultSkyTexture) );
14276 }
14277 v4 = 0;
14278 if ( strlen(pDefaultGroundTexture) )
14279 {
14280 do
14281 {
14282 if ( pDefaultGroundTexture[v4] == ' ' )
14283 pDefaultGroundTexture[v4] = 0;
14284 ++v4;
14285 }
14286 while ( v4 < strlen(pDefaultGroundTexture) );
14287 }
14288
14289 texmapping_terrain_subdivsize = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivsize", 16, pIniFilename);
14290 texmapping_terrain_subdivpow2 = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivpow2", 4, pIniFilename);
14291 texmapping_building_subdivsize = GetPrivateProfileIntW(L"texmapping", L"building_subdivsize", 32, pIniFilename);
14292 texmapping_building_subdivpow2 = GetPrivateProfileIntW(L"texmapping", L"building_subdivpow2", 5, pIniFilename);
14293
14294 MM7Initialization();
14295 }
14296
14297 //----- (004666D5) --------------------------------------------------------
14298 void __cdecl MM7Initialization()
14299 {
14300 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
14301 {
14302 if ( !byte_6BE388_graphicsmode )
14303 {
14304 outdoor_grid_band_1 = 10;
14305 outdoor_grid_band_2 = 15;
14306 outdoor_grid_band_3 = 20;
14307 pOutdoorCamera->shading_dist_mist = 8192;
14308 pOutdoorCamera->bNoSky = 0;
14309 LOBYTE(viewparams->field_20) = 0;
14310 }
14311 mipmapping_terrain_mm1 = 1024;
14312 mipmapping_terrain_mm2 = 2048;
14313 mipmapping_building_mm1 = 1024;
14314 mipmapping_building_mm2 = 2048;
14315 pOutdoorCamera->shading_dist_shade = 2048;
14316 pOutdoorCamera->terrain_gamma = 0;
14317 pOutdoorCamera->building_gamme = 0;
14318 mipmapping_terrain_mm3 = 4096;
14319 mipmapping_building_mm3 = 4096;
14320 pOutdoorCamera->shading_dist_shademist = 4096;
14321 pOutdoorCamera->outdoor_no_wavy_water = 0;
14322 sub_47F4D3(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
14323 }
14324 else
14325 {
14326 LOBYTE(viewparams->field_20) = 0;
14327 }
14328 pParty->uFlags |= 2u;
14329 viewparams->uSomeY = viewparams->uScreenY;
14330 viewparams->uSomeX = viewparams->uScreenX;
14331 viewparams->uSomeZ = viewparams->uScreenZ;
14332 viewparams->uSomeW = viewparams->uScreenW;
14333
14334 pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW);
14335 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
14336 pOutdoorCamera->_485F64();
14337 }
14338
14339
14340 //----- (00466B8C) --------------------------------------------------------
14341 int __cdecl AbortWithError()
14342 {
14343 if ( !aborting_app )
14344 {
14345 ClipCursor(0);
14346 aborting_app = 1;
14347 if ( !pRenderer->bWindowMode )
14348 pRenderer->ChangeBetweenWinFullscreenModes();
14349 if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 )
14350 SaveGame(1, 0); // "Internal Error"
14351 // "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?"
14352 Game_DeinitializeAndTerminate(1);
14353 }
14354 return 0;
14355 }
14356 // 720018: using guessed type int aborting_app;
14357
14358 //----- (00466BE5) --------------------------------------------------------
14359 void Abortf(const char *Format, ...)
14360 {
14361 va_list va; // [sp+8h] [bp+8h]@1
14362
14363 va_start(va, Format);
14364 if ( !pRenderer->bWindowMode )
14365 pRenderer->ChangeBetweenWinFullscreenModes();
14366 vsprintf(pTmpBuf, Format, va);
14367 if ( pMouse )
14368 pMouse->Activate(0);
14369 ClipCursor(0);
14370 MessageBoxA(0, pTmpBuf, "Error", 0x30u);
14371 Game_DeinitializeAndTerminate(1);
14372 }
14373
14374 //----- (00466C40) --------------------------------------------------------
14375 const wchar_t *MENU_STATE_to_string(MENU_STATE m)
14376 {
14377 switch (m)
14378 {
14379 case -1: return L"-1";
14380 case MENU_MAIN: return L"MENU_MAIN";
14381 case MENU_NEWGAME: return L"MENU_NEWGAME";
14382 case MENU_CREDITS: return L"MENU_CREDITS";
14383 case MENU_SAVELOAD: return L"MENU_SAVELOAD";
14384 case MENU_FINISHED: return L"MENU_FINISHED";
14385 case MENU_5: return L"MENU_5";
14386 case MENU_CREATEPARTY: return L"MENU_CREATEPARTY";
14387 case MENU_7: return L"MENU_7";
14388 case MENU_Credits: return L"MENU_Credits";
14389 case MENU_LOAD: return L"MENU_LOAD";
14390 case MENU_10: return L"MENU_10";
14391 default: return L"unk";
14392 };
14393 };
14394 void SetCurrentMenuID(MENU_STATE uMenu)
14395 {
14396 if ((int)uCurrentMenuID != -1)
14397 {
14398 if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard)
14399 pAsyncKeyboard->Resume();
14400 }
14401 uCurrentMenuID = uMenu;
14402
14403 Log::Warning(L"CurrentMenu = %s", MENU_STATE_to_string(uMenu));
14404 }
14405
14406 //----- (00466CA0) --------------------------------------------------------
14407 MENU_STATE GetCurrentMenuID()
14408 {
14409 return uCurrentMenuID;
14410 }
14411
14412
14413
14414
14415
14416 /*
14417 v17 = 0;
14418 if ( v4 > -2005532222 )
14419 {
14420 switch ( v4 + 2005532212 )
14421 {
14422 case 0:
14423 v7 = "DDERR_SURFACENOTATTACHED";
14424 goto LABEL_173;
14425 case 10:
14426 v7 = "DDERR_TOOBIGHEIGHT";
14427 goto LABEL_173;
14428 case 20:
14429 v7 = "DDERR_TOOBIGSIZE";
14430 goto LABEL_173;
14431 case 30:
14432 v7 = "DDERR_TOOBIGWIDTH";
14433 goto LABEL_173;
14434 case 50:
14435 v7 = "DDERR_UNSUPPORTEDFORMAT";
14436 goto LABEL_173;
14437 case 60:
14438 v7 = "DDERR_UNSUPPORTEDMASK";
14439 goto LABEL_173;
14440 case 61:
14441 v7 = "DDERR_INVALIDSTREAM";
14442 goto LABEL_173;
14443 case 77:
14444 v7 = "DDERR_VERTICALBLANKINPROGRESS";
14445 goto LABEL_173;
14446 case 80:
14447 v7 = "DDERR_WASSTILLDRAWING";
14448 goto LABEL_173;
14449 case 100:
14450 v7 = "DDERR_XALIGN";
14451 goto LABEL_173;
14452 case 101:
14453 v7 = "DDERR_INVALIDDIRECTDRAWGUID";
14454 goto LABEL_173;
14455 case 102:
14456 v7 = "DDERR_DIRECTDRAWALREADYCREATED";
14457 goto LABEL_173;
14458 case 103:
14459 v7 = "DDERR_NODIRECTDRAWHW";
14460 goto LABEL_173;
14461 case 104:
14462 v7 = "DDERR_PRIMARYSURFACEALREADYEXISTS";
14463 goto LABEL_173;
14464 case 105:
14465 v7 = "DDERR_NOEMULATION";
14466 goto LABEL_173;
14467 case 106:
14468 v7 = "DDERR_REGIONTOOSMALL";
14469 goto LABEL_173;
14470 case 107:
14471 v7 = "DDERR_CLIPPERISUSINGHWND";
14472 goto LABEL_173;
14473 case 108:
14474 v7 = "DDERR_NOCLIPPERATTACHED";
14475 goto LABEL_173;
14476 case 109:
14477 v7 = "DDERR_NOHWND";
14478 goto LABEL_173;
14479 case 110:
14480 v7 = "DDERR_HWNDSUBCLASSED";
14481 goto LABEL_173;
14482 case 111:
14483 v7 = "DDERR_HWNDALREADYSET";
14484 goto LABEL_173;
14485 case 112:
14486 v7 = "DDERR_NOPALETTEATTACHED";
14487 goto LABEL_173;
14488 case 113:
14489 v7 = "DDERR_NOPALETTEHW";
14490 goto LABEL_173;
14491 case 114:
14492 v7 = "DDERR_BLTFASTCANTCLIP";
14493 goto LABEL_173;
14494 case 115:
14495 v7 = "DDERR_NOBLTHW";
14496 goto LABEL_173;
14497 case 116:
14498 v7 = "DDERR_NODDROPSHW";
14499 goto LABEL_173;
14500 case 117:
14501 v7 = "DDERR_OVERLAYNOTVISIBLE";
14502 goto LABEL_173;
14503 case 118:
14504 v7 = "DDERR_NOOVERLAYDEST";
14505 goto LABEL_173;
14506 case 119:
14507 v7 = "DDERR_INVALIDPOSITION";
14508 goto LABEL_173;
14509 case 120:
14510 v7 = "DDERR_NOTAOVERLAYSURFACE";
14511 goto LABEL_173;
14512 case 121:
14513 v7 = "DDERR_EXCLUSIVEMODEALREADYSET";
14514 goto LABEL_173;
14515 case 122:
14516 v7 = "DDERR_NOTFLIPPABLE";
14517 goto LABEL_173;
14518 case 123:
14519 v7 = "DDERR_CANTDUPLICATE";
14520 goto LABEL_173;
14521 case 125:
14522 v7 = "DDERR_CANTCREATEDC";
14523 goto LABEL_173;
14524 case 126:
14525 v7 = "DDERR_NODC";
14526 goto LABEL_173;
14527 case 127:
14528 v7 = "DDERR_WRONGMODE";
14529 goto LABEL_173;
14530 case 128:
14531 v7 = "DDERR_IMPLICITLYCREATED";
14532 goto LABEL_173;
14533 case 129:
14534 v7 = "DDERR_NOTPALETTIZED";
14535 goto LABEL_173;
14536 case 130:
14537 v7 = "DDERR_UNSUPPORTEDMODE";
14538 goto LABEL_173;
14539 case 131:
14540 v7 = "DDERR_NOMIPMAPHW";
14541 goto LABEL_173;
14542 case 132:
14543 v7 = "DDERR_INVALIDSURFACETYPE";
14544 goto LABEL_173;
14545 case 140:
14546 v7 = "DDERR_NOOPTIMIZEHW";
14547 goto LABEL_173;
14548 case 141:
14549 v7 = "DDERR_NOTLOADED";
14550 goto LABEL_173;
14551 case 142:
14552 v7 = "DDERR_NOFOCUSWINDOW";
14553 goto LABEL_173;
14554 case 160:
14555 v7 = "DDERR_DCALREADYCREATED";
14556 goto LABEL_173;
14557 case 170:
14558 v7 = "DDERR_NONONLOCALVIDMEM";
14559 goto LABEL_173;
14560 case 180:
14561 v7 = "DDERR_CANTPAGELOCK";
14562 goto LABEL_173;
14563 case 200:
14564 v7 = "DDERR_CANTPAGEUNLOCK";
14565 goto LABEL_173;
14566 case 220:
14567 v7 = "DDERR_NOTPAGELOCKED";
14568 goto LABEL_173;
14569 case 230:
14570 v7 = "DDERR_MOREDATA";
14571 goto LABEL_173;
14572 case 231:
14573 v7 = "DDERR_EXPIRED";
14574 goto LABEL_173;
14575 case 235:
14576 v7 = "DDERR_VIDEONOTACTIVE";
14577 goto LABEL_173;
14578 case 239:
14579 v7 = "DDERR_DEVICEDOESNTOWNSURFACE";
14580 goto LABEL_173;
14581 default:
14582 goto LABEL_174;
14583 case 124:
14584 goto LABEL_176;
14585 }
14586 goto LABEL_176;
14587 }
14588 if ( v4 != -2005532222 )
14589 {
14590 if ( v4 > -2005532447 )
14591 {
14592 if ( v4 <= -2005532337 )
14593 {
14594 if ( v4 == -2005532337 )
14595 {
14596 v7 = "DDERR_NOVSYNCHW";
14597 goto LABEL_173;
14598 }
14599 if ( v4 > -2005532392 )
14600 {
14601 if ( v4 == -2005532382 )
14602 {
14603 v7 = "DDERR_NOROTATIONHW";
14604 goto LABEL_173;
14605 }
14606 if ( v4 == -2005532362 )
14607 {
14608 v7 = "DDERR_NOSTRETCHHW";
14609 goto LABEL_173;
14610 }
14611 if ( v4 == -2005532356 )
14612 {
14613 v7 = "DDERR_NOT4BITCOLOR";
14614 goto LABEL_173;
14615 }
14616 if ( v4 == -2005532355 )
14617 {
14618 v7 = "DDERR_NOT4BITCOLORINDEX";
14619 goto LABEL_173;
14620 }
14621 if ( v4 == -2005532352 )
14622 {
14623 v7 = "DDERR_NOT8BITCOLOR";
14624 goto LABEL_173;
14625 }
14626 if ( v4 == -2005532342 )
14627 {
14628 v7 = "DDERR_NOTEXTUREHW";
14629 goto LABEL_173;
14630 }
14631 }
14632 else
14633 {
14634 if ( v4 == -2005532392 )
14635 {
14636 v7 = "DDERR_NORASTEROPHW";
14637 goto LABEL_173;
14638 }
14639 if ( v4 == -2005532442 )
14640 {
14641 v7 = "DDERR_NOFLIPHW";
14642 goto LABEL_173;
14643 }
14644 if ( v4 == -2005532432 )
14645 {
14646 v7 = "DDERR_NOGDI";
14647 goto LABEL_173;
14648 }
14649 if ( v4 == -2005532422 )
14650 {
14651 v7 = "DDERR_NOMIRRORHW";
14652 goto LABEL_173;
14653 }
14654 if ( v4 == -2005532417 )
14655 {
14656 v7 = "DDERR_NOTFOUND";
14657 goto LABEL_173;
14658 }
14659 if ( v4 == -2005532412 )
14660 {
14661 v7 = "DDERR_NOOVERLAYHW";
14662 goto LABEL_173;
14663 }
14664 if ( v4 == -2005532402 )
14665 {
14666 v7 = "DDERR_OVERLAPPINGRECTS";
14667 goto LABEL_173;
14668 }
14669 }
14670 goto LABEL_174;
14671 }
14672 if ( v4 <= -2005532285 )
14673 {
14674 if ( v4 == -2005532285 )
14675 {
14676 v7 = "DDERR_PALETTEBUSY";
14677 goto LABEL_173;
14678 }
14679 if ( v4 == -2005532332 )
14680 {
14681 v7 = "DDERR_NOZBUFFERHW";
14682 goto LABEL_173;
14683 }
14684 if ( v4 == -2005532322 )
14685 {
14686 v7 = "DDERR_NOZOVERLAYHW";
14687 goto LABEL_173;
14688 }
14689 if ( v4 == DDERR_OUTOFCAPS )
14690 {
14691 v7 = "DDERR_OUTOFCAPS";
14692 goto LABEL_173;
14693 }
14694 if ( v4 == DDERR_OUTOFVIDEOMEMORY )
14695 {
14696 v7 = "DDERR_OUTOFVIDEOMEMORY";
14697 goto LABEL_173;
14698 }
14699 if ( v4 == DDERR_OVERLAYCANTCLIP )
14700 {
14701 v7 = "DDERR_OVERLAYCANTCLIP";
14702 goto LABEL_173;
14703 }
14704 if ( v4 == DDERR_OVERLAYCOLORKEYONLYONEACTIVE )
14705 {
14706 v7 = "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
14707 goto LABEL_173;
14708 }
14709 goto LABEL_174;
14710 }
14711 if ( v4 == -2005532272 )
14712 {
14713 v7 = "DDERR_COLORKEYNOTSET";
14714 goto LABEL_173;
14715 }
14716 if ( v4 == -2005532262 )
14717 {
14718 v7 = "DDERR_SURFACEALREADYATTACHED";
14719 goto LABEL_173;
14720 }
14721 if ( v4 == -2005532252 )
14722 {
14723 v7 = "DDERR_SURFACEALREADYDEPENDENT";
14724 goto LABEL_173;
14725 }
14726 if ( v4 != -2005532242 )
14727 {
14728 if ( v4 == -2005532237 )
14729 {
14730 v7 = "DDERR_CANTLOCKSURFACE";
14731 goto LABEL_173;
14732 }
14733 if ( v4 == -2005532232 )
14734 {
14735 v7 = "DDERR_SURFACEISOBSCURED";
14736 goto LABEL_173;
14737 }
14738 goto LABEL_174;
14739 }
14740 }
14741 else
14742 {
14743 if ( v4 == -2005532447 )
14744 {
14745 v7 = "DDERR_NOEXCLUSIVEMODE";
14746 goto LABEL_173;
14747 }
14748 if ( v4 <= -2005532562 )
14749 {
14750 if ( v4 == -2005532562 )
14751 {
14752 v7 = "DDERR_INVALIDCLIPLIST";
14753 goto LABEL_173;
14754 }
14755 if ( v4 > -2005532662 )
14756 {
14757 if ( v4 == -2005532652 )
14758 {
14759 v7 = "DDERR_CANNOTDETACHSURFACE";
14760 goto LABEL_173;
14761 }
14762 if ( v4 == -2005532632 )
14763 {
14764 v7 = "DDERR_CURRENTLYNOTAVAIL";
14765 goto LABEL_173;
14766 }
14767 if ( v4 == -2005532617 )
14768 {
14769 v7 = "DDERR_EXCEPTION";
14770 goto LABEL_173;
14771 }
14772 if ( v4 == -2005532582 )
14773 {
14774 v7 = "DDERR_HEIGHTALIGN";
14775 goto LABEL_173;
14776 }
14777 if ( v4 == -2005532577 )
14778 {
14779 v7 = "DDERR_INCOMPATIBLEPRIMARY";
14780 goto LABEL_173;
14781 }
14782 if ( v4 == -2005532572 )
14783 {
14784 v7 = "DDERR_INVALIDCAPS";
14785 goto LABEL_173;
14786 }
14787 }
14788 else
14789 {
14790 if ( v4 == -2005532662 )
14791 {
14792 v7 = "DDERR_CANNOTATTACHSURFACE";
14793 goto LABEL_173;
14794 }
14795 if ( v4 == -2147467263 )
14796 {
14797 v7 = "DDERR_UNSUPPORTED";
14798 goto LABEL_173;
14799 }
14800 if ( v4 == -2147467259 )
14801 {
14802 v7 = "DDERR_GENERIC";
14803 goto LABEL_173;
14804 }
14805 if ( v4 == -2147221008 )
14806 {
14807 v7 = "DDERR_NOTINITIALIZED";
14808 goto LABEL_173;
14809 }
14810 if ( v4 == -2147024882 )
14811 {
14812 v7 = "DDERR_OUTOFMEMORY";
14813 goto LABEL_173;
14814 }
14815 if ( v4 == -2147024809 )
14816 {
14817 v7 = "DDERR_INVALIDPARAMS";
14818 goto LABEL_173;
14819 }
14820 if ( v4 == -2005532667 )
14821 {
14822 v7 = "DDERR_ALREADYINITIALIZED";
14823 LABEL_173:
14824 v13 = strlen(v7);
14825 v12 = (char *)v7;
14826 LABEL_175:
14827 std::stringoperator_assign__const_char_ptr__(&a1, v12, v13);
14828 v13 = a3;
14829 pRenderer->field_40110 = 0;
14830 v15 = &v11;
14831 std::string40E2C8(&v11, Str, (int)((char *)&hr + 3));
14832 v10 = 48;
14833 LOBYTE(v17) = 1;
14834 Str = (char *)&v9;
14835 std::string40E2C8(&v9, "Direct Draw Error", (int)((char *)&a3 + 3));
14836 LOBYTE(v17) = 0;
14837 CheckHRESULT_stru0::ShowMessageBox(v6, &a1, v9, v10, v11, v13);
14838 v5 = 1;
14839 goto LABEL_176;
14840 }
14841 }
14842 LABEL_174:
14843 sprintfex(&Src, "Unknown DirectDraw/Direct3D error number %X", v4);
14844 v13 = strlen(&Src);
14845 v12 = &Src;
14846 goto LABEL_175;
14847 }
14848 if ( v4 > -2005532492 )
14849 {
14850 if ( v4 == -2005532467 )
14851 {
14852 v7 = "DDERR_NOCLIPLIST";
14853 goto LABEL_173;
14854 }
14855 if ( v4 == -2005532462 )
14856 {
14857 v7 = "DDERR_NOCOLORCONVHW";
14858 goto LABEL_173;
14859 }
14860 if ( v4 == -2005532460 )
14861 {
14862 v7 = "DDERR_NOCOOPERATIVELEVELSET";
14863 goto LABEL_173;
14864 }
14865 if ( v4 == -2005532457 )
14866 {
14867 v7 = "DDERR_NOCOLORKEY";
14868 goto LABEL_173;
14869 }
14870 if ( v4 == -2005532452 )
14871 {
14872 v7 = "DDERR_NOCOLORKEYHW";
14873 goto LABEL_173;
14874 }
14875 if ( v4 == -2005532450 )
14876 {
14877 v7 = "DDERR_NODIRECTDRAWSUPPORT";
14878 goto LABEL_173;
14879 }
14880 goto LABEL_174;
14881 }
14882 if ( v4 == -2005532492 )
14883 {
14884 v7 = "DDERR_NOALPHAHW";
14885 goto LABEL_173;
14886 }
14887 if ( v4 == -2005532552 )
14888 {
14889 v7 = "DDERR_INVALIDMODE";
14890 goto LABEL_173;
14891 }
14892 if ( v4 == -2005532542 )
14893 {
14894 v7 = "DDERR_INVALIDOBJECT";
14895 goto LABEL_173;
14896 }
14897 if ( v4 == -2005532527 )
14898 {
14899 v7 = "DDERR_INVALIDPIXELFORMAT";
14900 goto LABEL_173;
14901 }
14902 if ( v4 != -2005532522 )
14903 {
14904 if ( v4 == -2005532512 )
14905 {
14906 v7 = "DDERR_LOCKEDSURFACES";
14907 goto LABEL_173;
14908 }
14909 if ( v4 == -2005532502 )
14910 {
14911 v7 = "DDERR_NO3D";
14912 goto LABEL_173;
14913 }
14914 goto LABEL_174;
14915 }
14916 }*/
14917
14918
14919
14920 //----- (00467D5D) --------------------------------------------------------
14921 int __thiscall sub_467D5D(int _this)
14922 {
14923 return *(int *)(_this + 7204);
14924 }
14925
14926
14927
14928 //----- (00467E7F) --------------------------------------------------------
14929 void __thiscall sub_467E7F_EquipBody(unsigned int uEquipType)
14930 {
14931 unsigned int v1; // esi@1
14932 int v2; // ebx@1
14933 Player *v3; // eax@1
14934 int v4; // edx@1
14935 int v5; // esi@2
14936 int v6; // eax@2
14937 unsigned int v7; // eax@3
14938 ItemGen _this; // [sp+Ch] [bp-30h]@1
14939 Player *v9; // [sp+30h] [bp-Ch]@1
14940 int v10; // [sp+34h] [bp-8h]@1
14941 int *v11; // [sp+38h] [bp-4h]@1
14942
14943 v1 = uEquipType;
14944 _this.Reset();
14945 v2 = (unsigned __int8)byte_4E8394[v1 + 4];
14946 v3 = pPlayers[uActiveCharacter];
14947 v9 = v3;
14948 v11 = (int *)((char *)&v3->pEquipment + 4 * v2);
14949 v4 = *v11;
14950 v10 = *v11;
14951 if ( v10 )
14952 {
14953 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
14954 v5 = (int)((char *)v3 + 4 * (9 * v4 - 9));
14955 *(char *)(v5 + 556) = 0;
14956 pParty->pPickedItem.Reset();
14957 pParty->SetHoldingItem((ItemGen *)(v5 + 532));
14958 v6 = v10;
14959 _this.uBodyAnchor = v2 + 1;
14960 memcpy((void *)(v5 + 532), &_this, 0x24u);
14961 *v11 = v6;
14962 }
14963 else
14964 {
14965 v7 = v3->FindFreeInventorySlot();
14966 if ( (v7 & 0x80000000u) == 0 )
14967 {
14968 pParty->pPickedItem.uBodyAnchor = v2 + 1;
14969 memcpy(&v9->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v9->pInventoryItems[v7]));
14970 *v11 = v7 + 1;
14971 pMouse->RemoveHoldingItem();
14972 }
14973 }
14974 }
14975
14976 //----- (00467F48) --------------------------------------------------------
14977 void __fastcall sub_467F48(signed int a1)
14978 {
14979 signed int v1; // esi@1
14980
14981 v1 = a1;
14982 if ( !pGUIWindow_ScrollWindow && a1 >= 700 )
14983 {
14984 if ( a1 <= 782 )
14985 {
14986 uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE);
14987 pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)30, v1 - 700, 0);
14988 }
14989 }
14990 }
14991 // 720980: using guessed type int uTextureID_720980;
14992
14993 //----- (00467F9F) --------------------------------------------------------
14994 void __cdecl free_book_subwindow()
14995 {
14996 if ( pGUIWindow_ScrollWindow )
14997 {
14998 pGUIWindow_ScrollWindow->Release();
14999 pGUIWindow_ScrollWindow = 0;
15000 }
15001 }
15002
15003 //----- (00467FB6) --------------------------------------------------------
15004 char __cdecl sub_467FB6()
15005 {
15006 unsigned int v0; // eax@1
15007 char *v1; // ST18_4@3
15008 unsigned int v2; // eax@3
15009 GUIWindow a1; // [sp+Ch] [bp-54h]@1
15010
15011 memcpy(&a1, pGUIWindow_ScrollWindow, sizeof(a1));
15012 a1.Hint = 0;
15013 a1.uFrameX = 1;
15014 a1.uFrameY = 1;
15015 a1.uFrameWidth = 468;
15016 v0 = pFontSmallnum->CalcTextHeight(pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], &a1, 0, 0)
15017 + 2 * LOBYTE(pFontCreate->uFontHeight)
15018 + 24;
15019 a1.uFrameHeight = v0;
15020 if ( (signed int)(v0 + a1.uFrameY) > 479 )
15021 {
15022 v0 = 479 - a1.uFrameY;
15023 a1.uFrameHeight = 479 - a1.uFrameY;
15024 }
15025 a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
15026 a1.uFrameW = v0 + a1.uFrameY - 1;
15027 a1.DrawMessageBox(0);
15028 a1.uFrameX += 12;
15029 a1.uFrameWidth -= 24;
15030 a1.uFrameY += 12;
15031 a1.uFrameHeight -= 12;
15032 a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
15033 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
15034 v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName;
15035 v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
15036 sprintf(pTmpBuf, format_4E2D80, v2, v1);
15037 a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
15038 return a1.DrawText(
15039 pFontSmallnum,
15040 1,
15041 LOBYTE(pFontCreate->uFontHeight) - 3,
15042 0,
15043 pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C],
15044 0,
15045 0,
15046 0);
15047 }
15048
15049
15050
15051
15052 //----- (00468F8A) --------------------------------------------------------
15053 void __cdecl OnPaperdollLeftClick()
15054 {
15055 Player *v0; // ebx@1
15056 int v1; // ecx@1
15057 unsigned int v2; // edi@1
15058 unsigned int v3; // edx@4
15059 unsigned int v4; // esi@5
15060 unsigned __int16 v5; // ax@7
15061 unsigned int v6; // edi@19
15062 int v7; // esi@27
15063 unsigned int v8; // eax@29
15064 int v9; // edx@32
15065 int v10; // esi@34
15066 int v11; // eax@34
15067 int v12; // esi@38
15068 int v13; // eax@38
15069 char v14; // zf@38
15070 int v15; // esi@42
15071 int v16; // eax@42
15072 int v17; // eax@44
15073 unsigned int v18; // ecx@55
15074 unsigned int v19; // eax@55
15075 int v20; // esi@60
15076 int v21; // eax@60
15077 unsigned int v22; // eax@61
15078 unsigned int v23; // eax@62
15079 int v24; // esi@65
15080 int v25; // eax@65
15081 unsigned int v26; // eax@69
15082 int v27; // esi@81
15083 int v28; // eax@81
15084 int v29; // esi@84
15085 int v30; // eax@84
15086 int v31; // eax@85
15087 unsigned int v32; // ecx@88
15088 unsigned int v33; // eax@88
15089 int v34; // esi@90
15090 unsigned int v35; // eax@91
15091 int v36; // esi@93
15092 int v37; // edi@93
15093 ItemGen *v38; // edi@93
15094 __int16 v39; // dx@99
15095 signed int v40; // [sp-1Ch] [bp-68h]@80
15096 unsigned int v41; // [sp-18h] [bp-64h]@80
15097 signed int v42; // [sp-14h] [bp-60h]@80
15098 signed int v43; // [sp-10h] [bp-5Ch]@80
15099 int v44; // [sp-Ch] [bp-58h]@80
15100 unsigned int v45; // [sp-8h] [bp-54h]@80
15101 int v46; // [sp-4h] [bp-50h]@80
15102 ItemGen _this; // [sp+Ch] [bp-40h]@1
15103 unsigned int v48; // [sp+30h] [bp-1Ch]@88
15104 unsigned int v49; // [sp+34h] [bp-18h]@57
15105 unsigned int v50; // [sp+38h] [bp-14h]@50
15106 int v51; // [sp+3Ch] [bp-10h]@1
15107 unsigned int v52; // [sp+40h] [bp-Ch]@5
15108 int v53; // [sp+44h] [bp-8h]@1
15109 unsigned int v54; // [sp+48h] [bp-4h]@1
15110
15111 v51 = 0;
15112 _this.Reset();
15113 v0 = pPlayers[uActiveCharacter];
15114 v1 = v0->pEquipment.uMainHand;
15115 v2 = v0->pEquipment.uOffHand;
15116 v54 = v0->pEquipment.uOffHand;
15117 v53 = v1;
15118 if ( v1 && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uEquipType == 1 )
15119 v51 = v1;
15120 v3 = pParty->pPickedItem.uItemID;
15121 if ( pParty->pPickedItem.uItemID )
15122 {
15123 v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType;
15124 v4 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType;
15125 if ( v4 == 4 )
15126 {
15127 if ( v2 )
15128 {
15129 LABEL_7:
15130 LOBYTE(v5) = v0->GetActualSkillLevel(PLAYER_SKILL_SPEAR);
15131 if ( (signed int)SkillToMastery(v5) < 3 )
15132 {
15133 LABEL_8:
15134 v0->PlaySound(39, 0);
15135 return;
15136 }
15137 v3 = pParty->pPickedItem.uItemID;
15138 goto LABEL_16;
15139 }
15140 }
15141 else
15142 {
15143 if ( (v4 == 8 || v4 == 1 || v4 == 2)
15144 && v1
15145 && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uSkillType == 4 )
15146 goto LABEL_7;
15147 }
15148 LABEL_16:
15149 if ( !v0->CanEquip_RaceAndAlignmentCheck(v3) )
15150 goto LABEL_8;
15151 if ( pParty->pPickedItem.uItemID == 604 )
15152 {
15153 sub_467E7F_EquipBody(3u);
15154 WetsuitOn(uActiveCharacter);
15155 return;
15156 }
15157 v6 = v52;
15158 switch ( v52 )
15159 {
15160 case 2u:
15161 case 3u:
15162 case 5u:
15163 case 6u:
15164 case 7u:
15165 case 8u:
15166 case 9u:
15167 case 0xBu:
15168 if ( !v0->HasSkill(v4) )
15169 goto LABEL_8;
15170 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (v6 != 3 || bUnderwater) )
15171 goto LABEL_95;
15172 sub_467E7F_EquipBody(v6);
15173 if ( pParty->pPickedItem.uItemID == 604 )
15174 WetsuitOff(uActiveCharacter);
15175 return;
15176 case 0xAu:
15177 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
15178 goto LABEL_95;
15179 v52 = 10;
15180 v7 = (int)&v0->pEquipment.field_28;
15181 while ( 1 )
15182 {
15183 if ( !*(int *)v7 )
15184 {
15185 v8 = v0->FindFreeInventorySlot();
15186 if ( (v8 & 0x80000000u) == 0 )
15187 break;
15188 }
15189 ++v52;
15190 v7 += 4;
15191 if ( (signed int)v52 > 15 )
15192 goto LABEL_33;
15193 }
15194 v9 = v52;
15195 pParty->pPickedItem.uBodyAnchor = v52 + 1;
15196 memcpy(&v0->pInventoryItems[v8], &pParty->pPickedItem, sizeof(v0->pInventoryItems[v8]));
15197 *(&v0->pEquipment.uOffHand + v9) = v8 + 1;
15198 pMouse->RemoveHoldingItem();
15199 LABEL_33:
15200 if ( v52 == 16 )
15201 {
15202 v52 = v0->pEquipment.field_3C - 1;
15203 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15204 v10 = (int)((char *)v0 + 36 * v52);
15205 *(char *)(v10 + 556) = 0;
15206 pParty->pPickedItem.Reset();
15207 pParty->SetHoldingItem((ItemGen *)(v10 + 532));
15208 _this.uBodyAnchor = 16;
15209 v11 = v52 + 1;
15210 memcpy((void *)(v10 + 532), &_this, 0x24u);
15211 v0->pEquipment.field_3C = v11;
15212 }
15213 return;
15214 case 4u:
15215 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
15216 goto LABEL_95;
15217 if ( !v0->HasSkill(v4) )
15218 goto LABEL_8;
15219 if ( v54 )
15220 {
15221 --v54;
15222 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15223 v12 = (int)((char *)v0 + 36 * v54);
15224 *(char *)(v12 + 556) = 0;
15225 pParty->pPickedItem.Reset();
15226 pParty->SetHoldingItem((ItemGen *)(v12 + 532));
15227 _this.uBodyAnchor = 1;
15228 v13 = v54 + 1;
15229 v14 = v51 == 0;
15230 memcpy((void *)(v12 + 532), &_this, 0x24u);
15231 v0->pEquipment.uOffHand = v13;
15232 if ( v14 )
15233 return;
15234 }
15235 else
15236 {
15237 v52 = v0->FindFreeInventorySlot();
15238 if ( (v52 & 0x80000000u) != 0 )
15239 return;
15240 if ( !v51 )
15241 {
15242 pParty->pPickedItem.uBodyAnchor = 1;
15243 v17 = v52 + 1;
15244 memcpy(&v0->pInventoryItems[v52], &pParty->pPickedItem, sizeof(v0->pInventoryItems[v52]));
15245 v0->pEquipment.uOffHand = v17;
15246 goto LABEL_45;
15247 }
15248 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15249 v15 = (int)((char *)v0 + 36 * (v53 - 1));
15250 *(char *)(v15 + 556) = 0;
15251 pParty->pPickedItem.Reset();
15252 pParty->SetHoldingItem((ItemGen *)(v15 + 532));
15253 _this.uBodyAnchor = 1;
15254 v16 = v52 + 1;
15255 memcpy(&v0->pInventoryItems[v52], &_this, sizeof(v0->pInventoryItems[v52]));
15256 v0->pEquipment.uOffHand = v16;
15257 }
15258 v0->pEquipment.uMainHand = 0;
15259 return;
15260 case 0u:
15261 case 0xCu:
15262 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter)
15263 && pParty->pPickedItem.uItemID != 64
15264 && pParty->pPickedItem.uItemID != 65 )
15265 goto LABEL_95;
15266 if ( !v0->HasSkill(v4) )
15267 goto LABEL_8;
15268 v50 = 0;
15269 if ( v4 == 2 && (unsigned __int16)(v0->pActiveSkills[2] & 0xFFC0)
15270 || v4 == 1 && (signed int)SkillToMastery(v0->pActiveSkills[1]) >= 3 )
15271 {
15272 if (pAsyncMouse)
15273 {
15274 v18 = *((int *)pAsyncMouse + 6);
15275 v19 = *((int *)pAsyncMouse + 7);
15276 }
15277 else
15278 {
15279 v18 = pMouse->uMouseClickX;
15280 v19 = pMouse->uMouseClickY;
15281 }
15282 v49 = v19;
15283 if ( (signed int)v18 >= 560 )
15284 {
15285 if ( !v51 )
15286 {
15287 if ( v54 )
15288 {
15289 --v54;
15290 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15291 v20 = (int)((char *)v0 + 36 * v54);
15292 *(char *)(v20 + 556) = 0;
15293 pParty->pPickedItem.Reset();
15294 pParty->SetHoldingItem((ItemGen *)(v20 + 532));
15295 _this.uBodyAnchor = 1;
15296 v21 = v54 + 1;
15297 v14 = v52 == 12;
15298 memcpy((void *)(v20 + 532), &_this, 0x24u);
15299 v0->pEquipment.uOffHand = v21;
15300 if ( !v14 )
15301 return;
15302 v22 = _this.uItemID;
15303 LABEL_73:
15304 v50 = v22;
15305 goto LABEL_74;
15306 }
15307 v23 = v0->FindFreeInventorySlot();
15308 if ( (v23 & 0x80000000u) != 0 )
15309 return;
15310 pParty->pPickedItem.uBodyAnchor = 1;
15311 v50 = (unsigned int)&v0->pInventoryItems[v23];
15312 memcpy(&v0->pInventoryItems[v23], &pParty->pPickedItem, sizeof(v0->pInventoryItems[v23]));
15313 v0->pEquipment.uOffHand = v23 + 1;
15314 LABEL_71:
15315 pMouse->RemoveHoldingItem();
15316 if ( v52 != 12 )
15317 return;
15318 v22 = *(int *)v50;
15319 goto LABEL_73;
15320 }
15321 }
15322 }
15323 if ( !v53 )
15324 {
15325 v26 = v0->FindFreeInventorySlot();
15326 if ( (v26 & 0x80000000u) != 0 )
15327 return;
15328 pParty->pPickedItem.uBodyAnchor = 2;
15329 v50 = (unsigned int)&v0->pInventoryItems[v26];
15330 memcpy(&v0->pInventoryItems[v26], &pParty->pPickedItem, sizeof(v0->pInventoryItems[v26]));
15331 v0->pEquipment.uMainHand = v26 + 1;
15332 goto LABEL_71;
15333 }
15334 --v53;
15335 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15336 v24 = (int)((char *)v0 + 36 * v53);
15337 *(char *)(v24 + 556) = 0;
15338 pParty->pPickedItem.Reset();
15339 pParty->SetHoldingItem((ItemGen *)(v24 + 532));
15340 _this.uBodyAnchor = 2;
15341 v25 = v53 + 1;
15342 v14 = v52 == 12;
15343 memcpy((void *)(v24 + 532), &_this, 0x24u);
15344 v0->pEquipment.uMainHand = v25;
15345 if ( v14 )
15346 v50 = _this.uItemID;
15347 if ( v51 )
15348 v0->pEquipment.uOffHand = 0;
15349 LABEL_74:
15350 if ( v50 )
15351 stru_A750F8[uActiveCharacter - 1]._494836(
15352 *((int *)&pSpellDatas[66].field_8 + v50),
15353 uActiveCharacter - 1 + 9);
15354 break;
15355 case 1u:
15356 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
15357 goto LABEL_95;
15358 if ( !v0->HasSkill(v4) )
15359 goto LABEL_8;
15360 if ( v53 )
15361 {
15362 if ( v54 )
15363 {
15364 v46 = 0;
15365 v45 = 0;
15366 v44 = 0;
15367 v43 = 0;
15368 v42 = -1;
15369 v41 = 0;
15370 v40 = 0;
15371 goto LABEL_96;
15372 }
15373 --v53;
15374 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15375 v27 = (int)((char *)v0 + 36 * v53);
15376 *(char *)(v27 + 556) = 0;
15377 pParty->pPickedItem.Reset();
15378 pParty->SetHoldingItem((ItemGen *)(v27 + 532));
15379 _this.uBodyAnchor = 2;
15380 v28 = v53 + 1;
15381 memcpy((void *)(v27 + 532), &_this, 0x24u);
15382 v0->pEquipment.uMainHand = v28;
15383 }
15384 else
15385 {
15386 v52 = v0->FindFreeInventorySlot();
15387 if ( (v52 & 0x80000000u) == 0 )
15388 {
15389 if ( v54 )
15390 {
15391 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
15392 v29 = (int)((char *)v0 + 36 * (v54 - 1));
15393 *(char *)(v29 + 556) = 0;
15394 pParty->pPickedItem.Reset();
15395 pParty->SetHoldingItem((ItemGen *)(v29 + 532));
15396 _this.uBodyAnchor = 2;
15397 v30 = v52 + 1;
15398 memcpy(&v0->pInventoryItems[v52], &_this, sizeof(v0->pInventoryItems[v52]));
15399 v0->pEquipment.uOffHand = 0;
15400 v0->pEquipment.uMainHand = v30;
15401 }
15402 else
15403 {
15404 pParty->pPickedItem.uBodyAnchor = 2;
15405 v31 = v52 + 1;
15406 memcpy(&v0->pInventoryItems[v52], &pParty->pPickedItem, sizeof(v0->pInventoryItems[v52]));
15407 v0->pEquipment.uMainHand = v31;
15408 LABEL_45:
15409 pMouse->RemoveHoldingItem();
15410 }
15411 }
15412 }
15413 return;
15414 default:
15415 v0->UseItem_DrinkPotion_etc(uActiveCharacter, 0);
15416 return;
15417 }
15418 return;
15419 }
15420 if (pAsyncMouse)
15421 {
15422 v32 = *((int *)pAsyncMouse + 6);
15423 v33 = *((int *)pAsyncMouse + 7);
15424 v49 = *((int *)pAsyncMouse + 7);
15425 v48 = v32;
15426 }
15427 else
15428 {
15429 v32 = pMouse->uMouseClickX;
15430 v33 = pMouse->uMouseClickY;
15431 }
15432 v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF;
15433 if ( v34 )
15434 {
15435 v36 = v34 - 1;
15436 v37 = (int)((char *)v0 + 36 * v36);
15437 v50 = v37;
15438 v38 = (ItemGen *)(v37 + 532);
15439 v14 = v38->uItemID == 604;
15440 v52 = pItemsTable->pItems[v38->uItemID].uEquipType;
15441 if ( v14 )
15442 {
15443 if ( bUnderwater )
15444 {
15445 LABEL_95:
15446 v46 = 0;
15447 v45 = 0;
15448 v44 = 0;
15449 v43 = 0;
15450 v42 = -1;
15451 v41 = 0;
15452 v40 = 0;
15453 LABEL_96:
15454 pAudioPlayer->PlaySound(SOUND_27, v40, v41, v42, v43, v44, v45, v46);
15455 return;
15456 }
15457 WetsuitOff(uActiveCharacter);
15458 }
15459 if ( unk_50C9A0 )
15460 {
15461 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
15462 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
15463 v39 = v52;
15464 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36;
15465 *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39;
15466 ptr_50C9A4 = v38;
15467 unk_50C9A0 = 0;
15468 if ( pMessageQueue_50CBD0->uNumMessages )
15469 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
15470 pMouse->SetCursorBitmap("MICON1");
15471 dword_50C9D4 = 0;
15472 dword_50C9D0 = 113;
15473 dword_50C9D8 = 256;
15474 }
15475 else
15476 {
15477 if ( !ptr_50C9A4 )
15478 {
15479 pParty->SetHoldingItem(v38);
15480 *(&v0->uBirthYear + *(char *)(v50 + 556)) = 0;
15481 v38->Reset();
15482 }
15483 }
15484 }
15485 else
15486 {
15487 v35 = v0->pEquipment.uBow;
15488 if ( v35 )
15489 {
15490 auto _a = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v35 + 5];
15491 pParty->SetHoldingItem(_a);
15492 _a->Reset();
15493 v0->pEquipment.uBow = 0;
15494 }
15495 }
15496 }
15497
15498
15499
15500
15501 //----- (0046A0A1) --------------------------------------------------------
15502 int __thiscall UnprojectX(int x)
15503 {
15504 double v1; // st7@3
15505 int v3; // [sp-4h] [bp-8h]@5
15506
15507 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
15508 {
15509 if ( pRenderer->pRenderD3D )
15510 v1 = pGame->pIndoorCameraD3D->fov;
15511 else
15512 v1 = pIndoorCamera->flt_1C_fov;
15513 v3 = (signed __int64)v1;
15514 }
15515 else
15516 {
15517 v3 = pOutdoorCamera->int_fov_rad;
15518 }
15519 return stru_5C6E00->Atan2(x - pViewport->uScreenCenterX, v3) - stru_5C6E00->uIntegerHalfPi;
15520 }
15521
15522 //----- (0046A0F6) --------------------------------------------------------
15523 int __thiscall UnprojectY(int _this)
15524 {
15525 double v1; // st7@3
15526 int v3; // [sp-4h] [bp-8h]@5
15527
15528 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
15529 {
15530 if ( pRenderer->pRenderD3D )
15531 v1 = pGame->pIndoorCameraD3D->fov;
15532 else
15533 v1 = pIndoorCamera->flt_1C_fov;
15534 v3 = (signed __int64)v1;
15535 }
15536 else
15537 {
15538 v3 = pOutdoorCamera->int_fov_rad;
15539 }
15540 return stru_5C6E00->Atan2(_this - pViewport->uScreenCenterY, v3) - stru_5C6E00->uIntegerHalfPi;
15541 }
15542
15543 //----- (0046A14B) --------------------------------------------------------
15544 char __cdecl OnPressSpace()
15545 {
15546 SHORT v0; // ax@2
15547 int *v1; // eax@2
15548 char *v2; // ebx@5
15549 unsigned int v3; // esi@5
15550 signed int v4; // edi@7
15551 unsigned int v5; // edx@7
15552 int v6; // ecx@8
15553 int v7; // eax@8
15554 int v8; // ecx@17
15555 int *v9; // esi@22
15556 signed int v10; // ebx@22
15557 int i; // edi@23
15558 int v12; // edx@24
15559 int v13; // ecx@24
15560 int j; // esi@28
15561 int v16; // [sp+4h] [bp-1Ch]@0
15562 char *v17; // [sp+8h] [bp-18h]@5
15563 unsigned int v18; // [sp+Ch] [bp-14h]@5
15564 int v19; // [sp+10h] [bp-10h]@8
15565 int *v20; // [sp+14h] [bp-Ch]@5
15566 int *v21; // [sp+18h] [bp-8h]@7
15567 int v22; // [sp+1Ch] [bp-4h]@4
15568
15569 if ( pRenderer->pRenderD3D )
15570 {
15571 v0 = GetAsyncKeyState(17);
15572 pGame->_44EB12((v0 & 0x8001) != 0, &a3, &a4);
15573 v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val();
15574 if ( v1 != (int *)-1 )
15575 LOBYTE(v1) = DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
15576 return (char)v1;
15577 }
15578 v22 = 0;
15579 v1 = (int *)((signed int)(viewparams->uScreenZ + viewparams->uScreenX) >> 1);
15580 if ( (signed int)viewparams->uScreenY >= (signed int)viewparams->uScreenW )
15581 goto LABEL_21;
15582 v2 = (char *)v1 - 50;
15583 v1 = (int *)((char *)v1 + 50);
15584 v3 = 640 * viewparams->uScreenY;
15585 v17 = v2;
15586 v20 = v1;
15587 v18 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1;
15588 do
15589 {
15590 if ( (signed int)v2 >= (signed int)v20 )
15591 goto LABEL_20;
15592 v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]];
15593 v21 = &pRenderer->pActiveZBuffer[(int)&v2[v3]];
15594 v4 = v22;
15595 v5 = (((char *)v20 - v2 - 1) >> 1) + 1;
15596 do
15597 {
15598 v6 = 0;
15599 v7 = *v1 & 0xFFFF;
15600 v19 = 0;
15601 if ( v4 > 0 )
15602 {
15603 do
15604 {
15605 if ( dword_7207F0[v6] == v7 )
15606 break;
15607 ++v6;
15608 v19 = v6;
15609 }
15610 while ( v6 < v22 );
15611 }
15612 if ( (v7 & 7) == 5 )
15613 {
15614 v16 = (unsigned int)v7 >> 3;
15615 if ( (signed int)(((unsigned int)*v21 >> 16)
15616 - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)v7 >> 3].uDecorationDescID].uRadius) > 512 )
15617 goto LABEL_18;
15618 }
15619 else
15620 {
15621 if ( (unsigned int)*v21 > 0x2000000 )
15622 goto LABEL_18;
15623 }
15624 if ( v19 == v22 && v4 < 100 )
15625 {
15626 ++v22;
15627 ++v4;
15628 v8 = *v21;
15629 dword_7207EC[v4] = v7;
15630 dword_72065C[v4] = v8;
15631 }
15632 LABEL_18:
15633 v1 = v21 + 2;
15634 --v5;
15635 v21 += 2;
15636 }
15637 while ( v5 );
15638 v2 = v17;
15639 LABEL_20:
15640 v3 += 1280;
15641 --v18;
15642 }
15643 while ( v18 );
15644 LABEL_21:
15645 if ( v22 > 0 )
15646 {
15647 v9 = dword_720660;
15648 v10 = 1;
15649 do
15650 {
15651 for ( i = v10; i < v22; ++i )
15652 {
15653 v12 = *v9;
15654 v13 = dword_720660[i];
15655 if ( v13 < *v9 )
15656 {
15657 *v9 = v13;
15658 dword_720660[i] = v12;
15659 }
15660 }
15661 ++v10;
15662 ++v9;
15663 LOBYTE(v1) = v10 - 1;
15664 }
15665 while ( v10 - 1 < v22 );
15666 }
15667 for ( j = 0; j < v22; ++j )
15668 {
15669 LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16);
15670 if ( !(char)v1 )
15671 break;
15672 }
15673 return (char)v1;
15674 }
15675 // 72065C: using guessed type int dword_72065C[];
15676 // 7207EC: using guessed type int dword_7207EC[];
15677
15678 //----- (0046A334) --------------------------------------------------------
15679 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2)
15680 {
15681 int v2; // edx@1
15682 BLVFace *v4; // eax@9
15683 unsigned int v5; // ecx@9
15684 unsigned __int16 v6; // ax@11
15685 ODMFace *v7; // eax@16
15686 LevelDecoration *v8; // esi@19
15687 __int16 v9; // ax@19
15688 int v10; // eax@22
15689 int v11; // ecx@22
15690 int v12; // edi@23
15691 Actor *v13; // esi@23
15692 unsigned __int16 v14; // ax@23
15693 unsigned __int16 v15; // ax@33
15694 const char *v16; // eax@34
15695 int v17; // edi@36
15696 int v18; // eax@36
15697 ItemGen *v19; // esi@39
15698 unsigned int v20; // eax@39
15699 int v21; // ecx@40
15700 std::string v22; // [sp-18h] [bp-2Ch]@5
15701 const char *v23; // [sp-8h] [bp-1Ch]@5
15702 int v24; // [sp-4h] [bp-18h]@5
15703 char v25; // [sp+8h] [bp-Ch]@5
15704 int v26; // [sp+Ch] [bp-8h]@1
15705 int a3; // [sp+13h] [bp-1h]@5
15706
15707 v26 = a2;
15708 v2 = a1;
15709 switch ( a1 & 7 )
15710 {
15711 case 2:
15712 v17 = a1 >> 3;
15713 v26 = a1 >> 3;
15714 v18 = a1 >> 3;
15715 if ( pObjectList->pObjects[pLayingItems[v18].uObjectDescID].uFlags & 0x10
15716 || v17 >= 1000
15717 || !pLayingItems[v18].uObjectDescID )
15718 return 1;
15719 v19 = &pLayingItems[v18].stru_24;
15720 v20 = pLayingItems[v18].stru_24.uItemID;
15721 if ( pItemsTable->pItems[v20].uEquipType == 18 )
15722 {
15723 party_finds_gold(v19->uAdditionalValue, 0);
15724 viewparams->bRedrawGameUI = 1;
15725 v21 = v17;
15726 }
15727 else
15728 {
15729 if ( pParty->pPickedItem.uItemID )
15730 return 1;
15731 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName;
15732 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24);
15733 ShowStatusBarString(pTmpBuf2, 2u);
15734 if ( v19->uItemID == 506 )
15735 _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
15736 if ( v19->uItemID == 455 )
15737 _449B7E_toggle_bit(pParty->_award_bits, 185, 1u);
15738 if ( !pParty->AddItem(v19) )
15739 pParty->SetHoldingItem(v19);
15740 v21 = v26;
15741 }
15742 LayingItem::_42F933(v21);
15743 break;
15744 case 3:
15745 v12 = a1 >> 3;
15746 v13 = &pActors[a1 >> 3];
15747 v14 = v13->uAIState;
15748 if ( v14 == 4 || v14 == 17 )
15749 return 1;
15750 if ( v14 == 5 )
15751 {
15752 stru_50C198.LootActor(&pActors[a1 >> 3]);
15753 }
15754 else
15755 {
15756 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() )
15757 {
15758 Actor::FaceObject(v12, 4u, 0, 0);
15759 if ( v13->uNPC_ID )
15760 {
15761 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
15762 {
15763 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)161;
15764 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
15765 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
15766 ++pMessageQueue_50CBD0->uNumMessages;
15767 }
15768 }
15769 else
15770 {
15771 v15 = pNPCStats->pGroups_copy[v13->uGroup];
15772 if ( v15 )
15773 {
15774 v16 = pNPCStats->pCatchPhrases[v15];
15775 if ( v16 )
15776 {
15777 pParty->uFlags |= 2u;
15778 strcpy(byte_5B0938, v16);
15779 sub_4451A8_press_any_key(0, 0, 0);
15780 }
15781 }
15782 }
15783 }
15784 }
15785 break;
15786 case 5:
15787 v8 = &pLevelDecorations[a1 >> 3];
15788 v9 = v8->field_16_event_id;
15789 if ( v9 )
15790 {
15791 EventProcessor(v9, a1, 1);
15792 LOBYTE(v8->field_2) |= 8u;
15793 }
15794 else
15795 {
15796 if ( !pLevelDecorations[a1 >> 3].IsInteractive() )
15797 return 1;
15798 v10 = v8->_idx_in_stru123;
15799 v24 = 1;
15800 v11 = stru_5E4C90._decor_events[v10 - 75] + 380;
15801 _5C3420_pDecoration = v8;
15802 EventProcessor(v11, 0, 1);
15803 _5C3420_pDecoration = 0;
15804 }
15805 break;
15806 default:
15807 if ( (a1 & 7) != 6 )
15808 {
15809 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
15810 return 1;
15811 }
15812 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
15813 {
15814 if ( a1 >> 9 >= pOutdoor->uNumBModels
15815 || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
15816 || (v6 = v7->sCogTriggeredID) == 0 )
15817 return 1;
15818 LABEL_13:
15819 EventProcessor((signed __int16)v6, v2, 1);
15820 return 0;
15821 }
15822 v4 = &pIndoor->pFaces[a1 >> 3];
15823 v5 = v4->uAttributes;
15824 if ( !(v5 & 0x2000000) )
15825 {
15826 ShowNothingHereStatus();
15827 return 1;
15828 }
15829 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
15830 return 1;
15831 if ( pCurrentScreen != 19 )
15832 goto LABEL_13;
15833 break;
15834 }
15835 return 0;
15836 }
15837 // 4E28F8: using guessed type int pCurrentScreen;
15838
15839 //----- (0046A6AC) --------------------------------------------------------
15840 int __fastcall sub_46A6AC(int a1, int a2, int a3)
15841 {
15842 int result; // eax@2
15843 unsigned int v4; // edx@3
15844 int *v5; // esi@6
15845 unsigned int v6; // ebx@6
15846 signed int v7; // edi@9
15847 unsigned __int16 v8; // ax@9
15848 int i; // eax@14
15849 int v10; // ecx@19
15850 int v11; // [sp+0h] [bp-18h]@1
15851 unsigned int v12; // [sp+4h] [bp-14h]@3
15852 unsigned int v13; // [sp+8h] [bp-10h]@4
15853 int v14; // [sp+Ch] [bp-Ch]@1
15854 int *v15; // [sp+10h] [bp-8h]@4
15855 int v16; // [sp+14h] [bp-4h]@3
15856
15857 v11 = a2;
15858 v14 = a1;
15859 if ( pRenderer->pRenderD3D )
15860 {
15861 result = sub_46A7C8(a1, a2, a3);
15862 }
15863 else
15864 {
15865 v16 = 0;
15866 v4 = viewparams->uScreenX;
15867 v12 = viewparams->uScreenZ;
15868 if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW )
15869 {
15870 v15 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
15871 v13 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1;
15872 do
15873 {
15874 if ( (signed int)v4 < (signed int)v12 )
15875 {
15876 v5 = v15;
15877 v6 = ((v12 - v4 - 1) >> 1) + 1;
15878 do
15879 {
15880 if ( (*(char *)v5 & 7) == 3 )
15881 {
15882 if ( *v5 <= a3 << 16 )
15883 {
15884 v7 = (signed int)(unsigned __int16)*v5 >> 3;
15885 v8 = pActors[v7].uAIState;
15886 if ( v8 != 5 )
15887 {
15888 if ( v8 != 4 && v8 != 11 && v8 != 17 && v8 != 19 )
15889 {
15890 for ( i = 0; i < v16; ++i )
15891 {
15892 if ( *(int *)(v14 + 4 * i) == v7 )
15893 break;
15894 }
15895 if ( i == v16 )
15896 {
15897 if ( i < v11 - 1 )
15898 {
15899 v10 = v16++;
15900 *(int *)(v14 + 4 * v10) = v7;
15901 }
15902 }
15903 }
15904 }
15905 }
15906 }
15907 v5 += 2;
15908 --v6;
15909 }
15910 while ( v6 );
15911 }
15912 v15 += 1280;
15913 --v13;
15914 }
15915 while ( v13 );
15916 }
15917 result = v16;
15918 }
15919 return result;
15920 }
15921
15922 //----- (0046A7C8) --------------------------------------------------------
15923 int __fastcall sub_46A7C8(int a1, int a2, signed int a3)
15924 {
15925 unsigned int v3; // eax@2
15926 int v4; // ecx@2
15927 unsigned int v5; // eax@2
15928 unsigned int v6; // eax@4
15929 unsigned int v7; // edi@4
15930 unsigned __int16 v8; // ax@4
15931 float v9; // ST00_4@9
15932 int v10; // ecx@11
15933 unsigned int v12; // [sp+10h] [bp-14h]@1
15934 int v13; // [sp+14h] [bp-10h]@1
15935 int v14; // [sp+18h] [bp-Ch]@1
15936 int v15; // [sp+1Ch] [bp-8h]@1
15937 unsigned int a1a; // [sp+20h] [bp-4h]@1
15938
15939 v13 = a1;
15940 v14 = a2;
15941 v15 = 0;
15942 a1a = 0;
15943 v12 = pRenderer->GetBillboardDrawListSize();
15944 if ( (signed int)v12 > 0 )
15945 {
15946 do
15947 {
15948 v3 = pRenderer->GetParentBillboardID(a1a);
15949 v4 = pBillboardRenderList[v3].sZValue;
15950 v5 = (unsigned __int16)pBillboardRenderList[v3].sZValue;
15951 if ( (v5 & 7) == 3 )
15952 {
15953 if ( v4 <= (unsigned int)(a3 << 16) )
15954 {
15955 v6 = v5 >> 3;
15956 v7 = v6;
15957 v8 = pActors[v6].uAIState;
15958 if ( v8 != 5 )
15959 {
15960 if ( v8 != 4 )
15961 {
15962 if ( v8 != 11 )
15963 {
15964 if ( v8 != 19 )
15965 {
15966 if ( v8 != 17 )
15967 {
15968 v9 = (double)a3;
15969 if ( pGame->pVisInstance->DoesRayIntersectBillboard(v9, a1a) )
15970 {
15971 if ( v15 < v14 - 1 )
15972 {
15973 v10 = v15++;
15974 *(int *)(v13 + 4 * v10) = v7;
15975 }
15976 }
15977 }
15978 }
15979 }
15980 }
15981 }
15982 }
15983 }
15984 ++a1a;
15985 }
15986 while ( (signed int)a1a < (signed int)v12 );
15987 }
15988 return v15;
15989 }
15990
15991 //----- (0046A89E) --------------------------------------------------------
15992 int __fastcall sub_46A89E(int a1, int a2, signed int a3)
15993 {
15994 signed int v3; // edi@1
15995 char *v4; // esi@2
15996 int v5; // ebx@3
15997 int v6; // eax@3
15998 int v7; // ebx@3
15999 unsigned int v8; // ecx@3
16000 int v9; // edx@4
16001 unsigned int v10; // edx@6
16002 unsigned int v11; // edx@8
16003 __int16 v12; // ax@10
16004 int v13; // ecx@15
16005 int v15; // [sp+4h] [bp-18h]@1
16006 int v16; // [sp+8h] [bp-14h]@1
16007 int v17; // [sp+Ch] [bp-10h]@3
16008 int v18; // [sp+10h] [bp-Ch]@3
16009 int v19; // [sp+18h] [bp-4h]@1
16010
16011 v3 = 0;
16012 v15 = a2;
16013 v16 = a1;
16014 v19 = 0;
16015 if ( (signed int)uNumActors > 0 )
16016 {
16017 v4 = (char *)&pActors[0].uAIState;
16018 do
16019 {
16020 v5 = abs(*((short *)v4 - 17) - pParty->vPosition.x);
16021 v17 = abs(*((short *)v4 - 16) - pParty->vPosition.y);
16022 v18 = abs(*((short *)v4 - 15) - pParty->vPosition.z);
16023 v6 = v5;
16024 v7 = v17;
16025 v8 = v18;
16026 if ( v6 < v17 )
16027 {
16028 v9 = v6;
16029 v6 = v17;
16030 v7 = v9;
16031 }
16032 if ( v6 < v18 )
16033 {
16034 v10 = v6;
16035 v6 = v18;
16036 v8 = v10;
16037 }
16038 if ( v7 < (signed int)v8 )
16039 {
16040 v11 = v8;
16041 v8 = v7;
16042 v7 = v11;
16043 }
16044 if ( (signed int)(((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6) <= a3 )
16045 {
16046 v12 = *(short *)v4;
16047 if ( *(short *)v4 != 5 )
16048 {
16049 if ( v12 != 4 )
16050 {
16051 if ( v12 != 11 )
16052 {
16053 if ( v12 != 19 )
16054 {
16055 if ( v12 != 17 )
16056 {
16057 v13 = v19++;
16058 *(int *)(v16 + 4 * v13) = v3;
16059 if ( v19 >= v15 - 1 )
16060 break;
16061 }
16062 }
16063 }
16064 }
16065 }
16066 }
16067 ++v3;
16068 v4 += 836;
16069 }
16070 while ( v3 < (signed int)uNumActors );
16071 }
16072 return v19;
16073 }
16074
16075 //----- (0046A99B) --------------------------------------------------------
16076 int __cdecl sub_46A99B()
16077 {
16078 int v0; // ebx@1
16079 signed int v1; // ecx@1
16080 signed int v2; // esi@1
16081 int v3; // edx@1
16082 signed int v4; // eax@1
16083 int v5; // ecx@2
16084 int *v6; // eax@3
16085 int v7; // ecx@3
16086 int v8; // edx@5
16087 int v9; // edi@6
16088 unsigned __int8 v10; // zf@14
16089 char v11; // sf@14
16090 char v12; // of@14
16091 int *v14; // esi@19
16092 signed int v15; // ebx@19
16093 int i; // edi@20
16094 int v17; // ecx@21
16095 int v18; // edi@26
16096 int v19; // esi@27
16097 unsigned int v20; // ecx@27
16098 BLVFace *v21; // eax@32
16099 unsigned int v22; // ecx@33
16100 const char *v23; // eax@35
16101 const char *v24; // ecx@36
16102 LevelDecoration *v25; // ecx@43
16103 LevelDecoration *v26; // edi@43
16104 __int16 v27; // ax@43
16105 int v28; // [sp+Ch] [bp-18h]@1
16106 int v29; // [sp+14h] [bp-10h]@2
16107 int v30; // [sp+18h] [bp-Ch]@1
16108 signed int v31; // [sp+1Ch] [bp-8h]@3
16109 int v32; // [sp+20h] [bp-4h]@1
16110
16111 v0 = 0;
16112 v1 = (signed int)(viewparams->uScreenW + viewparams->uScreenY) >> 1;
16113 v2 = (signed int)(viewparams->uScreenX + viewparams->uScreenZ) >> 1;
16114 v3 = v1 - 50;
16115 v32 = 0;
16116 v4 = 100;
16117 v30 = v1 - 50;
16118 v28 = v1 + 50;
16119 if ( v1 - 50 >= v1 + 50 )
16120 return 0;
16121 v5 = 640 * v3;
16122 v29 = 640 * v3;
16123 while ( 2 )
16124 {
16125 v31 = 100;
16126 v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2];
16127 v7 = v0;
16128 while ( 1 )
16129 {
16130 v8 = *v6;
16131 --v31;
16132 if ( (unsigned int)*v6 <= 0x2000000 )
16133 {
16134 v9 = 0;
16135 if ( v7 > 0 )
16136 {
16137 do
16138 {
16139 if ( dword_7201B0_zvalues[v9] == (unsigned __int16)v8 )
16140 break;
16141 ++v9;
16142 }
16143 while ( v9 < v0 );
16144 }
16145 if ( v9 == v0 )
16146 {
16147 if ( v8 & 7 )
16148 {
16149 dword_720020_zvalues[v7] = v8;
16150 dword_7201B0_zvalues[v7] = (unsigned __int16)v8;
16151 ++v7;
16152 ++v0;
16153 v32 = v0;
16154 if ( v7 == 99 )
16155 {
16156 v12 = 0;
16157 v10 = v0 == 0;
16158 v11 = v0 < 0;
16159 goto LABEL_18;
16160 }
16161 }
16162 }
16163 }
16164 if ( !v31 )
16165 break;
16166 ++v6;
16167 }
16168 v4 = -1;
16169 ++v30;
16170 v5 = v29 + 640;
16171 v29 += 640;
16172 if ( v30 < v28 )
16173 continue;
16174 break;
16175 }
16176 v12 = 0;
16177 v10 = v0 == 0;
16178 v11 = v0 < 0;
16179 if ( !v0 )
16180 return 0;
16181 LABEL_18:
16182 if ( !((unsigned __int8)(v11 ^ v12) | v10) )
16183 {
16184 v14 = dword_720020_zvalues;
16185 v15 = 1;
16186 do
16187 {
16188 for ( i = v15; i < v32; ++i )
16189 {
16190 v17 = dword_720020_zvalues[i];
16191 if ( v17 < *v14 )
16192 {
16193 dword_720020_zvalues[i] = *v14;
16194 *v14 = v17;
16195 }
16196 }
16197 ++v15;
16198 ++v14;
16199 }
16200 while ( v15 - 1 < v32 );
16201 v0 = v32;
16202 }
16203 v18 = 0;
16204 if ( v0 <= 0 )
16205 return 0;
16206 while ( 1 )
16207 {
16208 v19 = dword_720020_zvalues[v18] & 0xFFFF;
16209 v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3;
16210 if ( (dword_720020_zvalues[v18] & 7) == 2 )
16211 {
16212 if ( v20 >= 0x3E8 )
16213 return 0;
16214 if ( !(pLayingItems[v20].uAttributes & 0x10) )
16215 {
16216 v23 = pLayingItems[v20].stru_24.GetDisplayName();
16217 LABEL_36:
16218 v24 = v23;
16219 goto LABEL_51;
16220 }
16221 goto LABEL_41;
16222 }
16223 if ( (dword_720020_zvalues[v18] & 7) == 3 )
16224 {
16225 if ( v20 >= 0xBB8 )
16226 return 0;
16227 v24 = (const char *)&pActors[v20];
16228 goto LABEL_51;
16229 }
16230 if ( (dword_720020_zvalues[v18] & 7) == 5 )
16231 break;
16232 if ( (dword_720020_zvalues[v18] & 7) == 6 )
16233 {
16234 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
16235 {
16236 v21 = &pIndoor->pFaces[v20];
16237 if ( !(BYTE3(v21->uAttributes) & 2) )
16238 goto LABEL_41;
16239 v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID;
16240 }
16241 else
16242 {
16243 if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels )
16244 goto LABEL_41;
16245 v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[((dword_720020_zvalues[v18] & 0xFFFFu) >> 3) & 0x3F].sCogTriggeredID;
16246 }
16247 if ( v22 )
16248 {
16249 v23 = _444732_GetEventHintString(v22);
16250 if ( v23 )
16251 goto LABEL_36;
16252 }
16253 }
16254 LABEL_41:
16255 ++v18;
16256 if ( v18 >= v0 )
16257 return 0;
16258 }
16259 v25 = &pLevelDecorations[v20];
16260 v26 = v25;
16261 v27 = v25->field_16_event_id;
16262 if ( v27 )
16263 {
16264 v23 = _444732_GetEventHintString(v27);
16265 if ( !v23 )
16266 return v19;
16267 goto LABEL_36;
16268 }
16269 if ( v25->IsInteractive() )
16270 v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic;
16271 else
16272 v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20;
16273 LABEL_51:
16274 sub_41C0B8_set_status_string(v24);
16275 return v19;
16276 }
16277
16278
16279 //----- (0046BDA8) --------------------------------------------------------
16280 unsigned int __cdecl GetGravityStrength()
16281 {
16282 int v0; // eax@1
16283
16284 v0 = ~LOBYTE(pGame->uFlags2) & 8;
16285 LOBYTE(v0) = v0 | 2;
16286 return (unsigned int)v0 >> 1;
16287 }
16288
16289 //----- (0046BDC0) --------------------------------------------------------
16290 void __cdecl sub_46BDC0_UpdateUserInput_and_MapSpecificStuff()
16291 {
16292 if ( dword_6BE364_game_settings_1 & 0x80 )
16293 {
16294 LOBYTE(dword_6BE364_game_settings_1) = dword_6BE364_game_settings_1 & 0x7F;
16295 }
16296 else
16297 {
16298 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
16299 {
16300 BLV_UpdateUserInputAndOther();
16301 }
16302 else
16303 {
16304 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
16305 ODM_UpdateUserInputAndOther();
16306 }
16307 _438F8F_area_of_effect__damage_evaluate();
16308 }
16309 }
16310
16311
16312
16313 //----- (0046BDF1) --------------------------------------------------------
16314 void __cdecl BLV_UpdateUserInputAndOther()
16315 {
16316 UpdateObjects();
16317 BLV_ProcessPartyActions();
16318 UpdateActors_BLV();
16319 BLV_UpdateDoors();
16320 _46CC4B_check_event_triggers();
16321 }
16322
16323 //----- (0046BE0A) --------------------------------------------------------
16324 void __cdecl ODM_UpdateUserInputAndOther()
16325 {
16326 bool v0; // eax@5
16327 int pOut; // [sp+8h] [bp-20h]@5
16328
16329 UpdateObjects();
16330 ODM_ProcessPartyActions();
16331 if ( pParty->vPosition.x < -22528
16332 || pParty->vPosition.x > 22528
16333 || pParty->vPosition.y < -22528
16334 || pParty->vPosition.y > 22528 )
16335 {
16336 strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
16337 v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, (char *)&pOut, 32);
16338 if ( !bUnderwater && (pParty->uFlags & 0x8C || BYTE1(pParty->uFlags) & 2 || pParty->bFlying) || !v0 )
16339 {
16340 if ( pParty->vPosition.x < -22528 )
16341 pParty->vPosition.x = -22528;
16342 if ( pParty->vPosition.x > 22528 )
16343 pParty->vPosition.x = 22528;
16344 if ( pParty->vPosition.y < -22528 )
16345 pParty->vPosition.y = -22528;
16346 if ( pParty->vPosition.y > 22528 )
16347 pParty->vPosition.y = 22528;
16348 }
16349 else
16350 {
16351 pAudioPlayer->StopChannels(-1, -1);
16352 UI_CreateTravelDialogue();
16353 }
16354 }
16355 //UpdateActors_ODM();Ritor1: it's temporarily
16356 _46CC4B_check_event_triggers();
16357 }
16358
16359
16360
16361
16362 //----- (0046BEF1) --------------------------------------------------------
16363 void LayingItem::_46BEF1_apply_spells()
16364 {
16365 LayingItem *v1; // edi@1
16366 char *v2; // esi@2
16367 __int16 v3; // fps@4
16368 unsigned __int8 v4; // c0@4
16369 unsigned __int8 v5; // c3@4
16370 signed int v6; // [sp+8h] [bp-4h]@1
16371
16372 v6 = 0;
16373 v1 = this;
16374 if ( (signed int)uNumActors > 0 )
16375 {
16376 v2 = (char *)&pActors[0].vPosition.y;
16377 do
16378 {
16379 if ( ((Actor *)(v2 - 144))->CanAct() )
16380 {
16381 //UNDEF(v3);
16382 if ( !(v4 | v5) )
16383 {
16384 if ( stru_50C198.GetMagicalResistance((Actor *)(v2 - 144), 0xAu) )
16385 {
16386 ((SpellBuff *)&v2[16 * v1->field_48 + 68])->Apply(
16387 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->field_4C << 7) * 0.033333335),
16388 v1->field_50,
16389 4u,
16390 0,
16391 0);
16392 *(v2 - 106) |= 8u;
16393 }
16394 }
16395 }
16396 ++v6;
16397 v2 += 836;
16398 }
16399 while ( v6 < (signed int)uNumActors );
16400 }
16401 }
16402
16403
16404 //----- (0046BFFA) --------------------------------------------------------
16405 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2)
16406 {
16407 LayingItem *v2; // esi@1
16408 ObjectDesc *v3; // ebx@1
16409 unsigned __int16 v5; // cx@9
16410 unsigned __int16 v6; // cx@14
16411 signed int v7; // edx@14
16412 unsigned int v8; // eax@19
16413 unsigned int v9; // edi@19
16414 signed int v10; // ebx@19
16415 char *v11; // edx@20
16416 unsigned __int16 v12; // ax@23
16417 int v13; // eax@27
16418 unsigned int v14; // ebx@33
16419 unsigned __int16 v15; // ax@35
16420 int v16; // eax@36
16421 unsigned int v17; // eax@37
16422 __int16 v18; // di@37
16423 signed int v19; // edx@37
16424 unsigned __int8 v20; // sf@37
16425 char *v21; // ecx@38
16426 unsigned __int16 v22; // ax@41
16427 unsigned int v23; // eax@46
16428 signed int v24; // ebx@46
16429 char *v25; // edx@47
16430 int v26; // edx@54
16431 int v27; // edx@55
16432 int v28; // edx@56
16433 int v29; // edx@57
16434 unsigned __int16 v30; // ax@60
16435 unsigned int v31; // ecx@60
16436 int v32; // edi@60
16437 unsigned int v33; // eax@65
16438 signed int v34; // edx@65
16439 char *v35; // ecx@66
16440 unsigned __int16 v36; // ax@69
16441 int v37; // ST14_4@72
16442 int v38; // eax@72
16443 int v39; // ST10_4@72
16444 int v40; // ST0C_4@72
16445 int v41; // edx@76
16446 int v42; // edx@77
16447 int v43; // edx@78
16448 unsigned __int8 v44; // zf@79
16449 int v45; // edx@79
16450 unsigned __int16 v46; // ax@80
16451 int v47; // eax@81
16452 int v48; // edx@87
16453 int v49; // edx@88
16454 int v50; // edx@89
16455 unsigned int v51; // eax@93
16456 signed int v52; // ebx@93
16457 char *v53; // edx@94
16458 unsigned __int16 v54; // ax@98
16459 unsigned int v55; // ecx@98
16460 signed int v56; // ebx@98
16461 char *v57; // edx@99
16462 unsigned __int16 v58; // ax@102
16463 unsigned __int16 v59; // ax@107
16464 unsigned int v60; // ecx@107
16465 signed int v61; // ebx@107
16466 char *v62; // edx@108
16467 unsigned __int16 v63; // ax@111
16468 int v64; // ebx@114
16469 signed int v65; // eax@114
16470 unsigned int v66; // edi@123
16471 unsigned __int16 v67; // ax@124
16472 unsigned int v68; // ecx@124
16473 signed int v69; // ebx@124
16474 char *v70; // edx@125
16475 unsigned __int16 v71; // ax@128
16476 unsigned int v72; // ebx@131
16477 int v73; // ST14_4@132
16478 int v74; // ST10_4@132
16479 int v75; // ebx@132
16480 int v76; // ST0C_4@132
16481 unsigned __int16 v77; // ax@132
16482 int v78; // eax@133
16483 char v79; // zf@139
16484 unsigned int v80; // eax@140
16485 signed int v81; // edx@140
16486 char *v82; // ecx@141
16487 unsigned __int16 v83; // ax@144
16488 unsigned __int16 v84; // ax@151
16489 unsigned int v85; // ecx@151
16490 signed int v86; // ebx@151
16491 char *v87; // edx@152
16492 unsigned __int16 v88; // ax@155
16493 unsigned int v89; // eax@158
16494 int v90; // ST34_4@159
16495 int v91; // eax@159
16496 unsigned int v92; // eax@163
16497 unsigned int v93; // eax@177
16498 char *v94; // ecx@178
16499 unsigned __int16 v95; // ax@181
16500 unsigned __int16 v96; // ax@184
16501 int v97; // eax@185
16502 unsigned __int16 v98; // ax@191
16503 unsigned int v99; // ecx@191
16504 char v100; // ST18_1@198
16505 int v101; // ST14_4@198
16506 int v102; // eax@198
16507 int v103; // ST10_4@198
16508 int v104; // ST0C_4@198
16509 unsigned __int16 v105; // ax@200
16510 signed int v106; // eax@208
16511 unsigned int v107; // edx@220
16512 signed int v108; // ebx@225
16513 unsigned int v109; // eax@234
16514 signed int v110; // ebx@234
16515 char *v111; // ecx@235
16516 unsigned __int16 v112; // ax@238
16517 unsigned __int16 v113; // si@241
16518 int v114; // eax@242
16519 int v115; // eax@245
16520 signed int v116; // eax@245
16521 unsigned __int16 v117; // ax@251
16522 unsigned int v118; // ecx@251
16523 signed int v119; // ebx@251
16524 char *v120; // edx@252
16525 unsigned __int16 v121; // ax@255
16526 unsigned int v122; // eax@260
16527 char *v123; // edx@261
16528 int v124; // eax@267
16529 int v125; // [sp-20h] [bp-4Ch]@28
16530 signed int v126; // [sp-1Ch] [bp-48h]@27
16531 unsigned int v127; // [sp-18h] [bp-44h]@27
16532 signed int v128; // [sp-14h] [bp-40h]@27
16533 signed int v129; // [sp-10h] [bp-3Ch]@27
16534 int v130; // [sp-Ch] [bp-38h]@27
16535 unsigned int v131; // [sp-8h] [bp-34h]@27
16536 char v132; // [sp-8h] [bp-34h]@131
16537 int v133; // [sp-4h] [bp-30h]@27
16538 char v134; // [sp-4h] [bp-30h]@131
16539 signed int v135; // [sp-4h] [bp-30h]@217
16540 int v136; // [sp+Ch] [bp-20h]@208
16541 int v137; // [sp+10h] [bp-1Ch]@208
16542 signed int v138; // [sp+14h] [bp-18h]@207
16543 signed int v139; // [sp+18h] [bp-14h]@208
16544 char *v140; // [sp+1Ch] [bp-10h]@61
16545 signed int v141; // [sp+1Ch] [bp-10h]@117
16546 unsigned int v142; // [sp+1Ch] [bp-10h]@158
16547 signed int v143; // [sp+1Ch] [bp-10h]@172
16548 char *v144; // [sp+1Ch] [bp-10h]@192
16549 signed int v145; // [sp+20h] [bp-Ch]@1
16550 signed int v146; // [sp+20h] [bp-Ch]@60
16551 int v147; // [sp+20h] [bp-Ch]@72
16552 signed int v148; // [sp+20h] [bp-Ch]@158
16553 int v149; // [sp+20h] [bp-Ch]@198
16554 unsigned __int16 v150; // [sp+20h] [bp-Ch]@208
16555 int v151; // [sp+24h] [bp-8h]@1
16556 signed int v152; // [sp+24h] [bp-8h]@208
16557 unsigned int v153; // [sp+28h] [bp-4h]@1
16558
16559 v153 = uLayingItemID;
16560 v2 = &pLayingItems[uLayingItemID];
16561 v3 = &pObjectList->pObjects[v2->uObjectDescID];
16562 v145 = a2;
16563 v151 = a2 & 7;
16564 if ( (a2 & 7) == 3 )
16565 {
16566 if ( (v2->field_58 & 7) == 3 && !pActors[v2->field_58 >> 3].GetActorsRelation(&pActors[a2 >> 3]) )
16567 return 1;
16568 }
16569 else
16570 {
16571 if ( (a2 & 7) == 4 && (v2->field_58 & 7) == 4 )
16572 return 1;
16573 }
16574 if ( pParty->bTurnBasedModeOn == 1 )
16575 {
16576 v5 = v2->uAttributes;
16577 if ( v5 & 4 )
16578 {
16579 --pTurnEngine->field_1C;
16580 v2->uAttributes = v5 & 0xFFFB;
16581 }
16582 }
16583 if ( v151 == 6 && (v2->field_58 & 7) != 4 )
16584 BYTE2(pActors[v2->field_58 >> 3].uAttributes) |= 4u;
16585 v6 = v2->uItemType;
16586 v7 = v2->uItemType;
16587 if ( v7 > 3060 )
16588 {
16589 if ( v7 > 6090 )
16590 {
16591 if ( v7 > 8090 )
16592 {
16593 if ( v7 == 9010 )
16594 goto LABEL_247;
16595 if ( v7 != 9030 )
16596 {
16597 if ( v7 != 9040 )
16598 {
16599 if ( v7 != 9080 )
16600 return 0;
16601 LABEL_191:
16602 v98 = v6 + 1;
16603 v99 = pObjectList->uNumObjects;
16604 v32 = 0;
16605 v2->uItemType = v98;
16606 v146 = 0;
16607 if ( (signed int)v99 > 0 )
16608 {
16609 v144 = (char *)&pObjectList->pObjects->uObjectID;
16610 while ( v98 != *(short *)v144 )
16611 {
16612 ++v146;
16613 v144 += 56;
16614 if ( v146 >= (signed int)v99 )
16615 goto LABEL_195;
16616 }
16617 goto LABEL_80;
16618 }
16619 LABEL_195:
16620 v46 = 0;
16621 goto LABEL_196;
16622 }
16623 goto LABEL_93;
16624 }
16625 LABEL_172:
16626 v143 = 17030;
16627 switch ( v6 )
16628 {
16629 case 0x1798u:
16630 v143 = 15040;
16631 break;
16632 case 0xFAAu:
16633 v143 = 13010;
16634 break;
16635 case 0x2346u:
16636 v143 = 18030;
16637 break;
16638 }
16639 v138 = 1;
16640 if ( v151 != 3 )
16641 {
16642 if ( v6 != 9030 || v2->field_50 != 4 )
16643 goto LABEL_246;
16644 v2->_46BEF1_apply_spells();
16645 LABEL_233:
16646 if ( !v138 )
16647 {
16648 v109 = pObjectList->uNumObjects;
16649 ++v2->uItemType;
16650 v110 = 0;
16651 if ( (signed int)v109 <= 0 )
16652 {
16653 LABEL_238:
16654 v112 = 0;
16655 }
16656 else
16657 {
16658 v111 = (char *)&pObjectList->pObjects->uObjectID;
16659 while ( v2->uItemType != *(short *)v111 )
16660 {
16661 ++v110;
16662 v111 += 56;
16663 if ( v110 >= (signed int)v109 )
16664 goto LABEL_238;
16665 }
16666 v112 = v110;
16667 }
16668 v2->uObjectDescID = v112;
16669 if ( !v112 )
16670 LayingItem::_42F933(v153);
16671 v2->vVelocity.z = 0;
16672 v2->vVelocity.y = 0;
16673 v2->vVelocity.x = 0;
16674 v2->uSpriteFrameID = 0;
16675 v113 = v2->uSoundID;
16676 if ( v113 )
16677 v114 = (signed __int16)v113 + 4;
16678 else
16679 v114 = 0;
16680 v133 = 0;
16681 v131 = 0;
16682 v130 = v114;
16683 v115 = 8 * v153;
16684 v129 = 0;
16685 v128 = -1;
16686 LOBYTE(v115) = 8 * v153 | 2;
16687 v127 = 0;
16688 v126 = v115;
16689 v116 = v143;
16690 goto LABEL_269;
16691 }
16692 LABEL_246:
16693 LayingItem::_42F933(v153);
16694 return 0;
16695 }
16696 v106 = v145;
16697 v150 = 0;
16698 v139 = v106 >> 3;
16699 v137 = v2->field_4C;
16700 v152 = v2->field_50;
16701 v136 = v2->field_48;
16702 if ( v6 == 9030 )
16703 {
16704 v150 = 2;
16705 if ( v152 == 2 )
16706 {
16707 v150 = 3;
16708 }
16709 else
16710 {
16711 if ( v152 >= 3 )
16712 v150 = 4;
16713 }
16714 BYTE2(pActors[v139].uAttributes) |= 8u;
16715 }
16716 if ( v7 == 6040 )
16717 {
16718 v135 = 7;
16719 }
16720 else
16721 {
16722 if ( v7 == 8030 )
16723 {
16724 v135 = 9;
16725 }
16726 else
16727 {
16728 if ( v7 != 9030 )
16729 {
16730 v107 = v136;
16731 LABEL_222:
16732 if ( v6 != 9030 || v152 != 4 )
16733 {
16734 v108 = v139;
16735 if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) )
16736 {
16737 v138 = 0;
16738 if ( v2->uItemType == 8030 )
16739 {
16740 pActors[v108].uAIState = Standing;
16741 pActors[v108].UpdateAnimation();
16742 }
16743 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[v136] + v108 * 836))->Apply(
16744 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
16745 v152,
16746 v150,
16747 0,
16748 0);
16749 }
16750 }
16751 else
16752 {
16753 v2->_46BEF1_apply_spells();
16754 }
16755 v2->field_4C = 0;
16756 v2->field_50 = 0;
16757 v2->field_48 = 0;
16758 goto LABEL_233;
16759 }
16760 v135 = 10;
16761 }
16762 }
16763 v107 = v135;
16764 goto LABEL_222;
16765 }
16766 if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 )
16767 goto LABEL_93;
16768 if ( v7 == 8010 )
16769 {
16770 if ( v151 == 3
16771 && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
16772 sub_43A97E(v153, v145);
16773 v93 = pObjectList->uNumObjects;
16774 ++v2->uItemType;
16775 v9 = 0;
16776 v52 = 0;
16777 if ( (signed int)v93 > 0 )
16778 {
16779 v94 = (char *)&pObjectList->pObjects->uObjectID;
16780 while ( v2->uItemType != *(short *)v94 )
16781 {
16782 ++v52;
16783 v94 += 56;
16784 if ( v52 >= (signed int)v93 )
16785 goto LABEL_181;
16786 }
16787 goto LABEL_202;
16788 }
16789 goto LABEL_181;
16790 }
16791 v79 = v7 == 8030;
16792 }
16793 else
16794 {
16795 if ( v7 == 6090 )
16796 goto LABEL_93;
16797 if ( v7 <= 4070 )
16798 {
16799 if ( v7 != 4070 )
16800 {
16801 v48 = v7 - 3090;
16802 if ( v48 )
16803 {
16804 v49 = v48 - 2;
16805 if ( v49 )
16806 {
16807 v50 = v49 - 908;
16808 if ( !v50 )
16809 goto LABEL_93;
16810 v45 = v50 - 30;
16811 v44 = v45 == 0;
16812 goto LABEL_91;
16813 }
16814 v54 = v6 - 1;
16815 v55 = pObjectList->uNumObjects;
16816 v9 = 0;
16817 v56 = 0;
16818 v44 = pObjectList->uNumObjects == 0;
16819 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
16820 v2->uItemType = v54;
16821 if ( v20 | v44 )
16822 {
16823 LABEL_102:
16824 v58 = 0;
16825 }
16826 else
16827 {
16828 v57 = (char *)&pObjectList->pObjects->uObjectID;
16829 while ( v54 != *(short *)v57 )
16830 {
16831 ++v56;
16832 v57 += 56;
16833 if ( v56 >= (signed int)v55 )
16834 goto LABEL_102;
16835 }
16836 v58 = v56;
16837 }
16838 v2->uObjectDescID = v58;
16839 if ( !v58 )
16840 LayingItem::_42F933(v153);
16841 v14 = v153;
16842 v2->vVelocity.z = 0;
16843 v2->vVelocity.y = 0;
16844 v2->vVelocity.x = 0;
16845 v2->uSpriteFrameID = 0;
16846 sub_43A97E(v153, v145);
16847 LABEL_35:
16848 v15 = v2->uSoundID;
16849 if ( v15 == (short)v9 )
16850 v16 = 0;
16851 else
16852 v16 = (signed __int16)v15 + 4;
16853 v133 = v9;
16854 v131 = v9;
16855 v130 = v16;
16856 v92 = v14;
16857 LABEL_267:
16858 v124 = 8 * v92;
16859 v129 = v9;
16860 v128 = -1;
16861 LOBYTE(v124) = v124 | 2;
16862 v127 = v9;
16863 v126 = v124;
16864 LABEL_268:
16865 v116 = word_4EE088_sound_ids[v2->field_48];
16866 LABEL_269:
16867 v125 = v116 + 1;
16868 goto LABEL_29;
16869 }
16870 v59 = v6 + 2;
16871 v60 = pObjectList->uNumObjects;
16872 v9 = 0;
16873 v61 = 0;
16874 v44 = pObjectList->uNumObjects == 0;
16875 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
16876 v2->uItemType = v59;
16877 if ( v20 | v44 )
16878 {
16879 LABEL_111:
16880 v63 = 0;
16881 }
16882 else
16883 {
16884 v62 = (char *)&pObjectList->pObjects->uObjectID;
16885 while ( v59 != *(short *)v62 )
16886 {
16887 ++v61;
16888 v62 += 56;
16889 if ( v61 >= (signed int)v60 )
16890 goto LABEL_111;
16891 }
16892 v63 = v61;
16893 }
16894 v2->uObjectDescID = v63;
16895 if ( !v63 )
16896 LayingItem::_42F933(v153);
16897 v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
16898 v44 = v2->field_50 == 4;
16899 v2->vVelocity.z = 0;
16900 v2->vVelocity.y = 0;
16901 v2->vVelocity.x = 0;
16902 v65 = 7;
16903 if ( v44 )
16904 v65 = 9;
16905 if ( v65 > 0 )
16906 {
16907 v141 = v65;
16908 do
16909 {
16910 v64 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
16911 v2->Create(v64, 0, 1000, 0);
16912 --v141;
16913 }
16914 while ( v141 );
16915 }
16916 LABEL_160:
16917 v14 = v153;
16918 LABEL_34:
16919 LayingItem::_42F933(v14);
16920 goto LABEL_35;
16921 }
16922 if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
16923 return 1;
16924 v67 = v6 + 1;
16925 v68 = pObjectList->uNumObjects;
16926 v69 = 0;
16927 v44 = pObjectList->uNumObjects == 0;
16928 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
16929 v2->uItemType = v67;
16930 if ( v20 | v44 )
16931 {
16932 LABEL_128:
16933 v71 = 0;
16934 }
16935 else
16936 {
16937 v70 = (char *)&pObjectList->pObjects->uObjectID;
16938 while ( v67 != *(short *)v70 )
16939 {
16940 ++v69;
16941 v70 += 56;
16942 if ( v69 >= (signed int)v68 )
16943 goto LABEL_128;
16944 }
16945 v71 = v69;
16946 }
16947 v2->uObjectDescID = v71;
16948 if ( !v71 )
16949 LayingItem::_42F933(v153);
16950 v134 = 0;
16951 v72 = v153;
16952 v132 = 0;
16953 LABEL_132:
16954 v73 = v2->vPosition.z;
16955 v74 = v2->vPosition.y;
16956 v75 = 8 * v72 | 2;
16957 v2->vVelocity.z = v66;
16958 v2->vVelocity.y = v66;
16959 v76 = v2->vPosition.x;
16960 v2->vVelocity.x = v66;
16961 v2->uSpriteFrameID = v66;
16962 stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134);
16963 v77 = v2->uSoundID;
16964 if ( v77 == (short)v66 )
16965 v78 = 0;
16966 else
16967 v78 = (signed __int16)v77 + 4;
16968 v133 = v66;
16969 v131 = v66;
16970 v130 = v78;
16971 v129 = v66;
16972 v128 = -1;
16973 v127 = v66;
16974 v126 = v75;
16975 goto LABEL_268;
16976 }
16977 if ( v7 == 4090 )
16978 {
16979 v84 = v6 + 2;
16980 v85 = pObjectList->uNumObjects;
16981 v9 = 0;
16982 v86 = 0;
16983 v44 = pObjectList->uNumObjects == 0;
16984 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
16985 v2->uItemType = v84;
16986 if ( v20 | v44 )
16987 {
16988 LABEL_155:
16989 v88 = 0;
16990 }
16991 else
16992 {
16993 v87 = (char *)&pObjectList->pObjects->uObjectID;
16994 while ( v84 != *(short *)v87 )
16995 {
16996 ++v86;
16997 v87 += 56;
16998 if ( v86 >= (signed int)v85 )
16999 goto LABEL_155;
17000 }
17001 v88 = v86;
17002 }
17003 v2->uObjectDescID = v88;
17004 if ( !v88 )
17005 LayingItem::_42F933(v153);
17006 v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
17007 v2->vVelocity.z = 0;
17008 v2->vVelocity.y = 0;
17009 v2->vVelocity.x = 0;
17010 v142 = v89;
17011 v148 = 7;
17012 do
17013 {
17014 pRnd->SetRange(-128, 128);
17015 v90 = pRnd->GetInRange();
17016 pRnd->SetRange(5, 500);
17017 v91 = pRnd->GetInRange();
17018 v142 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
17019 v2->Create(v90 + v142, 0, v91, 0);
17020 --v148;
17021 }
17022 while ( v148 );
17023 goto LABEL_160;
17024 }
17025 if ( v7 == 4092 )
17026 {
17027 v80 = pObjectList->uNumObjects;
17028 v66 = 0;
17029 v81 = 0;
17030 v44 = pObjectList->uNumObjects == 0;
17031 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
17032 v2->uItemType = 4091;
17033 if ( v20 | v44 )
17034 {
17035 LABEL_144:
17036 v83 = 0;
17037 }
17038 else
17039 {
17040 v82 = (char *)&pObjectList->pObjects->uObjectID;
17041 while ( *(short *)v82 != 4091 )
17042 {
17043 ++v81;
17044 v82 += 56;
17045 if ( v81 >= (signed int)v80 )
17046 goto LABEL_144;
17047 }
17048 v83 = v81;
17049 }
17050 v2->uObjectDescID = v83;
17051 if ( !v83 )
17052 LayingItem::_42F933(v153);
17053 v134 = 0;
17054 v72 = v153;
17055 v132 = v2->field_61;
17056 goto LABEL_132;
17057 }
17058 if ( v7 == 4100 || v7 == 6010 )
17059 goto LABEL_93;
17060 v79 = v7 == 6040;
17061 }
17062 if ( !v79 )
17063 return 0;
17064 goto LABEL_172;
17065 }
17066 if ( v7 == 3060 )
17067 goto LABEL_93;
17068 if ( v7 <= 555 )
17069 {
17070 if ( v7 == 555 )
17071 {
17072 sub_43A97E(v153, v145);
17073 v23 = pObjectList->uNumObjects;
17074 ++v2->uItemType;
17075 v18 = 0;
17076 v24 = 0;
17077 if ( (signed int)v23 <= 0 )
17078 {
17079 LABEL_41:
17080 v22 = 0;
17081 }
17082 else
17083 {
17084 v25 = (char *)&pObjectList->pObjects->uObjectID;
17085 while ( v2->uItemType != *(short *)v25 )
17086 {
17087 ++v24;
17088 v25 += 56;
17089 if ( v24 >= (signed int)v23 )
17090 goto LABEL_41;
17091 }
17092 v22 = v24;
17093 }
17094 LABEL_42:
17095 v2->uObjectDescID = v22;
17096 if ( v22 == v18 )
17097 LayingItem::_42F933(v153);
17098 v2->vVelocity.z = v18;
17099 v2->vVelocity.y = v18;
17100 v2->vVelocity.x = v18;
17101 v2->uSpriteFrameID = v18;
17102 }
17103 else
17104 {
17105 switch ( v7 )
17106 {
17107 case 500:
17108 case 505:
17109 case 510:
17110 case 515:
17111 case 520:
17112 case 525:
17113 case 530:
17114 case 535:
17115 case 540:
17116 sub_43A97E(v153, v145);
17117 v8 = pObjectList->uNumObjects;
17118 ++v2->uItemType;
17119 v9 = 0;
17120 v10 = 0;
17121 if ( (signed int)v8 <= 0 )
17122 goto LABEL_23;
17123 v11 = (char *)&pObjectList->pObjects->uObjectID;
17124 break;
17125 case 545:
17126 case 550:
17127 if ( v2->stru_24.uItemID != 405 && v2->stru_24.uAdditionalValue != 3 )
17128 {
17129 v14 = v153;
17130 v9 = 0;
17131 v2->vVelocity.z = 0;
17132 v2->vVelocity.y = 0;
17133 v2->vVelocity.x = 0;
17134 v2->uSpriteFrameID = 0;
17135 sub_43A97E(v153, v145);
17136 goto LABEL_34;
17137 }
17138 v17 = pObjectList->uNumObjects;
17139 v18 = 0;
17140 v19 = 0;
17141 v44 = pObjectList->uNumObjects == 0;
17142 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
17143 v2->uItemType = 600;
17144 if ( v20 | v44 )
17145 goto LABEL_41;
17146 v21 = (char *)&pObjectList->pObjects->uObjectID;
17147 while ( *(short *)v21 != 600 )
17148 {
17149 ++v19;
17150 v21 += 56;
17151 if ( v19 >= (signed int)v17 )
17152 goto LABEL_41;
17153 }
17154 v22 = v19;
17155 goto LABEL_42;
17156 default:
17157 return 0;
17158 }
17159 while ( v2->uItemType != *(short *)v11 )
17160 {
17161 ++v10;
17162 v11 += 56;
17163 if ( v10 >= (signed int)v8 )
17164 {
17165 LABEL_23:
17166 v12 = 0;
17167 goto LABEL_24;
17168 }
17169 }
17170 v12 = v10;
17171 LABEL_24:
17172 v2->uObjectDescID = v12;
17173 if ( !v12 )
17174 LayingItem::_42F933(v153);
17175 v44 = v2->uItemType == 555;
17176 v2->vVelocity.z = 0;
17177 v2->vVelocity.y = 0;
17178 v2->vVelocity.x = 0;
17179 v2->uSpriteFrameID = 0;
17180 if ( !v44 )
17181 goto LABEL_27;
17182 }
17183 return 0;
17184 }
17185 if ( v7 > 1100 )
17186 {
17187 v41 = v7 - 2030;
17188 if ( !v41 )
17189 goto LABEL_247;
17190 v42 = v41 - 30;
17191 if ( v42 )
17192 {
17193 v43 = v42 - 40;
17194 if ( !v43 )
17195 goto LABEL_59;
17196 v45 = v43 - 910;
17197 v44 = v45 == 0;
17198 LABEL_91:
17199 if ( !v44 && v45 != 20 )
17200 return 0;
17201 }
17202 LABEL_93:
17203 sub_43A97E(v153, v145);
17204 v51 = pObjectList->uNumObjects;
17205 ++v2->uItemType;
17206 v9 = 0;
17207 v52 = 0;
17208 if ( (signed int)v51 > 0 )
17209 {
17210 v53 = (char *)&pObjectList->pObjects->uObjectID;
17211 while ( v2->uItemType != *(short *)v53 )
17212 {
17213 ++v52;
17214 v53 += 56;
17215 if ( v52 >= (signed int)v51 )
17216 goto LABEL_181;
17217 }
17218 goto LABEL_202;
17219 }
17220 LABEL_181:
17221 v95 = 0;
17222 LABEL_182:
17223 v2->uObjectDescID = v95;
17224 if ( v95 == (short)v9 )
17225 LayingItem::_42F933(v153);
17226 v96 = v2->uSoundID;
17227 v2->vVelocity.z = v9;
17228 v2->vVelocity.y = v9;
17229 v2->vVelocity.x = v9;
17230 v2->uSpriteFrameID = v9;
17231 if ( v96 == (short)v9 )
17232 v97 = 0;
17233 else
17234 v97 = (signed __int16)v96 + 4;
17235 v133 = v9;
17236 v131 = v9;
17237 v130 = v97;
17238 v92 = v153;
17239 goto LABEL_267;
17240 }
17241 if ( v7 == 1100 )
17242 goto LABEL_93;
17243 v26 = v7 - 600;
17244 if ( !v26 )
17245 {
17246 v33 = pObjectList->uNumObjects;
17247 v34 = 0;
17248 v44 = pObjectList->uNumObjects == 0;
17249 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
17250 v2->uItemType = 601;
17251 if ( v20 | v44 )
17252 {
17253 LABEL_69:
17254 v36 = 0;
17255 }
17256 else
17257 {
17258 v35 = (char *)&pObjectList->pObjects->uObjectID;
17259 while ( *(short *)v35 != 601 )
17260 {
17261 ++v34;
17262 v35 += 56;
17263 if ( v34 >= (signed int)v33 )
17264 goto LABEL_69;
17265 }
17266 v36 = v34;
17267 }
17268 v2->uObjectDescID = v36;
17269 if ( !v36 )
17270 LayingItem::_42F933(v153);
17271 v37 = v2->vPosition.z;
17272 v2->vVelocity.z = 0;
17273 v38 = 8 * v153;
17274 v39 = v2->vPosition.y;
17275 LOBYTE(v38) = 8 * v153 | 2;
17276 v2->vVelocity.y = 0;
17277 v2->vVelocity.x = 0;
17278 v40 = v2->vPosition.x;
17279 v2->uSpriteFrameID = 0;
17280 v147 = v38;
17281 stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0);
17282 if ( HIBYTE(v3->uFlags) & 1 )
17283 array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor);
17284 v133 = 0;
17285 v131 = 0;
17286 v130 = 0;
17287 v129 = 0;
17288 v128 = -1;
17289 v127 = 0;
17290 v126 = v147;
17291 goto LABEL_28;
17292 }
17293 v27 = v26 - 410;
17294 if ( !v27 )
17295 goto LABEL_93;
17296 v28 = v27 - 40;
17297 if ( !v28 )
17298 goto LABEL_191;
17299 v29 = v28 - 10;
17300 if ( v29 )
17301 {
17302 if ( v29 != 20 )
17303 return 0;
17304 LABEL_59:
17305 if ( v151 != 3 )
17306 {
17307 v30 = v6 + 1;
17308 v31 = pObjectList->uNumObjects;
17309 v32 = 0;
17310 v2->uItemType = v30;
17311 v146 = 0;
17312 if ( (signed int)v31 > 0 )
17313 {
17314 v140 = (char *)&pObjectList->pObjects->uObjectID;
17315 while ( v30 != *(short *)v140 )
17316 {
17317 ++v146;
17318 v140 += 56;
17319 if ( v146 >= (signed int)v31 )
17320 goto LABEL_195;
17321 }
17322 LABEL_80:
17323 v46 = v146;
17324 LABEL_196:
17325 v2->uObjectDescID = v46;
17326 if ( v46 == (short)v32 )
17327 LayingItem::_42F933(v153);
17328 v100 = v2->field_61;
17329 v101 = v2->vPosition.z;
17330 v2->uSpriteFrameID = v32;
17331 v102 = 8 * v153;
17332 v103 = v2->vPosition.y;
17333 LOBYTE(v102) = 8 * v153 | 2;
17334 v2->vVelocity.x = v32;
17335 v2->vVelocity.y = v32;
17336 v104 = v2->vPosition.x;
17337 v2->vVelocity.z = v32;
17338 v149 = v102;
17339 stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
17340 if ( HIBYTE(v3->uFlags) & 1 )
17341 array_5118E8._440E91(
17342 v2->vPosition.x,
17343 v2->vPosition.y,
17344 v2->vPosition.z,
17345 v32,
17346 v3->uParticleTrailColor);
17347 v105 = v2->uSoundID;
17348 if ( v105 == (short)v32 )
17349 v47 = 0;
17350 else
17351 v47 = (signed __int16)v105 + 4;
17352 v133 = v32;
17353 v131 = v32;
17354 v130 = v47;
17355 v129 = v32;
17356 v128 = -1;
17357 v127 = v32;
17358 v126 = v149;
17359 goto LABEL_268;
17360 }
17361 goto LABEL_195;
17362 }
17363 return 1;
17364 }
17365 LABEL_247:
17366 if ( v151 == 6 || v151 == 5 || (v9 = 0, !v151) )
17367 return 1;
17368 if ( v151 != 2 )
17369 {
17370 sub_43A97E(v153, v145);
17371 v122 = pObjectList->uNumObjects;
17372 ++v2->uItemType;
17373 v52 = 0;
17374 if ( (signed int)v122 > 0 )
17375 {
17376 v123 = (char *)&pObjectList->pObjects->uObjectID;
17377 while ( v2->uItemType != *(short *)v123 )
17378 {
17379 ++v52;
17380 v123 += 56;
17381 if ( v52 >= (signed int)v122 )
17382 goto LABEL_181;
17383 }
17384 LABEL_202:
17385 v95 = v52;
17386 goto LABEL_182;
17387 }
17388 goto LABEL_181;
17389 }
17390 v117 = v6 + 1;
17391 v118 = pObjectList->uNumObjects;
17392 v119 = 0;
17393 v44 = pObjectList->uNumObjects == 0;
17394 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
17395 v2->uItemType = v117;
17396 if ( v20 | v44 )
17397 {
17398 LABEL_255:
17399 v121 = 0;
17400 }
17401 else
17402 {
17403 v120 = (char *)&pObjectList->pObjects->uObjectID;
17404 while ( v117 != *(short *)v120 )
17405 {
17406 ++v119;
17407 v120 += 56;
17408 if ( v119 >= (signed int)v118 )
17409 goto LABEL_255;
17410 }
17411 v121 = v119;
17412 }
17413 v2->uObjectDescID = v121;
17414 if ( !v121 )
17415 LayingItem::_42F933(v153);
17416 v2->vVelocity.z = 0;
17417 v2->vVelocity.y = 0;
17418 v2->vVelocity.x = 0;
17419 v2->uSpriteFrameID = 0;
17420 LABEL_27:
17421 v133 = v9;
17422 v131 = v9;
17423 v130 = v9;
17424 v13 = 8 * v153;
17425 v129 = v9;
17426 v128 = -1;
17427 LOBYTE(v13) = 8 * v153 | 2;
17428 v127 = v9;
17429 v126 = v13;
17430 LABEL_28:
17431 v125 = 8;
17432 LABEL_29:
17433 pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
17434 return 0;
17435 }
17436