From e1f21e67148944ee607c80113dde7077425be15b Mon Sep 17 00:00:00 2001 From: FoxAhead Date: Thu, 22 Sep 2022 20:37:00 +0300 Subject: [PATCH] 72. Processor affinity mask Added option for setting process affinity. Limits the use of cores by the game process. Can help run the game on modern fast systems with lots of cores. --- src/FarCry2MFL_FormOptions.dfm | 12 ++++++------ src/FarCry2MFL_FormOptions.res | Bin 3880 -> 4364 bytes src/FarCry2MFL_FormOptions.xml | 15 +++++++++++++-- src/FarCry2MFL_FormProgress.pas | 2 +- src/FarCry2MFL_Proc.pas | 13 +++++++++++++ src/FarCry2MFLauncher.dof | 6 +++--- src/FarCry2MFLauncher.res | Bin 15920 -> 15920 bytes 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/FarCry2MFL_FormOptions.dfm b/src/FarCry2MFL_FormOptions.dfm index 0dad159..9aae308 100644 --- a/src/FarCry2MFL_FormOptions.dfm +++ b/src/FarCry2MFL_FormOptions.dfm @@ -4,7 +4,7 @@ object FormOptions: TFormOptions BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'Options' - ClientHeight = 270 + ClientHeight = 282 ClientWidth = 513 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -18,14 +18,14 @@ object FormOptions: TFormOptions OnCreate = FormCreate DesignSize = ( 513 - 270) + 282) PixelsPerInch = 96 TextHeight = 13 object CheckListBox1: TCheckListBox Left = 4 Top = 4 Width = 161 - Height = 230 + Height = 242 OnClickCheck = CheckListBox1ClickCheck Anchors = [akLeft, akTop, akBottom] ItemHeight = 13 @@ -34,7 +34,7 @@ object FormOptions: TFormOptions end object ButtonOK: TButton Left = 152 - Top = 241 + Top = 253 Width = 101 Height = 25 Anchors = [akLeft, akBottom] @@ -52,7 +52,7 @@ object FormOptions: TFormOptions end object ButtonCancel: TButton Left = 260 - Top = 241 + Top = 253 Width = 101 Height = 25 Anchors = [akLeft, akBottom] @@ -65,7 +65,7 @@ object FormOptions: TFormOptions Left = 168 Top = 4 Width = 341 - Height = 230 + Height = 242 TabStop = False Anchors = [akLeft, akTop, akBottom] ReadOnly = True diff --git a/src/FarCry2MFL_FormOptions.res b/src/FarCry2MFL_FormOptions.res index a3f682923cf5406470de2183b7bd85e184605800..cd88cd72cbf1e87fc37b41de8917ee8aed362eb0 100644 GIT binary patch delta 470 zcmZWm!AiqG6s*;QU5Mz#qYQgfAv7&sgdU_<50&Z%Y@3&MG1(2f8zrayfP#>J5U(PB znpbg?np*Jm-pGrWB}dEzhVejdK_n_hP^t%}~4FCQs;-K(D2(JD!#lCI=XBBK$X z7(FLzwSm|$G1`Q5K>kmMOxXK?UCT^*gnO8$lx~Ss`|a)4FkrXdNGeAQGI$VaK`@kiLsGvf z>R2JBx>>(gNP8Ku2u`C|)frVFObTFBr delta 32 ncmeBCS|K+
- - + @@ -39,5 +39,16 @@ Runs a console command 'batchfile'. This text file can contain list of console c 'C:\Users\USERNAME\Documents\My Games\Far Cry 2'" default="0"> + + +
\ No newline at end of file diff --git a/src/FarCry2MFL_FormProgress.pas b/src/FarCry2MFL_FormProgress.pas index 338fc01..303e247 100644 --- a/src/FarCry2MFL_FormProgress.pas +++ b/src/FarCry2MFL_FormProgress.pas @@ -41,7 +41,7 @@ implementation procedure TFormProgress.StartTimer(TimeOut: Integer); begin - ProgressBar1.Max := TimeOut * 1000 div Timer1.Interval; + ProgressBar1.Max := TimeOut * 1000 div Integer(Timer1.Interval); Timer1.Enabled := True; end; diff --git a/src/FarCry2MFL_Proc.pas b/src/FarCry2MFL_Proc.pas index 135a53e..802a94f 100644 --- a/src/FarCry2MFL_Proc.pas +++ b/src/FarCry2MFL_Proc.pas @@ -43,6 +43,8 @@ TCommandLineOptions = record bZombieAI: Boolean; bExec: Boolean; sExec: string; + bAffinity: Boolean; + iAffinity: Integer; end; TGameFilesInfo = record @@ -426,6 +428,9 @@ function LaunchGame(): TProcessInformation; ZeroMemory(@ProcessInformation, SizeOf(ProcessInformation)); if not CreateProcess(PAnsiChar(FileName), PAnsiChar(CommandLine), nil, nil, False, CREATE_SUSPENDED, nil, PAnsiChar(Path), StartupInfo, ProcessInformation) then raise Exception.Create('CreateProcess: ' + IntToStr(GetLastError())); + if CommandLineOptions.bAffinity then + if not SetProcessAffinityMask(ProcessInformation.hProcess, CommandLineOptions.iAffinity) then + raise Exception.Create('SetProcessAffinityMask: ' + IntToStr(GetLastError())); EntryPointAddress := $004014EC; ZeroMemory(@Inject, SizeOf(Inject)); Inject.PushCommand := $68; @@ -881,6 +886,10 @@ function GetOptionByKey(Key: string): Variant; Result := CommandLineOptions.bExec; if Key = 'sExec' then Result := CommandLineOptions.sExec; + if Key = 'bAffinity' then + Result := CommandLineOptions.bAffinity; + if Key = 'iAffinity' then + Result := CommandLineOptions.iAffinity; end; procedure SetOptionByKey(Key: string; Value: Variant); @@ -917,6 +926,10 @@ procedure SetOptionByKey(Key: string; Value: Variant); CommandLineOptions.bExec := Value; if Key = 'sExec' then CommandLineOptions.sExec := Value; + if Key = 'bAffinity' then + CommandLineOptions.bAffinity := Value; + if Key = 'iAffinity' then + CommandLineOptions.iAffinity := Value; end; end. diff --git a/src/FarCry2MFLauncher.dof b/src/FarCry2MFLauncher.dof index a0bc297..2ee3336 100644 --- a/src/FarCry2MFLauncher.dof +++ b/src/FarCry2MFLauncher.dof @@ -113,9 +113,9 @@ RootDir= IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 -MinorVer=9 +MinorVer=10 Release=0 -Build=50 +Build=73 Debug=0 PreRelease=0 Special=0 @@ -126,7 +126,7 @@ CodePage=1252 [Version Info Keys] CompanyName= FileDescription= -FileVersion=1.9.0.50 +FileVersion=1.10.0.73 InternalName= LegalCopyright= LegalTrademarks= diff --git a/src/FarCry2MFLauncher.res b/src/FarCry2MFLauncher.res index a0fb5eda7ad1d0285d3f3203590df88c9f5dfa6b..bed1b0e1c71fabb1f2297bf6684ff82b8b5d5952 100644 GIT binary patch delta 52 zcmdl`v!Q0g3u|6321W)?1_lN&J^8EkYGxA#uE~pS6nPC93>fsl*qp(5^F^C@MgVbv B45t79 delta 52 zcmdl`v!Q0g3u|6Z21W)W1_lN&J^8EkYGxw_&dG~y6nQNf^cW0)*c3=IY`$m{&j