Skip to content

Commit

Permalink
Merge pull request #927 from lairworks/moveEmptyFrameListCheck
Browse files Browse the repository at this point in the history
Move empty frameList check to caller
  • Loading branch information
DanRStevens authored Jul 15, 2021
2 parents 1b481c2 + 0b78386 commit 3e8fcdd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions NAS2D/Resource/AnimationSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace
AnimationSet processXml(std::string filePath, ImageCache& imageCache);
std::map<std::string, std::string> processImageSheets(const std::string& basePath, const Xml::XmlElement* element, ImageCache& imageCache);
std::map<std::string, std::vector<AnimationSet::Frame>> processActions(const std::map<std::string, std::string>& imageSheetMap, const Xml::XmlElement* element, ImageCache& imageCache);
std::vector<AnimationSet::Frame> processFrames(const std::map<std::string, std::string>& imageSheetMap, const std::string& action, const Xml::XmlElement* element, ImageCache& imageCache);
std::vector<AnimationSet::Frame> processFrames(const std::map<std::string, std::string>& imageSheetMap, const Xml::XmlElement* element, ImageCache& imageCache);
}


Expand Down Expand Up @@ -195,7 +195,12 @@ namespace
throw std::runtime_error("Sprite Action redefinition: '" + actionName + "' " + endTag(action->row()));
}

actions[actionName] = processFrames(imageSheetMap, actionName, action, imageCache);
actions[actionName] = processFrames(imageSheetMap, action, imageCache);

if (actions[actionName].empty())
{
throw std::runtime_error("Sprite Action contains no valid frames: " + actionName);
}
}

return actions;
Expand All @@ -205,7 +210,7 @@ namespace
/**
* Parses through all <frame> tags within an <action> tag in a Sprite Definition.
*/
std::vector<AnimationSet::Frame> processFrames(const std::map<std::string, std::string>& imageSheetMap, const std::string& action, const Xml::XmlElement* element, ImageCache& imageCache)
std::vector<AnimationSet::Frame> processFrames(const std::map<std::string, std::string>& imageSheetMap, const Xml::XmlElement* element, ImageCache& imageCache)
{
std::vector<AnimationSet::Frame> frameList;

Expand Down Expand Up @@ -262,11 +267,6 @@ namespace
frameList.push_back(AnimationSet::Frame{image, bounds, anchorOffset, delay});
}

if (frameList.empty())
{
throw std::runtime_error("Sprite Action contains no valid frames: " + action);
}

return frameList;
}

Expand Down

0 comments on commit 3e8fcdd

Please sign in to comment.