mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-19 12:01:36 +00:00
Kill SPRITE/SPRITEINFO, SPRITE2INFO SOC headers
Kill it because maintaining three parsers for the same data is insane.
This commit is contained in:
parent
794385dd63
commit
499c61a9f2
3 changed files with 0 additions and 261 deletions
236
src/deh_soc.c
236
src/deh_soc.c
|
|
@ -640,242 +640,6 @@ void readlight(MYFILE *f, INT32 num)
|
|||
}
|
||||
#endif // HWRENDER
|
||||
|
||||
static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame)
|
||||
{
|
||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||
char *word, *word2;
|
||||
char *tmp;
|
||||
INT32 value;
|
||||
char *lastline;
|
||||
|
||||
do
|
||||
{
|
||||
lastline = f->curpos;
|
||||
if (myfgets(s, MAXLINELEN, f))
|
||||
{
|
||||
if (s[0] == '\n')
|
||||
break;
|
||||
|
||||
// First remove trailing newline, if there is one
|
||||
tmp = strchr(s, '\n');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
tmp = strchr(s, '#');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
if (s == tmp)
|
||||
continue; // Skip comment lines, but don't break.
|
||||
|
||||
// Set / reset word
|
||||
word = s;
|
||||
while ((*word == '\t') || (*word == ' '))
|
||||
word++;
|
||||
|
||||
// Get the part before the " = "
|
||||
tmp = strchr(s, '=');
|
||||
if (tmp)
|
||||
{
|
||||
*(tmp-1) = '\0';
|
||||
// Now get the part after
|
||||
word2 = tmp += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the part before the " "
|
||||
tmp = strchr(s, ' ');
|
||||
if (tmp)
|
||||
{
|
||||
*tmp = '\0';
|
||||
// Now get the part after
|
||||
tmp++;
|
||||
word2 = tmp;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
strupr(word);
|
||||
value = atoi(word2); // used for numerical settings
|
||||
|
||||
if (fastcmp(word, "XPIVOT"))
|
||||
sprinfo->pivot[frame].x = value;
|
||||
else if (fastcmp(word, "YPIVOT"))
|
||||
sprinfo->pivot[frame].y = value;
|
||||
else if (fastcmp(word, "ROTAXIS"))
|
||||
sprinfo->pivot[frame].rotaxis = value;
|
||||
else
|
||||
{
|
||||
f->curpos = lastline;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!myfeof(f)); // finish when the line is empty
|
||||
Z_Free(s);
|
||||
}
|
||||
|
||||
void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
|
||||
{
|
||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||
char *word, *word2;
|
||||
char *tmp;
|
||||
#ifdef HWRENDER
|
||||
INT32 value;
|
||||
#endif
|
||||
char *lastline;
|
||||
INT32 skinnumbers[MAXSKINS];
|
||||
INT32 foundskins = 0;
|
||||
|
||||
// allocate a spriteinfo
|
||||
spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
||||
info->available = true;
|
||||
|
||||
do
|
||||
{
|
||||
lastline = f->curpos;
|
||||
if (myfgets(s, MAXLINELEN, f))
|
||||
{
|
||||
if (s[0] == '\n')
|
||||
break;
|
||||
|
||||
// First remove trailing newline, if there is one
|
||||
tmp = strchr(s, '\n');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
tmp = strchr(s, '#');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
if (s == tmp)
|
||||
continue; // Skip comment lines, but don't break.
|
||||
|
||||
// Set / reset word
|
||||
word = s;
|
||||
while ((*word == '\t') || (*word == ' '))
|
||||
word++;
|
||||
|
||||
// Get the part before the " = "
|
||||
tmp = strchr(s, '=');
|
||||
if (tmp)
|
||||
{
|
||||
*(tmp-1) = '\0';
|
||||
// Now get the part after
|
||||
word2 = tmp += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the part before the " "
|
||||
tmp = strchr(s, ' ');
|
||||
if (tmp)
|
||||
{
|
||||
*tmp = '\0';
|
||||
// Now get the part after
|
||||
tmp++;
|
||||
word2 = tmp;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
strupr(word);
|
||||
#ifdef HWRENDER
|
||||
value = atoi(word2); // used for numerical settings
|
||||
|
||||
if (fastcmp(word, "LIGHTTYPE"))
|
||||
{
|
||||
if (sprite2)
|
||||
deh_warning("Sprite2 %s: invalid word '%s'", spr2names[num], word);
|
||||
else
|
||||
{
|
||||
INT32 oldvar;
|
||||
for (oldvar = 0; t_lspr[num] != &lspr[oldvar]; oldvar++)
|
||||
;
|
||||
t_lspr[num] = &lspr[value];
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (fastcmp(word, "SKIN"))
|
||||
{
|
||||
INT32 skinnum = -1;
|
||||
if (!sprite2)
|
||||
{
|
||||
deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word);
|
||||
continue;
|
||||
}
|
||||
|
||||
// make lowercase
|
||||
strlwr(word2);
|
||||
skinnum = R_SkinAvailable(word2);
|
||||
if (skinnum == -1)
|
||||
{
|
||||
deh_warning("Sprite2 %s: unknown skin %s", spr2names[num], word2);
|
||||
break;
|
||||
}
|
||||
|
||||
skinnumbers[foundskins] = skinnum;
|
||||
foundskins++;
|
||||
}
|
||||
else if (fastcmp(word, "DEFAULT"))
|
||||
{
|
||||
if (!sprite2)
|
||||
{
|
||||
deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word);
|
||||
continue;
|
||||
}
|
||||
if (num < (INT32)free_spr2 && num >= (INT32)SPR2_FIRSTFREESLOT)
|
||||
spr2defaults[num] = get_number(word2);
|
||||
else
|
||||
{
|
||||
deh_warning("Sprite2 %s: out of range (%d - %d), ignoring", spr2names[num], SPR2_FIRSTFREESLOT, free_spr2-1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (fastcmp(word, "FRAME"))
|
||||
{
|
||||
UINT8 frame = R_Char2Frame(word2[0]);
|
||||
// frame number too high
|
||||
if (frame >= 64)
|
||||
{
|
||||
if (sprite2)
|
||||
deh_warning("Sprite2 %s: invalid frame %s", spr2names[num], word2);
|
||||
else
|
||||
deh_warning("Sprite %s: invalid frame %s", sprnames[num], word2);
|
||||
break;
|
||||
}
|
||||
|
||||
// read sprite frame and store it in the spriteinfo_t struct
|
||||
readspriteframe(f, info, frame);
|
||||
if (sprite2)
|
||||
{
|
||||
INT32 i;
|
||||
if (!foundskins)
|
||||
{
|
||||
deh_warning("Sprite2 %s: no skins specified", spr2names[num]);
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < foundskins; i++)
|
||||
{
|
||||
size_t skinnum = skinnumbers[i];
|
||||
skin_t *skin = &skins[skinnum];
|
||||
spriteinfo_t *sprinfo = skin->sprinfo;
|
||||
M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t));
|
||||
}
|
||||
}
|
||||
else
|
||||
M_Memcpy(&spriteinfo[num], info, sizeof(spriteinfo_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
//deh_warning("Sprite %s: unknown word '%s'", sprnames[num], word);
|
||||
f->curpos = lastline;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!myfeof(f)); // finish when the line is empty
|
||||
|
||||
Z_Free(s);
|
||||
Z_Free(info);
|
||||
}
|
||||
|
||||
void readsprite2(MYFILE *f, INT32 num)
|
||||
{
|
||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ void readcutscene(MYFILE *f, INT32 num);
|
|||
void readlevelheader(MYFILE *f, INT32 num);
|
||||
void readgametype(MYFILE *f, char *gtname);
|
||||
void readsprite2(MYFILE *f, INT32 num);
|
||||
void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2);
|
||||
#ifdef HWRENDER
|
||||
void readlight(MYFILE *f, INT32 num);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -356,30 +356,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
else if (fastcmp(word, "SPRITE") || fastcmp(word, "SPRITEINFO"))
|
||||
{
|
||||
if (i == 0 && word2[0] != '0') // If word2 isn't a number
|
||||
i = get_sprite(word2); // find a sprite by name
|
||||
if (i < NUMSPRITES && i > 0)
|
||||
readspriteinfo(f, i, false);
|
||||
else
|
||||
{
|
||||
deh_warning("Sprite number %d out of range (0 - %d)", i, NUMSPRITES-1);
|
||||
ignorelines(f);
|
||||
}
|
||||
}
|
||||
else if (fastcmp(word, "SPRITE2INFO"))
|
||||
{
|
||||
if (i == 0 && word2[0] != '0') // If word2 isn't a number
|
||||
i = get_sprite2(word2); // find a sprite by name
|
||||
if (i < NUMPLAYERSPRITES && i >= 0)
|
||||
readspriteinfo(f, i, true);
|
||||
else
|
||||
{
|
||||
deh_warning("Sprite2 number %d out of range (0 - %d)", i, NUMPLAYERSPRITES-1);
|
||||
ignorelines(f);
|
||||
}
|
||||
}
|
||||
else if (fastcmp(word, "LEVEL"))
|
||||
{
|
||||
// Support using the actual map name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue