diff --git a/src/p_local.h b/src/p_local.h index 4f59246fc..86662d12f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -418,6 +418,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch); void P_DelSeclist(msecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); +void P_Initsecnode(void); void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist); diff --git a/src/p_map.c b/src/p_map.c index 9c974ce44..d66e33dca 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3983,19 +3983,51 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) Lots of new Boom functions that work faster and add functionality. */ +#ifndef PHOBOS_BUILD +static msecnode_t *headsecnode = NULL; +#endif + +void P_Initsecnode(void) +{ +#ifndef PHOBOS_BUILD + headsecnode = NULL; +#endif +} + // P_GetSecnode() retrieves a node from the freelist. The calling routine // should make sure it sets all fields properly. static msecnode_t *P_GetSecnode(void) { +#ifdef PHOBOS_BUILD return Z_LevelPoolCalloc(sizeof(msecnode_t)); +#else + msecnode_t *node; + + if (headsecnode) + { + // vanilla does not clear this + // so for compat reasons we also dont + // means we just reuse stale data which causes weird interactions with orbiting items in some cases + node = headsecnode; + headsecnode = headsecnode->m_thinglist_next; + } + else + node = Z_LevelPoolCalloc(sizeof(msecnode_t)); + + return node; +#endif } // P_PutSecnode() returns a node to the freelist. - static inline void P_PutSecnode(msecnode_t *node) { +#ifdef PHOBOS_BUILD Z_LevelPoolFree(node, sizeof(msecnode_t)); +#else + node->m_thinglist_next = headsecnode; + headsecnode = node; +#endif } // P_AddSecnode() searches the current list to see if this sector is diff --git a/src/p_setup.c b/src/p_setup.c index 2201c0b9f..0ad23f5fb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3001,6 +3001,9 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer + // Initialize sector node list. + P_Initsecnode(); + if (netgame || multiplayer) cv_debug = botskin = 0;