Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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
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.
string FindFileInMapPack (string pattern)
string GetField_fullspawndata (entity e, string fieldname, bool vfspath)
 Retrieves the value of a map entity field from fullspawndata.
void main ()
void make_safe_for_remove (entity e)
void Pause_TryPause ()
void Pause_TryPause_Dedicated (entity this)
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
void WarpZone_PostInitialize_Callback ()

Variables

float anglejitter
vector anglesjitter
string cvarfilter
bool game_delay_last
string gametypefilter
vector originjitter

Macro Definition Documentation

◆ X

#define X ( out,
in )
Value:
MACRO_BEGIN \
if (in != 0) { out = out + (random() * 2 - 1) * in; } \
#define MACRO_END
Definition macro.qh:7
float random(void)

Referenced by SV_OnEntityPreSpawnFunction().

Function Documentation

◆ CreatureFrame_All()

void CreatureFrame_All ( )

Definition at line 183 of file main.qc.

184{
186 return;
187
188 IL_EACH(g_damagedbycontents, it.damagedbycontents,
189 {
190 if (it.move_movetype == MOVETYPE_NOCLIP) continue;
191 CreatureFrame_Liquids(it);
192 CreatureFrame_FallDamage(it);
193 it.oldvelocity = it.velocity;
194 });
195}
float game_starttime
Definition stats.qh:82
float game_stopped
Definition stats.qh:81
float time
IntrusiveList g_damagedbycontents
Definition damage.qh:135
#define IL_EACH(this, cond, body)

References g_damagedbycontents, game_starttime, game_stopped, IL_EACH, and time.

Referenced by StartFrame().

◆ CreatureFrame_FallDamage()

void CreatureFrame_FallDamage ( entity this)

Definition at line 142 of file main.qc.

143{
144 if(IS_VEHICLE(this) || (this.flags & FL_PROJECTILE))
145 return; // vehicles and projectiles don't receive fall damage
146 if(!(this.velocity || this.oldvelocity))
147 return; // if the entity hasn't moved and isn't moving, then don't do anything
148
149 // check for falling damage
150 bool have_hook = false;
151 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
152 {
153 .entity weaponentity = weaponentities[slot];
154 if(this.(weaponentity).hook && this.(weaponentity).hook.state)
155 {
156 have_hook = true;
157 break;
158 }
159 }
160 if(!have_hook)
161 {
162 float dm; // dm is the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
164 dm = fabs(this.oldvelocity.z) - vlen(this.velocity);
165 else
166 dm = vlen(this.oldvelocity) - vlen(this.velocity);
167 if (IS_DEAD(this))
169 else
171 if (dm > 0)
172 {
173 tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
175 Damage (this, NULL, NULL, dm, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
176 }
177 }
178
180 Damage (this, NULL, NULL, 100000, DEATH_SHOOTING_STAR.m_id, DMG_NOWEP, this.origin, '0 0 0');
181}
entity hook
Definition player.qh:239
#define IS_DEAD(s)
Definition player.qh:245
float autocvar_g_maxspeed
Definition player.qh:43
const int FL_PROJECTILE
Definition constants.qh:85
float flags
const float MOVE_NOMONSTERS
vector mins
vector velocity
vector maxs
float trace_dphitq3surfaceflags
vector origin
float Q3SURFACEFLAG_NODAMAGE
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:503
#define DMG_NOWEP
Definition damage.qh:104
float vlen(vector v)
float min(float f,...)
float fabs(float f)
#define NULL
Definition post.qh:14
vector oldvelocity
Definition main.qh:42
int autocvar_g_balance_falldamage_maxdamage
Definition main.qh:13
float autocvar_g_balance_falldamage_minspeed
Definition main.qh:14
float autocvar_g_balance_falldamage_factor
Definition main.qh:12
float autocvar_g_balance_falldamage_deadminspeed
Definition main.qh:11
bool autocvar_g_balance_falldamage_onlyvertical
Definition main.qh:15
#define IS_VEHICLE(v)
Definition utils.qh:22
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

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, autocvar_g_maxspeed, Damage(), DMG_NOWEP, entity(), fabs(), FL_PROJECTILE, 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.

◆ CreatureFrame_hotliquids()

void CreatureFrame_hotliquids ( entity this)

Definition at line 70 of file main.qc.

71{
72 if (this.contents_damagetime >= time)
73 {
74 return;
75 }
76
78
79 if (this.flags & FL_PROJECTILE)
80 {
81 if (this.watertype == CONTENT_LAVA)
83 else if (this.watertype == CONTENT_SLIME)
85 }
86 else
87 {
88 // TODO: do we even need this hack? frozen players still die in lava!
89 if (STAT(FROZEN, this))
90 {
91 if (this.watertype == CONTENT_LAVA)
92 Damage(this, NULL, NULL, 10000, DEATH_LAVA.m_id, DMG_NOWEP, this.origin, '0 0 0');
93 else if (this.watertype == CONTENT_SLIME)
94 Damage(this, NULL, NULL, 10000, DEATH_SLIME.m_id, DMG_NOWEP, this.origin, '0 0 0');
95 }
96 else if (this.watertype == CONTENT_LAVA)
97 {
98 if (this.watersound_finished < time)
99 {
100 this.watersound_finished = time + 0.5;
101 sound (this, CH_PLAYER_SINGLE, SND_LAVA, VOL_BASE, ATTEN_NORM);
102 }
106 }
107 else if (this.watertype == CONTENT_SLIME)
108 {
109 if (this.watersound_finished < time)
110 {
111 this.watersound_finished = time + 0.5;
112 sound (this, CH_PLAYER_SINGLE, SND_SLIME, VOL_BASE, ATTEN_NORM);
113 }
115 }
116 }
117}
float watertype
Definition player.qh:225
float waterlevel
Definition player.qh:226
const float CONTENT_LAVA
const float CONTENT_SLIME
float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
Definition damage.qc:1002
#define STAT(...)
Definition stats.qh:82
int autocvar_g_balance_contents_playerdamage_lava_burn
Definition main.qh:7
float autocvar_g_balance_contents_playerdamage_lava_burn_time
Definition main.qh:8
float watersound_finished
Definition main.qh:44
float autocvar_g_balance_contents_damagerate
Definition main.qh:3
int autocvar_g_balance_contents_playerdamage_slime
Definition main.qh:9
int autocvar_g_balance_contents_playerdamage_lava
Definition main.qh:6
int autocvar_g_balance_contents_projectiledamage
Definition main.qh:10
float contents_damagetime
Definition main.qh:49
const int CH_PLAYER_SINGLE
Definition sound.qh:21
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52

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, entity(), Fire_AddDamage(), FL_PROJECTILE, flags, NULL, sound, STAT, time, VOL_BASE, waterlevel, watersound_finished, and watertype.

Referenced by CreatureFrame_Liquids().

◆ CreatureFrame_Liquids()

void CreatureFrame_Liquids ( entity this)

Definition at line 119 of file main.qc.

120{
121 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)
122 {
123 if (!(this.flags & FL_INWATER))
124 {
125 this.flags |= FL_INWATER;
126 this.contents_damagetime = 0;
127 }
128
130 }
131 else
132 {
133 if (this.flags & FL_INWATER)
134 {
135 // play leave water sound
136 this.flags &= ~FL_INWATER;
137 this.contents_damagetime = 0;
138 }
139 }
140}
const int FL_INWATER
Definition constants.qh:73
void CreatureFrame_hotliquids(entity this)
Definition main.qc:70

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

◆ dedicated_print()

void dedicated_print ( string input)

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

Definition at line 233 of file main.qc.

234{
235 if (autocvar_sv_dedicated) print(input);
236}
void print(string text,...)
bool autocvar_sv_dedicated
Definition world.qh:41

References autocvar_sv_dedicated, and print().

Referenced by GameLogEcho(), and Say().

◆ dropclient_do()

void dropclient_do ( entity this)

Definition at line 30 of file main.qc.

31{
32 if (this.owner)
33 dropclient(this.owner);
34 delete(this);
35}
entity owner
Definition main.qh:87

References entity(), and owner.

Referenced by dropclient_schedule().

◆ 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 44 of file main.qc.

45{
46 bool scheduled = false;
47 FOREACH_ENTITY_CLASS("dropclient_handler", true,
48 {
49 if(it.owner == this)
50 {
51 scheduled = true;
52 break; // can't use return here, compiler shows a warning
53 }
54 });
55 if (scheduled)
56 return false;
57
58 entity e = new_pure(dropclient_handler);
60 e.owner = this;
61 e.nextthink = time + 0.1;
62
63 // ignore this player for team balancing and queuing
64 this.team = -1;
65 this.wants_join = 0;
67 return true;
68}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int team
Definition main.qh:188
string classname
int wants_join
Definition ent_cs.qh:73
#define FOREACH_ENTITY_CLASS(class, cond, body)
Definition iter.qh:189
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
#define setthink(e, f)
void dropclient_do(entity this)
Definition main.qc:30
const string STR_OBSERVER
Definition utils.qh:7

References classname, dropclient_do(), entity(), FOREACH_ENTITY_CLASS, new_pure, setthink, STR_OBSERVER, team, time, and wants_join.

