diff --git a/src/p_local.h b/src/p_local.h index 9359290fa..8caab0d27 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -279,7 +279,6 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype); void P_RespawnSpecials(void); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); -void P_SetMobjSpawnDefaults(mobj_t *mobj); void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 58124fb9b..4945eed48 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10440,7 +10440,44 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - P_SetMobjSpawnDefaults(mobj); + mobj->radius = info->radius; + mobj->height = info->height; + mobj->flags = info->flags; + + mobj->health = (info->spawnhealth ? info->spawnhealth : 1); + + mobj->reactiontime = info->reactiontime; + + mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer + + // do not set the state with P_SetMobjState, + // because action routines can not be called yet + st = &states[info->spawnstate]; + + mobj->state = st; + mobj->tics = st->tics; + mobj->sprite = st->sprite; + mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + P_SetupStateAnimation(mobj, st); + + mobj->friction = ORIG_FRICTION; + + mobj->movefactor = FRACUNIT; + + // All mobjs are created at 100% scale. + mobj->scale = FRACUNIT; + mobj->destscale = mobj->scale; + mobj->scalespeed = FRACUNIT/12; + + // TODO: Make this a special map header + if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) + mobj->destscale = FRACUNIT/2; + + // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; + mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->floorspriteslope = NULL; // set subsector and/or block links P_SetThingPosition(mobj); @@ -10747,8 +10784,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->frame &= ~FF_FRAMEMASK; } - st = &states[info->spawnstate]; - // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) { @@ -10779,52 +10814,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) return mobj; } -void P_SetMobjSpawnDefaults(mobj_t *mobj) -{ - const mobjinfo_t *info = mobj->info; - state_t *st = &states[info->spawnstate]; - - mobj->radius = info->radius; - mobj->height = info->height; - mobj->flags = info->flags; - - mobj->health = (info->spawnhealth ? info->spawnhealth : 1); - - mobj->reactiontime = info->reactiontime; - - mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer - - // do not set the state with P_SetMobjState, - // because action routines can not be called yet - mobj->state = st; - mobj->tics = st->tics; - mobj->sprite = st->sprite; - mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - P_SetupStateAnimation(mobj, st); - - mobj->friction = ORIG_FRICTION; - - mobj->movefactor = FRACUNIT; - - // All mobjs are created at 100% scale. - mobj->scale = FRACUNIT; - mobj->destscale = mobj->scale; - mobj->scalespeed = FRACUNIT/12; - - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; - - // Make sure scale matches destscale immediately when spawned - P_SetScale(mobj, mobj->destscale); - - // Sprite rendering - mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = FRACUNIT; - mobj->spritexoffset = mobj->spriteyoffset = 0; - mobj->floorspriteslope = NULL; -} - static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { state_t *st; diff --git a/src/p_saveg.c b/src/p_saveg.c index c1364e08f..03229e740 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2692,10 +2692,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) } mobj->type = i; } - mobj->info = &mobjinfo[mobj->type]; - P_SetMobjSpawnDefaults(mobj); - if (diff & MD_POS) { mobj->x = READFIXED(save_p); @@ -2721,21 +2718,35 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff & MD_RADIUS) mobj->radius = READFIXED(save_p); + else + mobj->radius = mobj->info->radius; if (diff & MD_HEIGHT) mobj->height = READFIXED(save_p); + else + mobj->height = mobj->info->height; if (diff & MD_FLAGS) mobj->flags = READUINT32(save_p); + else + mobj->flags = mobj->info->flags; if (diff & MD_FLAGS2) mobj->flags2 = READUINT32(save_p); if (diff & MD_HEALTH) mobj->health = READINT32(save_p); + else + mobj->health = mobj->info->spawnhealth; if (diff & MD_RTIME) mobj->reactiontime = READINT32(save_p); + else + mobj->reactiontime = mobj->info->reactiontime; if (diff & MD_STATE) mobj->state = &states[READUINT16(save_p)]; + else + mobj->state = &states[mobj->info->spawnstate]; if (diff & MD_TICS) mobj->tics = READINT32(save_p); + else + mobj->tics = mobj->state->tics; if (diff & MD_SPRITE) { mobj->sprite = READUINT16(save_p); if (mobj->sprite == SPR_PLAY) @@ -2751,6 +2762,11 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->frame = READUINT32(save_p); mobj->anim_duration = READUINT16(save_p); } + else + { + mobj->frame = mobj->state->frame; + mobj->anim_duration = (UINT16)mobj->state->var2; + } if (diff & MD_EFLAGS) mobj->eflags = READUINT16(save_p); if (diff & MD_PLAYER) @@ -2767,14 +2783,20 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->threshold = READINT32(save_p); if (diff & MD_LASTLOOK) mobj->lastlook = READINT32(save_p); + else + mobj->lastlook = -1; if (diff & MD_TARGET) mobj->target = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_TRACER) mobj->tracer = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_FRICTION) mobj->friction = READFIXED(save_p); + else + mobj->friction = ORIG_FRICTION; if (diff & MD_MOVEFACTOR) mobj->movefactor = READFIXED(save_p); + else + mobj->movefactor = FRACUNIT; if (diff & MD_FUSE) mobj->fuse = READINT32(save_p); if (diff & MD_WATERTOP) @@ -2783,10 +2805,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->waterbottom = READFIXED(save_p); if (diff & MD_SCALE) mobj->scale = READFIXED(save_p); + else + mobj->scale = FRACUNIT; if (diff & MD_DSCALE) mobj->destscale = READFIXED(save_p); + else + mobj->destscale = mobj->scale; if (diff2 & MD2_SCALESPEED) mobj->scalespeed = READFIXED(save_p); + else + mobj->scalespeed = FRACUNIT/12; if (diff2 & MD2_CUSVAL) mobj->cusval = READINT32(save_p); if (diff2 & MD2_CVMEM) @@ -2817,10 +2845,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); + else + mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); + else + mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); + else + mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET)