--- quake2/game/g_main.c 2018/04/24 18:00:48 1.1.1.3 +++ quake2/game/g_main.c 2018/04/24 18:03:16 1.1.1.4 @@ -1,3 +1,22 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ #include "g_local.h" @@ -21,6 +40,7 @@ cvar_t *fraglimit; cvar_t *timelimit; cvar_t *password; cvar_t *spectator_password; +cvar_t *needpass; cvar_t *maxclients; cvar_t *maxspectators; cvar_t *maxentities; @@ -249,6 +269,33 @@ void EndDMLevel (void) } } + +/* +================= +CheckNeedPass +================= +*/ +void CheckNeedPass (void) +{ + int need; + + // if password or spectator_password has changed, update needpass + // as needed + if (password->modified || spectator_password->modified) + { + password->modified = spectator_password->modified = false; + + need = 0; + + if (*password->string && Q_stricmp(password->string, "none")) + need |= 1; + if (*spectator_password->string && Q_stricmp(spectator_password->string, "none")) + need |= 2; + + gi.cvar_set("needpass", va("%d", need)); + } +} + /* ================= CheckDMRules @@ -386,6 +433,9 @@ void G_RunFrame (void) // see if it is time to end a deathmatch CheckDMRules (); + // see if needpass needs updated + CheckNeedPass (); + // build the playerstate_t structures for all players ClientEndServerFrames (); }