From fa757c6695410bac3d32ae950670111d4a84d730 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 15:43:43 +0200 Subject: [PATCH] throw mobjcache allocation shit into a inline function --- src/p_mobj.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 1b7d5a786..5e28cb0c6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9386,13 +9386,8 @@ void P_SceneryThinker(mobj_t *mobj) // GAME SPAWN FUNCTIONS // -// -// P_SpawnMobj -// -mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +FUNCINLINE static ATTRINLINE mobj_t *P_AllocMobj(void) { - const mobjinfo_t *info = &mobjinfo[type]; - state_t *st; mobj_t *mobj; if (mobjcache != NULL) @@ -9406,6 +9401,20 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); } + return mobj; +} + +// +// P_SpawnMobj +// +mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +{ + const mobjinfo_t *info = &mobjinfo[type]; + state_t *st; + mobj_t *mobj; + + mobj = P_AllocMobj(); + // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; mobj->type = type; @@ -9870,16 +9879,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) state_t *st; mobj_t *mobj; - if (mobjcache != NULL) - { - mobj = mobjcache; - mobjcache = mobjcache->hnext; - memset(mobj, 0, sizeof(*mobj)); - } - else - { - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); - } + mobj = P_AllocMobj(); // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;