mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 13:21:10 +00:00
startedInFreePlay
This commit is contained in:
parent
71d49bcc3b
commit
fce57a1027
8 changed files with 109 additions and 27 deletions
|
@ -2972,6 +2972,23 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
|
||||||
K_CheckBumpers();
|
K_CheckBumpers();
|
||||||
else if (G_RaceGametype())
|
else if (G_RaceGametype())
|
||||||
P_CheckRacers();
|
P_CheckRacers();
|
||||||
|
|
||||||
|
// Reset startedInFreePlay
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (playeringame[i] && !players[i].spectator)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == MAXPLAYERS)
|
||||||
|
{
|
||||||
|
// Server was emptied, consider it FREE PLAY.
|
||||||
|
startedInFreePlay = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CL_Reset(void)
|
void CL_Reset(void)
|
||||||
|
@ -3412,6 +3429,10 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
|
||||||
HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false);
|
HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false);
|
||||||
kickreason = KR_LEAVE;
|
kickreason = KR_LEAVE;
|
||||||
break;
|
break;
|
||||||
|
case KICK_MSG_GRIEF:
|
||||||
|
HU_AddChatText(va("\x82*%s has been kicked (Automatic grief detection)", player_names[pnum]), false);
|
||||||
|
kickreason = KR_KICK;
|
||||||
|
break;
|
||||||
case KICK_MSG_BANNED:
|
case KICK_MSG_BANNED:
|
||||||
HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false);
|
HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false);
|
||||||
kickreason = KR_BAN;
|
kickreason = KR_BAN;
|
||||||
|
|
|
@ -521,17 +521,18 @@ extern consvar_t cv_playbackspeed;
|
||||||
#define KICK_MSG_TIMEOUT 4
|
#define KICK_MSG_TIMEOUT 4
|
||||||
#define KICK_MSG_BANNED 5
|
#define KICK_MSG_BANNED 5
|
||||||
#define KICK_MSG_PING_HIGH 6
|
#define KICK_MSG_PING_HIGH 6
|
||||||
#define KICK_MSG_CUSTOM_KICK 7
|
#define KICK_MSG_GRIEF 7
|
||||||
#define KICK_MSG_CUSTOM_BAN 8
|
#define KICK_MSG_CUSTOM_KICK 8
|
||||||
|
#define KICK_MSG_CUSTOM_BAN 9
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
KR_KICK = 1, //Kicked by server
|
KR_KICK = 1, //Kicked by server
|
||||||
KR_PINGLIMIT = 2, //Broke Ping Limit
|
KR_PINGLIMIT, //Broke Ping Limit
|
||||||
KR_SYNCH = 3, //Synch Failure
|
KR_SYNCH, //Synch Failure
|
||||||
KR_TIMEOUT = 4, //Connection Timeout
|
KR_TIMEOUT, //Connection Timeout
|
||||||
KR_BAN = 5, //Banned by server
|
KR_BAN, //Banned by server
|
||||||
KR_LEAVE = 6, //Quit the game
|
KR_LEAVE, //Quit the game
|
||||||
|
|
||||||
} kickreason_t;
|
} kickreason_t;
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,7 @@ tic_t mapreset; // Map reset delay when enough players have joined an empty game
|
||||||
UINT8 nospectategrief; // How many players need to be in-game to eliminate last; for preventing spectate griefing
|
UINT8 nospectategrief; // How many players need to be in-game to eliminate last; for preventing spectate griefing
|
||||||
boolean thwompsactive; // Thwomps activate on lap 2
|
boolean thwompsactive; // Thwomps activate on lap 2
|
||||||
SINT8 spbplace; // SPB exists, give the person behind better items
|
SINT8 spbplace; // SPB exists, give the person behind better items
|
||||||
|
boolean startedInFreePlay; // Map was started in free play
|
||||||
|
|
||||||
// Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players)
|
// Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players)
|
||||||
boolean legitimateexit; // Did this client actually finish the match?
|
boolean legitimateexit; // Did this client actually finish the match?
|
||||||
|
@ -2482,7 +2483,9 @@ void G_Ticker(boolean run)
|
||||||
if (G_GametypeHasSpectators()
|
if (G_GametypeHasSpectators()
|
||||||
&& (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING // definitely good
|
&& (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING // definitely good
|
||||||
|| gamestate == GS_WAITINGPLAYERS)) // definitely a problem if we don't do it at all in this gamestate, but might need more protection?
|
|| gamestate == GS_WAITINGPLAYERS)) // definitely a problem if we don't do it at all in this gamestate, but might need more protection?
|
||||||
|
{
|
||||||
K_CheckSpectateStatus();
|
K_CheckSpectateStatus();
|
||||||
|
}
|
||||||
|
|
||||||
if (pausedelay)
|
if (pausedelay)
|
||||||
pausedelay--;
|
pausedelay--;
|
||||||
|
|
45
src/k_kart.c
45
src/k_kart.c
|
@ -6316,6 +6316,10 @@ void K_CheckSpectateStatus(void)
|
||||||
if (numingame < 2 || leveltime < starttime || mapreset)
|
if (numingame < 2 || leveltime < starttime || mapreset)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// DON'T allow if the match is 20 seconds in
|
||||||
|
if (leveltime > (starttime + 20*TICRATE))
|
||||||
|
return;
|
||||||
|
|
||||||
// DON'T allow if the race is on the second lap
|
// DON'T allow if the race is on the second lap
|
||||||
if (G_RaceGametype() && players[i].laps)
|
if (G_RaceGametype() && players[i].laps)
|
||||||
return;
|
return;
|
||||||
|
@ -6331,15 +6335,11 @@ void K_CheckSpectateStatus(void)
|
||||||
respawnlist[numjoiners++] = i;
|
respawnlist[numjoiners++] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.4: prevent last lap jerkitude
|
// The map started as a legitimate race, but there's still the one player.
|
||||||
if (gamestate == GS_LEVEL)
|
// Don't allow new joiners, as they're probably a ragespeccer.
|
||||||
|
if (G_RaceGametype() && startedInFreePlay == false && numingame == 1)
|
||||||
{
|
{
|
||||||
if (!numingame) // but allow empty netgames to recover
|
return;
|
||||||
nospectategrief = 0;
|
|
||||||
else if (!nospectategrief && (leveltime > (starttime + 20*TICRATE)))
|
|
||||||
nospectategrief = numingame;
|
|
||||||
if (nospectategrief > 1)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// literally zero point in going any further if nobody is joining
|
// literally zero point in going any further if nobody is joining
|
||||||
|
@ -6391,13 +6391,40 @@ void K_CheckSpectateStatus(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the match if you're in an empty server
|
// Reset the match if you're in an empty server
|
||||||
if (!mapreset && gamestate == GS_LEVEL && leveltime >= starttime && (previngame < 2 && numingame >= 2))
|
if (!mapreset && gamestate == GS_LEVEL && (previngame < 2 && numingame >= 2))
|
||||||
{
|
{
|
||||||
S_ChangeMusicInternal("chalng", false); // COME ON
|
S_ChangeMusicInternal("chalng", false); // COME ON
|
||||||
mapreset = 3*TICRATE; // Even though only the server uses this for game logic, set for everyone for HUD
|
mapreset = 3*TICRATE; // Even though only the server uses this for game logic, set for everyone for HUD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void K_UpdateSpectateGrief(void)
|
||||||
|
{
|
||||||
|
UINT8 numingame = 0;
|
||||||
|
|
||||||
|
if (nospectategrief)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leveltime <= (starttime + 20*TICRATE))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (!playeringame[i] || players[i].spectator)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
numingame++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nospectategrief = numingame;
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//{ SRB2kart HUD Code
|
//{ SRB2kart HUD Code
|
||||||
|
|
|
@ -3278,6 +3278,7 @@ static void P_NetArchiveMisc(void)
|
||||||
WRITEUINT8(save_p, nospectategrief);
|
WRITEUINT8(save_p, nospectategrief);
|
||||||
WRITEUINT8(save_p, thwompsactive);
|
WRITEUINT8(save_p, thwompsactive);
|
||||||
WRITESINT8(save_p, spbplace);
|
WRITESINT8(save_p, spbplace);
|
||||||
|
WRITEUINT8(save_p, startedInFreePlay);
|
||||||
|
|
||||||
// Is it paused?
|
// Is it paused?
|
||||||
if (paused)
|
if (paused)
|
||||||
|
@ -3387,6 +3388,7 @@ static inline boolean P_NetUnArchiveMisc(void)
|
||||||
nospectategrief = READUINT8(save_p);
|
nospectategrief = READUINT8(save_p);
|
||||||
thwompsactive = (boolean)READUINT8(save_p);
|
thwompsactive = (boolean)READUINT8(save_p);
|
||||||
spbplace = READSINT8(save_p);
|
spbplace = READSINT8(save_p);
|
||||||
|
startedInFreePlay = READUINT8(save_p);
|
||||||
|
|
||||||
// Is it paused?
|
// Is it paused?
|
||||||
if (READUINT8(save_p) == 0x2f)
|
if (READUINT8(save_p) == 0x2f)
|
||||||
|
|
|
@ -3229,6 +3229,37 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||||
G_RecordDemo(buf);
|
G_RecordDemo(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wantedcalcdelay = wantedfrequency*2;
|
||||||
|
indirectitemcooldown = 0;
|
||||||
|
hyubgone = 0;
|
||||||
|
mapreset = 0;
|
||||||
|
nospectategrief = 0;
|
||||||
|
thwompsactive = false;
|
||||||
|
spbplace = -1;
|
||||||
|
|
||||||
|
startedInFreePlay = false;
|
||||||
|
{
|
||||||
|
UINT8 nump = 0;
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (!playeringame[i] || players[i].spectator)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nump++;
|
||||||
|
if (nump == 2)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nump <= 1)
|
||||||
|
{
|
||||||
|
startedInFreePlay = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===========
|
// ===========
|
||||||
// landing point for netgames.
|
// landing point for netgames.
|
||||||
netgameskip:
|
netgameskip:
|
||||||
|
@ -3301,14 +3332,6 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||||
CV_SetValue(&cv_analog, false);
|
CV_SetValue(&cv_analog, false);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
wantedcalcdelay = wantedfrequency*2;
|
|
||||||
indirectitemcooldown = 0;
|
|
||||||
hyubgone = 0;
|
|
||||||
mapreset = 0;
|
|
||||||
nospectategrief = 0;
|
|
||||||
thwompsactive = false;
|
|
||||||
spbplace = -1;
|
|
||||||
|
|
||||||
// clear special respawning que
|
// clear special respawning que
|
||||||
iquehead = iquetail = 0;
|
iquehead = iquetail = 0;
|
||||||
|
|
||||||
|
|
|
@ -735,6 +735,11 @@ void P_Ticker(boolean run)
|
||||||
if (hyubgone > 0)
|
if (hyubgone > 0)
|
||||||
hyubgone--;
|
hyubgone--;
|
||||||
|
|
||||||
|
if (G_RaceGametype())
|
||||||
|
{
|
||||||
|
K_UpdateSpectateGrief();
|
||||||
|
}
|
||||||
|
|
||||||
if (G_BattleGametype())
|
if (G_BattleGametype())
|
||||||
{
|
{
|
||||||
if (wantedcalcdelay && --wantedcalcdelay <= 0)
|
if (wantedcalcdelay && --wantedcalcdelay <= 0)
|
||||||
|
|
|
@ -8504,7 +8504,7 @@ void P_PlayerThink(player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netgame && cv_antigrief.value != 0)
|
if (netgame && cv_antigrief.value != 0 && G_RaceGametype())
|
||||||
{
|
{
|
||||||
if (!player->spectator && !player->exiting && !(player->pflags & PF_TIMEOVER))
|
if (!player->spectator && !player->exiting && !(player->pflags & PF_TIMEOVER))
|
||||||
{
|
{
|
||||||
|
@ -8530,7 +8530,7 @@ void P_PlayerThink(player_t *player)
|
||||||
XBOXSTATIC UINT8 buf[2];
|
XBOXSTATIC UINT8 buf[2];
|
||||||
|
|
||||||
buf[0] = n;
|
buf[0] = n;
|
||||||
buf[1] = KICK_MSG_CON_FAIL;
|
buf[1] = KICK_MSG_GRIEF;
|
||||||
SendNetXCmd(XD_KICK, &buf, 2);
|
SendNetXCmd(XD_KICK, &buf, 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue