From 8b427e35c26fd2db211deb711f120d86b93900e8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Dec 2021 12:28:48 +0100 Subject: [PATCH] - stuff that needs FromInt --- source/core/maphack.cpp | 4 ++-- source/core/maploader.cpp | 6 +++--- source/core/maptypes.h | 2 +- source/games/duke/src/actors.cpp | 5 +++-- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 10 +++++----- source/games/duke/src/ccmds.cpp | 4 ++-- source/games/duke/src/gameexec.cpp | 6 +++--- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/source/core/maphack.cpp b/source/core/maphack.cpp index 98313cd7c..21c2735d0 100644 --- a/source/core/maphack.cpp +++ b/source/core/maphack.cpp @@ -225,7 +225,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites) } else if (currentsprite != -1 && validateSprite()) { - sprites.sprites[currentsprite].cstat &= ~sc.Number; + sprites.sprites[currentsprite].cstat &= ESpriteFlags::FromInt(~sc.Number); } } } @@ -239,7 +239,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites) } else if (currentsprite != -1 && validateSprite()) { - sprites.sprites[currentsprite].cstat |= sc.Number; + sprites.sprites[currentsprite].cstat |= ESpriteFlags::FromInt(sc.Number); } } } diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 2a15ca94d..6e8ac4efd 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -293,7 +293,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno) spr.pos.x = fr.ReadInt32(); spr.pos.y = fr.ReadInt32(); spr.pos.z = fr.ReadInt32(); - spr.cstat = fr.ReadUInt16(); + spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16()); spr.picnum = fr.ReadInt16(); spr.shade = fr.ReadInt8(); spr.pal = fr.ReadUInt8(); @@ -321,7 +321,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno) spr.pos.x = fr.ReadInt32(); spr.pos.y = fr.ReadInt32(); spr.pos.z = fr.ReadInt32(); - spr.cstat = fr.ReadUInt16(); + spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16()); spr.shade = fr.ReadInt8(); spr.pal = fr.ReadUInt8(); spr.clipdist = fr.ReadUInt8(); @@ -349,7 +349,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno) spr.pos.x = fr.ReadInt32(); spr.pos.y = fr.ReadInt32(); spr.pos.z = fr.ReadInt32(); - spr.cstat = fr.ReadUInt16(); + spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16()); spr.shade = fr.ReadInt8(); spr.xrepeat = fr.ReadUInt8(); spr.yrepeat = fr.ReadUInt8(); diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 906dddc1e..a1242e65f 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -395,7 +395,7 @@ struct spritetypebase sectortype* sectp; - uint16_t cstat; + ESpriteFlags cstat; int16_t picnum; int16_t statnum; int16_t ang; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index b42f573e2..472294577 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1521,7 +1521,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) if (s->picnum == stripeball) { s->cstat = CSTAT_SPRITE_BLOCK_ALL; - s->cstat |= int(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP) & s->xvel; + s->cstat |= (CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP) & ESpriteFlags::FromInt(s->xvel); } } else @@ -2524,7 +2524,8 @@ void glasspieces(DDukeActor* actor) if (s->xvel > 0) { s->xvel -= 2; - s->cstat = ((s->xvel & 3) << 2); + static const ESpriteFlags flips[] = { 0, CSTAT_SPRITE_XFLIP, CSTAT_SPRITE_YFLIP, CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP }; + s->cstat = flips[s->xvel & 3]; } else s->xvel = 0; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index e8f46fee3..bfc660dac 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1133,7 +1133,7 @@ static void movecrack(DDukeActor* actor) } else { - s->cstat = t[0]; + s->cstat = ESpriteFlags::FromInt(t[0]); s->ang = t[1]; s->extra = 0; } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index feee0c52f..2e00c5e13 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -899,7 +899,7 @@ static void movecrack(DDukeActor* actor) } else { - s->cstat = t[0]; + s->cstat = ESpriteFlags::FromInt(t[0]); s->ang = t[1]; s->extra = 0; } @@ -2789,15 +2789,15 @@ static int henstand(DDukeActor *actor) s->cstat = CSTAT_SPRITE_BLOCK_ALL; if (s->picnum == BOWLINGPIN) { - s->cstat |= 4 & s->xvel; - s->cstat |= 8 & s->xvel; + s->cstat |= CSTAT_SPRITE_XFLIP & ESpriteFlags::FromInt(s->xvel); + s->cstat |= CSTAT_SPRITE_YFLIP & ESpriteFlags::FromInt(s->xvel); if (krand() & 1) s->picnum = BOWLINGPIN + 1; } else if (s->picnum == HENSTAND) { - s->cstat |= 4 & s->xvel; - s->cstat |= 8 & s->xvel; + s->cstat |= CSTAT_SPRITE_XFLIP & ESpriteFlags::FromInt(s->xvel); + s->cstat |= CSTAT_SPRITE_YFLIP & ESpriteFlags::FromInt(s->xvel); if (krand() & 1) s->picnum = HENSTAND + 1; if (!s->xvel) diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index 6a059f159..b68f68e1f 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -67,7 +67,7 @@ static int ccmd_spawn(CCmdFuncPtr parm) ang = atol(parm->parms[3]) & 2047; set |= 4; [[fallthrough]]; case 3: // cstat - cstat = (unsigned short)atol(parm->parms[2]); set |= 2; + cstat = ESpriteFlags::FromInt(atol(parm->parms[2])); set |= 2; [[fallthrough]]; case 2: // pal pal = (uint8_t)atol(parm->parms[1]); set |= 1; @@ -97,7 +97,7 @@ static int ccmd_spawn(CCmdFuncPtr parm) if (spawned) { if (set & 1) spawned->s->pal = (uint8_t)pal; - if (set & 2) spawned->s->cstat = (uint16_t)cstat; + if (set & 2) spawned->s->cstat = ESpriteFlags::FromInt(cstat); if (set & 4) spawned->s->ang = ang; if (set & 8) SetActor(spawned, { x, y, z }); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 33f4d8828..9bc64d7e5 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1193,7 +1193,7 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, spr->z, sActor, sPlayer); break; case ACTOR_CSTAT: - if (bSet) spr->cstat = lValue; + if (bSet) spr->cstat = ESpriteFlags::FromInt(lValue); else SetGameVarID(lVar2, spr->cstat, sActor, sPlayer); break; case ACTOR_PICNUM: @@ -2215,7 +2215,7 @@ int ParseState::parse(void) break; case concmd_cstator: insptr++; - g_sp->cstat |= (short)*insptr; + g_sp->cstat |= ESpriteFlags::FromInt(*insptr); insptr++; break; case concmd_clipdist: @@ -2225,7 +2225,7 @@ int ParseState::parse(void) break; case concmd_cstat: insptr++; - g_sp->cstat = (uint16_t)*insptr; + g_sp->cstat = ESpriteFlags::FromInt(*insptr); insptr++; break; case concmd_newpic: