Added a new Referee System with multiple ref support

This commit is contained in:
Daniel Simoes 2002-08-23 14:25:05 +00:00
parent 10d91a465f
commit 59f1e6ee62
8 changed files with 124 additions and 62 deletions

View File

@ -40,6 +40,7 @@
* Added spawnflag 8 to breakables to allow them to be unkickable
* Created a CTB respawn Queue.
* Added propper handling of players waiting for a respawn in CTB
* New Referee System to allow multiple admins, determined by g_RQ3_maxRefs
# List fixes here for the 2.1 release

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.112 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
// Revision 1.111 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
@ -1471,10 +1474,10 @@ char *ClientConnect(int clientNum, qboolean firstTime, qboolean isBot)
}
// JBravo: moved from ClientBegin
client->pers.enterTime = level.time;
/* Slicer - no no !! this can't be here !
// JBravo: cleaning up stuff
client->sess.sub = TEAM_FREE;
client->sess.captain = TEAM_FREE;
client->sess.captain = TEAM_FREE;*/
return NULL;
}
@ -2026,8 +2029,8 @@ void ClientDisconnect(int clientNum)
}
}
// aasimon: Referee. If player is referee, clean ref
if (clientNum == g_RQ3_RefID.integer)
trap_Cvar_Set("g_RQ3_RefID", "-1");
/*if (clientNum == g_RQ3_RefID.integer)
trap_Cvar_Set("g_RQ3_RefID", "-1");*/
// JBravo: if the client had a laser, turn it off so it doesnt stay there forever.
if (ent->client->lasersight) {

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.161 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
// Revision 1.160 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
@ -445,8 +448,8 @@ void DeathmatchScoreboardMessage(gentity_t * ent)
ent->client->sess.savedTeam != cl->sess.savedTeam)
alive = qtrue;
}
Com_sprintf(entry, sizeof(entry), " %i %i %i %i %i %i %i %i %i %i %i",
//MUDANCA ADICIONEI UM INTEIRO
Com_sprintf(entry, sizeof(entry), " %i %i %i %i %i %i %i %i %i %i %i %i",
level.sortedClients[i],
cl->ps.persistant[PERS_SCORE],
ping,
@ -457,7 +460,8 @@ void DeathmatchScoreboardMessage(gentity_t * ent)
cl->ps.persistant[PERS_DAMAGE_DELT], // JBravo: Added for scoreboard
alive, // JBravo: Added for TP scoreboard
cl->sess.captain, // Slicer: Added for Matchmode Scoreboard
cl->sess.sub // Slicer: Added for Matchmode Scoreboard
cl->sess.sub, // Slicer: Added for Matchmode Scoreboard
cl->sess.referee
);
j = strlen(entry);
@ -466,11 +470,11 @@ void DeathmatchScoreboardMessage(gentity_t * ent)
strcpy(string + stringlength, entry);
stringlength += j;
}
trap_SendServerCommand(ent - g_entities, va("scores %i %i %i %i %i %i %i%s", i,
//MUDANCA !!! REMOVI O ULTIMO INTEIRO
trap_SendServerCommand(ent - g_entities, va("scores %i %i %i %i %i %i%s", i,
level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE],
level.team1ready, level.team2ready,
(int) level.matchTime, g_RQ3_RefID.integer, string));
(int) level.matchTime, string));
}
/*
@ -1558,7 +1562,7 @@ static void Cmd_Say_f(gentity_t * ent, int mode, qboolean arg0)
//Slicer Matchmode
if (g_RQ3_matchmode.integer) {
normaluser = (ent->client->sess.captain == TEAM_FREE && ent - g_entities != g_RQ3_RefID.integer);
normaluser = (ent->client->sess.captain == TEAM_FREE && !ent->client->sess.referee);
switch (g_RQ3_forceteamtalk.integer) {
case 1: //Only allow say_team when the game hasn't started
if (level.inGame && normaluser)

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.117 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
// Revision 1.116 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
@ -510,6 +513,7 @@ typedef gentity_t *ignorelist_t[MAXIGNORE];
// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
typedef struct {
//Slicer Matchmode
int referee;
team_t captain;
team_t sub;
team_t sessionTeam;
@ -1331,7 +1335,8 @@ extern vmCvar_t g_RQ3_ctb_respawndelay; // JBravo: delay in seconds for ctb resp
//aasimon: Ref System for MM
extern vmCvar_t g_RQ3_AllowRef;
extern vmCvar_t g_RQ3_RefPass;
extern vmCvar_t g_RQ3_RefID;
//extern vmCvar_t g_RQ3_RefID;
extern vmCvar_t g_RQ3_maxRefs;
// aasimon: ini stuff
extern vmCvar_t g_RQ3_IniFile;

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.109 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
// Revision 1.108 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
@ -408,7 +411,8 @@ vmCvar_t g_RQ3_ctb_respawndelay;
// aasimon: Ref System for MM
vmCvar_t g_RQ3_AllowRef;
vmCvar_t g_RQ3_RefPass;
vmCvar_t g_RQ3_RefID;
//vmCvar_t g_RQ3_RefID;
vmCvar_t g_RQ3_maxRefs;
// aasimon: ini stuff
vmCvar_t g_RQ3_IniFile;
@ -564,8 +568,9 @@ static cvarTable_t gameCvarTable[] = {
//{ &g_RQ3_team2ready, "g_RQ3_team2ready", "0", 0, 0, qfalse},
// aasimon: Ref system for MM,added infor for referee id (clientnumber)
{&g_RQ3_AllowRef, "g_RQ3_AllowRef", "0", CVAR_SERVERINFO, 0, qtrue},
{&g_RQ3_RefPass, "g_RQ3_RefPassword", "", CVAR_USERINFO, 0, qfalse},
{&g_RQ3_RefID, "g_RQ3_RefID", "-1", CVAR_SYSTEMINFO | CVAR_ROM, 0, qfalse},
{&g_RQ3_RefPass, "g_RQ3_RefPassword", "", CVAR_ARCHIVE, 0, qfalse},
//{&g_RQ3_RefID, "g_RQ3_RefID", "-1", CVAR_SYSTEMINFO | CVAR_ROM, 0, qfalse},
{&g_RQ3_maxRefs, " g_RQ3_maxRefs", "1", CVAR_SERVERINFO, 0, qtrue},
// aasimon: stuff for da ini file
{&g_RQ3_IniFile, "g_RQ3_IniFile", "", CVAR_SERVERINFO, 0, qfalse},
{&g_RQ3_ValidIniFile, "g_RQ3_ValidIniFile", "1", CVAR_SYSTEMINFO | CVAR_ROM, 0, qfalse},
@ -1073,7 +1078,7 @@ void G_InitGame(int levelTime, int randomSeed, int restart)
level.team2ready = qfalse;
level.paused = qfalse;
level.settingsLocked = qfalse;
refVotes[0] = refVotes[1] = -1;
refVotes[0] = refVotes[1] = NULL;
}
if (trap_Cvar_VariableIntegerValue("bot_enable")) {

View File

@ -2,7 +2,7 @@
// JBravo: for warnings
int ClientNumberFromString(gentity_t * to, char *s);
int refVotes[2]; // refVotes[0] is the clientnumber red team voted
gentity_t *refVotes[2]; // refVotes[0] is the clientnumber red team voted
// refVotes[1] is the clientnumber blue team voted
@ -20,6 +20,21 @@ void SendEndMessage()
level.teamScores[TEAM_BLUE]));
trap_SendServerCommand(-1, va("print \"Total Match Time: %d:%02d \n\"", mins, secs));
}
int getNumberOfRefs() {
gentity_t *ent;
int i,count;
count = 0;
for (i = 0; i < level.maxclients; i++) {
ent = &g_entities[i];
if (!ent->inuse)
continue;
if(ent->client->sess.referee)
++count;
}
return count;
}
gentity_t *getEntByName(char *name)
{
gentity_t *ent;
@ -288,16 +303,15 @@ void MM_TeamName_f(gentity_t * ent)
void checkRefVotes()
{
gentity_t *ent;
char nr[4];
// gentity_t *ent;
// char nr[4];
G_Printf("Vote Red: %i Vote Blue %i \n", refVotes[0], refVotes[1]);
//G_Printf("Vote Red: %i Vote Blue %i \n", refVotes[0], refVotes[1]);
if (refVotes[0] == refVotes[1]) {
ent = g_entities + refVotes[0];
Com_sprintf(nr, sizeof(nr), "%i", refVotes[0]);
trap_Cvar_Set("g_RQ3_RefID", nr);
trap_SendServerCommand(-1, va("cp \"%s is the new Referee.\n\"", ent->client->pers.netname));
refVotes[0] = refVotes[1] = -1;
// ent = g_entities + refVotes[0];
refVotes[0]->client->sess.referee = 1;
trap_SendServerCommand(-1, va("cp \"%s is now a Referee.\n\"", refVotes[0]->client->pers.netname));
refVotes[0] = refVotes[1] = NULL;
}
}
@ -318,34 +332,42 @@ void MM_Referee_f(gentity_t * ent)
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Allowed on this server\n\""));
return;
}
if (captain == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Only captains can vote a referee\n\""));
return;
}
if (trap_Argc() < 2) {
if (Ref_Exists()) {
/*if (Ref_Exists()) {
ref = g_entities + g_RQ3_RefID.integer;
trap_SendServerCommand(ent - g_entities,
va("print \"Current Referee: %s\n\"", ref->client->pers.netname));
} else
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"No Referee currently assigned, use referee <name>"MM_DENY_COLOR" to assign\n\""));
va("print \""MM_DENY_COLOR"No Referee currently assigned, use referee <name>"MM_DENY_COLOR" to assign\n\""));*/
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Use referee <name> to vote a referee\n\""));
return;
}
if((g_RQ3_mmflags.integer & MMF_VOTEREF) != MMF_VOTEREF) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow captains to vote for a Referee\n\""));
return;
}
if (captain != TEAM_FREE) {
buff = ConcatArgs(1);
if ((ref = getEntByName(buff)) != NULL) {
refVotes[captain - 1] = ref - g_entities;
trap_SendServerCommand(-1,
va("print \""MM_OK_COLOR"%s has voted %s"MM_OK_COLOR" for referee\n\"",
ent->client->pers.netname, ref->client->pers.netname));
checkRefVotes();
} else {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Name\n\""));
return;
}
} else
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You need to be a captain to assign a referee\n\""));
if(getNumberOfRefs() == g_RQ3_maxRefs.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Too many referees already on the server\n\""));
return;
}
buff = ConcatArgs(1);
if ((ref = getEntByName(buff)) != NULL) {
refVotes[captain - 1] = ref;
trap_SendServerCommand(-1,
va("print \""MM_OK_COLOR"%s has voted %s"MM_OK_COLOR" for referee\n\"",
ent->client->pers.netname, ref->client->pers.netname));
checkRefVotes();
} else {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Name\n\""));
return;
}
}
void MM_ClearScores(qboolean clearTeamFlags)
@ -373,7 +395,7 @@ void MM_ClearScores(qboolean clearTeamFlags)
}
// aasimon: checks for a ref
qboolean Ref_Exists(void)
/*qboolean Ref_Exists(void)
{
if (g_RQ3_RefID.integer == -1)
@ -381,28 +403,32 @@ qboolean Ref_Exists(void)
else
return qtrue;
}
*/
//
// aasimon: Ref Auth. Do some kind of logging (ip's etc)
//
qboolean Ref_Auth(gentity_t * ent)
{
char pass[MAX_TOKEN_CHARS];
int cn;
char teste[2];
// int cn;
// char teste[2];
if (!g_RQ3_AllowRef.integer) {
// No ref allowed on the server - HELLO!!!!! FIREMAN CARS????
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Allowed on this server\n\""));
return qfalse;
}
if(!g_RQ3_matchmode.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"This server is not running match mode\n\""));
return qfalse;
}
if (Q_stricmp(g_RQ3_RefPass.string, "") == 0) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Password Set on this server\n\""));
return qfalse;
}
if (Ref_Exists()) {
/* if (Ref_Exists()) {
// One ref per match
cn = ent - g_entities;
@ -413,13 +439,28 @@ qboolean Ref_Auth(gentity_t * ent)
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Referee already set on this server\n\""));
return qfalse;
}*/
if(getNumberOfRefs() == g_RQ3_maxRefs.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Too many referees already on the server\n\""));
return qfalse;
}
if (ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You are already the referee\n\""));
return qfalse;
}
trap_Argv(1, pass, sizeof(pass));
// Does a simple plain text auth
if (Q_stricmp(pass, g_RQ3_RefPass.string) == 0) {
ent->client->sess.referee = 1;
trap_SendServerCommand(-1,
va("print \"%s "MM_OK_COLOR"is now a Referee\n\"",
ent->client->pers.netname));
return qtrue;
}
/* if (Q_stricmp(pass, g_RQ3_RefPass.string) == 0) {
cn = ent - g_entities;
Com_sprintf(teste, 3, "%i", cn);
trap_Cvar_Set("g_RQ3_RefID", teste);
@ -428,7 +469,7 @@ qboolean Ref_Auth(gentity_t * ent)
ent->client->pers.netname));
return qtrue;
}
*/
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Referee Password\n\""));
return qfalse;
@ -460,8 +501,8 @@ void Ref_Command(gentity_t * ent)
char param[MAX_TOKEN_CHARS];
int cn;
cn = ent - g_entities;
if (cn != g_RQ3_RefID.integer) {
//cn = ent - g_entities;
if (!ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You are not a referee\n\""));
return;
}
@ -561,13 +602,10 @@ void Ref_Command(gentity_t * ent)
void Ref_Resign(gentity_t * ent)
{
if (ent - g_entities != g_RQ3_RefID.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You are not a referee\n\""));
return;
if (ent->client->sess.referee) {
ent->client->sess.referee = 0;
trap_SendServerCommand(ent - g_entities, va("print \""MM_OK_COLOR"You resign from your referee status\n\""));
}
trap_Cvar_Set("g_RQ3_RefID", "-1");
trap_SendServerCommand(ent - g_entities, va("print \""MM_OK_COLOR"You resign from your referee status\n\""));
}
/*
@ -606,7 +644,7 @@ void MM_Settings_f(gentity_t * ent) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow you to change settings\n\""));
return;
}
if (ent->client->sess.captain == TEAM_FREE && ent - g_entities != g_RQ3_RefID.integer) {
if (ent->client->sess.captain == TEAM_FREE && !ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Only Captains and Referees can change match Settings\n\""));
return;
}

View File

@ -27,4 +27,4 @@ qboolean Ref_Exists(void);
qboolean Ref_Auth(gentity_t *); // No need to return a boolean in this context
void Ref_Command(gentity_t *);
void Ref_Resign(gentity_t *);
extern int refVotes[2];
extern gentity_t* refVotes[2];

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.20 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
// Revision 1.19 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
@ -89,13 +92,13 @@ void G_WriteClientSessionData(gclient_t * client)
//Reset teams on map changes / map_restarts, except on matchmode
client->sess.savedTeam = TEAM_SPECTATOR;
}
s = va("%i %i %i %i %i %i %i %i %i %i",
s = va("%i %i %i %i %i %i %i %i %i %i %i",
client->sess.sessionTeam,
client->sess.spectatorTime,
client->sess.spectatorState,
client->sess.spectatorClient, client->sess.wins, client->sess.losses, client->sess.teamLeader,
//Adding saved Team
client->sess.savedTeam, client->sess.captain, client->sess.sub
client->sess.savedTeam, client->sess.captain, client->sess.sub,client->sess.referee
//Captain and sub
);
@ -127,14 +130,15 @@ void G_ReadSessionData(gclient_t * client)
int savedTeam;
int captain;
int sub;
int ref;
var = va("session%i", client - level.clients);
trap_Cvar_VariableStringBuffer(var, s, sizeof(s));
//Slicer: Reading savedTeam also.
sscanf(s, "%i %i %i %i %i %i %i %i %i %i", &sessionTeam, // bk010221 - format
sscanf(s, "%i %i %i %i %i %i %i %i %i %i %i", &sessionTeam, // bk010221 - format
&client->sess.spectatorTime, &spectatorState, // bk010221 - format
&client->sess.spectatorClient, &client->sess.wins, &client->sess.losses, &teamLeader, // bk010221 - format
&savedTeam, &captain, &sub);
&savedTeam, &captain, &sub, &ref);
// bk001205 - format issues
@ -147,6 +151,7 @@ void G_ReadSessionData(gclient_t * client)
client->sess.savedTeam = (team_t) savedTeam;
client->sess.captain = (team_t) captain;
client->sess.sub = (team_t) sub;
client->sess.referee = ref;
if (g_gametype.integer == GT_CTF) {
client->sess.sessionTeam = TEAM_SPECTATOR;
@ -180,6 +185,7 @@ void G_InitSessionData(gclient_t * client, char *userinfo)
sess->captain = TEAM_FREE;
sess->sub = TEAM_FREE;
sess->referee = 0;
// JBravo: adding PERS_SAVEDTEAM
client->ps.persistant[PERS_SAVEDTEAM] = TEAM_SPECTATOR;