mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Spectator re-entry cooldown
This commit is contained in:
parent
ccf6584466
commit
e81a5ee0ca
9 changed files with 79 additions and 14 deletions
|
@ -644,6 +644,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i)
|
|||
rsp->onconveyor = LONG(players[i].onconveyor);
|
||||
|
||||
rsp->jointime = (tic_t)LONG(players[i].jointime);
|
||||
rsp->spectatorreentry = (tic_t)LONG(players[i].spectatorreentry);
|
||||
|
||||
rsp->splitscreenindex = players[i].splitscreenindex;
|
||||
|
||||
|
@ -767,6 +768,7 @@ static void resynch_read_player(resynch_pak *rsp)
|
|||
players[i].onconveyor = LONG(rsp->onconveyor);
|
||||
|
||||
players[i].jointime = (tic_t)LONG(rsp->jointime);
|
||||
players[i].spectatorreentry = (tic_t)LONG(rsp->spectatorreentry);
|
||||
|
||||
players[i].splitscreenindex = rsp->splitscreenindex;
|
||||
|
||||
|
|
|
@ -282,6 +282,7 @@ typedef struct
|
|||
INT32 onconveyor;
|
||||
|
||||
tic_t jointime;
|
||||
tic_t spectatorreentry;
|
||||
|
||||
UINT8 splitscreenindex;
|
||||
|
||||
|
|
|
@ -247,6 +247,9 @@ consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, N
|
|||
static CV_PossibleValue_t ingamecap_cons_t[] = {{0, "MIN"}, {MAXPLAYERS-1, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_ingamecap = {"ingamecap", "0", CV_NETVAR, ingamecap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t spectatorreentry_cons_t[] = {{0, "MIN"}, {10*60, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_spectatorreentry = {"spectatorreentry", "60", CV_NETVAR, spectatorreentry_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t respawntime_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
|
||||
|
@ -679,6 +682,7 @@ void D_RegisterServerCommands(void)
|
|||
CV_RegisterVar(&cv_restrictskinchange);
|
||||
CV_RegisterVar(&cv_allowteamchange);
|
||||
CV_RegisterVar(&cv_ingamecap);
|
||||
CV_RegisterVar(&cv_spectatorreentry);
|
||||
CV_RegisterVar(&cv_respawntime);
|
||||
CV_RegisterVar(&cv_killingdead);
|
||||
|
||||
|
@ -3703,12 +3707,15 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
|||
// Clear player score and rings if a spectator.
|
||||
if (players[playernum].spectator)
|
||||
{
|
||||
players[playernum].spectatorreentry = (cv_spectatorreentry.value * TICRATE);
|
||||
|
||||
if (G_BattleGametype()) // SRB2kart
|
||||
{
|
||||
players[playernum].marescore = 0;
|
||||
if (K_IsPlayerWanted(&players[playernum]))
|
||||
K_CalculateBattleWanted();
|
||||
}
|
||||
|
||||
players[playernum].health = 1;
|
||||
if (players[playernum].mo)
|
||||
players[playernum].mo->health = 1;
|
||||
|
|
|
@ -520,6 +520,7 @@ typedef struct player_s
|
|||
UINT8 bot;
|
||||
|
||||
tic_t jointime; // Timer when player joins game to change skin/color
|
||||
tic_t spectatorreentry;
|
||||
|
||||
UINT8 splitscreenindex;
|
||||
#ifdef HWRENDER
|
||||
|
|
14
src/g_game.c
14
src/g_game.c
|
@ -2603,6 +2603,7 @@ void G_PlayerReborn(INT32 player)
|
|||
INT32 wanted;
|
||||
INT32 respawnflip;
|
||||
boolean songcredit = false;
|
||||
tic_t spectatorreentry;
|
||||
|
||||
score = players[player].score;
|
||||
marescore = players[player].marescore;
|
||||
|
@ -2644,7 +2645,7 @@ void G_PlayerReborn(INT32 player)
|
|||
pity = players[player].pity;
|
||||
|
||||
// SRB2kart
|
||||
if (leveltime <= starttime)
|
||||
if (leveltime <= starttime || spectator == true)
|
||||
{
|
||||
itemroulette = 0;
|
||||
roulettetype = 0;
|
||||
|
@ -2655,6 +2656,14 @@ void G_PlayerReborn(INT32 player)
|
|||
comebackpoints = 0;
|
||||
wanted = 0;
|
||||
starpostwp = 0;
|
||||
|
||||
starposttime = 0;
|
||||
starpostx = 0;
|
||||
starposty = 0;
|
||||
starpostz = 0;
|
||||
starpostnum = 0;
|
||||
respawnflip = 0;
|
||||
starpostangle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2685,6 +2694,8 @@ void G_PlayerReborn(INT32 player)
|
|||
wanted = players[player].kartstuff[k_wanted];
|
||||
}
|
||||
|
||||
spectatorreentry = players[player].spectatorreentry;
|
||||
|
||||
p = &players[player];
|
||||
memset(p, 0, sizeof (*p));
|
||||
|
||||
|
@ -2737,6 +2748,7 @@ void G_PlayerReborn(INT32 player)
|
|||
p->kartstuff[k_wanted] = wanted;
|
||||
p->kartstuff[k_eggmanblame] = -1;
|
||||
p->kartstuff[k_starpostflip] = respawnflip;
|
||||
p->spectatorreentry = spectatorreentry;
|
||||
|
||||
// Don't do anything immediately
|
||||
p->pflags |= PF_USEDOWN;
|
||||
|
|
52
src/k_kart.c
52
src/k_kart.c
|
@ -6219,16 +6219,23 @@ void K_CheckSpectateStatus(void)
|
|||
{
|
||||
UINT8 respawnlist[MAXPLAYERS];
|
||||
UINT8 i, j, numingame = 0, numjoiners = 0;
|
||||
UINT8 previngame = 0;
|
||||
|
||||
// Maintain spectate wait timer
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (!playeringame[i])
|
||||
continue;
|
||||
|
||||
if (players[i].spectator && (players[i].pflags & PF_WANTSTOJOIN))
|
||||
players[i].kartstuff[k_spectatewait]++;
|
||||
else
|
||||
players[i].kartstuff[k_spectatewait] = 0;
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
players[i].spectatorreentry = 0;
|
||||
else if (players[i].spectatorreentry > 0)
|
||||
players[i].spectatorreentry--;
|
||||
}
|
||||
|
||||
// No one's allowed to join
|
||||
|
@ -6244,22 +6251,38 @@ void K_CheckSpectateStatus(void)
|
|||
if (!players[i].spectator)
|
||||
{
|
||||
numingame++;
|
||||
if (cv_ingamecap.value && numingame >= cv_ingamecap.value) // DON'T allow if you've hit the in-game player cap
|
||||
|
||||
// DON'T allow if you've hit the in-game player cap
|
||||
if (cv_ingamecap.value && numingame >= cv_ingamecap.value)
|
||||
return;
|
||||
if (gamestate != GS_LEVEL) // Allow if you're not in a level
|
||||
|
||||
// Allow if you're not in a level
|
||||
if (gamestate != GS_LEVEL)
|
||||
continue;
|
||||
if (players[i].exiting) // DON'T allow if anyone's exiting
|
||||
|
||||
// DON'T allow if anyone's exiting
|
||||
if (players[i].exiting)
|
||||
return;
|
||||
if (numingame < 2 || leveltime < starttime || mapreset) // Allow if the match hasn't started yet
|
||||
|
||||
// Allow if the match hasn't started yet
|
||||
if (numingame < 2 || leveltime < starttime || mapreset)
|
||||
continue;
|
||||
if (leveltime > (starttime + 20*TICRATE)) // DON'T allow if the match is 20 seconds in
|
||||
|
||||
// DON'T allow if the match is 20 seconds in
|
||||
if (leveltime > (starttime + 20*TICRATE))
|
||||
return;
|
||||
if (G_RaceGametype() && players[i].laps) // DON'T allow if the race is at 2 laps
|
||||
|
||||
// DON'T allow if the race is on the second lap
|
||||
if (G_RaceGametype() && players[i].laps)
|
||||
return;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (!(players[i].pflags & PF_WANTSTOJOIN))
|
||||
{
|
||||
// This spectator does not want to join.
|
||||
continue;
|
||||
}
|
||||
|
||||
respawnlist[numjoiners++] = i;
|
||||
}
|
||||
|
@ -6269,7 +6292,9 @@ void K_CheckSpectateStatus(void)
|
|||
return;
|
||||
|
||||
// Organize by spectate wait timer
|
||||
#if 0
|
||||
if (cv_ingamecap.value)
|
||||
#endif
|
||||
{
|
||||
UINT8 oldrespawnlist[MAXPLAYERS];
|
||||
memcpy(oldrespawnlist, respawnlist, numjoiners);
|
||||
|
@ -6293,16 +6318,25 @@ void K_CheckSpectateStatus(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Finally, we can de-spectate everyone!
|
||||
// Finally, we can de-spectate everyone in the list!
|
||||
previngame = numingame;
|
||||
|
||||
for (i = 0; i < numjoiners; i++)
|
||||
{
|
||||
if (cv_ingamecap.value && numingame+i >= cv_ingamecap.value) // Hit the in-game player cap while adding people?
|
||||
// Hit the in-game player cap while adding people? Get out of here
|
||||
if (cv_ingamecap.value > 0 && numingame >= cv_ingamecap.value)
|
||||
break;
|
||||
|
||||
// This person has their reentry cooldown active.
|
||||
if (players[i].spectatorreentry > 0 && numingame > 0)
|
||||
continue;
|
||||
|
||||
P_SpectatorJoinGame(&players[respawnlist[i]]);
|
||||
numingame++;
|
||||
}
|
||||
|
||||
// Reset the match if you're in an empty server
|
||||
if (!mapreset && gamestate == GS_LEVEL && leveltime >= starttime && (numingame < 2 && numingame+i >= 2)) // use previous i value
|
||||
if (!mapreset && gamestate == GS_LEVEL && leveltime >= starttime && (previngame < 2 && numingame >= 2))
|
||||
{
|
||||
S_ChangeMusicInternal("chalng", false); // COME ON
|
||||
mapreset = 3*TICRATE; // Even though only the server uses this for game logic, set for everyone for HUD
|
||||
|
|
|
@ -382,6 +382,8 @@ static int player_get(lua_State *L)
|
|||
lua_pushinteger(L, plr->bot);
|
||||
else if (fastcmp(field,"jointime"))
|
||||
lua_pushinteger(L, plr->jointime);
|
||||
else if (fastcmp(field,"spectatorreentry")
|
||||
lua_pushinteger(L, plr->spectatorreentry);
|
||||
else if (fastcmp(field,"splitscreenindex"))
|
||||
lua_pushinteger(L, plr->splitscreenindex);
|
||||
#ifdef HWRENDER
|
||||
|
@ -646,6 +648,8 @@ static int player_set(lua_State *L)
|
|||
return NOSET;
|
||||
else if (fastcmp(field,"jointime"))
|
||||
plr->jointime = (tic_t)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"spectatorreentry"))
|
||||
plr->spectatorreentry = (tic_t)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"splitscreenindex"))
|
||||
return NOSET;
|
||||
#ifdef HWRENDER
|
||||
|
|
10
src/p_mobj.c
10
src/p_mobj.c
|
@ -10650,10 +10650,7 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
else if (netgame && p->jointime <= 1 && pcount)
|
||||
{
|
||||
p->spectator = true;
|
||||
// Oni doesn't want this
|
||||
/*if (pcount == 1 || leveltime < starttime)
|
||||
p->pflags |= PF_WANTSTOJOIN;
|
||||
p->jointime = 2;*/
|
||||
p->spectatorreentry = (cv_spectatorreentry.value * TICRATE);
|
||||
}
|
||||
else if (multiplayer && !netgame)
|
||||
{
|
||||
|
@ -10667,6 +10664,8 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
// Spawn as a spectator,
|
||||
// yes even in splitscreen mode
|
||||
p->spectator = true;
|
||||
p->spectatorreentry = (cv_spectatorreentry.value * TICRATE);
|
||||
|
||||
if (playernum&1) p->skincolor = skincolor_redteam;
|
||||
else p->skincolor = skincolor_blueteam;
|
||||
|
||||
|
@ -10686,7 +10685,10 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
{
|
||||
// Fix stupid non spectator spectators.
|
||||
if (!p->spectator && !p->ctfteam)
|
||||
{
|
||||
p->spectator = true;
|
||||
p->spectatorreentry = (cv_spectatorreentry.value * TICRATE);
|
||||
}
|
||||
|
||||
// Fix team colors.
|
||||
// This code isn't being done right somewhere else. Oh well.
|
||||
|
|
|
@ -246,6 +246,7 @@ static void P_NetArchivePlayers(void)
|
|||
WRITEINT32(save_p, players[i].onconveyor);
|
||||
|
||||
WRITEUINT32(save_p, players[i].jointime);
|
||||
WRITEUINT32(save_p, players[i].spectatorreentry);
|
||||
|
||||
WRITEUINT8(save_p, players[i].splitscreenindex);
|
||||
|
||||
|
@ -411,6 +412,7 @@ static void P_NetUnArchivePlayers(void)
|
|||
players[i].onconveyor = READINT32(save_p);
|
||||
|
||||
players[i].jointime = READUINT32(save_p);
|
||||
players[i].spectatorreentry = READUINT32(save_p);
|
||||
|
||||
players[i].splitscreenindex = READUINT8(save_p);
|
||||
|
||||
|
|
Loading…
Reference in a new issue