Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
lib.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COMPONENT(com)
 Components always interpolate from the previous state.
#define emit(T, ...)
#define EVENT(T, args)
#define FOREACH_COMPONENT(com, body)
#define subscribe(listener, T, fn)
#define SYSTEM(sys, frameLimit, minfps)
 framelimit 0 is no limit, interpolation does not apply framerate below minfps will result in less than 100% speed
#define SYSTEM_UPDATE(sys)

Functions

 STATIC_INIT (components)

Variables

IntrusiveList g_components
IntrusiveList g_events

Macro Definition Documentation

◆ COMPONENT

#define COMPONENT ( com)
Value:
void com_##com##_interpolate(entity it, float a); \
.bool com_##com
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback

Components always interpolate from the previous state.

Definition at line 8 of file lib.qh.

8#define COMPONENT(com) \
9 void com_##com##_interpolate(entity it, float a); \
10 .bool com_##com

◆ emit

#define emit ( T,
... )
Value:
MACRO_BEGIN \
IL_EACH(g_events, it.evt_##T##_listener, it.evt_##T(__VA_ARGS__)); \
IntrusiveList g_events
Definition lib.qh:3
#define MACRO_END
Definition macro.qh:7

Definition at line 17 of file lib.qh.

17#define emit(T, ...) \
18 MACRO_BEGIN \
19 IL_EACH(g_events, it.evt_##T##_listener, it.evt_##T(__VA_ARGS__)); \
20 MACRO_END

Referenced by sys_phys_update().

◆ EVENT

#define EVENT ( T,
args )
Value:
.bool evt_##T##_listener; .void args evt_##T

Definition at line 15 of file lib.qh.

◆ FOREACH_COMPONENT

#define FOREACH_COMPONENT ( com,
body )
Value:
IL_EACH(g_components, it.com_##com, body)
#define IL_EACH(this, cond, body)
IntrusiveList g_components
Definition lib.qh:4

Definition at line 12 of file lib.qh.

◆ subscribe

#define subscribe ( listener,
T,
fn )
Value:
MACRO_BEGIN \
listener.evt_##T = (fn); \
listener.evt_##T##_listener = true; \
IL_PUSH(g_events, listener); \

Definition at line 22 of file lib.qh.

22#define subscribe(listener, T, fn) \
23 MACRO_BEGIN \
24 listener.evt_##T = (fn); \
25 listener.evt_##T##_listener = true; \
26 IL_PUSH(g_events, listener); \
27 MACRO_END

Referenced by STATIC_INIT().

◆ SYSTEM

#define SYSTEM ( sys,
frameLimit,
minfps )
Value:
void sys_##sys##_update(entity this, float dt); \
noref float autocvar_xon_sys_##sys##_dt = ((frameLimit) ? (1 / (frameLimit)) : 0); \
noref float autocvar_xon_sys_##sys##_minfps = (1 / (1 / (minfps)))

framelimit 0 is no limit, interpolation does not apply framerate below minfps will result in less than 100% speed

Definition at line 34 of file lib.qh.

34#define SYSTEM(sys, frameLimit, minfps) \
35 void sys_##sys##_update(entity this, float dt); \
36 noref float autocvar_xon_sys_##sys##_dt = ((frameLimit) ? (1 / (frameLimit)) : 0); \
37 noref float autocvar_xon_sys_##sys##_minfps = (1 / (1 / (minfps)))

◆ SYSTEM_UPDATE

#define SYSTEM_UPDATE ( sys)
Value:
MACRO_BEGIN \
static float t = 0; \
float dt = autocvar_xon_sys_##sys##_dt; \
float minfps = autocvar_xon_sys_##sys##_minfps; \
static float accumulator = 0; \
float a = 0; \
if (dt) { \
accumulator += min(frametime, 1 / (minfps)); \
} else { \
accumulator += frametime; \
dt = accumulator; \
a = 1; \
} \
while (accumulator >= dt) \
{ \
time = t; \
FOREACH_COMPONENT(sys, sys_##sys##_update(it, dt)); \
t += dt; \
accumulator -= dt; \
} \
if (!a) a = accumulator / dt; \
FOREACH_COMPONENT(sys, com_##sys##_interpolate(it, a)); \
float frametime
float time
float min(float f,...)

Definition at line 39 of file lib.qh.

39#define SYSTEM_UPDATE(sys) \
40 MACRO_BEGIN \
41 static float t = 0; \
42 float dt = autocvar_xon_sys_##sys##_dt; \
43 float minfps = autocvar_xon_sys_##sys##_minfps; \
44 static float accumulator = 0; \
45 float a = 0; \
46 if (dt) { \
47 accumulator += min(frametime, 1 / (minfps)); \
48 } else { \
49 accumulator += frametime; \
50 dt = accumulator; \
51 a = 1; \
52 } \
53 while (accumulator >= dt) \
54 { \
55 time = t; \
56 FOREACH_COMPONENT(sys, sys_##sys##_update(it, dt)); \
57 t += dt; \
58 accumulator -= dt; \
59 } \
60 if (!a) a = accumulator / dt; \
61 FOREACH_COMPONENT(sys, com_##sys##_interpolate(it, a)); \
62 MACRO_END

Referenced by systems_update().

Function Documentation

◆ STATIC_INIT()

STATIC_INIT ( components )

Definition at line 5 of file lib.qh.

#define IL_NEW()

References g_components, g_events, and IL_NEW.

Variable Documentation

◆ g_components

IntrusiveList g_components

Definition at line 4 of file lib.qh.

Referenced by STATIC_INIT().

◆ g_events

IntrusiveList g_events

Definition at line 3 of file lib.qh.

Referenced by STATIC_INIT().