comparison mm7_2.cpp @ 1542:7d986a396092

Merge
author Nomad
date Sat, 07 Sep 2013 13:03:18 +0200
parents 86cb7398d2a8 3c33f3e44f71
children 888157f45502
comparison
equal deleted inserted replaced
1541:86cb7398d2a8 1542:7d986a396092
216 } 216 }
217 return 0; 217 return 0;
218 } 218 }
219 219
220 //----- (004BBA85) -------------------------------------------------------- 220 //----- (004BBA85) --------------------------------------------------------
221 const char *sub_4BBA85_bounties() 221 void CheckBountyRespawnAndAward()
222 { 222 {
223 int v0; // edi@1
224 signed __int64 v1; // qax@2
225 int i; // eax@2 223 int i; // eax@2
226 int v3; // edx@3 224 int rand_monster_id; // edx@3
227 int v4; // edi@14
228 __int16 v5; // ax@14
229 char v6; // zf@14
230 Player *v7; // ebx@16
231 const char *result; // eax@19
232 225
233 uDialogueType = 83; 226 uDialogueType = 83;
234 pDialogueWindow->Release(); 227 pDialogueWindow->Release();
235 pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); 228 pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
236 pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" 229 pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
237 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); 230 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
238 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); 231 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
239 pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0); 232 pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_0, 83, 0, "", 0);
240 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); 233 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
241 dialog_menu_id = HOUSE_DIALOGUE_OTHER; 234 dialog_menu_id = HOUSE_DIALOGUE_OTHER;
242 v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102); 235 //get new monster for hunting
243 if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed ) 236 if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed )
244 { 237 {
245 pParty->field_75A[v0] = 0; 238 pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false;
246 __debugbreak(); // starting year-related constant here; 239 pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
247 v1 = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015))
248 * 0.033333335);
249 pParty->field_3C.field_0[2 * v0] = v1;
250 pParty->field_3C.field_0[2 * v0 + 1] = HIDWORD(v1);
251 for ( i = rand(); ; i = rand() ) 240 for ( i = rand(); ; i = rand() )
252 { 241 {
253 v3 = i % 258 + 1; 242 rand_monster_id = i % 258 + 1;
254 pParty->field_750[v0] = v3; 243 pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = rand_monster_id;
255 if ( (unsigned __int16)v3 < 0x73u || (unsigned __int16)v3 > 0x84u ) 244 if ( (unsigned __int16)rand_monster_id < 0x73u || (unsigned __int16)rand_monster_id > 0x84u )
256 { 245 {
257 if ( ((unsigned __int16)v3 < 0xEBu || (unsigned __int16)v3 > 0xFCu) 246 if ( ((unsigned __int16)rand_monster_id < 0xEBu || (unsigned __int16)rand_monster_id > 0xFCu)
258 && ((unsigned __int16)v3 < 0x85u || (unsigned __int16)v3 > 0x96u) 247 && ((unsigned __int16)rand_monster_id < 0x85u || (unsigned __int16)rand_monster_id > 0x96u)
259 && ((unsigned __int16)v3 < 0x97u || (unsigned __int16)v3 > 0xBAu) 248 && ((unsigned __int16)rand_monster_id < 0x97u || (unsigned __int16)rand_monster_id > 0xBAu)
260 && ((unsigned __int16)v3 < 0xC4u || (unsigned __int16)v3 > 0xC6u) ) 249 && ((unsigned __int16)rand_monster_id < 0xC4u || (unsigned __int16)rand_monster_id > 0xC6u) )
261 break; 250 break;
262 } 251 }
263 } 252 }
264 } 253 }
265 v4 = v0; 254 bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)];
266 v5 = pParty->field_750[v4]; 255 if ( !pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
267 v6 = pParty->field_75A[v4] == 0; 256 {
268 word_F8B1A0 = pParty->field_750[v4]; 257 bountyHunting_text = pNPCTopics[351].pText;
269 if ( v6 ) 258 if ( !pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
270 { 259 bountyHunting_text = pNPCTopics[353].pText;
271 v6 = v5 == 0; 260 }
272 result = pNPCTopics[351].pText; 261 else//get prize
273 if ( v6 ) 262 {
274 result = pNPCTopics[353].pText; 263 if ( pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] )
275 } 264 {
276 else 265 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0);
277 { 266 for ( uint i = 0; i < 4; ++i )
278 if ( v5 ) 267 pParty->pPlayers[i].SetVariable(VAR_Award, 86);
279 { 268 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel;
280 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v5].uLevel, 0); 269 pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = 0;
281 v7 = pParty->pPlayers; 270 pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false;
282 do 271 }
283 { 272 bountyHunting_text = pNPCTopics[352].pText;
284 v7->SetVariable(VAR_Award, 86); 273 }
285 ++v7;
286 }
287 while ( (signed int)v7 < (signed int)pParty->pHirelings );
288 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v4]].uLevel;
289 pParty->field_750[v4] = 0;
290 pParty->field_75A[v4] = 0;
291 }
292 result = pNPCTopics[352].pText;
293 }
294 dword_F8B1A4 = (char *)result;
295 return result;
296 } 274 }
297 275
298 //----- (004BBCDD) -------------------------------------------------------- 276 //----- (004BBCDD) --------------------------------------------------------
299 void sub_4BBCDD() 277 void sub_4BBCDD()
300 { 278 {
332 } 310 }
333 if ( v0 >= (signed int)uNumActors || (signed int)uNumActors <= 0) 311 if ( v0 >= (signed int)uNumActors || (signed int)uNumActors <= 0)
334 { 312 {
335 uDialogueType = 91; 313 uDialogueType = 91;
336 v4 = pParty->pPlayers; 314 v4 = pParty->pPlayers;
337 ++*((char *)&pParty->field_75A[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1); 315 ++*((char *)&pParty->monster_for_hunting_killed[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1);
338 do 316 do
339 { 317 {
340 v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3); 318 v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3);
341 ++v4; 319 ++v4;
342 } 320 }
441 pViewport->uViewportBR_X - pViewport->uViewportTL_X, 419 pViewport->uViewportBR_X - pViewport->uViewportTL_X,
442 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, 420 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
443 pRenderer->uTargetGMask | pRenderer->uTargetBMask); 421 pRenderer->uTargetGMask | pRenderer->uTargetBMask);
444 422
445 auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); 423 auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
446 pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0); 424 pRenderer->GetLeather(8, 352 - v0, pTex, pTex->uTextureHeight - v0);
447 425
448 pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428); 426 pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428);
449 v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0); 427 v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);
450 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v0, 0, v1, 0, 0, 0); 428 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v0, 0, v1, 0, 0, 0);
451 pRenderer->EndScene(); 429 pRenderer->EndScene();
705 char *v7; // edx@10 683 char *v7; // edx@10
706 char *v8; // ecx@12 684 char *v8; // ecx@12
707 char *v9; // eax@14 685 char *v9; // eax@14
708 unsigned int v10; // eax@25 686 unsigned int v10; // eax@25
709 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 687 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1
710 MSG Msg; // [sp+88h] [bp-48h]@22 688 //MSG Msg; // [sp+88h] [bp-48h]@22
711 unsigned int v14; // [sp+A4h] [bp-2Ch]@5 689 unsigned int v14; // [sp+A4h] [bp-2Ch]@5
712 void *v15; // [sp+A8h] [bp-28h]@1 690 void *v15; // [sp+A8h] [bp-28h]@1
713 char *pInString; // [sp+ACh] [bp-24h]@5 691 char *pInString; // [sp+ACh] [bp-24h]@5
714 unsigned int v17; // [sp+B0h] [bp-20h]@5 692 unsigned int v17; // [sp+B0h] [bp-20h]@5
715 unsigned int v18; // [sp+B4h] [bp-1Ch]@5 693 unsigned int v18; // [sp+B4h] [bp-1Ch]@5
825 else 803 else
826 { 804 {
827 LODWORD(v23) = GetTickCount() + 5000; 805 LODWORD(v23) = GetTickCount() + 5000;
828 while ( (unsigned int)v23 > GetTickCount() ) 806 while ( (unsigned int)v23 > GetTickCount() )
829 ; 807 ;
830 while ( 1 ) 808 for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
831 { 809 {
832 v10 = PeekMessageA(&Msg, 0, 0, 0, 1u); 810 if (msg.message == WM_QUIT)
833 if ( !v10 )
834 break;
835 if ( Msg.message == 18 )
836 Game_DeinitializeAndTerminate(0); 811 Game_DeinitializeAndTerminate(0);
837 TranslateMessage(&Msg); 812 TranslateMessage(&msg);
838 DispatchMessageA(&Msg); 813 DispatchMessage(&msg);
839 } 814 }
840 if ( pMessageQueue_50CBD0->uNumMessages ) 815 if ( pMessageQueue_50CBD0->uNumMessages )
841 { 816 {
842 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 817 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
843 pMessageQueue_50CBD0->uNumMessages = v10; 818 pMessageQueue_50CBD0->uNumMessages = v10;
844 } 819 }
845 pKeyActionMap->ResetKeys(); 820 pKeyActionMap->ResetKeys();
846 pKeyActionMap->uLastKeyPressed = 0; 821 pKeyActionMap->uLastKeyPressed = 0;
847 do 822 do
848 { 823 {
849 while ( PeekMessageA(&Msg, 0, 0, 0, 1u) ) 824 for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
850 { 825 {
851 if ( Msg.message == 18 ) 826 if (msg.message == WM_QUIT)
852 Game_DeinitializeAndTerminate(0); 827 Game_DeinitializeAndTerminate(0);
853 TranslateMessage(&Msg); 828 TranslateMessage(&msg);
854 DispatchMessageA(&Msg); 829 DispatchMessage(&msg);
855 } 830 }
856 } 831 }
857 while ( !pKeyActionMap->uLastKeyPressed ); 832 while ( !pKeyActionMap->uLastKeyPressed );
858 result = pMessageQueue_50CBD0->uNumMessages; 833 result = pMessageQueue_50CBD0->uNumMessages;
859 if ( pMessageQueue_50CBD0->uNumMessages ) 834 if ( pMessageQueue_50CBD0->uNumMessages )
1774 result = a2; 1749 result = a2;
1775 } 1750 }
1776 return result; 1751 return result;
1777 } 1752 }
1778 1753
1779 //----- (00450929) --------------------------------------------------------
1780 int LevelDecoration::GetGlobalEvent()
1781 {
1782 LevelDecoration *v1; // esi@1
1783 signed int v2; // eax@1
1784 int v3; // eax@5
1785 int v4; // eax@6
1786 int v5; // eax@7
1787 int v6; // eax@8
1788 int v7; // eax@9
1789 int result; // eax@14
1790 int v9; // eax@18
1791 int v10; // eax@19
1792 int v11; // eax@20
1793 int v12; // eax@21
1794 int v13; // eax@22
1795
1796 switch (uDecorationDescID)
1797 {
1798 case 0: case 1:
1799 case 2: case 3:
1800 return 0;
1801
1802 case 4: return 16; // dec01 "Trash Pile"
1803 case 5: return 32; // dec02 "Campfire"
1804 case 6: return 12 + rand() % 4; // dec03 "Cauldron"
1805 case 7: case 8:
1806 case 9: case 10:
1807 return 0;
1808
1809 case 11: return 34; // dec08 "Fruit plate"
1810 case 12:
1811 return 0;
1812
1813 case 13: return 17; // dec10 "Trash Pile"
1814 case 14: return 18; // dec11 "Filth"
1815 case 15: case 16: case 17:
1816 case 18: case 19: case 20:
1817 case 21: case 22: case 23:
1818 return 0;
1819
1820 case 24: return 36; // dec21 "Keg"
1821 case 25: case 26: case 27: case 28: case 29:
1822 case 30: case 31: case 32: case 33:
1823 return 0;
1824
1825 case 34: return 4 + rand() % 6; // dec32 "Barrel"
1826 case 35: case 36: case 37: case 38: case 39:
1827 case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49:
1828 case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59:
1829 case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69:
1830 case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79:
1831 case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89:
1832 case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99:
1833 case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109:
1834 case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119:
1835 case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129:
1836 case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139:
1837 case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149:
1838 case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159:
1839 case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169:
1840 case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179:
1841 case 180: case 181: case 182: case 183:
1842
1843 case 184: return 33; // dec24 "Campfire"
1844 case 185: case 186:
1845 return 0;
1846
1847 case 187: // dec88 "Mushroom"
1848 case 190: // dec91 "Mushroom"
1849 return 37;
1850
1851 case 188: case 189:
1852 case 191: case 192: case 193: case 194: case 195: case 196:
1853 case 197: case 198: case 199: case 200: case 201: case 202:
1854 case 203: case 204: case 205:
1855 return 0;
1856
1857 case 206: return 162 + rand() % 7; // dec60
1858 case 207: return 169 + rand() % 7; // dec61
1859 case 208: return 176 + rand() % 7; // dec62
1860 case 209: return 183 + rand() % 7; // dec63
1861 case 210: return 150; // dec64 "Magic Pedistal"
1862 case 211: return 151; // dec65 "Magic Pedistal"
1863 case 212: return 152; // dec66 "Magic Pedistal"
1864 case 213: return 153; // dec67 "Magic Pedistal"
1865 case 214: return 154; // dec68 "Magic Pedistal"
1866 case 215: return 155; // dec69 "Magic Pedistal"
1867 case 216: return 156; // dec70 "Magic Pedistal"
1868 case 217: return 157; // dec71 "Magic Pedistal"
1869 case 218: return 158; // dec72 "Magic Pedistal"
1870 case 219: return 159; // dec73 "Magic Pedistal"
1871 case 220: return 160; // dec74 "Magic Pedistal"
1872 case 221: return 161; // dec75 "Magic Pedistal"
1873
1874 case 222: case 223: case 224:
1875 case 225: case 226: case 227:
1876 return 0;
1877
1878 default: assert(false && "Invalid Decoration");
1879 }
1880 }
1881
1882 //----- (00450AAA) -------------------------------------------------------- 1754 //----- (00450AAA) --------------------------------------------------------
1883 void RespawnGlobalDecorations() 1755 void RespawnGlobalDecorations()
1884 { 1756 {
1885 memset(stru_5E4C90._decor_events, 0, 125); 1757 memset(stru_5E4C90._decor_events, 0, 125);
1886 1758
1887 uint decorEventIdx = 0; 1759 uint decorEventIdx = 0;
1888 for (uint i = 0; i < uNumLevelDecorations; ++i) 1760 for (uint i = 0; i < uNumLevelDecorations; ++i)
1889 { 1761 {
1890 auto decor = &pLevelDecorations[i]; 1762 auto decor = &pLevelDecorations[i];
1891 1763
1892 if (!decor->field_16_event_id) 1764 if (!decor->uEventID)
1893 { 1765 {
1894 if (decor->IsInteractive()) 1766 if (decor->IsInteractive())
1895 { 1767 {
1896 if (decorEventIdx < 124) 1768 if (decorEventIdx < 124)
1897 { 1769 {
3214 for (uint i = 0; i < uNumLevelDecorations; ++i) 3086 for (uint i = 0; i < uNumLevelDecorations; ++i)
3215 if (pLevelDecorations[i].uDecorationDescID == id) 3087 if (pLevelDecorations[i].uDecorationDescID == id)
3216 event_triggers[num_event_triggers++] = i; 3088 event_triggers[num_event_triggers++] = i;
3217 } 3089 }
3218 3090
3219 //----- (004621DA) --------------------------------------------------------
3220 int int_get_vector_length(signed int x, signed int y, signed int z)
3221 {
3222 signed int v3; // eax@2
3223
3224 if ( x < y )
3225 {
3226 v3 = x;
3227 x = y;
3228 y = v3;
3229 }
3230 if ( x < z )
3231 {
3232 v3 = x;
3233 x = z;
3234 z = v3;
3235 }
3236 if ( y < z )
3237 {
3238 v3 = y;
3239 y = z;
3240 z = v3;
3241 }
3242 return (11 * y >> 5) + x + (z >> 2);
3243 }
3244
3245 OPENFILENAMEA ofn; 3091 OPENFILENAMEA ofn;
3246 //----- (0046271C) -------------------------------------------------------- 3092 //----- (0046271C) --------------------------------------------------------
3247 void CreateDefaultBLVLevel() 3093 void CreateDefaultBLVLevel()
3248 { 3094 {
3249 ofn.lStructSize = 0x4Cu; 3095 ofn.lStructSize = 0x4Cu;
3320 LoadUI_Load(0); 3166 LoadUI_Load(0);
3321 } 3167 }
3322 pWindow = pGUIWindow_CurrentMenu; 3168 pWindow = pGUIWindow_CurrentMenu;
3323 } 3169 }
3324 3170
3325 MSG msg; 3171 for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);)
3326 while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) )
3327 { 3172 {
3328 if (msg.message == WM_QUIT) 3173 if (msg.message == WM_QUIT)
3329 Game_DeinitializeAndTerminate(0); 3174 Game_DeinitializeAndTerminate(0);
3330 TranslateMessage(&msg); 3175 TranslateMessage(&msg);
3331 DispatchMessageA(&msg); 3176 DispatchMessage(&msg);
3332 } 3177 }
3333 if (dword_6BE364_game_settings_1 & 0x0100) 3178 if (dword_6BE364_game_settings_1 & 0x0100)
3334 { 3179 {
3335 WaitMessage(); 3180 WaitMessage();
3336 } 3181 }
3407 pWindow_MainMenu->Release(); 3252 pWindow_MainMenu->Release();
3408 pIcons_LOD->RemoveTexturesPackFromTextureList(); 3253 pIcons_LOD->RemoveTexturesPackFromTextureList();
3409 } 3254 }
3410 3255
3411 //----- (004637EB) -------------------------------------------------------- 3256 //----- (004637EB) --------------------------------------------------------
3412 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) 3257 int __stdcall aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3413 { 3258 {
3414 HANDLE v6; // eax@32 3259 //HANDLE v6; // eax@32
3415 HDC v10; // edi@50 3260 //HDC v10; // edi@50
3416 int v11; // esi@50 3261 //int v11; // esi@50
3417 signed int v13; // eax@135 3262 //signed int v13; // eax@135
3418 char v29; // dl@209 3263 //char v29; // dl@209
3419 bool v31; // ebx@211 3264 //bool v31; // ebx@211
3420 float v33; // ST04_4@246 3265 //float v33; // ST04_4@246
3421 float v34; // ST04_4@254 3266 //float v34; // ST04_4@254
3422 struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13 3267 //struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
3423 int pXY[2]; // [sp+64h] [bp-8h]@261 3268 //int pXY[2]; // [sp+64h] [bp-8h]@261
3424 int a2; // [sp+7Ch] [bp+10h]@50 3269 //int a2; // [sp+7Ch] [bp+10h]@50
3425 3270
3426 switch (Msg) 3271 switch (uMsg)
3427 { 3272 {
3428 case WM_SIZING: return 1; 3273 case WM_SIZING: return 1;
3274
3429 case WM_CREATE: case WM_NCCREATE: 3275 case WM_CREATE: case WM_NCCREATE:
3276 case WM_GETTEXT: case WM_SETTEXT:
3430 case WM_SHOWWINDOW: 3277 case WM_SHOWWINDOW:
3431 case WM_GETTEXT: 3278 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3432 case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); 3279
3280 case WM_DESTROY:
3281 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
3282 PostQuitMessage(0);
3283 return 0;
3433 3284
3434 case WM_WINDOWPOSCHANGED: 3285 case WM_WINDOWPOSCHANGED:
3435 { 3286 {
3436 if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer) 3287 if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
3437 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); 3288 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
3438 3289
3439 return DefWindowProcW(hWnd, Msg, wParam, lParam); 3290 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3440 } 3291 }
3441 3292
3442 case WM_CHAR: 3293 case WM_CHAR:
3443 { 3294 {
3444 if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C) 3295 if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C)
3445 GUI_HandleHotkey(wParam); 3296 GUI_HandleHotkey(wParam);
3446 } 3297 }
3447 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3298 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3448 3299
3449 3300
3450 case WM_DEVICECHANGE: 3301 case WM_DEVICECHANGE:
3451 { 3302 {
3452 if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog 3303 if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog
3453 PostMessageA(hInsertCDWindow, WM_USER + 1, 0, 0); 3304 PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0);
3454 return 0; 3305 return 0;
3455 } 3306 }
3456 3307
3457 case WM_COMMAND: 3308 case WM_COMMAND:
3458 { 3309 {
3460 { 3311 {
3461 case 103: pRenderer->SavePCXScreenshot(); return 0; 3312 case 103: pRenderer->SavePCXScreenshot(); return 0;
3462 3313
3463 case 101: // Quit game 3314 case 101: // Quit game
3464 case 40001: 3315 case 40001:
3465 SendMessageA(::hWnd, WM_DESTROY, 0, 0); 3316 SendMessageW(hWnd, WM_DESTROY, 0, 0);
3466 return 0; 3317 return 0;
3467 3318
3468 3319
3469 case 104: 3320 case 104:
3470 pRenderer->ChangeBetweenWinFullscreenModes(); 3321 pRenderer->ChangeBetweenWinFullscreenModes();
3629 } 3480 }
3630 return 0; 3481 return 0;
3631 3482
3632 } 3483 }
3633 } 3484 }
3634 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3485 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3635 }; 3486
3636 3487 case WM_LBUTTONDOWN:
3637 if ( Msg > WM_SYSCOMMAND ) 3488 if (pArcomageGame->bGameInProgress)
3638 { 3489 {
3639 switch ( Msg ) 3490 pArcomageGame->stru1.field_0 = 7;
3640 { 3491 ArcomageGame::OnMouseClick(0, true);
3641 case WM_LBUTTONDOWN: 3492 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3642 if ( pArcomageGame->bGameInProgress ) 3493 }
3643 { 3494
3644 pArcomageGame->stru1.field_0 = 7; 3495 goto __handle_mouse_click;
3645 ArcomageGame::OnMouseClick(0, 1); 3496
3646 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3497 case WM_RBUTTONDOWN:
3647 } 3498 if (pArcomageGame->bGameInProgress)
3648 goto __handle_mouse_click; 3499 {
3649
3650 case WM_RBUTTONDOWN:
3651 v31 = 0;
3652 if ( !pArcomageGame->bGameInProgress )
3653 //goto LABEL_240;
3654 {
3655 if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
3656 pVideoPlayer->bStopBeforeSchedule = 1;
3657
3658 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3659 if (pGame)
3660 {
3661 v33 = pGame->pIndoorCameraD3D->GetPickDepth();
3662 pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter);
3663 }
3664
3665 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3666 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3667
3668 }
3669
3670 pArcomageGame->stru1.field_0 = 8; 3500 pArcomageGame->stru1.field_0 = 8;
3671 ArcomageGame::OnMouseClick(1, 1); 3501 ArcomageGame::OnMouseClick(1, true);
3672 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3502 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3673 case WM_LBUTTONUP: 3503 }
3674 if ( !pArcomageGame->bGameInProgress ) 3504
3675 //goto LABEL_218; 3505 if (pVideoPlayer->pVideoFrame.pPixels)
3676 { 3506 pVideoPlayer->bStopBeforeSchedule = 1;
3677 back_to_game(); 3507
3678 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3508 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3679 } 3509
3680 pArcomageGame->stru1.field_0 = 3; 3510 if (pGame)
3681 ArcomageGame::OnMouseClick(0, 0); 3511 {
3682 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3512 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 0, &vis_sprite_filter_2, &vis_door_filter);
3683 case WM_RBUTTONUP: 3513 }
3684 if ( !pArcomageGame->bGameInProgress ) 3514
3685 { 3515 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3686 //LABEL_218: 3516 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3687 3517
3688 back_to_game(); 3518
3689 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3519 case WM_LBUTTONUP:
3690 } 3520 if ( !pArcomageGame->bGameInProgress )
3691 pArcomageGame->stru1.field_0 = 4; 3521 {
3692 ArcomageGame::OnMouseClick(1, false); 3522 back_to_game();
3693 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3523 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3694 3524 }
3695 case WM_LBUTTONDBLCLK: 3525 pArcomageGame->stru1.field_0 = 3;
3696 if ( pArcomageGame->bGameInProgress ) 3526 ArcomageGame::OnMouseClick(0, 0);
3697 { 3527 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3698 pArcomageGame->stru1.field_0 = 7; 3528 case WM_RBUTTONUP:
3699 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3529 if ( !pArcomageGame->bGameInProgress )
3700 } 3530 {
3531 back_to_game();
3532 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3533 }
3534 pArcomageGame->stru1.field_0 = 4;
3535 ArcomageGame::OnMouseClick(1, false);
3536 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3537
3538 case WM_LBUTTONDBLCLK:
3539 if ( pArcomageGame->bGameInProgress )
3540 {
3541 pArcomageGame->stru1.field_0 = 7;
3542 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3543 }
3701 3544
3702 __handle_mouse_click: 3545 __handle_mouse_click:
3546 if (pVideoPlayer->pVideoFrame.pPixels)
3547 pVideoPlayer->bStopBeforeSchedule = 1;
3548
3549 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3550
3551 if (GetCurrentMenuID() == MENU_CREATEPARTY)
3552 {
3553 UI_OnKeyDown(VK_SELECT);
3554 }
3555
3556 if (pGame)
3557 pGame->PickMouse(512.0, LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_3, &vis_door_filter);
3558
3559 UI_OnMouseLeftClick(0);
3560
3561 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3562
3563 case WM_RBUTTONDBLCLK:
3564 if ( !pArcomageGame->bGameInProgress )
3565 {
3566 if (pVideoPlayer->pVideoFrame.pPixels)
3567 pVideoPlayer->bStopBeforeSchedule = 1;
3568
3569 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3570
3571 if (pGame)
3572 {
3573 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_2, &vis_door_filter);
3574 }
3575
3576 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3577 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3578 }
3579
3580 pArcomageGame->stru1.field_0 = 8;
3581
3582 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3583
3584 case WM_MBUTTONDOWN:
3585 if (pRenderer->pRenderD3D && pGame)
3586 {
3587 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter);
3588 }
3589
3590 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3591
3592 case WM_MOUSEMOVE:
3593 if ( pArcomageGame->bGameInProgress )
3594 {
3595 ArcomageGame::OnMouseMove(LOWORD(lParam), HIWORD(lParam));
3596 ArcomageGame::OnMouseClick(0, wParam == MK_LBUTTON);
3597 ArcomageGame::OnMouseClick(1, wParam == MK_RBUTTON);
3598 }
3599 else
3600 {
3601 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3602 }
3603
3604 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3605
3606 case WM_SYSCOMMAND:
3607 if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
3608 return 0;
3609
3610 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3611
3612 case WM_KEYUP:
3613 if (wParam == VK_CONTROL)
3614 {
3615 dword_507B98_ctrl_pressed = 0;
3616 }
3617
3618 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3619
3620 case WM_KEYDOWN:
3621 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
3622 {
3623 pKeyActionMap->_459F10(wParam);
3624 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3625 }
3626 if ( !pArcomageGame->bGameInProgress )
3627 {
3703 if ( pVideoPlayer->pVideoFrame.pPixels ) 3628 if ( pVideoPlayer->pVideoFrame.pPixels )
3704 pVideoPlayer->bStopBeforeSchedule = 1; 3629 pVideoPlayer->bStopBeforeSchedule = 1;
3705 3630 if ( wParam == VK_RETURN )
3706 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3707
3708 if (GetCurrentMenuID() != MENU_CREATEPARTY)
3709 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3710 else
3711 {
3712 UI_OnKeyDown(VK_SELECT);
3713 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3714 }
3715
3716
3717 if (pGame)
3718 pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter);
3719
3720 UI_OnMouseLeftClick(0);
3721
3722 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3723
3724 case WM_RBUTTONDBLCLK:
3725 v31 = 0;
3726 if ( !pArcomageGame->bGameInProgress )
3727 {
3728 //LABEL_240:
3729 if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
3730 pVideoPlayer->bStopBeforeSchedule = 1;
3731
3732 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3733 if (pGame)
3734 {
3735 v33 = pGame->pIndoorCameraD3D->GetPickDepth();
3736 pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter);
3737 }
3738
3739 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3740 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3741
3742 }
3743 pArcomageGame->stru1.field_0 = 8;
3744 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3745 case WM_MBUTTONDOWN:
3746 if ( pRenderer->pRenderD3D )
3747 {
3748 if ( pGame )
3749 {
3750 v34 = pGame->pIndoorCameraD3D->GetPickDepth();
3751 pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter);
3752 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3753 }
3754 }
3755 if ( !pGame )
3756 //goto _def_wnd_proc;
3757 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3758 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3759 case WM_MOUSEMOVE:
3760 if ( pArcomageGame->bGameInProgress )
3761 {
3762 pXY[0] = (unsigned __int16)lParam;
3763 pXY[1] = lParam >> 16;
3764 ArcomageGame::OnMouseMove((POINT *)pXY);
3765 ArcomageGame::OnMouseClick(0, wParam & 1);
3766 v29 = (wParam >> 1) & 1;
3767 ArcomageGame::OnMouseClick(1, v29 != 0);
3768 }
3769 else
3770 {
3771 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
3772 }
3773 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3774 default:
3775 //goto _def_wnd_proc;
3776 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3777 }
3778 }
3779 if ( Msg == WM_SYSCOMMAND )
3780 {
3781 if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
3782 return 0;
3783 //goto _def_wnd_proc;
3784 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3785 }
3786 if ( Msg > WM_ACTIVATEAPP )
3787 {
3788 if ( Msg != WM_KEYFIRST && Msg != WM_WINDOWPOSCHANGED)
3789 {
3790 if ( Msg == WM_KEYUP && wParam == VK_CONTROL )
3791 {
3792 dword_507B98_ctrl_pressed = 0;
3793 }
3794 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3795 }
3796 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
3797 {
3798 pKeyActionMap->_459F10(wParam);
3799 return DefWindowProcA(hWnd, Msg, wParam, lParam);
3800 }
3801 if ( !pArcomageGame->bGameInProgress )
3802 {
3803 if ( pVideoPlayer->pVideoFrame.pPixels )
3804 pVideoPlayer->bStopBeforeSchedule = 1;
3805 if ( wParam == VK_RETURN )
3806 {
3807 if ( !viewparams->field_4C )
3808 UI_OnKeyDown(wParam);
3809 return 0;
3810 }
3811 if ( wParam == VK_CONTROL )
3812 {
3813 dword_507B98_ctrl_pressed = 1;
3814 return 0;
3815 }
3816 if ( wParam == VK_ESCAPE )
3817 {
3818 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
3819 return 0;
3820 }
3821 if ( wParam <= VK_HOME )
3822 return 0;
3823 if ( wParam > VK_DOWN )
3824 {
3825 if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
3826 return 0;
3827 SendMessageA(hWnd, WM_COMMAND, 104, 0);
3828 return 0;
3829 }
3830 if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
3831 {
3832 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
3833 { 3631 {
3834 if ( !viewparams->field_4C ) 3632 if ( !viewparams->field_4C )
3835 UI_OnKeyDown(wParam); 3633 UI_OnKeyDown(wParam);
3836 return 0; 3634 return 0;
3837 } 3635 }
3838 } 3636 if ( wParam == VK_CONTROL )
3839 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) 3637 {
3840 return 0; 3638 dword_507B98_ctrl_pressed = 1;
3841 } 3639 return 0;
3842 3640 }
3843 pArcomageGame->stru1.field_0 = 1; 3641 if ( wParam == VK_ESCAPE )
3844 3642 {
3845 v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u); 3643 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
3846 set_stru1_field_8_InArcomage(v13); 3644 return 0;
3847 if ( wParam == 27 ) 3645 }
3848 { 3646 if ( wParam <= VK_HOME )
3849 pArcomageGame->GameOver = 1; 3647 return 0;
3850 pArcomageGame->field_F4 = 1; 3648 if ( wParam > VK_DOWN )
3851 pArcomageGame->uGameResult = 2; 3649 {
3852 pArcomageGame->field_B0 = -2; 3650 if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
3853 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3651 return 0;
3854 } 3652 SendMessageW(hWnd, WM_COMMAND, 104, 0);
3855 if ( wParam != 114 ) 3653 return 0;
3856 { 3654 }
3857 if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() ) 3655 if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
3858 SendMessageA(hWnd, 0x111u, 0x68u, 0); 3656 {
3859 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3657 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
3860 } 3658 {
3861 SendMessageA(hWnd, WM_COMMAND, 103, 0); 3659 if ( !viewparams->field_4C )
3862 return 0; 3660 UI_OnKeyDown(wParam);
3863 } 3661 return 0;
3864 if ( Msg == WM_ACTIVATEAPP ) 3662 }
3865 { 3663 }
3866 if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) ) 3664 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
3867 { 3665 return 0;
3868 if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) 3666 }
3869 { 3667
3870 dword_4E98BC_bApplicationActive = 1; 3668 pArcomageGame->stru1.field_0 = 1;
3871 if ( pRenderer->bWindowMode ) 3669
3872 { 3670 set_stru1_field_8_InArcomage(MapVirtualKey(wParam, MAPVK_VK_TO_CHAR));
3873 v10 = GetDC(0); 3671 if ( wParam == 27 )
3874 a2 = GetDeviceCaps(v10, BITSPIXEL); 3672 {
3875 v11 = GetDeviceCaps(v10, PLANES); 3673 pArcomageGame->GameOver = 1;
3876 ReleaseDC(0, v10); 3674 pArcomageGame->field_F4 = 1;
3877 if ( a2 != 16 || v11 != 1 ) 3675 pArcomageGame->uGameResult = 2;
3878 Abortf(pGlobalTXT_LocalizationStrings[62]); 3676 pArcomageGame->field_B0 = -2;
3879 } 3677 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3880 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; 3678 }
3881 3679 if ( wParam != 114 )
3882 if ( pArcomageGame->bGameInProgress ) 3680 {
3883 { 3681 if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
3884 pArcomageGame->field_F9 = 1; 3682 SendMessage(hWnd, WM_COMMAND, 0x68u, 0);
3885 } 3683 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3886 else 3684 }
3887 { 3685 SendMessageW(hWnd, WM_COMMAND, 103, 0);
3888 if ( BYTE1(dword_6BE364_game_settings_1) & 2 ) 3686 return 0;
3889 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu; 3687
3688 case WM_ACTIVATEAPP:
3689 if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) )
3690 {
3691 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
3692 {
3693 dword_4E98BC_bApplicationActive = 1;
3694 if ( pRenderer->bWindowMode )
3695 {
3696 HDC hDC = GetDC(hWnd);
3697 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
3698 int planes = GetDeviceCaps(hDC, PLANES);
3699 ReleaseDC(hWnd, hDC);
3700 if (bitsPerPixel != 16 || planes != 1)
3701 Abortf(pGlobalTXT_LocalizationStrings[62]);
3702 }
3703 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
3704
3705 if ( pArcomageGame->bGameInProgress )
3706 {
3707 pArcomageGame->field_F9 = 1;
3708 }
3890 else 3709 else
3891 pEventTimer->Resume(); 3710 {
3892 if ( BYTE1(dword_6BE364_game_settings_1) & 4 ) 3711 if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
3893 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; 3712 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
3713 else
3714 pEventTimer->Resume();
3715 if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
3716 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
3717 else
3718 pMiscTimer->Resume();
3719
3720 viewparams->bRedrawGameUI = true;
3721 if ( pVideoPlayer->pSmackerMovie )
3722 {
3723 pRenderer->RestoreFrontBuffer();
3724 pRenderer->_4A184C();
3725 pVideoPlayer->_4BF5B2();
3726 }
3727 }
3728 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
3729 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
3730 }
3731 }
3732 else
3733 {
3734 if (!(dword_6BE364_game_settings_1 & 0x100))
3735 {
3736 dword_4E98BC_bApplicationActive = 0;
3737 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
3738 pVideoPlayer->bStopBeforeSchedule = 1;
3739
3740 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
3741 SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
3742 ClipCursor(0);
3743 dword_6BE364_game_settings_1 |= 0x100u;
3744 if ( pEventTimer->bPaused )
3745 BYTE1(dword_6BE364_game_settings_1) |= 2u;
3894 else 3746 else
3895 pMiscTimer->Resume(); 3747 pEventTimer->Pause();
3896 3748 if ( pMiscTimer->bPaused )
3897 viewparams->bRedrawGameUI = true; 3749 BYTE1(dword_6BE364_game_settings_1) |= 4u;
3898 if ( pVideoPlayer->pSmackerMovie ) 3750 else
3751 pMiscTimer->Pause();
3752
3753 pAudioPlayer->StopChannels(-1, -1);
3754 if ( pAudioPlayer->hAILRedbook )
3755 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
3756 }
3757 }
3758 return 0;
3759
3760 case WM_CREATE:
3761 {
3762 auto hDC = GetDC(hWnd);
3763 {
3764 if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
3899 { 3765 {
3900 pRenderer->RestoreFrontBuffer(); 3766 ReleaseDC(hWnd, hDC);
3901 pRenderer->_4A184C(); 3767 Log::Warning(L"You must be running in 256 color mode or higher.");
3902 pVideoPlayer->_4BF5B2(); 3768 Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon.");
3903 } 3769 }
3904 } 3770 }
3905 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
3906 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
3907 }
3908 }
3909 else
3910 {
3911 if ( !(dword_6BE364_game_settings_1 & 0x100) )
3912 {
3913 while(initing); //ADDED spinlock to allow int players ets! Gloval
3914 dword_4E98BC_bApplicationActive = 0;
3915 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
3916 pVideoPlayer->bStopBeforeSchedule = 1;
3917
3918 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
3919 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
3920 ClipCursor(0);
3921 dword_6BE364_game_settings_1 |= 0x100u;
3922 if ( pEventTimer->bPaused )
3923 BYTE1(dword_6BE364_game_settings_1) |= 2u;
3924 else
3925 pEventTimer->Pause();
3926 if ( pMiscTimer->bPaused )
3927 BYTE1(dword_6BE364_game_settings_1) |= 4u;
3928 else
3929 pMiscTimer->Pause();
3930
3931 pAudioPlayer->StopChannels(-1, -1);
3932 if ( pAudioPlayer->hAILRedbook )
3933 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
3934 }
3935 }
3936 return 0;
3937 }
3938 if (Msg == WM_CREATE)
3939 {
3940 auto hDC = GetDC(hWnd);
3941 {
3942 if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
3943 {
3944 ReleaseDC(hWnd, hDC); 3771 ReleaseDC(hWnd, hDC);
3945 Log::Warning(L"You must be running in 256 color mode or higher."); 3772 }
3946 Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); 3773 return 0;
3947 } 3774
3948 } 3775 case WM_SETFOCUS:
3949 ReleaseDC(hWnd, hDC);
3950 return 0;
3951 }
3952 if ( Msg == WM_DESTROY )
3953 {
3954 v6 = GetCurrentProcess();
3955 SetPriorityClass(v6, 0x20u);
3956 if ( pGame )
3957 {
3958
3959 }
3960
3961 PostQuitMessage(0);
3962 return 0;
3963 }
3964 if ( Msg == WM_SETFOCUS )
3965 {
3966 if ( ::hWnd == (HWND)wParam )
3967 {
3968 dword_4E98BC_bApplicationActive = 0; 3776 dword_4E98BC_bApplicationActive = 0;
3969 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) 3777 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
3970 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); 3778 SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
3971 ClipCursor(0); 3779 ClipCursor(0);
3972 3780 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3973 } 3781
3974 //_def_wnd_proc: 3782 case WM_KILLFOCUS:
3975 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3783 dword_4E98BC_bApplicationActive = 1;
3976 } 3784 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3977 if ( Msg != WM_KILLFOCUS ) 3785
3978 { 3786 case WM_PAINT:
3979 if ( Msg == WM_PAINT )
3980 {
3981 if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) 3787 if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
3982 return 0; 3788 return 0;
3789 PAINTSTRUCT Paint;
3983 BeginPaint(hWnd, &Paint); 3790 BeginPaint(hWnd, &Paint);
3984 if ( pArcomageGame->bGameInProgress ) 3791 if ( pArcomageGame->bGameInProgress )
3985 { 3792 {
3986 pArcomageGame->field_F9 = 1; 3793 pArcomageGame->field_F9 = 1;
3987 } 3794 }
3994 } 3801 }
3995 } 3802 }
3996 pRenderer->Present(); 3803 pRenderer->Present();
3997 EndPaint(hWnd, &Paint); 3804 EndPaint(hWnd, &Paint);
3998 return 0; 3805 return 0;
3999 } 3806
4000 //goto _def_wnd_proc; 3807 default:
4001 return DefWindowProcA(hWnd, Msg, wParam, lParam); 3808 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
4002 } 3809 }
4003 if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || true )
4004 return DefWindowProcA(hWnd, Msg, wParam, lParam);
4005
4006 } 3810 }
4007 3811
4008 //----- (00464479) -------------------------------------------------------- 3812 //----- (00464479) --------------------------------------------------------
4009 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() 3813 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
4010 { 3814 {
4044 if ( pRenderer->pRenderD3D ) 3848 if ( pRenderer->pRenderD3D )
4045 pGame->pVisInstance->_4C1A02(); 3849 pGame->pVisInstance->_4C1A02();
4046 pEventTimer->Pause(); 3850 pEventTimer->Pause();
4047 pMiscTimer->Pause(); 3851 pMiscTimer->Pause();
4048 pParty->uFlags = 2; 3852 pParty->uFlags = 2;
4049 pCastSpellInfo.data()->_427D48(1); 3853 CastSpellInfoHelpers::_427D48();
4050 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); 3854 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
4051 DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); 3855 DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1);
4052 pMiscTimer->Resume(); 3856 pMiscTimer->Resume();
4053 pEventTimer->Resume(); 3857 pEventTimer->Resume();
4054 } 3858 }
4534 } 4338 }
4535 4339
4536 //----- (004651F4) -------------------------------------------------------- 4340 //----- (004651F4) --------------------------------------------------------
4537 bool MM7_Initialize() 4341 bool MM7_Initialize()
4538 { 4342 {
4539 initing=true; //ADDED Gloval
4540 wchar_t pCurrentDir[1024]; 4343 wchar_t pCurrentDir[1024];
4541 _wgetcwd(pCurrentDir, 1024); 4344 _wgetcwd(pCurrentDir, 1024);
4542 4345
4543 wchar_t pMM6IniFile[1024]; 4346 wchar_t pMM6IniFile[1024];
4544 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); 4347 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir);
4596 4399
4597 hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and MagicŪ VII", 4400 hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and MagicŪ VII",
4598 uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER, 4401 uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
4599 uWindowX, uWindowY, 4402 uWindowX, uWindowY,
4600 640, 480, 4403 640, 480,
4601 nullptr,
4602 nullptr, 4404 nullptr,
4603 wcxw.hInstance, 4405 wcxw.hInstance,
4604 nullptr); 4406 nullptr);
4605 4407
4606 HMENU menu = CreateMenu(); 4408 HMENU menu = CreateMenu();
4808 uWindowWidth = rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640; 4610 uWindowWidth = rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640;
4809 uWindowHeight = rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480; 4611 uWindowHeight = rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480;
4810 MoveWindow(hWnd, uWindowX, uWindowY, 4612 MoveWindow(hWnd, uWindowX, uWindowY,
4811 rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640, 4613 rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640,
4812 rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0); 4614 rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0);
4813 ShowWindow(hWnd, SW_SHOWNORMAL);
4814 4615
4815 pIcons_LOD = new LODFile_IconsBitmaps; 4616 pIcons_LOD = new LODFile_IconsBitmaps;
4816 if (!pIcons_LOD->Load("data\\icons.lod", "icons")) 4617 if (!pIcons_LOD->Load("data\\icons.lod", "icons"))
4817 { 4618 {
4818 MessageBoxW(nullptr, 4619 MessageBoxW(nullptr,
5123 case 3u: // smooth 4924 case 3u: // smooth
5124 uTurnSpeed = 0; 4925 uTurnSpeed = 0;
5125 break; 4926 break;
5126 } 4927 }
5127 4928
5128 initing = false; //ADDED Gloval 4929 ShowWindow(hWnd, SW_SHOWNORMAL);
5129 return true; 4930 return true;
5130 } 4931 }
5131 4932
5132 //----- (00465D0B) -------------------------------------------------------- 4933 //----- (00465D0B) --------------------------------------------------------
5133 void SecondaryInitialization() 4934 void SecondaryInitialization()
5364 } 5165 }
5365 5166
5366 bool new_sky = false; 5167 bool new_sky = false;
5367 bool change_seasons = false; 5168 bool change_seasons = false;
5368 bool all_magic = true; 5169 bool all_magic = true;
5170 bool wizard_eye = false;
5171 bool debug_information = false;
5172 bool show_picked_face = false;
5173 bool draw_debug_line = false;
5369 5174
5370 //----- (00462C94) -------------------------------------------------------- 5175 //----- (00462C94) --------------------------------------------------------
5371 bool MM_Main(const wchar_t *pCmdLine) 5176 bool MM_Main(const wchar_t *pCmdLine)
5372 { 5177 {
5373 IntegrityTest(); 5178 IntegrityTest();
6240 if ( v18 >= v0 ) 6045 if ( v18 >= v0 )
6241 return 0; 6046 return 0;
6242 } 6047 }
6243 v25 = &pLevelDecorations[v20]; 6048 v25 = &pLevelDecorations[v20];
6244 v26 = v25; 6049 v26 = v25;
6245 v27 = v25->field_16_event_id; 6050 v27 = v25->uEventID;
6246 if ( v27 ) 6051 if ( v27 )
6247 { 6052 {
6248 v23 = GetEventHintString(v27); 6053 v23 = GetEventHintString(v27);
6249 if ( !v23 ) 6054 if ( !v23 )
6250 return v19; 6055 return v19;