예제 #1
0
/*
======================
SV_Map_f

handle a 
map <mapname>
command from the console or progs.
======================
*/
void SV_Map_f (void)
{
	char	expanded[MAX_QPATH];
	qfile_t	*f;

	if (Cmd_Argc() != 2) {
		Com_Printf ("map <mapname> : continue game on a new map\n");
		return;
	}

	// check to make sure the level exists
	Q_snprintf (expanded, sizeof(expanded), "maps/%s.bsp", Cmd_Argv(1));
	f = FS_Open (expanded, "rb", false, true);
	if (!f)
		return;
	FS_Close (f);

	if (sv.mvdrecording)
		SV_MVDStop_f();

	NET_ServerConfig (true);

	if (!dedicated)
		CL_BeginLocalConnection ();

	SV_BroadcastCommand ("changing\n");
	SV_SendMessagesToAll ();

	SV_SpawnServer (Cmd_Argv(1), !Q_stricmp(Cmd_Argv(0), "devmap"));

	SV_BroadcastCommand ("reconnect\n");
}
예제 #2
0
/*
* SV_Map
* command from the console or progs.
*/
void SV_Map( const char *level, qboolean devmap )
{
	client_t *cl;
	int i;

	if( svs.demo.file )
		SV_Demo_Stop_f();

	// skip the end-of-unit flag if necessary
	if( level[0] == '*' )
		level++;

	if( sv.state == ss_dead )
		SV_InitGame(); // the game is just starting

	// remove all bots before changing map
	for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
	{
		if( cl->state && cl->edict && ( cl->edict->r.svflags & SVF_FAKECLIENT ) )
		{
			SV_DropClient( cl, DROP_TYPE_GENERAL, NULL );
		}
	}

	// wsw : Medar : this used to be at SV_SpawnServer, but we need to do it before sending changing
	// so we don't send frames after sending changing command
	// leave slots at start for clients only
	for( i = 0; i < sv_maxclients->integer; i++ )
	{
		// needs to reconnect
		if( svs.clients[i].state > CS_CONNECTING )
		{
			svs.clients[i].state = CS_CONNECTING;
		}

		// limit number of connected multiview clients
		if( svs.clients[i].mv )
		{
			if( sv.num_mv_clients < sv_maxmvclients->integer )
				sv.num_mv_clients++;
			else
				svs.clients[i].mv = qfalse;
		}

		svs.clients[i].lastframe = -1;
		memset( svs.clients[i].gameCommands, 0, sizeof( svs.clients[i].gameCommands ) );
	}

	SV_MOTD_Update();

	SCR_BeginLoadingPlaque();       // for local system
	SV_BroadcastCommand( "changing\n" );
	SV_SendClientMessages();
	SV_SpawnServer( level, devmap );
	SV_BroadcastCommand( "reconnect\n" );
}
예제 #3
0
/*
======================
SV_Map_f

handle a 
map <mapname>
command from the console or progs.
======================
*/
void SV_Map_f (void)
{
	char	level[MAX_QPATH];
	char	expanded[MAX_QPATH];
	FILE	*f;
	char	_startspot[MAX_QPATH];
	char	*startspot;

	if (Cmd_Argc() < 2)
	{
		Con_Printf ("map <levelname> : continue game on a new level\n");
		return;
	}
	strcpy (level, Cmd_Argv(1));
	if (Cmd_Argc() == 2)
	{
		startspot = NULL;
	}
	else
	{
		strcpy (_startspot, Cmd_Argv(2));
		startspot = _startspot;
	}

#if 0
	if (!strcmp (level, "e1m8"))
	{	// QuakeWorld can't go to e1m8
		SV_BroadcastPrintf (PRINT_HIGH, "can't go to low grav level in HexenWorld...\n");
		strcpy (level, "e1m5");
	}
#endif

	// check to make sure the level exists
	sprintf (expanded, "maps/%s.bsp", level);
	COM_FOpenFile (expanded, &f, false);
	if (!f)
	{
		Con_Printf ("Can't find %s\n", expanded);
		return;
	}
	fclose (f);

	SV_BroadcastCommand ("changing\n");
	SV_SendMessagesToAll ();

	SV_SpawnServer (level, startspot);

	SV_BroadcastCommand ("reconnect\n");
}
예제 #4
0
파일: cvar.c 프로젝트: bsmr-games/Hexen2
/*
============
Cvar_Set
============
*/
void Cvar_Set (char *var_name, char *value)
{
	cvar_t	*var;
	
	var = Cvar_FindVar (var_name);
	if (!var)
	{	// there is an error in C code if this happens
		Con_Printf ("Cvar_Set: variable %s not found\n", var_name);
		return;
	}

#ifdef SERVERONLY
	if (var->info)
	{
		Info_SetValueForKey (svs.info, var_name, value, MAX_SERVERINFO_STRING);
		SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);
	}
