Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
837c3a7b
Commit
837c3a7b
authored
Mar 15, 2024
by
LJ Sonic
Browse files
Options
Downloads
Patches
Plain Diff
Refactor R_AddSingleSpriteDef
parent
1c415749
No related branches found
No related tags found
1 merge request
!2394
Sprite names up to 64 character long and 256 frames per sprite
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/r_things.c
+42
-20
42 additions, 20 deletions
src/r_things.c
with
42 additions
and
20 deletions
src/r_things.c
+
42
−
20
View file @
837c3a7b
...
@@ -238,6 +238,40 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
...
@@ -238,6 +238,40 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
sprtemp
[
frame
].
flip
&=
~
(
1
<<
rotation
);
sprtemp
[
frame
].
flip
&=
~
(
1
<<
rotation
);
}
}
static
boolean
GetFramesAndRotationsFromLumpName
(
const
char
*
name
,
UINT8
*
ret_frame
,
UINT8
*
ret_rotation
,
UINT8
*
ret_frame2
,
UINT8
*
ret_rotation2
)
{
size_t
namelen
=
strlen
(
name
);
if
(
namelen
!=
6
&&
namelen
!=
8
)
return
false
;
*
ret_frame
=
R_Char2Frame
(
name
[
4
]);
*
ret_rotation
=
R_Char2Rotation
(
name
[
5
]);
if
(
*
ret_frame
>=
64
)
return
false
;
if
(
namelen
==
8
)
{
*
ret_frame2
=
R_Char2Frame
(
name
[
6
]);
*
ret_rotation2
=
R_Char2Rotation
(
name
[
7
]);
if
(
*
ret_frame2
>=
64
)
return
false
;
}
else
{
*
ret_frame2
=
255
;
*
ret_rotation2
=
255
;
}
return
true
;
}
// Install a single sprite, given its identifying name (4 chars)
// Install a single sprite, given its identifying name (4 chars)
//
//
// (originally part of R_AddSpriteDefs)
// (originally part of R_AddSpriteDefs)
...
@@ -254,8 +288,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
...
@@ -254,8 +288,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
boolean
R_AddSingleSpriteDef
(
const
char
*
sprname
,
spritedef_t
*
spritedef
,
UINT16
wadnum
,
UINT16
startlump
,
UINT16
endlump
)
boolean
R_AddSingleSpriteDef
(
const
char
*
sprname
,
spritedef_t
*
spritedef
,
UINT16
wadnum
,
UINT16
startlump
,
UINT16
endlump
)
{
{
UINT16
l
;
UINT16
l
;
UINT8
frame
;
UINT8
rotation
;
lumpinfo_t
*
lumpinfo
;
lumpinfo_t
*
lumpinfo
;
UINT16
numadded
=
0
;
UINT16
numadded
=
0
;
...
@@ -286,11 +318,12 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
...
@@ -286,11 +318,12 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
{
{
INT16
width
,
height
;
INT16
width
,
height
;
INT16
topoffset
,
leftoffset
;
INT16
topoffset
,
leftoffset
;
UINT8
frame
,
frame2
;
UINT8
rotation
,
rotation2
;
frame
=
R_Char2Frame
(
lumpinfo
[
l
].
name
[
4
]);
boolean
good
=
GetFramesAndRotationsFromLumpName
(
lumpinfo
[
l
].
name
,
&
frame
,
&
rotation
,
&
frame2
,
&
rotation2
);
rotation
=
R_Char2Rotation
(
lumpinfo
[
l
].
name
[
5
]);
if
(
frame
>=
64
||
rotation
==
255
)
// Give an actual NAME error -_-...
if
(
!
good
)
// Give an actual NAME error -_-...
{
{
CONS_Alert
(
CONS_WARNING
,
M_GetText
(
"Bad sprite name: %s
\n
"
),
W_CheckNameForNumPwad
(
wadnum
,
l
));
CONS_Alert
(
CONS_WARNING
,
M_GetText
(
"Bad sprite name: %s
\n
"
),
W_CheckNameForNumPwad
(
wadnum
,
l
));
continue
;
continue
;
...
@@ -322,19 +355,8 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
...
@@ -322,19 +355,8 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
//----------------------------------------------------
//----------------------------------------------------
R_InstallSpriteLump
(
wadnum
,
l
,
numspritelumps
,
frame
,
rotation
,
0
);
R_InstallSpriteLump
(
wadnum
,
l
,
numspritelumps
,
frame
,
rotation
,
0
);
if
(
frame2
!=
255
)
if
(
lumpinfo
[
l
].
name
[
6
])
R_InstallSpriteLump
(
wadnum
,
l
,
numspritelumps
,
frame2
,
rotation2
,
1
);
{
frame
=
R_Char2Frame
(
lumpinfo
[
l
].
name
[
6
]);
rotation
=
R_Char2Rotation
(
lumpinfo
[
l
].
name
[
7
]);
if
(
frame
>=
64
||
rotation
==
255
)
// Give an actual NAME error -_-...
{
CONS_Alert
(
CONS_WARNING
,
M_GetText
(
"Bad sprite name: %s
\n
"
),
W_CheckNameForNumPwad
(
wadnum
,
l
));
continue
;
}
R_InstallSpriteLump
(
wadnum
,
l
,
numspritelumps
,
frame
,
rotation
,
1
);
}
if
(
++
numspritelumps
>=
max_spritelumps
)
if
(
++
numspritelumps
>=
max_spritelumps
)
{
{
...
@@ -377,7 +399,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
...
@@ -377,7 +399,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
//
//
// some checks to help development
// some checks to help development
//
//
for
(
frame
=
0
;
frame
<
maxframe
;
frame
++
)
for
(
UINT8
frame
=
0
;
frame
<
maxframe
;
frame
++
)
{
{
switch
(
sprtemp
[
frame
].
rotate
)
switch
(
sprtemp
[
frame
].
rotate
)
{
{
...
@@ -399,7 +421,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
...
@@ -399,7 +421,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
default:
default:
// must have all 8/16 frames
// must have all 8/16 frames
rotation
=
((
sprtemp
[
frame
].
rotate
&
SRF_3DGE
)
?
16
:
8
);
UINT8
rotation
=
((
sprtemp
[
frame
].
rotate
&
SRF_3DGE
)
?
16
:
8
);
while
(
rotation
--
)
while
(
rotation
--
)
// we test the patch lump, or the id lump whatever
// we test the patch lump, or the id lump whatever
// if it was not loaded the two are LUMPERROR
// if it was not loaded the two are LUMPERROR
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment