mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-03 14:42:53 +00:00
Merge branch 'musicataparty' into 'master'
Music at a party See merge request KartKrew/Kart!543
This commit is contained in:
commit
65feacc16c
6 changed files with 118 additions and 93 deletions
|
|
@ -1562,7 +1562,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
|||
demo_extradata[playernum] |= DXD_COLOR;
|
||||
|
||||
// normal player colors
|
||||
if (server && !P_IsLocalPlayer(p))
|
||||
if (server && !P_IsMachineLocalPlayer(p))
|
||||
{
|
||||
boolean kick = false;
|
||||
|
||||
|
|
@ -3461,15 +3461,20 @@ 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 view if you are changed, or viewing someone who was changed.
|
||||
if (playernum == consoleplayer || displayplayers[0] == playernum)
|
||||
// Reset away view (some code referenced from P_SpectatorJoinGame)
|
||||
{
|
||||
// Call ViewpointSwitch hooks here.
|
||||
// The viewpoint was forcibly changed.
|
||||
if (displayplayers[0] != consoleplayer) // You're already viewing yourself. No big deal.
|
||||
LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true);
|
||||
UINT8 i = 0;
|
||||
INT32 *localplayertable = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers);
|
||||
|
||||
displayplayers[0] = consoleplayer;
|
||||
for (i = 0; i < r_splitscreen; i++)
|
||||
{
|
||||
if (localplayertable[i] == playernum)
|
||||
{
|
||||
LUAh_ViewpointSwitch(players+playernum, players+playernum, true);
|
||||
displayplayers[i] = playernum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (G_GametypeHasTeams())
|
||||
|
|
|
|||
23
src/k_kart.c
23
src/k_kart.c
|
|
@ -6595,7 +6595,7 @@ static void K_UpdateInvincibilitySounds(player_t *player)
|
|||
{
|
||||
INT32 sfxnum = sfx_None;
|
||||
|
||||
if (player->mo->health > 0 && !P_IsDisplayPlayer(player))
|
||||
if (player->mo->health > 0 && !P_IsLocalPlayer(player)) // used to be !P_IsDisplayPlayer(player)
|
||||
{
|
||||
if (cv_kartinvinsfx.value)
|
||||
{
|
||||
|
|
@ -8987,10 +8987,16 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
|
|||
P_SetScale(overlay, player->mo->scale);
|
||||
}
|
||||
player->invincibilitytimer = itemtime+(2*TICRATE); // 10 seconds
|
||||
if (P_IsLocalPlayer(player))
|
||||
|
||||
if (P_IsLocalPlayer(player) == true)
|
||||
{
|
||||
S_ChangeMusicSpecial("kinvnc");
|
||||
if (! P_IsDisplayPlayer(player))
|
||||
S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kinvnc));
|
||||
}
|
||||
else //used to be "if (P_IsDisplayPlayer(player) == false)"
|
||||
{
|
||||
S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc));
|
||||
}
|
||||
|
||||
P_RestoreMusic(player);
|
||||
K_PlayPowerGloatSound(player->mo);
|
||||
player->itemamount--;
|
||||
|
|
@ -9214,12 +9220,15 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
|
|||
|
||||
player->growshrinktimer = itemtime+(4*TICRATE); // 12 seconds
|
||||
|
||||
if (P_IsLocalPlayer(player) == true)
|
||||
if (player->invincibilitytimer > 0)
|
||||
{
|
||||
; // invincibility has priority in P_RestoreMusic, no point in starting here
|
||||
}
|
||||
else if (P_IsLocalPlayer(player) == true)
|
||||
{
|
||||
S_ChangeMusicSpecial("kgrow");
|
||||
}
|
||||
|
||||
if (P_IsDisplayPlayer(player) == false)
|
||||
else //used to be "if (P_IsDisplayPlayer(player) == false)"
|
||||
{
|
||||
S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,6 +682,7 @@ static int lib_pSpawnLockOn(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (state >= NUMSTATES)
|
||||
return luaL_error(L, "state %d out of range (0 - %d)", state, NUMSTATES-1);
|
||||
#if 0
|
||||
if (P_IsLocalPlayer(player)) // Only display it on your own view.
|
||||
{
|
||||
mobj_t *visual = P_SpawnMobj(lockon->x, lockon->y, lockon->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker
|
||||
|
|
@ -689,6 +690,9 @@ static int lib_pSpawnLockOn(lua_State *L)
|
|||
visual->renderflags |= RF_DONTDRAW;
|
||||
P_SetMobjStateNF(visual, state);
|
||||
}
|
||||
#else
|
||||
CONS_Alert(CONS_WARNING, "TODO: P_SpawnLockOn is deprecated\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ void P_ResetPlayer(player_t *player);
|
|||
boolean P_PlayerCanDamage(player_t *player, mobj_t *thing);
|
||||
|
||||
boolean P_IsLocalPlayer(player_t *player);
|
||||
boolean P_IsMachineLocalPlayer(player_t *player);
|
||||
boolean P_IsDisplayPlayer(player_t *player);
|
||||
|
||||
void P_SetPlayerAngle(player_t *player, angle_t angle);
|
||||
|
|
|
|||
147
src/p_user.c
147
src/p_user.c
|
|
@ -812,6 +812,7 @@ void P_RestoreMusic(player_t *player)
|
|||
if (r_splitscreen)
|
||||
{
|
||||
INT32 bestlocaltimer = 1;
|
||||
INT32 *localplayertable = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers);
|
||||
|
||||
#define setbests(p) \
|
||||
if (players[p].playerstate == PST_LIVE) \
|
||||
|
|
@ -821,12 +822,12 @@ void P_RestoreMusic(player_t *player)
|
|||
else if (players[p].growshrinktimer > bestlocaltimer) \
|
||||
{ wantedmus = 2; bestlocaltimer = players[p].growshrinktimer; } \
|
||||
}
|
||||
setbests(displayplayers[0]);
|
||||
setbests(displayplayers[1]);
|
||||
setbests(localplayertable[0]);
|
||||
setbests(localplayertable[1]);
|
||||
if (r_splitscreen > 1)
|
||||
setbests(displayplayers[2]);
|
||||
setbests(localplayertable[2]);
|
||||
if (r_splitscreen > 2)
|
||||
setbests(displayplayers[3]);
|
||||
setbests(localplayertable[3]);
|
||||
#undef setbests
|
||||
}
|
||||
else
|
||||
|
|
@ -1069,19 +1070,16 @@ void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative)
|
|||
}
|
||||
|
||||
//
|
||||
// P_IsLocalPlayer
|
||||
// P_IsMachineLocalPlayer
|
||||
//
|
||||
// Returns true if player is
|
||||
// on the local machine.
|
||||
// ACTUALLY on the local machine
|
||||
//
|
||||
boolean P_IsLocalPlayer(player_t *player)
|
||||
boolean P_IsMachineLocalPlayer(player_t *player)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
if (demo.playback)
|
||||
return P_IsDisplayPlayer(player);
|
||||
|
||||
for (i = 0; i <= r_splitscreen; i++) // DON'T skip P1
|
||||
for (i = 0; i <= r_splitscreen; i++)
|
||||
{
|
||||
if (player == &players[g_localplayers[i]])
|
||||
return true;
|
||||
|
|
@ -1090,6 +1088,35 @@ boolean P_IsLocalPlayer(player_t *player)
|
|||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// P_IsLocalPlayer
|
||||
//
|
||||
// Returns true if player is
|
||||
// on the local machine
|
||||
// (or simulated party)
|
||||
//
|
||||
boolean P_IsLocalPlayer(player_t *player)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
// nobody is ever local when watching something back - you're a spectator there, even if your g_localplayers might say otherwise
|
||||
if (demo.playback)
|
||||
return false;
|
||||
|
||||
// parties - treat everyone as if it's couch co-op
|
||||
if (splitscreen_partied[consoleplayer])
|
||||
{
|
||||
for (i = 0; i < splitscreen_party_size[consoleplayer]; i++)
|
||||
{
|
||||
if (splitscreen_party[consoleplayer][i] == (player-players))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return P_IsMachineLocalPlayer(player);
|
||||
}
|
||||
|
||||
//
|
||||
// P_IsDisplayPlayer
|
||||
//
|
||||
|
|
@ -3538,19 +3565,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
|
||||
boolean P_SpectatorJoinGame(player_t *player)
|
||||
{
|
||||
INT32 changeto = 0;
|
||||
const char *text = NULL;
|
||||
|
||||
// Team changing isn't allowed.
|
||||
if (!cv_allowteamchange.value)
|
||||
{
|
||||
if (P_IsLocalPlayer(player))
|
||||
CONS_Printf(M_GetText("Server does not allow team change.\n"));
|
||||
//player->flashing = TICRATE + 1; //to prevent message spam.
|
||||
}
|
||||
return false;
|
||||
|
||||
// Team changing in Team Match and CTF
|
||||
// Pressing fire assigns you to a team that needs players if allowed.
|
||||
// Partial code reproduction from p_tick.c autobalance code.
|
||||
else if (G_GametypeHasTeams())
|
||||
// a surprise tool that will help us later...
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
INT32 changeto = 0;
|
||||
INT32 z, numplayersred = 0, numplayersblue = 0;
|
||||
|
||||
//find a team by num players, score, or random if all else fails.
|
||||
|
|
@ -3577,55 +3604,47 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
|
||||
if (!LUAh_TeamSwitch(player, changeto, true, false, false))
|
||||
return false;
|
||||
|
||||
if (player->mo)
|
||||
{
|
||||
P_RemoveMobj(player->mo);
|
||||
player->mo = NULL;
|
||||
}
|
||||
player->spectator = false;
|
||||
player->pflags &= ~PF_WANTSTOJOIN;
|
||||
player->spectatewait = 0;
|
||||
player->ctfteam = changeto;
|
||||
player->playerstate = PST_REBORN;
|
||||
|
||||
//Reset away view
|
||||
if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
|
||||
{
|
||||
// Call ViewpointSwitch hooks here.
|
||||
// The viewpoint was forcibly changed.
|
||||
LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
|
||||
displayplayers[0] = consoleplayer;
|
||||
}
|
||||
|
||||
if (changeto == 1)
|
||||
CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80');
|
||||
else if (changeto == 2)
|
||||
CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue team"), '\x80');
|
||||
|
||||
return true; // no more player->mo, cannot continue.
|
||||
}
|
||||
// Joining in game from firing.
|
||||
else
|
||||
|
||||
// no conditions that could cause the gamejoin to fail below this line
|
||||
|
||||
if (player->mo)
|
||||
{
|
||||
if (player->mo)
|
||||
{
|
||||
P_RemoveMobj(player->mo);
|
||||
player->mo = NULL;
|
||||
}
|
||||
player->spectator = false;
|
||||
player->pflags &= ~PF_WANTSTOJOIN;
|
||||
player->spectatewait = 0;
|
||||
player->playerstate = PST_REBORN;
|
||||
|
||||
//Reset away view
|
||||
if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
|
||||
displayplayers[0] = consoleplayer;
|
||||
|
||||
HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false);
|
||||
return true; // no more player->mo, cannot continue.
|
||||
P_RemoveMobj(player->mo);
|
||||
player->mo = NULL;
|
||||
}
|
||||
return false;
|
||||
player->spectator = false;
|
||||
player->pflags &= ~PF_WANTSTOJOIN;
|
||||
player->spectatewait = 0;
|
||||
player->ctfteam = changeto;
|
||||
player->playerstate = PST_REBORN;
|
||||
|
||||
// Reset away view (some code referenced from Got_Teamchange)
|
||||
{
|
||||
UINT8 i = 0;
|
||||
INT32 *localplayertable = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers);
|
||||
|
||||
for (i = 0; i < r_splitscreen; i++)
|
||||
{
|
||||
if (localplayertable[i] == (player-players))
|
||||
{
|
||||
LUAh_ViewpointSwitch(player, player, true);
|
||||
displayplayers[i] = (player-players);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// a surprise tool that will help us later...
|
||||
if (changeto == 1)
|
||||
text = va("\x82*%s switched to the %c%s%c team.\n", player_names[player-players], '\x85', "RED", '\x82');
|
||||
else if (changeto == 2)
|
||||
text = va("\x82*%s switched to the %c%s%c team.\n", player_names[player-players], '\x85', "BLU", '\x82');
|
||||
else
|
||||
text = va("\x82*%s entered the game.", player_names[player-players]);
|
||||
|
||||
HU_AddChatText(text, false);
|
||||
return true; // no more player->mo, cannot continue.
|
||||
}
|
||||
|
||||
// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam
|
||||
|
|
|
|||
|
|
@ -1074,20 +1074,7 @@ static void ST_overlayDrawer(void)
|
|||
{
|
||||
if (cv_showviewpointtext.value)
|
||||
{
|
||||
if (!(multiplayer && demo.playback))
|
||||
{
|
||||
if(!P_IsLocalPlayer(stplyr))
|
||||
{
|
||||
/*char name[MAXPLAYERNAME+1];
|
||||
// shorten the name if its more than twelve characters.
|
||||
strlcpy(name, player_names[stplyr-players], 13);*/
|
||||
|
||||
// Show name of player being displayed
|
||||
V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, 0, M_GetText("VIEWPOINT:"));
|
||||
V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_ALLOWLOWERCASE, player_names[stplyr-players]);
|
||||
}
|
||||
}
|
||||
else if (!demo.title)
|
||||
if (!demo.title && !P_IsLocalPlayer(stplyr))
|
||||
{
|
||||
if (!r_splitscreen)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue