Factor out approaching val. to target val by half-difference steps into logapproach().

Fix a case in G_MovePlayers(), where the player sprite's shade is approached
toward the ceiling/floor's shade. Before, it could stop at one above or below!

git-svn-id: https://svn.eduke32.com/eduke32@4392 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-03-23 14:29:09 +00:00
parent 2f11c7d802
commit 21de8bb53a
3 changed files with 9 additions and 7 deletions

View file

@ -1178,6 +1178,12 @@ static inline uint32_t uhypsq(int32_t dx, int32_t dy)
return (uint32_t)dx*dx + (uint32_t)dy*dy; return (uint32_t)dx*dx + (uint32_t)dy*dy;
} }
static inline int32_t logapproach(int32_t val, int32_t targetval)
{
int32_t dif = targetval - val;
return (dif>>1) ? val + (dif>>1) : targetval;
}
void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y,
int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7))); int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7)));
int32_t lastwall(int16_t point); int32_t lastwall(int16_t point);

View file

@ -1309,9 +1309,9 @@ ACTOR_STATIC void G_MovePlayers(void)
} }
if (sector[s->sectnum].ceilingstat&1) if (sector[s->sectnum].ceilingstat&1)
s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; s->shade = logapproach(s->shade, sector[s->sectnum].ceilingshade);
else else
s->shade += (sector[s->sectnum].floorshade-s->shade)>>1; s->shade = logapproach(s->shade, sector[s->sectnum].floorshade);
BOLT: BOLT:
i = nexti; i = nexti;

View file

@ -1808,11 +1808,7 @@ static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shad
shadef[slot] += (shade-shadef[slot])>>2; shadef[slot] += (shade-shadef[slot])>>2;
if (!((shade-shadef[slot])>>2)) if (!((shade-shadef[slot])>>2))
{ shadef[slot] = logapproach(shadef[slot], shade);
shadef[slot] += (shade-shadef[slot])>>1;
if (!((shade-shadef[slot])>>1))
shadef[slot] = shade;
}
} }
else else
shadef[slot] = shade; shadef[slot] = shade;