1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
18 interface
22 function g_Res_SearchSameWAD(const path, filename: AnsiString; const resMd5: TMD5Digest): AnsiString;
24 // download map wad from server (if necessary)
25 // download all required map resource wads too
26 // returns name of the map wad (relative to mapdir), or empty string on error
29 // call this before downloading a new map from a server
31 // returns original name, or replacement name
36 implementation
40 //const DOWNLOAD_DIR = 'downloads';
42 var
46 // call this before downloading a new map from a server
48 begin
54 // returns original name, or replacement name
56 var
58 begin
66 begin
73 function scanDir (dirName: AnsiString; baseName: AnsiString; const resMd5: TMD5Digest): AnsiString;
74 var
80 begin
87 // scan files
89 try
90 repeat
92 begin
94 begin
97 begin
101 begin
105 exit;
109 end
110 else
111 begin
113 begin
120 finally
124 // scan subdirs
126 begin
135 function g_Res_SearchResWad (asMap: Boolean; fname: AnsiString; const resMd5: TMD5Digest): AnsiString;
136 begin
138 //if not assigned(scannedDirs) then scannedDirs := THashStrInt.Create();
140 begin
142 end
143 else
144 begin
150 function g_Res_SearchSameWAD (const path, filename: AnsiString; const resMd5: TMD5Digest): AnsiString;
151 begin
157 var
165 begin
166 //SetLength(mapData.ExternalResources, 0);
172 try
177 //MC_SEND_MapRequest();
185 // find or download a map
188 begin
189 // download map
192 begin
195 exit;
197 try
199 except
202 try
204 except
207 exit;
210 try
212 except
216 exit;
220 begin
223 exit;
225 // if it was resumed, check md5 and initiate full download if necessary
227 begin
229 // sorry for pasta, i am asshole
231 begin
233 try
236 except
239 exit;
241 try
243 except
247 exit;
251 begin
254 exit;
261 // download resources
263 begin
268 begin
269 // already here
272 end
273 else
274 begin
275 try
277 except
281 try
283 except
286 exit;
288 try
290 except
294 exit;
298 begin
301 exit;
303 // if it was resumed, check md5 and initiate full download if necessary
305 begin
307 // sorry for pasta, i am asshole
309 begin
310 e_LogWritefln('resuming failed; downloading resource `%s` to `%s` from scratch...', [tf.diskName, fname]);
311 try
314 except
317 exit;
319 try
321 except
325 exit;
329 begin
332 exit;
339 finally