1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-26 19:54:14 +01:00

now creates VDF plugin, removed most of the gameinfo.txt stuff, removed hl2launch as it's no longer needed

--HG--
branch : sourcemm-1.4.3
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.3%40601
This commit is contained in:
Christian Hammacher 2007-12-24 01:29:25 +00:00
parent 8c15b8d5da
commit cf6b8f8378
13 changed files with 275 additions and 408 deletions

View File

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

View File

@ -14,24 +14,31 @@ begin
WriteLn('');
WriteLn('// Looking up files...');
{ Check files }
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\hl2launch.exe') then
WriteLn('// Found files\hl2launch.exe')
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server.dll.source') then
WriteLn('// Found files\server.dll.source')
else begin
WriteLn('// Error: Couldn''t find files\hl2launch.exe!');
WriteLn('// Error: Couldn''t find files\server.dll.source!');
ReadLn;
exit;
end;
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server.dll') then
WriteLn('// Found files\server.dll')
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so.source') then
WriteLn('// Found files\server_i486.so.source')
else begin
WriteLn('// Error: Couldn''t find files\server.dll!');
WriteLn('// Error: Couldn''t find files\server_i486.so.source!');
ReadLn;
exit;
end;
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so') then
WriteLn('// Found files\server_i486.so')
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server.dll.orangebox') then
WriteLn('// Found files\server.dll.orangebox')
else begin
WriteLn('// Error: Couldn''t find files\server_i486.so!');
WriteLn('// Error: Couldn''t find files\server.dll.orangebox!');
ReadLn;
exit;
end;
if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so.orangebox') then
WriteLn('// Found files\server_i486.so.orangebox')
else begin
WriteLn('// Error: Couldn''t find files\server_i486.so.orangebox!');
ReadLn;
exit;
end;
@ -53,9 +60,10 @@ begin
{ Compress files }
WriteLn('// Compressing files...');
eFiles := TStringList.Create;
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\hl2launch.exe');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server.dll');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server.dll.source');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so.source');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server.dll.orangebox');
eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so.orangebox');
eStream := TMemoryStream.Create;
CompressFiles(eFiles, ExtractFilePath(ParamStr(0)) + 'temp.zip');
eStream.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
@ -63,6 +71,7 @@ begin
AttachToFile(ExtractFilePath(ParamStr(0)) + 'MMS_Installer.exe', eStream, Version);
DeleteFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
eStream.Free;
eFiles.Free;
WriteLn('// Done.');
ReadLn;
end.

Binary file not shown.

View File

@ -1,38 +0,0 @@
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"c:\programme\borland\delphi7\Projects\Bpl"
-LN"c:\programme\borland\delphi7\Projects\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST

View File

@ -1,189 +0,0 @@
program HL2Launch;
{$APPTYPE CONSOLE}
uses
SysUtils,
ShellApi,
Windows,
Classes;
procedure LaunchFile(eFile, eStartDir, eParams: String);
var eStartInfo: TStartupInfo;
eProcInfo: TProcessInformation;
begin
FillChar(eStartInfo, SizeOf(TStartupInfo), 0);
with eStartInfo do begin
cb := SizeOf(eStartInfo);
dwFlags := STARTF_USESHOWWINDOW;
end;
if (CreateProcess(nil, PChar(eFile + #32 + eParams), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, PChar(eStartDir), eStartInfo, eProcInfo)) then begin
try
WaitForSingleObject(eProcInfo.hProcess, INFINITE);
finally
CloseHandle(eProcInfo.hProcess);
CloseHandle(eProcInfo.hThread);
end;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
Write(' Done.' + #13#10);
end
else begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
Write(' Couldn''t start hl2.exe!' + #13#10);
end;
end;
function GetFileSize(eFile: String): Int64;
var eFindHandle: THandle;
eFindData: TWIN32FINDDATA;
begin
Result := 0;
if not FileExists(eFile) then exit;
eFindHandle := FindFirstFile(PChar(eFile), eFindData);
if eFindHandle = INVALID_HANDLE_VALUE then exit;
Result := (eFindData.nFileSizeHigh * (Int64(MAXDWORD) + 1)) + eFindData.nFileSizeLow;
FindClose(eFindHandle);
end;
var eStream: TFileStream;
ePath, eParams: String;
eModDir: String;
eSearchRec: TSearchRec;
eStr: TStringList;
i: integer;
CheckSuccessful: Boolean;
StartTime: Cardinal;
begin
ePath := ExtractFilePath(ParamStr(0));
for i := 1 to ParamCount do
eParams := eParams + #32 + ParamStr(i);
Delete(eParams, 1, 1);
if Pos('console', LowerCase(eParams)) = 0 then
eParams := eParams + ' -console';
eStream := nil;
eModDir := '';
SetConsoleTitle('HL2 Launcher');
Sleep(200); // wait a few ms until the launch program is closed
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
WriteLn(' _ _ _ ____ _ _ ');
WriteLn('| | | | | |___ \ | | __ _ _ _ _ __ ___| |__ ___ _ __ ');
WriteLn('| |_| | | __) | | | / _` | | | | ''_ \ / __| ''_ \ / _ \ ''__|');
WriteLn('| _ | |___ / __/ | |__| (_| | |_| | | | | (__| | | | __/ | ');
WriteLn('|_| |_|_____|_____| |_____\__,_|\__,_|_| |_|\___|_| |_|\___|_| ');
WriteLn(' for listen servers using Metamod:Source');
WriteLn('');
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
{ Check files }
WriteLn('Checking files...');
if not FileExists(ePath + 'hl2.exe') then begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
WriteLn('Error: hl2.exe is missing! Maybe wrong directory? If not, start your HL2 Mod again via Steam and try again.');
ReadLn;
exit;
end;
if not FileExists(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath))) + 'steam.exe') then begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
WriteLn('Error: Cannot find steam.exe! Make sure this application is located in your listen server''s directory.');
ReadLn;
exit;
end;
{ Verify GameInfo.txt ... }
Write('Verifying GameInfo.txt...');
if (FindFirst(ePath + '*.*', faDirectory, eSearchRec) = 0) then begin
repeat
if (FileExists(ePath + eSearchRec.Name + '\GameInfo.txt')) then begin
eModDir := eSearchRec.Name;
break;
end;
until (FindNext(eSearchRec) <> 0);
end;
FindClose(eSearchRec.FindHandle);
if eModDir = '' then begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
WriteLn('');
WriteLn('Error: Couldn''t find GameInfo.txt!');
ReadLn;
exit;
end
else begin
if Pos('game', LowerCase(eParams)) = 0 then // a small test which isn't worth a notice
eParams := '-game ' + eSearchRec.Name + #32 + eParams;
eStr := TStringList.Create;
eStr.LoadFromFile(ePath + eModDir + '\GameInfo.txt');
if Pos('|gameinfo_path|addons/metamod/bin', LowerCase(eStr.Text)) = 0 then begin
CheckSuccessful := False;
for i := 0 to eStr.Count -1 do begin
if Pos('searchpaths', LowerCase(Trim(eStr[i]))) = 1 then begin
if i+3 >= eStr.Count then
break;
eStr.Insert(i+2, ' GameBin |gameinfo_path|addons/metamod/bin');
CheckSuccessful := True;
break;
end;
end;
if CheckSuccessful then begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
SetFileAttributes(PChar(ePath + eModDir + '\GameInfo.txt'), 0);
eStr.SaveToFile(ePath + eModDir + '\GameInfo.txt');
SetFileAttributes(PChar(ePath + eModDir + '\GameInfo.txt'), faReadOnly);
Write(' Registered MM:S sucessfully' + #13#10);
end
else begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
Write(' Unexpected EOF, your GameInfo.txt seems to be corrupt' + #13#10);
end;
end
else begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
Write(' Done' + #13#10);
end;
eStr.Free;
end;
{ ... and set it to write-protected }
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
Write('Setting GameInfo.txt to write-protected...');
try
eStream := TFileStream.Create(ePath + eModDir + '\GameInfo.txt', fmShareDenyWrite);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
Write(' Done.' + #13#10);
except
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
WriteLn('');
WriteLn('Warning: Couldn''t set GameInfo.txt to write-protected!');
eStream := nil;
end;
{ Launch Steam if not opened }
ShellExecute(0, 'open', PChar(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath))) + 'steam.exe'), nil, PChar(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath)))), SW_SHOW);
{ Launch game }
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
Write('Starting HL2...');
StartTime := GetTickCount;
LaunchFile(ePath + 'hl2.exe', Copy(ePath, 1, Pos('Steam', ePath)+5), eParams);
if (GetTickCount - StartTime < 10000) then begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
WriteLn('Important: If you experience any problems starting HL2 using this program, please start it once via Steam and try again.');
ReadLn;
end;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
{ Free GameInfo.txt }
Write('Removing read-only again from GameInfo.txt...');
if Assigned(eStream) then begin
eStream.Free;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
Write(' Done' + #13#10);
end
else begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
Write(' Skipped' + #13#10);
end;
{ End message }
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
WriteLn('');
WriteLn('Thanks for using Metamod:Source! Visit http://www.sourcemm.net/');
Sleep(2500);
end.

Binary file not shown.

View File

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

Binary file not shown.

View File

@ -10,6 +10,8 @@ function GetAllFiles(Mask: String; Attr: Integer; Recursive: Boolean; ShowDirs:
// ftp
function GetAllDirs: TStringList;
function GetModName(const Path: String): String;
implementation
uses UnitfrmMain;
@ -121,6 +123,20 @@ begin
Result := eList;
end; }
function GetModName(const Path: String): String;
var i: integer;
begin
Result := '';
for i := Length(Path) -1 downto 1 do begin
if (Path[i] = '\') or (Path[i] = '/') then begin
Result := Copy(Path, i +1, Length(Path) -i);
break;
end;
end;
if (Copy(Result, Length(Result), 1) = '\') or (Copy(Result, Length(Result), 1) = '/') then
Result := Copy(Result, 1, Length(Result) -1);
end;
end.

View File

@ -13,11 +13,11 @@ procedure AddSkipped;
procedure AddNotFound;
procedure DownloadFile(eFile: String; eDestination: String);
procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS);
procedure InstallDedicated(eModPath: String; UseSteam: Boolean);
procedure InstallListen(ePath: String);
procedure InstallCustom(ePath: String; eOS: TOS);
procedure InstallFTP(OS: TOS);
procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS; const Source: Boolean);
procedure InstallDedicated(eModPath: String; const UseSteam, Source: Boolean);
procedure InstallListen(ePath: String; const Source: Boolean);
procedure InstallCustom(ePath: String; eOS: TOS; const Source: Boolean);
procedure InstallFTP(OS: TOS; const Source: Boolean; const ModDir: String);
var StartTime: TDateTime;
SteamPath: String;
@ -32,7 +32,7 @@ uses UnitfrmMain, UnitfrmProxy, UnitFunctions, UnitPackSystem;
function InstallTime: String;
begin
Result := FormatDateTime('HH:MM:SS', Now - StartTime);
Result := Copy(FormatDateTime('HH:MM:SS', Now - StartTime), 4, 5);
end;
procedure AddStatus(Text: String; Color: TColor; ShowTime: Boolean = True);
@ -218,18 +218,16 @@ end;
{ 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;
i: integer;
CopyConfig: Boolean;
eFound: Boolean;
begin
frmMain.ggeAll.MaxValue := 8;
frmMain.ggeAll.Progress := 0;
frmMain.ggeItem.MaxValue := 1;
frmMain.ggeItem.Progress := 0;
if (GetProcessID('Steam.exe') <> -1) and (SteamInstall) then begin
{if (GetProcessID('Steam.exe') <> -1) and (SteamInstall) then begin
if MessageBox(frmMain.Handle, 'Steam is still running. It is necersarry to shut it down before you install Metamod:Source. Shut it down now?', PChar(frmMain.Caption), MB_ICONQUESTION + MB_YESNO) = mrYes then begin
AddStatus('Shutting down Steam...', clBlack, False);
if GetProcessID('Steam.exe') = -1 then
@ -247,13 +245,13 @@ begin
Application.Terminate;
exit;
end;
end;
end;}
frmMain.ggeAll.Progress := 1;
frmMain.ggeItem.Progress := 1;
{ Unpack }
frmMain.ggeItem.Progress := 0;
AddStatus('Unpacking files...', clBlack);
if not Unpack() then begin
if not Unpack(Source) then begin
AddStatus('No files attached!', clRed);
Screen.Cursor := crDefault;
exit;
@ -282,7 +280,7 @@ begin
frmMain.ggeItem.Progress := 1;
frmMain.ggeAll.Progress := 3;
{ gameinfo.txt }
{ gameinfo.txt for check / create VDF file }
if not FileExists(ePath + 'gameinfo.txt') then begin
if MessageBox(frmMain.Handle, 'The file "gameinfo.txt" couldn''t be found. Continue installation?', PChar(frmMain.Caption), MB_ICONQUESTION + MB_YESNO) = mrNo then begin
AddStatus('Installation canceled by user!', clRed, False);
@ -304,33 +302,32 @@ begin
AddSkipped;
frmMain.ggeItem.Progress := 1;
frmMain.ggeAll.Progress := 4;
{ Gameinfo.txt }
{ CDF Plugin }
frmMain.ggeItem.Progress := 0;
eFound := False;
AddStatus('Editing gameinfo.txt...', clBlack);
eStr.LoadFromFile(ePath + 'gameinfo.txt');
for i := 0 to eStr.Count -1 do begin
if Trim(LowerCase(eStr[i])) = 'gamebin |gameinfo_path|addons/metamod/bin' then begin
eFound := True;
break;
AddStatus('Creating VDF Plugin...', clBlack);
if (FileExists(ePath + 'addons\metamod.vdf')) then begin
eStr.LoadFromFile(ePath + 'addons\metamod.vdf');
if (Pos('server.dll', eStr.Text) <> 0) then
AddSkipped
else begin
eStr.Add('');
eStr.Add('"Plugin"');
eStr.Add('{');
eStr.Add(' "file" "..\' + GetModName(ePath) + '\addons\metamod\bin\server.dll"');
eStr.Add('}');
eStr.SaveToFile(ePath + 'addons\metamod.vdf');
AddDone;
end;
end;
if not eFound then begin
for i := 0 to eStr.Count -1 do begin
if Trim(eStr[i]) = 'SearchPaths' then begin
eStr.Insert(i +2, ' GameBin |gameinfo_path|addons/metamod/bin');
AddDone;
break;
end;
end;
SetFileAttributes(PChar(ePath + 'gameinfo.txt'), 0);
eStr.SaveToFile(ePath + 'gameinfo.txt');
SetFileAttributes(PChar(ePath + 'gameinfo.txt'), faReadOnly); // important for listen servers
AddDone;
end
else
AddSkipped;
else begin
eStr.Add('');
eStr.Add('"Plugin"');
eStr.Add('{');
eStr.Add(' "file" "..\' + GetModName(ePath) + '\addons\metamod\bin\server.dll"');
eStr.Add('}');
eStr.SaveToFile(ePath + 'addons\metamod.vdf');
AddDone;
end;
eStr.Free;
frmMain.ggeItem.Progress := 1;
frmMain.ggeAll.Progress := 5;
@ -342,16 +339,9 @@ begin
AddDone;
frmMain.ggeItem.Progress := 1;
frmMain.ggeAll.Progress := 6;
if ListenInstall then begin
ePath := ExtractFilePath(Copy(ePath, 1, Length(ePath)-1));
AddStatus('Copying hl2launch.exe...', clBlack);
CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'hl2launch.exe'), PChar(ePath + 'hl2launch.exe'), False);
AddDone;
end;
{ Remove files }
frmMain.ggeItem.Progress := 0;
AddStatus('Removing temporary files...', clBlack);
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'hl2launch.exe'));
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server.dll'));
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server_i486.so'));
AddDone;
@ -363,44 +353,41 @@ begin
frmMain.cmdNext.Enabled := True;
frmMain.cmdCancel.Hide;
Screen.Cursor := crDefault;
if ListenInstall then
MessageBox(frmMain.Handle, PChar('hl2launch.exe has been copied to ' + ePath + '. You can use it if you want to start your Source game with Metamod:Source enabled.'), PChar(Application.Title), MB_ICONINFORMATION);
end;
{ Dedicated Server }
procedure InstallDedicated(eModPath: String; UseSteam: Boolean);
procedure InstallDedicated(eModPath: String; const UseSteam, Source: Boolean);
begin
StartTime := Now;
Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation on dedicated server...', clBlack, False);
BasicInstallation(eModPath, UseSteam, False, osWindows);
BasicInstallation(eModPath, UseSteam, False, osWindows, Source);
end;
{ Listen Server }
procedure InstallListen(ePath: String);
procedure InstallListen(ePath: String; const Source: Boolean);
begin
StartTime := Now;
Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation on the listen server...', clBlack);
BasicInstallation(ePath, True, True, osWindows);
BasicInstallation(ePath, True, True, osWindows, Source);
end;
{ Custom mod }
procedure InstallCustom(ePath: String; eOS: TOS);
procedure InstallCustom(ePath: String; eOS: TOS; const Source: Boolean);
begin
StartTime := Now;
Screen.Cursor := crHourGlass;
AddStatus('Starting Metamod:Source installation...', clBlack);
BasicInstallation(ePath, False, False, eOS);
BasicInstallation(ePath, False, False, eOS, Source);
end;
{ FTP }
procedure InstallFTP(OS: TOS);
procedure InstallFTP(OS: TOS; const Source: Boolean; const ModDir: String);
function DoReconnect: Boolean;
begin
Result := False;
@ -414,8 +401,10 @@ begin
end;
end;
label CreateAgain;
label UploadAgain;
var eStr: TStringList;
i: integer;
CopyConfig, eFound: Boolean;
@ -426,70 +415,24 @@ begin
frmMain.ggeAll.MaxValue := 6;
frmMain.ggeAll.Progress := 0;
frmMain.ggeItem.MaxValue := 1;
frmMain.ggeItem.MaxValue := 3;
frmMain.ggeItem.Progress := 0;
{ Unpack }
frmMain.ggeItem.Progress := 0;
AddStatus('Unpacking files...', clBlack);
if not Unpack() then begin
if not Unpack(Source) then begin
AddStatus('No files attached!', clRed);
Screen.Cursor := crDefault;
exit;
end;
AddDone;
frmMain.ggeAll.Progress := 2;
frmMain.ggeAll.Progress := 1;
frmMain.ggeItem.Progress := 1;
{ Check for installation }
AddStatus('Editing gameinfo.txt...', clBlack);
eStr := TStringList.Create;
DownloadFile('gameinfo.txt', ExtractFilePath(ParamStr(0)) + 'gameinfo.txt');
eStr.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'gameinfo.txt');
CopyConfig := True;
eFound := False;
for i := 0 to eStr.Count -1 do begin
if Trim(LowerCase(eStr[i])) = 'gamebin |gameinfo_path|addons/metamod/bin' then begin
eFound := True;
case MessageBox(frmMain.Handle, 'A Metamod:Source installation was already detected. If you choose to reinstall, your configuration files will be erased. Click Yes to continue, No to Upgrade, or Cancel to abort the install.', PChar(frmMain.Caption), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrNo: CopyConfig := False;
mrCancel: begin
Application.Terminate;
eStr.Free;
exit;
end;
end;
break;
end;
end;
if not eFound then begin
for i := 0 to eStr.Count -1 do begin
if Trim(eStr[i]) = 'SearchPaths' then begin
eStr.Insert(i +2, ' GameBin |gameinfo_path|addons/metamod/bin');
AddDone;
break;
end;
end;
eStr.SaveToFile(ExtractFilePath(ParamStr(0)) + 'gameinfo.txt');
UploadFile(ExtractFilePath(ParamStr(0)) + 'gameinfo.txt', 'gameinfo.txt');
try
AddStatus('Trying to set gameinfo.txt to read-only...', clBlack);
frmMain.IdFTP.Site('CHMOD 744 gameinfo.txt');
AddDone;
except
AddStatus('Warning: CHMOD not supported.', clMaroon);
end;
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'gameinfo.txt'));
end
else
AddSkipped;
frmMain.ggeAll.Progress := 3;
frmMain.ggeItem.Progress := 1;
Sleep(250);
{ Create directories }
frmMain.ggeAll.Progress := 2;
frmMain.ggeItem.Progress := 0;
frmMain.ggeItem.MaxValue := 3;
AddStatus('Creating directories...', clBlack);
if not eFound then begin
FTPMakeDir('addons');
@ -504,8 +447,50 @@ begin
end
else
AddSkipped;
frmMain.ggeAll.Progress := 4;
frmMain.ggeItem.Progress := 3;
{ Create/Edit VDF Plugin }
CopyConfig := True;
eFound := False;
frmMain.ggeAll.Progress := 3;
frmMain.ggeItem.Progress := 0;
AddStatus('Creating VDF Plugin...', clBlack);
eStr := TStringList.Create;
try
frmMain.IdFTP.ChangeDir('addons');
frmMain.ggeItem.Progress := 1;
DownloadFile('metamod.vdf', ExtractFilePath(ParamStr(0)) + 'metamod.vdf');
eStr.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'metamod.vdf');
frmMain.ggeItem.Progress := 2;
if (((Pos('server.dll', eStr.Text) <> 0) and (OS = osWindows)) or ((Pos('server_i486.so', eStr.Text) <> 0) and (OS = osLinux))) then begin
AddSkipped;
eFound := True;
case MessageBox(frmMain.Handle, 'A Metamod:Source installation was already detected. If you choose to reinstall, your configuration files will be erased. Click Yes to continue, No to Upgrade, or Cancel to abort the install.', PChar(frmMain.Caption), MB_ICONQUESTION + MB_YESNOCANCEL) of
mrNo: CopyConfig := False;
mrCancel: begin
Application.Terminate;
eStr.Free;
exit;
end;
end;
end
else
raise Exception.Create('Create config now!');
except
frmMain.ggeItem.Progress := 2;
eStr.Add('"Plugin"');
eStr.Add('{');
if (OS = osWindows) then
eStr.Add(' "file" "..\' + ModDir + '\addons\metamod\bin\server.dll"')
else
eStr.Add(' "file" "../' + ModDir + '/addons/metamod/bin/server_i486.so"');
eStr.Add('}');
eStr.SaveToFile(ExtractFilePath(ParamStr(0)) + 'metamod.vdf');
UploadFile(ExtractFilePath(ParamStr(0)) + 'metamod.vdf', 'metamod.vdf');
frmMain.ggeItem.Progress := 3;
AddDone;
end;
{ Upload metaplugins.ini }
frmMain.ggeAll.Progress := 4;
frmMain.ggeItem.MaxValue := 1;
@ -537,7 +522,6 @@ begin
end;
{ Remove created files }
AddStatus('Removing temporary files...', clBlack);
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'hl2launch.exe'));
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server.dll'));
DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server_i486.so'));
AddDone;

View File

@ -4,11 +4,11 @@ interface
uses SysUtils, Classes, Zlib;
procedure CompressFiles(Files : TStrings; const Filename : String);
function DecompressStream(Stream : TMemoryStream; DestDirectory : String): Boolean;
procedure CompressFiles(Files: TStrings; const Filename: String);
function DecompressStream(Stream: TMemoryStream; DestDirectory: String; const Source: Boolean): Boolean;
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream; Version: String): Boolean;
function LoadFromFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
function Unpack: Boolean;
function Unpack(const Source: Boolean): Boolean;
function GetVersion: String;
implementation
@ -54,6 +54,8 @@ begin
{ append the compressed file to the destination file }
tmpFile := TFileStream.Create('tmp',fmOpenRead);
try
l := tmpFile.Size;
outfile.WriteBuffer(l, SizeOf(l));
outfile.CopyFrom(tmpFile,0);
finally
tmpFile.Free;
@ -68,12 +70,13 @@ begin
DeleteFile('tmp');
end;
end;
function DecompressStream(Stream : TMemoryStream; DestDirectory : String): Boolean;
function DecompressStream(Stream : TMemoryStream; DestDirectory : String; const Source: Boolean): Boolean;
var
dest,s : String;
decompr : TDecompressionStream;
outfile : TFilestream;
i,l,c : Integer;
i,l,lr,c : Integer;
begin
// IncludeTrailingPathDelimiter (D6/D7 only)
dest := IncludeTrailingPathDelimiter(DestDirectory);
@ -82,24 +85,30 @@ begin
try
{ number of files }
Stream.Read(c,SizeOf(c));
for i := 1 to c do
begin
for i := 1 to c do begin
{ read filename }
Stream.Read(l,SizeOf(l));
SetLength(s,l);
Stream.Read(s[1],l);
{ read filesize }
Stream.Read(l,SizeOf(l));
{ decompress the files and store it }
s := dest+s; //include the path
outfile := TFileStream.Create(s,fmCreate);
decompr := TDecompressionStream.Create(Stream);
try
outfile.CopyFrom(decompr,l);
finally
outfile.Free;
decompr.Free;
end;
Stream.Read(lr,SizeOf(lr));
{ 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, '');
{ decompress the files and store it }
s := dest+s; //include the path
outfile := TFileStream.Create(s,fmCreate);
decompr := TDecompressionStream.Create(Stream);
try
outfile.CopyFrom(decompr,l);
finally
outfile.Free;
decompr.Free;
end;
end
else
Stream.Position := Stream.Position + lr;
end;
finally
Result := True;
@ -114,6 +123,7 @@ begin
Result := False;
if not FileExists(AFileName) then
Exit;
try
aStream := TFileStream.Create(AFileName, fmOpenWrite or fmShareDenyWrite);
MemoryStream.Seek(0, soFromBeginning);
@ -177,14 +187,14 @@ end;
{ Unpack function }
function Unpack: Boolean;
function Unpack(const Source: Boolean): Boolean;
var eStream: TMemoryStream;
begin
eStream := TMemoryStream.Create;
try
// Get ZIP
LoadFromFile(ParamStr(0), eStream);
DecompressStream(eStream, ExtractFilePath(ParamStr(0))); // Unpack files
DecompressStream(eStream, ExtractFilePath(ParamStr(0)), Source); // Unpack files
Result := True;
except

View File

@ -159,6 +159,7 @@ var ePath: String;
CurNode: TTreeNode;
eOS: TOS;
i: integer;
Source: Boolean;
begin
{ FTP }
if jplWizard.ActivePage = jspFTP then begin
@ -175,14 +176,27 @@ begin
end;
IdFTP.ChangeDir(ePath);
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);
eStr.Free;
exit;
end
else
eStr.Free;
// check for orangebox directory
Source := True;
if (AnsiSameText(trvDirectories.Selected.Text, 'tf')) 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
trvDirectories.Enabled := False;
cmdConnect.Enabled := False;
@ -198,54 +212,97 @@ begin
jspInstallProgress.Show;
// installation
Screen.Cursor := crAppStart;
InstallFTP(eOS);
InstallFTP(eOS, Source, trvDirectories.Selected.Text);
end
else if jplWizard.ActivePage = jspInstallProgress then
Close
else if jplWizard.ActivePage = jspSelectMod then begin
{ Dedicated Server }
if (frbDedicatedServer.Checked) or (frbStandaloneServer.Checked) then begin
if frbDedicatedServer.Checked then begin
Source := True;
ePath := trvMods.Selected.Text;
if ePath = 'Counter-Strike:Source' then
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\cstrike'
else if ePath = 'Day of Defeat:Source' then
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\dod'
else if ePath = 'Half-Life 2 Deathmatch' then
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\hl2mp'
else begin
{ get games }
if ePath = 'Team Fortress 2' then
ePath := trvMods.Selected.Parent.Text + '\source 2007 dedicated server\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;
SteamPath := IncludeTrailingPathDelimiter(SteamPath) + 'steamapps\';
// install it
if DirectoryExists(SteamPath + ePath) then begin
jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True, Source);
end
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);
jspSelectMod.Show;
exit;
end;
end;
{ Standalone Server }
if frbStandaloneServer.Checked then begin
Source := True;
ePath := trvMods.Selected.Text;
if ePath = 'Counter-Strike:Source' then
ePath := 'cstrike'
else if ePath = 'Day of Defeat:Source' then
ePath := 'dod'
else
ePath := 'hl2mp';
ePath := 'SteamApps\' + trvMods.Selected.Parent.Text + '\source dedicated server\' + ePath;
// install it
if frbDedicatedServer.Checked then begin
if DirectoryExists(SteamPath + ePath) then begin
jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True);
end
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);
jspSelectMod.Show;
exit;
else if ePath = 'Half-Life 2 Deathmatch' then
ePath := 'hl2mp'
else begin
{ get games }
if ePath = 'Team Fortress 2' then
ePath := 'orangebox\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;
// install it
if DirectoryExists(StandaloneServer + ePath) then begin
jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False, Source)
end
else begin
if DirectoryExists(StandaloneServer + ePath) then begin
jspInstallProgress.Show;
InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False)
end
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);
jspSelectMod.Show;
exit;
end;
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);
jspSelectMod.Show;
exit;
end;
end;
{ Listen Server }
if frbListenServer.Checked then begin
Source := True;
ePath := trvMods.Selected.Text;
if ePath = 'Counter-Strike:Source' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\counter-strike source\cstrike'
else if ePath = 'Half-Life 2 Deathmatch' then
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\half-life 2 deathmatch\hl2mp'
else
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\day of defeat source\dod';
else if ePath = 'Day of Defeat:Source' then
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
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 +313,7 @@ begin
end;
jspInstallProgress.Show;
InstallListen(IncludeTrailingPathDelimiter(ePath));
InstallListen(IncludeTrailingPathDelimiter(ePath), Source);
end;
end;
{ Custom mod below }
@ -287,6 +344,8 @@ begin
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
if DirectoryExists(ePath + eStr[i] + '\source dedicated server\hl2mp') then
trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch');
if DirectoryExists(ePath + eStr[i] + '\source 2007 dedicated server\tf') then
trvMods.Items.AddChild(CurNode, 'Team Fortress 2');
if CurNode.Count = 0 then
CurNode.Free
@ -330,6 +389,8 @@ begin
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
if DirectoryExists(ePath + eStr[i] + '\half-life 2 deathmatch') then
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
CurNode.Free
@ -362,6 +423,8 @@ begin
trvMods.Items.Add(nil, 'Day of Defeat:Source');
if DirectoryExists(StandaloneServer + 'hl2mp') then
trvMods.Items.Add(nil, 'Half-Life 2 Deatmatch');
if DirectoryExists(StandaloneServer + 'orangebox\tf') then
trvMods.Items.Add(nil, 'Team Fortress 2');
jspSelectMod.Show;
cmdNext.Enabled := False;
end
@ -374,8 +437,19 @@ begin
else if frbSelectMod.Checked then begin
{ Custom mod }
if frmSelectModPath.ShowModal = mrOk then begin
ePath := frmSelectModPath.trvDirectory.SelectedFolder.PathName;
{ check if this is an orangebox game }
Source := True;
if (AnsiSameText(ExtractFileName(ePath), 'tf')) 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;
InstallCustom(IncludeTrailingPathDelimiter(frmSelectModPath.trvDirectory.SelectedFolder.PathName), osWindows);
InstallCustom(IncludeTrailingPathDelimiter(ePath), osWindows, Source);
end;
end
else if frbFTP.Checked then // FTP

View File

@ -1,7 +1,8 @@
In this folder should be server.dll and server_i486.so.
Every MM:S library should be located in this directory.
How you prepare a release:
1) Copy the latest MM:S dlls and hl2launch.exe into this folder
2) Run Attach.exe
3) Test MMS_Installer.exe once (should work but nobody wants bug releases, especially not in the installer)
4) If everything worked fine, release it, otherwise pm me (Basic-Master)
How to prepare a release:
1) Copy the latest MM:S dlls into this folder
2) Append .source to the Source binaries and .orangebox to the OrangeBox binaries
3) Run Attach.exe
4) Test MMS_Installer.exe once (recommended)
5) Release it or e-Mail me if you find a bug