mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-09 07:40:21 +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;
|
std::string type;
|
||||||
is >> type;
|
is >> type;
|
||||||
|
@ -366,6 +366,14 @@ void BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||||
}
|
}
|
||||||
else if(type == "AC_RESET_PASS")
|
else if(type == "AC_RESET_PASS")
|
||||||
command = 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()
|
void BoneCommand::run()
|
||||||
|
@ -1701,9 +1709,16 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
BoneCommand bcmd;
|
BoneCommand bcmd;
|
||||||
bcmd.parse(b, is);
|
if(!bcmd.parse(b, is))
|
||||||
|
break;
|
||||||
newSkeletalKeyframe.commands.push_back(bcmd);
|
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
|
// generate empty bone keys
|
||||||
|
|
|
@ -92,7 +92,7 @@ protected:
|
||||||
class BoneCommand
|
class BoneCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void parse(Bone *b, SimpleIStringStream &is);
|
bool parse(Bone *b, SimpleIStringStream &is);
|
||||||
void run();
|
void run();
|
||||||
AnimationCommand command;
|
AnimationCommand command;
|
||||||
Bone *b;
|
Bone *b;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue