Xonotic
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. More...
 
#define emit(T, ...)
 
#define EVENT(T, args)   .bool evt_##T##_listener; .void args evt_##T
 
#define FOREACH_COMPONENT(com, body)   IL_EACH(g_components, it.com_##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 More...
 
#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
entity() spawn

Components always interpolate from the previous state.

Definition at line 8 of file lib.qh.

◆ emit

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

Definition at line 17 of file lib.qh.

Referenced by sys_phys_update().

◆ EVENT

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

Definition at line 15 of file lib.qh.

◆ FOREACH_COMPONENT

#define FOREACH_COMPONENT (   com,
  body 
)    IL_EACH(g_components, it.com_##com, body)

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); \
MACRO_END
IntrusiveList g_events
Definition: lib.qh:3

Definition at line 22 of file lib.qh.

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)))
entity() spawn

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.

◆ 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)); \
MACRO_END
float frametime
Definition: csprogsdefs.qc:17

Definition at line 39 of file lib.qh.

Referenced by systems_update().

Function Documentation

◆ STATIC_INIT()

STATIC_INIT ( components  )

Definition at line 5 of file lib.qh.

References IL_NEW.

IntrusiveList g_events
Definition: lib.qh:3
#define IL_NEW()
IntrusiveList g_components
Definition: lib.qh:4

Variable Documentation

◆ g_components

IntrusiveList g_components

Definition at line 4 of file lib.qh.

◆ g_events

IntrusiveList g_events

Definition at line 3 of file lib.qh.