Changed license in sourcehook_hookmangen_x86.h (agreed to by BAILOPAN and faluco)
Updated MSVC7 proj file
11 procedure LaunchFile(eFile, eStartDir, eParams: String);
12 var eStartInfo: TStartupInfo;
13 eProcInfo: TProcessInformation;
15 FillChar(eStartInfo, SizeOf(TStartupInfo), 0);
16 with eStartInfo do begin
17 cb := SizeOf(eStartInfo);
18 dwFlags := STARTF_USESHOWWINDOW;
21 if (CreateProcess(nil, PChar(eFile + #32 + eParams), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, PChar(eStartDir), eStartInfo, eProcInfo)) then begin
23 WaitForSingleObject(eProcInfo.hProcess, INFINITE);
25 CloseHandle(eProcInfo.hProcess);
26 CloseHandle(eProcInfo.hThread);
28 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
29 Write(' Done.' + #13#10);
32 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
33 Write(' Couldn''t start hl2.exe!' + #13#10);
37 function GetFileSize(eFile: String): Int64;
38 var eFindHandle: THandle;
39 eFindData: TWIN32FINDDATA;
42 if not FileExists(eFile) then exit;
43 eFindHandle := FindFirstFile(PChar(eFile), eFindData);
44 if eFindHandle = INVALID_HANDLE_VALUE then exit;
45 Result := (eFindData.nFileSizeHigh * (Int64(MAXDWORD) + 1)) + eFindData.nFileSizeLow;
46 FindClose(eFindHandle);
49 var eStream: TFileStream;
50 ePath, eParams: String;
52 eSearchRec: TSearchRec;
55 CheckSuccessful: Boolean;
58 ePath := ExtractFilePath(ParamStr(0));
59 for i := 1 to ParamCount do
60 eParams := eParams + #32 + ParamStr(i);
61 Delete(eParams, 1, 1);
62 if Pos('console', LowerCase(eParams)) = 0 then
63 eParams := eParams + ' -console';
67 SetConsoleTitle('HL2 Launcher');
68 Sleep(200); // wait a few ms until the launch program is closed
70 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
71 WriteLn(' _ _ _ ____ _ _ ');
72 WriteLn('| | | | | |___ \ | | __ _ _ _ _ __ ___| |__ ___ _ __ ');
73 WriteLn('| |_| | | __) | | | / _` | | | | ''_ \ / __| ''_ \ / _ \ ''__|');
74 WriteLn('| _ | |___ / __/ | |__| (_| | |_| | | | | (__| | | | __/ | ');
75 WriteLn('|_| |_|_____|_____| |_____\__,_|\__,_|_| |_|\___|_| |_|\___|_| ');
76 WriteLn(' for listen servers using Metamod:Source');
78 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
80 WriteLn('Checking files...');
81 if not FileExists(ePath + 'hl2.exe') then begin
82 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
83 WriteLn('Error: hl2.exe is missing! Maybe wrong directory? If not, start your HL2 Mod again via Steam and try again.');
87 if not FileExists(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath))) + 'steam.exe') then begin
88 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
89 WriteLn('Error: Cannot find steam.exe! Make sure this application is located in your listen server''s directory.');
93 { Verify GameInfo.txt ... }
94 Write('Verifying GameInfo.txt...');
95 if (FindFirst(ePath + '*.*', faDirectory, eSearchRec) = 0) then begin
97 if (FileExists(ePath + eSearchRec.Name + '\GameInfo.txt')) then begin
98 eModDir := eSearchRec.Name;
101 until (FindNext(eSearchRec) <> 0);
103 FindClose(eSearchRec.FindHandle);
104 if eModDir = '' then begin
105 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
107 WriteLn('Error: Couldn''t find GameInfo.txt!');
112 if Pos('game', LowerCase(eParams)) = 0 then // a small test which isn't worth a notice
113 eParams := '-game ' + eSearchRec.Name + #32 + eParams;
115 eStr := TStringList.Create;
116 eStr.LoadFromFile(ePath + eModDir + '\GameInfo.txt');
117 if Pos('|gameinfo_path|addons/metamod/bin', LowerCase(eStr.Text)) = 0 then begin
118 CheckSuccessful := False;
119 for i := 0 to eStr.Count -1 do begin
120 if Pos('searchpaths', LowerCase(Trim(eStr[i]))) = 1 then begin
121 if i+3 >= eStr.Count then
123 eStr.Insert(i+2, ' GameBin |gameinfo_path|addons/metamod/bin');
124 CheckSuccessful := True;
129 if CheckSuccessful then begin
130 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
131 SetFileAttributes(PChar(ePath + eModDir + '\GameInfo.txt'), 0);
132 eStr.SaveToFile(ePath + eModDir + '\GameInfo.txt');
133 SetFileAttributes(PChar(ePath + eModDir + '\GameInfo.txt'), faReadOnly);
134 Write(' Registered MM:S sucessfully' + #13#10);
137 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
138 Write(' Unexpected EOF, your GameInfo.txt seems to be corrupt' + #13#10);
142 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
143 Write(' Done' + #13#10);
147 { ... and set it to write-protected }
148 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
149 Write('Setting GameInfo.txt to write-protected...');
151 eStream := TFileStream.Create(ePath + eModDir + '\GameInfo.txt', fmShareDenyWrite);
152 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
153 Write(' Done.' + #13#10);
155 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
157 WriteLn('Warning: Couldn''t set GameInfo.txt to write-protected!');
160 { Launch Steam if not opened }
161 ShellExecute(0, 'open', PChar(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath))) + 'steam.exe'), nil, PChar(Copy(ePath, 1, Pos('\steamapps\', LowerCase(ePath)))), SW_SHOW);
163 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
164 Write('Starting HL2...');
165 StartTime := GetTickCount;
166 LaunchFile(ePath + 'hl2.exe', Copy(ePath, 1, Pos('Steam', ePath)+5), eParams);
167 if (GetTickCount - StartTime < 10000) then begin
168 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
169 WriteLn('Important: If you experience any problems starting HL2 using this program, please start it once via Steam and try again.');
172 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
173 { Free GameInfo.txt }
174 Write('Removing read-only again from GameInfo.txt...');
175 if Assigned(eStream) then begin
177 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
178 Write(' Done' + #13#10);
181 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
182 Write(' Skipped' + #13#10);
185 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
187 WriteLn('Thanks for using Metamod:Source! Visit http://www.sourcemm.net/');