Merge branch 'skinvarstuff' into 'next'

Update skin cvar from character select and compare against cvar when warping without a loaded file (resolves #1267, #1117, #1114, #1112)

Closes #1112, #1114, #1117, and #1267

See merge request STJr/SRB2!2467
This commit is contained in:
sphere 2024-06-03 14:19:44 +00:00
commit 6d68091f3f
4 changed files with 25 additions and 13 deletions

View file

@ -983,7 +983,7 @@ void D_StartTitle(void)
emeralds = 0; emeralds = 0;
memset(&luabanks, 0, sizeof(luabanks)); memset(&luabanks, 0, sizeof(luabanks));
lastmaploaded = 0; lastmaploaded = 0;
pickedchar = R_SkinAvailable(cv_defaultskin.string); pickedchar = R_SkinAvailable(cv_skin.string);
// In case someone exits out at the same time they start a time attack run, // In case someone exits out at the same time they start a time attack run,
// reset modeattacking // reset modeattacking

View file

@ -1363,11 +1363,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
axis = PlayerJoyAxis(ssplayer, JA_FIRENORMAL); axis = PlayerJoyAxis(ssplayer, JA_FIRENORMAL);
if (PLAYERINPUTDOWN(ssplayer, GC_FIRENORMAL) || (usejoystick && axis > 0)) if (PLAYERINPUTDOWN(ssplayer, GC_FIRENORMAL) || (usejoystick && axis > 0))
cmd->buttons |= BT_FIRENORMAL; cmd->buttons |= BT_FIRENORMAL;
// Toss flag button // Toss flag button
if (PLAYERINPUTDOWN(ssplayer, GC_TOSSFLAG)) if (PLAYERINPUTDOWN(ssplayer, GC_TOSSFLAG))
cmd->buttons |= BT_TOSSFLAG; cmd->buttons |= BT_TOSSFLAG;
// Shield button // Shield button
axis = PlayerJoyAxis(ssplayer, JA_SHIELD); axis = PlayerJoyAxis(ssplayer, JA_SHIELD);
if (PLAYERINPUTDOWN(ssplayer, GC_SHIELD) || (usejoystick && axis > 0)) if (PLAYERINPUTDOWN(ssplayer, GC_SHIELD) || (usejoystick && axis > 0))
@ -4018,7 +4018,7 @@ INT16 G_GetNextMap(boolean ignoretokens, boolean silent)
INT32 i; INT32 i;
INT16 newmapnum; INT16 newmapnum;
boolean spec = G_IsSpecialStage(gamemap); boolean spec = G_IsSpecialStage(gamemap);
// go to next level // go to next level
// newmapnum is 0-based, unlike gamemap // newmapnum is 0-based, unlike gamemap
if (nextmapoverride != 0) if (nextmapoverride != 0)
@ -4122,7 +4122,7 @@ INT16 G_GetNextMap(boolean ignoretokens, boolean silent)
if (spec && (!gottoken || ignoretokens) && !nextmapoverride) if (spec && (!gottoken || ignoretokens) && !nextmapoverride)
newmapnum = lastmap; // Exiting from a special stage? Go back to the game. Tails 08-11-2001 newmapnum = lastmap; // Exiting from a special stage? Go back to the game. Tails 08-11-2001
if (!(gametyperules & GTR_CAMPAIGN)) if (!(gametyperules & GTR_CAMPAIGN))
{ {
if (cv_advancemap.value == 0) // Stay on same map. if (cv_advancemap.value == 0) // Stay on same map.
@ -4130,7 +4130,7 @@ INT16 G_GetNextMap(boolean ignoretokens, boolean silent)
else if (cv_advancemap.value == 2) // Go to random map. else if (cv_advancemap.value == 2) // Go to random map.
newmapnum = RandMap(G_TOLFlag(gametype_to_use), prevmap); newmapnum = RandMap(G_TOLFlag(gametype_to_use), prevmap);
} }
return newmapnum; return newmapnum;
} }
@ -4140,7 +4140,7 @@ INT16 G_GetNextMap(boolean ignoretokens, boolean silent)
static void G_DoCompleted(void) static void G_DoCompleted(void)
{ {
INT32 i; INT32 i;
tokenlist = 0; // Reset the list tokenlist = 0; // Reset the list
if (modeattacking && pausedelay) if (modeattacking && pausedelay)
@ -4168,7 +4168,7 @@ static void G_DoCompleted(void)
//Get and set prevmap/nextmap //Get and set prevmap/nextmap
prevmap = (INT16)(gamemap-1); prevmap = (INT16)(gamemap-1);
nextmap = G_GetNextMap(false, false); nextmap = G_GetNextMap(false, false);
automapactive = false; automapactive = false;
// We are committed to this map now. // We are committed to this map now.

View file

@ -7000,7 +7000,10 @@ static void M_LevelSelectWarp(INT32 choice)
if (currentMenu == &SP_LevelSelectDef || currentMenu == &SP_PauseLevelSelectDef) if (currentMenu == &SP_LevelSelectDef || currentMenu == &SP_PauseLevelSelectDef)
{ {
if (cursaveslot > 0) // do we have a save slot to load? if (cursaveslot > 0) // do we have a save slot to load?
{
CV_StealthSet(&cv_skin, DEFAULTSKIN); // already handled by loadgame so we don't want this
G_LoadGame((UINT32)cursaveslot, startmap); // reload from SP save data: this is needed to keep score/lives/continues from reverting to defaults G_LoadGame((UINT32)cursaveslot, startmap); // reload from SP save data: this is needed to keep score/lives/continues from reverting to defaults
}
else // no save slot, start new game but keep the current skin else // no save slot, start new game but keep the current skin
{ {
M_ClearMenus(true); M_ClearMenus(true);
@ -8649,9 +8652,14 @@ static void M_LoadSelect(INT32 choice)
M_NewGame(); M_NewGame();
} }
else if (savegameinfo[saveSlotSelected-1].gamemap & 8192) // Completed else if (savegameinfo[saveSlotSelected-1].gamemap & 8192) // Completed
{
M_LoadGameLevelSelect(0); M_LoadGameLevelSelect(0);
}
else else
{
CV_StealthSet(&cv_skin, DEFAULTSKIN); // already handled by loadgame so we don't want this
G_LoadGame((UINT32)saveSlotSelected, 0); G_LoadGame((UINT32)saveSlotSelected, 0);
}
cursaveslot = saveSlotSelected; cursaveslot = saveSlotSelected;
} }
@ -9510,6 +9518,8 @@ static void M_ChoosePlayer(INT32 choice)
//lastmapsaved = 0; //lastmapsaved = 0;
gamecomplete = 0; gamecomplete = 0;
CV_StealthSet(&cv_skin, skins[skinnum]->name);
G_DeferedInitNew(ultmode, G_BuildMapName(startmap), skinnum, false, fromlevelselect); G_DeferedInitNew(ultmode, G_BuildMapName(startmap), skinnum, false, fromlevelselect);
COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this

View file

@ -1309,7 +1309,7 @@ static void SendNameAndColor(void)
SetColorLocal(consoleplayer, cv_playercolor.value); SetColorLocal(consoleplayer, cv_playercolor.value);
if (splitscreen) if (splitscreen || (!pickedchar && stricmp(cv_skin.string, skins[consoleplayer]->name) != 0))
SetSkinLocal(consoleplayer, R_SkinAvailable(cv_skin.string)); SetSkinLocal(consoleplayer, R_SkinAvailable(cv_skin.string));
else else
SetSkinLocal(consoleplayer, pickedchar); SetSkinLocal(consoleplayer, pickedchar);
@ -4609,7 +4609,7 @@ static void Command_ExitLevel_f(void)
SendNetXCmd(XD_EXITLEVEL, NULL, 0); SendNetXCmd(XD_EXITLEVEL, NULL, 0);
return; return;
} }
// Allow exiting without cheating if at least one player beat the level // Allow exiting without cheating if at least one player beat the level
// Consistent with just setting playersforexit to one // Consistent with just setting playersforexit to one
if (splitscreen || multiplayer) if (splitscreen || multiplayer)
@ -4623,7 +4623,7 @@ static void Command_ExitLevel_f(void)
continue; continue;
if (players[i].lives <= 0) if (players[i].lives <= 0)
continue; continue;
if ((players[i].pflags & PF_FINISHED) || players[i].exiting) if ((players[i].pflags & PF_FINISHED) || players[i].exiting)
{ {
SendNetXCmd(XD_EXITLEVEL, NULL, 0); SendNetXCmd(XD_EXITLEVEL, NULL, 0);
@ -4631,7 +4631,7 @@ static void Command_ExitLevel_f(void)
} }
} }
} }
// Only consider it a cheat if we're not allowed to go to the next map // Only consider it a cheat if we're not allowed to go to the next map
if (M_CampaignWarpIsCheat(gametype, G_GetNextMap(true, true) + 1, serverGamedata)) if (M_CampaignWarpIsCheat(gametype, G_GetNextMap(true, true) + 1, serverGamedata))
CONS_Alert(CONS_NOTICE, M_GetText("Cheats must be enabled to force exit to a locked level!\n")); CONS_Alert(CONS_NOTICE, M_GetText("Cheats must be enabled to force exit to a locked level!\n"));
@ -4770,7 +4770,7 @@ static void Command_Cheats_f(void)
G_SetUsedCheats(false); G_SetUsedCheats(false);
return; return;
} }
if (usedCheats) if (usedCheats)
CONS_Printf(M_GetText("Cheats are enabled, the game cannot be saved.\n")); CONS_Printf(M_GetText("Cheats are enabled, the game cannot be saved.\n"));
else else
@ -4942,6 +4942,8 @@ static boolean Skin2_CanChange(const char *valstr)
*/ */
static void Skin_OnChange(void) static void Skin_OnChange(void)
{ {
pickedchar = R_SkinAvailable(cv_skin.string);
if (!Playing()) if (!Playing())
return; return;