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
Package Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fancy2209
SRB2
Commits
b7a2b3f7
Commit
b7a2b3f7
authored
5 years ago
by
Monster Iestyn
Browse files
Options
Downloads
Patches
Plain Diff
Added switch cases to skin color related functions in r_draw.c, added extra error checking
parent
7ba4bbf8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/r_draw.c
+47
-30
47 additions, 30 deletions
src/r_draw.c
with
47 additions
and
30 deletions
src/r_draw.c
+
47
−
30
View file @
b7a2b3f7
...
...
@@ -523,33 +523,44 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U
INT32
i
,
starttranscolor
,
skinramplength
;
// Handle a couple of simple special cases
if
(
skinnum
==
TC_BOSS
||
skinnum
==
TC_ALLWHITE
||
skinnum
==
TC_METALSONIC
||
skinnum
==
TC_BLINK
||
color
==
SKINCOLOR_NONE
)
if
(
skinnum
<
TC_DEFAULT
)
{
if
(
skinnum
==
TC_ALLWHITE
)
memset
(
dest_colormap
,
0
,
NUM_PALETTE_ENTRIES
*
sizeof
(
UINT8
));
else
if
(
skinnum
==
TC_BLINK
&&
color
!=
SKINCOLOR_NONE
)
memset
(
dest_colormap
,
Color_Index
[
color
-
1
][
3
],
NUM_PALETTE_ENTRIES
*
sizeof
(
UINT8
));
else
switch
(
skinnum
)
{
for
(
i
=
0
;
i
<
NUM_PALETTE_ENTRIES
;
i
++
)
dest_colormap
[
i
]
=
(
UINT8
)
i
;
case
TC_RAINBOW
:
R_RainbowColormap
(
dest_colormap
,
color
);
return
;
case
TC_ALLWHITE
:
memset
(
dest_colormap
,
0
,
NUM_PALETTE_ENTRIES
*
sizeof
(
UINT8
));
return
;
case
TC_BLINK
:
if
(
color
>=
MAXTRANSLATIONS
)
I_Error
(
"Invalid skin color #%hu."
,
(
UINT16
)
color
);
if
(
color
!=
SKINCOLOR_NONE
)
{
memset
(
dest_colormap
,
Color_Index
[
color
-
1
][
3
],
NUM_PALETTE_ENTRIES
*
sizeof
(
UINT8
));
return
;
}
/* FALLTHRU */
case
TC_BOSS
:
case
TC_METALSONIC
:
default:
for
(
i
=
0
;
i
<
NUM_PALETTE_ENTRIES
;
i
++
)
dest_colormap
[
i
]
=
(
UINT8
)
i
;
// White!
if
(
skinnum
==
TC_BOSS
)
dest_colormap
[
31
]
=
0
;
else
if
(
skinnum
==
TC_METALSONIC
)
dest_colormap
[
159
]
=
0
;
return
;
}
// White!
if
(
skinnum
==
TC_BOSS
)
dest_colormap
[
31
]
=
0
;
else
if
(
skinnum
==
TC_METALSONIC
)
dest_colormap
[
159
]
=
0
;
return
;
}
else
if
(
skinnum
==
TC_RAINBOW
)
else
if
(
color
==
SKINCOLOR_NONE
)
{
R_RainbowColormap
(
dest_colormap
,
color
);
for
(
i
=
0
;
i
<
NUM_PALETTE_ENTRIES
;
i
++
)
dest_colormap
[
i
]
=
(
UINT8
)
i
;
return
;
}
...
...
@@ -558,6 +569,9 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U
starttranscolor
=
(
skinnum
!=
TC_DEFAULT
)
?
skins
[
skinnum
].
starttranscolor
:
DEFAULT_STARTTRANSCOLOR
;
if
(
starttranscolor
>=
NUM_PALETTE_ENTRIES
)
I_Error
(
"Invalid startcolor #%d."
,
starttranscolor
);
// Fill in the entries of the palette that are fixed
for
(
i
=
0
;
i
<
starttranscolor
;
i
++
)
dest_colormap
[
i
]
=
(
UINT8
)
i
;
...
...
@@ -570,7 +584,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U
skinramplength
=
16
;
}
else
skinramplength
=
i
-
NUM_PALETTE_ENTRIES
;
skinramplength
=
i
-
NUM_PALETTE_ENTRIES
;
// shouldn't this be NUM_PALETTE_ENTRIES - starttranscolor?
// Build the translated ramp
for
(
i
=
0
;
i
<
skinramplength
;
i
++
)
...
...
@@ -592,13 +606,16 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags)
INT32
skintableindex
;
// Adjust if we want the default colormap
if
(
skinnum
==
TC_DEFAULT
)
skintableindex
=
DEFAULT_TT_CACHE_INDEX
;
else
if
(
skinnum
==
TC_BOSS
)
skintableindex
=
BOSS_TT_CACHE_INDEX
;
else
if
(
skinnum
==
TC_METALSONIC
)
skintableindex
=
METALSONIC_TT_CACHE_INDEX
;
else
if
(
skinnum
==
TC_ALLWHITE
)
skintableindex
=
ALLWHITE_TT_CACHE_INDEX
;
else
if
(
skinnum
==
TC_RAINBOW
)
skintableindex
=
RAINBOW_TT_CACHE_INDEX
;
else
if
(
skinnum
==
TC_BLINK
)
skintableindex
=
BLINK_TT_CACHE_INDEX
;
else
skintableindex
=
skinnum
;
switch
(
skinnum
)
{
case
TC_DEFAULT
:
skintableindex
=
DEFAULT_TT_CACHE_INDEX
;
break
;
case
TC_BOSS
:
skintableindex
=
BOSS_TT_CACHE_INDEX
;
break
;
case
TC_METALSONIC
:
skintableindex
=
METALSONIC_TT_CACHE_INDEX
;
break
;
case
TC_ALLWHITE
:
skintableindex
=
ALLWHITE_TT_CACHE_INDEX
;
break
;
case
TC_RAINBOW
:
skintableindex
=
RAINBOW_TT_CACHE_INDEX
;
break
;
case
TC_BLINK
:
skintableindex
=
BLINK_TT_CACHE_INDEX
;
break
;
default:
skintableindex
=
skinnum
;
break
;
}
if
(
flags
&
GTC_CACHE
)
{
...
...
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