Merge branch 'rotsprite_i' of https://git.magicalgirl.moe/STJr/SRB2Internal.git into rotsprite_toast
This commit is contained in:
commit
278ddcf770
|
@ -868,6 +868,8 @@ static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame)
|
||||||
sprinfo->pivot[frame].x = value;
|
sprinfo->pivot[frame].x = value;
|
||||||
else if (fastcmp(word, "YPIVOT"))
|
else if (fastcmp(word, "YPIVOT"))
|
||||||
sprinfo->pivot[frame].y = value;
|
sprinfo->pivot[frame].y = value;
|
||||||
|
else if (fastcmp(word, "ROTAXIS"))
|
||||||
|
sprinfo->pivot[frame].rotaxis = value;
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -893,6 +895,11 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
|
||||||
spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
||||||
info->available = true;
|
info->available = true;
|
||||||
|
|
||||||
|
#ifdef ROTSPRITE
|
||||||
|
if ((sprites != NULL) && (!sprite2))
|
||||||
|
R_FreeSingleRotSprite(&sprites[num]);
|
||||||
|
#endif
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
lastline = f->curpos;
|
lastline = f->curpos;
|
||||||
|
@ -1006,7 +1013,7 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read sprite frame and store it on the spriteinfo_t struct
|
// read sprite frame and store it in the spriteinfo_t struct
|
||||||
readspriteframe(f, info, frame);
|
readspriteframe(f, info, frame);
|
||||||
if (sprite2)
|
if (sprite2)
|
||||||
{
|
{
|
||||||
|
@ -1018,8 +1025,12 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
|
||||||
}
|
}
|
||||||
for (i = 0; i < foundskins; i++)
|
for (i = 0; i < foundskins; i++)
|
||||||
{
|
{
|
||||||
skin_t *skin = &skins[skinnumbers[i]];
|
size_t skinnum = skinnumbers[i];
|
||||||
|
skin_t *skin = &skins[skinnum];
|
||||||
spriteinfo_t *sprinfo = skin->sprinfo;
|
spriteinfo_t *sprinfo = skin->sprinfo;
|
||||||
|
#ifdef ROTSPRITE
|
||||||
|
R_FreeSkinRotSprite(skinnum);
|
||||||
|
#endif
|
||||||
M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t));
|
M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ static int lib_getSpriteInfo(lua_State *L)
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, int idx)
|
static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, int idx)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int okcool = 0;
|
||||||
switch (lua_type(L, stk))
|
switch (lua_type(L, stk))
|
||||||
{
|
{
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
|
@ -312,14 +312,14 @@ static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, in
|
||||||
pivot[idx].rotaxis = (UINT8)value;
|
pivot[idx].rotaxis = (UINT8)value;
|
||||||
else if (ikey == -1 && (key != NULL))
|
else if (ikey == -1 && (key != NULL))
|
||||||
FIELDERROR("pivot key", va("invalid option %s", key));
|
FIELDERROR("pivot key", va("invalid option %s", key));
|
||||||
ok = 1;
|
okcool = 1;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TYPEERROR("sprite pivot", LUA_TTABLE, lua_type(L, stk))
|
TYPEERROR("sprite pivot", LUA_TTABLE, lua_type(L, stk))
|
||||||
}
|
}
|
||||||
return ok;
|
return okcool;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PopPivotTable(spriteinfo_t *info, lua_State *L, int stk)
|
static int PopPivotTable(spriteinfo_t *info, lua_State *L, int stk)
|
||||||
|
@ -376,7 +376,11 @@ static int lib_setSpriteInfo(lua_State *L)
|
||||||
UINT32 i = luaL_checkinteger(L, 1);
|
UINT32 i = luaL_checkinteger(L, 1);
|
||||||
if (i == 0 || i >= NUMSPRITES)
|
if (i == 0 || i >= NUMSPRITES)
|
||||||
return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1);
|
return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1);
|
||||||
info = &spriteinfo[i]; // get the sfxinfo to assign to.
|
#ifdef ROTSPRITE
|
||||||
|
if (sprites != NULL)
|
||||||
|
R_FreeSingleRotSprite(&sprites[i]);
|
||||||
|
#endif
|
||||||
|
info = &spriteinfo[i]; // get the spriteinfo to assign to.
|
||||||
}
|
}
|
||||||
luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.
|
luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.
|
||||||
lua_remove(L, 1); // pop sprite num, don't need it any more.
|
lua_remove(L, 1); // pop sprite num, don't need it any more.
|
||||||
|
@ -467,6 +471,9 @@ static int spriteinfo_set(lua_State *L)
|
||||||
lua_settop(L, 1); // leave only one value
|
lua_settop(L, 1); // leave only one value
|
||||||
|
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
|
if (sprites != NULL)
|
||||||
|
R_FreeSingleRotSprite(&sprites[sprinfo-spriteinfo]);
|
||||||
|
|
||||||
if (fastcmp(field, "pivot"))
|
if (fastcmp(field, "pivot"))
|
||||||
{
|
{
|
||||||
// pivot[] is a table
|
// pivot[] is a table
|
||||||
|
@ -597,7 +604,7 @@ static int framepivot_set(lua_State *L)
|
||||||
else if (fastcmp("y", field))
|
else if (fastcmp("y", field))
|
||||||
framepivot->y = luaL_checkinteger(L, 3);
|
framepivot->y = luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp("rotaxis", field))
|
else if (fastcmp("rotaxis", field))
|
||||||
framepivot->rotaxis = (rotaxis_t)(luaL_checkinteger(L, 3));
|
framepivot->rotaxis = luaL_checkinteger(L, 3);
|
||||||
else
|
else
|
||||||
return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field));
|
return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field));
|
||||||
|
|
||||||
|
|
|
@ -3510,20 +3510,6 @@ boolean P_AddWadFile(const char *wadfilename)
|
||||||
if (!mapsadded)
|
if (!mapsadded)
|
||||||
CONS_Printf(M_GetText("No maps added\n"));
|
CONS_Printf(M_GetText("No maps added\n"));
|
||||||
|
|
||||||
#ifdef ROTSPRITE
|
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
|
||||||
R_FreeRotSprite(&sprites[i]);
|
|
||||||
for (i = 0; i < MAXSKINS; i++)
|
|
||||||
{
|
|
||||||
spritedef_t *skinsprites = skins[i].sprites;
|
|
||||||
for (j = 0; j < NUMPLAYERSPRITES*2; j++)
|
|
||||||
{
|
|
||||||
R_FreeRotSprite(skinsprites);
|
|
||||||
skinsprites++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R_LoadSpriteInfoLumps(wadnum, numlumps);
|
R_LoadSpriteInfoLumps(wadnum, numlumps);
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
|
|
|
@ -940,6 +940,11 @@ static void R_ParseSpriteInfo(boolean spr2)
|
||||||
info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
||||||
info->available = true;
|
info->available = true;
|
||||||
|
|
||||||
|
#ifdef ROTSPRITE
|
||||||
|
if ((sprites != NULL) && (!spr2))
|
||||||
|
R_FreeSingleRotSprite(&sprites[sprnum]);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Left Curly Brace
|
// Left Curly Brace
|
||||||
sprinfoToken = M_GetToken(NULL);
|
sprinfoToken = M_GetToken(NULL);
|
||||||
if (sprinfoToken == NULL)
|
if (sprinfoToken == NULL)
|
||||||
|
@ -997,8 +1002,12 @@ static void R_ParseSpriteInfo(boolean spr2)
|
||||||
I_Error("Error parsing SPRTINFO lump: No skins specified in this sprite2 definition");
|
I_Error("Error parsing SPRTINFO lump: No skins specified in this sprite2 definition");
|
||||||
for (i = 0; i < foundskins; i++)
|
for (i = 0; i < foundskins; i++)
|
||||||
{
|
{
|
||||||
skin_t *skin = &skins[skinnumbers[i]];
|
size_t skinnum = skinnumbers[i];
|
||||||
|
skin_t *skin = &skins[skinnum];
|
||||||
spriteinfo_t *sprinfo = skin->sprinfo;
|
spriteinfo_t *sprinfo = skin->sprinfo;
|
||||||
|
#ifdef ROTSPRITE
|
||||||
|
R_FreeSkinRotSprite(skinnum);
|
||||||
|
#endif
|
||||||
M_Memcpy(&sprinfo[spr2num], info, sizeof(spriteinfo_t));
|
M_Memcpy(&sprinfo[spr2num], info, sizeof(spriteinfo_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1293,11 +1302,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_FreeRotSprite
|
// R_FreeSingleRotSprite
|
||||||
//
|
//
|
||||||
// Free sprite rotation data from memory.
|
// Free sprite rotation data from memory, for a single spritedef.
|
||||||
//
|
//
|
||||||
void R_FreeRotSprite(spritedef_t *spritedef)
|
void R_FreeSingleRotSprite(spritedef_t *spritedef)
|
||||||
{
|
{
|
||||||
UINT8 frame;
|
UINT8 frame;
|
||||||
INT32 rot, ang;
|
INT32 rot, ang;
|
||||||
|
@ -1343,4 +1352,22 @@ void R_FreeRotSprite(spritedef_t *spritedef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// R_FreeSkinRotSprite
|
||||||
|
//
|
||||||
|
// Free sprite rotation data from memory, for a skin.
|
||||||
|
// Calls R_FreeSingleRotSprite.
|
||||||
|
//
|
||||||
|
void R_FreeSkinRotSprite(size_t skinnum)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
skin_t *skin = &skins[skinnum];
|
||||||
|
spritedef_t *skinsprites = skin->sprites;
|
||||||
|
for (i = 0; i < NUMPLAYERSPRITES*2; i++)
|
||||||
|
{
|
||||||
|
R_FreeSingleRotSprite(skinsprites);
|
||||||
|
skinsprites++;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,7 +67,8 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
|
||||||
// rotsprite
|
// rotsprite
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip);
|
void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip);
|
||||||
void R_FreeRotSprite(spritedef_t *spritedef);
|
void R_FreeSingleRotSprite(spritedef_t *spritedef);
|
||||||
|
void R_FreeSkinRotSprite(size_t skinnum);
|
||||||
extern fixed_t cosang2rad[ROTANGLES];
|
extern fixed_t cosang2rad[ROTANGLES];
|
||||||
extern fixed_t sinang2rad[ROTANGLES];
|
extern fixed_t sinang2rad[ROTANGLES];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -244,7 +244,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||||
if (spritedef->numframes) // (then spriteframes is not null)
|
if (spritedef->numframes) // (then spriteframes is not null)
|
||||||
{
|
{
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
R_FreeRotSprite(spritedef);
|
R_FreeSingleRotSprite(spritedef);
|
||||||
#endif
|
#endif
|
||||||
// copy the already defined sprite frames
|
// copy the already defined sprite frames
|
||||||
M_Memcpy(sprtemp, spritedef->spriteframes,
|
M_Memcpy(sprtemp, spritedef->spriteframes,
|
||||||
|
@ -394,7 +394,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||||
spritedef->numframes < maxframe) // more frames are defined ?
|
spritedef->numframes < maxframe) // more frames are defined ?
|
||||||
{
|
{
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
R_FreeRotSprite(spritedef);
|
R_FreeSingleRotSprite(spritedef);
|
||||||
#endif
|
#endif
|
||||||
Z_Free(spritedef->spriteframes);
|
Z_Free(spritedef->spriteframes);
|
||||||
spritedef->spriteframes = NULL;
|
spritedef->spriteframes = NULL;
|
||||||
|
|
Loading…
Reference in New Issue