# HG changeset patch # User Ritor1 # Date 1388485568 -21600 # Node ID e378232bfd36baf652c0e0678220d352e6853a6c # Parent 49de109bbab592a79019372453036cb74b5c9093 screenshot diff -r 49de109bbab5 -r e378232bfd36 Render.cpp --- a/Render.cpp Sun Dec 29 01:26:15 2013 +0600 +++ b/Render.cpp Tue Dec 31 16:26:08 2013 +0600 @@ -2195,7 +2195,7 @@ { int v5; // eax@8 FILE *pOutFile; // edi@10 - unsigned short * v8; // eax@11 + unsigned short *v8; // eax@11 int v9; // eax@13 int v10; // ecx@15 signed int v12; // eax@18 @@ -2299,9 +2299,15 @@ lineB = (char *)lineRGB + 2 * pitch; for ( uint x = 0; x < this->field_10; x++ ) { - lineRGB[x] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); - lineG[x] = (signed int)(g_mask & *line_picture_data) >> (num_b_bits + num_g_bits - 8); - lineB[x] = (b_mask & *line_picture_data) << (8 - num_b_bits); + int p = *line_picture_data; + int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); + int value = (pRenderer->uTargetRMask & *line_picture_data); + int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); + lineRGB[x] = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );// + pRenderer->uTargetRBits - 8); + lineG[x] = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);// + pRenderer->uTargetGBits - 8); + int value2 = (pRenderer->uTargetGMask & *line_picture_data); + int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); + lineB[x] = (pRenderer->uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); line_picture_data += 2; } } @@ -2343,29 +2349,23 @@ //----- (0049F1BC) -------------------------------------------------------- void Render::SaveWinnersCertificate(const char *a1) { - Render *v2; // esi@1 - __int16 v3; // di@1 - int v4; // eax@4 - char *v5; // ecx@4 unsigned int v6; // eax@8 - FILE *v7; // edi@10 + //FILE *v7; // edi@10 int v8; // ecx@11 - int v9; // eax@11 + unsigned short *v9; // eax@11 int v10; // eax@13 - const char *v11; // ecx@15 - unsigned __int8 v12; // dl@15 signed int v13; // eax@18 char v14; // zf@27 HRESULT v15; // eax@29 - char v16; // [sp+Ch] [bp-12Ch]@10 + char v16[56]; // [sp+Ch] [bp-12Ch]@10 __int16 v17; // [sp+44h] [bp-F4h]@10 - int Dst; // [sp+48h] [bp-F0h]@7 + DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 int v19; // [sp+58h] [bp-E0h]@8 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 - char v21; // [sp+C4h] [bp-74h]@10 + char color_map[48]; // [sp+C4h] [bp-74h]@10 unsigned int v22; // [sp+F4h] [bp-44h]@11 - char *v23; // [sp+F8h] [bp-40h]@14 - int v24; // [sp+FCh] [bp-3Ch]@11 + char *lineB; // [sp+F8h] [bp-40h]@14 + int image_width; // [sp+FCh] [bp-3Ch]@11 int v25; // [sp+100h] [bp-38h]@4 FILE *File; // [sp+104h] [bp-34h]@3 char Str; // [sp+108h] [bp-30h]@10 @@ -2382,58 +2382,57 @@ char v38; // [sp+119h] [bp-1Fh]@10 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 - void *ptr; // [sp+120h] [bp-18h]@10 - unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 - int v43; // [sp+128h] [bp-10h]@4 + char *lineRGB; // [sp+120h] [bp-18h]@10 + void *surface; // [sp+124h] [bp-14h]@8 + int pitch; // [sp+128h] [bp-10h]@4 char v44; // [sp+12Fh] [bp-9h]@25 - char *i; // [sp+130h] [bp-8h]@10 - unsigned __int8 v46; // [sp+137h] [bp-1h]@17 - - v2 = this; - v3 = 0; + char *lineG; // [sp+130h] [bp-8h]@10 + unsigned char pict_byte; // [sp+137h] [bp-1h]@17 + byte test_byte; + + int num_r_bits = 5; + int num_g_bits = 6; + int num_b_bits = 5; + + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; + if ( !this->pRenderD3D || this->using_software_screen_buffer ) { ++dword_4EFA84; File = fopen(a1, "wb"); if ( File ) { - v4 = v2->field_10; - v5 = (char *)v2->field_14; - v25 = v4; - a1 = v5; - v43 = v4; - if ( v4 & 1 ) - v43 = v4 + 1; - if ( v2->pRenderD3D ) - { - memset(&Dst, 0, 0x7Cu); - Dst = 124; + v25 = this->field_10; + pitch = this->field_10; + if ( this->field_10 & 1 ) + pitch = this->field_10 + 1; + if ( this->pRenderD3D ) + { + memset(&Dst, 0, 0x7C); + Dst.dwSize = 124; if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) return; - __debugbreak(); // warning C4700: uninitialized local variable 'v20' used - v42 = v20; - __debugbreak(); // warning C4700: uninitialized local variable 'v19' used - v6 = v19 >> 1; - v3 = 0; + surface = Dst.lpSurface; + v6 = Dst.lPitch / 2; } else { pRenderer->BeginScene(); - //v42 = pRenderer->pTargetSurface; + surface = pRenderer->pTargetSurface; v6 = pRenderer->uTargetSurfacePitch; } - i = (char *)v6; - v33 = v25 - 1; - v31 = v3; - v34 = (short)a1 - 1; - v32 = v3; - v39 = v43; - memset(&v21, 0, 0x30u); - memset(&v16, 0, 0x38u); + v33 = this->field_10 - 1; + v31 = 0; + v34 = (short)this->field_14 - 1; + v32 = 0; + v39 = pitch; + memset(&color_map, 0, sizeof(color_map)); + memset(&v16, 0, sizeof(v16)); v37 = 0; Str = 10; v17 = 0; - v7 = File; v28 = 5; v29 = 1; v30 = 8; @@ -2441,96 +2440,71 @@ v36 = 75; v38 = 3; v40 = 1; - fwrite(&Str, 1u, 1u, File); - fwrite(&v28, 1u, 1u, v7); - fwrite(&v29, 1u, 1u, v7); - fwrite(&v30, 1u, 1u, v7); - fwrite(&v31, 2u, 1u, v7); - fwrite(&v32, 2u, 1u, v7); - fwrite(&v33, 2u, 1u, v7); - fwrite(&v34, 2u, 1u, v7); - fwrite(&v35, 2u, 1u, v7); - fwrite(&v36, 2u, 1u, v7); - fwrite(&v21, 0x30u, 1u, v7); - fwrite(&v37, 1u, 1u, v7); - fwrite(&v38, 1u, 1u, v7); - fwrite(&v39, 2u, 1u, v7); - fwrite(&v40, 2u, 1u, v7); - fwrite(&v16, 0x3Au, 1u, v7); - ptr = malloc(3 * v25 + 6); - if ( (signed int)a1 > 0 ) - { - v8 = v43; - File = (FILE *)a1; - v24 = 3 * v43; - v22 = 2 * (int)i; - v9 = (int)v42; - while ( 1 ) + fwrite(&Str, 1, 1, File); + fwrite(&v28, 1, 1, File); + fwrite(&v29, 1, 1, File); + fwrite(&v30, 1, 1, File); + fwrite(&v31, 2, 1, File); + fwrite(&v32, 2, 1, File); + fwrite(&v33, 2, 1, File); + fwrite(&v34, 2, 1, File); + fwrite(&v35, 2, 1, File); + fwrite(&v36, 2, 1, File); + fwrite(&color_map, 0x30, 1, File); + fwrite(&v37, 1, 1, File); + fwrite(&v38, 1, 1, File); + fwrite(&v39, 2, 1, File); + fwrite(&v40, 2, 1, File); + fwrite(&v16, 0x3A, 1, File); + lineRGB = (char *)malloc(3 * (v25 + 2)); + if ( (signed int)this->field_14 > 0 ) + { + image_width = 3 * pitch; + v9 = (unsigned short *)surface; + for ( uint j = 0; j < this->field_14; j++) { a1 = (const char *)v9; - v10 = 0; if ( v25 > 0 ) { - i = (char *)ptr + v8; - v23 = (char *)ptr + 2 * v43; - do + lineG = (char *)lineRGB + pitch; + lineB = (char *)lineRGB + 2 * pitch; + for ( v10 = 0; v10 < v25; v10++ ) { - *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) - + LOBYTE(v2->uTargetBBits) - + v2->uTargetRBits - - 8); - i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) - + LOBYTE(v2->uTargetGBits) - - 8); - v11 = a1; - v12 = LOBYTE(v2->uTargetBMask); + lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); + lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); + lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); a1 += 2; - v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); } - while ( v10 < v25 ); } - for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) + for ( uint i = 0; i < image_width; i += test_byte ) { - BYTE3(a1) = 1; - v46 = *((char *)ptr + (int)i); - do + pict_byte = lineRGB[i]; + for ( test_byte = 1; test_byte < 0x3F; test_byte ) { - v13 = (signed int)&i[BYTE3(a1)]; - if ( *((char *)ptr + v13) != v46 ) + v13 = i + test_byte; + if ( lineRGB[v13] != pict_byte ) break; - if ( !(v13 % v43) ) + if ( !(v13 % pitch) ) break; - ++BYTE3(a1); } - while ( BYTE3(a1) < 0x3Fu ); - if ( (signed int)&i[BYTE3(a1)] > v24 ) - BYTE3(a1) = 3 * v43 - (char)i; - if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) + if ( i + test_byte > image_width ) + test_byte = 3 * pitch - i; + if ( test_byte > 1 || pict_byte >= 0xC0 ) { - v44 = BYTE3(a1) | 0xC0; - fwrite(&v44, 1u, 1u, v7); + v44 = test_byte | 0xC0; + fwrite(&v44, 1, 1, File); } - fwrite(&v46, 1u, 1u, v7); + fwrite(&pict_byte, 1, 1, File); } - v9 = (int)&v42[v22 / 2]; - v14 = File == (FILE *)1; - File = (FILE *)((char *)File - 1); - v42 = (unsigned __int16 *)((char *)v42 + v22); - if ( v14 ) - break; - v8 = v43; + v9 += pitch; } } - if ( v2->pRenderD3D ) - { + if ( this->pRenderD3D ) ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); - } else - { pRenderer->EndScene(); - } - free(ptr); - fclose(v7); + free(lineRGB); + fclose(File); } } } diff -r 49de109bbab5 -r e378232bfd36 SaveLoad.cpp --- a/SaveLoad.cpp Sun Dec 29 01:26:15 2013 +0600 +++ b/SaveLoad.cpp Tue Dec 31 16:26:08 2013 +0600 @@ -712,7 +712,7 @@ pOutdoor->Draw(); pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - memset(&Dst, 0, 0x7Cu); + memset(&Dst, 0, 0x7C); Dst.dwSize = sizeof(Dst); if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) @@ -725,7 +725,7 @@ 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; + 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) diff -r 49de109bbab5 -r e378232bfd36 mm7_2.cpp --- a/mm7_2.cpp Sun Dec 29 01:26:15 2013 +0600 +++ b/mm7_2.cpp Tue Dec 31 16:26:08 2013 +0600 @@ -750,15 +750,13 @@ pWindow.uFrameW = 397; pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); if ( pParty->IsPartyGood() ) - { - v1 = pGlobalTXT_LocalizationStrings[675]; - } + v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom." else { result = pParty->IsPartyEvil(); if ( !(short)result ) return result; - v1 = pGlobalTXT_LocalizationStrings[676]; + v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build." } pInString = v1; v23 = pParty->uTimePlayed - 138240; @@ -769,33 +767,19 @@ if ( !v19 ) v19 = 1; pRenderer->BeginScene(); - pWindow.DrawTitleText(pFont, 1u, 0x23u, 1u, pGlobalTXT_LocalizationStrings[9], 3u); - v3 = pParty->pPlayers.data();//[0].pName; + pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations! v23 = 0i64; v20 = 0; - //for ( i = (int)pParty->pPlayers[0].pName; ; v3 = (char *)i ) - for ( i = pParty->pPlayers.data(); ; v3 = i ) + for ( uint i = 0; i < 4; i++ ) { - v4 = pClassNames[v3->classType]; - v5 = v3->GetBaseLevel(); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], i->pName, v5, v4); - pWindow.DrawTitleText( - pFont, - 1u, - v20 * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, - 1u, - pTmpBuf.data(), - 3u); - v23 += i->uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); - ++v20; - ++i; - if ( i > &pParty->pPlayers[3] ) - break; + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s + pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3); + v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); } v23 = (signed __int64)v23 / v19; - v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xCu, 0); - pWindow.DrawTitleText(pFont, 1u, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1u, v6, 0); - strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]); + v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0); + pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0); + strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time: v7 = pGlobalTXT_LocalizationStrings[56]; if ( v17 != 1 ) v7 = pGlobalTXT_LocalizationStrings[57]; @@ -809,7 +793,7 @@ strcat(pTmpBuf.data(), pTmpBuf2.data()); pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1u, pTmpBuf.data(), 3u); sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); - pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight, 1u, pTmpBuf.data(), 3u); + pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1u, pTmpBuf.data(), 3); dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; pRenderer->EndScene(); pRenderer->Present();