From e892de21ece59288e1867372143c741af94ec9e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 10 Jan 2022 00:38:26 +0100 Subject: [PATCH] - preparations for unlimited tsprites. Right now it is a no-op because Polymost cannot deal with this properly. --- source/core/coreactor.h | 4 ++++ source/core/gamefuncs.cpp | 2 ++ source/games/blood/src/animatesprite.cpp | 1 + source/games/duke/src/animatesprites_d.cpp | 1 + source/games/duke/src/animatesprites_r.cpp | 1 + source/games/exhumed/src/view.cpp | 1 + source/games/sw/src/draw.cpp | 1 + 7 files changed, 11 insertions(+) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 410868f0f..e5dd442f0 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -428,3 +428,7 @@ inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const w } tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreActor* actor); +inline void validateTSpriteSize(tspritetype*& tsprite, int& spritesortcnt) +{ + +} diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index a2537fd60..39381d336 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -412,6 +412,8 @@ void dragpoint(walltype* startwall, int newx, int newy) tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreActor* actor) { + validateTSpriteSize(tsprite, spritesortcnt); + if (spritesortcnt >= MAXSPRITESONSCREEN) return nullptr; auto tspr = &tsprite[spritesortcnt++]; diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index c64ea19ed..f5a5b4e2a 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -553,6 +553,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in int nViewSprites = spritesortcnt; for (int nTSprite = spritesortcnt - 1; nTSprite >= 0; nTSprite--) { + validateTSpriteSize(tsprite, spritesortcnt); tspritetype* pTSprite = &tsprite[nTSprite]; auto owneractor = static_cast(pTSprite->ownerActor); if (owneractor->spr.detail > gDetail) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index bd4aa672d..1f2338a4d 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -139,6 +139,7 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in //Between drawrooms() and drawmasks() is the perfect time to animate sprites for (j = 0; j < spritesortcnt; j++) { + validateTSpriteSize(tsprite, spritesortcnt); t = &tsprite[j]; h = static_cast(t->ownerActor); auto OwnerAc = h->GetOwner(); diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index c329e13e8..4395af1ef 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -124,6 +124,7 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in //Between drawrooms() and drawmasks() is the perfect time to animate sprites for (j = 0; j < spritesortcnt; j++) { + validateTSpriteSize(tsprite, spritesortcnt); t = &tsprite[j]; h = static_cast(t->ownerActor); auto OwnerAc = h->GetOwner(); diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 93ba52474..56667044c 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -73,6 +73,7 @@ static void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int x, int myspritesortcnt = &spritesortcnt; for (int i = 0; i < spritesortcnt; i++) { + validateTSpriteSize(tsprite, spritesortcnt); pTSprite = &tsprite[i]; if (pTSprite->ownerActor) diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 934c607c4..bb227a46d 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -605,6 +605,7 @@ void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int vie for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--) { + validateTSpriteSize(tsprite, spritesortcnt); tspritetype* tsp = &tsprite[tSpriteNum]; auto tActor = static_cast(tsp->ownerActor); auto tsectp = tsp->sectp;