#else
	if (var->info)
	{
		Info_SetValueForKey (cls.userinfo, var_name, value, MAX_INFO_STRING);
		if (cls.state >= ca_connected)
		{
			MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
			SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var_name, value));
		}
	}
#endif
	
	Z_Free (var->string);	// free the old value string
	
	var->string = Z_Malloc (strlen(value)+1);
	strcpy (var->string, value);
	var->value = atof (var->string);
}
예제 #5
0
void SV_Serverinfo_f (void)
{
	cvar_t	*var;

	if (Cmd_Argc() == 1)
	{
		Con_Printf ("Server info settings:\n");
		Info_Print (svs.info);
		return;
	}

	if (Cmd_Argc() != 3)
	{
		Con_Printf ("usage: serverinfo [ <key> <value> ]\n");
		return;
	}

	if (Cmd_Argv(1)[0] == '*')
	{
		Con_Printf ("Star variables cannot be changed.\n");
		return;
	}
	Info_SetValueForKey (svs.info, Cmd_Argv(1), Cmd_Argv(2), MAX_SERVERINFO_STRING);

	// if this is a cvar, change it too	
	var = Cvar_FindVar (Cmd_Argv(1));
	if (var)
	{
		Z_Free (var->string);	// free the old value string	
		var->string = CopyString (Cmd_Argv(2));
		var->value = atof (var->string);
	}

	SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);
}
예제 #6
0
파일: sv_ccmds.c 프로젝트: luaman/qforge-1
/*
	SV_Map_f

	handle a
	map <mapname>
	command from the console or progs.
*/
static void
SV_Map_f (void)
{
	const char *level;
	char       *expanded;
	QFile      *f;

	if (!curlevel)
		curlevel = dstring_newstr ();

	if (Cmd_Argc () > 2) {
		SV_Printf ("map <levelname> : continue game on a new level\n");
		return;
	}
	if (Cmd_Argc () == 1) {
		SV_Printf ("map is %s \"%s\" (%s)\n", curlevel->str,
				   PR_GetString (&sv_pr_state, SVstring (sv.edicts, message)),
				   nice_time (sv.time));
		return;
	}
	level = Cmd_Argv (1);

	// check to make sure the level exists
	expanded = nva ("maps/%s.bsp", level);
	f = QFS_FOpenFile (expanded);
	if (!f) {
		SV_Printf ("Can't find %s\n", expanded);
		free (expanded);
		return;
	}
	Qclose (f);
	free (expanded);

	if (sv.recording_demo)
		SV_Stop (0);

	SV_qtvChanging ();
	SV_BroadcastCommand ("changing\n");
	SV_SendMessagesToAll ();

	dstring_copystr (curlevel, level);
	SV_SpawnServer (level);

	SV_qtvReconnect ();
	SV_BroadcastCommand ("reconnect\n");
}
예제 #7
0
파일: sv_ccmds.c 프로젝트: jogi1/camquake
//handle a map <mapname> command from the console or progs.
void SV_Map_f (void) {
	char level[MAX_QPATH], expanded[MAX_QPATH];
#ifndef WITH_FTE_VFS
	FILE *f;
#else
	vfsfile_t *f;
#endif
	qbool devmap;

	if (Cmd_Argc() != 2) {
		Com_Printf ("%s <levelname> : continue game on a new level\n", Cmd_Argv(0));
		return;
	}
	devmap = !strcasecmp (Cmd_Argv(0), "devmap");
	strlcpy (level, Cmd_Argv(1), sizeof(level));

	// check to make sure the level exists
	snprintf (expanded, sizeof(expanded), "maps/%s.bsp", level);
#ifndef WITH_FTE_VFS
	if (FS_FOpenFile (expanded, &f) == -1) {
		Com_Printf ("Can't find %s\n", expanded);
		return;
	}
	fclose (f);
#else
	if (!(f = FS_OpenVFS(expanded, "rb", FS_ANY))) {
		Com_Printf ("Can't find %s\n", expanded);
		return;
	}
	VFS_CLOSE(f);
#endif // WITH_FTE_VFS

#ifndef SERVERONLY
	if (!dedicated)
		CL_BeginLocalConnection ();
#endif

	SV_BroadcastCommand ("changing\n");
	SV_SendMessagesToAll ();

	SV_SpawnServer (level, devmap);

	SV_BroadcastCommand ("reconnect\n");
}
예제 #8
0
파일: sv_init.c 프로젝트: greck2908/qengine
void SV_Map(qboolean attractloop, char *levelstring, qboolean loadgame)
{
  char spawnpoint[1];
  spawnpoint[0] = 0;
  sv.loadgame = loadgame;
  sv.attractloop = attractloop;

  if ((sv.state == ss_dead) && !sv.loadgame) {
    SV_InitGame(); /* the game is just starting */
  }

  Cvar_Set("nextserver", "");

#ifndef DEDICATED_ONLY
  SCR_BeginLoadingPlaque(); /* for local system */
#endif
  SV_BroadcastCommand("changing\n");
  SV_SendClientMessages();
  SV_SpawnServer(levelstring, spawnpoint, ss_game, attractloop, loadgame);
  Cbuf_CopyToDefer();

  SV_BroadcastCommand("reconnect\n");
}
예제 #9
0
/*
======================
SV_Map

  the full syntax is:

  map [*]<map>$<startspot>+<nextserver>

command from the console or progs.
Map can also be a.cin, .pcx, or .dm2 file
Nextserver is used to allow a cinematic to play, then proceed to
another level:

	map tram.cin+jail_e3
======================
*/
void SV_Map (qboolean attractloop, char *levelstring, qboolean loadgame)
{
	char	level[MAX_QPATH];
	char	*ch;
	int		l;
	char	spawnpoint[MAX_QPATH];

	sv.loadgame = loadgame;
	sv.attractloop = attractloop;

	if (sv.state == ss_dead && !sv.loadgame)
		SV_InitGame ();	// the game is just starting

	strcpy (level, levelstring);

	// if there is a + in the map, set nextserver to the remainder
	ch = strstr(level, "+");
	if (ch)
	{
		*ch = 0;
			Cvar_Set ("nextserver", va("gamemap \"%s\"", ch+1));
	}
	else
		Cvar_Set ("nextserver", "");

	//ZOID special hack for end game screen in coop mode
	if (Cvar_VariableValue ("coop") && !Q_stricmp(level, "victory.pcx"))
		Cvar_Set ("nextserver", "gamemap \"*base1\"");

	// if there is a $, use the remainder as a spawnpoint
	ch = strstr(level, "$");
	if (ch)
	{
		*ch = 0;
		strcpy (spawnpoint, ch+1);
	}
	else
		spawnpoint[0] = 0;

	// skip the end-of-unit flag if necessary
	if (level[0] == '*')
		strcpy (level, level+1);

	l = strlen(level);
	if (l > 4 && !strcmp (level+l-4, ".cin") )
	{
		SCR_BeginLoadingPlaque ();			// for local system
		SV_BroadcastCommand ("changing\n");
		SV_SpawnServer (level, spawnpoint, ss_cinematic, attractloop, loadgame);
	}
	else if (l > 4 && !strcmp (level+l-4, ".dm2") )
	{
		SCR_BeginLoadingPlaque ();			// for local system
		SV_BroadcastCommand ("changing\n");
		SV_SpawnServer (level, spawnpoint, ss_demo, attractloop, loadgame);
	}
	else if (l > 4 && !strcmp (level+l-4, ".pcx") )
	{
		SCR_BeginLoadingPlaque ();			// for local system
		SV_BroadcastCommand ("changing\n");
		SV_SpawnServer (level, spawnpoint, ss_pic, attractloop, loadgame);
	}
	else
	{
		SCR_BeginLoadingPlaque ();			// for local system
		SV_BroadcastCommand ("changing\n");
		SV_SendClientMessages ();
		SV_SpawnServer (level, spawnpoint, ss_game, attractloop, loadgame);
		Cbuf_CopyToDefer ();
	}

	SV_BroadcastCommand ("reconnect\n");
}
예제 #10
0
파일: sv_init.c 프로젝트: Bad-ptr/q2pro
/*
================
SV_SpawnServer

Change the server to a new map, taking all connected
clients along with it.
================
*/
void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint ) {
    int         i;
    client_t    *client;

#if USE_CLIENT
    SCR_BeginLoadingPlaque();           // for local system
#endif

    Com_Printf( "------- Server Initialization -------\n" );
    Com_Printf( "SpawnServer: %s\n", server );

    // everyone needs to reconnect
    FOR_EACH_CLIENT( client ) {
        SV_ClientReset( client );
    }

    SV_BroadcastCommand( "changing map=%s\n", server );
    SV_SendClientMessages();
    SV_SendAsyncPackets();

    // free current level
    CM_FreeMap( &sv.cm );
    SV_FreeFile( sv.entitystring );
    
    // wipe the entire per-level structure
    memset( &sv, 0, sizeof( sv ) );
    sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds();
    sv.spawncount &= 0x7FFFFFFF;

    // set legacy spawncounts
    FOR_EACH_CLIENT( client ) {
        client->spawncount = sv.spawncount;
    }

    // reset entity counter
    svs.next_entity = 0;

#if USE_FPS
    // set framerate parameters
    set_frame_time();
#endif

    // save name for levels that don't set message
    Q_strlcpy( sv.configstrings[CS_NAME], server, MAX_QPATH );
    Q_strlcpy( sv.name, server, sizeof( sv.name ) );
    
    if( Cvar_VariableInteger( "deathmatch" ) ) {
        sprintf( sv.configstrings[CS_AIRACCEL],
            "%d", sv_airaccelerate->integer );
    } else {
        strcpy( sv.configstrings[CS_AIRACCEL], "0" );
    }

#if !USE_CLIENT
    resolve_masters();
#endif

    override_entity_string( server );

    sv.cm = *cm;
    sprintf( sv.configstrings[CS_MAPCHECKSUM], "%d", ( int )cm->cache->checksum );

    // set inline model names
    Q_concat( sv.configstrings[CS_MODELS + 1], MAX_QPATH, "maps/", server, ".bsp", NULL );
    for( i = 1; i < cm->cache->nummodels; i++ ) {
        sprintf( sv.configstrings[ CS_MODELS + 1 + i ], "*%d", i );
    }

    //
    // clear physics interaction links
    //
    SV_ClearWorld();

    //
    // spawn the rest of the entities on the map
    //  

    // precache and static commands can be issued during
    // map initialization
    sv.state = ss_loading;

    X86_PUSH_FPCW;
    X86_SINGLE_FPCW;

    // load and spawn all other entities
    ge->SpawnEntities ( sv.name, sv.entitystring ?
        sv.entitystring : cm->cache->entitystring, spawnpoint );

    // run two frames to allow everything to settle
    ge->RunFrame (); sv.framenum++;
    ge->RunFrame (); sv.framenum++;

    X86_POP_FPCW;

    // make sure maxclients string is correct
    sprintf( sv.configstrings[CS_MAXCLIENTS], "%d", sv_maxclients->integer );

    // all precaches are complete
    sv.state = ss_game;

#if USE_MVD_SERVER
    // respawn dummy MVD client, set base states, etc
    SV_MvdMapChanged();
#endif

    // set serverinfo variable
    SV_InfoSet( "mapname", sv.name );
    SV_InfoSet( "port", net_port->string );

    Cvar_SetInteger( sv_running, ss_game, FROM_CODE );
    Cvar_Set( "sv_paused", "0" );
    Cvar_Set( "timedemo", "0" );

    EXEC_TRIGGER( sv_changemapcmd );

#if USE_SYSCON
    SV_SetConsoleTitle();
#endif

    SV_BroadcastCommand( "reconnect\n" );

    Com_Printf ("-------------------------------------\n");
}
예제 #11
0
/*
============
Cvar_Set
============
*/
void Cvar_Set (const char *var_name, const char *value)
{
	cvar_t		*var;
	size_t		varlen;

	var = Cvar_FindVar (var_name);
	if (!var)
	{	// there is an error in C code if this happens
		Con_Printf ("%s: variable %s not found\n", __thisfunc__, var_name);
		return;
	}

	if ( var->flags & (CVAR_ROM|CVAR_LOCKED) )
		return;	// cvar is marked read-only or locked temporarily

	if (var->flags & CVAR_REGISTERED)
	{
		if ( !strcmp(var->string, value) )
			return;	// no change
	}
	else
	{
		var->flags |= CVAR_REGISTERED;
	}

	varlen = strlen(value);
	if (var->string == NULL)
	{
		var->string = (char *) Z_Malloc (varlen + 1, Z_MAINZONE);
	}
	else if (strlen(var->string) != varlen)
	{
		Z_Free ((void *)var->string);	// free the old value string
		var->string = (char *) Z_Malloc (varlen + 1, Z_MAINZONE);
	}

	memcpy ((char *)var->string, value, varlen + 1);
	var->value = atof (var->string);
	var->integer = (int) var->value;

// handle notifications
#if defined (H2W)
#   if defined(SERVERONLY)
	if (var->flags & CVAR_SERVERINFO)
	{
		Info_SetValueForKey (svs.info, var_name, value, MAX_SERVERINFO_STRING);
		SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);
	}
#   else /* HWCL */
	if (var->flags & CVAR_USERINFO)
	{
		Info_SetValueForKey (cls.userinfo, var_name, value, MAX_INFO_STRING);
		if (cls.state >= ca_connected)
		{
			MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
			SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var_name, value));
		}
	}
#   endif
#else	/* ! H2W */
	if (var->flags & CVAR_NOTIFY)
	{
		if (sv.active)
			SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var_name, value);
	}
#endif	/* H2W	*/

// don't allow deathmatch and coop at the same time
#if !defined(H2W) || defined(SERVERONLY)
	if ( !strcmp(var->name, deathmatch.name) )
	{
		if (var->integer != 0)
			Cvar_Set("coop", "0");
	}
	else if ( !strcmp(var->name, coop.name) )
	{
		if (var->integer != 0)
			Cvar_Set("deathmatch", "0");
	}
#endif	/* coop && deathmatch */
}
예제 #12
0
파일: cvar.cpp 프로젝트: Adidasman1/rehlds
/* <18805> ../engine/cvar.c:198 */
void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value)
{
	if (!var || !value)
	{
		return;
	}

	const char *pszValue = value;
	char szNew[MAX_CVAR_VALUE];
	szNew[0] = 0;

	if (var->flags & FCVAR_PRINTABLEONLY)
	{
		if (Q_UnicodeValidate(value))
		{
			Q_strncpy(szNew, value, ARRAYSIZE(szNew) - 1);
			szNew[ARRAYSIZE(szNew) - 1] = 0;
		}
		else
		{
			// Copy only printable chars
			// TODO: Why not UTF-8 too?
			const char *pS = pszValue;
			char *pD = szNew;

			while (*pS)
			{
				if (*pS < 32 || *pS > 126)
				{
					pS++;
					continue;
				}
				*pD++ = *pS++;
			}
			*pD = 0;
		}

		if (!Q_UnicodeValidate(szNew))
		{
			// Call the artillery
			Q_UnicodeRepair(szNew);
		}

		if (szNew[0] == 0)
		{
			Q_strcpy(szNew, "empty");
		}

		pszValue = szNew;
	}

	if (var->flags & FCVAR_NOEXTRAWHITEPACE)
	{
		if (pszValue != szNew)
		{
			Q_strncpy(szNew, value, ARRAYSIZE(szNew) - 1);
			szNew[ARRAYSIZE(szNew) - 1] = 0;
		}

		Q_StripUnprintableAndSpace(szNew);

		pszValue = szNew;
	}

	qboolean changed = Q_strcmp(var->string, pszValue);

	if (var->flags & FCVAR_USERINFO)
	{
		if (g_pcls.state == ca_dedicated)
		{
			char *info = Info_Serverinfo();
			Info_SetValueForKey(info, var->name, pszValue, MAX_INFO_STRING);
			SV_BroadcastCommand("fullserverinfo \"%s\"\n", info);
		}
#ifndef SWDS
		else
		{
			Info_SetValueForKey(g_pcls.userinfo, var->name, pszValue, MAX_INFO_STRING);

			if (changed && g_pcls.state >= ca_connected)
			{
				MSG_WriteByte(&g_pcls.netchan.message, clc_stringcmd);
				SZ_Print(&g_pcls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var->name, pszValue));
			}
		}
#endif
	}

	if (changed && var->flags & FCVAR_SERVER)
	{
		if (!(var->flags & FCVAR_UNLOGGED))
		{
			if (var->flags & FCVAR_PROTECTED)
			{
				Log_Printf("Server cvar \"%s\" = \"%s\"\n", var->name, "***PROTECTED***");
				SV_BroadcastPrintf("\"%s\" changed to \"%s\"\n", var->name, "***PROTECTED***");
			}
			else
			{
				Log_Printf("Server cvar \"%s\" = \"%s\"\n", var->name, pszValue);
				SV_BroadcastPrintf("\"%s\" changed to \"%s\"\n", var->name, pszValue);
			}
		}

		if (!(var->flags & FCVAR_PROTECTED))
		{
			Steam_SetCVar(var->name, pszValue);
		}
		else if (pszValue[0] && Q_stricmp(pszValue, "none"))
		{
			Steam_SetCVar(var->name, "1");
		}
		else
		{
			Steam_SetCVar(var->name, "0");
		}
	}

	Z_Free(var->string);
	var->string = (char *)Z_Malloc(Q_strlen(pszValue) + 1);
	Q_strcpy(var->string, pszValue);
	var->value = (float)Q_atof(var->string);
}
예제 #13
0
/*
 * ======================
 * SV_Map
 *
 * the full syntax is:
 *
 * map [*]<map>$<startspot>+<nextserver>
 *
 * command from the console or progs.
 * Map can also be a.cin, .pcx, or .dm2 file
 * Nextserver is used to allow a cinematic to play, then proceed to
 * another level:
 *
 *      map tram.cin+jail_e3
 * ======================
 */
