mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-17 09:32:33 +00:00
Support setting two frames per lump for long sprites
This commit is contained in:
parent
22106ef8b1
commit
8a6b5d7c0f
1 changed files with 39 additions and 8 deletions
|
@ -278,17 +278,20 @@ static boolean GetFramesAndRotationsFromShortLumpName(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean GetFramesAndRotationsFromLongLumpName(
|
static boolean GetSingleFrameAndRotation(
|
||||||
const char *name,
|
const char *name,
|
||||||
|
size_t len,
|
||||||
INT32 *ret_frame,
|
INT32 *ret_frame,
|
||||||
UINT8 *ret_rotation,
|
UINT8 *ret_rotation
|
||||||
INT32 *ret_frame2,
|
|
||||||
UINT8 *ret_rotation2
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const char *underscore = strchr(name, '_');
|
const char *underscore = strchr(name, '_');
|
||||||
|
|
||||||
size_t framelen = underscore ? (size_t)(underscore - name) : strlen(name);
|
// Found but past the part of the name we are parsing
|
||||||
|
if ((size_t)(underscore - name) >= len)
|
||||||
|
underscore = NULL;
|
||||||
|
|
||||||
|
size_t framelen = underscore ? (size_t)(underscore - name) : len;
|
||||||
if (framelen < 1 || framelen > 4)
|
if (framelen < 1 || framelen > 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -304,8 +307,36 @@ static boolean GetFramesAndRotationsFromLongLumpName(
|
||||||
if (*ret_frame >= MAXFRAMENUM || *ret_rotation == 255)
|
if (*ret_frame >= MAXFRAMENUM || *ret_rotation == 255)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*ret_frame2 = -1;
|
return true;
|
||||||
*ret_rotation2 = 255;
|
}
|
||||||
|
|
||||||
|
static boolean GetFramesAndRotationsFromLongLumpName(
|
||||||
|
const char *name,
|
||||||
|
INT32 *ret_frame,
|
||||||
|
UINT8 *ret_rotation,
|
||||||
|
INT32 *ret_frame2,
|
||||||
|
UINT8 *ret_rotation2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const char *plus = strchr(name, '+');
|
||||||
|
|
||||||
|
if (plus)
|
||||||
|
{
|
||||||
|
size_t len1 = plus - name;
|
||||||
|
|
||||||
|
if (!GetSingleFrameAndRotation(name, len1, ret_frame, ret_rotation))
|
||||||
|
return false;
|
||||||
|
if (!GetSingleFrameAndRotation(plus + 1, strlen(name) - len1 - 1, ret_frame2, ret_rotation2))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!GetSingleFrameAndRotation(name, strlen(name), ret_frame, ret_rotation))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*ret_frame2 = -1;
|
||||||
|
*ret_rotation2 = 255;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -444,7 +475,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
||||||
UINT8 rotation, rotation2;
|
UINT8 rotation, rotation2;
|
||||||
|
|
||||||
boolean good = longname ?
|
boolean good = longname ?
|
||||||
GetFramesAndRotationsFromLongLumpName(lumpinfo[l].name, &frame, &rotation, &frame2, &rotation2) :
|
GetFramesAndRotationsFromLongLumpName(lumpinfo[l].longname, &frame, &rotation, &frame2, &rotation2) :
|
||||||
GetFramesAndRotationsFromShortLumpName(lumpinfo[l].name, &frame, &rotation, &frame2, &rotation2);
|
GetFramesAndRotationsFromShortLumpName(lumpinfo[l].name, &frame, &rotation, &frame2, &rotation2);
|
||||||
|
|
||||||
if (!good) // Give an actual NAME error -_-...
|
if (!good) // Give an actual NAME error -_-...
|
||||||
|
|
Loading…
Reference in a new issue