diff --git a/src/i_3dsound.c b/src/i_3dsound.c index b12bce27..d20352bf 100644 --- a/src/i_3dsound.c +++ b/src/i_3dsound.c @@ -173,13 +173,13 @@ static void CalcDistance(const mobj_t *listener, const mobj_t *source, // Treat monsters and projectiles as point sources. src->point_source = (source->thinker.function.v != (actionf_v)P_DegenMobjThinker && - source->info && source->info->actualheight); + source->info && source->actualheight); if (src->point_source) { fixed_t adz; // Vertical distance is from player's view to middle of source's sprite. - src->z = source->z + (source->info->actualheight >> 1); + src->z = source->z + (source->actualheight >> 1); adz = abs((listener->player->viewz >> FRACBITS) - (src->z >> FRACBITS)); CalcHypotenuse(distxy, adz, dist); } diff --git a/src/info.h b/src/info.h index 25e2dfa3..2c6f171e 100644 --- a/src/info.h +++ b/src/info.h @@ -1524,8 +1524,6 @@ typedef struct int bloodcolor; // [FG] colored blood and gibs // DEHEXTRA mobjtype_t droppeditem; // mobj to drop after death - // [crispy] height of the spawnstate's first sprite in pixels - int actualheight; } mobjinfo_t; #define NO_ALTSPEED -1 diff --git a/src/p_map.c b/src/p_map.c index 593d6c4e..63973cf1 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -491,6 +491,13 @@ static boolean P_ProjectileImmune(mobj_t *target, mobj_t *source) ); } +// [FG] mobj or actual sprite height +static const inline fixed_t thingheight (const mobj_t *const thing, const mobj_t *const cond) +{ + return (direct_vertical_aiming && cond && cond->player && thing->actualheight > thing->height) ? + thing->actualheight : thing->height; +} + static boolean PIT_CheckThing(mobj_t *thing) // killough 3/26/98: make static { fixed_t blockdist; @@ -565,13 +572,9 @@ static boolean PIT_CheckThing(mobj_t *thing) // killough 3/26/98: make static if (tmthing->flags & MF_MISSILE || (tmthing->flags & MF_BOUNCES && !(tmthing->flags & MF_SOLID))) { - // [crispy] mobj or actual sprite height - const fixed_t thingheight = (direct_vertical_aiming && tmthing->target && tmthing->target->player) ? - thing->info->actualheight : thing->height; - // see if it went over / under - if (tmthing->z > thing->z + thingheight) + if (tmthing->z > thing->z + thingheight(thing, tmthing->target)) return true; // overhead if (tmthing->z+tmthing->height < thing->z) @@ -1487,7 +1490,7 @@ static boolean PTR_AimTraverse (intercept_t *in) // check angles to see if the thing can be aimed at dist = FixedMul(attackrange, in->frac); - thingtopslope = FixedDiv(th->z+th->height - shootz , dist); + thingtopslope = FixedDiv(th->z+thingheight(th, shootthing) - shootz , dist); if (thingtopslope < bottomslope) return true; // shot over the thing @@ -1615,12 +1618,7 @@ static boolean PTR_ShootTraverse(intercept_t *in) // check angles to see if the thing can be aimed at dist = FixedMul (attackrange, in->frac); - { - // [crispy] mobj or actual sprite height - const fixed_t thingheight = (direct_vertical_aiming && shootthing->player) ? - th->info->actualheight : th->height; - thingtopslope = FixedDiv (th->z+thingheight - shootz , dist); - } + thingtopslope = FixedDiv (th->z+thingheight(th, shootthing) - shootz , dist); if (thingtopslope < aimslope) return true; // shot over the thing diff --git a/src/p_mobj.c b/src/p_mobj.c index ee57342c..1d9c31bb 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -108,6 +108,12 @@ boolean P_SetMobjState(mobj_t* mobj,statenum_t state) if (tempstate) Z_Free(tempstate); + // [FG] update object's actual height + if (ret) + { + mobj->actualheight = spritetopoffset[sprites[mobj->sprite].spriteframes[mobj->frame & FF_FRAMEMASK].lump[0]]; + } + return ret; } @@ -883,28 +889,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->intflags &= ~MIF_FLIP; } - // [crispy] height of the spawnstate's first sprite in pixels - if (!info->actualheight) - { - const spritedef_t *const sprdef = &sprites[mobj->sprite]; - - if (!sprdef->numframes || !(mobj->flags & (MF_SOLID|MF_SHOOTABLE))) - { - info->actualheight = info->height; - } - else - { - spriteframe_t *sprframe; - int lump; - patch_t *patch; - - sprframe = &sprdef->spriteframes[mobj->frame & FF_FRAMEMASK]; - lump = sprframe->lump[0]; - patch = W_CacheLumpNum(lump + firstspritelump, PU_CACHE); - - info->actualheight = SHORT(patch->height) << FRACBITS; - } - } + // [FG] initialize object's actual height + mobj->actualheight = spritetopoffset[sprites[st->sprite].spriteframes[st->frame & FF_FRAMEMASK].lump[0]]; P_AddThinker(&mobj->thinker); diff --git a/src/p_mobj.h b/src/p_mobj.h index ece97c77..7dd27dcb 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -379,6 +379,9 @@ typedef struct mobj_s // [FG] colored blood and gibs int bloodcolor; + + // [FG] height of the sprite in pixels + int actualheight; } mobj_t; // External declarations (fomerly in p_local.h) -- killough 5/2/98 diff --git a/src/p_saveg.c b/src/p_saveg.c index a0d7f161..af7fe1a0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -497,6 +497,9 @@ static void saveg_read_mobj_t(mobj_t *str) { str->bloodcolor = 0; } + + // [FG] height of the sprite in pixels + str->actualheight = spritetopoffset[sprites[str->sprite].spriteframes[str->frame & FF_FRAMEMASK].lump[0]]; } static void saveg_write_mobj_t(mobj_t *str) diff --git a/src/r_things.c b/src/r_things.c index dd6644f3..5f6b8f54 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -648,7 +648,7 @@ void R_ProjectSprite (mobj_t* thing) HU_UpdateCrosshairLock ( BETWEEN(0, viewwidth - 1, (centerxfrac + FixedMul(txc, xscale)) >> FRACBITS), - BETWEEN(0, viewheight - 1, (centeryfrac + FixedMul(viewz - interpz - crosshair_target->height/2, xscale)) >> FRACBITS) + BETWEEN(0, viewheight - 1, (centeryfrac + FixedMul(viewz - interpz - crosshair_target->actualheight/2, xscale)) >> FRACBITS) ); crosshair_target = NULL; // Don't update it again until next tic