1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-31 20:52:18 +01:00

updating installer for OrangeBox compatibility

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40502
This commit is contained in:
Christian Hammacher 2007-10-10 21:48:44 +00:00
parent 23459ec6e3
commit 45d217d393
7 changed files with 106 additions and 48 deletions

View File

@ -31,8 +31,8 @@
-M -M
-$M16384,1048576 -$M16384,1048576
-K$00400000 -K$00400000
-LE"c:\programme\borland\delphi7\Projects\Bpl" -LE"c:\program files\borland\delphi7\Projects\Bpl"
-LN"c:\programme\borland\delphi7\Projects\Bpl" -LN"c:\program files\borland\delphi7\Projects\Bpl"
-w-UNSAFE_TYPE -w-UNSAFE_TYPE
-w-UNSAFE_CODE -w-UNSAFE_CODE
-w-UNSAFE_CAST -w-UNSAFE_CAST

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,11 +13,11 @@ procedure AddSkipped;
procedure AddNotFound; procedure AddNotFound;
procedure DownloadFile(eFile: String; eDestination: String); procedure DownloadFile(eFile: String; eDestination: String);
procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS); procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS; const Source: Boolean);
procedure InstallDedicated(eModPath: String; UseSteam: Boolean); procedure InstallDedicated(eModPath: String; const UseSteam, Source: Boolean);
procedure InstallListen(ePath: String); procedure InstallListen(ePath: String; const Source: Boolean);
procedure InstallCustom(ePath: String; eOS: TOS); procedure InstallCustom(ePath: String; eOS: TOS; const Source: Boolean);
procedure InstallFTP(OS: TOS); procedure InstallFTP(OS: TOS; const Source: Boolean);
var StartTime: TDateTime; var StartTime: TDateTime;
SteamPath: String; SteamPath: String;
@ -218,7 +218,7 @@ end;
{ Basic Installation } { Basic Installation }
procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS); procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS; const Source: Boolean);
var eStr: TStringList; var eStr: TStringList;
i: integer; i: integer;
CopyConfig: Boolean; CopyConfig: Boolean;
@ -253,7 +253,7 @@ begin
{ Unpack } { Unpack }
frmMain.ggeItem.Progress := 0; frmMain.ggeItem.Progress := 0;
AddStatus('Unpacking files...', clBlack); AddStatus('Unpacking files...', clBlack);
if not Unpack() then begin if not Unpack(Source) then begin
AddStatus('No files attached!', clRed); AddStatus('No files attached!', clRed);
Screen.Cursor := crDefault; Screen.Cursor := crDefault;
exit; exit;
@ -370,37 +370,37 @@ end;
{ Dedicated Server } { Dedicated Server }
procedure InstallDedicated(eModPath: String; UseSteam: Boolean); procedure InstallDedicated(eModPath: String; const UseSteam, Source: Boolean);
begin begin
StartTime := Now; StartTime := Now;
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation on dedicated server...', clBlack, False); AddStatus('Starting Metamod:Source installation on dedicated server...', clBlack, False);
BasicInstallation(eModPath, UseSteam, False, osWindows); BasicInstallation(eModPath, UseSteam, False, osWindows, Source);
end; end;
{ Listen Server } { Listen Server }
procedure InstallListen(ePath: String); procedure InstallListen(ePath: String; const Source: Boolean);
begin begin
StartTime := Now; StartTime := Now;
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation on the listen server...', clBlack); AddStatus('Starting Metamod:Source installation on the listen server...', clBlack);
BasicInstallation(ePath, True, True, osWindows); BasicInstallation(ePath, True, True, osWindows, Source);
end; end;
{ Custom mod } { Custom mod }
procedure InstallCustom(ePath: String; eOS: TOS); procedure InstallCustom(ePath: String; eOS: TOS; const Source: Boolean);
begin begin
StartTime := Now; StartTime := Now;
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation...', clBlack); AddStatus('Starting Metamod:Source installation...', clBlack);
BasicInstallation(ePath, False, False, eOS); BasicInstallation(ePath, False, False, eOS, Source);
end; end;
{ FTP } { FTP }
procedure InstallFTP(OS: TOS); procedure InstallFTP(OS: TOS; const Source: Boolean);
function DoReconnect: Boolean; function DoReconnect: Boolean;
begin begin
Result := False; Result := False;
@ -432,7 +432,7 @@ begin
{ Unpack } { Unpack }
frmMain.ggeItem.Progress := 0; frmMain.ggeItem.Progress := 0;
AddStatus('Unpacking files...', clBlack); AddStatus('Unpacking files...', clBlack);
if not Unpack() then begin if not Unpack(Source) then begin
AddStatus('No files attached!', clRed); AddStatus('No files attached!', clRed);
Screen.Cursor := crDefault; Screen.Cursor := crDefault;
exit; exit;

