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
23 // download map wad from server (if necessary)
24 // download all required map resource wads too
25 // registers all required replacement wads
26 // returns name of the map wad (relative to mapdir), or empty string on error
29 // returns original name, or replacement name
33 implementation
37 var
38 // cvars
41 // other vars
45 //==========================================================================
46 //
47 // clearReplacementWads
48 //
49 // call this before downloading a new map from a server
50 //
51 //==========================================================================
53 begin
59 //==========================================================================
60 //
61 // addReplacementWad
62 //
63 // register new replacement wad
64 //
65 //==========================================================================
67 begin
74 //==========================================================================
75 //
76 // g_Res_FindReplacementWad
77 //
78 // returns original name, or replacement name
79 //
80 //==========================================================================
82 var
84 begin
91 //==========================================================================
92 //
93 // scanDir
94 //
95 // look for a wad to match the hash
96 // scans subdirs, ignores known wad extensions
97 //
98 // returns found wad disk name, or empty string
99 //
100 //==========================================================================
101 function scanDir (dirName: AnsiString; baseName: AnsiString; const resMd5: TMD5Digest): AnsiString;
102 var
108 begin
115 // scan files
117 try
118 repeat
120 begin
122 begin
125 begin
129 begin
133 exit;
137 end
138 else
139 begin
141 begin
148 finally
152 // scan subdirs
154 begin
163 //==========================================================================
164 //
165 // findExistingMapWadWithHash
166 //
167 // find map or resource wad using its base name and hash
168 //
169 // returns found wad disk name, or empty string
170 //
171 //==========================================================================
173 begin
178 //==========================================================================
179 //
180 // findExistingResWadWithHash
181 //
182 // find map or resource wad using its base name and hash
183 //
184 // returns found wad disk name, or empty string
185 //
186 //==========================================================================
188 begin
193 //==========================================================================
194 //
195 // g_Res_DownloadMapWAD
196 //
197 // download map wad from server (if necessary)
198 // download all required map resource wads too
199 // registers all required replacement wads
200 //
201 // returns name of the map wad (relative to mapdir), or empty string on error
202 //
203 //==========================================================================
205 var
213 begin
219 try
231 // find or download a map
234 begin
235 // download map
238 begin
241 exit;
243 try
245 except
248 try
250 except
253 exit;
256 try
258 except
262 exit;
266 begin
269 exit;
271 // if it was resumed, check md5 and initiate full download if necessary
273 begin
275 // sorry for pasta, i am asshole
277 begin
279 try
282 except
285 exit;
287 try
289 except
293 exit;
297 begin
300 exit;
307 // download resources
309 begin
314 begin
315 // already here
318 end
319 else
320 begin
321 try
323 except
327 try
329 except
332 exit;
334 try
336 except
340 exit;
344 begin
347 exit;
349 // if it was resumed, check md5 and initiate full download if necessary
351 begin
353 // sorry for pasta, i am asshole
355 begin
356 e_LogWritefln('resuming failed; downloading resource `%s` to `%s` from scratch...', [tf.diskName, fname]);
357 try
360 except
363 exit;
365 try
367 except
371 exit;
375 begin
378 exit;
385 finally
392 initialization
393 conRegVar('rdl_ignore_names', @g_res_ignore_names, 'list of resource wad names (without extensions) to ignore in dl hash checks', 'dl ignore wads');
394 conRegVar('rdl_ignore_enabled', @g_res_ignore_enabled, 'enable dl hash check ignore list', 'dl hash check ignore list active');