Ejemplo n.º 1
0
char *CL_GetConfigString (int index)
{
	if (!Com_CheckConfigStringIndex(index))
		Com_Error(ERR_DROP, "invalid access to configstring array with index: %i", index);

	return cl.configstrings[index];
}
Ejemplo n.º 2
0
char *SV_SetConfigString (int index, ...)
{
	va_list ap;
	const char *value;

	if (!Com_CheckConfigStringIndex(index))
		Com_Error(ERR_FATAL, "Invalid config string index given: %i", index);

	va_start(ap, index);

	switch (index) {
	case CS_LIGHTMAP:
	case CS_MAPCHECKSUM:
	case CS_UFOCHECKSUM:
	case CS_OBJECTAMOUNT:
		value = va("%i", va_arg(ap, int));
		break;
	default:
		value = va_arg(ap, char *);
		break;
	}

	/* change the string in sv
	 * there may be overflows in i==CS_TILES - but thats ok
	 * see definition of configstrings and MAX_TILESTRINGS */
	if (index == CS_TILES || index == CS_POSITIONS)
		Q_strncpyz(sv->configstrings[index], value, MAX_TOKEN_CHARS * MAX_TILESTRINGS);
	else
		Q_strncpyz(sv->configstrings[index], value, sizeof(sv->configstrings[index]));

	va_end(ap);

	return sv->configstrings[index];
}
Ejemplo n.º 3
0
char *SV_GetConfigString (int index)
{
	if (!Com_CheckConfigStringIndex(index))
		Com_Error(ERR_FATAL, "Invalid config string index given: %i", index);

	return sv->configstrings[index];
}
Ejemplo n.º 4
0
char *CL_SetConfigString (int index, dbuffer *msg)
{
	if (!Com_CheckConfigStringIndex(index))
		Com_Error(ERR_DROP, "invalid access to configstring array with index: %i", index);

	/* change the string in cl
	 * there may be overflows in i==CS_TILES - but thats ok
	 * see definition of configstrings and MAX_TILESTRINGS */
	if (index == CS_TILES || index == CS_POSITIONS)
		NET_ReadString(msg, cl.configstrings[index], MAX_TOKEN_CHARS * MAX_TILESTRINGS);
	else
		NET_ReadString(msg, cl.configstrings[index], sizeof(cl.configstrings[index]));

	return cl.configstrings[index];
}
Ejemplo n.º 5
0
int SV_GetConfigStringLength (int index)
{
    if (!Com_CheckConfigStringIndex(index))
        Com_Error(ERR_FATAL, "Invalid config string index given: %i", index);

    switch (index) {
    case CS_ENTITYSTRING:
        return MAX_TOKEN_CHARS * MAX_ENTITYSTRINGS;
    case CS_TILES:
        return MAX_TOKEN_CHARS * MAX_TILESTRINGS;
    case CS_POSITIONS:
        return MAX_TOKEN_CHARS * MAX_TILESTRINGS;
    case CS_MODELS:
        return MAX_TOKEN_CHARS * MAX_MODELS;
    case CS_PLAYERNAMES:
        return MAX_TOKEN_CHARS * MAX_CLIENTS;
    case CS_GENERAL:
        return MAX_TOKEN_CHARS * MAX_GENERAL;
    default:
        return MAX_TOKEN_CHARS;
    }
}
Ejemplo n.º 6
0
/**
 * @sa CL_ParseConfigString
 */
static void SV_Configstring (int index, const char *fmt, ...)
{
	char val[MAX_TOKEN_CHARS * MAX_TILESTRINGS];
	va_list argptr;

	if (!Com_CheckConfigStringIndex(index))
		SV_error("configstring: bad index %i", index);

	va_start(argptr, fmt);
	Q_vsnprintf(val, sizeof(val), fmt, argptr);
	va_end(argptr);

	SV_SetConfigString(index, val);

	if (Com_ServerState() != ss_loading) { /* send the update to everyone */
		dbuffer msg(4 + strlen(val));
		NET_WriteByte(&msg, svc_configstring);
		NET_WriteShort(&msg, index);
		NET_WriteString(&msg, val);

		/* send to all clients */
		SV_Multicast(~0, msg);
	}
}