Xonotic
main.qc File Reference
+ Include dependency graph for main.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define X(out, in)
 

Functions

void CreatureFrame_All ()
 
void CreatureFrame_FallDamage (entity this)
 
void CreatureFrame_hotliquids (entity this)
 
void CreatureFrame_Liquids (entity this)
 
void dedicated_print (string input)
 print(), but only print if the server is not local More...
 
void dropclient_do (entity this)
 
bool dropclient_schedule (entity this)
 Schedules dropclient for a player and returns true; if dropclient is already scheduled (for that player) it does nothing and returns false. More...
 
string GetField_fullspawndata (entity e, string f,...)
 
void main ()
 
void make_safe_for_remove (entity e)
 
void Pause_TryPause (bool ispaused)
 
void remove_except_protected (entity e)
 
void remove_safely (entity e)
 
void remove_unsafely (entity e)
 
void StartFrame ()
 
void SV_OnEntityPreSpawnFunction (entity this)
 
void SV_PausedTic (float elapsedtime)
 
void sys_phys_update (entity this, float dt)
 
void systems_update ()
 
void URI_Get_Callback (float id, float status, string data)
 engine callback More...
 
void WarpZone_PostInitialize_Callback ()
 

Variables

float anglejitter
 
vector anglesjitter
 
bool autocvar_sv_autopause = false
 
string cvarfilter
 
bool game_delay_last
 
string gametypefilter
 
vector originjitter
 

Macro Definition Documentation

◆ X

#define X (   out,
  in 
)
Value:
if (in != 0) { out = out + (random() * 2 - 1) * in; } \
MACRO_END
if(IS_DEAD(this))
Definition: impulse.qc:92

Referenced by SV_OnEntityPreSpawnFunction().

Function Documentation

◆ CreatureFrame_All()

void CreatureFrame_All ( )

Definition at line 175 of file main.qc.

References g_damagedbycontents, IL_EACH, and time.

Referenced by StartFrame().

176 {
177  if(game_stopped || time < game_starttime)
178  return;
179 
180  IL_EACH(g_damagedbycontents, it.damagedbycontents,
181  {
182  if (it.move_movetype == MOVETYPE_NOCLIP) continue;
183  CreatureFrame_Liquids(it);
184  CreatureFrame_FallDamage(it);
185  it.oldvelocity = it.velocity;
186  });
187 }
#define IL_EACH(this, cond, body)
IntrusiveList g_damagedbycontents
Definition: damage.qh:155
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ CreatureFrame_FallDamage()

void CreatureFrame_FallDamage ( entity  this)

Definition at line 134 of file main.qc.

References autocvar_g_balance_falldamage_deadminspeed, autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage, autocvar_g_balance_falldamage_minspeed, autocvar_g_balance_falldamage_onlyvertical, Damage(), DMG_NOWEP, fabs(), flags, hook, IS_DEAD, IS_VEHICLE, MAX_WEAPONSLOTS, maxs, min(), mins, MOVE_NOMONSTERS, NULL, oldvelocity, origin, Q3SURFACEFLAG_NODAMAGE, trace_dphitq3surfaceflags, vdist, velocity, vlen(), and weaponentities.

