diff --git a/src/p_mobj.c b/src/p_mobj.c index f6954baef..b676fd9c0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12665,6 +12665,28 @@ static mobj_t *P_MakeSoftwareCorona(mobj_t *mo, INT32 height) return corona; } +static boolean P_MapAlreadyHasStarPost(mobj_t *mobj) +{ + thinker_t *th; + mobj_t *mo2; + + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2 == mobj) + continue; + + if (mo2->type == MT_STARPOST && mo2->health == mobj->health) + return true; + } + + return false; +} + static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) { boolean override = LUA_HookMapThingSpawn(mobj, mthing); @@ -12961,35 +12983,10 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean } break; case MT_STARPOST: - { - thinker_t* th; - mobj_t* mo2; - boolean foundanother = false; - mobj->health = mthing->args[0] + 1; - - // See if other starposts exist in this level that have the same value. - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) - { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mo2 = (mobj_t*)th; - - if (mo2 == mobj) - continue; - - if (mo2->type == MT_STARPOST && mo2->health == mobj->health) - { - foundanother = true; - break; - } - } - - if (!foundanother) + if (!P_MapAlreadyHasStarPost(mobj)) numstarposts++; break; - } case MT_SPIKE: // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL)