Add DanceDatabase fallback

fixes being crashed when another player uses a modded dance
This commit is contained in:
Kae 2023-07-23 22:54:34 +10:00
parent 3b8ea95d61
commit c6a1d9880f
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,11 @@
{
"name" : "assetmissing",
"states" : ["idle","sit"],
"cycle" : 0.5,
"cyclic" : true,
"duration" : 1.0,
"steps" : [
// body, frontArm, backArm, headOffset, frontArmOffset, backArmOffset
[ "idle.1", "rotation?flipx", "rotation", [0, 0], [-6, 0], [0, 0] ]
]
}

View File

@ -17,7 +17,12 @@ DanceDatabase::DanceDatabase() {
}
DancePtr DanceDatabase::getDance(String const& name) const {
return m_dances.get(name);
if (auto dance = m_dances.ptr(name))
return *dance;
else {
Logger::error("Invalid dance '{}', using default", name);
return m_dances.get("assetmissing");
}
}
DancePtr DanceDatabase::readDance(String const& path) {