void SV_Map(qboolean attractloop, char *levelstring, qboolean loadgame)
{
    char level[MAX_QPATH];
    char *ch;
    int  l;
    char spawnpoint[MAX_QPATH];

    sv.loadgame    = loadgame;
    sv.attractloop = attractloop;

    if ((sv.state == ss_dead) && !sv.loadgame)
    {
        SV_InitGame();          // the game is just starting
    }
    // r1ch fix: buffer overflow
//	strcpy (level, levelstring);
    strncpy(level, levelstring, sizeof(level) - 1);

    // if there is a + in the map, set nextserver to the remainder
    ch = strstr(level, "+");
    if (ch)
    {
        *ch = 0;
        Cvar_Set("nextserver", va("gamemap \"%s\"", ch + 1));
    }
    else
    {
        Cvar_Set("nextserver", "");
    }

    //ZOID special hack for end game screen in coop mode
    if (Cvar_VariableValue("coop") && !Q_strcasecmp(level, "victory.pcx"))
    {
        Cvar_Set("nextserver", "gamemap \"*base1\"");
    }

    // if there is a $, use the remainder as a spawnpoint
    ch = strstr(level, "$");
    if (ch)
    {
        *ch = 0;
        strcpy(spawnpoint, ch + 1);
    }
    else
    {
        spawnpoint[0] = 0;
    }

    // skip the end-of-unit flag if necessary
    if (level[0] == '*')
    {
        strcpy(level, level + 1);
    }

    l = strlen(level);
#ifdef  ROQ_SUPPORT
    if ((l > 4) && (!strcmp(level + l - 4, ".cin") || !strcmp(level + l - 4, ".roq")))
#else
    if ((l > 4) && !strcmp(level + l - 4, ".cin"))
#endif // ROQ_SUPPORT
    {
        if (!dedicated->value)
        {
#ifndef DEDICATED_ONLY                 
            SCR_BeginLoadingPlaque();                                   // for local system
#endif            
        }
        SV_BroadcastCommand("changing\n");
        SV_SpawnServer(level, spawnpoint, ss_cinematic, attractloop, loadgame);
    }
    else if ((l > 4) && !strcmp(level + l - 4, ".dm2"))
    {
        if (!dedicated->value)
        {
#ifndef DEDICATED_ONLY                 
            SCR_BeginLoadingPlaque();                                   // for local system
#endif            
        }
        SV_BroadcastCommand("changing\n");
        SV_SpawnServer(level, spawnpoint, ss_demo, attractloop, loadgame);
    }
    else if ((l > 4) && !strcmp(level + l - 4, ".pcx"))
    {
        if (!dedicated->value)
        {
#ifndef DEDICATED_ONLY                 
            SCR_BeginLoadingPlaque();                                   // for local system
#endif            
        }
        SV_BroadcastCommand("changing\n");
        SV_SpawnServer(level, spawnpoint, ss_pic, attractloop, loadgame);
    }
    else
    {
        if (!dedicated->value)
        {
#ifndef DEDICATED_ONLY                 
            SCR_BeginLoadingPlaque();                                   // for local system
#endif            
        }
        SV_BroadcastCommand("changing\n");
        SV_SendClientMessages();
        SV_SpawnServer(level, spawnpoint, ss_game, attractloop, loadgame);
        Cbuf_CopyToDefer();
    }

    SV_BroadcastCommand("reconnect\n");
}
예제 #14
0
/*
======================
SV_Map

  the full syntax is:

  map [*]<map>$<startspot>+<nextserver>

command from the console or progs.
Map can also be a.cin, .pcx, or .dm2 file
Nextserver is used to allow a cinematic to play, then proceed to
another level:

	map tram.cin+jail_e3
======================
*/
void SV_Map (qboolean attractloop, const char *levelstring, qboolean loadgame)
{
	char	level[MAX_QPATH];
	char	*ch;
	int		l;
	char	spawnpoint[MAX_QPATH];

	strcpy(level, levelstring); // jit - copy level string before it gets modified by other commands (since it's a command argument)
	sv.loadgame = loadgame;
	sv.attractloop = attractloop;

	if (sv.state == ss_dead && !sv.loadgame)
		SV_InitGame();	// the game is just starting

	// if there is a + in the map, set nextserver to the remainder
	ch = strstr(level, "+");

	if (ch)
	{
		*ch = 0;
		Cvar_Set("nextserver", va("gamemap \"%s\"", ch + 1));
	}
	else
	{
		Cvar_Set("nextserver", "");
	}

	//ZOID special hack for end game screen in coop mode
	if (Cvar_VariableValue("coop") && Q_strcaseeq(level, "victory.pcx"))
		Cvar_Set("nextserver", "gamemap \"*base1\"");

	// if there is a $, use the remainder as a spawnpoint
	ch = strstr(level, "$");

	if (ch)
	{
		*ch = 0;
		strcpy(spawnpoint, ch + 1);
	}
	else
	{
		spawnpoint[0] = 0;
	}

	// skip the end-of-unit flag if necessary
	if (level[0] == '*')
		strcpy (level, level+1);

	l = strlen(level);

	if (l > 4 && Q_streq(level + l - 4, ".cin"))
	{
		SCR_BeginLoadingPlaque(NULL);			// for local system
		SV_BroadcastCommand("changing\n");
		SV_SpawnServer(level, spawnpoint, ss_cinematic, attractloop, loadgame);
	}
	else if (l > 4 && Q_streq(level + l - 4, ".dm2"))
	{
		SCR_BeginLoadingPlaque(NULL);			// for local system
		SV_BroadcastCommand("changing\n");
		SV_SpawnServer(level, spawnpoint, ss_demo, attractloop, loadgame);
	}
	else if (l > 4 && Q_streq(level + l - 4, ".pcx"))
	{
		SCR_BeginLoadingPlaque(NULL);			// for local system
		SV_BroadcastCommand("changing\n");
		SV_SpawnServer(level, spawnpoint, ss_pic, attractloop, loadgame);
	}
	else
	{
		char changing_cmd[1024];

		if (!dedicated->value)
			SCR_BeginLoadingPlaque(level);			// for local system

		Com_sprintf(changing_cmd, sizeof(changing_cmd), "changing \"%s\"\n", level);
		SV_BroadcastCommand(changing_cmd);
		SV_SendClientMessages();
		SV_SpawnServer(level, spawnpoint, ss_game, attractloop, loadgame);
		Cbuf_CopyToDefer();
	}

	SV_BroadcastCommand("reconnect\n");
}