Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_cmd.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CLIENT_COMMAND(id, description)

Functions

void Cmd_Scoreboard_Help ()
void Cmd_Scoreboard_SetFields (int argc)
void ConsoleCommand_macro_init ()
void LocalCommand_macro_write_aliases (int fh)
 STATIC_INIT (CLIENT_COMMANDS_aliases)

Macro Definition Documentation

◆ CLIENT_COMMAND

#define CLIENT_COMMAND ( id,
description )
Value:
CLASS(clientcommand_##id, Command) \
ATTRIB(clientcommand_##id, m_name, string, #id); \
ATTRIB(clientcommand_##id, m_description, string, description); \
ENDCLASS(clientcommand_##id) \
REGISTER(CLIENT_COMMANDS, CMD_CL, id, m_id, NEW(clientcommand_##id)); \
METHOD(clientcommand_##id, m_invokecmd, void(clientcommand_##id this, int request, entity caller, int arguments, string command))
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string m_name
Definition scores.qh:142
int m_id
Definition effect.qh:18
#define NEW(cname,...)
Definition oo.qh:120
#define CLASS(...)
Definition oo.qh:149
this m_description
Definition pages.qc:28

Definition at line 16 of file cl_cmd.qh.

16#define CLIENT_COMMAND(id, description) \
17 CLASS(clientcommand_##id, Command) \
18 ATTRIB(clientcommand_##id, m_name, string, #id); \
19 ATTRIB(clientcommand_##id, m_description, string, description); \
20 ENDCLASS(clientcommand_##id) \
21 REGISTER(CLIENT_COMMANDS, CMD_CL, id, m_id, NEW(clientcommand_##id)); \
22 METHOD(clientcommand_##id, m_invokecmd, void(clientcommand_##id this, int request, entity caller, int arguments, string command))

Function Documentation

◆ Cmd_Scoreboard_Help()

void Cmd_Scoreboard_Help ( )

Definition at line 718 of file scoreboard.qc.

719{
720 LOG_HELP(_("You can modify the scoreboard using the ^2scoreboard_columns_set command."));
721 LOG_HELP(_("Usage:"));
722 LOG_HELP("^2scoreboard_columns_set ^3default");
723 LOG_HELP(_("^2scoreboard_columns_set ^3field1 field2 ..."));
724 LOG_HELP(_("^2scoreboard_columns_set ^7without arguments reads the arguments from the cvar scoreboard_columns"));
725 LOG_HELP(_(" ^5Note: ^7scoreboard_columns_set without arguments is executed on every map start"));
726 LOG_HELP(_("^2scoreboard_columns_set ^3expand_default ^7loads default layout and expands it into the cvar scoreboard_columns so you can edit it"));
727 LOG_HELP(_("You can use a ^3|^7 to start the right-aligned fields."));
728 LOG_HELP(_("The following field names are recognized (case insensitive):"));
729
730 LOG_HELP("");
732
733 LOG_HELP("");
734 LOG_HELP(_("Before a field you can put a + or - sign, then a comma separated list\n"
735 "of gametypes, then a slash, to make the field show up only in these\n"
736 "or in all but these gametypes. You can also specify 'all' as a\n"
737 "field to show all fields available for the current gametype."));
738
739 LOG_HELP("");
740 LOG_HELP(_("The special gametype names 'teams' and 'noteams' can be used to\n"
741 "include/exclude ALL teams/noteams gametypes."));
742
743 LOG_HELP("");
744 LOG_HELP(_("Example: scoreboard_columns_set name ping pl | +ctf/field3 -dm/field4"));
745 LOG_HELP(_("will display name, ping and pl aligned to the left, and the fields\n"
746 "right of the vertical bar aligned to the right."));
747 LOG_HELP(_("'field3' will only be shown in CTF, and 'field4' will be shown in all\n"
748 "other gametypes except DM."));
749}
#define LOG_HELP(...)
Definition log.qh:83
void PrintScoresLabels()

References LOG_HELP, and PrintScoresLabels().

Referenced by LocalCommand_hud().

◆ Cmd_Scoreboard_SetFields()

void Cmd_Scoreboard_SetFields ( int argc)

Definition at line 774 of file scoreboard.qc.

775{
776 TC(int, argc);
777 if (!gametype)
778 return; // do nothing, we don't know gametype and scores yet
779
780 int i;
781 bool have_name = false, have_primary = false, have_secondary = false, have_separator = false;
782
783 // sbt_fields uses strunzone on the titles!
784 if (!sbt_field_title[0])
785 for (i = 0; i < MAX_SBT_FIELDS; ++i)
786 sbt_field_title[i] = strzone("(null)");
787
788 // TODO: re-enable with gametype-dependent cvars?
789 if (argc < 3) // no arguments provided
791
792 if (argc < 3)
794
795 if (argc == 3)
796 {
797 if (argv(2) == "default" || argv(2) == "expand_default")
798 {
799 if (argv(2) == "expand_default")
800 cvar_set("scoreboard_columns", SCOREBOARD_DEFAULT_COLUMNS);
802 }
803 else if (argv(2) == "all" || argv(2) == "ALL")
804 {
805 string s = "ping pl name |"; // scores without label (not really scores)
806 if (argv(2) == "ALL")
807 {
808 // scores without label
809 s = strcat(s, " ", "sum");
810 s = strcat(s, " ", "kdratio");
811 s = strcat(s, " ", "frags");
812 }
813 FOREACH(Scores, it != ps_primary && it != ps_secondary && scores_label(it) != "",
814 s = strcat(s, " ", scores_label(it)));
816 s = strcat(s, " ", scores_label(ps_secondary));
817 s = strcat(s, " ", scores_label(ps_primary));
818 argc = tokenizebyseparator(strcat("0 1 ", s), " ");
819 }
820 }
821
822
823 sbt_num_fields = 0;
824
825 hud_fontsize = HUD_GetFontsize("hud_fontsize");
826
827 string str, pattern;
828 int slash;
829 bool nocomplain;
830 for (i = 1; i < argc - 1; ++i)
831 {
832 str = argv(i+1);
833 nocomplain = false;
834 if (substring(str, 0, 1) == "?")
835 {
836 nocomplain = true;
837 str = substring(str, 1, strlen(str) - 1);
838 }
839
840 slash = strstrofs(str, "/", 0);
841 if (slash >= 0)
842 {
843 pattern = substring(str, 0, slash);
844 str = substring(str, slash + 1, strlen(str) - (slash + 1));
845
846 if (!isGametypeInFilter(gametype, teamplay, false, pattern))
847 continue;
848 }
849
850 str = strtolower(str);
852
854 switch (str)
855 {
856 // fields without a label (not networked via the score system)
857 case "ping": sbt_field[sbt_num_fields] = SP_PING; break;
858 case "pl": sbt_field[sbt_num_fields] = SP_PL; break;
859 case "name":
860 case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break;
861 case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break;
862 case "kd":
863 case "kdr":
864 case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break;
865 case "sum":
866 case "diff":
867 case "k-d": sbt_field[sbt_num_fields] = SP_SUM; break;
868 case "frags": sbt_field[sbt_num_fields] = SP_FRAGS; break;
869 default: // fields with a label
870 {
871 // map alternative labels
872 if (str == "damage")
873 str = "dmg";
874 if (str == "damagetaken")
875 str = "dmgtaken";
876
877 FOREACH(Scores, str == strtolower(scores_label(it)),
878 {
879 j = it;
880 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
881 });
882
883 // NOTE: can't check STAT(SHOWFPS) here, if checked too early it returns false anyway
884 if (!nocomplain && str != "fps" && str != "skill") // server can disable the fps or skill fields
885 LOG_INFOF("^1Error:^7 Unknown score field: '%s'", str);
886
888 continue;
889
890 LABEL(found)
892 if (j == ps_primary)
893 have_primary = true;
894 if (j == ps_secondary)
895 have_secondary = true;
896
897 }
898 }
901 break;
902 }
903
905 have_primary = true;
907 have_secondary = true;
909 have_secondary = true;
910 int missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
911
912 if (sbt_num_fields + missing < MAX_SBT_FIELDS)
913 {
914 if (!have_name)
915 {
917 for (i = sbt_num_fields; i > 0; --i)
918 {
920 sbt_field[i] = sbt_field[i-1];
921 }
923 sbt_field[0] = SP_NAME;
925 LOG_INFO("fixed missing field 'name'");
926
927 if (!have_separator)
928 {
930 for (i = sbt_num_fields; i > 1; --i)
931 {
933 sbt_field[i] = sbt_field[i-1];
934 }
935 sbt_field_title[1] = strzone("|");
936 sbt_field[1] = SP_SEPARATOR;
938 LOG_INFO("fixed missing field '|'");
939 }
940 }
941 else if (!have_separator)
942 {
944 sbt_field[sbt_num_fields] = SP_SEPARATOR;
946 LOG_INFO("fixed missing field '|'");
947 }
948 if (!have_secondary)
949 {
953 LOG_INFOF("fixed missing field '%s'", scores_label(ps_secondary));
954 }
955 if (!have_primary)
956 {
960 LOG_INFOF("fixed missing field '%s'", scores_label(ps_primary));
961 }
962 }
963
964 sbt_field[sbt_num_fields] = SP_END;
966}
vector hud_fontsize
Definition main.qh:77
entity gametype
Definition main.qh:43
#define scores_label(this)
Definition scores.qh:146
entity PlayerScoreField
Definition scores.qh:140
#define scores_flags(this)
Definition scores.qh:147
const int SFL_ALLOW_HIDE
Allow a column to be hidden (do not automatically add it even if it is a sorting key).
Definition scores.qh:112
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition util.qc:1189
string strtolower(string s)
#define LABEL(id)
Definition compiler.qh:34
#define strstrofs
#define strlen
#define tokenizebyseparator
vector HUD_GetFontsize(string cvarname)
Definition hud.qc:112
PlayerScoreField ps_secondary
Definition hud.qh:117
PlayerScoreField ps_primary
Definition hud.qh:117
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define TC(T, sym)
Definition _all.inc:82
#define LOG_INFO(...)
Definition log.qh:62
#define LOG_INFOF(...)
Definition log.qh:63
void cvar_set(string name, string value)
string substring(string s, float start, float length)
string strzone(string s)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
int sbt_num_fields
Definition scoreboard.qc:52
string TranslateScoresLabel(string label)
PlayerScoreField sbt_field[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:47
#define SCOREBOARD_DEFAULT_COLUMNS
const int MAX_SBT_FIELDS
Definition scoreboard.qc:45
int sb_field_sizes_init
Definition scoreboard.qc:59
string sbt_field_title[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:49
string autocvar_scoreboard_columns
Definition scoreboard.qh:6
#define strfree(this)
Definition string.qh:57
#define strcpy(this, s)
Definition string.qh:51
bool teamplay
Definition teams.qh:59

References argv(), autocvar_scoreboard_columns, cvar_set(), FOREACH, gametype, hud_fontsize, HUD_GetFontsize(), isGametypeInFilter(), LABEL, LOG_INFO, LOG_INFOF, MAX_SBT_FIELDS, ps_primary, ps_secondary, sb_field_sizes_init, sbt_field, sbt_field_title, sbt_num_fields, SCOREBOARD_DEFAULT_COLUMNS, scores_flags, scores_label, SFL_ALLOW_HIDE, strcat(), strcpy, strfree, strlen, strstrofs, strtolower(), strzone(), substring(), TC, teamplay, tokenizebyseparator, and TranslateScoresLabel().

Referenced by LocalCommand_hud().

◆ ConsoleCommand_macro_init()

void ConsoleCommand_macro_init ( )

Definition at line 605 of file cl_cmd.qc.

606{
607 // first init normal commands
608 #define CONSOLE_COMMAND(name, execution) \
609 { registercommand(name); }
610
612 #undef CONSOLE_COMMAND
613
614 // then init movement commands
615 #ifndef CAMERATEST
616 if (isdemo())
617 {
618 #endif
619 #define CONSOLE_COMMAND(name, execution) \
620 registercommand(name);
621
623 #undef CONSOLE_COMMAND
624 #ifndef CAMERATEST
625}
626 #endif
627}
#define CONSOLE_COMMANDS_NORMAL()
Definition cl_cmd.qc:581
#define CONSOLE_COMMANDS_MOVEMENT()
Definition cl_cmd.qc:586
float isdemo()

References CONSOLE_COMMANDS_MOVEMENT, CONSOLE_COMMANDS_NORMAL, and isdemo().

Referenced by CSQC_Init().

◆ LocalCommand_macro_write_aliases()

void LocalCommand_macro_write_aliases ( int fh)

Definition at line 519 of file cl_cmd.qc.

520{
521 FOREACH(CLIENT_COMMANDS, true, CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description));
522}
#define CMD_Write_Alias(execute, command, description)
Definition generic.qh:34

References CMD_Write_Alias, and FOREACH.

Referenced by GENERIC_COMMAND().

◆ STATIC_INIT()

STATIC_INIT ( CLIENT_COMMANDS_aliases )

Definition at line 24 of file cl_cmd.qh.

24 {
25 FOREACH(CLIENT_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl")));
26}
void localcmd(string command,...)

References FOREACH, and localcmd().