Referenced by MUTATOR_HOOKFUNCTION(), and PlayerFrame().

◆ FindFileInMapPack()

string FindFileInMapPack ( string pattern)

Definition at line 500 of file main.qc.

501{
502 if (!checkextension("DP_QC_FS_SEARCH_PACKFILE"))
503 return string_null;
504
505 string base_pack = whichpack(strcat("maps/", mapname, ".bsp"));
506 if (base_pack == "" || !base_pack) // this map isn't packaged or there was an error
507 return string_null;
508
509 int glob = search_packfile_begin(pattern, true, true, base_pack);
510 if (glob < 0)
511 return string_null;
512
513 string file = search_getfilename(glob, 0);
514 search_end(glob);
515 return file;
516}
string mapname
string search_getfilename(float handle, float num)
float checkextension(string ext)
void search_end(float handle)
string string_null
Definition nil.qh:9
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References checkextension(), mapname, search_end(), search_getfilename(), strcat(), and string_null.

Referenced by door_init_shared(), and spawnfunc().

◆ GetField_fullspawndata()

string GetField_fullspawndata ( entity e,
string fieldname,
bool vfspath )

Retrieves the value of a map entity field from fullspawndata.

This bypasses field value changes made by the engine, eg string-to-float and escape sequence substitution.

Avoids the need to declare fields just to read them once :)

Returns the last instance of the field to match DarkPlaces behaviour.

Path support: converts \ to / and checks the file exists, if vfspath is true. Returns string_null if the entity does not have the field, or the file is not in the VFS.

FIXME: entities with //comments are not supported.

Definition at line 451 of file main.qc.

452{
453 string v = string_null;
454
455 if (!e.fullspawndata) // Engine lacks support, warning spam in CheckEngineExtensions()
456 return v;
457
458 if (strstrofs(e.fullspawndata, "//", 0) >= 0)
459 {
460 // tokenize and tokenize_console return early if "//" is reached,
461 // which can leave an odd number of tokens and break key:value pairing.
462 LOG_WARNF("^1EDICT %s fullspawndata contains unsupported //comment^7%s", ftos(num_for_edict(e)), e.fullspawndata);
463 return v;
464 }
465
466 //print(sprintf("%s(EDICT %s, FIELD %s)\n", __FUNC__, ftos(num_for_edict(e)), fieldname));
467 //print(strcat("FULLSPAWNDATA:", e.fullspawndata, "\n"));
468
469 // tokenize treats \ as an escape, but tokenize_console returns the required literal
470 for (int t = tokenize_console(e.fullspawndata) - 3; t > 0; t -= 2)
471 {
472 //print(sprintf("\tTOKEN %s:%s\t%s:%s\n", ftos(t), ftos(t + 1), argv(t), argv(t + 1)));
473 if (argv(t) == fieldname)
474 {
475 v = argv(t + 1);
476 break;
477 }
478 }
479
480 //print(strcat("RESULT: ", v, "\n\n"));
481
482 if (v && vfspath)
483 {
484 v = strreplace("\\", "/", v);
485 if (whichpack(v) == "")
486 return string_null;
487 }
488
489 return v;
490}
#define strstrofs
#define tokenize_console
#define LOG_WARNF(...)
Definition log.qh:62
string ftos(float f)
string argv(float n)

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

Referenced by DoesQ3ARemoveThisEntity(), door_init_shared(), MapInfo_Get_ByName_NoFallbacks(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), and StartItem().

◆ main()

void main ( )

Definition at line 568 of file main.qc.

569{
570
571}

◆ make_safe_for_remove()

void make_safe_for_remove ( entity e)

Definition at line 238 of file main.qc.

239{
240 if (e.initialize_entity)
241 {
242 entity ent, prev = NULL;
243 for (ent = initialize_entity_first; ent; )
244 {
245 if ((ent == e) || ((ent.classname == "initialize_entity") && (ent.enemy == e)))
246 {
247 //print("make_safe_for_remove: getting rid of initializer ", etos(ent), "\n");
248 // skip it in linked list
249 if (prev)
250 {
251 prev.initialize_entity_next = ent.initialize_entity_next;
252 ent = prev.initialize_entity_next;
253 }
254 else
255 {
256 initialize_entity_first = ent.initialize_entity_next;
258 }
259 }
260 else
261 {
262 prev = ent;
263 ent = ent.initialize_entity_next;
264 }
265 }
266 }
267}
prev
Definition all.qh:71
entity initialize_entity_first
Definition world.qh:121

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

Referenced by remove_safely().

◆ Pause_TryPause()

