예제 #1
0
qbool Cvar_Command (void)
{
	cvar_t *v;

	// check variables
	if (!(v = Cvar_Find (Cmd_Argv(0))))
		return false;

	if (Cmd_Argc() == 1) {
		if (cvar_viewhelp.value)
			Help_DescribeCvar (v);

		if (cvar_viewdefault.value) {
			char *spaces = CreateSpaces(strlen(v->name) + 2);

			Com_Printf ("%s : default value is \"%s\"\n", v->name, v->defaultvalue);

			Com_Printf ("%s current value is \"%s\"\n", spaces, v->string);

			if ((v->flags & CVAR_AUTO) && v->autoString) {
				Com_Printf ("%s auto    value is \"%s\"\n", spaces, v->autoString);
			}

			if (cvar_viewlatched.integer && v->latchedString) {
				Com_Printf ("%s latched value is \"%s\"\n", spaces, v->latchedString);
			}

		} else {
			Com_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);

			if ((v->flags & CVAR_AUTO) && v->autoString) {
				Com_Printf ("auto: \"%s\"\n", v->autoString);
			}

			if (cvar_viewlatched.integer && v->latchedString) {
				Com_Printf ("latched: \"%s\"\n", v->latchedString);
			}
		}
	} else {
		// RestrictTriggers means that advanced (possibly cheaty) scripts are not allowed
		// So we will force the usage of user-created variables to go through the set command
		if ((v->flags & CVAR_USER_CREATED) && Rulesets_RestrictTriggers()) {
			Com_Printf ("Current ruleset requires \"set\" with user created variables\n");
			return true;
		}

		Cvar_Set (v, Cmd_MakeArgs(1));
	}

	return true;
}
예제 #2
0
void TP_SearchForMsgTriggers (const char *s, int level)
{
	msg_trigger_t	*t;
	char *string;
 
	// message triggers disabled
	if (!tp_msgtriggers.value)
		return;
 
	// triggers banned by ruleset
	if (Rulesets_RestrictTriggers () && !cls.demoplayback && !cl.spectator)
		return;
 
	// we are in spec/demo mode, so play triggers if user want it
	if ((cls.demoplayback || cl.spectator) && cl_restrictions.value)
		return;
 
	for (t = msg_triggers; t; t = t->next) {
		if ((t->level == level || (t->level == 3 && level == 4)) && t->string[0] && strstr(s, t->string)) {
			if (level == PRINT_CHAT && (
			            strstr (s, "f_version") || strstr (s, "f_skins") || strstr(s, "f_fakeshaft") ||
			            strstr (s, "f_server") || strstr (s, "f_scripts") || strstr (s, "f_cmdline") ||
			            strstr (s, "f_system") || strstr (s, "f_speed") || strstr (s, "f_modified"))
			   )
				continue; // don't let llamas fake proxy replies
 
			if (cl.teamfortress && level == PRINT_HIGH && TP_IsFlagMessage (s))
				continue;
 
			if ((string = Cmd_AliasString (t->name))) {
				strlcpy(vars.lasttrigger_match, s, sizeof (vars.lasttrigger_match));
				Cbuf_AddTextEx (&cbuf_safe, va("%s\n", string));
			} else {
				Com_Printf ("trigger \"%s\" has no matching alias\n", t->name);
			}
		}
	}
}
예제 #3
0
void TP_ExecTrigger (char *trigger)
{
	int i, j, numteammates = 0;
	cmd_alias_t *alias;
 
	if (!tp_triggers.value || ((cls.demoplayback || cl.spectator) && cl_restrictions.value))
		return;
 
	for (i = 0; i < num_f_triggers; i++) {
		if (!strcmp (f_triggers[i].name, trigger))
			break;
	}

	if (i == num_f_triggers) {
		Com_Printf ("Unknown f_trigger \"%s\"", trigger);
		return;
	}
 
	if (f_triggers[i].teamplay && !tp_forceTriggers.value) {
		if (!cl.teamplay)
			return;
 
		for (j = 0; j < MAX_CLIENTS; j++)
			if (cl.players[j].name[0] && !cl.players[j].spectator && j != cl.playernum)
				if (!strcmp(cl.players[j].team, cl.players[cl.playernum].team))
					numteammates++;
 
		if (!numteammates)
			return;
	}
 
	if ((alias = Cmd_FindAlias (trigger))) {
		if (!(f_triggers[i].restricted && Rulesets_RestrictTriggers ())) {
			Cbuf_AddTextEx (&cbuf_main, va("%s\n", alias->value));
		}
	}
}
예제 #4
0
qbool CL_SearchForReTriggers (const char *s, unsigned trigger_type)
{
	pcre_trigger_t *rt;
	pcre_internal_trigger_t *irt;
	cmd_alias_t *trig_alias;
	qbool removestr = false;
	int result;
	int offsets[99];
	int len = strlen(s);
 
	// internal triggers - always enabled
	if (trigger_type < RE_PRINT_ECHO) {
		allow_re_triggers = true;
		for (irt = internal_triggers; irt; irt = irt->next) {
			if (irt->flags & trigger_type) {
				result = pcre_exec (irt->regexp, irt->regexp_extra, s, len, 0, 0, offsets, 99);
				if (result >= 0) {
					Re_Trigger_Copy_Subpatterns (s, offsets, min(result,10), re_subi);
					irt->func (s);
				}
			}
		}
		if (!allow_re_triggers)
			return false;
	}
 
	// message triggers disabled
	if (!tp_msgtriggers.value)
		return false;
 
	// triggers banned by ruleset or FPD and we are a player
	if (((cl.fpd & FPD_NO_SOUNDTRIGGERS) || (cl.fpd & FPD_NO_TIMERS) ||
	        Rulesets_RestrictTriggers ()) && !cls.demoplayback && !cl.spectator)
		return false;
 
	// we are in spec/demo mode, so play triggers if user want it
	if ((cls.demoplayback || cl.spectator) && cl_restrictions.value)
		return false;
 
	// regexp triggers
	for (rt = re_triggers; rt; rt = rt->next)
		if ( (rt->flags & RE_ENABLED) &&	// enabled
		        (rt->flags & trigger_type) &&	// mask fits
		        rt->regexp &&					// regexp not empty
		        (rt->min_interval == 0.0 ||
		         cls.realtime >= rt->min_interval + rt->lasttime)) // not too fast.
			// TODO: disable it ^^^ for FPD_NO_TIMERS case.
			// probably it dont solve re_trigger timers problem
			// you always trigger on statusbar(TF) or wp_stats (KTPro/KTX) messages and get 0.5~1.5 accuracy for your timer
		{
			result = pcre_exec (rt->regexp, rt->regexp_extra, s, len, 0, 0, offsets, 99);
			if (result >= 0) {
				rt->lasttime = cls.realtime;
				rt->counter++;
				Re_Trigger_Copy_Subpatterns (s, offsets, min(result,10), re_sub);
 
				if (!(rt->flags & RE_NOACTION)) {
					trig_alias = Cmd_FindAlias (rt->name);
					Print_current++;
					if (trig_alias) {
						Cbuf_InsertTextEx (&cbuf_safe, "\nwait\n");
						Cbuf_InsertTextEx (&cbuf_safe, rt->name);
						Cbuf_ExecuteEx (&cbuf_safe);
					} else
						Com_Printf ("re_trigger \"%s\" has no matching alias\n", rt->name);
					Print_current--;
				}
 
				if (rt->flags & RE_REMOVESTR)
					removestr = true;
				if (rt->flags & RE_NOLOG)
					Print_flags[Print_current] |= PR_LOG_SKIP;
				if (rt->flags & RE_FINAL)
					break;
			}
		}
 
	if (removestr)
		Print_flags[Print_current] |= PR_SKIP;
 
	return removestr;
}