当前位置: 首页>>代码示例>>C++>>正文


C++ Com_ServerState函数代码示例

本文整理汇总了C++中Com_ServerState函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_ServerState函数的具体用法?C++ Com_ServerState怎么用?C++ Com_ServerState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Com_ServerState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CL_Connect_f

void CL_Connect_f(void)
{
  char *server;

  if (Cmd_Argc() != 2) {
    Com_Printf("usage: connect <server>\n");
    return;
  }

  if (Com_ServerState()) {
    /* if running a local server, kill it and reissue
       note: this is connect with the save game system */
    SV_Shutdown("Server quit\n", false);
  } else {
    CL_Disconnect();
  }

  server = Cmd_Argv(1);

  NET_Config(true); /* allow remote */

  CL_Disconnect();

  cls.state = ca_connecting;
  Q_strlcpy(cls.servername, server, sizeof(cls.servername));
  cls.connect_time = -99999; /* HACK: CL_CheckForResend() will fire immediately */
}
开发者ID:greck2908,项目名称:qengine,代码行数:27,代码来源:cl_network.c

示例2: SV_FindIndex

/**
 * @brief Search the index in the config strings relative to a given start
 * @param name The value of the config string to search the index for
 * @param start The relative start point for the search
 * @param max The max. searched entries in the config string before giving up
 * @param create if @c true the value will get written into the config strings (appended)
 * @return @c 0 if not found
 */
static unsigned int SV_FindIndex (const char *name, int start, int max, qboolean create)
{
	int i;

	if (!name || !name[0])
		return 0;

	for (i = 1; i < max && SV_GetConfigString(start + i)[0] != '\0'; i++) {
		const char *configString = SV_GetConfigString(start + i);
		if (Q_streq(configString, name))
			return i;
	}

	if (!create)
		return 0;

	if (i == max)
		Com_Error(ERR_DROP, "*Index: overflow '%s' start: %i, max: %i", name, start, max);

	SV_SetConfigString(start + i, name);

	if (Com_ServerState() != ss_loading) {	/* send the update to everyone */
		struct dbuffer *msg = new_dbuffer();
		NET_WriteByte(msg, svc_configstring);
		NET_WriteShort(msg, start + i);
		NET_WriteString(msg, name);
		SV_Multicast(~0, msg);
	}

	return i;
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:39,代码来源:sv_game.c

示例3: Cvar_FixCheatVars

/**
 * @brief Reset cheat cvar values to default
 * @sa CL_SendCommand
 */
void Cvar_FixCheatVars (void)
{
	if (!(Com_ServerState() && !Cvar_GetInteger("sv_cheats")))
		return;

	for (cvar_t* var = cvarVars; var; var = var->next) {
		if (!(var->flags & CVAR_CHEAT))
			continue;

		if (!var->defaultString) {
			Com_Printf("Cheat cvars: Cvar %s has no default value\n", var->name);
			continue;
		}

		if (Q_streq(var->string, var->defaultString))
			continue;

		/* also remove the oldString value here */
		Mem_Free(var->oldString);
		var->oldString = nullptr;
		Mem_Free(var->string);
		var->string = Mem_PoolStrDup(var->defaultString, com_cvarSysPool, 0);
		var->value = atof(var->string);
		var->integer = atoi(var->string);

		Com_Printf("'%s' is a cheat cvar - activate sv_cheats to use it.\n", var->name);
	}
}
开发者ID:drone-pl,项目名称:ufoai,代码行数:32,代码来源:cvar.cpp

示例4: CL_Disconnect

/**
 * @brief Sets the @c cls.state to @c ca_disconnected and informs the server
 * @sa CL_Drop
 * @note Goes from a connected state to disconnected state
 * Sends a disconnect message to the server
 * This is also called on @c Com_Error, so it shouldn't cause any errors
 */
void CL_Disconnect (void)
{
	if (cls.state < ca_connecting)
		return;

	Com_Printf("Disconnecting...\n");

	/* send a disconnect message to the server */
	if (!Com_ServerState()) {
		dbuffer msg;
		NET_WriteByte(&msg, clc_stringcmd);
		NET_WriteString(&msg, NET_STATE_DISCONNECT "\n");
		NET_WriteMsg(cls.netStream, msg);
		/* make sure, that this is send */
		NET_Wait(0);
	}

	NET_StreamFinished(cls.netStream);
	cls.netStream = nullptr;

	CL_ClearState();

	S_Stop();

	R_ShutdownModels(false);
	R_FreeWorldImages();

	CL_SetClientState(ca_disconnected);
	CL_ClearBattlescapeEvents();
	GAME_EndBattlescape();
}
开发者ID:Astrocoderguy,项目名称:ufoai,代码行数:38,代码来源:cl_main.cpp

示例5: SCR_SetLoadingBackground

/**
 * @brief Updates needed cvar for loading screens
 * @param[in] mapString The mapstring of the map that is currently loaded
 * @note If @c mapString is NULL the @c sv_mapname cvar is used
 * @return The loading/background pic path
 */
static const image_t* SCR_SetLoadingBackground (const char *mapString)
{
	const char *mapname;
	image_t* image;

	if (!mapString || Com_ServerState())
		mapname = Cvar_GetString("sv_mapname");
	else {
		mapname = mapString;
		Cvar_Set("sv_mapname", mapString);
	}

	/* we will try to load the random map shots by just removing the + from the beginning */
	if (mapname[0] == '+')
		mapname++;

	image = R_FindImage(va("pics/maps/loading/%s", mapname), it_worldrelated);
	if (image == r_noTexture)
		image = R_FindImage("pics/maps/loading/default", it_pic);

	/* strip away the pics/ part */
	Cvar_Set("mn_mappicbig", image->name + 5);

	return image;
}
开发者ID:ptitSeb,项目名称:UFO--AI-OpenPandora,代码行数:31,代码来源:cl_screen.c

示例6: M_PushMenu

void M_PushMenu ( menuframework_s *menu )
{
	int		i;

	if (Cvar_VariableIntValue ("maxclients") == 1 
		&& Com_ServerState () && !cl_paused->integer)
		Cvar_Set ("paused", "1");

	// if this menu is already present, drop back to that level
	// to avoid stacking menus by hotkeys
	for( i=0 ; i<m_menudepth ; i++ ) {
		if( m_layers[i] == menu ) {
			break;
		}
	}

	if (i == m_menudepth)
	{
		if (m_menudepth >= MAX_MENU_DEPTH)
			Com_Error (ERR_FATAL, "M_PushMenu: MAX_MENU_DEPTH");
		m_layers[m_menudepth++] = menu;
	}
	else {
		m_menudepth = i+1;
	}

	m_active = menu;

	m_entersound = true;

	cls.key_dest = key_menu;
}
开发者ID:chrisnew,项目名称:quake2,代码行数:32,代码来源:ui_atoms.c

示例7: CL_RequestNextDownload

/**
 * @brief
 * @note Called after precache was sent from the server
 * @sa SV_Configstrings_f
 * @sa CL_Precache_f
 */
void CL_RequestNextDownload (void)
{
	if (cls.state != ca_connected) {
		Com_Printf("CL_RequestNextDownload: Not connected (%i)\n", cls.state);
		return;
	}

	/* Use the map data from the server */
	cl.mapTiles = SV_GetMapTiles();
	cl.mapData = SV_GetMapData();

	/* as a multiplayer client we have to load the map here and
	 * check the compatibility with the server */
	if (!Com_ServerState() && !CL_CanMultiplayerStart())
		return;

	CL_ViewLoadMedia();

	dbuffer msg(7);
	/* send begin */
	/* this will activate the render process (see client state ca_active) */
	NET_WriteByte(&msg, clc_stringcmd);
	/* see CL_StartGame */
	NET_WriteString(&msg, NET_STATE_BEGIN "\n");
	NET_WriteMsg(cls.netStream, msg);

	cls.waitingForStart = CL_Milliseconds();

	S_MumbleLink();
}
开发者ID:Astrocoderguy,项目名称:ufoai,代码行数:36,代码来源:cl_main.cpp

示例8: CL_Connect_f

/*
================
CL_Connect_f

================
*/
void CL_Connect_f (void)
{
	char	*server;

	if (Cmd_Argc() != 2)
	{
		Com_Printf ("usage: connect <server>\n");
		return;	
	}
	
	if (Com_ServerState ())
	{	// if running a local server, kill it and reissue
		SV_Shutdown (va("Server quit\n", msg), false);
	}
	else
	{
		CL_Disconnect ();
	}

	server = Cmd_Argv (1);

	NET_Config (true);		// allow remote

	CL_Disconnect ();

	cls.state = ca_connecting;
	strncpy (cls.servername, server, sizeof(cls.servername)-1);
	cls.connect_time = -99999;	// CL_CheckForResend() will fire immediately
}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:35,代码来源:cl_main.c

示例9: StartServerActionFunc

void StartServerActionFunc (void *self)
{
	char	startmap[1024];
    float timelimit;
    float fraglimit;
    float maxclients;
	char	*spot;

	strcpy (startmap, strchr (mapnames[s_startmap_list.curvalue], '\n') + 1);

    maxclients = (float)strtod(s_maxclients_field.buffer, (char **)NULL);
    timelimit = (float)strtod(s_timelimit_field.buffer, (char **)NULL);
    fraglimit = (float)strtod(s_fraglimit_field.buffer, (char **)NULL);

	Cvar_SetValue ("maxclients", Q_Clamp (0, maxclients, maxclients));
	Cvar_SetValue ("timelimit", Q_Clamp (0, timelimit, timelimit));
	Cvar_SetValue ("fraglimit", Q_Clamp (0, fraglimit, fraglimit));
	Cvar_Set ("hostname", s_hostname_field.buffer);

	Cvar_SetValue ("deathmatch", (float)!s_rules_box.curvalue);
	Cvar_SetValue ("coop", (float)s_rules_box.curvalue);

	spot = NULL;

	// coop spawns
	if (s_rules_box.curvalue == 1)
	{
		if (Q_stricmp (startmap, "bunk1") == 0)
			spot = "start";
		else if (Q_stricmp (startmap, "mintro") == 0)
			spot = "start";
		else if (Q_stricmp (startmap, "fact1") == 0)
			spot = "start";
		else if (Q_stricmp (startmap, "power1") == 0)
			spot = "pstart";
		else if (Q_stricmp (startmap, "biggun") == 0)
			spot = "bstart";
		else if (Q_stricmp (startmap, "hangar1") == 0)
			spot = "unitstart";
		else if (Q_stricmp (startmap, "city1") == 0)
			spot = "unitstart";
		else if (Q_stricmp (startmap, "boss1") == 0)
			spot = "bosstart";
	}

	if (spot)
	{
		if (Com_ServerState())
			Cbuf_AddText ("disconnect\n");

		Cbuf_AddText (va ("gamemap \"*%s$%s\"\n", startmap, spot));
	}
	else
	{
		Cbuf_AddText (va ("map %s\n", startmap));
	}

	M_ForceMenuOff ();
}
开发者ID:raynorpat,项目名称:cake,代码行数:59,代码来源:menu_mp_startserver.c

示例10: CL_ParseServerData

/*
==================
CL_ParseServerData
==================
*/
void CL_ParseServerData(void)
{
    extern cvar_t * fs_gamedirvar;
    char * str;
    int i;

    Com_DPrintf("Serverdata packet received.\n");
    //
    // wipe the client_state_t struct
    //
    CL_ClearState();
    cls.state = ca_connected;

    // parse protocol version number
    i = MSG_ReadLong(&net_message);
    cls.serverProtocol = i;

    // BIG HACK to let demos from release work with the 3.0x patch!!!
    if (Com_ServerState() && PROTOCOL_VERSION == 34)
    {
    }
    else if (i != PROTOCOL_VERSION)
    {
        Com_Error(ERR_DROP, "Server returned version %i, not %i", i, PROTOCOL_VERSION);
    }

    cl.servercount = MSG_ReadLong(&net_message);
    cl.attractloop = MSG_ReadByte(&net_message);

    // game directory
    str = MSG_ReadString(&net_message);
    strncpy(cl.gamedir, str, sizeof(cl.gamedir) - 1);

    // set gamedir
    if ((*str && (!fs_gamedirvar->string || !*fs_gamedirvar->string || strcmp(fs_gamedirvar->string, str))) || (!*str && (fs_gamedirvar->string || *fs_gamedirvar->string)))
        Cvar_Set("game", str);

    // parse player entity number
    cl.playernum = MSG_ReadShort(&net_message);

    // get the full level name
    str = MSG_ReadString(&net_message);

    if (cl.playernum == -1)
    {
        // playing a cinematic or showing a pic, not a level
        SCR_PlayCinematic(str);
    }
    else
    {
        // separate the printfs so the server message can have a color
        Com_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
        Com_Printf("%c%s\n", 2, str);

        // need to prep refresh at next opportunity
        cl.refresh_prepped = false;
    }
}
开发者ID:glampert,项目名称:quake2-for-ps2,代码行数:63,代码来源:cl_parse.c

示例11: M_Menu_SaveGame_f

void M_Menu_SaveGame_f (void)
{
	if (!Com_ServerState())
		return;		// not playing a game

	SaveGame_MenuInit();
	M_PushMenu( &s_savegame_menu );
	Create_Savestrings ();
}
开发者ID:chrisnew,项目名称:quake2,代码行数:9,代码来源:ui_loadsavegame.c

示例12: LegacyProtocol

/*
==================
LegacyProtocol
A utility function that determines
if parsing of old protocol should be used.
==================
*/
qboolean LegacyProtocol (void)
{
	//if (dedicated->value)	// Server always uses new protocol
	//	return false;
	if ( (Com_ServerState() && cls.serverProtocol <= OLD_PROTOCOL_VERSION)
		|| (cls.serverProtocol == OLD_PROTOCOL_VERSION) )
		return true;
	return false;
}
开发者ID:postfix,项目名称:quake2vr,代码行数:16,代码来源:cl_parse.c

示例13: CL_Pause_f

/*
==================
CL_Pause_f
==================
*/
void CL_Pause_f (void)
{
	// never pause in multiplayer
	if (Cvar_VariableValue ("maxclients") > 1 || !Com_ServerState ())
	{
		Cvar_SetValue ("paused", 0);
		return;
	}

	Cvar_SetValue ("paused", !cl_paused->value);
}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:16,代码来源:cl_main.c

示例14: CL_OnBattlescape

/**
 * @brief Check whether we are in a tactical mission as server or as client. But this
 * only means that we are able to render the map - not that the game is running (the
 * team can still be missing - see @c CL_BattlescapeRunning)
 * @note handles multiplayer and singleplayer
 * @sa CL_BattlescapeRunning
 * @return true when we are in battlefield
 */
bool CL_OnBattlescape (void)
{
	/* server_state is set to zero (ss_dead) on every battlefield shutdown */
	if (Com_ServerState())
		return true; /* server */

	/* client */
	if (cls.state >= ca_connected)
		return true;

	return false;
}
开发者ID:Qazzian,项目名称:ufoai_suspend,代码行数:20,代码来源:cl_battlescape.cpp

示例15: UI_ForceMenuOff

/*
=================
UI_ForceMenuOff
=================
*/
void UI_ForceMenuOff (void)
{
	// Knightmare- added Psychospaz's mouse support
	UI_RefreshCursorLink();
	m_drawfunc = 0;
	m_keyfunc = 0;
	cls.key_dest = key_game;
	m_menudepth = 0;
	Key_ClearStates ();
	if (!cls.consoleActive && Cvar_VariableValue ("maxclients") == 1 && Com_ServerState()) // Knightmare added
		Cvar_Set ("paused", "0");
}
开发者ID:Kiln707,项目名称:KMQuake2,代码行数:17,代码来源:ui_subsystem.c


注:本文中的Com_ServerState函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。