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:19
#define NEW(cname,...)
Definition oo.qh:117
#define CLASS(...)
Definition oo.qh:145
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 711 of file scoreboard.qc.

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

References LOG_HELP, and PrintScoresLabels().

Referenced by LocalCommand_hud().

◆ Cmd_Scoreboard_SetFields()

void Cmd_Scoreboard_SetFields ( int argc)

Definition at line 767 of file scoreboard.qc.

768{
769 TC(int, argc);
770 if (!gametype)
771 return; // do nothing, we don't know gametype and scores yet
772
773 int i;
774 bool have_name = false, have_primary = false, have_secondary = false, have_separator = false;
775
776 // sbt_fields uses strunzone on the titles!
777 if (!sbt_field_title[0])
778 for (i = 0; i < MAX_SBT_FIELDS; ++i)
779 sbt_field_title[i] = strzone("(null)");
780
781 // TODO: re enable with gametype dependant cvars?
782 if (argc < 3) // no arguments provided
784
785 if (argc < 3)
787
788 if (argc == 3)
789 {
790 if (argv(2) == "default" || argv(2) == "expand_default")
791 {
792 if (argv(2) == "expand_default")
793 cvar_set("scoreboard_columns", SCOREBOARD_DEFAULT_COLUMNS);
795 }
796 else if (argv(2) == "all" || argv(2) == "ALL")
797 {
798 string s = "ping pl name |"; // scores without label (not really scores)
799 if (argv(2) == "ALL")
800 {
801 // scores without label
802 s = strcat(s, " ", "sum");
803 s = strcat(s, " ", "kdratio");
804 s = strcat(s, " ", "frags");
805 }
806 FOREACH(Scores, true,
807 {
808 if (it != ps_primary && it != ps_secondary && scores_label(it) != "")
809 s = strcat(s, " ", scores_label(it));
810 });
812 s = strcat(s, " ", scores_label(ps_secondary));
813 s = strcat(s, " ", scores_label(ps_primary));
814 argc = tokenizebyseparator(strcat("0 1 ", s), " ");
815 }
816 }
817
818
819 sbt_num_fields = 0;
820
821 hud_fontsize = HUD_GetFontsize("hud_fontsize");
822
823 string str, pattern;
824 int slash;
825 bool nocomplain;
826 for (i = 1; i < argc - 1; ++i)
827 {
828 str = argv(i+1);
829 nocomplain = false;
830 if (substring(str, 0, 1) == "?")
831 {
832 nocomplain = true;
833 str = substring(str, 1, strlen(str) - 1);
834 }
835
836 slash = strstrofs(str, "/", 0);
837 if (slash >= 0)
838 {
839 pattern = substring(str, 0, slash);
840 str = substring(str, slash + 1, strlen(str) - (slash + 1));
841
842 if (!isGametypeInFilter(gametype, teamplay, false, pattern))
843 continue;
844 }
845
846 str = strtolower(str);
848
850 switch (str)
851 {
852 // fields without a label (not networked via the score system)
853 case "ping": sbt_field[sbt_num_fields] = SP_PING; break;
854 case "pl": sbt_field[sbt_num_fields] = SP_PL; break;
855 case "name":
856 case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break;
857 case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break;
858 case "kd":
859 case "kdr":
860 case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break;
861 case "sum":
862 case "diff":
863 case "k-d": sbt_field[sbt_num_fields] = SP_SUM; break;
864 case "frags": sbt_field[sbt_num_fields] = SP_FRAGS; break;
865 default: // fields with a label
866 {
867 // map alternative labels
868 if (str == "damage")
869 str = "dmg";
870 if (str == "damagetaken")
871 str = "dmgtaken";
872
873 FOREACH(Scores, str == strtolower(scores_label(it)),
874 {
875 j = it;
876 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
877 });
878
879 // NOTE: can't check STAT(SHOWFPS) here, if checked too early it returns false anyway
880 if (!nocomplain && str != "fps" && str != "skill") // server can disable the fps or skill fields
881 LOG_INFOF("^1Error:^7 Unknown score field: '%s'", str);
882
884 continue;
885
886 LABEL(found)
888 if (j == ps_primary)
889 have_primary = true;
890 if (j == ps_secondary)
891 have_secondary = true;
892
893 }
894 }
897 break;
898 }
899
901 have_primary = true;
903 have_secondary = true;
905 have_secondary = true;
906 int missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
907
908 if (sbt_num_fields + missing < MAX_SBT_FIELDS)
909 {
910 if (!have_name)
911 {
913 for (i = sbt_num_fields; i > 0; --i)
914 {
916 sbt_field[i] = sbt_field[i-1];
917 }
919 sbt_field[0] = SP_NAME;
921 LOG_INFO("fixed missing field 'name'");
922
923 if (!have_separator)
924 {
926 for (i = sbt_num_fields; i > 1; --i)
927 {
929 sbt_field[i] = sbt_field[i-1];
930 }
931 sbt_field_title[1] = strzone("|");
932 sbt_field[1] = SP_SEPARATOR;
934 LOG_INFO("fixed missing field '|'");
935 }
936 }
937 else if (!have_separator)
938 {
940 sbt_field[sbt_num_fields] = SP_SEPARATOR;
942 LOG_INFO("fixed missing field '|'");
943 }
944 if (!have_secondary)
945 {
949 LOG_INFOF("fixed missing field '%s'", scores_label(ps_secondary));
950 }
951 if (!have_primary)
952 {
956 LOG_INFOF("fixed missing field '%s'", scores_label(ps_primary));
957 }
958 }
959
960 sbt_field[sbt_num_fields] = SP_END;
962}
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:1087
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:65
#define LOG_INFOF(...)
Definition log.qh:66
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:49
string TranslateScoresLabel(string label)
PlayerScoreField sbt_field[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:44
#define SCOREBOARD_DEFAULT_COLUMNS
const int MAX_SBT_FIELDS
Definition scoreboard.qc:42
int sb_field_sizes_init
Definition scoreboard.qc:56
string sbt_field_title[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:46
string autocvar_scoreboard_columns
Definition scoreboard.qh:6
#define strfree(this)
Definition string.qh:59
#define strcpy(this, s)
Definition string.qh:52
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().