From 8f0f0e88161eb52e1d28ef9a12a4c35e18956f9d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Dec 2021 17:35:01 +0100 Subject: [PATCH] - manual sprite flag replacements in Duke. --- source/build/src/engine.cpp | 2 +- source/build/src/mdsprite.cpp | 2 +- source/build/src/polymost.cpp | 4 ++-- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/animatesprites_r.cpp | 6 ++--- source/games/duke/src/player_d.cpp | 6 ++--- source/games/duke/src/player_r.cpp | 4 ++-- source/games/duke/src/sectors_d.cpp | 6 ++--- source/games/duke/src/sectors_r.cpp | 4 ++-- source/games/duke/src/spawn_d.cpp | 28 +++++++++++----------- source/games/duke/src/spawn_r.cpp | 24 +++++++++---------- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index a6fcbed70..f260c8a6a 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -419,7 +419,7 @@ int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyo if (height != NULL) *height = hei; - if (spr->cstat&128) + if (spr->cstat & CSTAT_SPRITE_YCENTER) zofs = hei>>1; // NOTE: a positive per-tile yoffset translates the sprite into the diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index d6c279bf9..5b1dde005 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1252,7 +1252,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) // tinting pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; - pc[3] = (tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) ? glblend[tspr->blend].def[!!(tspr->cstat&512)].alpha : 1.0f; + pc[3] = (tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) ? glblend[tspr->blend].def[!!(tspr->cstat & CSTAT_SPRITE_TRANS_FLIP)].alpha : 1.0f; pc[3] *= 1.0f - sext->alpha; SetRenderStyleFromBlend(!!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT), tspr->blend, !!(tspr->cstat & CSTAT_SPRITE_TRANS_FLIP)); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index b23959e67..e5322324b 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -1877,7 +1877,7 @@ void polymost_scansector(int32_t sectnum) while (auto act = it.Next()) { auto spr = &act->s(); - if ((spr->cstat & 0x8000) || spr->xrepeat == 0 || spr->yrepeat == 0) + if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) continue; vec2_t const s = { spr->x-globalposx, spr->y-globalposy }; @@ -1886,7 +1886,7 @@ void polymost_scansector(int32_t sectnum) (hw_models && tile2model[spr->picnum].modelid>=0) || ((s.x * gcosang) + (s.y * gsinang) > 0)) { - if ((spr->cstat&(64+48))!=(64+16) || + if ((spr->cstat&(CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_MASK))!=(CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL) || (r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || (r_voxels && gi->Voxelize(spr->picnum) > -1) || DMulScale(bcos(spr->ang), -s.x, bsin(spr->ang), -s.y, 6) > 0) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 427a65a5f..feee0c52f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -3374,7 +3374,7 @@ void handle_se06_r(DDukeActor *actor) ns = EGS(s->sector(), s->x, s->y, s->sector()->ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5); if (ns) { - ns->s->cstat = 514; + ns->s->cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; ns->s->pal = 7; ns->s->xrepeat = 80; ns->s->yrepeat = 255; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 52b1c3c11..3236604f9 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -931,9 +931,9 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in t->picnum = s->picnum + (h->temp_data[0] & 1); [[fallthrough]]; case SHOTGUNSHELL: - t->cstat |= 12; + t->cstat |= CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP; if (h->temp_data[0] > 1) t->cstat &= ~CSTAT_SPRITE_XFLIP; - if (h->temp_data[0] > 2) t->cstat &= ~12; + if (h->temp_data[0] > 2) t->cstat &= ~CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP; break; case FRAMEEFFECT1: if (Owner && Owner->statnum < MAXSTATUS) @@ -954,7 +954,7 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in t->pal = Owner->pal; t->shade = Owner->shade; t->ang = Owner->ang; - t->cstat = 2 | Owner->cstat; + t->cstat = CSTAT_SPRITE_TRANSLUCENT | Owner->cstat; } } break; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index d95b8580a..4445e63a8 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -205,7 +205,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int spawned->s->y = sy + bsin(sa + 112) / 448; spawned->s->z = sz - 256; spawned->s->setsector(s->sector()); - spawned->s->cstat = 0x80; + spawned->s->cstat = CSTAT_SPRITE_YCENTER; spawned->s->ang = sa; spawned->s->xrepeat = 2; spawned->s->yrepeat = 2; @@ -982,7 +982,7 @@ static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int if (!spark) return; spark->s->pal = 2; - spark->s->cstat |= 130; + spark->s->cstat |= CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT; spark->s->xrepeat = spark->s->yrepeat = 1; if (hit.hitWall == nullptr && hit.actor() == nullptr && hit.hitSector != nullptr) @@ -2790,7 +2790,7 @@ void processinput_d(int snum) if (clz.type == kHitSprite) { - if ((clz.actor()->s->cstat & 33) == 33) + if ((clz.actor()->s->cstat & (CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_BLOCK)) == (CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_BLOCK)) { psectlotag = 0; p->footprintcount = 0; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index cf677ca43..4be9ca2ac 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2360,7 +2360,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) j->s->xrepeat = 3; j->s->yrepeat = 2; j->s->z = p->pos.z + (8 << 8); - j->s->cstat = 514; + j->s->cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; } } } @@ -3463,7 +3463,7 @@ void processinput_r(int snum) if (clz.type == kHitSprite) { - if ((clz.actor()->s->cstat & 33) == 33) + if ((clz.actor()->s->cstat & (CSTAT_SPRITE_ALIGNMENT_FLOOR| CSTAT_SPRITE_BLOCK)) == (CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_BLOCK)) { psectlotag = 0; p->footprintcount = 0; diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 49ff8bcb0..06cc8c1a7 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -691,7 +691,7 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw } if (spawned) { - spawned->s->cstat |= 18 + 128; + spawned->s->cstat |= CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER; auto delta = wal->delta(); spawned->s->ang = getangle(-delta.x, -delta.y) - 512; @@ -1255,7 +1255,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case TOILET: s->picnum = TOILETBROKE; - s->cstat |= (krand() & 1) << 2; + if (krand() & 1) s->cstat |= CSTAT_SPRITE_XFLIP; s->cstat &= ~CSTAT_SPRITE_BLOCK_ALL; spawn(targ, TOILETWATER); S_PlayActorSound(GLASS_BREAKING, targ); @@ -1263,7 +1263,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case STALL: s->picnum = STALLBROKE; - s->cstat |= (krand() & 1) << 2; + if (krand() & 1) s->cstat |= CSTAT_SPRITE_XFLIP; s->cstat &= ~CSTAT_SPRITE_BLOCK_ALL; spawn(targ, TOILETWATER); S_PlayActorSound(GLASS_HEAVYBREAK, targ); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 47eaa96bd..5bef29c80 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2281,7 +2281,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) } case TOILET: s->picnum = TOILETBROKE; - s->cstat |= (krand() & 1) << 2; + if(krand() & 1) s->cstat |= CSTAT_SPRITE_XFLIP; s->cstat &= ~CSTAT_SPRITE_BLOCK_ALL; spawn(targ, TOILETWATER); S_PlayActorSound(GLASS_BREAKING, targ); @@ -2289,7 +2289,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case STALL: s->picnum = STALLBROKE; - s->cstat |= (krand() & 1) << 2; + if (krand() & 1) s->cstat |= CSTAT_SPRITE_XFLIP; s->cstat &= ~CSTAT_SPRITE_BLOCK_ALL; spawn(targ, TOILETWATER); S_PlayActorSound(GLASS_HEAVYBREAK, targ); diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index fbf13826c..82843ae81 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -240,7 +240,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* sp->xrepeat = 32; if (gs.lasermode == 1) - sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL + 2; + sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_TRANSLUCENT; else if (gs.lasermode == 0 || gs.lasermode == 2) sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL; else @@ -297,7 +297,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* if (spj->picnum == TIRE) sp->shade = 127; } - sp->cstat |= 32; + sp->cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR; if (sp->picnum == LAVAPOOL) // Twentieth Anniversary World Tour { int fz = getflorzofslopeptr(sp->sector(), sp->x, sp->y); @@ -317,7 +317,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* case BLOODSPLAT2: case BLOODSPLAT3: case BLOODSPLAT4: - sp->cstat |= 16; + sp->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL; sp->xrepeat = 7 + (krand() & 7); sp->yrepeat = 7 + (krand() & 7); sp->z -= (16 << 8); @@ -460,8 +460,8 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* case MASKWALL14: case MASKWALL15: { - int j = sp->cstat & 60; - sp->cstat = j | 1; + auto j = sp->cstat & (CSTAT_SPRITE_ALIGNMENT_MASK | CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP); + sp->cstat = j | CSTAT_SPRITE_BLOCK; ChangeActorStat(act, 0); break; } @@ -498,7 +498,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* if (sp->picnum == QUEBALL || sp->picnum == STRIPEBALL) { - sp->cstat = 256; + sp->cstat = CSTAT_SPRITE_BLOCK_HITSCAN; sp->clipdist = 8; } else @@ -654,7 +654,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* sp->x += krand() % 256 - 128; sp->y += krand() % 256 - 128; sp->z -= krand() % 10240; - sp->cstat |= 0x80; + sp->cstat |= CSTAT_SPRITE_YCENTER; } ChangeActorStat(act, STAT_MISC); @@ -926,7 +926,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* break; case DOORSHOCK: - sp->cstat |= 1 + 256; + sp->cstat |= CSTAT_SPRITE_BLOCK_ALL; sp->shade = -12; ChangeActorStat(act, 6); break; @@ -951,7 +951,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* sp->yrepeat = j; sp->xrepeat = 25 - (j >> 1); - sp->cstat |= (krand() & 4); + if (krand() & 4) sp->cstat |= CSTAT_SPRITE_XFLIP; break; } @@ -1011,7 +1011,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* sp->z -= (32 << 8); sp->zvel = -1024; ssp(act, CLIPMASK0); - sp->cstat = krand() & 4; + if (krand() & 4) sp->cstat |= CSTAT_SPRITE_XFLIP; } else { @@ -1078,7 +1078,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* case BOUNCEMINE: act->SetOwner(act); - sp->cstat |= 1 + 256; //Make it hitable + sp->cstat |= CSTAT_SPRITE_BLOCK_ALL; //Make it hitable sp->xrepeat = sp->yrepeat = 24; sp->shade = -127; sp->extra = gs.impact_damage << 2; @@ -1114,7 +1114,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* if (spj) { sp->ang = spj->ang; - sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL + 128 + 2; + sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT; sp->xrepeat = sp->yrepeat = 1; sp->xvel = -8; ssp(act, CLIPMASK0); @@ -1139,7 +1139,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* sp->cstat = CSTAT_SPRITE_INVISIBLE; sp->xrepeat = sp->yrepeat = 0; } - else sp->cstat = 1 + 256; + else sp->cstat = CSTAT_SPRITE_BLOCK_ALL; sp->extra = gs.impact_damage << 2; act->SetOwner(act); ChangeActorStat(act, STAT_STANDABLE); @@ -1157,7 +1157,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* } else { - sp->cstat |= (sp->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) ? 1 : 17; + sp->cstat |= (sp->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) ? CSTAT_SPRITE_BLOCK : (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_ALIGNMENT_WALL); sp->extra = 1; } diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 487733908..5c4e87a05 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -346,14 +346,14 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* if (spj->picnum == TIRE) sp->shade = 127; } - sp->cstat |= 32; + sp->cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR; [[fallthrough]]; case BLOODSPLAT1: case BLOODSPLAT2: case BLOODSPLAT3: case BLOODSPLAT4: - sp->cstat |= 16; + sp->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL; sp->xrepeat = 7 + (krand() & 7); sp->yrepeat = 7 + (krand() & 7); sp->z -= (16 << 8); @@ -426,8 +426,8 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case MASKWALL7: { - int j = sp->cstat & 60; - sp->cstat = j | 1; + auto j = sp->cstat & (CSTAT_SPRITE_ALIGNMENT_MASK | CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP); + sp->cstat = j | CSTAT_SPRITE_BLOCK; ChangeActorStat(act, 0); break; } @@ -448,7 +448,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case STRIPEBALL: if (sp->picnum == QUEBALL || sp->picnum == STRIPEBALL) { - sp->cstat = 256; + sp->cstat = CSTAT_SPRITE_BLOCK_HITSCAN; sp->clipdist = 8; } else @@ -459,7 +459,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, 2); break; case BOWLINGBALL: - sp->cstat = 256; + sp->cstat = CSTAT_SPRITE_BLOCK_HITSCAN; sp->clipdist = 64; sp->xrepeat = 11; sp->yrepeat = 9; @@ -906,7 +906,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case MAMACLOUD: sp->xrepeat = 64; sp->yrepeat = 64; - sp->cstat = 2; + sp->cstat = CSTAT_SPRITE_TRANSLUCENT; sp->cstat |= CSTAT_SPRITE_TRANS_FLIP; sp->x += (krand() & 2047) - 1024; sp->y += (krand() & 2047) - 1024; @@ -990,7 +990,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* sp->yrepeat = 128; sp->clipdist = MulScale(sp->xrepeat, tileWidth(sp->picnum), 7); sp->clipdist >>= 2; - sp->cstat = 2; + sp->cstat = CSTAT_SPRITE_TRANSLUCENT; break; case LTH: sp->xrepeat = 24; @@ -1079,7 +1079,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_ACTIVATOR); break; case DOORSHOCK: - sp->cstat |= 1 + 256; + sp->cstat |= CSTAT_SPRITE_BLOCK_ALL; sp->shade = -12; ChangeActorStat(act, STAT_STANDABLE); @@ -1101,7 +1101,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* sp->yrepeat = j; sp->xrepeat = 25 - (j >> 1); - sp->cstat |= (krand() & 4); + if(krand() & 4) sp->cstat |= CSTAT_SPRITE_XFLIP; break; } case HEAVYHBOMB: @@ -1221,12 +1221,12 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case SHOTGUNAMMO: sp->xrepeat = 18; sp->yrepeat = 17; - if (isRRRA()) sp->cstat = 256; + if (isRRRA()) sp->cstat = CSTAT_SPRITE_BLOCK_HITSCAN; break; case SIXPAK: sp->xrepeat = 13; sp->yrepeat = 9; - if (isRRRA()) sp->cstat = 256; + if (isRRRA()) sp->cstat = CSTAT_SPRITE_BLOCK_HITSCAN; break; case FIRSTAID: sp->xrepeat = 8;