mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-26 02:07:26 +00:00
Make BoneCommand::parse() a bit more resilient and bail out when something is wrong
This commit is contained in:
parent
339490e3e9
commit
b4c1b811ce
2 changed files with 18 additions and 3 deletions
|
@ -311,7 +311,7 @@ void Bone::updateSegments()
|
|||
}
|
||||
}
|
||||
|
||||
void BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||
{
|
||||
std::string type;
|
||||
is >> type;
|
||||
|
@ -366,6 +366,14 @@ void BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
|||
}
|
||||
else if(type == "AC_RESET_PASS")
|
||||
command = AC_RESET_PASS;
|
||||
else // fail
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Failed to parse bone command string: invalid command: " << type;
|
||||
errorLog(os.str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BoneCommand::run()
|
||||
|
@ -1701,9 +1709,16 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
if (b)
|
||||
{
|
||||
BoneCommand bcmd;
|
||||
bcmd.parse(b, is);
|
||||
if(!bcmd.parse(b, is))
|
||||
break;
|
||||
newSkeletalKeyframe.commands.push_back(bcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "SkeletalSprite::loadSkeletal: File " << fn << " anim " << newAnimation.name << " specifies non-existing bone idx " << bidx;
|
||||
errorLog(os.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
// generate empty bone keys
|
||||
|
|
|
@ -92,7 +92,7 @@ protected:
|
|||
class BoneCommand
|
||||
{
|
||||
public:
|
||||
void parse(Bone *b, SimpleIStringStream &is);
|
||||
bool parse(Bone *b, SimpleIStringStream &is);
|
||||
void run();
|
||||
AnimationCommand command;
|
||||
Bone *b;
|
||||
|
|
Loading…
Reference in a new issue