| 104 |
104 |
| 105 // |
105 // |
| 106 // ------------------------------------------------------------------------------------------------- |
106 // ------------------------------------------------------------------------------------------------- |
| 107 // |
107 // |
| 108 |
108 |
| 109 static QString findWAD (QString name) |
109 static QString findWad (QString name) |
| 110 { |
110 { |
| 111 QStringList wadpaths = Config::get ("wadpaths").toStringList(); |
111 QStringList wadpaths = Config::get ("wadpaths").toStringList(); |
| 112 |
|
| 113 if (wadpaths.empty()) |
|
| 114 { |
|
| 115 error (tr ("No WAD paths configured!")); |
|
| 116 |
|
| 117 // Cannot just return an empty string here since that'd trigger another error prompt - skip |
|
| 118 // ahead and exit. |
|
| 119 exit (1); |
|
| 120 } |
|
| 121 |
112 |
| 122 for (int i = 0; i < wadpaths.size(); ++i) |
113 for (int i = 0; i < wadpaths.size(); ++i) |
| 123 { |
114 { |
| 124 QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name); |
115 QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name); |
| 125 QFile f (fullpath); |
116 QFile f (fullpath); |
| 126 |
117 |
| 127 if (f.exists()) |
118 if (f.exists()) |
| 128 return fullpath; |
119 return fullpath; |
| 129 } |
120 } |
| |
121 |
| |
122 // WAD names are case-sensitive under non-Windows and they can appear in uppercase |
| |
123 // so we need to test that too. |
| |
124 if (name != name.toUpper()) |
| |
125 return findWad (name.toUpper()); |
| 130 |
126 |
| 131 return ""; |
127 return ""; |
| 132 } |
128 } |
| 133 |
129 |
| 134 // |
130 // |
| 316 assert (not version.name.isNull()); |
312 assert (not version.name.isNull()); |
| 317 } |
313 } |
| 318 |
314 |
| 319 QString iwadpath; |
315 QString iwadpath; |
| 320 QStringList pwadpaths; |
316 QStringList pwadpaths; |
| |
317 bool doneAssimilation = false; |
| 321 |
318 |
| 322 // Find the WADs |
319 // Find the WADs |
| 323 for (int i = 0; i < wads.size(); ++i) |
320 for (int i = 0; i < wads.size(); ++i) |
| 324 { |
321 { |
| 325 const QString& wad = wads[i]; |
322 const QString& wad = wads[i]; |
| 326 QString path = findWAD (wad); |
323 QString path = findWad (wad); |
| 327 |
324 |
| 328 // WAD names are case-sensitive under non-Windows and they can appear in uppercase |
325 if (path.isEmpty() and not doneAssimilation and Config::get ("autoassimilate").toBool()) |
| 329 // so we need to test that too. |
326 { |
| 330 if (path.isEmpty()) |
327 QStringList wadpaths = Config::get ("wadpaths").toStringList(); |
| 331 path = findWAD (wad.toUpper()); |
328 |
| |
329 // If there are no wad paths, try assimilate from other sources. |
| |
330 assimilateWadPaths (wadpaths); |
| |
331 Config::set ("wadpaths", wadpaths); |
| |
332 |
| |
333 // Try find the wad again |
| |
334 path = findWad (wad); |
| |
335 } |
| 332 |
336 |
| 333 if (path.isEmpty()) |
337 if (path.isEmpty()) |
| 334 { |
338 { |
| 335 error (tr ("Couldn't find %1!").arg (wad)); |
339 error (tr ("Couldn't find %1!").arg (wad)); |
| 336 return 1; |
340 return 1; |