From 5e3e37f74cfa4a03f9835f31f14b34c7893f8ef7 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 1 Mar 2023 09:18:28 +0800 Subject: [PATCH] Added a tweak to the ammo info for Glovz's/YAAM * to display correct ammo stats based on the formulas w/o editing proto.msg manually. Updated translation ini files. Set the maximum number of screenshots to 10k (was 100k) * 100k is impractical because the max files per directory on FAT32 is 65535 (only if all files are in 8.3 format) when the game came out. --- artifacts/config_files/Translations.ini | 2 + .../translations/brazilian_portuguese.ini | 2 + artifacts/translations/chs.ini | 4 +- artifacts/translations/cht.ini | 4 +- artifacts/translations/french.ini | 2 + artifacts/translations/german.ini | 2 + artifacts/translations/polish.ini | 2 + artifacts/translations/russian.ini | 2 + sfall/Modules/Credits.cpp | 2 - sfall/Modules/DamageMod.cpp | 21 ++++ sfall/Modules/Graphics.cpp | 106 +++++++++--------- 11 files changed, 94 insertions(+), 55 deletions(-) diff --git a/artifacts/config_files/Translations.ini b/artifacts/config_files/Translations.ini index 426f8e19..25df2315 100644 --- a/artifacts/config_files/Translations.ini +++ b/artifacts/config_files/Translations.ini @@ -11,6 +11,8 @@ PartyLvlMsg=Lvl: PartyACMsg=AC: PartyAddictMsg=Addict NPCPickupFail=%s cannot pick up the item. +AmmoInfoGlovz=Div: DR/%d, DT/%d +AmmoInfoYAAM=DT Mod: %d [AppearanceMod] RaceText=Race diff --git a/artifacts/translations/brazilian_portuguese.ini b/artifacts/translations/brazilian_portuguese.ini index 70973022..d4db5f56 100644 --- a/artifacts/translations/brazilian_portuguese.ini +++ b/artifacts/translations/brazilian_portuguese.ini @@ -11,6 +11,8 @@ PartyLvlMsg=Nvl: PartyACMsg=CA: PartyAddictMsg=Viciado NPCPickupFail=%s não pôde pegar o item. +AmmoInfoGlovz=Div: DR/%d, DT/%d +AmmoInfoYAAM=DT Mod: %d [AppearanceMod] RaceText=Raça diff --git a/artifacts/translations/chs.ini b/artifacts/translations/chs.ini index 850d824a..73517700 100644 --- a/artifacts/translations/chs.ini +++ b/artifacts/translations/chs.ini @@ -4,13 +4,15 @@ KarmaGain= KarmaLoss=ÄãʧȥÁË%dµãµÀµÂ¡£ HighlightFail1=ÄãûÓÐЯ´ø¶¯Ì¬¸ÐÓ¦Æ÷¡£ HighlightFail2=ÄãµÄ¶¯Ì¬¸ÐÓ¦Æ÷ûµçÁË¡£ -SuperStimExploitMsg=Äã²»ÄܶÔûÊÜÉ˵ĽÇɫʹÓÃÕâ¸öÎïÆ·£¡ +SuperStimExploitMsg=Äã²»ÄܶÔδÊÜÉ˵ĽÇɫʹÓÃÕâ¸öÎïÆ·£¡ BlockedCombat=ÄãÏÖÔÚ²»ÄܽøÈëÕ½¶·¡£ SaveSfallDataFail=´¢´æ´æµµÑÓÕ¹ÐÅϢʱ·¢Éú´íÎ󣡼ì²éÊÇ·ñÓÐÆäËû³ÌÐòÕ¼Óô浵Îļþ£¯ÎļþŠAÖ®ºóÔÙÊÔÒ»´Î¡£ PartyLvlMsg=µÈ¼¶: PartyACMsg=AC: PartyAddictMsg=ÉÏñ« NPCPickupFail=%sÎÞ·¨½«¶«Î÷¼ñÆðÀ´¡£ +AmmoInfoGlovz=Div: DR/%d, DT/%d +AmmoInfoYAAM=DT Mod: %d [AppearanceMod] RaceText=ÖÖ×å diff --git a/artifacts/translations/cht.ini b/artifacts/translations/cht.ini index 76e74ba5..54981c9b 100644 --- a/artifacts/translations/cht.ini +++ b/artifacts/translations/cht.ini @@ -4,13 +4,15 @@ KarmaGain= KarmaLoss=§A¥¢¥h¤F%dÂI¹D¼w¡C HighlightFail1=§A¨S¦³Äâ±a°ÊºA·PÀ³¾¹¡C HighlightFail2=§Aªº°ÊºA·PÀ³¾¹¨S¹q¤F¡C -SuperStimExploitMsg=§A¤£¯à¹ï¨S¨ü¶Ëªº¨¤¦â¨Ï¥Î³o­Óª««~¡I +SuperStimExploitMsg=§A¤£¯à¹ï¥¼¨ü¶Ëªº¨¤¦â¨Ï¥Î³o­Óª««~¡I BlockedCombat=§A²{¦b¤£¯à¶i¤J¾Ô°«¡C SaveSfallDataFail=Àx¦s¦sÀÉ©µ¦ù¸ê°T®Éµo¥Í¿ù»~¡IÀˬd¬O§_¦³¨ä¥Lµ{¦¡¥e¥Î¦sÀÉÀɮסþ¸ê®Æ§¨¤§«á¦A¸Õ¤@¦¸¡C PartyLvlMsg=µ¥¯Å: PartyACMsg=AC: PartyAddictMsg=¤WÅ} NPCPickupFail=%sµLªk±NªF¦è¾ß°_¨Ó¡C +AmmoInfoGlovz=Div: DR/%d, DT/%d +AmmoInfoYAAM=DT Mod: %d [AppearanceMod] RaceText=ºØ±Ú diff --git a/artifacts/translations/french.ini b/artifacts/translations/french.ini index 9ea97db6..0c949076 100644 --- a/artifacts/translations/french.ini +++ b/artifacts/translations/french.ini @@ -11,6 +11,8 @@ PartyLvlMsg=Niveau: PartyACMsg=CA: PartyAddictMsg=Accroc NPCPickupFail=%s ne peux pas prendre cet objet. +AmmoInfoGlovz=Div. : RD/%d, SD/%d +AmmoInfoYAAM=Mod. SD : %d [AppearanceMod] RaceText=Race diff --git a/artifacts/translations/german.ini b/artifacts/translations/german.ini index 15280a82..7fec334e 100644 --- a/artifacts/translations/german.ini +++ b/artifacts/translations/german.ini @@ -11,6 +11,8 @@ PartyLvlMsg=Lvl: PartyACMsg=RÜ: PartyAddictMsg=Abhäng NPCPickupFail=%s kann das Objekt nicht nehmen. +AmmoInfoGlovz=Div: RV/%d, SV/%d +AmmoInfoYAAM=SV-Mod: %d [AppearanceMod] RaceText=Geschlecht diff --git a/artifacts/translations/polish.ini b/artifacts/translations/polish.ini index d27359b3..ac4ac250 100644 --- a/artifacts/translations/polish.ini +++ b/artifacts/translations/polish.ini @@ -11,6 +11,8 @@ PartyLvlMsg=Lvl: PartyACMsg=AC: PartyAddictMsg=Uzale¿niony NPCPickupFail=%s nie mo¿e podnieœæ przedmiotu. +AmmoInfoGlovz=Dz.: OO/%d, PO/%d +AmmoInfoYAAM=Mod. PO: %d [AppearanceMod] RaceText=Rasa diff --git a/artifacts/translations/russian.ini b/artifacts/translations/russian.ini index 5e96f06f..a3b9e41d 100644 --- a/artifacts/translations/russian.ini +++ b/artifacts/translations/russian.ini @@ -11,6 +11,8 @@ PartyLvlMsg= PartyACMsg=ÊÁ: PartyAddictMsg=Çàâèñèìîñòü NPCPickupFail=%s íå ìîæåò ïîäîáðàòü ïðåäìåò. +AmmoInfoGlovz=Äåë.: ÑÓ/%d, ÏÓ/%d +AmmoInfoYAAM=Èçì. ÏÓ: %d [AppearanceMod] RaceText=Ðàñà diff --git a/sfall/Modules/Credits.cpp b/sfall/Modules/Credits.cpp index e90dd612..80c18dae 100644 --- a/sfall/Modules/Credits.cpp +++ b/sfall/Modules/Credits.cpp @@ -82,7 +82,6 @@ static const char* ExtraLines[] = { }; static DWORD ExtraLineCount = sizeof(ExtraLines) / 4; -//static const char* creditsFile = "credits.txt"; static DWORD __fastcall CreditsNextLine(char* buf, DWORD* font, DWORD* colour) { if (!InCredits || CreditsLine >= ExtraLineCount) return 0; @@ -172,7 +171,6 @@ static void __declspec(naked) ShowCreditsHook() { pop eax; mov InCredits, 1; mov CreditsLine, 0; - //mov eax, creditsFile; call fo::funcoffs::credits_; mov InCredits, 0; retn; diff --git a/sfall/Modules/DamageMod.cpp b/sfall/Modules/DamageMod.cpp index 9b55786c..8d303355 100644 --- a/sfall/Modules/DamageMod.cpp +++ b/sfall/Modules/DamageMod.cpp @@ -20,6 +20,7 @@ #include "..\FalloutEngine\Fallout2.h" #include "..\Logging.h" +#include "..\Translate.h" #include "Unarmed.h" #include "..\Game\stats.h" @@ -31,6 +32,8 @@ namespace sfall static int formula; +static char ammoInfoFmt[32]; + static const DWORD DamageFunctionReturn = 0x424A63; // Damage Fix v5 (with v5.1 Damage Multiplier tweak) by Glovz 2014.04.16.xx.xx @@ -239,6 +242,13 @@ end: } } +static __declspec(naked) void AmmoInfoPrintGlovz() { + __asm { + lea edi, ammoInfoFmt; + retn; + } +} + // YAAM v1.1a by Haenlomal 2010.05.13 static __declspec(naked) void DamageYAAM() { static long calcDT, calcDR; @@ -327,6 +337,13 @@ end: } } +static __declspec(naked) void AmmoInfoPrintYAAM() { + __asm { + lea ecx, ammoInfoFmt; + retn; + } +} + //////////////////////////////////////////////////////////////////////////////// // Display melee damage w/o PERK_bonus_hth_damage bonus @@ -485,9 +502,13 @@ void DamageMod::init() { case 1: case 2: MakeJump(0x424995, DamageGlovz); + MakeCall(0x49B54A, AmmoInfoPrintGlovz, 2); // Dmg Mod (obj_examine_func_) + Translate::Get("sfall", "AmmoInfoGlovz", "Div: DR/%d, DT/%d", ammoInfoFmt, 32); break; case 5: MakeJump(0x424995, DamageYAAM); + MakeCall(0x49B4EB, AmmoInfoPrintYAAM, 2); // DR Mod (obj_examine_func_) + Translate::Get("sfall", "AmmoInfoYAAM", "DT Mod: %d", ammoInfoFmt, 32); break; } } diff --git a/sfall/Modules/Graphics.cpp b/sfall/Modules/Graphics.cpp index f1714f13..ccbc923e 100644 --- a/sfall/Modules/Graphics.cpp +++ b/sfall/Modules/Graphics.cpp @@ -1213,6 +1213,57 @@ void __stdcall Graphics::ForceGraphicsRefresh(DWORD d) { forcingGraphicsRefresh = (d == 0) ? 0 : 1; } +long __stdcall SaveScreen(const char* file) { + IDirect3DSurface9* surface; + d3d9Device->CreateOffscreenPlainSurface(gWidth, gHeight, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, 0); + d3d9Device->GetRenderTargetData(backBuffer, surface); + + LPD3DXBUFFER buffer; + D3DXCreateBuffer(gWidth * gHeight * 2, &buffer); + + D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_PNG, surface, 0, 0); + //D3DXSaveSurfaceToFileA(file, D3DXIFF_PNG, surface, 0, 0); // slow save + + HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + bool resultOK = (hFile != INVALID_HANDLE_VALUE); + if (resultOK) { + DWORD dwWritten; + WriteFile(hFile, buffer->GetBufferPointer(), buffer->GetBufferSize(), &dwWritten, 0); + CloseHandle(hFile); + } + + surface->Release(); + buffer->Release(); + + return (resultOK) ? 0 : 1; +} + +long __stdcall game_screendump_hook() { + char fileName[16]; + + for (int i = 0; i < 10000; i++) { + std::sprintf(fileName, "scr%.5d.png", i); // scr#####.png + + HANDLE hFile = CreateFileA(fileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); + if (hFile == INVALID_HANDLE_VALUE) { + return SaveScreen(fileName); + } + CloseHandle(hFile); + } + return 1; +} + +static __declspec(naked) void dump_screen_hack_replacement() { + __asm { + push ecx; + push edx; + call fo::funcoffs::game_screendump_; // call ds:[FO_VAR_screendump_func]; + pop edx; + pop ecx; + retn; + } +} + //////////////////////////////// WINDOW RENDER ///////////////////////////////// class OverlaySurface { @@ -1343,57 +1394,6 @@ static __declspec(naked) void palette_fade_to_hook() { } } -long __stdcall SaveScreen(const char* file) { - IDirect3DSurface9* surface; - d3d9Device->CreateOffscreenPlainSurface(gWidth, gHeight, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, 0); - d3d9Device->GetRenderTargetData(backBuffer, surface); - - LPD3DXBUFFER buffer; - D3DXCreateBuffer(gWidth * gHeight * 2, &buffer); - - D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_PNG, surface, 0, 0); - //D3DXSaveSurfaceToFileA(file, D3DXIFF_PNG, surface, 0, 0); // slow save - - HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); - bool resultOK = (hFile != INVALID_HANDLE_VALUE); - if (resultOK) { - DWORD dwWritten; - WriteFile(hFile, buffer->GetBufferPointer(), buffer->GetBufferSize(), &dwWritten, 0); - CloseHandle(hFile); - } - - surface->Release(); - buffer->Release(); - - return (resultOK) ? 0 : 1; -} - -long __stdcall game_screendump_hook() { - char fileName[16]; - - for (int i = 0; i < 10000; i++) { - std::sprintf(fileName, "scr%.5d.png", i); // scr#####.png - - HANDLE hFile = CreateFileA(fileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); - if (hFile == INVALID_HANDLE_VALUE) { - return SaveScreen(fileName); - } - CloseHandle(hFile); - } - return 1; -} - -static __declspec(naked) void dump_screen_hack_replacement() { - __asm { - push ecx; - push edx; - call fo::funcoffs::game_screendump_; // call ds:[FO_VAR_screendump_func]; - pop edx; - pop ecx; - retn; - } -} - void Graphics::init() { Graphics::mode = (hrpIsEnabled) // avoid mode mismatch between ddraw.ini and another ini file ? IniReader::GetIntDefaultConfig("Graphics", "Mode", 0) @@ -1464,6 +1464,10 @@ void Graphics::init() { } } + // Set the maximum number of BMP screenshots to 10k (was 100k) + const DWORD screendumpMaxAddr[] = {0x4C908B, 0x4C9093}; // default_screendump_ + SafeWriteBatch(10000, screendumpMaxAddr); + int multi = IniReader::GetConfigInt("Graphics", "FadeMultiplier", 100); if (multi != 100) { dlogr("Applying fade patch.", DL_INIT);