mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-20 19:02:34 +00:00
Refactor spriteframepivot_t into spriteinfoframe_t
This commit is contained in:
parent
1d100f9c89
commit
8aeb048f0a
5 changed files with 23 additions and 18 deletions
|
@ -925,9 +925,9 @@ static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame)
|
|||
value = atoi(word2); // used for numerical settings
|
||||
|
||||
if (fastcmp(word, "XPIVOT"))
|
||||
sprinfo->pivot[frame].x = value;
|
||||
sprinfo->frames[frame].pivot.x = value;
|
||||
else if (fastcmp(word, "YPIVOT"))
|
||||
sprinfo->pivot[frame].y = value;
|
||||
sprinfo->frames[frame].pivot.y = value;
|
||||
// TODO: 2.3: Delete
|
||||
else if (fastcmp(word, "ROTAXIS"))
|
||||
deh_warning("SpriteInfo: ROTAXIS is deprecated and will be removed.");
|
||||
|
|
|
@ -333,9 +333,9 @@ static int PopPivotSubTable(spriteinfo_t *info, lua_State *L, int stk, int idx)
|
|||
}
|
||||
// Set it
|
||||
if (ikey == 1 || (key && fastcmp(key, "x")))
|
||||
info->pivot[idx].x = (INT32)value;
|
||||
info->frames[idx].pivot.x = (INT32)value;
|
||||
else if (ikey == 2 || (key && fastcmp(key, "y")))
|
||||
info->pivot[idx].y = (INT32)value;
|
||||
info->frames[idx].pivot.y = (INT32)value;
|
||||
// TODO: 2.3: Delete
|
||||
else if (ikey == 3 || (key && fastcmp(key, "rotaxis")))
|
||||
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
|
||||
|
@ -552,8 +552,8 @@ static int pivotlist_set(lua_State *L)
|
|||
else if (lua_isuserdata(L, 3))
|
||||
{
|
||||
struct PivotFrame *container = luaL_checkudata(L, 3, META_FRAMEPIVOT);
|
||||
memcpy(&sprinfo->pivot[frame],
|
||||
&container->sprinfo->pivot[container->frame],
|
||||
memcpy(&sprinfo->frames[frame].pivot,
|
||||
&container->sprinfo->frames[container->frame].pivot,
|
||||
sizeof(spriteframepivot_t));
|
||||
okcool = 1;
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ static int pivotlist_num(lua_State *L)
|
|||
static int framepivot_get(lua_State *L)
|
||||
{
|
||||
struct PivotFrame *container = luaL_checkudata(L, 1, META_FRAMEPIVOT);
|
||||
spriteframepivot_t *framepivot = &container->sprinfo->pivot[container->frame];
|
||||
spriteframepivot_t *framepivot = &container->sprinfo->frames[container->frame].pivot;
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
|
||||
I_Assert(framepivot != NULL);
|
||||
|
@ -597,7 +597,7 @@ static int framepivot_get(lua_State *L)
|
|||
static int framepivot_set(lua_State *L)
|
||||
{
|
||||
struct PivotFrame *container = luaL_checkudata(L, 1, META_FRAMEPIVOT);
|
||||
spriteframepivot_t *framepivot = &container->sprinfo->pivot[container->frame];
|
||||
spriteframepivot_t *framepivot = &container->sprinfo->frames[container->frame].pivot;
|
||||
UINT8 *available = container->sprinfo->available;
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
|
||||
|
|
|
@ -98,13 +98,13 @@ patch_t *Patch_GetRotatedSprite(
|
|||
|
||||
if (R_IsSpriteInfoAvailable(sprinfo, frame))
|
||||
{
|
||||
xpivot = sprinfo->pivot[frame].x;
|
||||
ypivot = sprinfo->pivot[frame].y;
|
||||
xpivot = sprinfo->frames[frame].pivot.x;
|
||||
ypivot = sprinfo->frames[frame].pivot.y;
|
||||
}
|
||||
else if (R_IsSpriteInfoAvailable(sprinfo, SPRINFO_DEFAULT_FRAME))
|
||||
{
|
||||
xpivot = sprinfo->pivot[SPRINFO_DEFAULT_FRAME].x;
|
||||
ypivot = sprinfo->pivot[SPRINFO_DEFAULT_FRAME].y;
|
||||
xpivot = sprinfo->frames[SPRINFO_DEFAULT_FRAME].pivot.x;
|
||||
ypivot = sprinfo->frames[SPRINFO_DEFAULT_FRAME].pivot.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1556,18 +1556,18 @@ struct ParsedSpriteInfoFrame {
|
|||
INT32 pivotY;
|
||||
};
|
||||
|
||||
static boolean define_spriteinfo_frame(struct ParsedSpriteInfoFrame *frame, spriteinfo_t *dest, UINT16 index)
|
||||
static boolean define_spriteinfo_frame(struct ParsedSpriteInfoFrame *frame, spriteinfoframe_t *dest)
|
||||
{
|
||||
boolean defined = false;
|
||||
|
||||
if (frame->pivotX != INT32_MAX)
|
||||
{
|
||||
dest->pivot[index].x = frame->pivotX;
|
||||
dest->pivot.x = frame->pivotX;
|
||||
defined = true;
|
||||
}
|
||||
if (frame->pivotY != INT32_MAX)
|
||||
{
|
||||
dest->pivot[index].y = frame->pivotY;
|
||||
dest->pivot.y = frame->pivotY;
|
||||
defined = true;
|
||||
}
|
||||
|
||||
|
@ -1704,7 +1704,7 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
|
|||
{
|
||||
for (UINT16 frameIter = frameID; frameIter <= frameEndID; frameIter++)
|
||||
{
|
||||
if (define_spriteinfo_frame(&frame, parser->info, frameIter))
|
||||
if (define_spriteinfo_frame(&frame, &parser->info->frames[frameIter]))
|
||||
{
|
||||
set_bit_array(parser->info->available, frameIter);
|
||||
}
|
||||
|
@ -1712,7 +1712,7 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
|
|||
}
|
||||
else
|
||||
{
|
||||
if (define_spriteinfo_frame(&frame, parser->info, frameID))
|
||||
if (define_spriteinfo_frame(&frame, &parser->info->frames[frameID]))
|
||||
{
|
||||
set_bit_array(parser->info->available, frameID);
|
||||
}
|
||||
|
|
|
@ -98,12 +98,17 @@ typedef struct
|
|||
INT32 x, y;
|
||||
} spriteframepivot_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframepivot_t pivot;
|
||||
} spriteinfoframe_t;
|
||||
|
||||
#define SPRINFO_DEFAULT_FRAME (MAXFRAMENUM)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 available[BIT_ARRAY_SIZE(MAXFRAMENUM + 1)]; // 1 extra for default_frame
|
||||
spriteframepivot_t pivot[MAXFRAMENUM + 1];
|
||||
spriteinfoframe_t frames[MAXFRAMENUM + 1];
|
||||
} spriteinfo_t;
|
||||
|
||||
// PNG support
|
||||
|
|
Loading…
Reference in a new issue