Revert the parts of r3159 corresponding to redefining lotag and hitag as unsigned, so that they are once again signed.

Any issues in Duke's code relating to misunderstanding these types are now restricted to Duke itself rather than changing the engine and potentially introducing new issues in all Build games.

git-svn-id: https://svn.eduke32.com/eduke32@6581 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-01-15 23:13:50 +00:00
parent ecdb08eb68
commit 214109b506
8 changed files with 48 additions and 43 deletions

View file

@ -317,6 +317,9 @@ enum {
SPR_ALIGN_MASK = 32+16,
};
// compatibility token for bitfield uses of the most significant bit of signed int16_t
#define INT16_32768 ((int16_t)32768)
#include "buildtypes.h"
#define UNTRACKED_STRUCTS
#undef buildtypes_h__

View file

@ -50,7 +50,7 @@ typedef struct
StructTracker(Sector, int8_t) floorshade;
StructTracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning;
StructTracker(Sector, uint8_t) /*CM_CEILINGZ:*/ visibility, fogpal;
StructTracker(Sector, uint16_t) lotag, hitag;
StructTracker(Sector, int16_t) lotag, hitag;
StructTracker(Sector, int16_t) extra;
} StructName(sectortypev7);
@ -77,7 +77,7 @@ typedef struct
StructTracker(Wall, int16_t) picnum, overpicnum;
StructTracker(Wall, int8_t) shade;
StructTracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning;
StructTracker(Wall, uint16_t) lotag, hitag;
StructTracker(Wall, int16_t) lotag, hitag;
StructTracker(Wall, int16_t) extra;
} StructName(walltypev7);
@ -114,7 +114,7 @@ typedef struct
StructTracker(Sprite, int8_t) xoffset, yoffset;
StructTracker(Sprite, int16_t) sectnum, statnum;
StructTracker(Sprite, int16_t) ang, owner, xvel, yvel, zvel;
StructTracker(Sprite, uint16_t) lotag, hitag;
StructTracker(Sprite, int16_t) lotag, hitag;
StructTracker(Sprite, int16_t) extra;
} StructName(spritetype);
@ -140,7 +140,7 @@ typedef struct
StructTracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning;
StructTracker(Sector, uint8_t) /*CM_CEILINGZ:*/ visibility, fogpal;
StructTracker(Sector, uint16_t) lotag, hitag;
StructTracker(Sector, int16_t) lotag, hitag;
StructTracker(Sector, int16_t) extra;
} StructName(sectortypevx);
@ -154,7 +154,7 @@ typedef struct
StructTracker(Wall, int16_t) picnum, overpicnum;
StructTracker(Wall, int8_t) shade;
StructTracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning;
StructTracker(Wall, uint16_t) lotag, hitag;
StructTracker(Wall, int16_t) lotag, hitag;
StructTracker(Wall, int16_t) extra;
StructTracker(Wall, uint8_t) blend, filler_;
} StructName(walltypevx);

View file

@ -2123,7 +2123,7 @@ crack_default:
{
pSprite->lotag -= 3;
if ((int16_t)pSprite->lotag <= 0)
pSprite->lotag = (uint16_t)(-99);
pSprite->lotag = -99;
}
else
pSprite->shade = -33;
@ -5656,7 +5656,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
j = pSprite->owner;
if (sprite[j].lotag == UINT16_MAX)
if ((uint16_t)sprite[j].lotag == UINT16_MAX)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
q = pSector->extra>>3;
@ -6499,7 +6499,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_10_DOOR_AUTO_CLOSE:
// XXX: 32791, what the hell?
if ((pSector->lotag&0xff) == ST_27_STRETCH_BRIDGE || (pSector->floorz > pSector->ceilingz && (pSector->lotag&0xff) != ST_23_SWINGING_DOOR) || pSector->lotag == 32791)
if ((pSector->lotag&0xff) == ST_27_STRETCH_BRIDGE || (pSector->floorz > pSector->ceilingz && (pSector->lotag&0xff) != ST_23_SWINGING_DOOR) || pSector->lotag == (int16_t)32791)
{
j = 1;

View file

@ -1272,7 +1272,7 @@ static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncon
{
// ^^^ C-CON takes precedence for now.
const el_actor_t *a = &g_elActors[tilenum];
uint16_t *movflagsptr = &AC_MOVFLAGS(&sprite[i], &actor[i]);
auto movflagsptr = &AC_MOVFLAGS(&sprite[i], &actor[i]);
SH(i) = a->strength;
AC_ACTION_ID(actor[i].t_data) = a->act.id;
@ -3116,7 +3116,7 @@ int A_Spawn(int spriteNum, int tileNum)
case SE_9_DOWN_OPEN_DOOR_LIGHTS:
if (sector[sectNum].lotag &&
labs(sector[sectNum].ceilingz-pSprite->z) > 1024)
sector[sectNum].lotag |= 32768; //If its open
sector[sectNum].lotag |= INT16_32768; //If its open
fallthrough__;
case SE_8_UP_OPEN_DOOR_LIGHTS:
//First, get the ceiling-floor shade
@ -3210,7 +3210,7 @@ int A_Spawn(int spriteNum, int tileNum)
int const startWall = sector[sectNum].wallptr;
int const endWall = startWall + sector[sectNum].wallnum;
pSprite->extra = (sector[sectNum].hitag != UINT16_MAX);
pSprite->extra = ((uint16_t)sector[sectNum].hitag != UINT16_MAX);
// TRAIN_SECTOR_TO_SE_INDEX
sector[sectNum].hitag = newSprite;

View file

@ -261,7 +261,7 @@ static int32_t VM_CheckSquished(void)
#endif
if (vm.pSprite->pal == 1 ?
(floorZ - ceilZ >= ZOFFSET5 || (pSector->lotag&32768)) :
(floorZ - ceilZ >= ZOFFSET5 || (pSector->lotag & INT16_32768)) :
(floorZ - ceilZ >= ZOFFSET4))
return 0;
@ -648,10 +648,10 @@ static int32_t A_GetWaterZOffset(int spritenum);
GAMEEXEC_STATIC void VM_Move(void)
{
// NOTE: commented out condition is dead since r3159 (making hi/lotag unsigned).
// XXX: Does it break anything? Where are movflags with all bits set created?
const uint16_t * const movflagsptr = &AC_MOVFLAGS(vm.pSprite, &actor[vm.spriteNum]);
int const movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr;
auto const movflagsptr = &AC_MOVFLAGS(vm.pSprite, &actor[vm.spriteNum]);
// NOTE: test against -1 commented out and later revived in source history
// XXX: Does its presence/absence break anything? Where are movflags with all bits set created?
int const movflags = (*movflagsptr == (std::remove_pointer<decltype(movflagsptr)>::type)-1) ? 0 : *movflagsptr;
int const deadflag = (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0);
AC_COUNT(vm.pData)++;
@ -3692,7 +3692,7 @@ nullquote:
if (foundSect >= 0 && isanearoperator(sector[foundSect].lotag))
if ((sector[foundSect].lotag&0xff) == ST_23_SWINGING_DOOR || sector[foundSect].floorz == sector[foundSect].ceilingz)
if ((sector[foundSect].lotag&(16384|32768)) == 0)
if ((sector[foundSect].lotag&(int16_t)(16384|INT16_32768)) == 0)
{
int32_t j;
@ -5536,8 +5536,8 @@ finish_qsprintf:
G_OperateRespawns(vm.pSprite->yvel);
break;
default:
// if (vm.pSprite->hitag >= 0)
G_OperateRespawns(vm.pSprite->hitag);
if (vm.pSprite->hitag >= 0)
G_OperateRespawns(vm.pSprite->hitag);
break;
}
continue;
@ -5642,7 +5642,7 @@ void VM_UpdateAnim(int spriteNum, int32_t *pData)
int const action_incval = actor[spriteNum].ac.incval;
int const action_delay = actor[spriteNum].ac.delay;
#endif
uint16_t *actionticsptr = &AC_ACTIONTICS(&sprite[spriteNum], &actor[spriteNum]);
auto actionticsptr = &AC_ACTIONTICS(&sprite[spriteNum], &actor[spriteNum]);
*actionticsptr += TICSPERFRAME;
if (*actionticsptr > action_delay)

View file

@ -856,8 +856,8 @@ int32_t __fastcall VM_GetWall(int32_t const wallNum, int32_t labelNum)
case WALL_YPANNING: labelNum = pWall->ypanning; break;
case WALL_LOTAG: labelNum = (int16_t)pWall->lotag; break;
case WALL_HITAG: labelNum = (int16_t)pWall->hitag; break;
case WALL_ULOTAG: labelNum = pWall->lotag; break;
case WALL_UHITAG: labelNum = pWall->hitag; break;
case WALL_ULOTAG: labelNum = (uint16_t)pWall->lotag; break;
case WALL_UHITAG: labelNum = (uint16_t)pWall->hitag; break;
case WALL_EXTRA: labelNum = pWall->extra; break;
case WALL_BLEND:
#ifdef NEW_MAP_FORMAT
@ -900,8 +900,8 @@ void __fastcall VM_SetWall(int32_t const wallNum, int32_t const labelNum, int32_
case WALL_YPANNING: pWall->ypanning = iSet; break;
case WALL_LOTAG: pWall->lotag = (int16_t)iSet; break;
case WALL_HITAG: pWall->hitag = (int16_t)iSet; break;
case WALL_ULOTAG: pWall->lotag = iSet; break;
case WALL_UHITAG: pWall->hitag = iSet; break;
case WALL_ULOTAG: pWall->lotag = (uint16_t)iSet; break;
case WALL_UHITAG: pWall->hitag = (uint16_t)iSet; break;
case WALL_EXTRA: pWall->extra = iSet; break;
case WALL_BLEND:
#ifdef NEW_MAP_FORMAT
@ -956,8 +956,8 @@ int32_t __fastcall VM_GetSector(int32_t const sectNum, int32_t labelNum)
case SECTOR_FOGPAL: labelNum = pSector->fogpal; break;
case SECTOR_LOTAG: labelNum = (int16_t)pSector->lotag; break;
case SECTOR_HITAG: labelNum = (int16_t)pSector->hitag; break;
case SECTOR_ULOTAG: labelNum = pSector->lotag; break;
case SECTOR_UHITAG: labelNum = pSector->hitag; break;
case SECTOR_ULOTAG: labelNum = (uint16_t)pSector->lotag; break;
case SECTOR_UHITAG: labelNum = (uint16_t)pSector->hitag; break;
case SECTOR_EXTRA: labelNum = pSector->extra; break;
case SECTOR_CEILINGBUNCH:
case SECTOR_FLOORBUNCH:
@ -1020,8 +1020,8 @@ void __fastcall VM_SetSector(int32_t const sectNum, int32_t const labelNum, int3
case SECTOR_FOGPAL: pSector->fogpal = iSet; break;
case SECTOR_LOTAG: pSector->lotag = (int16_t) iSet; break;
case SECTOR_HITAG: pSector->hitag = (int16_t) iSet; break;
case SECTOR_ULOTAG: pSector->lotag = iSet; break;
case SECTOR_UHITAG: pSector->hitag = iSet; break;
case SECTOR_ULOTAG: pSector->lotag = (uint16_t)iSet; break;
case SECTOR_UHITAG: pSector->hitag = (uint16_t)iSet; break;
case SECTOR_EXTRA: pSector->extra = iSet; break;
case SECTOR_CEILINGBUNCH:
case SECTOR_FLOORBUNCH:
@ -1064,8 +1064,8 @@ void __fastcall VM_SetSprite(int32_t const spriteNum, int32_t const labelNum, in
case ACTOR_ZVEL: pSprite->zvel = iSet; break;
case ACTOR_LOTAG: pSprite->lotag = (int16_t)iSet; break;
case ACTOR_HITAG: pSprite->hitag = (int16_t)iSet; break;
case ACTOR_ULOTAG: pSprite->lotag = iSet; break;
case ACTOR_UHITAG: pSprite->hitag = iSet; break;
case ACTOR_ULOTAG: pSprite->lotag = (uint16_t)iSet; break;
case ACTOR_UHITAG: pSprite->hitag = (uint16_t)iSet; break;
case ACTOR_EXTRA: pSprite->extra = iSet; break;
case ACTOR_HTCGG: actor[spriteNum].cgg = iSet; break;
case ACTOR_HTPICNUM: actor[spriteNum].picnum = iSet; break;
@ -1136,8 +1136,8 @@ int32_t __fastcall VM_GetSprite(int32_t const spriteNum, int32_t labelNum, int32
case ACTOR_ZVEL: labelNum = pSprite->zvel; break;
case ACTOR_LOTAG: labelNum = (int16_t)pSprite->lotag; break;
case ACTOR_HITAG: labelNum = (int16_t)pSprite->hitag; break;
case ACTOR_ULOTAG: labelNum = pSprite->lotag; break;
case ACTOR_UHITAG: labelNum = pSprite->hitag; break;
case ACTOR_ULOTAG: labelNum = (uint16_t)pSprite->lotag; break;
case ACTOR_UHITAG: labelNum = (uint16_t)pSprite->hitag; break;
case ACTOR_EXTRA: labelNum = pSprite->extra; break;
case ACTOR_HTCGG: labelNum = actor[spriteNum].cgg; break;
case ACTOR_HTPICNUM: labelNum = actor[spriteNum].picnum; break;
@ -1213,8 +1213,8 @@ error:
case ACTOR_ZVEL: labelNum = tspr->zvel; break;
case ACTOR_LOTAG: labelNum = (int16_t) tspr->lotag; break;
case ACTOR_HITAG: labelNum = (int16_t) tspr->hitag; break;
case ACTOR_ULOTAG: labelNum = tspr->lotag; break;
case ACTOR_UHITAG: labelNum = tspr->hitag; break;
case ACTOR_ULOTAG: labelNum = (uint16_t)tspr->lotag; break;
case ACTOR_UHITAG: labelNum = (uint16_t)tspr->hitag; break;
case ACTOR_EXTRA: labelNum = tspr->extra; break;
default: labelNum = -1; break;
}
@ -1260,8 +1260,8 @@ error:
case ACTOR_ZVEL: tspr->zvel = iSet; break;
case ACTOR_LOTAG: tspr->lotag = (int16_t) iSet; break;
case ACTOR_HITAG: tspr->hitag = (int16_t) iSet; break;
case ACTOR_ULOTAG: tspr->lotag = iSet; break;
case ACTOR_UHITAG: tspr->hitag = iSet; break;
case ACTOR_ULOTAG: tspr->lotag = (uint16_t)iSet; break;
case ACTOR_UHITAG: tspr->hitag = (uint16_t)iSet; break;
case ACTOR_EXTRA: tspr->extra = iSet; break;
}
}

View file

@ -1012,7 +1012,7 @@ static void G_SetupRotfixedSprites(void)
}
}
static inline int G_CheckExitSprite(int spriteNum) { return (sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); }
static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); }
static void prelevel(char g)
{
@ -1040,7 +1040,7 @@ static void prelevel(char g)
case ST_20_CEILING_DOOR:
case ST_22_SPLITTING_DOOR:
if (sector[i].floorz > sector[i].ceilingz)
sector[i].lotag |= 32768;
sector[i].lotag |= INT16_32768;
continue;
}
@ -1071,7 +1071,7 @@ static void prelevel(char g)
continue;
}
if (sector[i].lotag == UINT16_MAX)
if ((uint16_t)sector[i].lotag == UINT16_MAX)
{
g_player[0].ps->exitx = wall[sector[i].wallptr].x;
g_player[0].ps->exity = wall[sector[i].wallptr].y;

View file

@ -818,7 +818,7 @@ REDODOOR:
if (j >= 0) j = sector[j].ceilingz;
else
{
pSector->lotag |= 32768;
pSector->lotag |= INT16_32768;
goto REDODOOR;
}
}
@ -1183,8 +1183,10 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
if (wallOrSprite < 0)
return 0;
int lotag, hitag, nSwitchPicnum, nSwitchPal;
vec3_t davector;
int16_t lotag, hitag;
int16_t nSwitchPicnum;
uint8_t nSwitchPal;
if (switchType == SWITCH_SPRITE) // A wall sprite
{
@ -1370,7 +1372,7 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
}
}
if (lotag == UINT16_MAX)
if ((uint16_t)lotag == UINT16_MAX)
{
P_EndLevel();
return 1;
@ -2880,7 +2882,7 @@ void P_CheckSectors(int playerNum)
if (pPlayer->cursectnum > -1)
{
sectortype *const pSector = &sector[pPlayer->cursectnum];
switch (pSector->lotag)
switch ((uint16_t)pSector->lotag)
{
case 32767:
pSector->lotag = 0;