Added Ignore

This commit is contained in:
Richard Allen 2002-05-10 04:06:27 +00:00
parent 8c431c132c
commit fac5c85740
6 changed files with 197 additions and 1 deletions

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.46 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.45 2002/04/28 11:01:21 slicer
// Added "teammodel" command for Matchmode
//
@ -983,6 +986,10 @@ void CG_InitConsoleCommands( void ) {
trap_AddCommand ("radio_power");
// JBravo: tkok
trap_AddCommand ("tkok");
// JBravo: ignore
trap_AddCommand ("ignore");
trap_AddCommand ("ignorenum");
trap_AddCommand ("clearignorelist");
// Slicer: Matchmode
trap_AddCommand ("captain");
trap_AddCommand ("ready");

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.105 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.104 2002/05/06 00:35:49 jbravo
// Small fixes to misc stuff
//
@ -1198,6 +1201,9 @@ static void G_SayTo(gentity_t *ent, gentity_t *other, int mode, int color, const
&& ent->client->sess.sessionTeam != TEAM_FREE ) {
return;
}
// JBravo: is the guy ignored ?
if (IsInIgnoreList (other, ent))
return;
// JBravo: Dead people dont speak to the living... or so Im told.
if (ent->client->sess.sessionTeam == TEAM_SPECTATOR &&
(other->client->sess.sessionTeam == TEAM_RED ||
@ -2915,6 +2921,13 @@ void ClientCommand( int clientNum ) {
RQ3_Cmd_Radio_f (ent);
else if (Q_stricmp (cmd, "dropweapon") == 0) // XRAY FMJ
Cmd_DropWeapon_f( ent );
// JBravo: adding ignore
else if (Q_stricmp (cmd, "ignorenum") == 0)
Cmd_Ignorenum_f (ent);
else if (Q_stricmp (cmd, "ignore") == 0)
Cmd_Ignore_f (ent);
else if (Q_stricmp (cmd, "clearignorelist") == 0)
Cmd_Ignoreclear_f (ent);
// JBravo: adding tkok
else if (Q_stricmp (cmd, "tkok") == 0)
RQ3_Cmd_TKOk (ent);

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.68 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.67 2002/05/09 20:58:30 jbravo
// New Obit system and a warning cleanup in zcam
//
@ -1048,7 +1051,6 @@ player_die
==================
*/
void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {
gentity_t *ent;
gentity_t *DMReward;
int anim, contents, killer, i;
char *killerName, *obit;

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.78 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.77 2002/05/09 20:58:30 jbravo
// New Obit system and a warning cleanup in zcam
//
@ -380,6 +383,10 @@ typedef struct {
#define FOLLOW_ACTIVE1 -1
#define FOLLOW_ACTIVE2 -2
// JBravo: for ignore
#define MAXIGNORE 11
typedef gentity_t *ignorelist_t[MAXIGNORE];
// client data that stays across multiple levels or tournament restarts
// this is achieved by writing all the data to cvar strings at game shutdown
// time and reading them back at connection time. Anything added here
@ -397,6 +404,8 @@ typedef struct {
qboolean teamLeader; // true when this client is a team leader
gentity_t *spawnPoint; // JBravo: This players spawnpoint
qboolean teamSpawn; // JBravo: This player is being spawned with his team.
int ignore_time; // JBravo: to avoid ignore flooding
ignorelist_t ignorelist; // JBravo: This players ignore list.
} clientSession_t;
//

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.85 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.84 2002/05/09 02:43:12 jbravo
// Fixing stuff and use cmd's
//
@ -289,6 +292,24 @@ void Cmd_DropItem_f(gentity_t *ent);
void Cmd_DropWeapon_f(gentity_t *ent);
void AddIP(char *str);
gentity_t *
FindClientByPersName (char *name) {
int i;
gentity_t *other, *found;
found = NULL;
for (i = 0; i <= level.maxclients; i++) {
other = &g_entities[i];
if (!other->inuse)
continue;
if (other && other->client && (Q_stricmp (other->client->pers.netname, name) == 0)) {
found = other;
break;
}
}
return (found);
}
void CheckTeamRules()
{
int winner, i, checked_tie = 0;
@ -1202,6 +1223,8 @@ void RQ3_Cmd_Radio_f(gentity_t *ent)
player = &g_entities[i];
if (!player->inuse)
continue;
if (IsInIgnoreList (player, ent))
continue;
if (player->client->sess.savedTeam == ent->client->sess.savedTeam)
trap_SendServerCommand(player-g_entities, va("rq3_cmd %i %i %i\n", RADIO,
kills-1, ent->client->radioGender));
@ -1212,6 +1235,8 @@ void RQ3_Cmd_Radio_f(gentity_t *ent)
player = &g_entities[i];
if (!player->inuse)
continue;
if (IsInIgnoreList (player, ent))
continue;
if (player->client->sess.savedTeam == ent->client->sess.savedTeam) {
if (player->r.svFlags & SVF_BOT)
trap_SendServerCommand(player-g_entities, va("print \"radio %s %s\n\"",
@ -1818,3 +1843,135 @@ void RQ3_Cmd_Stuff (void)
trap_SendServerCommand(client, va("stuff %s\n", cmd));
// trap_SendServerCommand(client, va("rq3_cmd %i %s\n", STUFF, cmd));
}
int RQ3_FindFreeIgnoreListEntry (gentity_t *source) {
return (IsInIgnoreList (source, NULL));
}
void RQ3_ClearIgnoreList (gentity_t *ent) {
int i;
if (!ent->client)
return;
for (i = 0; i < MAXIGNORE; i++)
ent->client->sess.ignorelist[i] = NULL;
}
int IsInIgnoreList (gentity_t *source, gentity_t *subject) {
int i;
if (!source || !source->client)
return 0;
for (i = 1; i < MAXIGNORE; i++)
if (source->client->sess.ignorelist[i] == subject)
return i;
return 0;
}
void RQ3_AddOrDelIgnoreSubject (gentity_t *source, gentity_t *subject, qboolean silent) {
int i;
if (!source->client)
return;
if (!subject->client || !subject->inuse) {
trap_SendServerCommand(source-g_entities, va("print \"Only valid clients may be added to ignore list!\n\""));
return;
}
i = IsInIgnoreList (source, subject);
if (i) {
//subject is in ignore list, so delete it
source->client->sess.ignorelist[i] = NULL;
if (!silent) {
trap_SendServerCommand(source-g_entities, va("print \"%s was removed from ignore list.\n\"",
subject->client->pers.netname));
trap_SendServerCommand(subject-g_entities, va("print \"%s is no longer ignoring you.\n\"",
source->client->pers.netname));
}
source->client->sess.ignore_time = level.framenum;
} else {
//subject has to be added
i = RQ3_FindFreeIgnoreListEntry (source);
if (!i) {
if (!silent)
trap_SendServerCommand(source-g_entities, va("print \"Sorry, ignore list is full!\n\""));
} else {
//we've found a place
source->client->sess.ignorelist[i] = subject;
if (!silent) {
trap_SendServerCommand(source-g_entities, va("print \"%s was added to ignore list.\n\"",
subject->client->pers.netname));
trap_SendServerCommand(subject-g_entities, va("print \"%s ignores you.\n\"",
source->client->pers.netname));
}
}
}
}
void RQ3__ClrIgnoresOn (gentity_t *target) {
gentity_t *other;
int i;
for (i = 1; i <= level.maxclients; i++) {
other = &g_entities[i];
if (other->inuse && other->client) {
if (IsInIgnoreList (other, target))
RQ3_AddOrDelIgnoreSubject (other, target, qtrue);
}
}
}
void Cmd_Ignore_f (gentity_t *self) {
gentity_t *target;
char s[128];
int i;
i = trap_Argc ();
if (i < 2) {
trap_SendServerCommand(self-g_entities, va("print \"Usage: ignore <playername>.\n\""));
return;
}
trap_Argv(1, s, sizeof(s));
target = FindClientByPersName (s);
if (target && target != self) {
if (level.framenum > (self->client->sess.ignore_time + 50))
RQ3_AddOrDelIgnoreSubject (self, target, qfalse);
else {
trap_SendServerCommand(self-g_entities, va("print \"Wait 5 seconds before ignoring again.\n\""));
return;
}
} else
trap_SendServerCommand(self-g_entities, va("print \"Use ignorelist to see who can be ignored.\n\""));
}
void Cmd_Ignorenum_f (gentity_t *self) {
int i;
gentity_t *target;
char arg[128];
i = trap_Argc ();
if (i < 2) {
trap_SendServerCommand(self-g_entities, va("print \"Usage: ignorenum <playernumber>.\n\""));
return;
}
trap_Argv(1, arg, sizeof(arg));
i = atoi (arg);
if (i && i <= level.maxclients) {
target = &g_entities[i];
if (target && target->client && target != self && target->inuse)
RQ3_AddOrDelIgnoreSubject (self, target, qfalse);
else
trap_SendServerCommand(self-g_entities, va("print \"Use ignorelist to see who can be ignored.\n\""));
} else
trap_SendServerCommand(self-g_entities, va("print \"Used ignorenum with illegal number.\n\""));
}
void Cmd_Ignoreclear_f (gentity_t *self) {
RQ3_ClearIgnoreList (self);
trap_SendServerCommand(self-g_entities, va("print \"Your ignorelist is now clear.\n\""));
}

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.15 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.14 2002/05/04 16:19:02 jbravo
// Fixing the stuff cmd to work on dedicated servers.
//
@ -58,6 +61,7 @@
#define WINNER_TEAM1 1
#define WINNER_TEAM2 2
#define WINNER_TIE 3
//Slicer TeamName Size.
#define TEAM_NAME_SIZE 30
@ -90,3 +94,7 @@ void RQ3_Cmd_TKOk(gentity_t *ent);
void RQ3_Cmd_Stuff(void);
void Add_TeamWound(gentity_t *attacker, gentity_t *victim, int mod);
void setFFState(gentity_t *ent);
void Cmd_Ignore_f(gentity_t *ent);
void Cmd_Ignorenum_f(gentity_t *ent);
void Cmd_Ignoreclear_f(gentity_t *ent);
int IsInIgnoreList(gentity_t *source, gentity_t *subject);