View File

@ -4,11 +4,11 @@ interface
uses SysUtils, Classes, Zlib; uses SysUtils, Classes, Zlib;
procedure CompressFiles(Files : TStrings; const Filename : String); procedure CompressFiles(Files: TStrings; const Filename: String);
function DecompressStream(Stream : TMemoryStream; DestDirectory : String): Boolean; function DecompressStream(Stream: TMemoryStream; DestDirectory: String; const Source: Boolean): Boolean;
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream; Version: String): Boolean; function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream; Version: String): Boolean;
function LoadFromFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean; function LoadFromFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
function Unpack: Boolean; function Unpack(const Source: Boolean): Boolean;
function GetVersion: String; function GetVersion: String;
implementation implementation
@ -68,7 +68,8 @@ begin
DeleteFile('tmp'); DeleteFile('tmp');
end; end;
end; end;
function DecompressStream(Stream : TMemoryStream; DestDirectory : String): Boolean;
function DecompressStream(Stream : TMemoryStream; DestDirectory : String; const Source: Boolean): Boolean;
var var
dest,s : String; dest,s : String;
decompr : TDecompressionStream; decompr : TDecompressionStream;
@ -82,13 +83,15 @@ begin
try try
{ number of files } { number of files }
Stream.Read(c,SizeOf(c)); Stream.Read(c,SizeOf(c));
for i := 1 to c do for i := 1 to c do begin
begin
{ read filename } { read filename }
Stream.Read(l,SizeOf(l)); Stream.Read(l,SizeOf(l));
SetLength(s,l); SetLength(s,l);
Stream.Read(s[1],l); Stream.Read(s[1],l);
{ read filesize } { check if this is the right file }
if ((Pos('.source', s) <> 0) and (Source)) or ((Pos('.orangebox', s) <> 0) and (not Source)) then begin
{ remove extension and read filesize }
s := ChangeFileExt(s, '');
Stream.Read(l,SizeOf(l)); Stream.Read(l,SizeOf(l));
{ decompress the files and store it } { decompress the files and store it }
s := dest+s; //include the path s := dest+s; //include the path
@ -101,6 +104,7 @@ begin
decompr.Free; decompr.Free;
end; end;
end; end;
end;
finally finally
Result := True; Result := True;
end; end;
@ -177,14 +181,14 @@ end;
{ Unpack function } { Unpack function }
function Unpack: Boolean; function Unpack(const Source: Boolean): Boolean;
var eStream: TMemoryStream; var eStream: TMemoryStream;
begin begin
eStream := TMemoryStream.Create; eStream := TMemoryStream.Create;
try try
// Get ZIP // Get ZIP
LoadFromFile(ParamStr(0), eStream); LoadFromFile(ParamStr(0), eStream);
DecompressStream(eStream, ExtractFilePath(ParamStr(0))); // Unpack files DecompressStream(eStream, ExtractFilePath(ParamStr(0)), Source); // Unpack files
Result := True; Result := True;
except except

View File