void Pause_TryPause ( )

Definition at line 205 of file main.qc.

206{
207 int n = 0, p = 0;
209 if (PHYS_INPUT_BUTTON_CHAT(it)) ++p;
210 ++n;
211 });
212 if (!n) return;
213 if (n == p)
214 setpause(1);
215 else
216 setpause(0);
217}
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition player.qh:159
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References FOREACH_CLIENT, IS_REAL_CLIENT, and PHYS_INPUT_BUTTON_CHAT.

Referenced by StartFrame(), and SV_PausedTic().

◆ Pause_TryPause_Dedicated()

void Pause_TryPause_Dedicated ( entity this)

Definition at line 198 of file main.qc.

199{
201 setpause(1);
202}
int player_count
Definition api.qh:103
bool intermission_running
bool autocvar__endmatch
Definition world.qh:6

References autocvar__endmatch, entity(), intermission_running, and player_count.

Referenced by spawnfunc().

◆ remove_except_protected()

void remove_except_protected ( entity e)

Definition at line 269 of file main.qc.

270{
271 if(e.remove_except_protected_forbidden)
272 error("not allowed to remove this at this point");
273 builtin_remove(e);
274}
#define error
Definition pre.qh:6

References entity(), and error.

Referenced by InitializeEntitiesRun().

◆ remove_safely()

void remove_safely ( entity e)

Definition at line 283 of file main.qc.

284{
286 builtin_remove(e);
287}
void make_safe_for_remove(entity e)
Definition main.qc:238

References entity(), and make_safe_for_remove().

Referenced by spawnfunc().

◆ remove_unsafely()

void remove_unsafely ( entity e)

Definition at line 276 of file main.qc.

277{
278 if(e.classname == "spike")
279 error("Removing spikes is forbidden (crylink bug), please report");
280 builtin_remove(e);
281}

References entity(), and error.

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

◆ StartFrame()

void StartFrame ( )

Definition at line 301 of file main.qc.

302{
304 {
305 // DP calls these for real clients only
306 sys_phys_update(it, frametime); // called by SV_PlayerPhysics for players
307 PlayerPreThink(it);
308 });
309
311
312 delete_fn = remove_unsafely; // not during spawning!
316
317#ifdef PROFILING
318 if(time > client_cefc_accumulatortime + 1)
319 {
320 float t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
321 int c_seeing = 0;
322 int c_seen = 0;
323 FOREACH_CLIENT(true, {
324 if(IS_REAL_CLIENT(it))
325 ++c_seeing;
326 if(IS_PLAYER(it))
327 ++c_seen;
328 });
329 LOG_INFO(
330 "CEFC time: ", ftos(t * 1000), "ms; ",
331 "CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ",
332 "CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0')
333 );
334 client_cefc_accumulatortime = time;
335 client_cefc_accumulator = 0;
336 }
337#endif
338
339 IL_EACH(g_projectiles, it.csqcprojectile_clientanimate, CSQCProjectile_Check(it));
340
341 if (RedirectionThink()) return;
342
345
347
349 if (sys_frametime <= 0) sys_frametime = 1.0 / 60.0; // somewhat safe fallback
350
351 if (timeout_status == TIMEOUT_LEADTIME) // just before the timeout (when timeout_status will be TIMEOUT_ACTIVE)
352 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
353
354 // detect when the pre-game countdown (if any) has ended and the game has started
355 bool game_delay = (time < game_starttime);
356 if (autocvar_sv_eventlog && game_delay_last && !game_delay)
357 GameLogEcho(":startdelay_ended");
358 game_delay_last = game_delay;
359
362
363 // after CheckRules_World() as it may set intermission_running, and after RedirectionThink() in case listen server is closing
366
368 ReadyRestart(true);
369 return;
370 }
371
374 MUTATOR_CALLHOOK(SV_StartFrame);
375
376 GlobalStats_updateglobal();
377 FOREACH_CLIENT(true,
378 {
379 GlobalStats_update(it);
380 if (IS_FAKE_CLIENT(it))
381 PlayerPostThink(it); // DP calls this for real clients only
382 PlayerFrame(it);
383 });
384}
void anticheat_startframe()
Definition anticheat.qc:240
void bot_serverframe()
Definition bot.qc:689
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
bool warmup_stage
Definition main.qh:120
float serverprevtime
Definition main.qh:207
#define IS_PLAYER(s)
Definition player.qh:243
float warmup_limit
Definition stats.qh:375
int timeout_status
Definition stats.qh:87
void execute_next_frame()
Definition util.qc:1748
float frametime
void CSQCProjectile_Check(entity e)
void GameLogEcho(string s)
Definition gamelog.qc:15
bool autocvar_sv_eventlog
Definition gamelog.qh:3
#define PlayerPostThink
Definition _all.inc:258
#define PlayerPreThink
Definition _all.inc:254
float servertime
Definition net.qh:348
void UncustomizeEntitiesRun()
Definition net.qh:168
#define LOG_INFO(...)
Definition log.qh:65
ERASEABLE vector solve_quadratic(float a, float b, float c)
ax^2 + bx + c = 0
Definition math.qh:304
void PlayerFrame(entity this)
Definition client.qc:2822
float orig_slowmo
Definition common.qh:58
float sys_frametime
Definition common.qh:57
const float TIMEOUT_LEADTIME
Definition common.qh:48
void ReadyRestart(bool forceWarmupEnd)
Definition vote.qc:526
bool game_delay_last
Definition main.qc:297
void sys_phys_update(entity this, float dt)
Definition physics.qc:10
void remove_unsafely(entity e)
Definition main.qc:276
void CreatureFrame_All()
Definition main.qc:183
void Pause_TryPause()
Definition main.qc:205
float autocvar_sys_ticrate
Definition main.qh:17
bool autocvar_sv_autopause
Definition main.qh:19
#define autocvar_slowmo
Definition main.qh:16
float serverframetime
Definition main.qh:39
IntrusiveList g_projectiles
Definition common.qh:58
void WarpZone_StartFrame()
Definition server.qc:772
var void delete_fn(entity e)
#define IS_FAKE_CLIENT(v)
Definition utils.qh:16
void CheckRules_World()
Definition world.qc:1705
void InitializeEntitiesRun()
Definition world.qc:2242
float RedirectionThink()
Definition world.qc:2540

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

