Correct arithmetic comparisons of lo/hitags in actors.c.

Rewriting them in the obvious way, i.e. by casting the expression
to int16_t first.  (That is, this commit is the reverse of r3174,
but with casts applied.)  This fixes at least one regression: a
FIREEXT with a hitag of 0 should not be linked with same-
(that is, zero-) tagged SEENINEs or OOZFILTERs.
Mind the corner cases!

git-svn-id: https://svn.eduke32.com/eduke32@3210 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-11-18 19:01:29 +00:00
parent d8cd41fa94
commit 0153853024

View file

@ -1362,10 +1362,10 @@ ACTOR_STATIC void G_MoveFallers(void)
} }
else if (T1 == 1) else if (T1 == 1)
{ {
if (s->lotag < INT16_MAX) if ((int16_t)s->lotag > 0)
{ {
s->lotag-=3; s->lotag-=3;
if (s->lotag > INT16_MAX) if ((int16_t)s->lotag <= 0)
{ {
s->xvel = (32+(krand()&63)); s->xvel = (32+(krand()&63));
s->zvel = -(1024+(krand()&1023)); s->zvel = -(1024+(krand()&1023));
@ -1905,7 +1905,7 @@ ACTOR_STATIC void G_MoveStandables(void)
A_PlaySound(PIPEBOMB_EXPLODE,j); A_PlaySound(PIPEBOMB_EXPLODE,j);
A_PlaySound(GLASS_HEAVYBREAK,j); A_PlaySound(GLASS_HEAVYBREAK,j);
if (s->hitag < INT16_MAX) if ((int16_t)s->hitag > 0)
{ {
j = headspritestat[STAT_STANDABLE]; j = headspritestat[STAT_STANDABLE];
while (j >= 0) while (j >= 0)
@ -1959,10 +1959,11 @@ ACTOR_STATIC void G_MoveStandables(void)
{ {
if (s->shade == -32) if (s->shade == -32)
{ {
if (s->lotag < INT16_MAX) if ((int16_t)s->lotag > 0)
{ {
s->lotag-=3; s->lotag-=3;
if (s->lotag > INT16_MAX) s->lotag = UINT16_MAX-99; if ((int16_t)s->lotag <= 0)
s->lotag = (uint16_t)(-99);
} }
else else
s->shade = -33; s->shade = -33;
@ -2023,7 +2024,7 @@ DETONATE:
if (s->xrepeat) if (s->xrepeat)
for (x=0; x<8; x++) RANDOMSCRAP; for (x=0; x<8; x++) RANDOMSCRAP;
if ((t[3] == 1 && s->xrepeat) || s->lotag == UINT16_MAX-99) if ((t[3] == 1 && s->xrepeat) || (int16_t)s->lotag == -99)
{ {
int32_t j = A_Spawn(i,EXPLOSION2); int32_t j = A_Spawn(i,EXPLOSION2);
x = s->extra; x = s->extra;
@ -2042,7 +2043,7 @@ DETONATE:
if (s->yvel == 1) if (s->yvel == 1)
{ {
s->hitag--; s->hitag--;
if (s->hitag == UINT16_MAX) if ((int16_t)s->hitag <= 0)
{ {
G_OperateSectors(sect,i); G_OperateSectors(sect,i);
@ -2264,7 +2265,7 @@ CLEAR_THE_BOLT:
goto BOLT; goto BOLT;
case TOUCHPLATE__STATIC: case TOUCHPLATE__STATIC:
if (t[1] == 1 && s->hitag != UINT16_MAX) //Move the sector floor if (t[1] == 1 && (int16_t)s->hitag >= 0) //Move the sector floor
{ {
x = sector[sect].floorz; x = sector[sect].floorz;
@ -2317,7 +2318,7 @@ CLEAR_THE_BOLT:
t[3] = !t[3]; t[3] = !t[3];
G_OperateMasterSwitches(s->lotag); G_OperateMasterSwitches(s->lotag);
G_OperateActivators(s->lotag,p); G_OperateActivators(s->lotag,p);
if (s->hitag < INT16_MAX) if ((int16_t)s->hitag > 0)
{ {
s->hitag--; s->hitag--;
if (s->hitag == 0) t[5] = 1; if (s->hitag == 0) t[5] = 1;