src/demo.cpp

changeset 39
2c368cf5cc19
parent 38
db677d321cf4
child 41
e985ebb67fdd
equal deleted inserted replaced
38:db677d321cf4 39:2c368cf5cc19
74 // ------------------------------------------------------------------------------------------------- 74 // -------------------------------------------------------------------------------------------------
75 // 75 //
76 76
77 static ZandronumVersion findVersion (QString versionName) 77 static ZandronumVersion findVersion (QString versionName)
78 { 78 {
79 for (const QVariant& it : getVersions()) 79 QList<QVariant> versions = Config::get ("versions").toList();
80 { 80
81 ZandronumVersion version = it.value<ZandronumVersion>(); 81 for (int i = 0; i < versions.size(); ++i)
82 {
83 if (not versions[i].canConvert<ZandronumVersion>())
84 continue;
85
86 ZandronumVersion version = versions[i].value<ZandronumVersion>();
82 87
83 if (version.name == versionName 88 if (version.name == versionName
84 or version.name + "M" == versionName 89 or version.name + "M" == versionName
85 or version.name == versionName + "M") 90 or version.name == versionName + "M")
86 { 91 {
87 return version; 92 return version;
88 } 93 }
89 } 94 }
90 95
91 return ZandronumVersion(); 96 return ZandronumVersion();
92 } 97 }
93 98
94 // 99 //
95 // ------------------------------------------------------------------------------------------------- 100 // -------------------------------------------------------------------------------------------------
101 106
102 if (wadpaths.empty()) 107 if (wadpaths.empty())
103 { 108 {
104 error (tr ("No WAD paths configured!")); 109 error (tr ("No WAD paths configured!"));
105 110
106 // Cannot just return an empty string here since that'd trigger 111 // Cannot just return an empty string here since that'd trigger another error prompt - skip
107 // another error prompt - skip ahead and exit. 112 // ahead and exit.
108 exit (9); 113 exit (1);
109 } 114 }
110 115
111 for (int i = 0; i < wadpaths.size(); ++i) 116 for (int i = 0; i < wadpaths.size(); ++i)
112 { 117 {
113 QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name); 118 QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name);
202 error (tr ("'%1' is not a valid Zandronum demo file!").arg (path)); 207 error (tr ("'%1' is not a valid Zandronum demo file!").arg (path));
203 return 1; 208 return 1;
204 } 209 }
205 } 210 }
206 211
207 stream >> headers.length 212 stream >> headers.length;
208 >> length; 213 stream >> length;
209 214
210 // The remaining headers are variable and relative to the length header. 215 // The remaining headers are variable and relative to the length header.
211 headers.version = headers.length + 1; 216 headers.version = headers.length + 1;
212 headers.userInfo = headers.length + 3, 217 headers.userInfo = headers.length + 3,
213 headers.bodyStart = headers.length + 4; 218 headers.bodyStart = headers.length + 4;

mercurial