Beispiel #1
0
/**
 * @brief Delegates all printing to the console.
 */
static void Print(const char *msg) {

	if (console_state.lock) {
		Con_Append(PRINT_HIGH, msg);
	} else {
		printf("%s", msg);
	}
}
Beispiel #2
0
/**
 * @brief Parses an incoming SVC_PRINT message.
 */
static void Cl_ParsePrint(void) {

	const byte level = Net_ReadByte(&net_message);
	const char *string = Net_ReadString(&net_message);

	// the server shouldn't have sent us anything below our level anyway
	if (level >= message_level->integer) {

		// check to see if we should ignore the message
		if (*cl_ignore->string) {

			char patterns[MAX_STRING_CHARS];
			g_strlcpy(patterns, cl_ignore->string, sizeof(patterns));

			const char *p = patterns;
			while (true) {
				const char *pattern = ParseToken(&p);
				if (pattern == NULL) {
					break;
				}

				if (GlobMatch(pattern, string)) {
					return;
				}
			}
		}

		char *sample = NULL;
		switch (level) {
			case PRINT_CHAT:
			case PRINT_TEAM_CHAT:
				if (level == PRINT_CHAT && *cl_chat_sound->string) {
					sample = cl_chat_sound->string;
				} else if (level == PRINT_TEAM_CHAT && *cl_team_chat_sound->string) {
					sample = cl_team_chat_sound->string;
				}
				break;
			default:
				break;
		}

		if (sample) {
			S_AddSample(&(const s_play_sample_t) {
				.sample = S_LoadSample(sample)
			});
		}

		Con_Append(level, string);
	}