# HG changeset patch # User Ritor1 # Date 1383496957 -21600 # Node ID 1175adbf8c58d77ad5d01a343223beb003980fb8 # Parent 157fd28315672d7ac940e69ba79d5d023eb6a4ee# Parent f7e8c4d4a01bc3600071dac310b9bb91b5f05925 Merge diff -r 157fd2831567 -r 1175adbf8c58 .gitignore --- a/.gitignore Sun Nov 03 22:42:25 2013 +0600 +++ b/.gitignore Sun Nov 03 22:42:37 2013 +0600 @@ -3,3 +3,4 @@ Release *.orig .hg/* +Build/ diff -r 157fd2831567 -r 1175adbf8c58 Actor.cpp --- a/Actor.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/Actor.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -3789,10 +3789,10 @@ if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { ItemGen* item; - //if (i == 0) + if (i == 0) + item = player->GetOffHandItem(); + else item = player->GetMainHandItem(); - //else - //item = player->GetOffHandItem(); a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); if ( isLifeStealing && pMonster->sCurrentHP > 0 ) { diff -r 157fd2831567 -r 1175adbf8c58 Game.cpp --- a/Game.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/Game.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -757,6 +757,7 @@ WriteWindowsRegistryInt("window X", Rect.left); WriteWindowsRegistryInt("window Y", Rect.top); } + window->Delete(); WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); pItemsTable->Release(); pNPCStats->Release(); diff -r 157fd2831567 -r 1175adbf8c58 OSWindow.cpp --- a/OSWindow.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/OSWindow.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -410,6 +410,15 @@ return false; } + HDC hDC = GetDC(NULL); + int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); + int planes = GetDeviceCaps(hDC, PLANES); + ReleaseDC(NULL, hDC); + if (bitsPerPixel != 16 || planes != 1) + { + SetColorDepth(16); + } + SetWindowedMode(window_width, window_height); Show(); @@ -501,7 +510,8 @@ { SetWindowLongW(api_handle, GWL_EXSTYLE, 0); SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); - + SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, 0); + RECT rcWindow; GetWindowRect(api_handle, &rcWindow); @@ -789,3 +799,37 @@ return true; } + +bool OSWindow::SetColorDepth(int bit) +{ + dm.dmSize = sizeof(DEVMODE); + if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)) + { + printf("EnumDisplaySettings failed:%d\n", GetLastError()); + return false; + } + dm.dmBitsPerPel = bit; + dm.dmFields = DM_BITSPERPEL; + if (ChangeDisplaySettings(&dm, CDS_TEST) !=DISP_CHANGE_SUCCESSFUL) + { + printf("\nIllegal graphics mode: %d\n", GetLastError()); + return false; + } + if (ChangeDisplaySettings(&dm, 0) == DISP_CHANGE_SUCCESSFUL) + { + ChangedColorDepth = true; + } +} + +void OSWindow::Delete() +{ + Deinitialize(); +} + +void OSWindow::Deinitialize() +{ + if( ChangedColorDepth ) + { + SetColorDepth(32); + } +} \ No newline at end of file diff -r 157fd2831567 -r 1175adbf8c58 OSWindow.h --- a/OSWindow.h Sun Nov 03 22:42:25 2013 +0600 +++ b/OSWindow.h Sun Nov 03 22:42:37 2013 +0600 @@ -6,7 +6,7 @@ { public: static OSWindow *Create(const wchar_t *title, int window_width, int window_height); - + void Delete(); void SetFullscreenMode(); void SetWindowedMode(int new_window_width, int new_window_height); @@ -38,11 +38,15 @@ protected: bool Initialize(const wchar_t *title, int window_width, int window_height); + void Deinitialize(); + bool SetColorDepth(int bit); bool WinApiMessageProc(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result); HWND api_handle; + DEVMODE dm; private: + bool ChangedColorDepth; static LPARAM __stdcall WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); HMENU CreateDebugMenuPanel(); diff -r 157fd2831567 -r 1175adbf8c58 Party.cpp --- a/Party.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/Party.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -1122,7 +1122,7 @@ v8 = 0; for (int i = 0; i < 4; i++) { - v9 = &pPlayers[(uActiveCharacter + i) % 4]; //start with current active player, then cycle right if item won't fit + v9 = ::pPlayers[(uActiveCharacter + i) % 4]; //start with current active player, then cycle right if item won't fit v10 = v9->AddItem(-1, pItem->uItemID); if ( v10 ) { diff -r 157fd2831567 -r 1175adbf8c58 mm7_2.cpp --- a/mm7_2.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/mm7_2.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -6011,7 +6011,7 @@ v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; v124 = 8 * v153; LOBYTE(v124) = v124 | 2; - v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1; pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0); return 0; } diff -r 157fd2831567 -r 1175adbf8c58 mm7_data.cpp --- a/mm7_data.cpp Sun Nov 03 22:42:25 2013 +0600 +++ b/mm7_data.cpp Sun Nov 03 22:42:37 2013 +0600 @@ -787,7 +787,7 @@ std::array pHiredNPCsIconsOffsetsY = {152, 152}; std::array dword_4EE07C; // weak _UNKNOWN unk_4EE084; // weak -std::array<__int16, 100> word_4EE088_sound_ids = +std::array<__int16, 101> word_4EE088_sound_ids = {{ 0, 10000, 10010, 10020, 10030, 10040, 10050, 10060, 10070, 10080, 10090, 10100, 11000, 11010, 11020, 11030, 11040, 11050, 11060, 11070, @@ -798,7 +798,8 @@ 15040, 15050, 15060, 15070, 15080, 15090, 15100, 16000, 16010, 16020, 16030, 16040, 16050, 16060, 16070, 16080, 16090, 16100, 17000, 17010, 17020, 17030, 17040, 17050, 17060, 17070, 17080, 17090, 17100, 18000, - 18010, 18020, 18030, 18040, 18050, 18060, 18070, 18080, 18090, 18100 + 18010, 18020, 18030, 18040, 18050, 18060, 18070, 18080, 18090, 18100, + 1 }}; std::array word_4EE150 = {{ diff -r 157fd2831567 -r 1175adbf8c58 mm7_data.h --- a/mm7_data.h Sun Nov 03 22:42:25 2013 +0600 +++ b/mm7_data.h Sun Nov 03 22:42:37 2013 +0600 @@ -478,7 +478,7 @@ extern std::array pHiredNPCsIconsOffsetsY; extern std::array dword_4EE07C; // weak extern _UNKNOWN unk_4EE084; // weak -extern std::array<__int16, 100> word_4EE088_sound_ids; // weak +extern std::array<__int16, 101> word_4EE088_sound_ids; // weak extern std::array word_4EE150; extern int dword_4EED78; // weak extern _UNKNOWN unk_4EED80; // weak