@ -159,6 +159,7 @@ var ePath: String;
CurNode: TTreeNode; CurNode: TTreeNode;
eOS: TOS; eOS: TOS;
i: integer; i: integer;
Source: Boolean;
begin begin
{ FTP } { FTP }
if jplWizard.ActivePage = jspFTP then begin if jplWizard.ActivePage = jspFTP then begin
@ -175,14 +176,27 @@ begin
end; end;
IdFTP.ChangeDir(ePath); IdFTP.ChangeDir(ePath);
IdFTP.List(eStr, '', False); IdFTP.List(eStr, '', False);
if eStr.IndexOf('gameinfo.txt') = -1 then begin eStr.CaseSensitive := False;
// check if gameinfo.txt is in the directory -> valid installation
if (eStr.IndexOf('gameinfo.txt') = -1) then begin
MessageBox(Handle, 'Invalid directory. Please select your mod directory and try again.', PChar(Application.Title), MB_ICONWARNING); MessageBox(Handle, 'Invalid directory. Please select your mod directory and try again.', PChar(Application.Title), MB_ICONWARNING);
eStr.Free; eStr.Free;
exit; exit;
end end
else else
eStr.Free; eStr.Free;
// check for orangebox directory
Source := True;
if (eStr.IndexOf('orangebox') <> -1) then begin
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrYes: Source := False;
mrNo: Source := True;
mrCancel: begin
eStr.Free;
exit;
end;
end;
end;
// design stuff // design stuff
trvDirectories.Enabled := False; trvDirectories.Enabled := False;
cmdConnect.Enabled := False; cmdConnect.Enabled := False;
@ -198,26 +212,38 @@ begin
jspInstallProgress.Show; jspInstallProgress.Show;
// installation // installation
Screen.Cursor := crAppStart; Screen.Cursor := crAppStart;
InstallFTP(eOS); InstallFTP(eOS, Source);
end end
else if jplWizard.ActivePage = jspInstallProgress then else if jplWizard.ActivePage = jspInstallProgress then
Close Close
else if jplWizard.ActivePage = jspSelectMod then begin else if jplWizard.ActivePage = jspSelectMod then begin
{ Dedicated Server } { Dedicated Server }
if (frbDedicatedServer.Checked) or (frbStandaloneServer.Checked) then begin if (frbDedicatedServer.Checked) or (frbStandaloneServer.Checked) then begin
Source := True;
ePath := trvMods.Selected.Text; ePath := trvMods.Selected.Text;
if ePath = 'Counter-Strike:Source' then if ePath = 'Counter-Strike:Source' then
ePath := 'cstrike' ePath := 'cstrike'
else if ePath = 'Day of Defeat:Source' then else if ePath = 'Day of Defeat:Source' then
ePath := 'dod' ePath := 'dod'
else else if ePath = 'Half-Life 2 Deathmatch' then
ePath := 'hl2mp'; ePath := 'hl2mp'
ePath := 'SteamApps\' + trvMods.Selected.Parent.Text + '\source dedicated server\' + ePath; else begin
{ get games }
if ePath = 'Team Fortress 2' then
ePath := 'orangebox/tf'; // TODO: !HP! check this path
{ ask user, just in case }
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrYes: Source := False;
mrNo: Source := True;
mrCancel: exit;
end;
end;
// install it // install it
if frbDedicatedServer.Checked then begin if frbDedicatedServer.Checked then begin
if DirectoryExists(SteamPath + ePath) then begin if DirectoryExists(SteamPath + ePath) then begin
jspInstallProgress.Show; jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True); InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True, Source);
end end
else begin else begin
MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist any more. Run Dedicated Server with the chosen mod and try again.', PChar(Application.Title), MB_ICONERROR); MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist any more. Run Dedicated Server with the chosen mod and try again.', PChar(Application.Title), MB_ICONERROR);
@ -228,7 +254,7 @@ begin
else begin else begin
if DirectoryExists(StandaloneServer + ePath) then begin if DirectoryExists(StandaloneServer + ePath) then begin
jspInstallProgress.Show; jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False) InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False, Source)
end end
else begin else begin
MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist (any more). Run Half-Life Dedicated Server with the chosen mod again and restart.', PChar(Application.Title), MB_ICONERROR); MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist (any more). Run Half-Life Dedicated Server with the chosen mod again and restart.', PChar(Application.Title), MB_ICONERROR);
@ -239,13 +265,25 @@ begin
end; end;
{ Listen Server } { Listen Server }
if frbListenServer.Checked then begin if frbListenServer.Checked then begin
Source := True;
ePath := trvMods.Selected.Text; ePath := trvMods.Selected.Text;
if ePath = 'Counter-Strike:Source' then if ePath = 'Counter-Strike:Source' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\counter-strike source\cstrike' ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\counter-strike source\cstrike'
else if ePath = 'Half-Life 2 Deathmatch' then else if ePath = 'Half-Life 2 Deathmatch' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\half-life 2 deathmatch\hl2mp' ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\half-life 2 deathmatch\hl2mp'
else else if ePath = 'Day of Defeat:Source' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\day of defeat source\dod'; ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\day of defeat source\dod'
else begin
{ get games }
if ePath = 'Team Fortress 2' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\team fortress 2\tf';
{ ask user, just in case }
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrYes: Source := False;
mrNo: Source := True;
mrCancel: exit;
end;
end;
if Pos(SteamPath, ePath) = 0 then if Pos(SteamPath, ePath) = 0 then
MessageBox(Handle, 'An error occured. Please report this bug to the Metamod:Source team and post a new thread on the forums of www.amxmodx.org.', PChar(Application.Title), MB_ICONSTOP) MessageBox(Handle, 'An error occured. Please report this bug to the Metamod:Source team and post a new thread on the forums of www.amxmodx.org.', PChar(Application.Title), MB_ICONSTOP)
@ -256,7 +294,7 @@ begin
end; end;
jspInstallProgress.Show; jspInstallProgress.Show;
InstallListen(IncludeTrailingPathDelimiter(ePath)); InstallListen(IncludeTrailingPathDelimiter(ePath), Source);
end; end;
end; end;
{ Custom mod below } { Custom mod below }
@ -287,6 +325,7 @@ begin
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source'); trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
if DirectoryExists(ePath + eStr[i] + '\source dedicated server\hl2mp') then if DirectoryExists(ePath + eStr[i] + '\source dedicated server\hl2mp') then
trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch'); trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch');
// TODO: !HP! add "Team Fortress 2" item here
if CurNode.Count = 0 then if CurNode.Count = 0 then
CurNode.Free CurNode.Free
@ -330,6 +369,8 @@ begin
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source'); trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
if DirectoryExists(ePath + eStr[i] + '\half-life 2 deathmatch') then if DirectoryExists(ePath + eStr[i] + '\half-life 2 deathmatch') then
trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch'); trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch');
if DirectoryExists(ePath + eStr[i] + '\team fortress 2') then
trvMods.Items.AddChild(CurNode, 'Team Fortress 2');
if CurNode.Count = 0 then if CurNode.Count = 0 then
CurNode.Free CurNode.Free
@ -362,6 +403,8 @@ begin
trvMods.Items.Add(nil, 'Day of Defeat:Source'); trvMods.Items.Add(nil, 'Day of Defeat:Source');
if DirectoryExists(StandaloneServer + 'hl2mp') then if DirectoryExists(StandaloneServer + 'hl2mp') then
trvMods.Items.Add(nil, 'Half-Life 2 Deatmatch'); trvMods.Items.Add(nil, 'Half-Life 2 Deatmatch');
if DirectoryExists(StandaloneServer + 'orangebox\tf') then
trvMods.Items.Add(nil, 'Team Fortress 2');
jspSelectMod.Show; jspSelectMod.Show;
cmdNext.Enabled := False; cmdNext.Enabled := False;
end end
@ -374,8 +417,19 @@ begin
else if frbSelectMod.Checked then begin else if frbSelectMod.Checked then begin
{ Custom mod } { Custom mod }
if frmSelectModPath.ShowModal = mrOk then begin if frmSelectModPath.ShowModal = mrOk then begin
ePath := IncludeTrailingPathDelimiter(frmSelectModPath.trvDirectory.SelectedFolder.PathName);
{ check if this is an orangebox game }
Source := True;
if (Pos('orangebox', LowerCase(ePath)) <> 0) then begin
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrYes: Source := False;
mrNo: Source := True;
mrCancel: exit;
end;
end;
{ install now }
jspInstallProgress.Show; jspInstallProgress.Show;
InstallCustom(IncludeTrailingPathDelimiter(frmSelectModPath.trvDirectory.SelectedFolder.PathName), osWindows); InstallCustom(ePath, osWindows, Source);
end; end;
end end
else if frbFTP.Checked then // FTP else if frbFTP.Checked then // FTP