Coop and Deathmatch flag fixes:

1. Deathmatch and Coop not at the same time
2. Recognize Coop in Maxplayers command (e.g. called through SinglePlayer menu)
This commit is contained in:
Maddes Buecher 2000-08-17 17:18:01 +00:00
parent 64462f814d
commit 809e15da8a
2 changed files with 117 additions and 56 deletions

View file

@ -61,7 +61,8 @@ Cvar_Display
same cvar display for all cvar commands
============
*/
void Cvar_Display (cvar_t *var)
void
Cvar_Display ( cvar_t *var )
{
Con_Printf ("%c%c%c ",
(var->flags & CVAR_ARCHIVE) ? 'A' : ' ', // archived
@ -126,7 +127,8 @@ void Cvar_Display (cvar_t *var)
Cvar_FindVar
============
*/
cvar_t *Cvar_FindVar (char *var_name)
cvar_t *
Cvar_FindVar ( char *var_name )
{
cvar_t *var;
@ -137,7 +139,8 @@ cvar_t *Cvar_FindVar (char *var_name)
return NULL;
}
cvar_t *Cvar_FindAlias (char *alias_name)
cvar_t *
Cvar_FindAlias ( char *alias_name )
{
cvar_alias_t *alias;
@ -147,7 +150,8 @@ cvar_t *Cvar_FindAlias (char *alias_name)
return NULL;
}
void Cvar_Alias_Get (char *name, cvar_t *cvar)
void
Cvar_Alias_Get ( char *name, cvar_t *cvar )
{
cvar_alias_t *alias;
cvar_t *var;
@ -162,13 +166,13 @@ void Cvar_Alias_Get (char *name, cvar_t *cvar)
Con_Printf ("CAlias_Get: tried to alias used cvar name %s\n",name);
return;
}
var = Cvar_FindAlias(name);
var = Cvar_FindAlias(name);
if (!var)
{
alias = (cvar_alias_t *) malloc(sizeof(cvar_alias_t));
alias->next = calias_vars;
calias_vars = alias;
alias->name = strdup(name);
alias->name = strdup(name);
alias->cvar = cvar;
}
}
@ -178,7 +182,8 @@ void Cvar_Alias_Get (char *name, cvar_t *cvar)
Cvar_VariableValue
============
*/
float Cvar_VariableValue (char *var_name)
float
Cvar_VariableValue ( char *var_name )
{
cvar_t *var;
@ -196,7 +201,8 @@ float Cvar_VariableValue (char *var_name)
Cvar_VariableString
============
*/
char *Cvar_VariableString (char *var_name)
char *
Cvar_VariableString ( char *var_name )
{
cvar_t *var;
@ -214,7 +220,8 @@ char *Cvar_VariableString (char *var_name)
Cvar_CompleteVariable
============
*/
char *Cvar_CompleteVariable (char *partial)
char *
Cvar_CompleteVariable ( char *partial )
{
cvar_t *cvar;
cvar_alias_t *alias;
@ -229,7 +236,7 @@ char *Cvar_CompleteVariable (char *partial)
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
if (!strcmp (partial,cvar->name))
return cvar->name;
// check aliases too :)
for (alias=calias_vars ; alias ; alias=alias->next)
if (!strcmp (partial, alias->name))
@ -259,7 +266,8 @@ Cvar_Set
============
*/
#if defined(QUAKEWORLD)
void Cvar_Set (cvar_t *var, char *value)
void
Cvar_Set ( cvar_t *var, char *value )
{
if (!var)
return;
@ -291,7 +299,8 @@ void Cvar_Set (cvar_t *var, char *value)
var->value = Q_atof (var->string);
}
#elif defined(UQUAKE)
void Cvar_Set (cvar_t *var, char *value)
void
Cvar_Set ( cvar_t *var, char *value )
{
qboolean changed;
// 2000-06-22 Range check for cvars by Maddes start
@ -388,6 +397,18 @@ void Cvar_Set (cvar_t *var, char *value)
if (sv.active)
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
}
// 1999-09-06 deathmatch/coop not at the same time fix by Maddes start
if ( (var == deathmatch) && (var->value != 0) )
{
Cvar_Set (coop, "0");
}
if ( (var == coop) && (var->value != 0) )
{
Cvar_Set (deathmatch, "0");
}
// 1999-09-06 deathmatch/coop not at the same time fix by Maddes end
}
#endif
@ -399,7 +420,8 @@ Cvar_Command
Handles variable inspection and changing from the console
============
*/
qboolean Cvar_Command (void)
qboolean
Cvar_Command ( void )
{
cvar_t *v;
@ -430,7 +452,8 @@ Writes lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
void Cvar_WriteVariables (QFile *f)
void
Cvar_WriteVariables ( QFile *f )
{
cvar_t *var;
@ -439,7 +462,8 @@ void Cvar_WriteVariables (QFile *f)
Qprintf (f, "%s \"%s\"\n", var->name, var->string);
}
void Cvar_Set_f(void)
void
Cvar_Set_f ( void )
{
cvar_t *var;
char *value;
@ -466,7 +490,8 @@ void Cvar_Set_f(void)
}
}
void Cvar_Toggle_f (void)
void
Cvar_Toggle_f ( void )
{
cvar_t *var;
@ -488,7 +513,8 @@ void Cvar_Toggle_f (void)
Cvar_Set (var, var->value ? "0" : "1");
}
void Cvar_Help_f (void)
void
Cvar_Help_f ( void )
{
char *var_name;
cvar_t *var;
@ -511,7 +537,8 @@ void Cvar_Help_f (void)
Con_Printf ("variable not found\n");
}
void Cvar_CvarList_f (void)
void
Cvar_CvarList_f ( void )
{
cvar_t *var;
int i;
@ -556,7 +583,8 @@ void Cvar_CvarList_f (void)
// 2000-06-22 Partial selection for CvarList command by Maddes end
}
void Cvar_Init()
void
Cvar_Init ( )
{
developer = Cvar_Get ("developer","0",0,"None");
@ -566,7 +594,8 @@ void Cvar_Init()
Cmd_AddCommand ("cvarlist",Cvar_CvarList_f);
}
void Cvar_Shutdown (void)
void
Cvar_Shutdown ( void )
{
cvar_t *var,*next;
cvar_alias_t *alias,*nextalias;
@ -582,7 +611,7 @@ void Cvar_Shutdown (void)
free(var);
var = next;
}
// Free aliases
// Free aliases
alias = calias_vars;
while(alias)
{
@ -594,7 +623,8 @@ void Cvar_Shutdown (void)
}
cvar_t *Cvar_Get(char *name, char *string, int cvarflags, char *description)
cvar_t *
Cvar_Get ( char *name, char *string, int cvarflags, char *description )
{
cvar_t *v;
@ -629,7 +659,7 @@ cvar_t *Cvar_Get(char *name, char *string, int cvarflags, char *description)
v->flags ^= CVAR_HEAP;
v->flags |= cvarflags;
if (!Q_strcmp (v->description,"User created cvar"))
{
{
// Set with the real description
free(v->description);
v->description = strdup (description);

View file

@ -96,18 +96,19 @@ cvar_t *config_modem_init;
cvar_t *config_modem_hangup;
extern int vcrFile;
qboolean recording = false;
qboolean recording = false;
// these two macros are to make the code more readable
#define sfunc net_drivers[sock->driver]
#define dfunc net_drivers[net_driverlevel]
int net_driverlevel;
int net_driverlevel;
double net_time;
double net_time;
double SetNetTime(void)
double
SetNetTime ( void )
{
net_time = Sys_DoubleTime();
return net_time;
@ -122,7 +123,8 @@ Called by drivers when a new communications endpoint is required
The sequence and buffer fields will be filled in properly
===================
*/
qsocket_t *NET_NewQSocket (void)
qsocket_t *
NET_NewQSocket ( void )
{
qsocket_t *sock;
@ -161,7 +163,8 @@ qsocket_t *NET_NewQSocket (void)
}
void NET_FreeQSocket(qsocket_t *sock)
void
NET_FreeQSocket ( qsocket_t *sock )
{
qsocket_t *s;
@ -187,7 +190,8 @@ void NET_FreeQSocket(qsocket_t *sock)
}
static void NET_Listen_f (void)
static void
NET_Listen_f ( void )
{
if (Cmd_Argc () != 2)
{
@ -206,7 +210,8 @@ static void NET_Listen_f (void)
}
static void MaxPlayers_f (void)
static void
MaxPlayers_f ( void )
{
int n;
@ -238,14 +243,23 @@ static void MaxPlayers_f (void)
Cbuf_AddText ("listen 1\n");
svs.maxclients = n;
if (n == 1)
if (n == 1) {
Cvar_Set (deathmatch, "0");
else
Cvar_Set (deathmatch, "1");
Cvar_Set (coop, "0"); // 1999-07-30 coop and deathmatch flag fix by Frog/Maddes
} else {
// 1999-07-30 coop and deathmatch flag fix by Frog/Maddes start
if (coop->value) {
Cvar_Set (deathmatch, "0");
} else {
// 1999-07-30 coop and deathmatch flag fix by Frog/Maddes end
Cvar_Set (deathmatch, "1");
} // 1999-07-30 coop and deathmatch flag fix by Frog/Maddes
}
}
static void NET_Port_f (void)
static void
NET_Port_f ( void )
{
int n;
@ -274,7 +288,8 @@ static void NET_Port_f (void)
}
static void PrintSlistHeader(void)
static void
PrintSlistHeader ( void )
{
Con_Printf("Server Map Users\n");
Con_Printf("--------------- --------------- -----\n");
@ -282,7 +297,8 @@ static void PrintSlistHeader(void)
}
static void PrintSlist(void)
static void
PrintSlist ( void )
{
int n;
@ -297,7 +313,8 @@ static void PrintSlist(void)
}
static void PrintSlistTrailer(void)
static void
PrintSlistTrailer ( void )
{
if (hostCacheCount)
Con_Printf("== end list ==\n\n");
@ -306,7 +323,8 @@ static void PrintSlistTrailer(void)
}
void NET_Slist_f (void)
void
NET_Slist_f ( void )
{
if (slistInProgress)
return;
@ -327,7 +345,8 @@ void NET_Slist_f (void)
}
static void Slist_Send(void)
static void
Slist_Send ( void )
{
for (net_driverlevel=0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
@ -343,7 +362,8 @@ static void Slist_Send(void)
}
static void Slist_Poll(void)
static void
Slist_Poll ( void )
{
for (net_driverlevel=0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
@ -377,10 +397,11 @@ NET_Connect
===================
*/
int hostCacheCount = 0;
hostcache_t hostcache[HOSTCACHESIZE];
int hostCacheCount = 0;
hostcache_t hostcache[HOSTCACHESIZE];
qsocket_t *NET_Connect (char *host)
qsocket_t *
NET_Connect ( char *host )
{
qsocket_t *ret;
int n;
@ -469,7 +490,8 @@ struct
long session;
} vcrConnect;
qsocket_t *NET_CheckNewConnections (void)
qsocket_t *
NET_CheckNewConnections ( void )
{
qsocket_t *ret;
@ -512,7 +534,8 @@ qsocket_t *NET_CheckNewConnections (void)
NET_Close
===================
*/
void NET_Close (qsocket_t *sock)
void
NET_Close ( qsocket_t *sock )
{
if (!sock)
return;
@ -552,7 +575,8 @@ struct
extern void PrintStats(qsocket_t *s);
int NET_GetMessage (qsocket_t *sock)
int
NET_GetMessage ( qsocket_t *sock )
{
int ret;
@ -637,7 +661,8 @@ struct
int r;
} vcrSendMessage;
int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
int
NET_SendMessage ( qsocket_t *sock, sizebuf_t *data )
{
int r;
@ -668,7 +693,8 @@ int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
}
int NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
int
NET_SendUnreliableMessage ( qsocket_t *sock, sizebuf_t *data )
{
int r;
@ -707,7 +733,8 @@ Returns true or false if the given qsocket can currently accept a
message to be transmitted.
==================
*/
qboolean NET_CanSendMessage (qsocket_t *sock)
qboolean
NET_CanSendMessage ( qsocket_t *sock )
{
int r;
@ -734,7 +761,8 @@ qboolean NET_CanSendMessage (qsocket_t *sock)
}
int NET_SendToAll(sizebuf_t *data, int blocktime)
int
NET_SendToAll ( sizebuf_t *data, int blocktime )
{
double start;
int i;
@ -816,7 +844,8 @@ NET_Init
====================
*/
void NET_Init (int port)
void
NET_Init ( int port )
{
int i;
int controlSocket;
@ -922,7 +951,8 @@ NET_Shutdown
====================
*/
void NET_Shutdown (void)
void
NET_Shutdown ( void )
{
qsocket_t *sock;
@ -953,7 +983,8 @@ void NET_Shutdown (void)
static PollProcedure *pollProcedureList = NULL;
void NET_Poll(void)
void
NET_Poll ( void )
{
PollProcedure *pp;
qboolean useModem;
@ -984,7 +1015,8 @@ void NET_Poll(void)
}
void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
void
SchedulePollProcedure ( PollProcedure *proc, double timeOffset )
{
PollProcedure *pp, *prev;
@ -1006,4 +1038,3 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
proc->next = pp;
prev->next = proc;
}