mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 20:11:47 +00:00
Refactor PR_ApplyProfile and its ilk
- Reduces copypasted code. - Preperation for the next commit.
This commit is contained in:
parent
52c1cfd1cf
commit
8946bf9e01
2 changed files with 52 additions and 17 deletions
|
|
@ -402,18 +402,8 @@ skincolornum_t PR_GetProfileColor(profile_t *p)
|
||||||
return p->color;
|
return p->color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
static void PR_ApplyProfile_Appearance(profile_t *p, UINT8 playernum)
|
||||||
{
|
{
|
||||||
profile_t *p = PR_GetProfile(profilenum);
|
|
||||||
|
|
||||||
// this CAN happen!!
|
|
||||||
if (p == NULL)
|
|
||||||
{
|
|
||||||
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
|
||||||
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
|
||||||
p = PR_GetProfile(0); // Use guest profile instead if things went south somehow.
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_StealthSet(&cv_skin[playernum], p->skinname);
|
CV_StealthSet(&cv_skin[playernum], p->skinname);
|
||||||
CV_StealthSetValue(&cv_playercolor[playernum], PR_GetProfileColor(p));
|
CV_StealthSetValue(&cv_playercolor[playernum], PR_GetProfileColor(p));
|
||||||
CV_StealthSet(&cv_playername[playernum], p->playername);
|
CV_StealthSet(&cv_playername[playernum], p->playername);
|
||||||
|
|
@ -421,13 +411,19 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
||||||
// Followers
|
// Followers
|
||||||
CV_StealthSet(&cv_follower[playernum], p->follower);
|
CV_StealthSet(&cv_follower[playernum], p->follower);
|
||||||
CV_StealthSetValue(&cv_followercolor[playernum], p->followercolor);
|
CV_StealthSetValue(&cv_followercolor[playernum], p->followercolor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PR_ApplyProfile_Settings(profile_t *p, UINT8 playernum)
|
||||||
|
{
|
||||||
// toggles
|
// toggles
|
||||||
CV_StealthSetValue(&cv_kickstartaccel[playernum], p->kickstartaccel);
|
CV_StealthSetValue(&cv_kickstartaccel[playernum], p->kickstartaccel);
|
||||||
|
|
||||||
// set controls...
|
// set controls...
|
||||||
memcpy(&gamecontrol[playernum], p->controls, sizeof(gamecontroldefault));
|
memcpy(&gamecontrol[playernum], p->controls, sizeof(gamecontroldefault));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PR_ApplyProfile_Memory(UINT8 profilenum, UINT8 playernum)
|
||||||
|
{
|
||||||
// set memory cvar
|
// set memory cvar
|
||||||
CV_StealthSetValue(&cv_lastprofile[playernum], profilenum);
|
CV_StealthSetValue(&cv_lastprofile[playernum], profilenum);
|
||||||
|
|
||||||
|
|
@ -438,17 +434,51 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
||||||
|
{
|
||||||
|
profile_t *p = PR_GetProfile(profilenum);
|
||||||
|
|
||||||
|
// this CAN happen!!
|
||||||
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||||
|
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
||||||
|
p = PR_GetProfile(profilenum);
|
||||||
|
}
|
||||||
|
|
||||||
|
PR_ApplyProfile_Appearance(p, playernum);
|
||||||
|
PR_ApplyProfile_Settings(p, playernum);
|
||||||
|
PR_ApplyProfile_Memory(profilenum, playernum);
|
||||||
|
}
|
||||||
|
|
||||||
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum)
|
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum)
|
||||||
{
|
{
|
||||||
profile_t *p = PR_GetProfile(profilenum);
|
profile_t *p = PR_GetProfile(profilenum);
|
||||||
|
|
||||||
CV_StealthSet(&cv_skin[playernum], p->skinname);
|
// this CAN happen!!
|
||||||
CV_StealthSetValue(&cv_playercolor[playernum], p->color);
|
if (p == NULL)
|
||||||
CV_StealthSet(&cv_playername[playernum], p->playername);
|
{
|
||||||
|
// no need to be as loud...
|
||||||
|
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
||||||
|
p = PR_GetProfile(profilenum);
|
||||||
|
}
|
||||||
|
|
||||||
// Followers
|
PR_ApplyProfile_Appearance(p, playernum);
|
||||||
CV_StealthSet(&cv_follower[playernum], p->follower);
|
}
|
||||||
CV_StealthSetValue(&cv_followercolor[playernum], p->followercolor);
|
|
||||||
|
void PR_ApplyProfilePretend(UINT8 profilenum, UINT8 playernum)
|
||||||
|
{
|
||||||
|
profile_t *p = PR_GetProfile(profilenum);
|
||||||
|
|
||||||
|
// this CAN happen!!
|
||||||
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||||
|
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
||||||
|
p = PR_GetProfile(profilenum);
|
||||||
|
}
|
||||||
|
|
||||||
|
PR_ApplyProfile_Memory(profilenum, playernum);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 PR_GetProfileNum(profile_t *p)
|
UINT8 PR_GetProfileNum(profile_t *p)
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,11 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum);
|
||||||
// Controls, kickstartaccel and "current profile" data is *not* modified.
|
// Controls, kickstartaccel and "current profile" data is *not* modified.
|
||||||
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum);
|
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum);
|
||||||
|
|
||||||
|
// PR_ApplyProfilePretend(UINT8 profilenum, UINT8 playernum)
|
||||||
|
// ONLY modifies "current profile" data.
|
||||||
|
// Exists because any other option inteferes with rapid testing.
|
||||||
|
void PR_ApplyProfilePretend(UINT8 profilenum, UINT8 playernum);
|
||||||
|
|
||||||
// PR_GetProfileNum(profile_t *p)
|
// PR_GetProfileNum(profile_t *p)
|
||||||
// Gets the profile's index # in profilesList
|
// Gets the profile's index # in profilesList
|
||||||
UINT8 PR_GetProfileNum(profile_t *p);
|
UINT8 PR_GetProfileNum(profile_t *p);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue