diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index dcf35e8f0..dd787ce0e 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2372,6 +2372,10 @@ static void HWR_AddLine(seg_t *line) v2x = line->v2->x; v2y = line->v2->y; + // QUICK: use cross product to reject lines not facing viewer + if (R_PointOnViewBackSide(v1x, v1y, v2x, v2y)) + return; + // OPTIMIZE: quickly reject orthogonal back sides. angle1 = R_PointToAngle64(v1x, v1y); angle2 = R_PointToAngle64(v2x, v2y); @@ -2491,6 +2495,10 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) return false; } + // Sitting on a line? + if (R_PointOnViewBackSide(px1, py1, px2, py2)) + return true; + angle1 = R_PointToAngle64(px1, py1); angle2 = R_PointToAngle64(px2, py2); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6294a5ab7..e02bddb24 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -551,6 +551,7 @@ static int call_hooks { /* call generic mobj hooks first */ calls += call_mobj_type_hooks(hook, MT_NULL); + //if (hook->mobj_type < NUMMOBJTYPES) calls += call_mobj_type_hooks(hook, hook->mobj_type); ps_lua_mobjhooks.value.i += calls; } diff --git a/src/p_inter.c b/src/p_inter.c index e3575fa1a..e0ac0ebf3 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1701,7 +1701,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) else prandom = P_RandomKey(5); // No placable object, just use a random number. - switch(prandom) + switch (prandom) { default: item = MT_BUNNY; break; case 1: item = MT_BIRD; break; @@ -2284,16 +2284,26 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig - if (!target || (target->health <= 0)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(target)) +#else + if (!target) +#endif + return false; + + if (target->health <= 0) return false; // Spectator handling if (netgame) { - if (damage == DMG_SPECTATOR && target->player && target->player->spectator) - damage = DMG_INSTAKILL; - else if (target->player && target->player->spectator) - return false; + if (target->player && target->player->spectator) + { + if (damage == DMG_SPECTATOR) + damage = DMG_INSTAKILL; + else + return false; + } if (source && source->player && source->player->spectator) return false; @@ -2399,6 +2409,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if (source == target) return false; // Don't hit yourself with your own paraloop, baka + if (source && source->player && !cv_friendlyfire.value && (gametype == GT_COOP || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) @@ -2448,7 +2459,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing]) { - if (!force) // shoulddamage bypasses all of that. + if (!force) // shoulddamage bypasses all of that. { K_DoInstashield(player); return false; diff --git a/src/p_mobj.c b/src/p_mobj.c index 3fd1cf6f5..ff8229c4f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1279,7 +1279,6 @@ static void P_PushableCheckBustables(mobj_t *mo) if (rover->master->frontsector->crumblestate) continue; - topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); // Height checks @@ -1291,29 +1290,34 @@ static void P_PushableCheckBustables(mobj_t *mo) if (mo->z+mo->height > bottomheight) continue; } - else if (rover->flags & FF_SPINBUST) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - } else { - if (mo->z >= topheight) - continue; + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - if (mo->z+mo->height < bottomheight) - continue; + if (rover->flags & FF_SPINBUST) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->momz + mo->height < bottomheight) + continue; + } + else + { + if (mo->z >= topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } } EV_CrumbleChain(node->m_sector, rover); @@ -5429,17 +5433,17 @@ static void P_Boss9Thinker(mobj_t *mobj) || mobj->target->player->powers[pw_invulnerability] || mobj->target->player->powers[pw_super])) danger = false; - if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) + else if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) danger = false; - if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) + else if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) danger = false; - if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) + else if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) danger = false; - if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) + else if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) danger = false; - if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) + else if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) danger = false; - if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) + else if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; if (danger) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index f28d9cbf7..e2a42fb8d 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -331,6 +331,10 @@ static void R_AddLine(seg_t *line) v2x = line->v2->x; v2y = line->v2->y; + // QUICK: use cross product to reject lines not facing viewer + if (R_PointOnViewBackSide(v1x, v1y, v2x, v2y)) + return; + // big room fix angle1 = R_PointToAngle64(v1x, v1y); angle2 = R_PointToAngle64(v2x, v2y); @@ -545,6 +549,10 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) x2 = bspcoord[check[2]]; y2 = bspcoord[check[3]]; + // Sitting on a line? + if (R_PointOnViewBackSide(x1, y1, x2, y2)) + return true; + // big room fix angle1 = R_PointToAngle64(x1, y1) - viewangle; angle2 = R_PointToAngle64(x2, y2) - viewangle; diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 425663f8f..efdc06b27 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -346,16 +346,18 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - const boolean doreset = mobj->resetinterp && mobj->type != MT_GHOST && mobj->type != MT_PLAYERRETICULE; + const boolean doreset = mobj->resetinterp && (mobj->type != MT_GHOST) && (mobj->type != MT_PLAYERRETICULE) && (mobj->type != MT_SHADOW); out->x = doreset ? mobj->x : R_LerpFixed(mobj->old_x, mobj->x, frac); out->y = doreset ? mobj->y : R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = doreset ? mobj->z : R_LerpFixed(mobj->old_z, mobj->z, frac); - out->spritexscale = doreset ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - out->spriteyscale = doreset ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - out->spritexoffset = doreset ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - out->spriteyoffset = doreset ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + //out->subsector = R_PointInSubsector(out->x, out->y); // this is unused if (mobj->player) diff --git a/src/r_main.h b/src/r_main.h index e8b7393e3..7c5bc2a1f 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -123,6 +123,13 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t return v > 0; } +FUNCINLINE static ATTRINLINE boolean R_PointOnViewBackSide(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) +{ + // use cross product to determine side quickly + INT64 v = ((INT64)x1 - viewx) * ((INT64)y2 - viewy) - ((INT64)x2 - viewx) * ((INT64)y1 - viewy); + return v >= 0; +} + angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);