Mercurial > mm7
diff SaveLoad.cpp @ 2154:9bd7522cdbbb
Render decoupling.
Unsorted variables cleaning.
author | Nomad |
---|---|
date | Thu, 09 Jan 2014 14:36:48 +0200 |
parents | d28d3c006077 |
children | daa61976637d |
line wrap: on
line diff
--- a/SaveLoad.cpp Thu Jan 09 02:34:20 2014 +0200 +++ b/SaveLoad.cpp Thu Jan 09 14:36:48 2014 +0200 @@ -229,7 +229,7 @@ //----- (0045F469) -------------------------------------------------------- void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) { - unsigned short *pScreenshot; // edi@5 + //unsigned short *pScreenshot; // edi@5 int text_pos; // eax@6 FILE *pLLoidFile; // edi@24 char* compressed_buf; // edi@30 @@ -278,10 +278,10 @@ pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; else pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; - pScreenshot = MakeScreenshot(150, 112); + + pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); strcpy(pLodDirectory.pFilename, "image.pcx"); - pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); - free(pScreenshot); + if (pCurrentScreen == SCREEN_SAVEGAME) { pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); @@ -556,7 +556,7 @@ viewparams->bRedrawGameUI = 1; for (uint i = 0; i < 45; i++) pSavegameThumbnails[i].Release(); - //while ( (signed int)v3 < (signed int)&unk_6A0758 ); + if ( bNotArena ) pNew_LOD->_4621A7(); else @@ -665,166 +665,4 @@ } free(pSave); } -//----- (0045E03A) -------------------------------------------------------- -unsigned short *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; - - pPixels = (unsigned __int16 *)malloc(2 * height * width); - memset(pPixels, 0 , 2 * height * width); - - v3 = pPixels; - if (!pRenderer->pRenderD3D) - __debugbreak(); - - pRenderer->BeginSceneD3D(); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->Draw(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Draw(); - - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - memset(&Dst, 0, 0x7C); - Dst.dwSize = sizeof(Dst); - - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) - { - for (uint y = 0; y < height; ++y) - { - for (uint x = 0; x < 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 (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) - { - auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; - *v3 = *p; - } - else __debugbreak(); - ++v3; - } - } - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); - } - else - { - __debugbreak(); // unrefactored - v4 = height; - if ( height > 0 ) - { - do - { - if ( width > 0 ) - { - v5 = width & 1; - v6 = (unsigned int)width >> 1; - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v7 = &v3[2 * v6]; - for ( j = v5; j; --j ) - { - *v7 = 0; - ++v7; - } - v3 += width; - } - --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(); - }*/ - return pPixels; -} -//----- (0045E26C) -------------------------------------------------------- -void SaveScreenshot(const char *pFilename) -{ - unsigned short *screenshot; // esi@1 - - screenshot = MakeScreenshot(92, 68); - pRenderer->SavePCXImage(pFilename, screenshot, 92, 68); - free(screenshot); -} \ No newline at end of file