◆ SV_OnEntityPreSpawnFunction()

void SV_OnEntityPreSpawnFunction ( entity this)

Definition at line 392 of file main.qc.

393{
394 if (this)
395 if (this.gametypefilter != "")
397 {
398 delete(this);
399 return;
400 }
401 if (this.cvarfilter != "" && !expr_evaluate(this.cvarfilter)) {
402 delete(this);
403 return;
404 }
405
406 if (q3compat && DoesQ3ARemoveThisEntity(this)) {
407 delete(this);
408 return;
409 }
410
411 set_movetype(this, this.movetype);
412
413 if (this.monster_attack) {
415 }
416
417 // support special -1 and -2 angle from radiant
418 if (this.angles == '0 -1 0') {
419 this.angles = '-90 0 0';
420 } else if (this.angles == '0 -2 0') {
421 this.angles = '+90 0 0';
422 }
423
424 #define X(out, in) MACRO_BEGIN \
425 if (in != 0) { out = out + (random() * 2 - 1) * in; } \
426 MACRO_END
427 X(this.origin.x, this.originjitter.x); X(this.origin.y, this.originjitter.y); X(this.origin.z, this.originjitter.z);
428 X(this.angles.x, this.anglesjitter.x); X(this.angles.y, this.anglesjitter.y); X(this.angles.z, this.anglesjitter.z);
429 X(this.angles.y, this.anglejitter);
430 #undef X
431
432 if (MUTATOR_CALLHOOK(OnEntityPreSpawn, this)) {
433 delete(this);
434 return;
435 }
436}
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition util.qc:1087
float movetype
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]?
Definition cvar.qh:48
ent angles
Definition ent_cs.qc:121
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
Gametype MapInfo_LoadedGametype
Definition mapinfo.qh:220
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
bool DoesQ3ARemoveThisEntity(entity this)
Definition quake3.qc:360
q3compat
Definition quake3.qc:59
#define X(out, in)
string gametypefilter
Definition main.qc:389
string cvarfilter
Definition main.qc:390
int have_team_spawns
bool monster_attack
IntrusiveList g_monster_targets
bool teamplay
Definition teams.qh:59

References angles, cvarfilter, DoesQ3ARemoveThisEntity(), entity(), 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.

◆ SV_PausedTic()

void SV_PausedTic ( float elapsedtime)

Definition at line 220 of file main.qc.

221{
222 if (autocvar__endmatch) // `endmatch` while paused
223 setpause(0); // proceed to intermission
224 else if (!autocvar_sv_dedicated)
225 {
228 else
229 setpause(0);
230 }
231}

References autocvar__endmatch, autocvar_sv_autopause, autocvar_sv_dedicated, and Pause_TryPause().

◆ sys_phys_update()

void sys_phys_update ( entity this,
float dt )

Definition at line 10 of file physics.qc.

11{
12 if (!IS_CLIENT(this))
13 {
15 return;
16 }
17
18 sys_phys_fix(this, dt);
19 if (sys_phys_override(this, dt))
20 return;
21
22 sys_phys_monitor(this, dt);
23
24 PHYS_CS(this).movement_old = PHYS_CS(this).movement;
25 PHYS_CS(this).v_angle_old = this.v_angle;
26 PHYS_CS(this).buttons_old = PHYS_INPUT_BUTTON_MASK(this);
27
28 sys_phys_ai(this);
29
31
32 if (IS_SVQC)
33 {
34 if (this.move_movetype == MOVETYPE_NONE)
35 return;
36 // when we get here, disableclientprediction cannot be 2
37 if(this.move_movetype == MOVETYPE_FOLLOW) // not compatible with prediction
39 else if(this.move_qcphysics)
41 else
43 }
44
46
47 PM_check_frozen(this);
48
49 PM_check_blocked(this);
50
51 float maxspeed_mod = 1;
52
53 // conveyors: first fix velocity
54 if (this.conveyor.active)
55 this.velocity -= this.conveyor.movedir;
56 MUTATOR_CALLHOOK(PlayerPhysics, this, dt);
57
58 if (!IS_PLAYER(this))
59 {
61 maxspeed_mod = STAT(SPECTATORSPEED, this);
62 }
63 sys_phys_fixspeed(this, maxspeed_mod);
64
65 if (IS_DEAD(this))
66 {
67 // handle water here
68 vector midpoint = ((this.absmin + this.absmax) * 0.5);
69 int cont = pointcontents(midpoint);
70 if (cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
71 {
72 this.velocity = this.velocity * 0.5;
73
74 // do we want this?
75 // if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
76 // { this.velocity_z = 70; }
77 }
79 return;
80 }
81
82 PM_check_slick(this);
83
84 if (IS_SVQC && !PHYS_FIXANGLE(this))
85 this.angles = eY * this.v_angle.y;
86 if (IS_PLAYER(this))
87 {
88 if (IS_ONGROUND(this))
89 {
91 PM_Footsteps(this);
92 }
93 else if (IsFlying(this))
94 this.wasFlying = true;
95 CheckPlayerJump(this);
96 }
97
98 if (this.flags & FL_WATERJUMP)
99 {
100 this.velocity_x = this.movedir.x;
101 this.velocity_y = this.movedir.y;
102 if (time > this.teleport_time || this.waterlevel == WATERLEVEL_NONE)
103 {
104 this.flags &= ~FL_WATERJUMP;
105 this.teleport_time = 0;
106 }
107 }
108 else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod, dt))
109 { /* handled */ }
110 else if (this.move_movetype == MOVETYPE_NOCLIP
111 || this.move_movetype == MOVETYPE_FLY
113 || MUTATOR_CALLHOOK(IsFlying, this))
114 {
115 this.com_phys_friction = PHYS_FRICTION(this);
116 this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
117 this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
118 this.com_phys_friction_air = true;
119 sys_phys_simulate(this, dt);
120 this.com_phys_friction_air = false;
121 }
122 else if (this.waterlevel >= WATERLEVEL_SWIMMING)
123 {
124 this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
125 this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
126 this.com_phys_water = true;
127 sys_phys_simulate(this, dt);
128 this.com_phys_water = false;
129 this.jumppadcount = 0;
130 }
131 else if (this.ladder_entity)
132 {
133 this.com_phys_friction = PHYS_FRICTION(this);
134 this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
135 this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
136 this.com_phys_gravity = -PHYS_GRAVITY(this) * dt;
137 if (PHYS_ENTGRAVITY(this))
138 this.com_phys_gravity *= PHYS_ENTGRAVITY(this);
139 this.com_phys_ladder = true;
140 this.com_phys_friction_air = true;
141 sys_phys_simulate(this, dt);
142 this.com_phys_friction_air = false;
143 this.com_phys_ladder = false;
144 this.com_phys_gravity = 0;
145 }
146 else if (ITEMS_STAT(this) & IT_USING_JETPACK)
147 PM_jetpack(this, maxspeed_mod, dt);
148 else if (IS_ONGROUND(this) && (!IS_ONSLICK(this) || !PHYS_SLICK_APPLYGRAVITY(this)))
149 {
150 if (!WAS_ONGROUND(this))
151 {
152 emit(phys_land, this);
153 if (this.lastground < time - 0.3)
154 this.velocity *= (1 - PHYS_FRICTION_ONLAND(this));
155 }
156 this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
157 this.com_phys_gravity = -PHYS_GRAVITY(this) * dt;
158 if (PHYS_ENTGRAVITY(this))
159 this.com_phys_gravity *= PHYS_ENTGRAVITY(this);
160 this.com_phys_ground = true;
161 this.com_phys_vel_2d = true;
162 sys_phys_simulate(this, dt);
163 this.com_phys_vel_2d = false;
164 this.com_phys_ground = false;
165 this.com_phys_gravity = 0;
166 }
167 else
168 {
169 this.com_phys_acc_rate_air = PHYS_AIRACCELERATE(this) * min(maxspeed_mod, 1);
170 this.com_phys_acc_rate_air_stop = PHYS_AIRSTOPACCELERATE(this) * maxspeed_mod;
171 this.com_phys_acc_rate_air_strafe = PHYS_AIRSTRAFEACCELERATE(this) * maxspeed_mod;
172 this.com_phys_vel_max_air_strafe = PHYS_MAXAIRSTRAFESPEED(this) * maxspeed_mod;
173 this.com_phys_vel_max_air = PHYS_MAXAIRSPEED(this) * maxspeed_mod;
174 this.com_phys_vel_max = PHYS_MAXAIRSPEED(this) * min(maxspeed_mod, 1);
175 this.com_phys_air = true;
176 this.com_phys_vel_2d = true;
177 sys_phys_simulate(this, dt);
178 this.com_phys_vel_2d = false;
179 this.com_phys_air = false;
180 }
181
183}
bool sys_phys_override(entity this, float dt)
Definition cl_physics.qc:13
void sys_phys_monitor(entity this, float dt)
Definition cl_physics.qc:19
void sys_phys_ai(entity this)
Definition cl_physics.qc:21
void sys_phys_spectator_control(entity this)
Definition cl_physics.qc:25
void sys_phys_pregame_hold(entity this)
Definition cl_physics.qc:23
void sys_phys_fixspeed(entity this, float maxspeed_mod)
Definition cl_physics.qc:27
void sys_phys_fix(entity this, float dt)
Definition cl_physics.qc:3
const int IT_USING_JETPACK
Definition item.qh:27
void PM_check_hitground(entity this)
Definition player.qc:656
void PM_jetpack(entity this, float maxspd_mod, float dt)
Definition player.qc:727
void PM_check_blocked(entity this)
Definition player.qc:715
void PM_check_frozen(entity this)
Definition player.qc:641
void CheckPlayerJump(entity this)
Definition player.qc:526
void PM_check_slick(entity this)
Definition player.qc:702
bool IsFlying(entity this)
Definition player.qc:836
void PM_Footsteps(entity this)
Definition player.qc:681
#define PHYS_CS(s)
Definition player.qh:258
#define IS_CLIENT(s)
Definition player.qh:242
#define PHYS_MAXAIRSTRAFESPEED(s)
Definition player.qh:135
vector v_angle
Definition player.qh:237
#define PHYS_AIRACCELERATE(s)
Definition player.qh:95
#define WAS_ONGROUND(s)
Definition player.qh:207
float teleport_time
Definition player.qh:216
#define PHYS_FRICTION(s)
Definition player.qh:114
#define ITEMS_STAT(s)
Definition player.qh:214
#define PHYS_MAXAIRSPEED(s)
Definition player.qh:134
#define PHYS_AIRSTRAFEACCELERATE(s)
Definition player.qh:107
bool wasFlying
Definition player.qh:65
#define PHYS_FIXANGLE(s)
Definition player.qh:220
#define PHYS_ACCELERATE(s)
Definition player.qh:94
float lastground
Definition player.qh:64
#define PHYS_MAXSPEED(s)
Definition player.qh:136
#define PHYS_AIRSTOPACCELERATE(s)
Definition player.qh:105
#define PHYS_FRICTION_ONLAND(s)
Definition player.qh:115
entity conveyor
Definition player.qh:57
#define PHYS_SLICK_APPLYGRAVITY(s)
Definition player.qh:148
#define PHYS_INPUT_BUTTON_MASK(s)
Definition player.qh:189
const int FL_WATERJUMP
Definition constants.qh:80
const float CONTENT_WATER
vector absmax
vector absmin
float disableclientprediction
float com_phys_acc_rate_air_strafe
Definition physics.qh:12
float com_phys_acc_rate_air
Definition physics.qh:11
float com_phys_gravity
Definition physics.qh:16
float com_phys_acc_rate
Definition physics.qh:10
float com_phys_vel_max
Definition physics.qh:7
bool com_phys_vel_2d
Definition physics.qh:22
bool com_phys_air
Definition physics.qh:20
bool com_phys_water
Definition physics.qh:23
bool move_qcphysics
Definition physics.qh:25
bool com_phys_ladder
Definition physics.qh:21
float com_phys_friction
Definition physics.qh:14
float com_phys_vel_max_air
Definition physics.qh:8
bool com_phys_ground
Definition physics.qh:19
float com_phys_vel_max_air_strafe
Definition physics.qh:9
float com_phys_acc_rate_air_stop
Definition physics.qh:13
bool com_phys_friction_air
Definition physics.qh:24
void sys_phys_simulate(entity this, float dt)
for players
Definition physics.qc:198
void sys_phys_simulate_simple(entity this, float dt)
for other entities
Definition physics.qc:480
void sys_phys_postupdate(entity this)
Definition physics.qc:185
float jumppadcount
Definition jumppads.qh:28
entity ladder_entity
Definition ladder.qh:11
#define IS_SVQC
Definition _all.inc:12
#define emit(T,...)
Definition lib.qh:17
vector movedir
Definition viewloc.qh:18
const int MOVETYPE_NONE
Definition movetypes.qh:129
const int WATERLEVEL_SWIMMING
Definition movetypes.qh:13
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
const int WATERLEVEL_NONE
Definition movetypes.qh:11
#define PHYS_GRAVITY(s)
Definition movetypes.qh:53
#define IS_ONSLICK(s)
Definition movetypes.qh:19
const int MOVETYPE_FLY_WORLDONLY
Definition movetypes.qh:143
float move_movetype
Definition movetypes.qh:76
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
const int MOVETYPE_FLY
Definition movetypes.qh:134
#define PHYS_ENTGRAVITY(s)
Definition movetypes.qh:55
#define IS_ONGROUND(s)
Definition movetypes.qh:16
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
void viewloc_PlayerPhysics(entity this)
Definition viewloc.qc:13

