Xonotic
all.qh File Reference
#include <common/command/_mod.qh>
#include <common/stats.qh>
#include "config.qh"
#include "weapon.qh"
#include <common/util.qh>
#include "all.inc"
+ Include dependency graph for all.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _W_CONFIG(class, fld, T, wepname)
 
#define _W_NET(class, fld, T, wepname)
 
#define _W_PROP(class, fld, T, wepname)
 
#define _W_PROP_CVAR(wepname, fld)
 
#define _W_UPDATE(class, fld, T, wepname)
 
#define DEFAULT_FILENAME   "weapons_dump.cfg"
 
#define EVAL_REGISTER_WEAPON(...)   __VA_ARGS__
 
#define REGISTER_WEAPON(...)   EVAL_REGISTER_WEAPON(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__))
 
#define REGISTER_WEAPON_2(id, inst)   REGISTER(Weapons, WEP, id, m_id, inst)
 
#define REGISTER_WEAPON_3(id, sname, inst)
 TODO: deprecated - remove. More...
 
#define W_CONFIG(class, wepname, fld, T, m)   W_CONFIG_##m(class, fld, T, wepname)
 
#define W_CONFIG_BEGIN(class)
 
#define W_CONFIG_BOTH(class, fld, T, wepname)
 
#define W_CONFIG_END()
 
#define W_CONFIG_NONE(class, fld, T, wepname)   _W_CONFIG(class, fld, T, wepname)
 
#define W_CONFIG_PRI(class, fld, T, wepname)   _W_CONFIG(class, primary_##fld, T, wepname)
 
#define W_CONFIG_SEC(class, fld, T, wepname)   _W_CONFIG(class, secondary_##fld, T, wepname)
 
#define W_NET(class, wepname, fld, T, m)   W_NET_##m(class, fld, T, wepname)
 
#define W_NET_BEGIN(class)
 
#define W_NET_BOTH(class, fld, T, wepname)
 
#define W_NET_END()
 
#define W_NET_NONE(class, fld, T, wepname)   _W_NET(class, fld, T, wepname)
 
#define W_NET_PRI(class, fld, T, wepname)   _W_NET(class, primary_##fld, T, wepname)
 
#define W_NET_SEC(class, fld, T, wepname)   _W_NET(class, secondary_##fld, T, wepname)
 
#define W_PROP(class, wepname, fld, T, m)   W_PROP_##m(class, fld, T, wepname)
 
#define W_PROP_BEGIN(class)
 
#define W_PROP_BOTH(class, fld, T, wepname)
 
#define W_PROP_END()
 
#define W_PROP_NONE(class, fld, T, wepname)   _W_PROP(class, fld, T, wepname)
 
#define W_PROP_PRI(class, fld, T, wepname)   _W_PROP(class, primary_##fld, T, wepname)
 
#define W_PROP_SEC(class, fld, T, wepname)   _W_PROP(class, secondary_##fld, T, wepname)
 
#define W_PROPS(L, class, prefix)
 
#define W_UPDATE(class, wepname, fld, T, m)   W_UPDATE_##m(class, fld, T, wepname)
 
#define W_UPDATE_BEGIN(class)
 
#define W_UPDATE_BOTH(class, fld, T, wepname)
 
#define W_UPDATE_END()
 
#define W_UPDATE_NONE(class, fld, T, wepname)   _W_UPDATE(class, fld, T, wepname)
 
#define W_UPDATE_PRI(class, fld, T, wepname)   _W_UPDATE(class, primary_##fld, T, wepname)
 
#define W_UPDATE_SEC(class, fld, T, wepname)   _W_UPDATE(class, secondary_##fld, T, wepname)
 
#define WEP_CVAR(wepname, name)   (_wep_##wepname.wepvar_##name)
 
#define WEP_CVAR_BOTH(wepname, isprimary, name)   ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
 
#define WEP_CVAR_PRI(wepname, name)   WEP_CVAR(wepname, primary_##name)
 
#define WEP_CVAR_SEC(wepname, name)   WEP_CVAR(wepname, secondary_##name)
 
#define WEP_HARDCODED_IMPULSES   20
 
#define WEP_IMPULSE_BEGIN   230
 
#define WEP_IMPULSE_END   bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (REGISTRY_COUNT(Weapons) - 1) - 1, 253)
 
#define WEP_LAST   (REGISTRY_COUNT(Weapons) - 1)
 
#define WEPSET(id)   (WEP_##id.m_wepset)
 
#define WepSet_FromWeapon(it)   ((it).m_wepset)
 

Functions

