SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { size_t pos = animationFile.find('|'); std::string palettes; if (pos != std::string::npos) palettes = animationFile.substr(pos + 1); XML::Document doc(animationFile.substr(0, pos)); XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "sprite")) { logger->log("Error, failed to parse %s", animationFile.c_str()); std::string errorFile = paths.getStringValue("sprites") + paths.getStringValue("spriteErrorFile"); if (animationFile != errorFile) return load(errorFile, 0); else return nullptr; } SpriteDef *def = new SpriteDef; def->mProcessedFiles.insert(animationFile); def->loadSprite(rootNode, variant, palettes); def->substituteActions(); if (serverVersion < 1) def->fixDeadAction(); return def; }
SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { std::string::size_type pos = animationFile.find('|'); std::string palettes; if (pos != std::string::npos) palettes = animationFile.substr(pos + 1); XML::Document doc(animationFile.substr(0, pos)); xmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) { logger->log("Error, failed to parse %s", animationFile.c_str()); std::string errorFile = paths.getStringValue("sprites") + paths.getStringValue("spriteErrorFile"); if (animationFile != errorFile) { return load(errorFile, 0); } else { return NULL; } } SpriteDef *def = new SpriteDef; def->loadSprite(rootNode, variant, palettes); def->substituteActions(); return def; }