Referenced by StartFrame().

◆ 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

◆ URI_Get_Callback()

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

engine callback

Definition at line 531 of file main.qc.

532{
533 if(url_URI_Get_Callback(id, status, data))
534 {
535 // handled
536 }
537 else if (id == URI_GET_DISCARD)
538 {
539 // discard
540 }
541 else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
542 {
543 // sv_cmd curl
544 Curl_URI_Get_Callback(id, status, data);
545 }
546 else if (id >= URI_GET_IPBAN && id <= URI_GET_IPBAN_END)
547 {
548 // online ban list
549 OnlineBanList_URI_Get_Callback(id, status, data);
550 }
551 else if (MUTATOR_CALLHOOK(URI_GetCallback, id, status, data))
552 {
553 // handled by a mutator
554 }
555 else
556 {
557 LOG_INFO("Received HTTP request data for an invalid id ", ftos(id), ".");
558 }
559}
void Curl_URI_Get_Callback(int id, float status, string data)
Definition generic.qc:31
void OnlineBanList_URI_Get_Callback(float id, float status, string data)
Definition ipban.qc:79
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_IPBAN_END
Definition urllib.qh:6
const int URI_GET_CURL
Definition urllib.qh:7
const int URI_GET_DISCARD
Definition urllib.qh:4
const int URI_GET_CURL_END
Definition urllib.qh:8

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().