WepSet _WepSet_FromWeapon (int i)
 
 GENERIC_COMMAND (dumpweapons, "Dump all turrets into " DEFAULT_FILENAME, false)
 
 REGISTER_WEAPON (Null, NEW(Weapon))
 
 REGISTRY (Weapons, 72) STATIC_INIT(WeaponPickup)
 
 STATIC_INIT (register_weapons_done)
 
Weapon Weapon_from_name (string s)
 

Variables

WepSet m_wepset
 
const int WEP_FIRST = 1
 
WepSet WEPSET_ALL
 
WepSet WEPSET_SUPERWEAPONS
 

Macro Definition Documentation

◆ _W_CONFIG

#define _W_CONFIG (   class,
  fld,
  T,
  wepname 
)

Definition at line 205 of file all.qh.

◆ _W_NET

#define _W_NET (   class,
  fld,
  T,
  wepname 
)

Definition at line 291 of file all.qh.

◆ _W_PROP

#define _W_PROP (   class,
  fld,
  T,
  wepname 
)

Definition at line 185 of file all.qh.

◆ _W_PROP_CVAR

#define _W_PROP_CVAR (   wepname,
  fld 
)

Definition at line 186 of file all.qh.

◆ _W_UPDATE

#define _W_UPDATE (   class,
  fld,
  T,
  wepname 
)

Definition at line 241 of file all.qh.

◆ DEFAULT_FILENAME

#define DEFAULT_FILENAME   "weapons_dump.cfg"

Definition at line 41 of file all.qh.

Referenced by GENERIC_COMMAND().

◆ EVAL_REGISTER_WEAPON

#define EVAL_REGISTER_WEAPON (   ...)    __VA_ARGS__

Definition at line 124 of file all.qh.

◆ REGISTER_WEAPON

#define REGISTER_WEAPON (   ...)    EVAL_REGISTER_WEAPON(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__))

Definition at line 123 of file all.qh.

◆ REGISTER_WEAPON_2

#define REGISTER_WEAPON_2 (   id,
  inst 
)    REGISTER(Weapons, WEP, id, m_id, inst)

Definition at line 125 of file all.qh.

◆ REGISTER_WEAPON_3

#define REGISTER_WEAPON_3 (   id,
  sname,
  inst 
)
Value:
REGISTER_WEAPON_2(id, inst); \
[[alias("WEP_" #id)]] Weapon _wep_##sname
#define REGISTER_WEAPON_2(id, inst)
Definition: all.qh:125
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41

TODO: deprecated - remove.

Definition at line 127 of file all.qh.

◆ W_CONFIG

#define W_CONFIG (   class,
  wepname,
  fld,
  T,
 
)    W_CONFIG_##m(class, fld, T, wepname)

Definition at line 192 of file all.qh.

◆ W_CONFIG_BEGIN

#define W_CONFIG_BEGIN (   class)

Definition at line 204 of file all.qh.

◆ W_CONFIG_BOTH

#define W_CONFIG_BOTH (   class,
  fld,
  T,
  wepname 
)
Value:
W_CONFIG_PRI(class, fld, T, wepname) \
W_CONFIG_SEC(class, fld, T, wepname)
#define W_CONFIG_PRI(class, fld, T, wepname)
Definition: all.qh:194

Definition at line 196 of file all.qh.

◆ W_CONFIG_END

#define W_CONFIG_END ( )

Definition at line 206 of file all.qh.

◆ W_CONFIG_NONE

#define W_CONFIG_NONE (   class,
  fld,
  T,
  wepname 
)    _W_CONFIG(class, fld, T, wepname)

Definition at line 193 of file all.qh.

◆ W_CONFIG_PRI

#define W_CONFIG_PRI (   class,
  fld,
  T,
  wepname 
)    _W_CONFIG(class, primary_##fld, T, wepname)

Definition at line 194 of file all.qh.

◆ W_CONFIG_SEC

#define W_CONFIG_SEC (   class,
  fld,
  T,
  wepname 
)    _W_CONFIG(class, secondary_##fld, T, wepname)

Definition at line 195 of file all.qh.

◆ W_NET

#define W_NET (   class,
  wepname,
  fld,
  T,
 
)    W_NET_##m(class, fld, T, wepname)

Definition at line 246 of file all.qh.

◆ W_NET_BEGIN

#define W_NET_BEGIN (   class)

Definition at line 290 of file all.qh.

◆ W_NET_BOTH

#define W_NET_BOTH (   class,
  fld,
  T,
  wepname 
)
Value:
W_NET_PRI(class, fld, T, wepname) \
W_NET_SEC(class, fld, T, wepname)
#define W_NET_PRI(class, fld, T, wepname)
Definition: all.qh:248

