Skip to content
Permalink
Browse files

mod: added /specuninvite command

  • Loading branch information
rmarquis committed Dec 2, 2019
1 parent b8752f2 commit 4811adfd867f94cfd926569b9195837896307fe2
Showing with 112 additions and 2 deletions.
  1. +1 −0 src/cgame/cg_consolecmds.c
  2. +110 −2 src/game/g_cmds_ext.c
  3. +1 −0 src/game/g_local.h
@@ -2102,6 +2102,7 @@ void CG_InitConsoleCommands(void)
trap_AddCommand("say_team");
trap_AddCommand("scores");
trap_AddCommand("specinvite");
trap_AddCommand("specuninvite");
trap_AddCommand("speclock");
trap_AddCommand("specunlock");
trap_AddCommand("statsall");
@@ -84,6 +84,7 @@ static const cmd_reference_t aCommandInfo[] =
{ "sclogout", qtrue, qfalse, G_sclogout_cmd, ":^7 Removes shoutcaster status" },
{ "scores", qtrue, qtrue, G_scores_cmd, ":^7 Displays current match stat info" },
{ "specinvite", qtrue, qtrue, G_specinvite_cmd, ":^7 Invites a player to spectate a speclock'ed team" },
{ "specuninvite", qtrue, qtrue, G_specuninvite_cmd, ":^7 Uninvites a spectator of a speclock'ed team" },
{ "speclock", qtrue, qtrue, G_speclock_cmd, ":^7 Locks a player's team from spectators" },
// { "speconly", qtrue, qtrue, NULL, ":^7 Toggles option to stay as a spectator in 1v1" },
{ "specunlock", qtrue, qfalse, G_speclock_cmd, ":^7 Unlocks a player's team from spectators" },
@@ -880,7 +881,7 @@ void G_specinvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock)
return;
}

// Find the player to invite.
// Find the player to invite
trap_Argv(1, arg, sizeof(arg));
if ((pid = ClientNumberFromString(ent, arg)) == -1)
{
@@ -896,7 +897,7 @@ void G_specinvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock)
return;
}

// Can't invite an active player.
// Can't invite an active player
if (player->client->sess.sessionTeam != TEAM_SPECTATOR)
{
CP("cpm \"You can't specinvite a non-spectator!\n\"");
@@ -916,6 +917,113 @@ void G_specinvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock)
}
}

/**
* @brief Remove invitation of a player to spectate a team.
* @param[in] ent
* @param[in] dwCommand
* @param fLock - unused
*/
void G_specuninvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock)
{
gentity_t *player;
char arg[MAX_TOKEN_CHARS];

if (team_nocontrols.integer)
{
G_noTeamControls(ent);
return;
}
if (!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName))
{
return;
}

if (ent->client->sess.sessionTeam == TEAM_AXIS || ent->client->sess.sessionTeam == TEAM_ALLIES)
{
int pid;

if (!teamInfo[ent->client->sess.sessionTeam].spec_lock)
{
CP("cpm \"Your team isn't locked from spectators!\n\"");
return;
}

// Find the player to invite
trap_Argv(1, arg, sizeof(arg));
if ((pid = ClientNumberFromString(ent, arg)) == -1)
{
return;
}

player = g_entities + pid;

// Can't uninvite self
if (player->client == ent->client)
{
CP("cpm \"You can't specuninvite yourself!\n\"");
return;
}

// Can't uninvite an active player
if (player->client->sess.sessionTeam != TEAM_SPECTATOR)
{
CP("cpm \"You can't specuninvite a non-spectator!\n\"");
return;
}

// Can't uninvite referre
if (player->client->sess.referee)
{
CP("cpm \"You can't specuninvite a referee!\n\"");
return;
}

// Can't uninvite shoutcaster
if (player->client->sess.shoutcaster)
{
CP("cpm \"You can't specuninvite a shoutcaster!\n\"");
return;
}

if (player->client->sess.spectatorState == SPECTATOR_FOLLOW)
{
StopFollowing(player);
player->client->sess.spec_team &= ~ent->client->sess.sessionTeam;
}
player->client->sess.spec_invite &= ~ent->client->sess.sessionTeam;

// Notify sender/recipient
CP(va("print \"%s^7 has been sent an uninvite spectator notification.\n\"", player->client->pers.netname));
G_printFull(va("*** You've been uninvited to spectate the %s team!", aTeams[ent->client->sess.sessionTeam]), player);

}
else
{
// Referee can't specuninvite oneself
if (ent->client->sess.referee)
{
CP("cpm \"Referee can't specuninvite oneself!\n\"");
return;
}

// Shoutcaster can't specuninvite oneself
if (ent->client->sess.shoutcaster)
{
CP("cpm \"Shoutcaster can't specuninvite oneself!\n\"");
return;
}

// Spectators can uninvite themselves from current spectated team
if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW)
{
StopFollowing(ent);
ent->client->sess.spec_team &= ~ent->client->sess.sessionTeam;
}
ent->client->sess.spec_invite &= ~ent->client->sess.sessionTeam;
CP("cpm \"You have uninvited yourself!\n\"");
}
}

/**
* @brief Locks/unlocks a player's team from spectators.
* @param[in] ent
@@ -2353,6 +2353,7 @@ void G_makesc_cmd(void);
void G_removesc_cmd(void);
void G_scores_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fValue);
void G_specinvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock);
void G_specuninvite_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock);
void G_speclock_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fLock);
void G_statsall_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fDump);
void G_teamready_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fDump);

0 comments on commit 4811adf

Please sign in to comment.
You can’t perform that action at this time.