diff --git a/src/p_mobj.c b/src/p_mobj.c index a21d676cb..11f804ab8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -14538,24 +14538,10 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj) return true; } -static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +void P_CopyMapThingSpecialFieldsToMobj(const mapthing_t *mthing, mobj_t *mobj) { - mobj_t *mobj = NULL; size_t arg = SIZE_MAX; - mobj = P_SpawnMobj(x, y, z, type); - mobj->spawnpoint = mthing; - - mobj->angle = FixedAngle(mthing->angle << FRACBITS); - mobj->pitch = FixedAngle(mthing->pitch << FRACBITS); - mobj->roll = FixedAngle(mthing->roll << FRACBITS); - - P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale)); - mobj->destscale = FixedMul(mobj->destscale, mthing->scale); - - mobj->spritexscale = mthing->spritexscale; - mobj->spriteyscale = mthing->spriteyscale; - P_SetThingTID(mobj, mthing->tid); mobj->special = mthing->special; @@ -14609,6 +14595,26 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj->script_stringargs[arg] = Z_Realloc(mobj->script_stringargs[arg], len + 1, PU_LEVEL, NULL); M_Memcpy(mobj->script_stringargs[arg], mthing->script_stringargs[arg], len + 1); } +} + +static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +{ + mobj_t *mobj = NULL; + + mobj = P_SpawnMobj(x, y, z, type); + mobj->spawnpoint = mthing; + + mobj->angle = FixedAngle(mthing->angle << FRACBITS); + mobj->pitch = FixedAngle(mthing->pitch << FRACBITS); + mobj->roll = FixedAngle(mthing->roll << FRACBITS); + + P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale)); + mobj->destscale = FixedMul(mobj->destscale, mthing->scale); + + mobj->spritexscale = mthing->spritexscale; + mobj->spriteyscale = mthing->spriteyscale; + + P_CopyMapThingSpecialFieldsToMobj(mthing, mobj); if (!P_SetupSpawnedMapThing(mthing, mobj)) { diff --git a/src/p_mobj.h b/src/p_mobj.h index 2570acda9..dabdafe51 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -557,6 +557,7 @@ fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const f fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y); mobj_t *P_SpawnMapThing(mapthing_t *mthing); +void P_CopyMapThingSpecialFieldsToMobj(const mapthing_t *mthing, mobj_t *mobj); void P_SpawnHoop(mapthing_t *mthing); void P_SpawnItemPattern(mapthing_t *mthing); void P_SpawnItemLine(mapthing_t *mt1, mapthing_t *mt2); diff --git a/src/p_saveg.c b/src/p_saveg.c index 2f8a5d66b..9a40538ef 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4538,6 +4538,10 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->script_stringargs[j][len] = '\0'; } } + else if (mobj->spawnpoint) + { + P_CopyMapThingSpecialFieldsToMobj(mobj->spawnpoint, mobj); + } if (diff2 & MD2_FLOORSPRITESLOPE) { pslope_t *slope = (pslope_t *)P_CreateFloorSpriteSlope(mobj);