Definition at line 250 of file all.qh.

◆ W_NET_END

#define W_NET_END ( )

Definition at line 292 of file all.qh.

◆ W_NET_NONE

#define W_NET_NONE (   class,
  fld,
  T,
  wepname 
)    _W_NET(class, fld, T, wepname)

Definition at line 247 of file all.qh.

◆ W_NET_PRI

#define W_NET_PRI (   class,
  fld,
  T,
  wepname 
)    _W_NET(class, primary_##fld, T, wepname)

Definition at line 248 of file all.qh.

◆ W_NET_SEC

#define W_NET_SEC (   class,
  fld,
  T,
  wepname 
)    _W_NET(class, secondary_##fld, T, wepname)

Definition at line 249 of file all.qh.

◆ W_PROP

#define W_PROP (   class,
  wepname,
  fld,
  T,
 
)    W_PROP_##m(class, fld, T, wepname)

Definition at line 171 of file all.qh.

◆ W_PROP_BEGIN

#define W_PROP_BEGIN (   class)

Definition at line 178 of file all.qh.

◆ W_PROP_BOTH

#define W_PROP_BOTH (   class,
  fld,
  T,
  wepname 
)
Value:
W_PROP_PRI(class, fld, T, wepname) \
W_PROP_SEC(class, fld, T, wepname)
#define W_PROP_PRI(class, fld, T, wepname)
Definition: all.qh:173

Definition at line 175 of file all.qh.

◆ W_PROP_END

#define W_PROP_END ( )

Definition at line 188 of file all.qh.

◆ W_PROP_NONE

#define W_PROP_NONE (   class,
  fld,
  T,
  wepname 
)    _W_PROP(class, fld, T, wepname)

Definition at line 172 of file all.qh.

◆ W_PROP_PRI

#define W_PROP_PRI (   class,
  fld,
  T,
  wepname 
)    _W_PROP(class, primary_##fld, T, wepname)

Definition at line 173 of file all.qh.

◆ W_PROP_SEC

#define W_PROP_SEC (   class,
  fld,
  T,
  wepname 
)    _W_PROP(class, secondary_##fld, T, wepname)

Definition at line 174 of file all.qh.

◆ W_PROPS

#define W_PROPS (   L,
  class,
  prefix 
)
Value:
L(W_PROP_BEGIN, W_PROP, W_PROP_END, class, prefix) \
L(W_CONFIG_BEGIN, W_CONFIG, W_CONFIG_END, class, prefix) \
L(W_UPDATE_BEGIN, W_UPDATE, W_UPDATE_END, class, prefix) \
L(W_NET_BEGIN, W_NET, W_NET_END, class, prefix) \
\
#define W_UPDATE(class, wepname, fld, T, m)
Definition: all.qh:210
#define W_NET_BEGIN(class)
Definition: all.qh:290
#define W_CONFIG_END()
Definition: all.qh:206
#define W_NET(class, wepname, fld, T, m)
Definition: all.qh:246
#define W_NET_END()
Definition: all.qh:292
#define W_CONFIG(class, wepname, fld, T, m)
Definition: all.qh:192
#define W_UPDATE_END()
Definition: all.qh:242
#define W_PROP_BEGIN(class)
Definition: all.qh:178
#define W_UPDATE_BEGIN(class)
Definition: all.qh:240
#define W_PROP_END()
Definition: all.qh:188
#define W_PROP(class, wepname, fld, T, m)
Definition: all.qh:171
#define W_CONFIG_BEGIN(class)
Definition: all.qh:204

Definition at line 163 of file all.qh.

◆ W_UPDATE

#define W_UPDATE (   class,
  wepname,
  fld,
  T,
 
)    W_UPDATE_##m(class, fld, T, wepname)

Definition at line 210 of file all.qh.

◆ W_UPDATE_BEGIN

#define W_UPDATE_BEGIN (   class)

Definition at line 240 of file all.qh.

◆ W_UPDATE_BOTH

#define W_UPDATE_BOTH (   class,
  fld,
  T,
  wepname 
)
Value:
W_UPDATE_PRI(class, fld, T, wepname) \
W_UPDATE_SEC(class, fld, T, wepname)
#define W_UPDATE_PRI(class, fld, T, wepname)
Definition: all.qh:212

Definition at line 214 of file all.qh.

◆ W_UPDATE_END

#define W_UPDATE_END ( )

Definition at line 242 of file all.qh.

◆ W_UPDATE_NONE

#define W_UPDATE_NONE (   class,
  fld,
  T,
  wepname 
)    _W_UPDATE(class, fld, T, wepname)

