diff --git a/source/core/states.cpp b/source/core/states.cpp index bf2d20efe..bdd2abbf7 100644 --- a/source/core/states.cpp +++ b/source/core/states.cpp @@ -870,16 +870,34 @@ bool FStateDefinitions::SetLoop() // //========================================================================== -int FStateDefinitions::AddStates(FState *state, const FScriptPosition &sc) +int FStateDefinitions::AddStates(FState *state, const char *framechars, const FScriptPosition &sc) { bool error = false; int frame = 0; int count = 0; + while (*framechars) + { + bool noframe = false; - StateArray.Push(*state); - SourceLines.Push(sc); - ++count; + if (*framechars == '#') + noframe = true; + else if (*framechars == '^') + frame = '\\' - 'A'; + else + frame = (*framechars & 223) - 'A'; + framechars++; + if (frame < 0 || frame > 28) + { + frame = 0; + error = true; + } + + state->Frame = frame; + StateArray.Push(*state); + SourceLines.Push(sc); + ++count; + } laststate = &StateArray[StateArray.Size() - 1]; laststatebeforelabel = laststate; return !error ? count : -count; @@ -1062,3 +1080,12 @@ int GetSpriteIndex(const char * spritename, bool add) return 0; } +/* +DEFINE_ACTION_FUNCTION(FState, ValidateSpriteFrame) +{ + PARAM_SELF_STRUCT_PROLOGUE(FState); + ACTION_RETURN_BOOL(self->Frame < sprites[self->sprite].numframes); +} +*/ + + diff --git a/source/core/states.h b/source/core/states.h index 311b83473..4d6146069 100644 --- a/source/core/states.h +++ b/source/core/states.h @@ -90,8 +90,9 @@ struct FState { FState *NextState; VMFunction *ActionFunc; - int32_t sprite; + int16_t sprite; int16_t Tics; + uint8_t Frame; uint8_t StateFlags; uint8_t DefineFlags; public: @@ -238,7 +239,7 @@ public: bool SetStop(); bool SetWait(); bool SetLoop(); - int AddStates(FState *state, const FScriptPosition &sc); + int AddStates(FState* state, const char* framechars, const FScriptPosition& sc); int GetStateCount() const { return StateArray.Size(); } };