135 {
136  if(IS_VEHICLE(this) || (this.flags & FL_PROJECTILE))
137  return; // vehicles and projectiles don't receive fall damage
138  if(!(this.velocity || this.oldvelocity))
139  return; // if the entity hasn't moved and isn't moving, then don't do anything
140 
141  // check for falling damage
142  bool have_hook = false;
143  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
144  {
145  .entity weaponentity = weaponentities[slot];
146  if(this.(weaponentity).hook && this.(weaponentity).hook.state)
147  {
148  have_hook = true;
149  break;
150  }
151  }
152  if(!have_hook)
153  {
154  float dm; // dm is the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
156  dm = fabs(this.oldvelocity.z) - vlen(this.velocity);
157  else
158  dm = vlen(this.oldvelocity) - vlen(this.velocity);
159  if (IS_DEAD(this))
161  else
163  if (dm > 0)
164  {
165  tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
167  Damage (this, NULL, NULL, dm, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
168  }
169  }
170 
171  if(autocvar_g_maxspeed > 0 && vdist(this.velocity, >, autocvar_g_maxspeed))
172  Damage (this, NULL, NULL, 100000, DEATH_SHOOTING_STAR.m_id, DMG_NOWEP, this.origin, '0 0 0');
173 }
bool autocvar_g_balance_falldamage_onlyvertical
Definition: main.qh:15
float autocvar_g_balance_falldamage_deadminspeed
Definition: main.qh:11
entity hook
Definition: hook.qh:19
float trace_dphitq3surfaceflags
vector maxs
Definition: csprogsdefs.qc:113
origin
Definition: ent_cs.qc:114
vector oldvelocity
Definition: main.qh:38
#define DMG_NOWEP
Definition: damage.qh:126
const float MOVE_NOMONSTERS
Definition: csprogsdefs.qc:253
vector mins
Definition: csprogsdefs.qc:113
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
float Q3SURFACEFLAG_NODAMAGE
#define NULL
Definition: post.qh:17
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define IS_DEAD(s)
Definition: utils.qh:26
int autocvar_g_balance_falldamage_maxdamage
Definition: main.qh:13
#define IS_VEHICLE(v)
Definition: utils.qh:22
float autocvar_g_balance_falldamage_minspeed
Definition: main.qh:14
float flags
Definition: csprogsdefs.qc:129
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
float autocvar_g_balance_falldamage_factor
Definition: main.qh:12
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:

◆ CreatureFrame_hotliquids()

void CreatureFrame_hotliquids ( entity  this)

Definition at line 63 of file main.qc.

References ATTEN_NORM, autocvar_g_balance_contents_damagerate, autocvar_g_balance_contents_playerdamage_lava, autocvar_g_balance_contents_playerdamage_lava_burn, autocvar_g_balance_contents_playerdamage_lava_burn_time, autocvar_g_balance_contents_playerdamage_slime, autocvar_g_balance_contents_projectiledamage, CH_PLAYER_SINGLE, CONTENT_LAVA, CONTENT_SLIME, contents_damagetime, Damage(), DMG_NOWEP, Fire_AddDamage(), flags, NULL, sound, time, VOL_BASE, waterlevel, watersound_finished, and watertype.

Referenced by CreatureFrame_Liquids().

64 {
65  if (this.contents_damagetime >= time)
66  {
67  return;
68  }
69 
71 
72  if (this.flags & FL_PROJECTILE)
73  {
74  if (this.watertype == CONTENT_LAVA)
75  Damage (this, NULL, NULL, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_LAVA.m_id, DMG_NOWEP, this.origin, '0 0 0');
76  else if (this.watertype == CONTENT_SLIME)
77  Damage (this, NULL, NULL, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_SLIME.m_id, DMG_NOWEP, this.origin, '0 0 0');
78  }
79  else
80  {
81  if (STAT(FROZEN, this))
82  {
83  if (this.watertype == CONTENT_LAVA)
84  Damage(this, NULL, NULL, 10000, DEATH_LAVA.m_id, DMG_NOWEP, this.origin, '0 0 0');
85  else if (this.watertype == CONTENT_SLIME)
86  Damage(this, NULL, NULL, 10000, DEATH_SLIME.m_id, DMG_NOWEP, this.origin, '0 0 0');
87  }
88  else if (this.watertype == CONTENT_LAVA)
89  {
90  if (this.watersound_finished < time)
91  {
92  this.watersound_finished = time + 0.5;
93  sound (this, CH_PLAYER_SINGLE, SND_LAVA, VOL_BASE, ATTEN_NORM);
94  }
95  Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_LAVA.m_id, DMG_NOWEP, this.origin, '0 0 0');
98  }
99  else if (this.watertype == CONTENT_SLIME)
100  {
101  if (this.watersound_finished < time)
102  {
103  this.watersound_finished = time + 0.5;
104  sound (this, CH_PLAYER_SINGLE, SND_SLIME, VOL_BASE, ATTEN_NORM);
105  }
106  Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_SLIME.m_id, DMG_NOWEP, this.origin, '0 0 0');
107  }
108  }
109 }
float autocvar_g_balance_contents_playerdamage_lava_burn_time
Definition: main.qh:8
const float CONTENT_LAVA
Definition: csprogsdefs.qc:240
int autocvar_g_balance_contents_playerdamage_lava
Definition: main.qh:6
float watertype
Definition: progsdefs.qc:182
float autocvar_g_balance_contents_damagerate
Definition: main.qh:3
float waterlevel
Definition: progsdefs.qc:181
float watersound_finished
Definition: main.qh:40
const int CH_PLAYER_SINGLE
Definition: sound.qh:21
#define DMG_NOWEP
Definition: damage.qh:126
int autocvar_g_balance_contents_playerdamage_lava_burn
Definition: main.qh:7
const float CONTENT_SLIME
Definition: csprogsdefs.qc:239
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
const float ATTEN_NORM
Definition: sound.qh:30
int autocvar_g_balance_contents_playerdamage_slime
Definition: main.qh:9
float flags
Definition: csprogsdefs.qc:129
float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
Definition: damage.qc:1077
int autocvar_g_balance_contents_projectiledamage
Definition: main.qh:10
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
float contents_damagetime
Definition: main.qh:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreatureFrame_Liquids()

void CreatureFrame_Liquids ( entity  this)

Definition at line 111 of file main.qc.

References contents_damagetime, CreatureFrame_hotliquids(), FL_INWATER, and flags.

