From: TimePath Date: Sun, 1 Nov 2015 05:59:38 +0000 (+1100) Subject: Precache: defer X-Git-Tag: xonotic-v0.8.2~1745 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9fe69143689e17b506450608a7489fd9d630ab6b;p=xonotic%2Fxonotic-data.pk3dir.git Precache: defer --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index ac3d8f2ae..20f949bf3 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -131,6 +131,7 @@ void CSQC_Init(void) // needs to be done so early because of the constants they create static_init(); static_init_late(); + static_init_precache(); // precaches diff --git a/qcsrc/common/models/all.qh b/qcsrc/common/models/all.qh index f38b23fff..b81567427 100644 --- a/qcsrc/common/models/all.qh +++ b/qcsrc/common/models/all.qh @@ -11,7 +11,7 @@ REGISTER_REGISTRY(RegisterModels) string MDL_##name##_get() { return path; } \ REGISTER(RegisterModels, MDL, Models, name, m_id, NEW(Model, MDL_##name##_get)) -STATIC_INIT(RegisterModels_precache) { +PRECACHE(Models) { FOREACH(Models, true, LAMBDA({ it.model_precache(it); })); diff --git a/qcsrc/common/sounds/all.qh b/qcsrc/common/sounds/all.qh index fd56eeca3..1bf8ba170 100644 --- a/qcsrc/common/sounds/all.qh +++ b/qcsrc/common/sounds/all.qh @@ -14,7 +14,7 @@ REGISTER_REGISTRY(RegisterSounds) // Used in places where a string is required #define SND(id) (SND_##id.sound_str()) -STATIC_INIT(RegisterSounds_precache) { +PRECACHE(Sounds) { FOREACH(Sounds, true, LAMBDA({ it.sound_precache(it); })); diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index 49ce802e9..a9f7f53d6 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -5,6 +5,8 @@ void __static_init() {} #define static_init() CALL_ACCUMULATED_FUNCTION(__static_init) void __static_init_late() {} #define static_init_late() CALL_ACCUMULATED_FUNCTION(__static_init_late) +void __static_init_precache() {} +#define static_init_precache() CALL_ACCUMULATED_FUNCTION(__static_init_precache) #define REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func) @@ -13,7 +15,8 @@ void __static_init_late() {} ACCUMULATE_FUNCTION(where, _static_##func) \ void _static_##func() -#define STATIC_INIT(func) _STATIC_INIT(__static_init, func) -#define STATIC_INIT_LATE(func) _STATIC_INIT(__static_init_late, func##_late) +#define STATIC_INIT(func) _STATIC_INIT(__static_init, func) +#define STATIC_INIT_LATE(func) _STATIC_INIT(__static_init_late, func##_late) +#define PRECACHE(func) _STATIC_INIT(__static_init_precache, func##_precache) #endif diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 13d8fcd49..bd5a24fee 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -83,6 +83,7 @@ void m_init() // needs to be done so early because of the constants they create static_init(); static_init_late(); + static_init_precache(); RegisterSLCategories(); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 01e69f4be..e6641947c 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -559,6 +559,7 @@ spawnfunc(__init_dedicated_server) // needs to be done so early because of the constants they create static_init(); static_init_late(); + static_init_precache(); MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); @@ -658,6 +659,7 @@ spawnfunc(worldspawn) InitGameplayMode(); static_init_late(); + static_init_precache(); readlevelcvars(); GrappleHookInit();