From aa7d9a08ca3dd67858bf4ebfa7fd0dd7daadce0e Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Wed, 20 Jul 2011 23:07:46 -0700 Subject: [PATCH 1/6] Fix improperly calculated window size in initial Windowed mode. --- Sources/Plasma/Apps/plClient/plClient.cpp | 76 ++++++++++++----------- Sources/Plasma/Apps/plClient/plClient.h | 3 +- Sources/Plasma/Apps/plClient/winmain.cpp | 34 +--------- Sources/Plasma/CoreLibExe/hsExeError.cpp | 3 +- 4 files changed, 45 insertions(+), 71 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 0d531766..efe26c4e 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -751,7 +751,7 @@ hsBool plClient::MsgReceive(plMessage* msg) { ISetGraphicsDefaults(); ResetDisplayDevice(plPipeline::fDefaultPipeParams.Width, plPipeline::fDefaultPipeParams.Height, plPipeline::fDefaultPipeParams.ColorDepth, plPipeline::fDefaultPipeParams.Windowed, - plPipeline::fDefaultPipeParams.AntiAliasingAmount, plPipeline::fDefaultPipeParams.AnisotropicLevel, plPipeline::fDefaultPipeParams.VSync, true); + plPipeline::fDefaultPipeParams.AntiAliasingAmount, plPipeline::fDefaultPipeParams.AnisotropicLevel, plPipeline::fDefaultPipeParams.VSync); } break; @@ -2150,54 +2150,60 @@ hsG3DDeviceModeRecord plClient::ILoadDevMode(const char* devModeFile) return dmr; } -void plClient::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync, hsBool windowOnly) +void plClient::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync) { if(!fPipeline) return; - int BorderWidth = 0, BorderHeight = 0, CaptionHeight = 0; WindowActivate(false); - int ActualWidth; - int ActualHeight; - if( Windowed ) - { - BorderWidth = GetSystemMetrics( SM_CXSIZEFRAME ); - BorderHeight = GetSystemMetrics( SM_CYSIZEFRAME ); - CaptionHeight = GetSystemMetrics( SM_CYCAPTION ); - ActualWidth = Width + BorderWidth * 2; - ActualHeight = Height + BorderHeight * 2 + CaptionHeight; - SetWindowLong( fWindowHndl, GWL_STYLE, - WS_POPUP | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE); - SetWindowLong(fWindowHndl, GWL_EXSTYLE, 0); - } - else - { - SetWindowLong(fWindowHndl, GWL_STYLE, - WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZE | WS_VISIBLE); + ResizeDisplayDevice(Width, Height, Windowed); - SetWindowLong(fWindowHndl, GWL_EXSTYLE, WS_EX_APPWINDOW); - } + fPipeline->ResetDisplayDevice(Width, Height, ColorDepth, Windowed, NumAASamples, MaxAnisotropicSamples, VSync); + + WindowActivate(true); +} + +void plClient::ResizeDisplayDevice(int Width, int Height, hsBool Windowed) +{ - if(!windowOnly) - fPipeline->ResetDisplayDevice(Width, Height, ColorDepth, Windowed, NumAASamples, MaxAnisotropicSamples, VSync); + if (plMouseDevice::Instance()) + plMouseDevice::Instance()->SetDisplayResolution((float)Width, (float)Height); float aspectratio = (float)Width / (float)Height; - plMouseDevice::Instance()->SetDisplayResolution((float)Width, (float)Height); - pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio ); + if (pfGameGUIMgr::GetInstance()) + pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio ); - UINT flags = SWP_NOCOPYBITS | SWP_NOMOVE | SWP_SHOWWINDOW; - if(Windowed) - { - SetWindowPos( fWindowHndl, HWND_NOTOPMOST, 0, 0, ActualWidth, ActualHeight, flags ); - } - else + + UInt32 winStyle, winExStyle; + if( Windowed ) { - SetWindowPos( fWindowHndl, HWND_TOP, 0, 0, Width, Height, flags ); + winStyle = WS_OVERLAPPEDWINDOW; + winExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + } else { + winStyle = WS_POPUP; + winExStyle = WS_EX_APPWINDOW; } + SetWindowLong(fWindowHndl, GWL_STYLE, winStyle); + SetWindowLong(fWindowHndl, GWL_EXSTYLE, winExStyle); - WindowActivate(true); -} + UInt32 flags = SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_FRAMECHANGED; + UInt32 OutsideWidth, OutsideHeight; + HWND insertAfter; + if( Windowed ) + { + RECT winRect = { 0, 0, Width, Height }; + AdjustWindowRectEx(&winRect, winStyle, false, winExStyle); + OutsideWidth = winRect.right - winRect.left; + OutsideHeight = winRect.bottom - winRect.top; + insertAfter = HWND_NOTOPMOST; + } else { + OutsideWidth = Width; + OutsideHeight = Height; + insertAfter = HWND_TOP; + } + SetWindowPos( fWindowHndl, insertAfter, 0, 0, OutsideWidth, OutsideHeight, flags ); +} void WriteBool(hsStream *stream, char *name, hsBool on ) { diff --git a/Sources/Plasma/Apps/plClient/plClient.h b/Sources/Plasma/Apps/plClient/plClient.h index 3ac62f4c..5b1ae482 100644 --- a/Sources/Plasma/Apps/plClient/plClient.h +++ b/Sources/Plasma/Apps/plClient/plClient.h @@ -276,7 +276,8 @@ public: virtual hsBool WindowActive() const { return fWindowActive; } void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; } - void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false, hsBool windowOnly = false); + void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false); + void ResizeDisplayDevice(int Width, int Height, hsBool Windowed); void IDetectAudioVideoSettings(); void IWriteDefaultGraphicsSettings(const wchar* destFile); diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 77c052f1..56dcbcdc 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -769,11 +769,6 @@ bool InitClient( HWND hWnd ) #ifdef DETACH_EXE hInstance = ((LPCREATESTRUCT) lParam)->hInstance; -#endif - // If in fullscreen mode, get rid of the window borders. Note: this won't take - // effect until the next SetWindowPos call - -#ifdef DETACH_EXE // This Function loads the EXE into Virtual memory...supposedly HRESULT hr = DetachFromMedium(hInstance, DMDFM_ALWAYS | DMDFM_ALLPAGES); @@ -783,34 +778,7 @@ bool InitClient( HWND hWnd ) gClient->SetDone(true); else { - if( gClient->GetPipeline()->IsFullScreen() ) - { - SetWindowLong(hWnd, GWL_STYLE, WS_POPUP); - SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); - SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - gWinBorderDX = gWinBorderDY = gWinMenuDY = 0; - } - else { - SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPED | WS_CAPTION); - SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - } - - int goodWidth = gClient->GetPipeline()->Width() + gWinBorderDX * 2; - int goodHeight = gClient->GetPipeline()->Height() + gWinBorderDY * 2 + gWinMenuDY; - - SetWindowPos( - hWnd, - nil, - 0, - 0, - goodWidth, - goodHeight, - SWP_NOCOPYBITS - | SWP_NOMOVE - | SWP_NOOWNERZORDER - | SWP_NOZORDER - | SWP_FRAMECHANGED - ); + gClient->ResizeDisplayDevice(gClient->GetPipeline()->Width(), gClient->GetPipeline()->Height(), !gClient->GetPipeline()->IsFullScreen()); } if( gPendingActivate ) diff --git a/Sources/Plasma/CoreLibExe/hsExeError.cpp b/Sources/Plasma/CoreLibExe/hsExeError.cpp index 4a6e6956..0707ecad 100644 --- a/Sources/Plasma/CoreLibExe/hsExeError.cpp +++ b/Sources/Plasma/CoreLibExe/hsExeError.cpp @@ -136,8 +136,7 @@ void ErrorMinimizeAppWindow () { // If the application's topmost window is a fullscreen // popup window, minimize it before displaying an error HWND appWindow = GetActiveWindow(); - if ( ((GetWindowLong(appWindow, GWL_STYLE) & WS_POPUP) != 0) && - ((GetWindowLong(appWindow, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) ) + if ( ((GetWindowLong(appWindow, GWL_STYLE) & WS_POPUP) != 0) ) SetWindowPos( appWindow, HWND_NOTOPMOST, From 6bd23dac39d91f061722ad74dfd4c3faf760fa9a Mon Sep 17 00:00:00 2001 From: diafero Date: Mon, 1 Aug 2011 17:57:59 +0200 Subject: [PATCH 2/6] ignore pyc files (from the resource generator) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 813dc5ed..44dae2f7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ tags *.swp *.o *.orig +*.pyc Makefile CMakeCache.txt From b3e10ea95f58ef0c2d08c1d71322737cb2ded89e Mon Sep 17 00:00:00 2001 From: diafero Date: Mon, 1 Aug 2011 17:57:15 +0200 Subject: [PATCH 3/6] skip EULA if no TOS file exists --- Sources/Plasma/Apps/plClient/winmain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 56dcbcdc..31774239 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -1008,6 +1008,8 @@ BOOL CALLBACK UruTOSDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SetDlgItemText(hwndDlg, IDC_URULOGIN_EULATEXT, eulaData); delete [] eulaData; } + else // no TOS found, go ahead + EndDialog(hwndDlg, true); break; } From e2603ef9dabbcfff00a5f76d175e4f6a8a667bd3 Mon Sep 17 00:00:00 2001 From: diafero Date: Mon, 1 Aug 2011 18:35:39 +0200 Subject: [PATCH 4/6] remove unused parameter (how old is that code??) --- Sources/Plasma/Apps/plClient/winmain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 31774239..46335029 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -86,7 +86,6 @@ extern hsBool gUseBackgroundDownloader; enum { - kArgToDni, kArgSkipLoginDialog, kArgServerIni, kArgLocalData, @@ -94,7 +93,6 @@ enum }; static const CmdArgDef s_cmdLineArgs[] = { - { kCmdArgFlagged | kCmdTypeBool, L"ToDni", kArgToDni }, { kCmdArgFlagged | kCmdTypeBool, L"SkipLoginDialog", kArgSkipLoginDialog }, { kCmdArgFlagged | kCmdTypeString, L"ServerIni", kArgServerIni }, { kCmdArgFlagged | kCmdTypeBool, L"LocalData", kArgLocalData }, From 4563df7f201cbf716fa6f6bf088662fe3598ac96 Mon Sep 17 00:00:00 2001 From: diafero Date: Mon, 1 Aug 2011 23:19:00 +0200 Subject: [PATCH 5/6] fix UruLauncher crash when the Launcher manifest is empty --- Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp | 7 +++++++ .../Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp b/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp index 2c465a7a..98832e1a 100644 --- a/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp +++ b/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp @@ -153,6 +153,13 @@ static void ManifestCallback ( return; } +#ifndef PLASMA_EXTERNAL_RELEASE + if (entryCount == 0) { // dataserver does not contain a patcher + s_downloadComplete = true; + return; + } +#endif + char ansi[MAX_PATH]; // MD5 check current patcher against value in manifest diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index a17d4d50..453c7940 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -944,7 +944,7 @@ bool ManifestRequestTrans::Recv ( dword numFiles = reply.numFiles; dword wcharCount = reply.wcharCount; - const wchar* curChar = reply.manifestData; + const wchar* curChar = reply.manifestData; // the pointer is not yet dereferenced here! // tell the server we got the data Cli2File_ManifestEntryAck manifestAck; @@ -955,9 +955,9 @@ bool ManifestRequestTrans::Recv ( m_conn->Send(&manifestAck, manifestAck.messageBytes); - // if wcharCount is 2, the data only contains the terminator "\0\0" and we + // if wcharCount is 2 or less, the data only contains the terminator "\0\0" and we // don't need to convert anything (and we are done) - if ((IS_NET_ERROR(reply.result)) || (wcharCount == 2)) { + if ((IS_NET_ERROR(reply.result)) || (wcharCount <= 2)) { // we have a problem... or we have nothing to so, so we're done m_result = reply.result; m_state = kTransStateComplete; From 325953eee5366336a4c8ced0dbc20fab6cfb621e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 2 Aug 2011 23:32:01 -0400 Subject: [PATCH 6/6] Compile fixes for PlasmaMAX --- Sources/Tools/MaxMain/CMakeLists.txt | 4 +++- Sources/Tools/MaxMain/SimpleExport.rc | 15 --------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Sources/Tools/MaxMain/CMakeLists.txt b/Sources/Tools/MaxMain/CMakeLists.txt index d39c5d25..f78f70c7 100644 --- a/Sources/Tools/MaxMain/CMakeLists.txt +++ b/Sources/Tools/MaxMain/CMakeLists.txt @@ -96,6 +96,7 @@ endif() target_link_libraries(MaxMain ${EXPAT_LIBRARY}) target_link_libraries(MaxMain ${DirectX_LIBRARIES}) target_link_libraries(MaxMain ${JPEG_LIBRARY}) +target_link_libraries(MaxMain ${PNG_LIBRARY}) target_link_libraries(MaxMain ${Ogg_LIBRARIES}) target_link_libraries(MaxMain ${OPENAL_LIBRARY}) target_link_libraries(MaxMain ${OPENSSL_LIBRARIES}) @@ -105,7 +106,7 @@ target_link_libraries(MaxMain optimized ${PYTHON_LIBRARY}) target_link_libraries(MaxMain ${Speex_LIBRARY}) target_link_libraries(MaxMain ${Vorbis_LIBRARIES}) -# Carbon copy from MaxMain +# Carbon copy from plClient # TODO: Maybe see if some of these can be removed? target_link_libraries(MaxMain CoreLib) target_link_libraries(MaxMain CoreLibExe) @@ -135,6 +136,7 @@ target_link_libraries(MaxMain plAudioCore) target_link_libraries(MaxMain plAvatar) target_link_libraries(MaxMain plCompression) target_link_libraries(MaxMain plContainer) +target_link_libraries(MaxMain plClientResMgr) target_link_libraries(MaxMain plDrawable) target_link_libraries(MaxMain plEncryption) target_link_libraries(MaxMain plFile) diff --git a/Sources/Tools/MaxMain/SimpleExport.rc b/Sources/Tools/MaxMain/SimpleExport.rc index cb57200e..33931d00 100644 --- a/Sources/Tools/MaxMain/SimpleExport.rc +++ b/Sources/Tools/MaxMain/SimpleExport.rc @@ -449,21 +449,6 @@ BEGIN END #endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_CURSOR_UP BITMAP "../../Plasma/Apps/plClient/res/cursor_up.bmp" -IDB_CURSOR_DOWN BITMAP "../../Plasma/Apps/plClient/res/cursor_down.bmp" -IDB_CURSOR_RIGHT BITMAP "../../Plasma/Apps/plClient/res/cursor_right.bmp" -IDB_CURSOR_LEFT BITMAP "../../Plasma/Apps/plClient/res/cursor_left.bmp" -IDB_CURSOR_OPEN BITMAP "../../Plasma/Apps/plClient/res/cursor_open.bmp" -IDB_CURSOR_GRAB BITMAP "../../Plasma/Apps/plClient/res/cursor_grab.bmp" -IDB_CURSOR_CLICKED BITMAP "../../Plasma/Apps/plClient/res/cursor_clicked.bmp" -IDB_CURSOR_POISED BITMAP "../../Plasma/Apps/plClient/res/cursor_poised.bmp" - ///////////////////////////////////////////////////////////////////////////// // // Menu