From 415dc5246d35d27771e958d30f727196623c3e45 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 8 Jan 2022 21:18:18 +0100 Subject: [PATCH] - fixed sprting of non-translucent sprites. --- source/core/actorlist.cpp | 2 +- source/core/automap.cpp | 2 +- source/core/coreactor.h | 3 ++- source/core/gamefuncs.cpp | 2 +- source/core/maptypes.h | 4 +--- source/core/rendering/scene/hw_drawlist.cpp | 2 +- source/core/savegamehelp.cpp | 2 +- source/games/blood/src/db.cpp | 1 - source/games/sw/src/sprite.cpp | 2 -- 9 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 21c5fcda4..358a7b28f 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -353,7 +353,7 @@ DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail) InsertActorSect(actor, sector, tail); Numsprites++; - actor->spr.time = leveltimer++; + actor->time = leveltimer++; return actor; } diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 222d0bf65..eb098b7a7 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -608,7 +608,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) auto A = *(DCoreActor**)a; auto B = *(DCoreActor**)b; if (A->spr.pos.Z != B->spr.pos.Z) return B->spr.pos.Z - A->spr.pos.Z; - return A->spr.time - B->spr.time; // ensures stable sort. + return A->time - B->time; // ensures stable sort. }); vertices.Resize(4); diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 217fdb14c..410868f0f 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -21,6 +21,7 @@ public: spritesmooth_t spsmooth; vec3_t opos; + int time; int16_t oang; DCoreActor() = default; @@ -42,7 +43,7 @@ public: int GetIndex() const { // This is only identical with the sprite index for items spawned at map start. - return spr.time; + return time; } int32_t interpolatedx(double const smoothratio, int const scale = 16) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 4fc793f10..8a61acc95 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -434,7 +434,7 @@ tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreAct tspr->lotag = actor->spr.lotag; tspr->hitag = actor->spr.hitag; tspr->extra = actor->spr.extra; - tspr->time = actor->spr.time; + tspr->time = actor->time; tspr->ownerActor = actor; // need to copy the slope sprite flag around because for tsprites the bit combination means 'voxel'. diff --git a/source/core/maptypes.h b/source/core/maptypes.h index df16bbe03..bb15166d0 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -447,9 +447,6 @@ struct spritetypebase uint8_t yrepeat; int8_t xoffset; int8_t yoffset; - - // extensions not from the binary map format. - int time; }; @@ -470,6 +467,7 @@ struct spritetype : public spritetypebase struct tspritetype : public spritetypebase { DCoreActor* ownerActor; + int time; }; extern TArray sector; diff --git a/source/core/rendering/scene/hw_drawlist.cpp b/source/core/rendering/scene/hw_drawlist.cpp index ccddca832..1630cedee 100644 --- a/source/core/rendering/scene/hw_drawlist.cpp +++ b/source/core/rendering/scene/hw_drawlist.cpp @@ -688,7 +688,7 @@ inline int HWDrawList::CompareSprites(SortNode * a,SortNode * b) if (s1->depth < s2->depth) return 1; if (s1->depth > s2->depth) return -1; - return s1->Sprite->time - s2->Sprite->time; + return s2->Sprite->time - s1->Sprite->time; } //========================================================================== diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 316914151..9f13a3df7 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -470,7 +470,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet ("hitag", c.hitag, def->hitag) ("extra", c.extra, def->extra) ("detail", c.detail, def->detail) - ("time", c.time, def->time) ("cstat2", c.cstat2, def->cstat2) .EndObject(); } @@ -674,6 +673,7 @@ void DCoreActor::Serialize(FSerializer& arc) ("prevsect", prevSect) ("nextsect", nextSect) ("sprite", spr) + ("time", time) ("spriteext", sprext); if (arc.isReading()) spsmooth = {}; diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index 844f5fa81..43b21805b 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -501,7 +501,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* pSprite->detail = load.detail; pSprite->shade = load.shade; pSprite->blend = 0; - pSprite->time = i; validateSprite(*pSprite, secno, i); if (pSprite->extra > 0) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index f886a3d27..ac1947434 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -925,9 +925,7 @@ bool ActorTestSpawn(DSWActor* actor) if (actor->spr.statnum == STAT_DEFAULT && actor->spr.lotag == TAG_SPAWN_ACTOR) { auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); - int t = actorNew->spr.time; // must be preserved! actorNew->spr = actor->spr; - actorNew->spr.time = t; change_actor_stat(actorNew, STAT_SPAWN_TRIGGER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); return false;