From 2cb3734f85a21ff632e54e63345f51aea1518da3 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 15 Nov 2012 14:28:18 +0000 Subject: [PATCH] Split r3159..r3161, part 8: make some members of base types unsigned. NOTE: This will need very thorough review. git-svn-id: https://svn.eduke32.com/eduke32@3174 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 19 ++++++++++++------- polymer/eduke32/build/src/build.c | 2 +- polymer/eduke32/source/actors.c | 22 +++++++++++----------- polymer/eduke32/source/astub.c | 6 +++--- polymer/eduke32/source/game.c | 2 +- polymer/eduke32/source/premap.c | 4 ++-- polymer/eduke32/source/sector.c | 4 ++-- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 19a7699b3..f1c96a1e3 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -103,7 +103,7 @@ void yax_updategrays(int32_t posze); #ifdef YAX_ENABLE // more user tag hijacking: lotag/extra :/ -# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].lotag + 2*Cf)) +# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(int16_t *)(&Ptr[Wall].lotag + 2*Cf)) # define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf) # define YAX_NEXTWALLDEFAULT(Cf) (((Cf)==YAX_CEILING) ? 0 : -1) @@ -228,7 +228,7 @@ typedef struct { Tracker(Sector, int16_t) wallptr, wallnum; Tracker(Sector, int32_t) ceilingz, floorz; - Tracker(Sector, int16_t) ceilingstat, floorstat; + Tracker(Sector, uint16_t) ceilingstat, floorstat; Tracker(Sector, int16_t) ceilingpicnum, ceilingheinum; Tracker(Sector, int8_t) ceilingshade; Tracker(Sector, uint8_t) ceilingpal, ceilingxpanning, ceilingypanning; @@ -236,7 +236,8 @@ typedef struct Tracker(Sector, int8_t) floorshade; Tracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning; Tracker(Sector, uint8_t) visibility, filler; - Tracker(Sector, int16_t) lotag, hitag, extra; + Tracker(Sector, uint16_t) lotag, hitag; + Tracker(Sector, int16_t) extra; } sectortype; //cstat: @@ -257,11 +258,13 @@ typedef struct typedef struct { Tracker(Wall, int32_t) x, y; - Tracker(Wall, int16_t) point2, nextwall, nextsector, cstat; + Tracker(Wall, int16_t) point2, nextwall, nextsector; + Tracker(Wall, uint16_t) cstat; Tracker(Wall, int16_t) picnum, overpicnum; Tracker(Wall, int8_t) shade; Tracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning; - Tracker(Wall, int16_t) lotag, hitag, extra; + Tracker(Wall, uint16_t) lotag, hitag; + Tracker(Wall, int16_t) extra; } walltype; //cstat: @@ -287,14 +290,16 @@ typedef struct typedef struct { Tracker(Sprite, int32_t) x, y, z; - Tracker(Sprite, int16_t) cstat, picnum; + Tracker(Sprite, uint16_t) cstat; + Tracker(Sprite, int16_t) picnum; Tracker(Sprite, int8_t) shade; Tracker(Sprite, uint8_t) pal, clipdist, filler; Tracker(Sprite, uint8_t) xrepeat, yrepeat; Tracker(Sprite, int8_t) xoffset, yoffset; Tracker(Sprite, int16_t) sectnum, statnum; Tracker(Sprite, int16_t) ang, owner, xvel, yvel, zvel; - Tracker(Sprite, int16_t) lotag, hitag, extra; + Tracker(Sprite, uint16_t) lotag, hitag; + Tracker(Sprite, int16_t) extra; } spritetype; typedef struct { diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index a53ca1aa3..cd4f28c57 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -1640,7 +1640,7 @@ static int32_t backup_highlighted_map(mapinfofull_t *mapinfo) { // if a bunch was discarded sectortype *const sec = &mapinfo->sector[i]; - int16_t *const cs = j==YAX_CEILING ? &sec->ceilingstat : &sec->floorstat; + uint16_t *const cs = j==YAX_CEILING ? &sec->ceilingstat : &sec->floorstat; uint8_t *const xp = j==YAX_CEILING ? &sec->ceilingxpanning : &sec->floorxpanning; *cs &= ~YAX_BIT; diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index f3e3038bb..86183012c 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 > 0) + if (s->lotag < INT16_MAX) { s->lotag-=3; - if (s->lotag <= 0) + if (s->lotag > INT16_MAX) { 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 > 0) + if (s->hitag < INT16_MAX) { j = headspritestat[STAT_STANDABLE]; while (j >= 0) @@ -1959,10 +1959,10 @@ ACTOR_STATIC void G_MoveStandables(void) { if (s->shade == -32) { - if (s->lotag > 0) + if (s->lotag < INT16_MAX) { s->lotag-=3; - if (s->lotag <= 0) s->lotag = -99; + if (s->lotag > INT16_MAX) s->lotag = UINT16_MAX-99; } else s->shade = -33; @@ -2023,7 +2023,7 @@ DETONATE: if (s->xrepeat) for (x=0; x<8; x++) RANDOMSCRAP; - if ((t[3] == 1 && s->xrepeat) || s->lotag == -99) + if ((t[3] == 1 && s->xrepeat) || s->lotag == UINT16_MAX-99) { int32_t j = A_Spawn(i,EXPLOSION2); x = s->extra; @@ -2042,7 +2042,7 @@ DETONATE: if (s->yvel == 1) { s->hitag--; - if (s->hitag <= 0) + if (s->hitag == UINT16_MAX) { G_OperateSectors(sect,i); @@ -2264,7 +2264,7 @@ CLEAR_THE_BOLT: goto BOLT; case TOUCHPLATE__STATIC: - if (t[1] == 1 && s->hitag >= 0) //Move the sector floor + if (t[1] == 1 && s->hitag != UINT16_MAX) //Move the sector floor { x = sector[sect].floorz; @@ -2317,7 +2317,7 @@ CLEAR_THE_BOLT: t[3] = !t[3]; G_OperateMasterSwitches(s->lotag); G_OperateActivators(s->lotag,p); - if (s->hitag > 0) + if (s->hitag < INT16_MAX) { s->hitag--; if (s->hitag == 0) t[5] = 1; @@ -5541,7 +5541,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 j = s->owner; - if (sprite[j].lotag == (int16_t) 65535) + if (sprite[j].lotag == UINT16_MAX) KILLIT(i); q = sc->extra>>3; @@ -6421,7 +6421,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_10_DOOR_AUTO_CLOSE: // XXX: 32791, what the hell? - if ((sc->lotag&0xff) == ST_27_STRETCH_BRIDGE || (sc->floorz > sc->ceilingz && (sc->lotag&0xff) != ST_23_SWINGING_DOOR) || sc->lotag == (int16_t) 32791) + if ((sc->lotag&0xff) == ST_27_STRETCH_BRIDGE || (sc->floorz > sc->ceilingz && (sc->lotag&0xff) != ST_23_SWINGING_DOOR) || sc->lotag == 32791) { int32_t p; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 25e7bc1d6..771225279 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4818,7 +4818,7 @@ static void toggle_cf_flipping(int32_t sectnum, int32_t floorp) static const int16_t orient[8] = { 360, -360, -180, 180, -270, 270, 90, -90 }; - int16_t *stat = &SECTORFLD(sectnum,stat, floorp); + uint16_t *stat = &SECTORFLD(sectnum,stat, floorp); int32_t i = *stat; i = (i&0x4)+((i>>4)&3); @@ -6388,7 +6388,7 @@ static void Keys3d(void) if (AIMING_AT_CEILING_OR_FLOOR) //Set masked/transluscent ceilings/floors { int32_t nexti[4] = { 128, 256, 384, 0 }; - int16_t *stat = &AIMED_CEILINGFLOOR(stat); + uint16_t *stat = &AIMED_CEILINGFLOOR(stat); const char *statmsg[4] = {"normal", "masked", "translucent", "translucent (2)"}; i = (*stat&(128+256))>>7; @@ -11020,7 +11020,7 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr if (showinvisibility && (tspr->cstat&32768)) { tspr->pal = 6; - tspr->cstat &= ~32768; + tspr->cstat &= (uint16_t)~32768; tspr->cstat |= 2+512; } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 088c6f6c2..59921f7e9 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -5833,7 +5833,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) startwall = sector[sect].wallptr; endwall = startwall+sector[sect].wallnum; - if (sector[sect].hitag == -1) + if (sector[sect].hitag == UINT16_MAX) sp->extra = 0; else sp->extra = 1; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 6a44ae0c8..b79d15e58 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1139,7 +1139,7 @@ static inline void prelevel(char g) continue; } - if (sector[i].lotag == -1) + if (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; @@ -1154,7 +1154,7 @@ static inline void prelevel(char g) A_ResetVars(i); A_LoadActor(i); VM_OnEvent(EVENT_LOADACTOR, i, -1, -1, 0); - if (sprite[i].lotag == -1 && (sprite[i].cstat&16)) + if (sprite[i].lotag == UINT16_MAX && (sprite[i].cstat&16)) { g_player[0].ps->exitx = SX; g_player[0].ps->exity = SY; diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 884421b14..1bba17b9a 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -3031,7 +3031,7 @@ void P_CheckSectors(int32_t snum) P_DoQuote(QUOTE_FOUND_SECRET,p); p->secret_rooms++; return; - case -1: + case UINT16_MAX: for (TRAVERSE_CONNECT(i)) g_player[i].ps->gm = MODE_EOL; sector[p->cursectnum].lotag = 0; @@ -3049,7 +3049,7 @@ void P_CheckSectors(int32_t snum) ud.m_level_number = ud.level_number; } return; - case -2: + case UINT16_MAX-1: sector[p->cursectnum].lotag = 0; p->timebeforeexit = GAMETICSPERSEC*8; p->customexitsound = sector[p->cursectnum].hitag;