mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-20 06:53:00 +00:00
Merge branch 'skinchange_spectatorify' into 'master'
Skinchange Spectatorify Closes #305 See merge request KartKrew/Kart!936
This commit is contained in:
commit
8d33b5d6af
5 changed files with 177 additions and 131 deletions
195
src/d_netcmd.c
195
src/d_netcmd.c
|
|
@ -494,7 +494,7 @@ consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_NETVAR|CV_CALL|CV_NO
|
|||
static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {MAX_LAPS, "MAX"}, {0, "Map default"}, {0, NULL}};
|
||||
consvar_t cv_numlaps = CVAR_INIT ("numlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, numlaps_cons_t, NumLaps_OnChange);
|
||||
|
||||
consvar_t cv_forceskin = CVAR_INIT ("forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange);
|
||||
consvar_t cv_forceskin = CVAR_INIT ("forcecharacter", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange);
|
||||
|
||||
consvar_t cv_downloading = CVAR_INIT ("downloading", "On", 0, CV_OnOff, NULL);
|
||||
consvar_t cv_allowexitlevel = CVAR_INIT ("allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL);
|
||||
|
|
@ -1347,69 +1347,19 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
|||
}
|
||||
}
|
||||
|
||||
UINT8 CanChangeSkin(INT32 playernum)
|
||||
boolean CanChangeSkin(INT32 playernum)
|
||||
{
|
||||
(void)playernum;
|
||||
|
||||
// Of course we can change if we're not playing
|
||||
if (!Playing() || !addedtogame)
|
||||
return true;
|
||||
|
||||
// Force skin in effect.
|
||||
if (cv_forceskin.value != -1)
|
||||
if (cv_forceskin.value != -1 && K_CanChangeRules(true))
|
||||
return false;
|
||||
|
||||
// Can change skin in intermission and whatnot.
|
||||
if (gamestate != GS_LEVEL)
|
||||
return true;
|
||||
|
||||
// Server has skin change restrictions.
|
||||
if (cv_restrictskinchange.value)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
// Can change skin during initial countdown.
|
||||
if (leveltime < starttime)
|
||||
return true;
|
||||
|
||||
// Not in game, so you can change
|
||||
if (players[playernum].spectator)
|
||||
return true;
|
||||
|
||||
// Check for freeeplay
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (i == consoleplayer)
|
||||
continue;
|
||||
if (playeringame[i] && !players[i].spectator && gamestate == GS_LEVEL)
|
||||
return false; // Not freeplay!
|
||||
}
|
||||
|
||||
// if we've gotten here, then it's freeplay, and switching anytime is fair game.
|
||||
return true;
|
||||
}
|
||||
// if restrictskinchange is off and we're trying to change skins, don't allow changing skins while moving after the race has started.
|
||||
else if (gamestate == GS_LEVEL && leveltime >= starttime)
|
||||
return (!P_PlayerMoving(playernum));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean CanChangeSkinWhilePlaying(INT32 playernum)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
// Force skin in effect.
|
||||
if ((cv_forceskin.value != -1))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (D_IsPlayerHumanAndGaming(i) &&
|
||||
!P_IsLocalPlayer(&players[i]))
|
||||
{
|
||||
return CanChangeSkin(playernum);
|
||||
}
|
||||
}
|
||||
// ... there used to be a lot more here, but it's now handled in Got_NameAndColor.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1616,6 +1566,47 @@ static void SendNameAndColor(UINT8 n)
|
|||
SendNetXCmdForPlayer(n, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void FinalisePlaystateChange(INT32 playernum)
|
||||
{
|
||||
demo_extradata[playernum] |= DXD_PLAYSTATE;
|
||||
|
||||
// Clear player score and rings if a spectator.
|
||||
if (players[playernum].spectator)
|
||||
{
|
||||
if (gametyperules & GTR_POINTLIMIT) // SRB2kart
|
||||
{
|
||||
players[playernum].roundscore = 0;
|
||||
K_CalculateBattleWanted();
|
||||
}
|
||||
|
||||
K_PlayerForfeit(playernum, true);
|
||||
|
||||
if (players[playernum].mo)
|
||||
players[playernum].mo->health = 1;
|
||||
|
||||
K_StripItems(&players[playernum]);
|
||||
}
|
||||
|
||||
// Reset away view (some code referenced from P_SpectatorJoinGame)
|
||||
{
|
||||
UINT8 i = 0;
|
||||
INT32 *localplayertable = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers);
|
||||
|
||||
for (i = 0; i <= r_splitscreen; i++)
|
||||
{
|
||||
if (localplayertable[i] == playernum)
|
||||
{
|
||||
LUA_HookViewpointSwitch(players+playernum, players+playernum, true);
|
||||
displayplayers[i] = playernum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
K_CheckBumpers(); // SRB2Kart
|
||||
P_CheckRacers(); // also SRB2Kart
|
||||
}
|
||||
|
||||
static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
player_t *p = &players[playernum];
|
||||
|
|
@ -1693,8 +1684,46 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
|||
CV_StealthSet(&cv_skin[localplayer], skins[forcedskin].name);
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT8 oldskin = players[playernum].skin;
|
||||
|
||||
SetPlayerSkinByNum(playernum, skin);
|
||||
|
||||
// The following is a miniature subset of Got_Teamchange.
|
||||
if ((gamestate == GS_LEVEL) // In a level?
|
||||
&& (cv_restrictskinchange.value) // Skin changes are restricted?
|
||||
&& (G_GametypeHasSpectators() && players[playernum].spectator == false) // not a spectator but could be?
|
||||
&& (players[playernum].jointime > 1) // permit on join
|
||||
&& (leveltime > introtime) // permit during intro turnaround
|
||||
&& (players[playernum].skin != oldskin)) // a skin change actually happened?
|
||||
{
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (i == playernum)
|
||||
continue;
|
||||
if (!playeringame[i])
|
||||
continue;
|
||||
if (players[i].spectator)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i != MAXPLAYERS // Someone on your server who isn't you?
|
||||
&& LUA_HookTeamSwitch(&players[playernum], 0, false, false, false)) // fiiiine, lua can except it
|
||||
{
|
||||
P_DamageMobj(players[playernum].mo, NULL, NULL, 1, DMG_SPECTATOR);
|
||||
players[playernum].playerstate = PST_REBORN;
|
||||
|
||||
players[playernum].pflags &= ~PF_WANTSTOJOIN;
|
||||
players[playernum].spectator = true;
|
||||
|
||||
HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false);
|
||||
|
||||
FinalisePlaystateChange(playernum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set follower colour:
|
||||
// Don't bother doing garbage and kicking if we receive None,
|
||||
// this is both silly and a waste of time,
|
||||
|
|
@ -3700,7 +3729,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
|||
|
||||
//Safety first!
|
||||
// (not respawning spectators here...)
|
||||
if (!players[playernum].spectator)
|
||||
if (!players[playernum].spectator && gamestate == GS_LEVEL)
|
||||
{
|
||||
if (players[playernum].mo)
|
||||
{
|
||||
|
|
@ -3764,22 +3793,6 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
|||
else if (NetPacket.packet.newteam == 0)
|
||||
HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false); // "entered the game" text was moved to P_SpectatorJoinGame
|
||||
|
||||
// Reset away view (some code referenced from P_SpectatorJoinGame)
|
||||
{
|
||||
UINT8 i = 0;
|
||||
INT32 *localplayertable = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers);
|
||||
|
||||
for (i = 0; i <= r_splitscreen; i++)
|
||||
{
|
||||
if (localplayertable[i] == playernum)
|
||||
{
|
||||
LUA_HookViewpointSwitch(players+playernum, players+playernum, true);
|
||||
displayplayers[i] = playernum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (G_GametypeHasTeams())
|
||||
{
|
||||
if (NetPacket.packet.newteam)
|
||||
|
|
@ -3796,27 +3809,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
|||
if (gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
demo_extradata[playernum] |= DXD_PLAYSTATE;
|
||||
|
||||
// Clear player score and rings if a spectator.
|
||||
if (players[playernum].spectator)
|
||||
{
|
||||
if (gametyperules & GTR_POINTLIMIT) // SRB2kart
|
||||
{
|
||||
players[playernum].roundscore = 0;
|
||||
K_CalculateBattleWanted();
|
||||
}
|
||||
|
||||
K_PlayerForfeit(playernum, true);
|
||||
|
||||
if (players[playernum].mo)
|
||||
players[playernum].mo->health = 1;
|
||||
|
||||
K_StripItems(&players[playernum]);
|
||||
}
|
||||
|
||||
K_CheckBumpers(); // SRB2Kart
|
||||
P_CheckRacers(); // also SRB2Kart
|
||||
FinalisePlaystateChange(playernum);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -6116,14 +6109,14 @@ static void Command_Automate_Set(void)
|
|||
static void ForceSkin_OnChange(void)
|
||||
{
|
||||
// NOT in SP, silly!
|
||||
if (!(netgame || multiplayer))
|
||||
if (!Playing() || !K_CanChangeRules(true))
|
||||
return;
|
||||
|
||||
if (cv_forceskin.value < 0)
|
||||
CONS_Printf("The server has lifted the forced skin restrictions.\n");
|
||||
CONS_Printf("The server has lifted the forced character restrictions.\n");
|
||||
else
|
||||
{
|
||||
CONS_Printf("The server is restricting all players to skin \"%s\".\n",cv_forceskin.string);
|
||||
CONS_Printf("The server is restricting all players to \"%s\".\n",cv_forceskin.string);
|
||||
ForceAllSkins(cv_forceskin.value);
|
||||
}
|
||||
}
|
||||
|
|
@ -6244,7 +6237,7 @@ static void Skin_OnChange(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (CanChangeSkinWhilePlaying(consoleplayer))
|
||||
if (CanChangeSkin(consoleplayer))
|
||||
{
|
||||
SendNameAndColor(0);
|
||||
}
|
||||
|
|
@ -6265,7 +6258,7 @@ static void Skin2_OnChange(void)
|
|||
if (!Playing() || !splitscreen)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkinWhilePlaying(g_localplayers[1]))
|
||||
if (CanChangeSkin(g_localplayers[1]))
|
||||
SendNameAndColor(1);
|
||||
else
|
||||
{
|
||||
|
|
@ -6279,7 +6272,7 @@ static void Skin3_OnChange(void)
|
|||
if (!Playing() || splitscreen < 2)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkinWhilePlaying(g_localplayers[2]))
|
||||
if (CanChangeSkin(g_localplayers[2]))
|
||||
SendNameAndColor(2);
|
||||
else
|
||||
{
|
||||
|
|
@ -6293,7 +6286,7 @@ static void Skin4_OnChange(void)
|
|||
if (!Playing() || splitscreen < 3)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkinWhilePlaying(g_localplayers[3]))
|
||||
if (CanChangeSkin(g_localplayers[3]))
|
||||
SendNameAndColor(3);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -285,8 +285,7 @@ void LiveStudioAudience(void);
|
|||
void D_Cheat(INT32 playernum, INT32 cheat, ...);
|
||||
|
||||
// used for the player setup menu
|
||||
UINT8 CanChangeSkin(INT32 playernum);
|
||||
boolean CanChangeSkinWhilePlaying(INT32 playernum);
|
||||
boolean CanChangeSkin(INT32 playernum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include "k_follower.h"
|
||||
#include "d_player.h" // KITEM_ constants
|
||||
#include "doomstat.h" // MAXSPLITSCREENPLAYERS
|
||||
#include "k_grandprix.h" // K_CanChangeRules
|
||||
|
||||
#include "i_joy.h" // for joystick menu controls
|
||||
|
||||
|
|
@ -1689,6 +1690,7 @@ void M_DrawCharacterSelect(void)
|
|||
INT16 quadx, quady;
|
||||
INT16 skin;
|
||||
INT32 basex = optionsmenu.profile != NULL ? 64 : 0;
|
||||
boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1);
|
||||
|
||||
if (setup_numplayers > 0)
|
||||
{
|
||||
|
|
@ -1696,6 +1698,8 @@ void M_DrawCharacterSelect(void)
|
|||
}
|
||||
|
||||
// We have to loop twice -- first time to draw the drop shadows, a second time to draw the icons.
|
||||
if (forceskin == false)
|
||||
{
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
for (j = 0; j < 9; j++)
|
||||
|
|
@ -1718,6 +1722,7 @@ void M_DrawCharacterSelect(void)
|
|||
V_DrawScaledPatch(basex+ 82 + (i*16) + quadx + 1, 22 + (j*16) + quady + 1, 0, W_CachePatchName("ICONBACK", PU_CACHE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw this inbetween. These drop shadows should be covered by the stat graph, but the icons shouldn't.
|
||||
V_DrawScaledPatch(basex+ 3, 2, 0, W_CachePatchName((optionsmenu.profile ? "PR_STGRPH" : "STATGRPH"), PU_CACHE));
|
||||
|
|
@ -1725,8 +1730,22 @@ void M_DrawCharacterSelect(void)
|
|||
// Draw the icons now
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
if ((forceskin == true) && (i != skins[cv_forceskin.value].kartspeed-1))
|
||||
continue;
|
||||
|
||||
for (j = 0; j < 9; j++)
|
||||
{
|
||||
if (forceskin == true)
|
||||
{
|
||||
if (j != skins[cv_forceskin.value].kartweight-1)
|
||||
continue;
|
||||
skin = cv_forceskin.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
skin = setup_chargrid[i][j].skinlist[setup_page];
|
||||
}
|
||||
|
||||
for (k = 0; k < setup_numplayers; k++)
|
||||
{
|
||||
if (setup_player[k].mdepth < CSSTEP_ASKCHANGES)
|
||||
|
|
@ -1736,7 +1755,6 @@ void M_DrawCharacterSelect(void)
|
|||
break; // k == setup_numplayers means no one has it selected
|
||||
}
|
||||
|
||||
skin = setup_chargrid[i][j].skinlist[setup_page];
|
||||
quadx = 4 * (i / 3);
|
||||
quady = 4 * (j / 3);
|
||||
|
||||
|
|
@ -1752,7 +1770,7 @@ void M_DrawCharacterSelect(void)
|
|||
V_DrawMappedPatch(basex + 82 + (i*16) + quadx, 22 + (j*16) + quady, 0, faceprefix[skin][FACE_RANK], colormap);
|
||||
|
||||
// draw dot if there are more alts behind there!
|
||||
if (setup_page+1 < setup_chargrid[i][j].numskins)
|
||||
if (forceskin == false && setup_page+1 < setup_chargrid[i][j].numskins)
|
||||
V_DrawScaledPatch(basex + 82 + (i*16) + quadx, 22 + (j*16) + quady + 11, 0, W_CachePatchName("ALTSDOT", PU_CACHE));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,6 +433,9 @@ menu_t *M_SpecificMenuRestore(menu_t *torestore)
|
|||
M_MPOptSelectInit(-1);
|
||||
}
|
||||
|
||||
// One last catch.
|
||||
PLAY_CharSelectDef.prevMenu = &MainDef;
|
||||
|
||||
return torestore;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../k_menu.h"
|
||||
#include "../r_skins.h"
|
||||
#include "../s_sound.h"
|
||||
#include "../k_grandprix.h" // K_CanChangeRules
|
||||
|
||||
menuitem_t PLAY_CharSelect[] =
|
||||
{
|
||||
|
|
@ -789,6 +790,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
|||
{
|
||||
UINT8 numclones;
|
||||
INT32 skin;
|
||||
boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1);
|
||||
|
||||
if (cv_splitdevice.value)
|
||||
num = 0;
|
||||
|
|
@ -847,6 +849,21 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
|||
p->clonenum = 0;
|
||||
|
||||
if (M_MenuConfirmPressed(num) /*|| M_MenuButtonPressed(num, MBT_START)*/)
|
||||
{
|
||||
if (forceskin)
|
||||
{
|
||||
if ((p->gridx != skins[cv_forceskin.value].kartspeed-1)
|
||||
|| (p->gridy != skins[cv_forceskin.value].kartweight-1))
|
||||
{
|
||||
S_StartSound(NULL, sfx_s3k7b); //sfx_s3kb2
|
||||
}
|
||||
else
|
||||
{
|
||||
p->mdepth = CSSTEP_COLORS;
|
||||
S_StartSound(NULL, sfx_s3k63);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
skin = setup_chargrid[p->gridx][p->gridy].skinlist[setup_page];
|
||||
if (setup_page >= setup_chargrid[p->gridx][p->gridy].numskins || skin == -1)
|
||||
|
|
@ -862,6 +879,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
|||
|
||||
S_StartSound(NULL, sfx_s3k63);
|
||||
}
|
||||
}
|
||||
|
||||
M_SetMenuDelay(num);
|
||||
}
|
||||
|
|
@ -884,7 +902,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
|||
M_SetMenuDelay(num);
|
||||
}
|
||||
|
||||
if (num == 0 && setup_numplayers == 1 && setup_maxpage) // ONLY one player.
|
||||
if (num == 0 && setup_numplayers == 1 && setup_maxpage && !forceskin) // ONLY one player.
|
||||
{
|
||||
if (M_MenuButtonPressed(num, MBT_L))
|
||||
{
|
||||
|
|
@ -961,6 +979,8 @@ static void M_HandleCharRotate(setup_player_t *p, UINT8 num)
|
|||
|
||||
static void M_HandleColorRotate(setup_player_t *p, UINT8 num)
|
||||
{
|
||||
boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1);
|
||||
|
||||
if (cv_splitdevice.value)
|
||||
num = 0;
|
||||
|
||||
|
|
@ -987,7 +1007,8 @@ static void M_HandleColorRotate(setup_player_t *p, UINT8 num)
|
|||
}
|
||||
else if (M_MenuBackPressed(num))
|
||||
{
|
||||
if (setup_chargrid[p->gridx][p->gridy].numskins == 1)
|
||||
if (forceskin
|
||||
|| setup_chargrid[p->gridx][p->gridy].numskins == 1)
|
||||
{
|
||||
p->mdepth = CSSTEP_CHARS; // Skip clones menu
|
||||
}
|
||||
|
|
@ -1253,6 +1274,7 @@ static void M_HandleFollowerColorRotate(setup_player_t *p, UINT8 num)
|
|||
boolean M_CharacterSelectHandler(INT32 choice)
|
||||
{
|
||||
INT32 i;
|
||||
boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1);
|
||||
|
||||
(void)choice;
|
||||
|
||||
|
|
@ -1318,7 +1340,18 @@ boolean M_CharacterSelectHandler(INT32 choice)
|
|||
}
|
||||
|
||||
// Just makes it easier to access later
|
||||
if (forceskin)
|
||||
{
|
||||
if (p->gridx != skins[cv_forceskin.value].kartspeed-1
|
||||
|| p->gridy != skins[cv_forceskin.value].kartweight-1)
|
||||
p->skin = -1;
|
||||
else
|
||||
p->skin = cv_forceskin.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum];
|
||||
}
|
||||
|
||||
// Keep profile colour.
|
||||
/*if (p->mdepth < CSSTEP_COLORS)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue