Mercurial > mm7
changeset 2461:ff7f4995aa25
function MakeScreenshot()
author | Ritor1 |
---|---|
date | Tue, 05 Aug 2014 17:00:35 +0600 |
parents | 1921b140607a |
children | 1d04e48651d4 |
files | GUIWindow.cpp Game.cpp LOD.cpp OSAPI.cpp Outdoor.cpp Render.cpp UI/UICharacter.cpp UI/UIPopup.cpp mm7_2.cpp |
diffstat | 9 files changed, 252 insertions(+), 404 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIWindow.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/GUIWindow.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -181,14 +181,12 @@ //----- (0041D73D) -------------------------------------------------------- void GUIWindow::_41D73D_draw_buff_tooltip() - { - +{ __int64 remaing_time; // ST28_8@11 unsigned short text_color; int Y_pos; // esi@11 int string_count; // [sp+20h] [bp-4h]@7 - string_count = 0; for (int i=0; i<20; ++i) if ( pParty->pPartyBuffs[i].uExpireTime > 0i64 ) @@ -199,9 +197,9 @@ uFrameZ = uFrameWidth + uFrameX - 1; uFrameW = uFrameY + uFrameHeight - 1; DrawMessageBox(0); - DrawTitleText(pFontArrus, 0, 12, 0, pGlobalTXT_LocalizationStrings[451], 3u); + DrawTitleText(pFontArrus, 0, 12, 0, pGlobalTXT_LocalizationStrings[451], 3); if ( !string_count ) - DrawTitleText(pFontComic, 0, 40, 0, pGlobalTXT_LocalizationStrings[153], 3u); + DrawTitleText(pFontComic, 0, 40, 0, pGlobalTXT_LocalizationStrings[153], 3); GetTickCount(); string_count = 0; @@ -215,7 +213,7 @@ DrawText(pFontComic, 52, Y_pos, text_color, aSpellNames[i], 0, 0, 0); DrawBuff_remaining_time_string(Y_pos, this, remaing_time, pFontComic); ++string_count; - } + } } }
--- a/Game.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/Game.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -208,9 +208,11 @@ static uint frames_this_second = 0; static uint last_frame_time = GetTickCount(); static uint framerate_time_elapsed = 0; + if ( pCurrentScreen == SCREEN_GAME && uCurrentlyLoadedLevelType == LEVEL_Outdoor) pWeather->Draw();//Ritor1: my include + //while(GetTickCount() - last_frame_time < 33 );//FPS control uint frame_dt = GetTickCount() - last_frame_time; last_frame_time = GetTickCount();
--- a/LOD.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/LOD.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -1965,50 +1965,32 @@ //----- (00410423) -------------------------------------------------------- void LODFile_IconsBitmaps::_410423_move_textures_to_device() { - //LODFile_IconsBitmaps *v1; // esi@1 - unsigned int v2; // edi@1 - char *v3; // ebx@2 size_t v4; // eax@9 char *v5; // ST1C_4@9 - void *v6; // eax@12 - signed int v7; // esi@13 - __debugbreak();//Ritor1 - v2 = this->uNumLoadedFiles - 1; - if ( (v2 & 0x80000000u) == 0 ) + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) { - v3 = &this->pTextures[v2].pName[2]; - do + if ( this->ptr_011BB4[i] ) { - if ( this->ptr_011BB4[v2] ) + if ( this->pTextures[i].pName[0] != 'w' || this->pTextures[i].pName[1] != 't' + || this->pTextures[i].pName[2] != 'r' || this->pTextures[i].pName[3] != 'd' || this->pTextures[i].pName[4] != 'r' ) + pRenderer->LoadTexture(&this->pTextures[i].pName[0], this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], + &this->pHardwareTextures[i]); + else { - if ( *(v3 - 2) != 'w' || *(v3 - 1) != 't' || *v3 != 'r' || v3[1] != 'd' || v3[2] != 'r' ) - { - pRenderer->LoadTexture(v3 - 2, *((short *)v3 + 17), (IDirectDrawSurface4 **)&this->pHardwareSurfaces[v2], - &this->pHardwareTextures[v2]); - } - else - { - v4 = strlen(v3 - 2); - v5 = (char *)malloc(v4 + 2); - *v5 = 'h'; - strcpy(v5 + 1, v3 - 2); - pRenderer->LoadTexture(v5, *((short *)v3 + 17), (IDirectDrawSurface4 **)&this->pHardwareSurfaces[v2], - &this->pHardwareTextures[v2]); - free(v5); - } + v4 = strlen(&this->pTextures[i].pName[0]); + v5 = (char *)malloc(v4 + 2); + *v5 = 'h'; + strcpy(v5 + 1, &this->pTextures[i].pName[0]); + pRenderer->LoadTexture(v5, this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], &this->pHardwareTextures[i]); + free(v5); } - --v2; - v3 -= 72; } - while ( (v2 & 0x80000000u) == 0 ); } - v6 = this->ptr_011BB4; - if ( v6 ) + if ( this->ptr_011BB4 ) { - v7 = this->uNumLoadedFiles; - if ( v7 > 1 ) - memset(v6, 0, v7 - 1); + if ( this->uNumLoadedFiles > 1 ) + memset(this->ptr_011BB4, 0, this->uNumLoadedFiles - 1); } }
--- a/OSAPI.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/OSAPI.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -15,20 +15,19 @@ //----- (00462C94) -------------------------------------------------------- -int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t *lpCmdLine, int nShowCmd) +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hprevinstance, wchar_t *lpCmdLine, int nShowCmd) { Log::Initialize(); //if (HWND hMM7Window = FindWindowW(L"MM7", 0)) - if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))//check whether the window is open(проверка открыто ли окно такое же) + if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))//check whether the window is open { if (IsIconic(hMM7Window)) ShowWindow(hMM7Window, SW_RESTORE); SetForegroundWindow(GetLastActivePopup(hMM7Window)); return 0; } - //GetActiveWindow() возвращает дескриптор активного окна текущего приложения(котоpое имеет текущий фокус ввода). - //В случае ошибки,или в случае,если в программе нет активных окон,функция возвращает 0. + HWND hPrevWindow = GetActiveWindow(); if (!hPrevWindow) {
--- a/Outdoor.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/Outdoor.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -3641,12 +3641,12 @@ v129 = fixpoint_mul(4, stru_5C6E00->Cos(GetTickCount())); pZ = v113 + v129; if ( pModel_ ) - pZ = v113; //взлетание выше + pZ = v113; if (pParty->FlyActive()) stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFE; pParty->uFallStartY = pZ; } - else if ( pZ < v111 )// подъём в горку + else if ( pZ < v111 ) { if ( is_on_water && fall_speed ) SpriteObject::sub_42F960_create_object(pX, pY, v111);
--- a/Render.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/Render.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -1324,13 +1324,6 @@ //----- (0049DE14) -------------------------------------------------------- bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) { - //IDirectDraw4 *v8; // eax@12 - //IDirectDraw4 *v9; // eax@16 - //IDirectDraw4 *v10; // eax@20 - //IDirectDraw4 *v13; // eax@35 - //const char *v23; // [sp-4h] [bp-DCh]@9 - //const char *v24; // [sp-4h] [bp-DCh]@13 - //const char *v25; // [sp-4h] [bp-DCh]@19 DWORD v26; // [sp-4h] [bp-DCh]@30 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 @@ -1345,12 +1338,14 @@ this->bWindowed = bWindowed; this->hWindow = hWnd; - if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) + //Создание объекта DirectDraw + if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, NULL))) { sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); return 0; } + //Запрос интерфейса IDirectDraw4 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) { sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); @@ -1359,8 +1354,9 @@ return 0; } lpDD->Release(); - lpDD = 0; - + lpDD = NULL; + + //Задаём уровень совместного доступа для приложения DirectDraw в оконном режиме if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) { if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) @@ -1369,199 +1365,202 @@ if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } + + // memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); ddsd2.dwSize = sizeof(DDSURFACEDESC2); ddsd2.dwFlags = DDSD_CAPS; ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) - { - ddsd2.dwSize = sizeof(DDSURFACEDESC2); - pHost->GetDisplayMode(&ddsd2); - if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) - { - sprintf(pErrorMessage, "Init - Desktop isn't in 16 bit mode.\n"); - if (pFrontBuffer) + //Создаём первичную поверхность + if ( FAILED(pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL)) ) + { + sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); + if (pHost) + { + pHost->Release(); + pHost = NULL; + } + return 0; + } + ddsd2.dwSize = sizeof(DDSURFACEDESC2); + pHost->GetDisplayMode(&ddsd2); + if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) + { + sprintf(pErrorMessage, "Init - Desktop isn't in 16 bit mode.\n"); + if (pFrontBuffer) + { + pFrontBuffer->Release(); + pFrontBuffer = NULL; + } + if (pHost) + { + pHost->Release(); + pHost = NULL; + } + return 0; + } + + ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; + ddsd2.dwWidth = game_width; + ddsd2.dwHeight = game_height; + if (pHost->CreateSurface(&ddsd2, &pBackBuffer, NULL) ) + { + sprintf(pErrorMessage, "Init - Failed to create back buffer.\n"); + if (pFrontBuffer) + { + pFrontBuffer->Release(); + pFrontBuffer = NULL; + } + if (pHost) + { + pHost->Release(); + pHost = NULL; + } + return 0; + } + if ( pHost->CreateClipper(0, &v30, 0) ) + { + sprintf(pErrorMessage, "Init - Failed to create clipper.\n"); + if (pBackBuffer) + { + pBackBuffer->Release(); + pBackBuffer = NULL; + } + if (pFrontBuffer) + { + pFrontBuffer->Release(); + pFrontBuffer= NULL; + } + if (pHost) + { + pHost->Release(); + pHost = NULL; + } + return 0; + } + v30->SetHWnd(0, hWnd); + pFrontBuffer->SetClipper(v30); + + v30->Release(); + v30 = NULL; + + pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); + + ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; + ddsd2.dwWidth = game_width; + ddsd2.dwHeight = game_height; + + if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, + (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, + &ddsd2.ddpfPixelFormat) ) + { + sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n"); + if (pBackBuffer) + { + pBackBuffer->Release(); + pBackBuffer = NULL; + } + if (pFrontBuffer) + { + pFrontBuffer->Release(); + pFrontBuffer= NULL; + } + if (pHost) + { + pHost->Release(); + pHost = NULL; + } + return 0; + } + if ( uDeviceID == 2 || uDeviceID == 3 ) + ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + + if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) ) + { + if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) + { + if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) ) { - pFrontBuffer->Release(); - pFrontBuffer = 0; - } - if (pHost) - { - pHost->Release(); - pHost = 0; + memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); + d3dvp2.dvClipWidth = 2.0; + d3dvp2.dvClipY = 1.0; + d3dvp2.dvClipHeight = 2.0; + d3dvp2.dvMaxZ = 1.0; + d3dvp2.dvMinZ = 0.0; + goto LABEL_54; } - return 0; - } - - ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; - ddsd2.dwWidth = game_width; - ddsd2.dwHeight = game_height; - if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) - { - sprintf(pErrorMessage, "Init - Failed to create back buffer.\n"); - if (pFrontBuffer) + sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); + if (pDirect3D) { - pFrontBuffer->Release(); - pFrontBuffer = 0; + pDirect3D->Release(); + pDirect3D = NULL; } - if (pHost) + if (pZBuffer) { - pHost->Release(); - pHost = 0; + pZBuffer->Release(); + pZBuffer = NULL; } - return 0; - } - if ( pHost->CreateClipper(0, &v30, 0) ) - { - sprintf(pErrorMessage, "Init - Failed to create clipper.\n"); if (pBackBuffer) { pBackBuffer->Release(); - pBackBuffer = 0; - } - if (pFrontBuffer) - { - pFrontBuffer->Release(); - pFrontBuffer= 0; - } - if (pHost) - { - pHost->Release(); - pHost = 0; - } - return 0; - } - v30->SetHWnd(0, hWnd); - pFrontBuffer->SetClipper(v30); - - v30->Release(); - v30 = 0; - - pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); - - ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; - ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; - ddsd2.dwWidth = game_width; - ddsd2.dwHeight = game_height; - - if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, - (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, - &ddsd2.ddpfPixelFormat) ) - { - sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n"); - if (pBackBuffer) - { - pBackBuffer->Release(); - pBackBuffer = 0; + pBackBuffer = NULL; } if (pFrontBuffer) { pFrontBuffer->Release(); - pFrontBuffer= 0; + pFrontBuffer= NULL; } if (pHost) { pHost->Release(); - pHost = 0; - } - return 0; - } - if ( uDeviceID == 2 || uDeviceID == 3 ) - ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; - - if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) - { - if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) - { - if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) ) - { - memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); - d3dvp2.dvClipWidth = 2.0; - d3dvp2.dvClipY = 1.0; - d3dvp2.dvClipHeight = 2.0; - d3dvp2.dvMaxZ = 1.0; - d3dvp2.dvMinZ = 0.0; - goto LABEL_54; - } - sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); - if (pDirect3D) - { - pDirect3D->Release(); - pDirect3D = 0; - } - if (pZBuffer) - { - pZBuffer->Release(); - pZBuffer = 0; - } - if (pBackBuffer) - { - pBackBuffer->Release(); - pBackBuffer = 0; - } - if (pFrontBuffer) - { - pFrontBuffer->Release(); - pFrontBuffer= 0; - } - if (pHost) - { - pHost->Release(); - pHost = 0; - } - return 0; - } - sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); - if (pZBuffer) - { - pZBuffer->Release(); - pZBuffer = 0; - } - if (pBackBuffer) - { - pBackBuffer->Release(); - pBackBuffer = 0; - } - if (pFrontBuffer) - { - pFrontBuffer->Release(); - pFrontBuffer= 0; - } - if (pHost) - { - pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } - sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); + sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); + if (pZBuffer) + { + pZBuffer->Release(); + pZBuffer = NULL; + } if (pBackBuffer) { pBackBuffer->Release(); - pBackBuffer = 0; + pBackBuffer = NULL; } if (pFrontBuffer) { pFrontBuffer->Release(); - pFrontBuffer= 0; + pFrontBuffer= NULL; } if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } - sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); + sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); + if (pBackBuffer) + { + pBackBuffer->Release(); + pBackBuffer = NULL; + } + if (pFrontBuffer) + { + pFrontBuffer->Release(); + pFrontBuffer= NULL; + } if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } @@ -1575,7 +1574,7 @@ if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } @@ -1585,7 +1584,7 @@ if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } @@ -1595,13 +1594,13 @@ ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd2.dwBackBufferCount = 1; - if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) + if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) ) { sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } @@ -1618,17 +1617,17 @@ if (pBackBuffer) { pBackBuffer->Release(); - pBackBuffer = 0; + pBackBuffer = NULL; } if (pFrontBuffer) { pFrontBuffer->Release(); - pFrontBuffer= 0; + pFrontBuffer= NULL; } if (pHost) { pHost->Release(); - pHost = 0; + pHost = NULL; } return 0; } @@ -1662,7 +1661,7 @@ if ( uDeviceID == 2 || uDeviceID == 3 ) BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; //uDeviceIDa = &pZBuffer; - if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) + if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) ) { sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); if (pBackBuffer) @@ -1943,7 +1942,7 @@ ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; } - if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) + if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, NULL))) return false; if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) { @@ -2311,17 +2310,13 @@ int v5; // eax@8 FILE *pOutFile; // edi@10 unsigned short *v8; // eax@11 -// int v9; // eax@13 -// int v10; // ecx@15 signed int v12; // eax@18 -// HRESULT v14; // eax@29 char v15[56]; // [sp+Ch] [bp-158h]@10 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 char color_map[48]; // [sp+C4h] [bp-A0h]@10 char Filename[40]; // [sp+F4h] [bp-70h]@3 char *lineB; // [sp+11Ch] [bp-48h]@14 char *lineG; // [sp+120h] [bp-44h]@14 - //int v24; // [sp+124h] [bp-40h]@11 FILE *File; // [sp+128h] [bp-3Ch]@3 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 @@ -2353,8 +2348,8 @@ pitch = pitch + 1; if ( this->pRenderD3D ) { - memset(&Dst, 0, 0x7C); - Dst.dwSize = 124; + memset(&Dst, 0, sizeof(Dst)); + Dst.dwSize = sizeof(Dst); if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) return; surface = Dst.lpSurface; @@ -2451,7 +2446,7 @@ } } if ( this->pRenderD3D ) - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); + ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); else pRenderer->EndScene(); @@ -2617,7 +2612,7 @@ } } if ( this->pRenderD3D ) - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); + ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); else pRenderer->EndScene(); free(lineRGB); @@ -3238,7 +3233,7 @@ } } - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); + ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); /* while ( 1 ) { @@ -3289,7 +3284,7 @@ uHalfWidth = v20; if ( !--uNumLines ) { - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); + ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); return; } } @@ -3485,7 +3480,7 @@ ddsd2.ddsCaps.dwCaps = 2112; ddsd2.dwWidth = 640; ddsd2.dwHeight = 480; - ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); + ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, NULL)); pBeforePresentFunction = Present_ColorKey; } else*/ @@ -3497,7 +3492,7 @@ pDesc.dwSize = 124, !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) return 0; - pBackBuffer4->Unlock(0); + pBackBuffer4->Unlock(NULL); v22 = (int *)pTargetSurface_unaligned + 4; v23 = (unsigned int)pDesc.lpSurface & 7; LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; @@ -3682,7 +3677,7 @@ ddsd2.ddsCaps.dwCaps = 2112; ddsd2.dwWidth = 640; ddsd2.dwHeight = 480; - ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); + ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, NULL)); pBeforePresentFunction = Present_ColorKey;*/ using_software_screen_buffer = 1; //LABEL_47: @@ -3699,8 +3694,8 @@ if (!pTargetSurface_unaligned) return false; - memset(&pDesc, 0, 0x7Cu); - pDesc.dwSize = 124; + memset(&pDesc, 0, sizeof(pDesc)); + pDesc.dwSize = sizeof(pDesc); if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) { delete [] pTargetSurface_unaligned; @@ -3709,7 +3704,7 @@ memset32(pTargetSurface_unaligned, -1, num_pixels); - pRenderer->pBackBuffer4->Unlock(0); + pRenderer->pBackBuffer4->Unlock(NULL); /*v19 = pTargetSurface_unaligned; v20 = (unsigned int)pDesc.lpSurface & 7; v21 = (unsigned int)ptr_400E8 & 7; @@ -4042,7 +4037,7 @@ char v9; // [sp+Bh] [bp-1h]@1 v9 = 1; - result = pSurface->Lock(0, pDesc, uLockFlags, 0); + result = pSurface->Lock(NULL, pDesc, uLockFlags, NULL); /* Когда объект DirectDrawSurface теряет поверхностную память, методы возвратят DDERR_SURFACELOST и не выполнят никакую другую функцию. Метод IDirectDrawSurface::Restore перераспределит поверхностную память @@ -4065,7 +4060,7 @@ pRenderer->pFrontBuffer4->Restore(); pSurface->Restore(); } - result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); + result = pSurface->Lock(NULL, pDesc, DDLOCK_WAIT, NULL); if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )//DDERR_SURFACEBUSY - Доступ к этой поверхности отказан, //потому что поверхность блокирована другой нитью. DDERR_INVALIDRECT - Обеспечиваемый прямоугольник недопустим. { @@ -4136,13 +4131,9 @@ void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) { DWORD flags; // eax@1 -// IDirectDraw *v4; // ecx@3 -//// HRESULT v5; // eax@5 -// int v6; // [sp-8h] [bp-8h]@3 -// unsigned int v7; // [sp-4h] [bp-4h]@3 - - flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : - DDSCL_NORMAL; + + //Установка взаимодействия для полноэкранного и оконного режимов + flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL; ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); } @@ -4191,7 +4182,7 @@ pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; v4 = (struct _DDSURFACEDESC *)&a2.lPitch; }*/ - ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); + ErrD3D(pDD->CreateSurface(v4, pOutSurf, NULL)); } //----- (004A12CD) -------------------------------------------------------- @@ -4236,7 +4227,7 @@ ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 }*/ - ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); + ErrD3D(v2->CreateSurface(v4, ppBackBuffer, NULL)); } //----- (004A139A) -------------------------------------------------------- @@ -4273,7 +4264,7 @@ ddsd2.dwSize = 0x7Cu; ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; - ErrD3D(v7->CreateSurface(&ddsd2, &pFrontBuffer4, 0)); + ErrD3D(v7->CreateSurface(&ddsd2, &pFrontBuffer4, NULL)); pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4; ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4; } @@ -4289,10 +4280,7 @@ ddsd.lPitch = 108; ddsd.dwBackBufferCount = 33; ddsd.ddsCaps.dwCaps = 8728; - ErrD3D(pDirectDraw2->CreateSurface( - &ddsd, - (IDirectDrawSurface **)&pFrontBuffer2, - 0)); + ErrD3D(pDirectDraw2->CreateSurface(&ddsd, (IDirectDrawSurface **)&pFrontBuffer2, NULL)); pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; @@ -4352,7 +4340,7 @@ //----- (004A16E1) -------------------------------------------------------- void Render::UnlockBackBuffer() { - ErrD3D(pBackBuffer4->Unlock(0)); + ErrD3D(pBackBuffer4->Unlock(NULL)); } //----- (004A172E) -------------------------------------------------------- @@ -4384,7 +4372,7 @@ //----- (004A17C7) -------------------------------------------------------- void Render::UnlockFrontBuffer() { - ErrD3D(pFrontBuffer4->Unlock(0)); + ErrD3D(pFrontBuffer4->Unlock(NULL)); } //----- (004A1814) -------------------------------------------------------- @@ -6290,7 +6278,7 @@ //Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth, // (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0); - ErrD3D(pNextSurf->Unlock(0)); + ErrD3D(pNextSurf->Unlock(NULL)); //bMipMaps = 0x4D86ACu; } if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) @@ -6324,7 +6312,7 @@ } v14 += (desc.lPitch >> 1) - desc.dwWidth; } - ErrD3D((*pOutSurface)->Unlock(0)); + ErrD3D((*pOutSurface)->Unlock(NULL)); } } delete [] pHWLTexture->pPixels; @@ -6369,7 +6357,7 @@ } v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2; } - ErrD3D(pSprite->pTextureSurface->Unlock(0)); + ErrD3D(pSprite->pTextureSurface->Unlock(NULL)); } delete [] sprite_texture->pPixels; delete sprite_texture; @@ -6439,7 +6427,7 @@ this->pTargetSurface = 0; this->uTargetSurfacePitch = 0; this->field_18_locked_pitch = 0; - ErrD3D(this->pColorKeySurface4->Unlock(0)); + ErrD3D(this->pColorKeySurface4->Unlock(NULL)); }*/ } else @@ -9127,26 +9115,10 @@ unsigned short *Render::MakeScreenshot(signed int width, signed int height) { unsigned __int16 *v3; // ebx@1 - int v4; // edx@7 - unsigned __int8 v5; // cf@9 - unsigned int v6; // ecx@9 - unsigned __int16 *v7; // edi@9 - int j; // ecx@9 -// unsigned int screen_x; // qax@18 -// HRESULT v14; // eax@21 -// int v15; // edi@29 -// signed __int64 v16; // qax@30 -// signed int v17; // edx@34 -// unsigned __int16 *v18; // edi@36 -// int k; // ecx@36 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 float interval_x; // [sp+84h] [bp-20h]@1 - //unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 float interval_y; // [sp+8Ch] [bp-18h]@1 -// unsigned int screen_y; // [sp+90h] [bp-14h]@17 -// int v28; // [sp+98h] [bp-Ch]@16 -// int v29; // [sp+9Ch] [bp-8h]@15 interval_x = game_viewport_width / (double)width; interval_y = game_viewport_height / (double)height; @@ -9163,126 +9135,37 @@ else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) pOutdoor->Draw(); DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - memset(&Dst, 0, 0x7C); + memset(&Dst, 0, sizeof(Dst)); Dst.dwSize = sizeof(Dst); if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) { - for (uint y = 0; y < (unsigned int)height; ++y) - { - for (uint x = 0; x < (unsigned int)width; ++x) - { - //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)]; - /* - if (ddpfPrimarySuface.dwRGBBitCount == 32) - { - auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; - *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); - } - else if (ddpfPrimarySuface.dwRGBBitCount == 16) - { - auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; - *v3 = *p; - } - */ - pRenderer->pTargetSurface; - if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) - { - auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch; - *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); - } - else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) + if (uCurrentlyLoadedLevelType == LEVEL_null) + memset(&v3, 0, sizeof(v3)); + else + { + for (uint y = 0; y < (unsigned int)height; ++y) + { + for (uint x = 0; x < (unsigned int)width; ++x) { - auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; - *v3 = *p; - } - else __debugbreak(); - ++v3; - } - } - ErrD3D(pBackBuffer4->Unlock(0)); - } - else - { - __debugbreak(); // unrefactored - black screenshot - v4 = height; - if ( height > 0 ) - { - do - { - if ( width > 0 ) - { - v5 = width & 1; - v6 = (unsigned int)width / 2; - memset(v3, 0, 4 * ((unsigned int)width / 2)); - v7 = &v3[2 * v6]; - for ( j = v5; j; --j ) + if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) + { + unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch/4); + *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); + } + else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) { - *v7 = 0; - ++v7; + unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; + *v3 = *p; } - v3 += width; + else + assert(false); + ++v3; } - --v4; - } - while ( v4 ); - } - } - - /*if (!pRenderer->pRenderD3D) - { - pRenderer->BeginScene(); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - pIndoor->Draw(); - } - else - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - pOutdoor->Draw(); - } - _this = pRenderer->pTargetSurface; - v26 = pRenderer->uTargetSurfacePitch; - if ( pRenderer->pTargetSurface ) - { - if ( height > 0 ) - { - for ( v29 = 0; v29 < height; ++v29 ) - { - if ( width > 0 ) - { - v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); - for ( v28 = 0; v28 < width; v28++ ) - { - *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; - ++v3; - } - } - } - } - } - else - { - if ( height > 0 ) - { - for ( v17 = height; v17; --v17 ) - { - if ( width > 0 ) - { - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v18 = &v3[2 * ((unsigned int)width >> 1)]; - for ( k = width & 1; k; --k ) - { - *v18 = 0; - ++v18; - } - v3 += width; - } - } - } - } - pRenderer->EndScene(); - }*/ + } + } + ErrD3D(pBackBuffer4->Unlock(NULL)); + } return pPixels; } //----- (0045E26C) --------------------------------------------------------
--- a/UI/UICharacter.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/UI/UICharacter.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -2333,8 +2333,8 @@ int v7; // esi@27 int v8; // eax@29 int v17; // eax@44 - unsigned int v18; // ecx@55 - unsigned int v19; // eax@55 + //unsigned int v18; // ecx@55 + //unsigned int v19; // eax@55 // unsigned int v22; // eax@61 int v23; // eax@62 int v26; // eax@69 @@ -2527,9 +2527,9 @@ if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_DAGGER] & 0xFFC0) || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_SWORD]) >= 3 ) { - v18 = pMouse->uMouseClickX; - v19 = pMouse->uMouseClickY; - if ( (signed int)v18 >= 560 ) + //v18 = pMouse->uMouseClickX; + //v19 = pMouse->uMouseClickY; + if ( (signed int)pMouse->uMouseClickX >= 560 ) { if ( !v51 ) {
--- a/UI/UIPopup.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/UI/UIPopup.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -436,20 +436,10 @@ //----- (0041E360) -------------------------------------------------------- void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *pWindow) { -// int v8; // eax@4 unsigned __int16 v9; // dx@4 SpriteFrame *v10; // edi@17 unsigned int v18; // ecx@19 unsigned int v19; // eax@21 -// char *v20; // esi@28 -// int v21; // edx@29 -// unsigned __int16 *v22; // ecx@29 -// int v23; // eax@29 -// int v25; // esi@32 -// char *v26; // edx@34 -// unsigned __int8 v27; // sf@36 -// unsigned __int8 v28; // of@36 -// SpellBuff *v40; // eax@60 int skill_points; // edi@61 unsigned int skill_level; // eax@61 int pTextHeight; // edi@90 @@ -462,9 +452,6 @@ unsigned char resistances[11]; // [sp+124h] [bp-C8h]@127 RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3 unsigned int v107; // [sp+1A0h] [bp-4Ch]@18 -// unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34 -// unsigned int v109; // [sp+1A8h] [bp-44h]@32 -// LPVOID v110; // [sp+1ACh] [bp-40h]@28 bool for_effects; // [sp+1C0h] [bp-2Ch]@3 bool normal_level; // [sp+1D0h] [bp-1Ch]@18 bool expert_level; // [sp+1C4h] [bp-28h]@18 @@ -472,7 +459,6 @@ bool grandmaster_level; // [sp+1B4h] [bp-38h]@3 const char *pText; // [sp+1D4h] [bp-18h]@18 int pTextColorID; // [sp+1E4h] [bp-8h]@18 -// int a4; // [sp+1E8h] [bp-4h]@18 int v115; bool monster_full_informations = false; @@ -646,7 +632,7 @@ pRenderer->WritePixel16(x, y, b | 2 * (src[idx] & 0xFFE0)); } } - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0); + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(NULL); } } }
--- a/mm7_2.cpp Thu Jul 31 13:18:42 2014 +0600 +++ b/mm7_2.cpp Tue Aug 05 17:00:35 2014 +0600 @@ -240,9 +240,7 @@ window_SpeakInHouse->Release(); window_SpeakInHouse = 0; if ( v15 == (void *)2 ) - { result = pMessageQueue_50CBD0->uNumMessages; - } else { LODWORD(v23) = GetTickCount() + 5000; @@ -1418,9 +1416,9 @@ pEventTimer = Timer::Create(); pEventTimer->Initialize(); - window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height); + window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window - pRenderer = Render::Create(); + pRenderer = Render::Create();//Create DirectX if (!pRenderer) { Log::Warning(L"Render creation failed");