示例#1
0
/*
===============
SV_StatusString

Builds the string that is sent as heartbeats and status replies
===============
*/
static const char *SV_StatusString()
{
	guard(SV_StatusString);
	static char	status[MAX_MSGLEN - 16];

	if (sv.attractloop) return "";

	int statusLength = appSprintf(ARRAY_ARG(status), "%s\n", Cvar_BitInfo(CVAR_SERVERINFO));
	for (int i = 0; i < sv_maxclients->integer; i++)
	{
		client_t *cl = &svs.clients[i];
		if (cl->state == cs_connected || cl->state == cs_spawned)
		{
			char player[256];
			int playerLength = appSprintf(ARRAY_ARG(player), "%d %d \"%s\"\n",
				cl->edict->client->ps.stats[STAT_FRAGS], cl->ping, *cl->Name);
			if (statusLength + playerLength >= sizeof(status))
				break;		// can't hold any more
			memcpy(status + statusLength, player, playerLength+1);
			statusLength += playerLength;
		}
	}

	return status;
	unguard;
}
示例#2
0
文件: cl_input.c 项目: Bad-ptr/q2pro
static void CL_SendUserinfo( void ) {
    char userinfo[MAX_INFO_STRING];
    cvar_t *var;
    int i;

    if( !cls.userinfo_modified ) {
        return;
    }

    if( cls.userinfo_modified == MAX_PACKET_USERINFOS ) {
        size_t len = Cvar_BitInfo( userinfo, CVAR_USERINFO );
        Com_DDPrintf( "%s: %u: full update\n", __func__, com_framenum );
        MSG_WriteByte( clc_userinfo );
        MSG_WriteData( userinfo, len + 1 );
        MSG_FlushTo( &cls.netchan->message );
    } else if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) {
        Com_DDPrintf( "%s: %u: %d updates\n", __func__, com_framenum,
            cls.userinfo_modified );
        for( i = 0; i < cls.userinfo_modified; i++ ) { 
            var = cls.userinfo_updates[i];
            MSG_WriteByte( clc_userinfo_delta );
            MSG_WriteString( var->name );
            if( var->flags & CVAR_USERINFO ) {
                MSG_WriteString( var->string );
            } else {
                // no longer in userinfo
                MSG_WriteString( NULL );
            }
        }
        MSG_FlushTo( &cls.netchan->message );
    } else {
        Com_WPrintf( "%s: update count is %d, should never happen.\n",
            __func__, cls.userinfo_modified );
    }

    cls.userinfo_modified = 0;
}
示例#3
0
文件: cvar.cpp 项目: drone-pl/ufoai
/**
 * @brief Returns an info string containing all the CVAR_SERVERINFO cvars
 * @sa SV_StatusString
 */
const char* Cvar_Serverinfo (char* info, size_t infoSize)
{
	info[0] = '\0';
	return Cvar_BitInfo(CVAR_SERVERINFO, info, infoSize);
}
示例#4
0
// returns an info string containing all the CVAR_SERVERINFO cvars
char	*Cvar_Serverinfo (void)
{
	return Cvar_BitInfo (CVAR_SERVERINFO);
}
示例#5
0
// returns an info string containing all the CVAR_USERINFO cvars
char	*Cvar_Userinfo (void)
{
	return Cvar_BitInfo (CVAR_USERINFO);
}