Skip to content

Commit 55167e6

Browse files
committed
Fix ZH launch problem (ssleay32.dll)
1 parent 30f10c4 commit 55167e6

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Mod launcher/manager for C&C: Generals: Zero Hour
1515
You don't install this one, you just unzip the zip file in the releases
1616
and execute the .exe file :)
1717

18+
## Fixing ssleay32.dll Problem
19+
* Please install this fix: https://bibber.eu/downloads/cnc-ultimate-collection-launchers/
20+
1821
## Mod Installation Instructions
1922
* Locate your mod files. Most mods will come with a couple of .big files
2023
and no other files.

src/mainform.pas

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ procedure TFormMain.ScanMods();
9292
mod_dir : string;
9393
begin
9494
// scan the dirs in gamedir/Mods
95-
mod_dir := IncludeTrailingPathDelimiter(settings.game_dir)+'Mods';
95+
mod_dir := path_join(settings.game_dir, 'Mods');
9696
If FindFirst( mod_dir + '\*', faAnyFile and faDirectory, info ) = 0 then
9797
Repeat
9898
ProcessMod( info );
@@ -196,7 +196,8 @@ procedure TFormMain.LaunchGame( params: string );
196196
begin
197197
// Just run the game. Don't wait for it.
198198
// The user knows how and when to actiave or deactivate stuff.
199-
ShellExecute( 0, nil, PChar(settings.game_exe), PChar(params), nil, SW_NORMAL );
199+
ShellExecute( 0, nil, PChar(settings.game_exe), PChar(params), PChar(settings.game_dir), SW_NORMAL );
200+
// RunAsAdmin(FormMain.Handle, settings.game_exe, params);
200201
//RunCommand( settings.game_exe, [params], s );
201202
//SysUtils.ExecuteProcess(settings.game_exe, params, []);
202203
end;
@@ -250,9 +251,10 @@ procedure TFormMain.ActivateMod( mod_name: string );
250251
for i := 0 to zbigs.Count-1 do
251252
begin
252253
fname := zbigs[ i ];
253-
src := mod_path + fname;
254-
dest := settings.game_dir + fname;
254+
src := path_join(mod_path, fname);
255+
dest := path_join(settings.game_dir, fname);
255256
dest := StringReplace( dest, '.zbig', '.big', [rfReplaceAll] );
257+
// Warning( src + ' --> ' + dest );
256258
MoveFile( PChar(src), PChar(dest) );
257259
end;
258260
end;
@@ -265,7 +267,7 @@ procedure TFormMain.DeactivateMod();
265267
begin
266268
// From saved settings, determine what mod is active.
267269
mod_name := settings.conf.GetValue( '/current_mod/name', '' );
268-
if length( mod_name ) = 0 then
270+
if mod_name = '' then
269271
exit;
270272

271273
// Find zbigs in the game/Mods/mod_name then move it to game dir.
@@ -277,8 +279,8 @@ procedure TFormMain.DeactivateMod();
277279
for i := 0 to cnt-1 do
278280
begin
279281
fname := settings.conf.GetValue( '/current_mod/files/'+IntToStr(i), '' );
280-
dest := mod_path + fname;
281-
src := settings.game_dir + fname;
282+
dest := path_join(mod_path, fname);
283+
src := path_join(settings.game_dir, fname);
282284
src := StringReplace( src, '.zbig', '.big', [rfReplaceAll] );
283285
// Warning( src + ' --> ' + dest );
284286
MoveFile( PChar(src), PChar(dest) );

src/settings.pas

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TSettings = class
2121
procedure LoadConf();
2222

2323
//function GetMyDoc(): string;
24-
function FindGeneralsExe( t: string ): string;
24+
function FindGeneralsExe(): string;
2525
function GetInstallDir: string;
2626

2727
// Property getter setters
@@ -69,9 +69,9 @@ procedure TSettings.LoadConf();
6969
CreateDir( config_dir );
7070
end;
7171

72-
json_fname := 'config.json';
73-
json_fname := path_join( config_dir, json_fname );
74-
conf.Filename := json_fname; // created if NE. loads if E.
72+
json_fname := 'mod4_config.json';
73+
json_fname := path_join(ExtractFileDir(Application.ExeName), json_fname);
74+
conf.Filename := json_fname; // Created if not exists. Loads it otherwise.
7575
end;
7676

7777
function TSettings.GetInstallDir: string;
@@ -80,7 +80,7 @@ function TSettings.GetInstallDir: string;
8080
diag: TOpenDialog;
8181
begin
8282
// Number 1, try registry.
83-
result := FindGeneralsExe( 'InstallPath' );
83+
result := FindGeneralsExe();
8484