◆ WarpZone_PostInitialize_Callback()

void WarpZone_PostInitialize_Callback ( )

Definition at line 518 of file main.qc.

519{
520 // create waypoint links for warpzones
521 entity tracetest_ent = spawn();
522 setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
523 tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
524 //for(entity e = warpzone_first; e; e = e.warpzone_next)
525 for(entity e = NULL; (e = find(e, classname, "trigger_warpzone")); )
526 waypoint_spawnforteleporter_wz(e, tracetest_ent);
527 delete(tracetest_ent);
528}
void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent)
const vector PL_MIN_CONST
Definition constants.qh:56
const vector PL_MAX_CONST
Definition constants.qh:55
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
float DPCONTENTS_BODY
float DPCONTENTS_PLAYERCLIP
#define spawn
entity find(entity start,.string field, string match)

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

Referenced by WarpZone_StartFrame().

Variable Documentation

◆ anglejitter

float anglejitter

Definition at line 388 of file main.qc.

◆ anglesjitter

vector anglesjitter

Definition at line 387 of file main.qc.

◆ cvarfilter

string cvarfilter

Definition at line 390 of file main.qc.

Referenced by SV_OnEntityPreSpawnFunction().

◆ game_delay_last

bool game_delay_last

Definition at line 297 of file main.qc.

Referenced by StartFrame().

◆ gametypefilter

string gametypefilter

Definition at line 389 of file main.qc.

Referenced by SV_OnEntityPreSpawnFunction().

◆ originjitter