Skip to content

Commit

Permalink
Allow assigning IQM frames by animation name plus frame offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa the Magician authored and coelckers committed Nov 25, 2022
1 parent 58a64e4 commit 8206c29
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/common/models/models_iqm.cpp
Expand Up @@ -434,10 +434,19 @@ void IQMModel::UnloadGeometry()

int IQMModel::FindFrame(const char* name, bool nodefault)
{
// This doesn't really mean all that much for IQM
// [MK] allow looking up frames by animation name plus offset (using a colon as separator)
const char* colon = strrchr(name,':');
int nlen = (colon==nullptr)?strlen(name):(colon-name);
for (unsigned i = 0; i < Anims.Size(); i++)
{
if (!stricmp(name, Anims[i].Name.GetChars())) return i;
if (!strnicmp(name, Anims[i].Name.GetChars(), nlen))
{
// if no offset is given, return the first frame
if (colon == nullptr) return Anims[i].FirstFrame;
unsigned offset = atoi(colon+1);
if (offset >= Anims[i].NumFrames) return FErr_NotFound;
return Anims[i].FirstFrame+offset;
}
}
return FErr_NotFound;
}
Expand Down

0 comments on commit 8206c29

Please sign in to comment.