Remove many redundant (int16_t) casts and one now incorrect one.

The redundant ones are in code like this: s->cstat = (int16_t)32768;
Because the value is eventually converted to the type of "s->cstat", any
casts to integral types having at least as many bits are no-ops, signedness
being irrelevant due to (probably any two's complement arch targeting
compiler's) bit-pattern preserving semantics of these conversions.

The now incorrect one is: if (lotag == (int16_t) 65535),
"int32_t lotag" being read from a wall or sprite struct directly earlier.
Now, with these members being unsigned, and (int16_t)65535 equalling -1,
the check always fails.  The correction fixes normal switches having such
a lotag ending the level immediately.

In short: integer casts before assignments are unnecessary, those in reads
highly relevant!

git-svn-id: https://svn.eduke32.com/eduke32@3211 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-11-18 19:01:34 +00:00
parent 0153853024
commit 1009e0f2ec
3 changed files with 15 additions and 15 deletions

View file

@ -1008,7 +1008,7 @@ void A_MoveDummyPlayers(void)
else
{
if (sector[SECT].lotag != ST_2_UNDERWATER) SZ = sector[SECT].floorz;
CS = (int16_t) 32768;
CS = 32768;
}
}
@ -3794,7 +3794,7 @@ ACTOR_STATIC void G_MoveActors(void)
{
if (g_noEnemies == 1)
{
s->cstat = (int16_t)32768;
s->cstat = 32768;
goto BOLT;
}
else if (g_noEnemies == 2) s->cstat = 257;
@ -4006,7 +4006,7 @@ ACTOR_STATIC void G_MoveActors(void)
{
if (g_noEnemies == 1)
{
s->cstat = (int16_t)32768;
s->cstat = 32768;
goto BOLT;
}
else if (g_noEnemies == 2) s->cstat = 257;
@ -4580,7 +4580,7 @@ DETONATEB:
{
t[2] = g_itemRespawnTime;
A_Spawn(i,RESPAWNMARKERRED);
s->cstat = (int16_t) 32768;
s->cstat = 32768;
s->yrepeat = 9;
goto BOLT;
}
@ -4624,7 +4624,7 @@ DETONATEB:
{
t[2] = g_itemRespawnTime;
A_Spawn(i,RESPAWNMARKERRED);
s->cstat = (int16_t) 32768;
s->cstat = 32768;
}
}
@ -4652,8 +4652,8 @@ DETONATEB:
case SECTOREFFECTOR__STATIC:
if (sprite[j].lotag == 1)
{
sprite[j].lotag = (int16_t) 65535;
sprite[j].hitag = (int16_t) 65535;
sprite[j].lotag = 65535;
sprite[j].hitag = 65535;
}
break;
case REACTOR__STATIC:
@ -4664,7 +4664,7 @@ DETONATEB:
break;
case REACTORSPARK__STATIC:
case REACTOR2SPARK__STATIC:
sprite[j].cstat = (int16_t) 32768;
sprite[j].cstat = 32768;
break;
}
j = nextspritesect[j];
@ -4794,7 +4794,7 @@ DETONATEB:
if ((j = A_IncurDamage(i)) >= 0)
{
t[0] = 1; // static
s->cstat = (int16_t)32768;
s->cstat = 32768;
for (x=0; x<5; x++) RANDOMSCRAP;
goto BOLT;
}
@ -4822,7 +4822,7 @@ DETONATEB:
{
if (g_noEnemies == 1)
{
s->cstat = (int16_t)32768;
s->cstat = 32768;
goto BOLT;
}
else if (g_noEnemies == 2)

View file

@ -4362,7 +4362,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case FORCESPHERE__STATIC:
if (j == -1)
{
sp->cstat = (int16_t) 32768;
sp->cstat = 32768;
changespritestat(i, STAT_ZOMBIEACTOR);
}
else
@ -4804,7 +4804,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
changespritestat(i, STAT_MISC);
break;
}
sp->cstat = (int16_t)32768;
sp->cstat = 32768;
changespritestat(i, STAT_FX);
break;
@ -5155,7 +5155,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case ACTIVATORLOCKED__STATIC:
case ACTIVATOR__STATIC:
sp->cstat = (int16_t) 32768;
sp->cstat = 32768;
if (sp->picnum == ACTIVATORLOCKED)
sector[sp->sectnum].lotag |= 16384;
changespritestat(i, STAT_ACTIVATOR);
@ -5937,7 +5937,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->shade = -16;
if (sp->xrepeat <= 8)
{
sp->cstat = (int16_t)32768;
sp->cstat = 32768;
sp->xrepeat=sp->yrepeat=0;
}
else sp->cstat = 1+256;

View file

@ -1436,7 +1436,7 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchissprite)
}
}
if (lotag == (int16_t) 65535)
if (lotag == 65535)
{
g_player[myconnectindex].ps->gm = MODE_EOL;