SendNameAndColor: Some cleanup

- Default to "Default", not "Match", when sendFollowerColor is unusable
- Do not use invalid index into `followers[]` when adjusting sendFollowerColor
This commit is contained in:
toaster 2023-04-25 14:53:25 +01:00
parent 0964ba5c7b
commit a03c31f59a

View file

@ -1486,7 +1486,7 @@ static void SendNameAndColor(const UINT8 n)
} }
else else
{ {
// Use our old color // Use our default color
CV_StealthSetValue(&cv_playercolor[n], SKINCOLOR_NONE); CV_StealthSetValue(&cv_playercolor[n], SKINCOLOR_NONE);
} }
@ -1496,7 +1496,7 @@ static void SendNameAndColor(const UINT8 n)
// ditto for follower colour: // ditto for follower colour:
if (sendFollowerColor != SKINCOLOR_NONE && K_ColorUsable(sendFollowerColor, true) == false) if (sendFollowerColor != SKINCOLOR_NONE && K_ColorUsable(sendFollowerColor, true) == false)
{ {
CV_StealthSet(&cv_followercolor[n], "Match"); // set it to "Match". I don't care about your stupidity! CV_StealthSet(&cv_followercolor[n], "Default"); // set it to "Default". I don't care about your stupidity!
sendFollowerColor = cv_followercolor[n].value; sendFollowerColor = cv_followercolor[n].value;
} }
@ -1563,7 +1563,14 @@ static void SendNameAndColor(const UINT8 n)
if (sendFollowerColor == SKINCOLOR_NONE) if (sendFollowerColor == SKINCOLOR_NONE)
{ {
sendFollowerColor = followers[cv_follower[n].value].defaultcolor; if (cv_follower[n].value >= 0)
{
sendFollowerColor = followers[cv_follower[n].value].defaultcolor;
}
else
{
sendFollowerColor = SKINCOLOR_RED; // picked by dice roll, guaranteed to be random
}
} }
// Finally write out the complete packet and send it off. // Finally write out the complete packet and send it off.