Sprite frame/char compatibility
This commit is contained in:
parent
37969a3415
commit
48204a5ba7
5 changed files with 19 additions and 21 deletions
|
|
@ -2364,7 +2364,7 @@ static int lib_rChar2Frame(lua_State *L)
|
|||
{
|
||||
const char *p = luaL_checkstring(L, 1);
|
||||
//HUDSAFE
|
||||
lua_pushinteger(L, R_Char2Frame(*p)); // first character only
|
||||
lua_pushinteger(L, R_Char2Frame(*p, lua_compatmode)); // first character only
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -2374,7 +2374,7 @@ static int lib_rFrame2Char(lua_State *L)
|
|||
char c[2] = "";
|
||||
//HUDSAFE
|
||||
|
||||
c[0] = R_Frame2Char(ch);
|
||||
c[0] = R_Frame2Char(ch, lua_compatmode);
|
||||
c[1] = 0;
|
||||
|
||||
lua_pushstring(L, c);
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ static UINT8 GetPivotFrame(lua_State *L, int idx)
|
|||
}
|
||||
else
|
||||
{
|
||||
frame = R_Char2Frame(field[0]);
|
||||
frame = R_Char2Frame(field[0], false);
|
||||
if (frame == 255)
|
||||
luaL_error(L, "invalid frame %s", field);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1502,7 +1502,7 @@ static boolean R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boole
|
|||
else
|
||||
frameChar = sprinfoToken;
|
||||
|
||||
frameFrame = R_Char2Frame(frameChar[0]);
|
||||
frameFrame = R_Char2Frame(frameChar[0], false);
|
||||
Z_Free(sprinfoToken);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
|
|||
UINT8 rotation,
|
||||
UINT8 flipped)
|
||||
{
|
||||
char cn = R_Frame2Char(frame), cr = R_Rotation2Char(rotation); // for debugging
|
||||
char cn = R_Frame2Char(frame, wadfiles[wad]->compatmode), cr = R_Rotation2Char(rotation); // for debugging
|
||||
|
||||
INT32 r;
|
||||
lumpnum_t lumppat = wad;
|
||||
|
|
@ -294,6 +294,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
lumpinfo_t *lumpinfo;
|
||||
softwarepatch_t patch;
|
||||
UINT16 numadded = 0;
|
||||
boolean compat = wadfiles[wadnum]->compatmode;
|
||||
|
||||
memset(sprtemp,0xFF, sizeof (sprtemp));
|
||||
maxframe = (size_t)-1;
|
||||
|
|
@ -328,7 +329,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
boolean isPNG = false;
|
||||
#endif
|
||||
|
||||
frame = R_Char2Frame(lumpinfo[l].name[4]);
|
||||
frame = R_Char2Frame(lumpinfo[l].name[4], compat);
|
||||
rotation = R_Char2Rotation(lumpinfo[l].name[5]);
|
||||
|
||||
if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-...
|
||||
|
|
@ -382,7 +383,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
|
||||
if (lumpinfo[l].name[6])
|
||||
{
|
||||
frame = R_Char2Frame(lumpinfo[l].name[6]);
|
||||
frame = R_Char2Frame(lumpinfo[l].name[6], compat);
|
||||
rotation = R_Char2Rotation(lumpinfo[l].name[7]);
|
||||
|
||||
if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-...
|
||||
|
|
@ -440,7 +441,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
{
|
||||
case SRF_NONE:
|
||||
// no rotations were found for that frame at all
|
||||
I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame));
|
||||
I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame, compat));
|
||||
break;
|
||||
|
||||
case SRF_SINGLE:
|
||||
|
|
@ -451,7 +452,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
// we test to see whether the left and right slots are present
|
||||
if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR))
|
||||
I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (L-R mode)",
|
||||
sprname, R_Frame2Char(frame));
|
||||
sprname, R_Frame2Char(frame, compat));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -462,7 +463,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
// if it was not loaded the two are LUMPERROR
|
||||
if (sprtemp[frame].lumppat[rotation] == LUMPERROR)
|
||||
I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (1-%c mode)",
|
||||
sprname, R_Frame2Char(frame), ((sprtemp[frame].rotate & SRF_3DGE) ? 'G' : '8'));
|
||||
sprname, R_Frame2Char(frame, compat), ((sprtemp[frame].rotate & SRF_3DGE) ? 'G' : '8'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,33 +273,30 @@ void R_InitDrawNodes(void);
|
|||
// as much as possible while also defining all 64 slots in a sane manner
|
||||
// 2.1: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]]
|
||||
// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]]
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame)
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame, boolean compat)
|
||||
{
|
||||
#if 1 // 2.1 compat
|
||||
return 'A' + frame;
|
||||
#else
|
||||
if (compat)
|
||||
return 'A' + frame;
|
||||
|
||||
if (frame < 26) return 'A' + frame;
|
||||
if (frame < 36) return '0' + (frame - 26);
|
||||
if (frame < 62) return 'a' + (frame - 36);
|
||||
if (frame == 62) return '!';
|
||||
if (frame == 63) return '@';
|
||||
return '\xFF';
|
||||
#endif
|
||||
}
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn)
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn, boolean compat)
|
||||
{
|
||||
#if 1 // 2.1 compat
|
||||
if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead
|
||||
return cn - 'A';
|
||||
#else
|
||||
if (compat)
|
||||
return (cn == '+' ? '\\' : cn) - 'A'; // PK3 can't use backslash, so use + instead
|
||||
|
||||
if (cn >= 'A' && cn <= 'Z') return (cn - 'A');
|
||||
if (cn >= '0' && cn <= '9') return (cn - '0') + 26;
|
||||
if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36;
|
||||
if (cn == '!') return 62;
|
||||
if (cn == '@') return 63;
|
||||
return 255;
|
||||
#endif
|
||||
}
|
||||
|
||||
// "Left" and "Right" character symbols for additional rotation functionality
|
||||
|
|
|
|||
Loading…
Reference in a new issue