112 {
113  if (this.watertype <= CONTENT_WATER && this.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
114  {
115  if (!(this.flags & FL_INWATER))
116  {
117  this.flags |= FL_INWATER;
118  this.contents_damagetime = 0;
119  }
120 
122  }
123  else
124  {
125  if (this.flags & FL_INWATER)
126  {
127  // play leave water sound
128  this.flags &= ~FL_INWATER;
129  this.contents_damagetime = 0;
130  }
131  }
132 }
float flags
Definition: csprogsdefs.qc:129
void CreatureFrame_hotliquids(entity this)
Definition: main.qc:63
float contents_damagetime
Definition: main.qh:45
float FL_INWATER
Definition: progsdefs.qc:235
+ Here is the call graph for this function:

◆ dedicated_print()

void dedicated_print ( string  input)

print(), but only print if the server is not local

Definition at line 205 of file main.qc.

References print(), and server_is_dedicated.

Referenced by GameLogEcho(), and Say().

206 {
207  if (server_is_dedicated) print(input);
208 }
bool server_is_dedicated
Definition: world.qh:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dropclient_do()

void dropclient_do ( entity  this)

Definition at line 29 of file main.qc.

References owner.

Referenced by dropclient_schedule().

30 {
31  if (this.owner)
32  dropclient(this.owner);
33  delete(this);
34 }
entity owner
Definition: main.qh:73
+ Here is the caller graph for this function:

◆ dropclient_schedule()

bool dropclient_schedule ( entity  this)

Schedules dropclient for a player and returns true; if dropclient is already scheduled (for that player) it does nothing and returns false.

NOTE: this function exists only to allow sending a message to the kicked player with Send_Notification, which doesn't work if called together with dropclient

Definition at line 42 of file main.qc.

References dropclient_do(), entity(), FOREACH_ENTITY_CLASS, new_pure, setthink, and time.

Referenced by MUTATOR_HOOKFUNCTION(), PlayerPostThink(), and PlayerPreThink().

43 {
44  bool scheduled = false;
45  FOREACH_ENTITY_CLASS("dropclient_handler", true,
46  {
47  if(it.owner == this)
48  {
49  scheduled = true;
50  break; // can't use return here, compiler shows a warning
51  }
52  });
53  if (scheduled)
54  return false;
55 
56  entity e = new_pure(dropclient_handler);
58  e.owner = this;
59  e.nextthink = time + 0.1;
60  return true;
61 }
void dropclient_do(entity this)
Definition: main.qc:29
entity() spawn
#define FOREACH_ENTITY_CLASS(class, cond, body)
Definition: iter.qh:189
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetField_fullspawndata()

string GetField_fullspawndata ( entity  e,
string  f,
  ... 
)

Definition at line 400 of file main.qc.

References argv(), ftos(), LOG_WARNF, string_null, strstrofs, tokenize_console, and v.

Referenced by door_reset().

413 {
414  string v = string_null;
415 
416  if (!e.fullspawndata)
417  {
418  //LOG_WARNF("^1EDICT %s (classname %s) has no fullspawndata, engine lacks support?", ftos(num_for_edict(e)), e.classname);
419  return v;
420  }
421 
422  if (strstrofs(e.fullspawndata, "//", 0) >= 0)
423  {
424  // tokenize and tokenize_console return early if "//" is reached,
425  // which can leave an odd number of tokens and break key:value pairing.
426  LOG_WARNF("^1EDICT %s fullspawndata contains unsupported //comment^7%s", ftos(num_for_edict(e)), e.fullspawndata);
427  return v;
428  }
429 
430  //print(sprintf("%s(EDICT %s, FIELD %s)\n", __FUNC__, ftos(num_for_edict(e)), f));
431  //print(strcat("FULLSPAWNDATA:", e.fullspawndata, "\n"));
432 
433  // tokenize treats \ as an escape, but tokenize_console returns the required literal
434  for (int t = tokenize_console(e.fullspawndata) - 3; t > 0; t -= 2)
435  {
436  //print(sprintf("\tTOKEN %s:%s\t%s:%s\n", ftos(t), ftos(t + 1), argv(t), argv(t + 1)));
437  if (argv(t) == f)
438  {
439  v = argv(t + 1);
440  break;
441  }
442  }
443 
444  //print(strcat("RESULT: ", v, "\n\n"));
445 
446  if (v && ...(0, bool) == true)
447  {
448  v = strreplace("\\", "/", v);
449  if (whichpack(v) == "")
450  return string_null;
451  }
452 
453  return v;
454 }
string string_null
Definition: nil.qh:9
#define LOG_WARNF(...)
Definition: log.qh:67
#define strstrofs
Definition: dpextensions.qh:42
#define tokenize_console
Definition: dpextensions.qh:24
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

void main ( )

Definition at line 506 of file main.qc.

507 {
508 
509 }

◆ make_safe_for_remove()

void make_safe_for_remove ( entity  e)

Definition at line 210 of file main.qc.

References entity(), initialize_entity_first, NULL, and prev.

Referenced by remove_safely().

211 {
212  if (e.initialize_entity)
213  {
214  entity ent, prev = NULL;
215  for (ent = initialize_entity_first; ent; )
216  {
217  if ((ent == e) || ((ent.classname == "initialize_entity") && (ent.enemy == e)))
218  {
219  //print("make_safe_for_remove: getting rid of initializer ", etos(ent), "\n");
220  // skip it in linked list
221  if (prev)
222  {
223  prev.initialize_entity_next = ent.initialize_entity_next;
224  ent = prev.initialize_entity_next;
225  }
226  else
227  {
228  initialize_entity_first = ent.initialize_entity_next;
230  }
231  }
232  else
233  {
234  prev = ent;
235  ent = ent.initialize_entity_next;
236  }
237  }
238  }
239 }
entity() spawn
prev
Definition: all.qh:66
#define NULL
Definition: post.qh:17
entity initialize_entity_first
Definition: world.qh:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Pause_TryPause()

void Pause_TryPause ( bool  ispaused)

Definition at line 189 of file main.qc.

References FOREACH_CLIENT, IS_PLAYER, IS_REAL_CLIENT, and PHYS_INPUT_BUTTON_CHAT.

Referenced by StartFrame(), and SV_PausedTic().

190 {
191  int n = 0;
193  if (PHYS_INPUT_BUTTON_CHAT(it) != ispaused) return;
194  ++n;
195  });
196  if (!n) return;
197  setpause(ispaused);
198 }
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition: player.qh:155
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the caller graph for this function:

◆ remove_except_protected()

void remove_except_protected ( entity  e)

Definition at line 241 of file main.qc.

References error().

Referenced by InitializeEntitiesRun().

