Xonotic
sv_cmd.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GameCommand_macro_write_aliases (float fh)
 
void race_deleteTime (string map, float pos)
 
void shuffleteams ()
 

Variables

bool shuffleteams_on_reset_map
 

Function Documentation

◆ GameCommand_macro_write_aliases()

void GameCommand_macro_write_aliases ( float  fh)

Definition at line 1711 of file sv_cmd.qc.

References CMD_Write_Alias, and FOREACH.

Referenced by GENERIC_COMMAND().

1712 {
1713  FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
1714 }
#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:

◆ race_deleteTime()

void race_deleteTime ( string  map,
float  pos 
)

Definition at line 452 of file race.qc.

References db_put(), db_remove, ftos(), GetMapname(), getrankings(), MSG_ALL, race_readTime(), race_readUID(), race_send_recordtime(), race_SendRanking(), record_type, ServerProgsDB, strcat(), and strcpy.

Referenced by GameCommand_delrec().

453 {
454  for(int i = pos; i <= RANKINGS_CNT; ++i)
455  {
456  string therank = ftos(i);
457  if (i == RANKINGS_CNT)
458  {
459  db_remove(ServerProgsDB, strcat(map, record_type, "time", therank));
460  db_remove(ServerProgsDB, strcat(map, record_type, "crypto_idfp", therank));
461  }
462  else
463  {
464  db_put(ServerProgsDB, strcat(map, record_type, "time", therank), ftos(race_readTime(GetMapname(), i+1)));
465  db_put(ServerProgsDB, strcat(map, record_type, "crypto_idfp", therank), race_readUID(GetMapname(), i+1));
466  }
467  }
468 
469  race_SendRanking(pos, 0, 1, MSG_ALL);
470  if(pos == 1)
472 
473  strcpy(rankings_reply, getrankings());
474 }
ERASEABLE void db_put(int db, string key, string value)
Definition: map.qh:101
string getrankings()
Definition: getreplies.qc:46
string GetMapname()
Definition: intermission.qc:18
float ServerProgsDB
Definition: world.qh:131
string race_readUID(string map, float pos)
Definition: race.qc:83
#define strcpy(this, s)
Definition: string.qh:49
string record_type
Definition: world.qh:49
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"))
void race_send_recordtime(float msg)
Definition: race.qc:251
float race_readTime(string map, float pos)
Definition: race.qc:78
#define db_remove(db, key)
Definition: map.qh:98
void race_SendRanking(float pos, float prevpos, float del, float msg)
Definition: race.qc:285
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shuffleteams()

void shuffleteams ( )

Definition at line 1245 of file sv_cmd.qc.

References bprint(), entity(), Entity_GetTeamIndex(), FOREACH_CLIENT, FOREACH_CLIENT_RANDOM, INGAME, IS_PLAYER, LOG_INFO, max(), MoveToTeam(), NULL, NUM_TEAMS, Player_HasRealForcedTeam(), TeamBalance_CheckAllowedTeams(), TeamBalance_Destroy(), TeamBalance_IsTeamAllowed(), and teamplay.

Referenced by GameCommand_shuffleteams(), and reset_map().

1246 {
1247  if (!teamplay)
1248  {
1249  LOG_INFO("Can't shuffle teams when currently not playing a team game.");
1250  return;
1251  }
1252 
1253  FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), {
1254  if (Player_HasRealForcedTeam(it)) {
1255  // we could theoretically assign forced players to their teams
1256  // and shuffle the rest to fill the empty spots but in practise
1257  // either all players or none are gonna have forced teams
1258  LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
1259  return;
1260  }
1261  });
1262 
1263  int number_of_teams = 0;
1265  for (int i = 1; i <= NUM_TEAMS; ++i)
1266  {
1267  if (TeamBalance_IsTeamAllowed(balance, i))
1268  {
1269  number_of_teams = max(i, number_of_teams);
1270  }
1271  }
1272  TeamBalance_Destroy(balance);
1273 
1274  int team_index = 0;
1275  FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || INGAME(it), {
1276  int target_team_index = team_index + 1;
1277  if (Entity_GetTeamIndex(it) != target_team_index)
1278  {
1279  MoveToTeam(it, target_team_index, 6);
1280  }
1281  team_index = (team_index + 1) % number_of_teams;
1282  });
1283 
1284  bprint("Successfully shuffled the players around randomly.\n");
1285 }
#define INGAME(it)
Definition: sv_rules.qh:20
const int NUM_TEAMS
Number of teams in the game.
Definition: teams.qh:3
bool MoveToTeam(entity client, int team_index, int type)
Moves player to the specified team.
Definition: teamplay.qc:327
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition: teamplay.qc:627
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
int Entity_GetTeamIndex(entity this)
Returns the team index of the given entity.
Definition: teamplay.qc:176
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
float teamplay
Definition: progsdefs.qc:31
bool TeamBalance_IsTeamAllowed(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition: teamplay.qc:662
#define FOREACH_CLIENT_RANDOM(cond, body)
Definition: utils.qh:55
bool Player_HasRealForcedTeam(entity player)
Returns whether player has real forced team.
Definition: teamplay.qc:341
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings...
Definition: teamplay.qc:487
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ shuffleteams_on_reset_map

bool shuffleteams_on_reset_map

Definition at line 7 of file sv_cmd.qh.

Referenced by GameCommand_shuffleteams(), MUTATOR_HOOKFUNCTION(), and reset_map().