Xonotic
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)
 
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))
#define NEW(cname,...)
Definition: oo.qh:105
CLASS(Object) Object
Definition: oo.qh:318
entity() spawn
#define CLIENT_COMMANDS(ent, request, arguments, command)
Definition: cmd.qc:800
int m_id
Definition: effect.qh:19
string m_name
Definition: scores.qh:135

Definition at line 16 of file cl_cmd.qh.

Referenced by W_Model().

Function Documentation

◆ Cmd_Scoreboard_Help()

void Cmd_Scoreboard_Help ( )

Definition at line 357 of file scoreboard.qc.

References LOG_HELP.

Referenced by LocalCommand_hud().

358 {
359  LOG_HELP(_("You can modify the scoreboard using the ^2scoreboard_columns_set command."));
360  LOG_HELP(_("Usage:"));
361  LOG_HELP("^2scoreboard_columns_set ^3default");
362  LOG_HELP(_("^2scoreboard_columns_set ^3field1 field2 ..."));
363  LOG_HELP(_("^2scoreboard_columns_set ^7without arguments reads the arguments from the cvar scoreboard_columns"));
364  LOG_HELP(_(" ^5Note: ^7scoreboard_columns_set without arguments is executed on every map start"));
365  LOG_HELP(_("^2scoreboard_columns_set ^3expand_default ^7loads default layout and expands it into the cvar scoreboard_columns so you can edit it"));
366  LOG_HELP(_("You can use a ^3|^7 to start the right-aligned fields."));
367  LOG_HELP(_("The following field names are recognized (case insensitive):"));
368  LOG_HELP("");
369 
371  LOG_HELP("");
372 
373  LOG_HELP(_("Before a field you can put a + or - sign, then a comma separated list\n"
374  "of game types, then a slash, to make the field show up only in these\n"
375  "or in all but these game types. You can also specify 'all' as a\n"
376  "field to show all fields available for the current game mode."));
377  LOG_HELP("");
378 
379  LOG_HELP(_("The special game type names 'teams' and 'noteams' can be used to\n"
380  "include/exclude ALL teams/noteams game modes."));
381  LOG_HELP("");
382 
383  LOG_HELP(_("Example: scoreboard_columns_set name ping pl | +ctf/field3 -dm/field4"));
384  LOG_HELP(_("will display name, ping and pl aligned to the left, and the fields\n"
385  "right of the vertical bar aligned to the right."));
386  LOG_HELP(_("'field3' will only be shown in CTF, and 'field4' will be shown in all\n"
387  "other gamemodes except DM."));
388 }
void PrintScoresLabels()
Definition: scoreboard.qc:167
#define LOG_HELP(...)
Definition: log.qh:95
+ Here is the caller graph for this function:

◆ Cmd_Scoreboard_SetFields()

void Cmd_Scoreboard_SetFields ( int  )

Definition at line 412 of file scoreboard.qc.

Referenced by LocalCommand_hud().

413 {
414  TC(int, argc);
415  int i, slash;
416  string str, pattern;
417  bool have_name = false, have_primary = false, have_secondary = false, have_separator = false;
418  int missing;
419 
420  if(!gametype)
421  return; // do nothing, we don't know gametype and scores yet
422 
423  // sbt_fields uses strunzone on the titles!
424  if(!sbt_field_title[0])
425  for(i = 0; i < MAX_SBT_FIELDS; ++i)
426  sbt_field_title[i] = strzone("(null)");
427 
428  // TODO: re enable with gametype dependant cvars?
429  if(argc < 3) // no arguments provided
431 
432  if(argc < 3)
434 
435  if(argc == 3)
436  {
437  if(argv(2) == "default" || argv(2) == "expand_default")
438  {
439  if(argv(2) == "expand_default")
440  cvar_set("scoreboard_columns", SCOREBOARD_DEFAULT_COLUMNS);
442  }
443  else if(argv(2) == "all" || argv(2) == "ALL")
444  {
445  string s = "ping pl name |"; // scores without label (not really scores)
446  if(argv(2) == "ALL")
447  {
448  // scores without label
449  s = strcat(s, " ", "sum");
450  s = strcat(s, " ", "kdratio");
451  s = strcat(s, " ", "frags");
452  }
453  FOREACH(Scores, true, {
454  if(it != ps_primary)
455  if(it != ps_secondary)
456  if(scores_label(it) != "")
457  s = strcat(s, " ", scores_label(it));
458  });
459  if(ps_secondary != ps_primary)
460  s = strcat(s, " ", scores_label(ps_secondary));
461  s = strcat(s, " ", scores_label(ps_primary));
462  argc = tokenizebyseparator(strcat("0 1 ", s), " ");
463  }
464  }
465 
466 
467  sbt_num_fields = 0;
468 
469  hud_fontsize = HUD_GetFontsize("hud_fontsize");
470 
471  for(i = 1; i < argc - 1; ++i)
472  {
473  str = argv(i+1);
474  bool nocomplain = false;
475  if(substring(str, 0, 1) == "?")
476  {
477  nocomplain = true;
478  str = substring(str, 1, strlen(str) - 1);
479  }
480 
481  slash = strstrofs(str, "/", 0);
482  if(slash >= 0)
483  {
484  pattern = substring(str, 0, slash);
485  str = substring(str, slash + 1, strlen(str) - (slash + 1));
486 
487  if (!isGametypeInFilter(gametype, teamplay, false, pattern))
488  continue;
489  }
490 
491  str = strtolower(str);
494 
496  switch(str)
497  {
498  // fields without a label (not networked via the score system)
499  case "ping": sbt_field[sbt_num_fields] = SP_PING; break;
500  case "pl": sbt_field[sbt_num_fields] = SP_PL; break;
501  case "name": case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break;
502  case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break;
503  case "kd": case "kdr": case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break;
504  case "sum": case "diff": case "k-d": sbt_field[sbt_num_fields] = SP_SUM; break;
505  case "frags": sbt_field[sbt_num_fields] = SP_FRAGS; break;
506  default: // fields with a label
507  {
508  // map alternative labels
509  if (str == "damage") str = "dmg";
510  if (str == "damagetaken") str = "dmgtaken";
511 
512  FOREACH(Scores, true, {
513  if (str == strtolower(scores_label(it))) {
514  j = it;
515  goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
516  }
517  });
518 
519  // NOTE: can't check STAT(SHOWFPS) here, if checked too early it returns false anyway
520  if(!nocomplain && str != "fps") // server can disable the fps field
521  LOG_INFOF("^1Error:^7 Unknown score field: '%s'", str);
522 
523  strfree(sbt_field_title[sbt_num_fields]);
525  continue;
526 
527  LABEL(found)
529  if(j == ps_primary)
530  have_primary = true;
531  if(j == ps_secondary)
532  have_secondary = true;
533 
534  }
535  }
536  ++sbt_num_fields;
537  if(sbt_num_fields >= MAX_SBT_FIELDS)
538  break;
539  }
540 
542  have_primary = true;
543  if(scores_flags(ps_secondary) & SFL_ALLOW_HIDE)
544  have_secondary = true;
545  if(ps_primary == ps_secondary)
546  have_secondary = true;
547  missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
548 
549  if(sbt_num_fields + missing < MAX_SBT_FIELDS)
550  {
551  if(!have_name)
552  {
553  strfree(sbt_field_title[sbt_num_fields]);
554  for(i = sbt_num_fields; i > 0; --i)
555  {
557  sbt_field_size[i] = sbt_field_size[i-1];
558  sbt_field[i] = sbt_field[i-1];
559  }
561  sbt_field[0] = SP_NAME;
562  ++sbt_num_fields;
563  LOG_INFO("fixed missing field 'name'");
564 
565  if(!have_separator)
566  {
567  strfree(sbt_field_title[sbt_num_fields]);
568  for(i = sbt_num_fields; i > 1; --i)
569  {
571  sbt_field_size[i] = sbt_field_size[i-1];
572  sbt_field[i] = sbt_field[i-1];
573  }
574  sbt_field_title[1] = strzone("|");
575  sbt_field[1] = SP_SEPARATOR;
576  sbt_field_size[1] = stringwidth("|", false, hud_fontsize);
577  ++sbt_num_fields;
578  LOG_INFO("fixed missing field '|'");
579  }
580  }
581  else if(!have_separator)
582  {
583  strcpy(sbt_field_title[sbt_num_fields], "|");
585  sbt_field[sbt_num_fields] = SP_SEPARATOR;
586  ++sbt_num_fields;
587  LOG_INFO("fixed missing field '|'");
588  }
589  if(!have_secondary)
590  {
594  ++sbt_num_fields;
595  LOG_INFOF("fixed missing field '%s'", scores_label(ps_secondary));
596  }
597  if(!have_primary)
598  {
602  ++sbt_num_fields;
603  LOG_INFOF("fixed missing field '%s'", scores_label(ps_primary));
604  }
605  }
606 
607  sbt_field[sbt_num_fields] = SP_END;
608 }
PlayerScoreField sbt_field[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:43
#define stringwidth
Definition: csprogsdefs.qh:29
string TranslateScoresLabel(string label)
Definition: scoreboard.qc:168
const int MAX_SBT_FIELDS
Definition: scoreboard.qc:41
string sbt_field_title[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:45
#define strcpy(this, s)
Definition: string.qh:49
#define SCOREBOARD_DEFAULT_COLUMNS
Definition: scoreboard.qc:394
#define LOG_INFOF(...)
Definition: log.qh:71
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector HUD_GetFontsize(string cvarname)
Definition: hud.qc:111
PlayerScoreField ps_secondary
Definition: hud.qh:116
#define LOG_INFO(...)
Definition: log.qh:70
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition: util.qc:972
entity gametype
Definition: main.qh:30
#define TC(T, sym)
Definition: _all.inc:82
#define strstrofs
Definition: dpextensions.qh:42
float teamplay
Definition: progsdefs.qc:31
#define scores_flags(this)
Definition: scores.qh:140
float sbt_field_size[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:44
int sbt_num_fields
Definition: scoreboard.qc:46
#define scores_label(this)
Definition: scores.qh:139
#define tokenizebyseparator
Definition: dpextensions.qh:21
#define LABEL(id)
Definition: compiler.qh:36
PlayerScoreField ps_primary
Definition: hud.qh:116
vector hud_fontsize
Definition: main.qh:63
#define strfree(this)
Definition: string.qh:56
string autocvar_scoreboard_columns
Definition: scoreboard.qh:5
#define FOREACH(list, cond, body)
Definition: iter.qh:19
entity PlayerScoreField
Definition: scores.qh:133
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:108
+ Here is the caller graph for this function:

◆ ConsoleCommand_macro_init()

void ConsoleCommand_macro_init ( )

Definition at line 579 of file cl_cmd.qc.

References CONSOLE_COMMANDS_MOVEMENT, CONSOLE_COMMANDS_NORMAL, and isdemo().

Referenced by CSQC_Init().

580 {
581  // first init normal commands
582  #define CONSOLE_COMMAND(name, execution) \
583  { registercommand(name); }
584 
586  #undef CONSOLE_COMMAND
587 
588  // then init movement commands
589  #ifndef CAMERATEST
590  if (isdemo())
591  {
592  #endif
593  #define CONSOLE_COMMAND(name, execution) \
594  registercommand(name);
595 
597  #undef CONSOLE_COMMAND
598  #ifndef CAMERATEST
599 }
600  #endif
601 }
#define CONSOLE_COMMANDS_MOVEMENT()
Definition: cl_cmd.qc:560
#define CONSOLE_COMMANDS_NORMAL()
Definition: cl_cmd.qc:553
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LocalCommand_macro_write_aliases()

void LocalCommand_macro_write_aliases ( int  fh)

Definition at line 491 of file cl_cmd.qc.

References CLIENT_COMMANDS, CMD_Write_Alias, and FOREACH.

Referenced by GENERIC_COMMAND().

492 {
493  FOREACH(CLIENT_COMMANDS, true, CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description));
494 }
#define CLIENT_COMMANDS(ent, request, arguments, command)
Definition: cmd.qc:800
#define CMD_Write_Alias(execute, command, description)
Definition: generic.qh:34
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the caller graph for this function:

◆ STATIC_INIT()

STATIC_INIT ( CLIENT_COMMANDS_aliases  )

Definition at line 24 of file cl_cmd.qh.

References FOREACH, and localcmd.

24  {
25  FOREACH(CLIENT_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl")));
26 }
#define CLIENT_COMMANDS(ent, request, arguments, command)
Definition: cmd.qc:800
#define FOREACH(list, cond, body)
Definition: iter.qh:19