242 {
243  if(e.remove_except_protected_forbidden)
244  error("not allowed to remove this at this point");
245  builtin_remove(e);
246 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove_safely()

void remove_safely ( entity  e)

Definition at line 255 of file main.qc.

References make_safe_for_remove().

Referenced by spawnfunc().

256 {
258  builtin_remove(e);
259 }
void make_safe_for_remove(entity e)
Definition: main.qc:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove_unsafely()

void remove_unsafely ( entity  e)

Definition at line 248 of file main.qc.

References error().

Referenced by InitializeEntitiesRun(), spawnfunc(), and StartFrame().

249 {
250  if(e.classname == "spike")
251  error("Removing spikes is forbidden (crylink bug), please report");
252  builtin_remove(e);
253 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartFrame()

void StartFrame ( )

Definition at line 274 of file main.qc.

References anticheat_startframe(), autocvar_slowmo, autocvar_sv_autopause, autocvar_sv_eventlog, autocvar_sys_ticrate, bot_serverframe(), CheckRules_World(), CreatureFrame_All(), CSQCProjectile_Check(), delete_fn(), execute_next_frame(), FOREACH_CLIENT, frametime, ftos(), g_players, g_projectiles, game_delay_last, GameLogEcho(), IL_EACH, InitializeEntitiesRun(), IS_FAKE_CLIENT, IS_PLAYER, IS_REAL_CLIENT, LOG_INFO, MUTATOR_CALLHOOK, orig_slowmo, Pause_TryPause(), PlayerPostThink(), PlayerPreThink(), ReadyRestart(), RedirectionThink(), remove_unsafely(), server_is_dedicated, serverframetime, serverprevtime, servertime, solve_quadratic(), sys_frametime, sys_phys_update(), time, TIMEOUT_LEADTIME, and warmup_stage.

275 {
276  // TODO: if move is more than 50ms, split it into two moves (this matches QWSV behavior and the client prediction)
279 
282 
283  delete_fn = remove_unsafely; // not during spawning!
285  servertime = time;
287 
288 #ifdef PROFILING
289  if(time > client_cefc_accumulatortime + 1)
290  {
291  float t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
292  int c_seeing = 0;
293  int c_seen = 0;
294  FOREACH_CLIENT(true, {
295  if(IS_REAL_CLIENT(it))
296  ++c_seeing;
297  if(IS_PLAYER(it))
298  ++c_seen;
299  });
300  LOG_INFO(
301  "CEFC time: ", ftos(t * 1000), "ms; ",
302  "CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ",
303  "CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0')
304  );
305  client_cefc_accumulatortime = time;
306  client_cefc_accumulator = 0;
307  }
308 #endif
309 
310  IL_EACH(g_projectiles, it.csqcprojectile_clientanimate, CSQCProjectile_Check(it));
311 
312  if (RedirectionThink()) return;
313 
314  UncustomizeEntitiesRun();
316 
317  WarpZone_StartFrame();
318 
320  if (sys_frametime <= 0) sys_frametime = 1.0 / 60.0; // somewhat safe fallback
321 
322  if (timeout_status == TIMEOUT_LEADTIME) // just before the timeout (when timeout_status will be TIMEOUT_ACTIVE)
323  orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
324 
325  // detect when the pre-game countdown (if any) has ended and the game has started
326  bool game_delay = (time < game_starttime);
327  if (autocvar_sv_eventlog && game_delay_last && !game_delay)
328  GameLogEcho(":startdelay_ended");
329  game_delay_last = game_delay;
330 
333 
334  if (warmup_stage && !game_stopped && warmup_limit > 0 && time - game_starttime >= warmup_limit) {
335  ReadyRestart(true);
336  return;
337  }
338 
339  bot_serverframe();
341  MUTATOR_CALLHOOK(SV_StartFrame);
342 
343  GlobalStats_updateglobal();
344  FOREACH_CLIENT(true, GlobalStats_update(it));
346 }
void remove_unsafely(entity e)
Definition: main.qc:248
#define IL_EACH(this, cond, body)
ERASEABLE vector solve_quadratic(float a, float b, float c)
ax^2 + bx + c = 0
Definition: math.qh:307
#define IS_FAKE_CLIENT(v)
Definition: utils.qh:16
void PlayerPostThink(entity this)
Definition: client.qc:2651
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
float autocvar_sys_ticrate
Definition: main.qh:17
void CSQCProjectile_Check(entity e)
bool warmup_stage
Definition: main.qh:103
var void delete_fn(entity e)
bool game_delay_last
Definition: main.qc:269
void CheckRules_World()
Definition: world.qc:1593
void PlayerPreThink(entity this)
Definition: client.qc:2402
void InitializeEntitiesRun()
Definition: world.qc:2179
float RedirectionThink()
Definition: world.qc:2349
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
bool autocvar_sv_autopause
Definition: main.qc:271
float sys_frametime
Definition: common.qh:57
void CreatureFrame_All()
Definition: main.qc:175
float serverframetime
Definition: main.qh:36
IntrusiveList g_players
Definition: client.qh:85
float frametime
Definition: csprogsdefs.qc:17
#define LOG_INFO(...)
Definition: log.qh:70
void GameLogEcho(string s)
Definition: gamelog.qc:12
void anticheat_startframe()
Definition: anticheat.qc:224
void bot_serverframe()
Definition: bot.qc:658
void ReadyRestart(bool forceWarmupEnd)
Definition: vote.qc:484
IntrusiveList g_projectiles
Definition: common.qh:46
void sys_phys_update(entity this, float dt)
Definition: physics.qc:11
const float TIMEOUT_LEADTIME
Definition: common.qh:48
#define autocvar_slowmo
Definition: main.qh:16
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void execute_next_frame()
Definition: util.qc:1612
float servertime
Definition: main.qh:36
float serverprevtime
Definition: main.qh:180
void Pause_TryPause(bool ispaused)
Definition: main.qc:189
bool autocvar_sv_eventlog
Definition: gamelog.qh:3
float time
Definition: csprogsdefs.qc:16
bool server_is_dedicated
Definition: world.qh:37
#define IS_PLAYER(v)
Definition: utils.qh:9
float orig_slowmo
Definition: common.qh:58
+ Here is the call graph for this function:

◆ SV_OnEntityPreSpawnFunction()

void SV_OnEntityPreSpawnFunction ( entity  this)

Definition at line 354 of file main.qc.

References angles, cvarfilter, DoesQ3ARemoveThisEntity(), expr_evaluate(), g_monster_targets, gametypefilter, have_team_spawns, IL_PUSH(), isGametypeInFilter(), MapInfo_LoadedGametype, monster_attack, movetype, MUTATOR_CALLHOOK, origin, q3compat, set_movetype(), teamplay, and X.

355 {
356  if (this)
357  if (this.gametypefilter != "")
359  {
360  delete(this);
361  return;
362  }
363  if (this.cvarfilter != "" && !expr_evaluate(this.cvarfilter)) {
364  delete(this);
365  return;
366  }
367 
368  if (q3compat && DoesQ3ARemoveThisEntity(this)) {
369  delete(this);
370  return;
371  }
372 
373  set_movetype(this, this.movetype);
374 
375  if (this.monster_attack) {
376  IL_PUSH(g_monster_targets, this);
377  }
378 
379  // support special -1 and -2 angle from radiant
380  if (this.angles == '0 -1 0') {
381  this.angles = '-90 0 0';
382  } else if (this.angles == '0 -2 0') {
383  this.angles = '+90 0 0';
384  }
385 
386  #define X(out, in) MACRO_BEGIN \
387  if (in != 0) { out = out + (random() * 2 - 1) * in; } \
388  MACRO_END
389  X(this.origin.x, this.originjitter.x); X(this.origin.y, this.originjitter.y); X(this.origin.z, this.originjitter.z);
390  X(this.angles.x, this.anglesjitter.x); X(this.angles.y, this.anglesjitter.y); X(this.angles.z, this.anglesjitter.z);
391  X(this.angles.y, this.anglejitter);
392  #undef X
393 
394  if (MUTATOR_CALLHOOK(OnEntityPreSpawn, this)) {
395  delete(this);
396  return;
397  }
398 }
string cvarfilter
Definition: main.qc:352
bool monster_attack
Definition: sv_monsters.qh:62
IntrusiveList g_monster_targets
Definition: sv_monsters.qh:147
int have_team_spawns
Definition: spawnpoints.qh:16
Gametype MapInfo_LoadedGametype
Definition: mapinfo.qh:193
origin
Definition: ent_cs.qc:114
int q3compat
Definition: quake3.qh:3
#define X(out, in)
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition: util.qc:972
float teamplay
Definition: progsdefs.qc:31
bool DoesQ3ARemoveThisEntity(entity this)
Definition: quake3.qc:282
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
vector angles
Definition: csprogsdefs.qc:104
float movetype
Definition: csprogsdefs.qc:98
void set_movetype(entity this, int mt)
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...
Definition: cvar.qh:48
string gametypefilter
Definition: main.qc:351
+ Here is the call graph for this function:

◆ SV_PausedTic()

void SV_PausedTic ( float  elapsedtime)

Definition at line 200 of file main.qc.

References Pause_TryPause(), and server_is_dedicated.

201 {
202  if (!server_is_dedicated) Pause_TryPause(false);
203 }
void Pause_TryPause(bool ispaused)
Definition: main.qc:189
bool server_is_dedicated
Definition: world.qh:37
+ Here is the call graph for this function:

◆ sys_phys_update()

void sys_phys_update ( entity  this,
float  dt 
)

Definition at line 11 of file physics.qc.

References absmax, absmin, angles, CheckPlayerJump(), com_phys_acc_rate, com_phys_acc_rate_air, com_phys_acc_rate_air_stop, com_phys_acc_rate_air_strafe, com_phys_air, com_phys_friction, com_phys_friction_air, com_phys_gravity, com_phys_ground, com_phys_ladder, com_phys_vel_2d, com_phys_vel_max, com_phys_vel_max_air, com_phys_vel_max_air_strafe, com_phys_water, CONTENT_LAVA, CONTENT_SLIME, CONTENT_WATER, conveyor, disableclientprediction, emit, FL_WATERJUMP, flags, IS_CLIENT, IS_DEAD, IS_ONGROUND, IS_ONSLICK, IS_PLAYER, IS_SVQC, IsFlying(), ITEMS_STAT, jumppadcount, ladder_entity, lastground, min(), move_movetype, move_qcphysics, movedir, MOVETYPE_FLY, MOVETYPE_FLY_WORLDONLY, MOVETYPE_FOLLOW, MOVETYPE_NOCLIP, MOVETYPE_NONE, MUTATOR_CALLHOOK, PHYS_ACCELERATE, PHYS_AIRACCELERATE, PHYS_AIRSTOPACCELERATE, PHYS_AIRSTRAFEACCELERATE, PHYS_FRICTION, PHYS_FRICTION_ONLAND, PHYS_INPUT_BUTTON_MASK, PHYS_MAXAIRSPEED, PHYS_MAXAIRSTRAFESPEED, PHYS_MAXSPEED, PHYS_SLICK_APPLYGRAVITY, PM_check_blocked(), PM_check_frozen(), PM_check_hitground(), PM_check_slick(), PM_Footsteps(), PM_jetpack(), sys_in_update(), sys_phys_ai(), sys_phys_fix(), sys_phys_fixspeed(), sys_phys_monitor(), sys_phys_override(), sys_phys_postupdate(), sys_phys_pregame_hold(), sys_phys_simulate(), sys_phys_simulate_simple(), sys_phys_spectator_control(), teleport_time, time, v_angle, vector(), velocity, viewloc_PlayerPhysics(), WAS_ONGROUND, wasFlying, waterlevel, WATERLEVEL_NONE, and WATERLEVEL_SWIMMING.

Referenced by StartFrame().

12 {
13  if (!IS_CLIENT(this)) {
14  sys_phys_simulate_simple(this, dt);
15  return;
16  }
17  sys_in_update(this, dt);
18 
19  sys_phys_fix(this, dt);
20  if (sys_phys_override(this, dt))
21  return;
22 
23  sys_phys_monitor(this, dt);
24 
25  PHYS_CS(this).movement_old = PHYS_CS(this).movement;
26  PHYS_CS(this).v_angle_old = this.v_angle;
27  PHYS_CS(this).buttons_old = PHYS_INPUT_BUTTON_MASK(this);
28 
29  sys_phys_ai(this);
30 
32 
33  if (IS_SVQC) {
34  if (this.move_movetype == MOVETYPE_NONE) { return; }
35  // when we get here, disableclientprediction cannot be 2
36  if(this.move_movetype == MOVETYPE_FOLLOW) // not compatible with prediction
37  this.disableclientprediction = 1;
38  else if(this.move_qcphysics)
39  this.disableclientprediction = -1;
40  else
41  this.disableclientprediction = 0;
42  }
43 
45 
46  PM_check_frozen(this);
47 
48  PM_check_blocked(this);
49 
50  float maxspeed_mod = 1;
51 
52 // conveyors: first fix velocity
53  if (this.conveyor.active) { this.velocity -= this.conveyor.movedir; }
54  MUTATOR_CALLHOOK(PlayerPhysics, this, dt);
55 
56  if (!IS_PLAYER(this)) {
58  maxspeed_mod = STAT(SPECTATORSPEED, this);
59  }
60  sys_phys_fixspeed(this, maxspeed_mod);
61 
62  if (IS_DEAD(this)) {
63  // handle water here
64  vector midpoint = ((this.absmin + this.absmax) * 0.5);
65  int cont = pointcontents(midpoint);
66  if (cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME) {
67  this.velocity = this.velocity * 0.5;
68 
69  // do we want this?
70  // if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
71  // { this.velocity_z = 70; }
72  }
73  sys_phys_postupdate(this);
74  return;
75  }
76 
77  PM_check_slick(this);
78 
79  if (IS_SVQC && !PHYS_FIXANGLE(this)) { this.angles = '0 1 0' * this.v_angle.y; }
80  if (IS_PLAYER(this)) {
81  if (IS_ONGROUND(this)) {
82  PM_check_hitground(this);
83  PM_Footsteps(this);
84  } else if (IsFlying(this)) {
85  this.wasFlying = true;
86  }
87  CheckPlayerJump(this);
88  }
89 
90  if (this.flags & FL_WATERJUMP) {
91  this.velocity_x = this.movedir.x;
92  this.velocity_y = this.movedir.y;
93  if (time > this.teleport_time || this.waterlevel == WATERLEVEL_NONE) {
94  this.flags &= ~FL_WATERJUMP;
95  this.teleport_time = 0;
96  }
97  } else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod, dt)) {
98  // handled
99  } else if (this.move_movetype == MOVETYPE_NOCLIP
100  || this.move_movetype == MOVETYPE_FLY
102  || MUTATOR_CALLHOOK(IsFlying, this)) {
103  this.com_phys_friction = PHYS_FRICTION(this);
104  this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
105  this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
106  this.com_phys_friction_air = true;
107  sys_phys_simulate(this, dt);
108  this.com_phys_friction_air = false;
109  } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
110  this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
111  this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
112  this.com_phys_water = true;
113  sys_phys_simulate(this, dt);
114  this.com_phys_water = false;
115  this.jumppadcount = 0;
116  } else if (this.ladder_entity) {
117  this.com_phys_friction = PHYS_FRICTION(this);
118  this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
119  this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
120  this.com_phys_gravity = -PHYS_GRAVITY(this) * dt;
121  if (PHYS_ENTGRAVITY(this)) { this.com_phys_gravity *= PHYS_ENTGRAVITY(this); }
122  this.com_phys_ladder = true;
123  this.com_phys_friction_air = true;
124  sys_phys_simulate(this, dt);
125  this.com_phys_friction_air = false;
126  this.com_phys_ladder = false;
127  this.com_phys_gravity = 0;
128  } else if (ITEMS_STAT(this) & IT_USING_JETPACK) {
129  PM_jetpack(this, maxspeed_mod, dt);
130  } else if (IS_ONGROUND(this) && (!IS_ONSLICK(this) || !PHYS_SLICK_APPLYGRAVITY(this))) {
131  if (!WAS_ONGROUND(this)) {
132  emit(phys_land, this);
133  if (this.lastground < time - 0.3) {
134  this.velocity *= (1 - PHYS_FRICTION_ONLAND(this));
135  }
136  }
137  this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
138  this.com_phys_gravity = -PHYS_GRAVITY(this) * dt;
139  if (PHYS_ENTGRAVITY(this)) { this.com_phys_gravity *= PHYS_ENTGRAVITY(this); }
140  this.com_phys_ground = true;
141  this.com_phys_vel_2d = true;
142  sys_phys_simulate(this, dt);
143  this.com_phys_vel_2d = false;
144  this.com_phys_ground = false;
145  this.com_phys_gravity = 0;
146  } else {
147  this.com_phys_acc_rate_air = PHYS_AIRACCELERATE(this) * min(maxspeed_mod, 1);
148  this.com_phys_acc_rate_air_stop = PHYS_AIRSTOPACCELERATE(this) * maxspeed_mod;
149  this.com_phys_acc_rate_air_strafe = PHYS_AIRSTRAFEACCELERATE(this) * maxspeed_mod;
150  this.com_phys_vel_max_air_strafe = PHYS_MAXAIRSTRAFESPEED(this) * maxspeed_mod;
151  this.com_phys_vel_max_air = PHYS_MAXAIRSPEED(this) * maxspeed_mod;
152  this.com_phys_vel_max = PHYS_MAXAIRSPEED(this) * min(maxspeed_mod, 1);
153  this.com_phys_air = true;
154  this.com_phys_vel_2d = true;
155  sys_phys_simulate(this, dt);
156  this.com_phys_vel_2d = false;
157  this.com_phys_air = false;
158  }
159 
160  sys_phys_postupdate(this);
161 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
void CheckPlayerJump(entity this)
Definition: player.qc:473
#define PHYS_MAXAIRSPEED(s)
Definition: player.qh:130
const float CONTENT_LAVA
Definition: csprogsdefs.qc:240
#define WAS_ONGROUND(s)
Definition: player.qh:203
#define PHYS_ACCELERATE(s)
Definition: player.qh:91
float waterlevel
Definition: progsdefs.qc:181
#define IS_CLIENT(v)
Definition: utils.qh:13
bool sys_phys_override(entity this, float dt)
Definition: cl_physics.qc:13
void sys_phys_simulate(entity this, float dt)
for players
Definition: physics.qc:174
float teleport_time
Definition: player.qh:212
#define PHYS_FRICTION(s)
Definition: player.qh:110
void PM_check_slick(entity this)
Definition: player.qc:670
bool move_qcphysics
Definition: physics.qh:25
void PM_check_hitground(entity this)
Definition: player.qc:624
void sys_phys_postupdate(entity this)
Definition: physics.qc:163
bool com_phys_ladder
Definition: physics.qh:21
float com_phys_acc_rate_air_strafe
Definition: physics.qh:12
float com_phys_acc_rate_air
Definition: physics.qh:11
vector v_angle
Definition: progsdefs.qc:161
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
#define PHYS_INPUT_BUTTON_MASK(s)
Definition: player.qh:185
float lastground
Definition: player.qh:61
void sys_phys_fixspeed(entity this, float maxspeed_mod)
Definition: cl_physics.qc:27
float jumppadcount
Definition: jumppads.qh:15
bool com_phys_ground
Definition: physics.qh:19
bool wasFlying
Definition: player.qh:62
float com_phys_acc_rate_air_stop
Definition: physics.qh:13
#define PHYS_SLICK_APPLYGRAVITY(s)
Definition: player.qh:144
#define ITEMS_STAT(s)
Definition: player.qh:210
float move_movetype
Definition: movetypes.qh:76
float com_phys_vel_max_air
Definition: physics.qh:8
void sys_phys_simulate_simple(entity this, float dt)
for other entities
Definition: physics.qc:423
const int WATERLEVEL_NONE
Definition: movetypes.qh:11
void viewloc_PlayerPhysics(entity this)
Definition: viewloc.qc:13
float com_phys_vel_max_air_strafe
Definition: physics.qh:9
vector absmax
Definition: csprogsdefs.qc:92
#define PHYS_AIRSTOPACCELERATE(s)
Definition: player.qh:102
vector movedir
Definition: progsdefs.qc:203
void PM_Footsteps(entity this)
Definition: player.qc:649
const float CONTENT_SLIME
Definition: csprogsdefs.qc:239
entity conveyor
Definition: player.qh:54
const float CONTENT_WATER
Definition: csprogsdefs.qc:238
void PM_check_frozen(entity this)
Definition: player.qc:609
#define PHYS_AIRACCELERATE(s)
Definition: player.qh:92
float MOVETYPE_FLY_WORLDONLY
#define IS_ONSLICK(s)
Definition: movetypes.qh:19
float com_phys_friction
Definition: physics.qh:14
void sys_phys_ai(entity this)
Definition: cl_physics.qc:21
void PM_jetpack(entity this, float maxspd_mod, float dt)
Definition: player.qc:695
void PM_check_blocked(entity this)
Definition: player.qc:683
#define IS_DEAD(s)
Definition: utils.qh:26
void sys_phys_pregame_hold(entity this)
Definition: cl_physics.qc:23
bool IsFlying(entity this)
Definition: player.qc:804
float com_phys_acc_rate
Definition: physics.qh:10
entity ladder_entity
Definition: ladder.qh:11
#define IS_SVQC
Definition: _all.inc:14
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool com_phys_air
Definition: physics.qh:20
float com_phys_vel_max
Definition: physics.qh:7
float MOVETYPE_NOCLIP
Definition: progsdefs.qc:254
float flags
Definition: csprogsdefs.qc:129
float MOVETYPE_FOLLOW
bool com_phys_water
Definition: physics.qh:23
bool com_phys_vel_2d
Definition: physics.qh:22
const int WATERLEVEL_SWIMMING
Definition: movetypes.qh:13
void sys_in_update(entity this, float dt)
Definition: input.qc:3
float com_phys_gravity
Definition: physics.qh:16
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define PHYS_MAXAIRSTRAFESPEED(s)
Definition: player.qh:131
#define emit(T,...)
Definition: lib.qh:17
void sys_phys_fix(entity this, float dt)
Definition: cl_physics.qc:3
vector angles
Definition: csprogsdefs.qc:104
vector absmin
Definition: csprogsdefs.qc:92
#define PHYS_AIRSTRAFEACCELERATE(s)
Definition: player.qh:103
float time
Definition: csprogsdefs.qc:16
void sys_phys_monitor(entity this, float dt)
Definition: cl_physics.qc:19
vector velocity
Definition: csprogsdefs.qc:103
#define PHYS_MAXSPEED(s)
Definition: player.qh:132
float MOVETYPE_FLY
Definition: progsdefs.qc:251
#define IS_PLAYER(v)
Definition: utils.qh:9
float FL_WATERJUMP
Definition: progsdefs.qc:242
int disableclientprediction
Definition: physics.qc:4
bool com_phys_friction_air
Definition: physics.qh:24
#define PHYS_FRICTION_ONLAND(s)
Definition: player.qh:111
void sys_phys_spectator_control(entity this)
Definition: cl_physics.qc:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ systems_update()

