| 235 | } |
| 236 | |
| 237 | void ParseLevelXML(const std::string& path, LevelInfo& li) { |
| 238 | for (int i = 0, len = path.size(); i < len; ++i) { |
| 239 | if (path[i] == '\\') { |
| 240 | std::stringstream ss; |
| 241 | ss << "Path to ParseLevelXML should not contain \\ \"" << path.c_str() << "\""; |
| 242 | DisplayError("Error", ss.str().c_str()); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | if (!CheckFileAccess(path.c_str())) { |
| 247 | FatalError("Error", "Could not find level file: %s", path.c_str()); |
| 248 | } |
| 249 | |
| 250 | TiXmlDocument doc; |
| 251 | if (!doc.LoadFile(path.c_str())) { |
| 252 | FatalError("Error", "Bad xml data in level file %s\n%s on row %d", path.c_str(), doc.ErrorDesc(), doc.ErrorRow()); |
| 253 | } |
| 254 | |
| 255 | li.SetDefaults(); |
| 256 | |
| 257 | GetXMLVersionFromDoc(doc, li.xml_version_); |
| 258 | ExtractLevelName(path, li.level_name_); |
| 259 | li.path_ = path; |
| 260 | |
| 261 | const TiXmlElement* root = doc.RootElement(); |
| 262 | |
| 263 | // Check if this is the newer level format with the "correct" Level root node |
| 264 | // If it is, reassign, otherwise iterator on the "bottom" of the document. |
| 265 | // LOGW << "test:" << root->Value() << std::endl; |
| 266 | if (root && strcmp(root->Value(), "Level") == 0) { |
| 267 | root = root->FirstChildElement(); |
| 268 | } |
| 269 | |
| 270 | if (!root) { |
| 271 | LOGE << "Level Root is null!" << std::endl; |
| 272 | } |
| 273 | |
| 274 | for (const TiXmlElement* field = root; field; field = field->NextSiblingElement()) { |
| 275 | const char* val = field->Value(); |
| 276 | switch (val[0]) { |
| 277 | case 'A': |
| 278 | switch (val[1]) { |
| 279 | case 'm': // AmbientSounds |
| 280 | if (strcmp("AmbientSounds", val) == 0) { |
| 281 | HandleAmbientSounds(li.ambient_sounds_, field->FirstChildElement()); |
| 282 | } |
| 283 | break; |
| 284 | case 'c': |
| 285 | switch (val[2]) { |
| 286 | case 't': // ActorObjects |
| 287 | if (strcmp("ActorObjects", val) == 0) { |
| 288 | LoadEntityDescriptionListFromXML(li.desc_list_, field); |
| 289 | } |
| 290 | break; |
| 291 | case 'h': // Achievements |
| 292 | if (strcmp("Achievements", val) == 0) { |
| 293 | if (field->GetText()) { |
| 294 | ScriptParam sp; |
no test coverage detected