Skip to content

Commit

Permalink
#329 make g_knifeonly votable
Browse files Browse the repository at this point in the history
  • Loading branch information
krazykaze81 committed Apr 28, 2023
1 parent 75108bb commit e8aa669
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MAIN/ui_mp/menudef.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ If you have questions concerning this license or the applicable additional terms
#define CV_SVF_MATCHRESET 16
#define CV_SVF_MUTESPECS 32
#define CV_SVF_NEXTMAP 64
#define CV_SVF_PUB 128
#define CV_SVF_KNIFEONLY 128 // replaced pub
#define CV_SVF_REFEREE 256
#define CV_SVF_SHUFFLETEAMS 512
#define CV_SVF_SWAPTEAMS 1024
Expand Down
5 changes: 3 additions & 2 deletions src/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4610,7 +4610,7 @@ const voteType_t voteToggles[] =
{ "vote_allow_matchreset", CV_SVF_MATCHRESET },
{ "vote_allow_mutespecs", CV_SVF_MUTESPECS },
{ "vote_allow_nextmap", CV_SVF_NEXTMAP },
{ "vote_allow_pub", CV_SVF_PUB },
//{ "vote_allow_pub", CV_SVF_PUB }, // not used
{ "vote_allow_referee", CV_SVF_REFEREE },
{ "vote_allow_shuffleteamsxp", CV_SVF_SHUFFLETEAMS },
{ "vote_allow_swapteams", CV_SVF_SWAPTEAMS },
Expand All @@ -4619,7 +4619,8 @@ const voteType_t voteToggles[] =
{ "vote_allow_warmupdamage", CV_SVF_WARMUPDAMAGE },
{ "vote_allow_antilag", CV_SVF_ANTILAG },
{ "vote_allow_balancedteams", CV_SVF_BALANCEDTEAMS },
{ "vote_allow_muting", CV_SVF_MUTING }
{ "vote_allow_muting", CV_SVF_MUTING },
{ "vote_allow_knifeonly", CV_SVF_KNIFEONLY },
};

int numVotesAvailable = sizeof(voteToggles) / sizeof(voteType_t);
Expand Down
5 changes: 4 additions & 1 deletion src/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ extern vmCvar_t vote_allow_map;
extern vmCvar_t vote_allow_matchreset;
extern vmCvar_t vote_allow_mutespecs;
extern vmCvar_t vote_allow_nextmap;
extern vmCvar_t vote_allow_pub;
//extern vmCvar_t vote_allow_pub;
extern vmCvar_t vote_allow_referee;
extern vmCvar_t vote_allow_shuffleteamsxp;
extern vmCvar_t vote_allow_swapteams;
Expand All @@ -1745,6 +1745,7 @@ extern vmCvar_t vote_allow_antilag;
extern vmCvar_t vote_allow_balancedteams;
extern vmCvar_t vote_allow_muting;
extern vmCvar_t vote_allow_cointoss;
extern vmCvar_t vote_allow_knifeonly;
extern vmCvar_t vote_limit;
extern vmCvar_t vote_percent;

Expand Down Expand Up @@ -2108,6 +2109,7 @@ void G_refRemoveShoutcaster_cmd(gentity_t* ent);
void G_refGetStatus(gentity_t* ent);
int G_refClientnumForName( gentity_t *ent, const char *name );
void G_refPrintf(gentity_t* ent, const char *fmt, ...);// _attribute((format(printf, 2, 3)));
void G_refKillAllPlayers(gentity_t* ent);
void G_PlayerBan(void);
void G_MakeReferee(void);
void G_RemoveReferee(void);
Expand Down Expand Up @@ -2156,6 +2158,7 @@ int G_Unreferee_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *ar
int G_AntiLag_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd );
int G_BalancedTeams_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd );
int G_CoinToss_v(gentity_t* ent, unsigned int dwVoteIndex, char* arg, char* arg2, qboolean fRefereeCmd);
int G_KnivesOnly_v(gentity_t* ent, unsigned int dwVoteIndex, char* arg, char* arg2, qboolean fRefereeCmd);

//
// g_geoip.c
Expand Down
6 changes: 4 additions & 2 deletions src/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ vmCvar_t vote_allow_map;
vmCvar_t vote_allow_matchreset;
vmCvar_t vote_allow_mutespecs;
vmCvar_t vote_allow_nextmap;
vmCvar_t vote_allow_pub;
//vmCvar_t vote_allow_pub;
vmCvar_t vote_allow_referee;
vmCvar_t vote_allow_shuffleteamsxp;
vmCvar_t vote_allow_swapteams;
Expand All @@ -212,6 +212,7 @@ vmCvar_t vote_allow_antilag;
vmCvar_t vote_allow_balancedteams;
vmCvar_t vote_allow_muting;
vmCvar_t vote_allow_cointoss;
vmCvar_t vote_allow_knifeonly;
vmCvar_t vote_limit;
vmCvar_t vote_percent;
vmCvar_t refereePassword;
Expand Down Expand Up @@ -482,7 +483,7 @@ cvarTable_t gameCvarTable[] = {
{ &vote_allow_matchreset, "vote_allow_matchreset", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_mutespecs, "vote_allow_mutespecs", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_nextmap, "vote_allow_nextmap", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_pub, "vote_allow_pub", "1", 0, 0, qfalse, qfalse },
//{ &vote_allow_pub, "vote_allow_pub", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_referee, "vote_allow_referee", "0", 0, 0, qfalse, qfalse },
{ &vote_allow_swapteams, "vote_allow_swapteams", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_friendlyfire, "vote_allow_friendlyfire", "1", 0, 0, qfalse, qfalse },
Expand All @@ -492,6 +493,7 @@ cvarTable_t gameCvarTable[] = {
{ &vote_allow_balancedteams,"vote_allow_balancedteams", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_muting, "vote_allow_muting", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_cointoss, "vote_allow_cointoss", "1", 0, 0, qfalse, qfalse },
{ &vote_allow_knifeonly, "vote_allow_knifeonly", "1", 0, 0, qfalse, qfalse },

// RTCWPro
{ &g_screenShake, "g_screenShake", "4", CVAR_ARCHIVE, 0, qtrue },
Expand Down
35 changes: 35 additions & 0 deletions src/game/g_referee.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,4 +1224,39 @@ void G_refPrintf(gentity_t* ent, const char *fmt, ...) {
}
//else { CP(va("cpm \"%s\n\"", text)); }
else { CP(va("print \"%s\n\"", text)); }
}

/*
===========
Kill player
===========
*/
void G_refKillAllPlayers(gentity_t* ent)
{
gclient_t* cl;

for (int i = 0; i < level.numPlayingClients; i++) {

cl = &level.clients[level.sortedClients[i]];

if (cl->pers.connected != CON_CONNECTED) {
continue;
}

if (cl->sess.sessionTeam == TEAM_SPECTATOR) {
continue;
}

if (cl->ps.pm_flags & PMF_LIMBO)
{
continue;
}

ent = &g_entities[cl->ps.clientNum];
G_Damage(ent, NULL, NULL, NULL, NULL, 250, DAMAGE_NO_PROTECTION, MOD_SELFKILL);
//AP(va("chat \"console:^7 %s ^7was killed by %s^3!\n\"", ent->client->pers.netname, tag));
player_die(ent, ent, ent, 100000, MOD_SELFKILL);
}

return;
}
27 changes: 27 additions & 0 deletions src/game/g_vote.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static const vote_reference_t aVoteInfo[] = {
{ 0x1ff, "antilag", G_AntiLag_v, "Anti-Lag", " <0|1>^7\n Toggles Anti-Lag on the server" },
{ 0x1ff, "balancedteams", G_BalancedTeams_v, "Balanced Teams", " <0|1>^7\n Toggles team balance forcing" },
{ 0x1ff, "cointoss", G_CoinToss_v, "Coin Toss", " ^7\n Heads or Tails." },
{ 0x1ff, "knifeonly", G_KnivesOnly_v, "Knives Only", " <0|1>^7\n Toggles knives only for all players" },
{ 0, 0, NULL, 0 }
};

Expand Down Expand Up @@ -857,6 +858,32 @@ int G_BalancedTeams_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char
return( G_OK );
}

// *** Knives only ***
int G_KnivesOnly_v(gentity_t* ent, unsigned int dwVoteIndex, char* arg, char* arg2, qboolean fRefereeCmd) {
// Vote request (vote is being initiated)
if (arg) {

if (g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_WARMUP_COUNTDOWN || g_gamestate.integer == GS_INTERMISSION) {
G_refPrintf(ent, "^3Knives only can only be voted on during warmup!");
return(G_INVALID);
}

return(G_voteProcessOnOff(ent, arg, arg2, fRefereeCmd,
!!(g_knifeonly.integer),
vote_allow_knifeonly.integer,
dwVoteIndex));
// Vote action (vote has passed)
}
else {
// Knives only (g_knifeonly)
G_voteSetOnOff("Knives Only", "g_knifeonly");
trap_Cvar_Set("g_knifeonly", level.voteInfo.vote_value);
G_refKillAllPlayers(ent);
}

return(G_OK);
}

// *** Timelimit ***
int G_Timelimit_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) {
// Vote request (vote is being initiated)
Expand Down

0 comments on commit e8aa669

Please sign in to comment.