void systems_update ( )

Definition at line 7 of file main.qc.

8 {
9  float realtime = time;
10  SYSTEM_UPDATE(phys);
11  time = realtime;
12 }
#define SYSTEM_UPDATE(sys)
Definition: lib.qh:39
float time
Definition: csprogsdefs.qc:16

◆ URI_Get_Callback()

void URI_Get_Callback ( float  id,
float  status,
string  data 
)

engine callback

Definition at line 469 of file main.qc.

References Curl_URI_Get_Callback(), ftos(), LOG_INFO, MUTATOR_CALLHOOK, OnlineBanList_URI_Get_Callback(), URI_GET_CURL, URI_GET_CURL_END, URI_GET_DISCARD, URI_GET_IPBAN, URI_GET_IPBAN_END, and url_URI_Get_Callback().

470 {
471  if(url_URI_Get_Callback(id, status, data))
472  {
473  // handled
474  }
475  else if (id == URI_GET_DISCARD)
476  {
477  // discard
478  }
479  else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
480  {
481  // sv_cmd curl
482  Curl_URI_Get_Callback(id, status, data);
483  }
484  else if (id >= URI_GET_IPBAN && id <= URI_GET_IPBAN_END)
485  {
486  // online ban list
487  OnlineBanList_URI_Get_Callback(id, status, data);
488  }
489  else if (MUTATOR_CALLHOOK(URI_GetCallback, id, status, data))
490  {
491  // handled by a mutator
492  }
493  else
494  {
495  LOG_INFO("Received HTTP request data for an invalid id ", ftos(id), ".");
496  }
497 }
void Curl_URI_Get_Callback(int id, float status, string data)
Definition: generic.qc:31
const int URI_GET_IPBAN_END
Definition: urllib.qh:6
ERASEABLE float url_URI_Get_Callback(int id, float status, string data)
Definition: urllib.qc:28
const int URI_GET_IPBAN
Definition: urllib.qh:5
const int URI_GET_DISCARD
Definition: urllib.qh:4
void OnlineBanList_URI_Get_Callback(float id, float status, string data)
Definition: ipban.qc:79
const int URI_GET_CURL
Definition: urllib.qh:7
#define LOG_INFO(...)
Definition: log.qh:70
const int URI_GET_CURL_END
Definition: urllib.qh:8
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:

◆ WarpZone_PostInitialize_Callback()

void WarpZone_PostInitialize_Callback ( )

Definition at line 456 of file main.qc.

References classname, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, entity(), find(), NULL, spawn(), and waypoint_spawnforteleporter_wz().

Referenced by WarpZone_Projectile_Touch().

457 {
458  // create waypoint links for warpzones
459  entity tracetest_ent = spawn();
460  setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
461  tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
462  //for(entity e = warpzone_first; e; e = e.warpzone_next)
463  for(entity e = NULL; (e = find(e, classname, "trigger_warpzone")); )
464  waypoint_spawnforteleporter_wz(e, tracetest_ent);
465  delete(tracetest_ent);
466 }
entity() spawn
float DPCONTENTS_BOTCLIP
float DPCONTENTS_PLAYERCLIP
string classname
Definition: csprogsdefs.qc:107
void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent)
Definition: waypoints.qc:2031
#define NULL
Definition: post.qh:17
float DPCONTENTS_SOLID
float DPCONTENTS_BODY
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ anglejitter

float anglejitter

Definition at line 350 of file main.qc.

◆ anglesjitter

vector anglesjitter

Definition at line 349 of file main.qc.

◆ autocvar_sv_autopause

bool autocvar_sv_autopause = false

Definition at line 271 of file main.qc.

Referenced by StartFrame().

◆ cvarfilter

string cvarfilter

Definition at line 352 of file main.qc.

Referenced by SV_OnEntityPreSpawnFunction().

◆ game_delay_last

bool game_delay_last

Definition at line 269 of file main.qc.

Referenced by StartFrame().

◆ gametypefilter

string gametypefilter

Definition at line 351 of file main.qc.

Referenced by SV_OnEntityPreSpawnFunction().

◆ originjitter

vector originjitter

Definition at line 348 of file main.qc.

Referenced by SUB().