diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8a7bb772..008ad906 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -646,6 +646,9 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->jointime = (tic_t)LONG(players[i].jointime); rsp->spectatorreentry = (tic_t)LONG(players[i].spectatorreentry); + rsp->grieftime = (tic_t)LONG(players[i].grieftime); + rsp->griefstrikes = players[i].griefstrikes; + rsp->splitscreenindex = players[i].splitscreenindex; rsp->hasmo = false; @@ -770,6 +773,9 @@ static void resynch_read_player(resynch_pak *rsp) players[i].jointime = (tic_t)LONG(rsp->jointime); players[i].spectatorreentry = (tic_t)LONG(rsp->spectatorreentry); + players[i].grieftime = (tic_t)LONG(rsp->grieftime); + players[i].griefstrikes = rsp->griefstrikes; + players[i].splitscreenindex = rsp->splitscreenindex; //We get a packet for each player in game. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index c341c4ae..98aec37e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -284,6 +284,9 @@ typedef struct tic_t jointime; tic_t spectatorreentry; + tic_t grieftime; + UINT8 griefstrikes; + UINT8 splitscreenindex; //player->mo stuff diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7913a086..cd8c2318 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -250,6 +250,9 @@ consvar_t cv_ingamecap = {"ingamecap", "0", CV_NETVAR, ingamecap_cons_t, NULL, 0 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}; +static CV_PossibleValue_t antigrief_cons_t[] = {{20, "MIN"}, {60, "MAX"}, {0, "Off"}, {0, NULL}}; +consvar_t cv_antigrief = {"antigrief", "30", CV_NETVAR, antigrief_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}}; @@ -683,6 +686,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_allowteamchange); CV_RegisterVar(&cv_ingamecap); CV_RegisterVar(&cv_spectatorreentry); + CV_RegisterVar(&cv_antigrief); CV_RegisterVar(&cv_respawntime); CV_RegisterVar(&cv_killingdead); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1e158808..1348af03 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -94,6 +94,7 @@ extern consvar_t cv_killingdead; extern consvar_t cv_pause; extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_ingamecap, cv_respawntime; +extern consvar_t cv_spectatorreentry, cv_antigrief; /*extern consvar_t cv_teleporters, cv_superring, cv_supersneakers, cv_invincibility; extern consvar_t cv_jumpshield, cv_watershield, cv_ringshield, cv_forceshield, cv_bombshield; diff --git a/src/d_player.h b/src/d_player.h index 52a1e48e..0f9358ed 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -522,6 +522,9 @@ typedef struct player_s tic_t jointime; // Timer when player joins game to change skin/color tic_t spectatorreentry; + tic_t grieftime; + UINT8 griefstrikes; + UINT8 splitscreenindex; #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering diff --git a/src/g_game.c b/src/g_game.c index 94d14210..b6cc7b0c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2604,6 +2604,8 @@ void G_PlayerReborn(INT32 player) INT32 respawnflip; boolean songcredit = false; tic_t spectatorreentry; + tic_t grieftime; + UINT8 griefstrikes; score = players[player].score; marescore = players[player].marescore; @@ -2696,6 +2698,9 @@ void G_PlayerReborn(INT32 player) spectatorreentry = players[player].spectatorreentry; + grieftime = players[player].grieftime; + griefstrikes = players[player].griefstrikes; + p = &players[player]; memset(p, 0, sizeof (*p)); @@ -2748,7 +2753,10 @@ void G_PlayerReborn(INT32 player) p->kartstuff[k_wanted] = wanted; p->kartstuff[k_eggmanblame] = -1; p->kartstuff[k_starpostflip] = respawnflip; + p->spectatorreentry = spectatorreentry; + p->grieftime = grieftime; + p->griefstrikes = griefstrikes; // Don't do anything immediately p->pflags |= PF_USEDOWN; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 663e625c..26561a4d 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -382,8 +382,12 @@ 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") + else if (fastcmp(field,"spectatorreentry")) lua_pushinteger(L, plr->spectatorreentry); + else if (fastcmp(field,"grieftime")) + lua_pushinteger(L, plr->grieftime); + else if (fastcmp(field,"griefstrikes")) + lua_pushinteger(L, plr->griefstrikes); else if (fastcmp(field,"splitscreenindex")) lua_pushinteger(L, plr->splitscreenindex); #ifdef HWRENDER @@ -650,6 +654,10 @@ static int player_set(lua_State *L) 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,"grieftime")) + plr->grieftime = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"griefstrikes")) + plr->griefstrikes = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"splitscreenindex")) return NOSET; #ifdef HWRENDER diff --git a/src/p_inter.c b/src/p_inter.c index abb12811..7f7c8861 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1454,7 +1454,15 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { // blatant reuse of a variable that's normally unused in circuit if (!player->tossdelay) + { S_StartSound(toucher, sfx_s26d); + + if (netgame && cv_antigrief.value) + { + player->grieftime += TICRATE; + } + } + player->tossdelay = 3; return; } @@ -1478,6 +1486,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->starpostangle = special->angle; player->starpostnum = special->health; player->kartstuff[k_starpostflip] = special->spawnpoint->options & MTF_OBJECTFLIP; // store flipping + player->grieftime = 0; //S_StartSound(toucher, special->info->painsound); return; diff --git a/src/p_mobj.c b/src/p_mobj.c index 1cd7205e..6b58e235 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10730,6 +10730,8 @@ void P_SpawnPlayer(INT32 playernum) // Spawn with a pity shield if necessary. //P_DoPityCheck(p); + p->grieftime = 0; + if (G_BattleGametype()) // SRB2kart { mobj_t *overheadarrow = P_SpawnMobj(mobj->x, mobj->y, mobj->z + P_GetPlayerHeight(p)+16*FRACUNIT, MT_PLAYERARROW); diff --git a/src/p_saveg.c b/src/p_saveg.c index 178a844c..3a29269b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -248,6 +248,9 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].jointime); WRITEUINT32(save_p, players[i].spectatorreentry); + WRITEUINT32(save_p, players[i].grieftime); + WRITEUINT8(save_p, players[i].griefstrikes); + WRITEUINT8(save_p, players[i].splitscreenindex); WRITEUINT16(save_p, flags); @@ -414,6 +417,9 @@ static void P_NetUnArchivePlayers(void) players[i].jointime = READUINT32(save_p); players[i].spectatorreentry = READUINT32(save_p); + players[i].grieftime = READUINT32(save_p); + players[i].griefstrikes = READUINT8(save_p); + players[i].splitscreenindex = READUINT8(save_p); flags = READUINT16(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 04d69c9b..73f6938e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4316,12 +4316,21 @@ DoneSection2: nospectategrief = nump; thwompsactive = true; // Lap 2 effects + player->grieftime = 0; } else if (player->starpostnum) { // blatant reuse of a variable that's normally unused in circuit if (!player->tossdelay) + { S_StartSound(player->mo, sfx_s26d); + + if (netgame && cv_antigrief.value) + { + player->grieftime += TICRATE; + } + } + player->tossdelay = 3; } diff --git a/src/p_user.c b/src/p_user.c index cb6b7bd6..6b1e35d0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8489,6 +8489,55 @@ void P_PlayerThink(player_t *player) } } + if (netgame && cv_antigrief.value != 0) + { + if (!player->spectator && !player->exiting && !(player->pflags & PF_TIMEOVER)) + { + const tic_t griefval = cv_antigrief.value * TICRATE; + const UINT8 n = player - players; + + if (n != serverplayer && !IsPlayerAdmin(n)) + { + if (player->grieftime > griefval) + { + player->griefstrikes++; + player->grieftime = 0; + + if (server) + { + if (player->griefstrikes > 2) + { + // Send kick + XBOXSTATIC UINT8 buf[2]; + + buf[0] = n; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + else + { + // Send spectate + changeteam_union NetPacket; + UINT16 usvalue; + + NetPacket.value.l = NetPacket.value.b = 0; + NetPacket.packet.newteam = 0; + NetPacket.packet.playernum = n; + NetPacket.packet.verification = true; + + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); + SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + } + } + } + else + { + player->grieftime++; + } + } + } + } + if ((netgame || multiplayer) && player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing]) { player->pflags ^= PF_WANTSTOJOIN;