Definition at line 211 of file all.qh.

◆ W_UPDATE_PRI

#define W_UPDATE_PRI (   class,
  fld,
  T,
  wepname 
)    _W_UPDATE(class, primary_##fld, T, wepname)

Definition at line 212 of file all.qh.

◆ W_UPDATE_SEC

#define W_UPDATE_SEC (   class,
  fld,
  T,
  wepname 
)    _W_UPDATE(class, secondary_##fld, T, wepname)

Definition at line 213 of file all.qh.

◆ WEP_CVAR

#define WEP_CVAR (   wepname,
  name 
)    (_wep_##wepname.wepvar_##name)

◆ WEP_CVAR_BOTH

#define WEP_CVAR_BOTH (   wepname,
  isprimary,
  name 
)    ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))

Definition at line 302 of file all.qh.

◆ WEP_CVAR_PRI

#define WEP_CVAR_PRI (   wepname,
  name 
)    WEP_CVAR(wepname, primary_##name)

Definition at line 300 of file all.qh.

◆ WEP_CVAR_SEC

#define WEP_CVAR_SEC (   wepname,
  name 
)    WEP_CVAR(wepname, secondary_##name)

Definition at line 301 of file all.qh.

Referenced by HUD_Crosshair(), and NET_HANDLE().

◆ WEP_HARDCODED_IMPULSES

#define WEP_HARDCODED_IMPULSES   20

Definition at line 312 of file all.qh.

◆ WEP_IMPULSE_BEGIN

#define WEP_IMPULSE_BEGIN   230

Definition at line 315 of file all.qh.

Referenced by STATIC_INIT(), and W_FixWeaponOrder().

◆ WEP_IMPULSE_END

#define WEP_IMPULSE_END   bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (REGISTRY_COUNT(Weapons) - 1) - 1, 253)

Definition at line 316 of file all.qh.

Referenced by STATIC_INIT().

◆ WEP_LAST

◆ WEPSET

#define WEPSET (   id)    (WEP_##id.m_wepset)

◆ WepSet_FromWeapon

Function Documentation

◆ _WepSet_FromWeapon()

WepSet _WepSet_FromWeapon ( int  i)

Definition at line 53 of file all.qc.

References BIT, REGISTRY_MAX, and WEP_FIRST.

Referenced by STATIC_INIT().

54 {
55  a -= WEP_FIRST;
56  if (REGISTRY_MAX(Weapons) > 24)
57  if (a >= 24)
58  {
59  a -= 24;
60  if (REGISTRY_MAX(Weapons) > 48)
61  if (a >= 24)
62  {
63  a -= 24;
64  return '0 0 1' * BIT(a);
65  }
66  return '0 1 0' * BIT(a);
67  }
68  return '1 0 0' * BIT(a);
69 }
const int WEP_FIRST
Definition: all.qh:304
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
#define REGISTRY_MAX(id)
Definition: registry.qh:17
+ Here is the caller graph for this function:

◆ GENERIC_COMMAND()

GENERIC_COMMAND ( dumpweapons  ,
"Dump all turrets into "  DEFAULT_FILENAME,
false   
)

Definition at line 43 of file all.qh.

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, DEFAULT_FILENAME, Dump_Weapon_Settings(), entity(), fclose(), FILE_WRITE, fopen(), FOREACH, LOG_HELP, LOG_HELPF, LOG_INFO, LOG_INFOF, MSG_ALL, msg_entity, new_pure, NULL, setthink, STATIC_INIT_LATE(), time, to, and void().

44 {
45  switch(request)
46  {
48  {
49  #ifdef SVQC
50  wep_config_file = -1;
51  wep_config_alsoprint = -1;
52  string filename = argv(1);
53 
54  if(filename == "")
55  {
56  filename = DEFAULT_FILENAME;
57  wep_config_alsoprint = false;
58  }
59  else if(filename == "-")
60  {
61  filename = DEFAULT_FILENAME;
62  wep_config_alsoprint = true;
63  }
64  wep_config_file = fopen(filename, FILE_WRITE);
65 
66  if(wep_config_file >= 0)
67  {
69  LOG_INFOF("Dumping weapons... File located in ^2data/data/%s^7.", filename);
70  fclose(wep_config_file);
71  wep_config_file = -1;
72  wep_config_alsoprint = -1;
73  }
74  else
75  {
76  LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
77  }
78  #else
79  LOG_INFO("Weapons dump command only works with sv_cmd.");
80  #endif
81  return;
82  }
83 
84  default:
85  case CMD_REQUEST_USAGE:
86  {
87  LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpweapons [<filename>]");
88  LOG_HELPF(" Where <filename> is the file to write (default is %s),", DEFAULT_FILENAME);
89  LOG_HELP(" if supplied with '-' output to console as well as default,");
90  LOG_HELP(" if left blank, it will only write to default.");
91  return;
92  }
93  }
94 }
#define LOG_HELPF(...)
Definition: log.qh:96
const int CMD_REQUEST_USAGE
Definition: command.qh:4
#define LOG_HELP(...)
Definition: log.qh:95
#define LOG_INFOF(...)
Definition: log.qh:71
const int CMD_REQUEST_COMMAND
Definition: command.qh:3
#define LOG_INFO(...)
Definition: log.qh:70
const float FILE_WRITE
Definition: csprogsdefs.qc:233
#define DEFAULT_FILENAME
Definition: all.qh:41
void Dump_Weapon_Settings()
Definition: config.qc:32
+ Here is the call graph for this function:

◆ REGISTER_WEAPON()

REGISTER_WEAPON ( Null  ,
NEW(Weapon  
)

◆ REGISTRY()

REGISTRY ( Weapons  ,
72   
)

Definition at line 28 of file all.qh.

References FOREACH, and NEW.

30  { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
#define NEW(cname,...)
Definition: oo.qh:105
#define FOREACH(list, cond, body)
Definition: iter.qh:19

◆ STATIC_INIT()

STATIC_INIT ( register_weapons_done  )

Definition at line 321 of file all.qh.

References _WepSet_FromWeapon(), autocvar_developer, CASE, colormapPaletteColor, entity(), ENUMCLASS, ENUMCLASS_END, FOREACH, ftos(), imp, localcmd, LOG_TRACEF, name, REGISTRY_GET, REGISTRY_MAX, REPLICATE_INIT(), shotdir, shotorg, strcat(), strzone(), substring(), vector(), W_FixWeaponOrder_AllowIncomplete(), weaponorder_byid, WEP_FLAG_SUPERWEAPON, WEP_IMPULSE_BEGIN, and WEP_IMPULSE_END.

322 {
323  string inaccessible = "";
324  FOREACH(Weapons, true, {
325  WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
326  WEPSET_ALL |= set;
327  if (it.spawnflags & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
328  if (it == WEP_Null) continue;
329  int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
330  if (imp <= WEP_IMPULSE_END)
331  localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp));
332  else
333  inaccessible = strcat(inaccessible, "\n", it.netname);
334  });
335  if (inaccessible && autocvar_developer > 0) LOG_TRACEF("Impulse limit exceeded, weapon(s) will not be directly accessible: %s", inaccessible);
336  #ifdef CSQC
337  FOREACH(Weapons, true, it.wr_init(it));
338  #endif
339  weaponorder_byid = "";
340  for (int i = REGISTRY_MAX(Weapons) - 1; i >= 1; --i)
341  if (REGISTRY_GET(Weapons, i))
342  weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
343  weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
344 }
vector WepSet
Definition: weapon.qh:11
int int int imp
Definition: impulse.qc:90
WepSet WEPSET_SUPERWEAPONS
Definition: all.qh:307
#define WEP_IMPULSE_END
Definition: all.qh:316
#define WEP_IMPULSE_BEGIN
Definition: all.qh:315
WepSet WEPSET_ALL
Definition: all.qh:306
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
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"))
WepSet _WepSet_FromWeapon(int i)
Definition: all.qc:53
#define LOG_TRACEF(...)
Definition: log.qh:82
#define REGISTRY_MAX(id)
Definition: registry.qh:17
string weaponorder_byid
Definition: weapon.qh:214
noref int autocvar_developer
Definition: log.qh:102
#define FOREACH(list, cond, body)
Definition: iter.qh:19
const int WEP_FLAG_SUPERWEAPON
Definition: weapon.qh:202
+ Here is the call graph for this function:

◆ Weapon_from_name()

Weapon Weapon_from_name ( string  s)

Definition at line 134 of file all.qh.

References FOREACH, reload_time, and X().

Referenced by readplayerstartcvars(), W_Apply_Weaponreplace(), and weapon_defaultspawnfunc().

135 {
136  FOREACH(Weapons, it != WEP_Null && it.netname == s, return it);
137  return WEP_Null;
138 }
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ m_wepset

WepSet m_wepset

Definition at line 36 of file all.qh.

◆ WEP_FIRST

◆ WEPSET_ALL

WepSet WEPSET_ALL

Definition at line 306 of file all.qh.

◆ WEPSET_SUPERWEAPONS