8585
// installdir might point to Generals.exe!
8686
// If file, FileExists returns true.
@@ -117,7 +117,7 @@ function TSettings.GetInstallDir: string;
117117

118118
procedure TSettings.SetGameDir(AValue: string);
119119
begin
120-
conf.SetValue( 'game_dir', Utf8Decode(AValue) );
120+
conf.SetValue( Utf8Decode('game_dir'), Utf8Decode(AValue) );
121121
end;
122122

123123
// get directories we need for the launcher.
@@ -128,7 +128,7 @@ procedure TSettings.GetDirs();
128128
installdir: string;
129129
begin
130130
//mydoc := GetMyDoc();
131-
//dataleaf := FindGeneralsExe( 'UserDataLeafName' );
131+
//dataleaf := FindGeneralsExe();
132132
//moddir := mydoc + dataleaf;
133133

134134
// Well, config load failed. Attempt to read reg or read user input...
@@ -157,43 +157,38 @@ function TSettings.GetGameDir(): string;
157157
function TryReadRegKey(
158158
reg: TRegistry;
159159
key: string;
160-
t: string
160+
subkey: string;
161+
exe_path: string
161162
): string;
162163
var
163164
tmp: string;
164165
begin
165-
Result := '';
166166
if reg.KeyExists(key) then
167167
begin
168168
reg.OpenKeyReadOnly(key);
169-
if reg.ValueExists(t) then
170-
tmp := reg.ReadString( t );
169+
if reg.ValueExists(subkey) then
170+
tmp := reg.ReadString(subkey);
171171
reg.CloseKey();
172172

173-
tmp := path_join(tmp, 'Generals.exe');
173+
tmp := path_join(tmp, exe_path);
174174
if FileExists(tmp) then
175175
Result := tmp;
176176
end;
177177
end;
178178

179-
function ResolveZH(
180-
reg: TRegistry;
181-
t: string
182-
): string;
179+
function ResolveZH(reg: TRegistry): string;
183180
var
184-
key: string;
185181
tmp: string;
186182
begin
187-
Result := TryReadRegKey(reg, 'SOFTWARE\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour', t);
183+
// Try the Ultimatate Collection launcher first, if exists.
184+
Result := TryReadRegKey(reg, 'SOFTWARE\EA Games\Command and Conquer Generals Zero Hour', 'Install Dir', 'Command and Conquer Generals Zero Hour\Generals.exe');
188185
if Result <> '' then Exit(Result);
189-
190-
Result := TryReadRegKey(reg, 'SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour', t);
186+
Result := TryReadRegKey(reg, 'SOFTWARE\WOW6432Node\EA Games\Command and Conquer Generals Zero Hour', 'Install Dir', 'Command and Conquer Generals Zero Hour\Generals.exe');
191187
if Result <> '' then Exit(Result);
192188

193-
Result := TryReadRegKey(reg, 'SOFTWARE\Electronic Arts\EA Games\Generals', t);
189+
Result := TryReadRegKey(reg, 'SOFTWARE\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour', 'InstallPath', 'Generals.exe');
194190
if Result <> '' then Exit(Result);
195-
196-
Result := TryReadRegKey(reg, 'SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals', t);
191+
Result := TryReadRegKey(reg, 'SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour', 'InstallPath', 'Generals.exe');
197192
if Result <> '' then Exit(Result);
198193

199194
// Try where mod4.exe is
@@ -204,16 +199,18 @@ function ResolveZH(
204199

205200
// read values from
206201
// SOFTWARE\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour
207-
function TSettings.FindGeneralsExe( t: string ): string;
202+
// SOFTWARE\WOW6432Node\EA Games\Command and Conquer Generals Zero Hour
203+
// ... etc.
204+
function TSettings.FindGeneralsExe(): string;
208205
var
209206
reg: TRegistry;
210207
begin
211208
reg := TRegistry.Create(KEY_READ);
212209
try
213210
reg.RootKey := HKEY_LOCAL_MACHINE;
214-
Result := ResolveZH(reg, t);
211+
Result := ResolveZH(reg);
215212
if Result = '' then
216-
Warning( '제로아워 레지스트리값 ' + t + ' 읽기 실패, Generals.exe를 직접 골라주세요.' );
213+
Warning( '레지스트리로 제로아워 찾기 실패, Generals.exe를 직접 골라주세요.' );
217214
finally
218215
reg.Free;
219216
end;

0 commit comments

Comments
 (0)