From 015385302468d2256d60c8b1c919964f73dac441 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 18 Nov 2012 19:01:29 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/actors.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 8d179e0a5..94f39fbb1 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -1362,10 +1362,10 @@ ACTOR_STATIC void G_MoveFallers(void) } else if (T1 == 1) { - if (s->lotag < INT16_MAX) + if ((int16_t)s->lotag > 0) { s->lotag-=3; - if (s->lotag > INT16_MAX) + if ((int16_t)s->lotag <= 0) { s->xvel = (32+(krand()&63)); s->zvel = -(1024+(krand()&1023)); @@ -1905,7 +1905,7 @@ ACTOR_STATIC void G_MoveStandables(void) A_PlaySound(PIPEBOMB_EXPLODE,j); A_PlaySound(GLASS_HEAVYBREAK,j); - if (s->hitag < INT16_MAX) + if ((int16_t)s->hitag > 0) { j = headspritestat[STAT_STANDABLE]; while (j >= 0) @@ -1959,10 +1959,11 @@ ACTOR_STATIC void G_MoveStandables(void) { if (s->shade == -32) { - if (s->lotag < INT16_MAX) + if ((int16_t)s->lotag > 0) { 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 s->shade = -33; @@ -2023,7 +2024,7 @@ DETONATE: if (s->xrepeat) 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); x = s->extra; @@ -2042,7 +2043,7 @@ DETONATE: if (s->yvel == 1) { s->hitag--; - if (s->hitag == UINT16_MAX) + if ((int16_t)s->hitag <= 0) { G_OperateSectors(sect,i); @@ -2264,7 +2265,7 @@ CLEAR_THE_BOLT: goto BOLT; 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; @@ -2317,7 +2318,7 @@ CLEAR_THE_BOLT: t[3] = !t[3]; G_OperateMasterSwitches(s->lotag); G_OperateActivators(s->lotag,p); - if (s->hitag < INT16_MAX) + if ((int16_t)s->hitag > 0) { s->hitag--; if (s->hitag == 0) t[5] = 1;