- unlimited the displayable sprites.

Now with Polymost gone this can finally be done properly.
This commit is contained in:
Christoph Oelckers 2022-08-07 10:25:15 +02:00
parent 3ca9052b7a
commit 4d423004e9
22 changed files with 183 additions and 176 deletions

View file

@ -44,7 +44,6 @@ enum
MAXVOXELS = 1024,
// Maximum number of component tiles in a multi-psky:
MAXSPRITESONSCREEN = 4096,
MAXUNIQHUDID = 256, //Extra slots so HUD models can store animation state without messing game sprites
TSPR_TEMP = 99,

View file

@ -459,11 +459,7 @@ inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const w
return res;
}
tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreActor* actor);
inline void validateTSpriteSize(tspritetype*& tsprite, int& spritesortcnt)
{
}
tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor);
inline PClassActor* PClass::FindActor(FName name)
{

View file

@ -553,12 +553,9 @@ sectortype* nextsectorneighborzptr(sectortype* sectp, int startz, int flags)
//
//==========================================================================
tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreActor* actor)
tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
{
validateTSpriteSize(tsprite, spritesortcnt);
if (spritesortcnt >= MAXSPRITESONSCREEN) return nullptr;
auto tspr = &tsprite[spritesortcnt++];
auto tspr = tsprites.newTSprite();
tspr->pos = actor->spr.pos;
tspr->cstat = actor->spr.cstat;

View file

@ -9,6 +9,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
#include "packet.h"
#include "binaryangle.h"
#include "inputstate.h"
#include "maptypes.h"
class FSerializer;
struct FRenderViewpoint;
@ -118,7 +119,7 @@ struct GameInterface
virtual int chaseCamX(binangle ang) { return 0; }
virtual int chaseCamY(binangle ang) { return 0; }
virtual int chaseCamZ(fixedhoriz horiz) { return 0; }
virtual void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0;
virtual void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0;
virtual void UpdateCameras(double smoothratio) {}
virtual void EnterPortal(DCoreActor* viewer, int type) {}
virtual void LeavePortal(DCoreActor* viewer, int type) {}

View file

@ -491,6 +491,47 @@ struct tspritetype : public spritetypebase
int time;
};
class tspriteArray
{
static const int blockbits = 9;
static const int blocksize = 1 << blockbits;
struct block
{
tspritetype data[blocksize];
};
TDeletingArray<block*> blocks;
unsigned size;
public:
tspritetype* newTSprite()
{
if ((size & (blocksize - 1)) == 0) blocks.Push(new block);
return get(size++);
}
tspritetype* get(unsigned index)
{
assert(index < size);
return &blocks[index >> blockbits]->data[index & (blocksize - 1)];
}
tspritetype* current()
{
return get(size - 1);
}
void clear()
{
blocks.DeleteAndClear();
size = 0;
}
unsigned Size() const
{
return size;
}
};
extern TArray<sectortype> sector;
extern TArray<walltype> wall;
extern TArray<sectortype> sectorbackup;

View file

@ -685,7 +685,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
(r_voxels && tiletovox[actor->spr.picnum] >= 0 && voxmodels[tiletovox[actor->spr.picnum]]) ||
(r_voxels && gi->Voxelize(actor->spr.picnum) > -1) ||
DMulScale(bcos(actor->spr.ang), -sx, bsin(actor->spr.ang), -sy, 6) > 0)
if (!renderAddTsprite(di->tsprite, di->spritesortcnt, actor))
if (!renderAddTsprite(di->tsprites, actor))
break;
}
}

View file

@ -273,9 +273,9 @@ HWPortal * HWDrawInfo::FindPortal(const void * src)
void HWDrawInfo::DispatchSprites()
{
for (int i = 0; i < spritesortcnt; i++)
for (unsigned i = 0; i < tsprites.Size(); i++)
{
auto tspr = &tsprite[i];
auto tspr = tsprites.get(i);
int tilenum = tspr->picnum;
auto actor = tspr->ownerActor;
@ -378,8 +378,7 @@ void HWDrawInfo::CreateScene(bool portal)
screen->mVertexData->Map();
screen->mLights->Map();
memset(tsprite, 0, sizeof(tsprite));
spritesortcnt = 0;
tsprites.clear();
ingeo = false;
geoofs = { 0,0 };
@ -395,7 +394,7 @@ void HWDrawInfo::CreateScene(bool portal)
mDrawer.RenderScene(&vp.SectCount, 1, portal);
SetupSprite.Clock();
gi->processSprites(tsprite, spritesortcnt, view.X, view.Y, vp.Pos.Z * -256, bamang(vp.RotAngle), vp.TicFrac * 65536);
gi->processSprites(tsprites, view.X, view.Y, vp.Pos.Z * -256, bamang(vp.RotAngle), vp.TicFrac * 65536);
DispatchSprites();
SetupSprite.Unclock();

View file

@ -112,8 +112,7 @@ struct HWDrawInfo
FRenderViewpoint Viewpoint;
HWViewpointUniforms VPUniforms; // per-viewpoint uniform state
TArray<HWPortal *> Portals;
tspritetype tsprite[MAXSPRITESONSCREEN];
int spritesortcnt;
tspriteArray tsprites;
TArray<FFlatVertex> SlopeSpriteVertices; // we need to cache these in system memory in case of translucency splits.
// This is needed by the BSP traverser.

View file

@ -84,22 +84,17 @@ static void RotateXZ(int* pX, int*, int* pZ, int ang)
//
//---------------------------------------------------------------------------
tspritetype* viewInsertTSprite(tspritetype* tsprite, int& spritesortcnt, sectortype* pSector, int nStatnum, tspritetype const* const parentTSprite)
tspritetype* viewInsertTSprite(tspriteArray& tsprites, sectortype* pSector, int nStatnum, tspritetype const* const parentTSprite)
{
if (spritesortcnt >= MAXSPRITESONSCREEN)
return nullptr;
int nTSprite = spritesortcnt;
tspritetype* pTSprite = &tsprite[nTSprite];
tspritetype* pTSprite = tsprites.newTSprite();
memset(pTSprite, 0, sizeof(tspritetype));
pTSprite->cstat = CSTAT_SPRITE_YCENTER;
pTSprite->xrepeat = 64;
pTSprite->yrepeat = 64;
pTSprite->ownerActor = nullptr;
pTSprite->type = -spritesortcnt;
pTSprite->type = -int(tsprites.Size() - 1);
pTSprite->statnum = nStatnum;
pTSprite->sectp = pSector;
spritesortcnt++;
if (parentTSprite)
{
pTSprite->pos = parentTSprite->pos;
@ -145,12 +140,12 @@ static const WEAPONICON gWeaponIcon[] = {
//
//---------------------------------------------------------------------------
static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int nTSprite, VIEW_EFFECT nViewEffect)
static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFFECT nViewEffect)
{
assert(nViewEffect >= 0 && nViewEffect < kViewEffectMax);
auto pTSprite = &tsprite[nTSprite];
auto pTSprite = tsprites.get(nTSprite);
auto owneractor = static_cast<DBloodActor*>(pTSprite->ownerActor);
if (gDetail < effectDetail[nViewEffect] || nTSprite >= MAXSPRITESONSCREEN) return NULL;
if (gDetail < effectDetail[nViewEffect]) return NULL;
switch (nViewEffect)
{
case kViewEffectSpotProgress: {
@ -160,7 +155,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
auto pNSprite2 = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite2 = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite2)
break;
@ -179,7 +174,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
case kViewEffectAtom:
for (int i = 0; i < 16; i++)
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -205,7 +200,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
{
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -221,7 +216,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectTesla:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -235,7 +230,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectShoot:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -247,7 +242,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectReflectiveBall:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -260,7 +255,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectPhase:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -285,10 +280,10 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
{
nAng = (nAng + 1024) & 2047;
}
for (int i = 0; i < 5 && spritesortcnt < MAXSPRITESONSCREEN; i++)
for (int i = 0; i < 5; i++)
{
auto pSector = pTSprite->sectp;
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pSector, 32767, NULL);
auto pNSprite = viewInsertTSprite(tsprites, pSector, 32767, NULL);
if (!pNSprite)
break;
@ -315,7 +310,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectFlame:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -328,7 +323,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectSmokeHigh:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -347,7 +342,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectSmokeLow:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -366,7 +361,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectTorchHigh:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -380,7 +375,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectTorchLow:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -394,7 +389,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectShadow:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
pNSprite->pos.Z = getflorzofslopeptr(pTSprite->sectp, pNSprite->pos.X, pNSprite->pos.Y);
@ -430,7 +425,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectFlareHalo:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -445,7 +440,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectCeilGlow:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -464,7 +459,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectFloorGlow:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -484,7 +479,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
}
case kViewEffectSpear:
{
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -504,7 +499,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int
WEAPONICON weaponIcon = gWeaponIcon[pPlayer->curWeapon];
auto& nTile = weaponIcon.nTile;
if (nTile < 0) break;
auto pNSprite = viewInsertTSprite(tsprite, spritesortcnt, pTSprite->sectp, 32767, pTSprite);
auto pNSprite = viewInsertTSprite(tsprites, pTSprite->sectp, 32767, pTSprite);
if (!pNSprite)
break;
@ -558,17 +553,15 @@ static void viewApplyDefaultPal(tspritetype* pTSprite, sectortype const* pSector
//
//---------------------------------------------------------------------------
void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smoothratio)
void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smoothratio)
{
int nViewSprites = tsprites.Size();
// shift before interpolating to increase precision.
int myclock = (PlayClock << 3) + MulScale(4 << 3, smoothratio, 16);
assert(spritesortcnt <= MAXSPRITESONSCREEN);
gCameraAng = cA;
int nViewSprites = spritesortcnt;
for (int nTSprite = spritesortcnt - 1; nTSprite >= 0; nTSprite--)
for (int nTSprite = int(tsprites.Size()) - 1; nTSprite >= 0; nTSprite--)
{
validateTSpriteSize(tsprite, spritesortcnt);
tspritetype* pTSprite = &tsprite[nTSprite];
tspritetype* pTSprite = tsprites.get(nTSprite);
auto owneractor = static_cast<DBloodActor*>(pTSprite->ownerActor);
if (owneractor->spr.detail > gDetail)
{
@ -762,14 +755,13 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
pTSprite->xrepeat = pTSprite->yrepeat = 0;
}
}
if (spritesortcnt >= MAXSPRITESONSCREEN) continue;
if (owneractor->hasX() && owneractor->xspr.burnTime > 0)
{
pTSprite->shade = ClipRange(pTSprite->shade - 16 - QRandom(8), -128, 127);
}
if (pTSprite->flags & 256)
{
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSmokeHigh);
viewAddEffect(tsprites, nTSprite, kViewEffectSmokeHigh);
}
if (pTSprite->flags & 1024)
{
@ -785,7 +777,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
case kDecorationCandle:
if (!owneractor->hasX() || owneractor->xspr.state == 1) {
pTSprite->shade = -128;
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectPhase);
viewAddEffect(tsprites, nTSprite, kViewEffectPhase);
}
else {
pTSprite->shade = -8;
@ -794,10 +786,10 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
case kDecorationTorch:
if (!owneractor->hasX() || owneractor->xspr.state == 1) {
pTSprite->picnum++;
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTorchHigh);
viewAddEffect(tsprites, nTSprite, kViewEffectTorchHigh);
}
else {
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSmokeHigh);
viewAddEffect(tsprites, nTSprite, kViewEffectSmokeHigh);
}
break;
default:
@ -810,13 +802,13 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
switch (pTSprite->type) {
case kItemFlagABase:
if (owneractor->hasX() && owneractor->xspr.state > 0 && gGameOptions.nGameType == 3) {
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectBigFlag);
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectBigFlag);
if (pNTSprite) pNTSprite->pal = 10;
}
break;
case kItemFlagBBase:
if (owneractor->hasX() && owneractor->xspr.state > 0 && gGameOptions.nGameType == 3) {
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectBigFlag);
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectBigFlag);
if (pNTSprite) pNTSprite->pal = 7;
}
break;
@ -844,10 +836,10 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
pTSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR;
break;
case kMissileTeslaRegular:
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTesla);
viewAddEffect(tsprites, nTSprite, kViewEffectTesla);
break;
case kMissileButcherKnife:
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectTrail);
viewAddEffect(tsprites, nTSprite, kViewEffectTrail);
break;
case kMissileFlareRegular:
case kMissileFlareAlt:
@ -859,18 +851,18 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
}
}
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlareHalo);
viewAddEffect(tsprites, nTSprite, kViewEffectFlareHalo);
if (pTSprite->type != kMissileFlareRegular) break;
sectortype* pSector1 = pTSprite->sectp;
int zDiff = (pTSprite->pos.Z - pSector1->ceilingz) >> 8;
if ((pSector1->ceilingstat & CSTAT_SECTOR_SKY) == 0 && zDiff < 64) {
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectCeilGlow);
viewAddEffect(tsprites, nTSprite, kViewEffectCeilGlow);
}
zDiff = (pSector1->floorz - pTSprite->pos.Z) >> 8;
if ((pSector1->floorstat & CSTAT_SECTOR_SKY) == 0 && zDiff < 64) {
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFloorGlow);
viewAddEffect(tsprites, nTSprite, kViewEffectFloorGlow);
}
break;
}
@ -906,15 +898,15 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
}
if (powerupCheck(pPlayer, kPwUpReflectShots)) {
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectReflectiveBall);
viewAddEffect(tsprites, nTSprite, kViewEffectReflectiveBall);
}
if (cl_showweapon && gGameOptions.nGameType > 0 && gView) {
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShowWeapon);
viewAddEffect(tsprites, nTSprite, kViewEffectShowWeapon);
}
if (pPlayer->flashEffect && (gView != pPlayer || gViewPos != VIEWPOS_0)) {
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShoot);
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectShoot);
if (pNTSprite) {
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
pNTSprite->pos.X += MulScale(pPosture->zOffset, Cos(pTSprite->ang), 28);
@ -925,7 +917,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
if (pPlayer->hasFlag > 0 && gGameOptions.nGameType == 3) {
if (pPlayer->hasFlag & 1) {
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlag);
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag);
if (pNTSprite)
{
pNTSprite->pal = 10;
@ -933,7 +925,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
}
}
if (pPlayer->hasFlag & 2) {
auto pNTSprite = viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectFlag);
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag);
if (pNTSprite)
{
pNTSprite->pal = 7;
@ -946,13 +938,13 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
if (pTSprite->ownerActor != gView->actor || gViewPos != VIEWPOS_0) {
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->pos.X, pTSprite->pos.Y) >= cZ)
{
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShadow);
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);
}
}
if (gModernMap && owneractor->hasX()) { // add target spot indicator for patrol dudes
if (owneractor->xspr.dudeFlag4 && aiInPatrolState(owneractor->xspr.aiState) && owneractor->xspr.data3 > 0 && owneractor->xspr.data3 <= kMaxPatrolSpotValue)
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSpotProgress);
viewAddEffect(tsprites, nTSprite, kViewEffectSpotProgress);
}
break;
}
@ -962,7 +954,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
if (owneractor->xspr.data1) {
pTSprite->picnum = 772;
if (owneractor->xspr.data2)
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectSpear);
viewAddEffect(tsprites, nTSprite, kViewEffectSpear);
}
}
else if (owneractor->xspr.data1) pTSprite->picnum = 773;
@ -977,16 +969,16 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
if (pTSprite->type < kThingBase || pTSprite->type >= kThingMax || owneractor->hit.florhit.type == kHitNone)
{
if ((pTSprite->flags & kPhysMove) && getflorzofslopeptr(pTSprite->sectp, pTSprite->pos.X, pTSprite->pos.Y) >= cZ)
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShadow);
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);
}
}
break;
}
}
for (int nTSprite = spritesortcnt - 1; nTSprite >= nViewSprites; nTSprite--)
for (int nTSprite = int(tsprites.Size() - 1); nTSprite >= nViewSprites; nTSprite--)
{
tspritetype* pTSprite = &tsprite[nTSprite];
tspritetype* pTSprite = tsprites.get(nTSprite);
int nAnim = 0;
switch (picanm[pTSprite->picnum].extra & 7)
{
@ -1031,9 +1023,9 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
//
//---------------------------------------------------------------------------
void GameInterface::processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
viewProcessSprites(tsprite, spritesortcnt, viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
viewProcessSprites(tsprites, viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
}
int display_mirror;

View file

@ -145,7 +145,7 @@ struct GameInterface : public ::GameInterface
int chaseCamX(binangle ang) override { return MulScale(-Cos(ang.asbuild()), 1280, 30); }
int chaseCamY(binangle ang) override { return MulScale(-Sin(ang.asbuild()), 1280, 30); }
int chaseCamZ(fixedhoriz horiz) override { return FixedToInt(MulScale(horiz.asq16(), 1280, 3)) - (16 << 8); }
void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override;
void LoadGameTextures() override;

View file

@ -147,7 +147,7 @@ void viewCorrectViewOffsets(int nPlayer, vec3_t const* oldpos);
void InitStatusBar(void);
void UpdateStatusBar();
void viewInit(void);
void viewprocessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void viewprocessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void viewSetMessage(const char* pMessage, const char* color = nullptr, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);

View file

@ -44,16 +44,16 @@ EXTERN_CVAR(Bool, wt_commentary)
BEGIN_DUKE_NS
void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio)
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothratio)
{
int j, k, p;
int k, p;
int l, t1, t3, t4;
tspritetype* t;
DDukeActor* h;
for (j = 0; j < spritesortcnt; j++)
for (unsigned j = 0; j < tsprites.Size(); j++)
{
t = &tsprite[j];
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
switch (t->picnum)
@ -137,10 +137,9 @@ 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++)
for (unsigned j = 0; j < tsprites.Size(); j++)
{
validateTSpriteSize(tsprite, spritesortcnt);
t = &tsprite[j];
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
auto OwnerAc = h->GetOwner();
@ -327,8 +326,8 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && ps[p].GetActor()->spr.extra > 0 && ps[p].curr_weapon > 0)
{
auto newtspr = &tsprite[spritesortcnt++];
newtspr = t;
auto newtspr = tsprites.newTSprite();
*newtspr = *t;
newtspr->statnum = 99;
@ -569,7 +568,7 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
{
if (h->spr.picnum != HOTMEAT)
{
if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2) && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
if (r_shadows && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
{
int daz;
@ -581,7 +580,7 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
if ((h->spr.pos.Z - daz) < (8 << 8) && ps[screenpeek].pos.Z < daz)
{
auto shadowspr = &tsprite[spritesortcnt++];
auto shadowspr = tsprites.newTSprite();
*shadowspr = *t;
shadowspr->statnum = 99;

View file

@ -37,18 +37,18 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS
void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio)
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothratio)
{
int j, k, p;
int k, p;
int l, t1, t3, t4;
tspritetype* t;
DDukeActor* h;
int bg = 0;
for (j = 0; j < spritesortcnt; j++)
for (unsigned j = 0; j < tsprites.Size(); j++)
{
t = &tsprite[j];
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
switch (t->picnum)
@ -121,11 +121,9 @@ 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++)
for (unsigned j = 0; j < tsprites.Size(); j++)
{
validateTSpriteSize(tsprite, spritesortcnt);
t = &tsprite[j];
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
auto OwnerAc = h->GetOwner();
@ -370,8 +368,8 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && ps[p].GetActor()->spr.extra > 0 && ps[p].curr_weapon > 0)
{
auto newtspr = &tsprite[spritesortcnt++];
newtspr = t;
auto newtspr = tsprites.newTSprite();
*newtspr = *t;
newtspr->statnum = 99;
@ -725,7 +723,7 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
{
if (h->spr.picnum != EXPLOSION2 && h->spr.picnum != DOMELITE && h->spr.picnum != TORNADO && h->spr.picnum != EXPLOSION3 && (h->spr.picnum != SBMOVE || isRRRA()))
{
if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2) && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
if (r_shadows && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW))
{
int daz;
@ -738,7 +736,7 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
if ((h->spr.pos.Z - daz) < (8 << 8))
if (ps[screenpeek].pos.Z < daz)
{
auto shadowspr = &tsprite[spritesortcnt++];
auto shadowspr = tsprites.newTSprite();
*shadowspr = *t;
shadowspr->statnum = 99;

View file

@ -98,8 +98,8 @@ void displaymasks_d(int snum, int p, double smoothratio);
void displaymasks_r(int snum, int p, double smoothratio);
void think_d();
void think_r();
void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
Dispatcher fi;

View file

@ -59,7 +59,7 @@ struct GameInterface : public ::GameInterface
int chaseCamX(binangle ang) { return -ang.bcos(-4); }
int chaseCamY(binangle ang) { return -ang.bsin(-4); }
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 9; }
void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override;
@ -110,7 +110,7 @@ struct Dispatcher
void (*displayweapon)(int snum, double smoothratio);
void (*displaymasks)(int snum, int p, double smoothratio);
void (*animatesprites)(tspritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio);
void (*animatesprites)(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
};

View file

@ -406,9 +406,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
fi.animatesprites(tsprite, spritesortcnt, viewx, viewy, viewang.asbuild(), int(smoothRatio));
fi.animatesprites(tsprites, viewx, viewy, viewang.asbuild(), int(smoothRatio));
}

View file

@ -239,7 +239,7 @@ struct GameInterface : public ::GameInterface
int chaseCamX(binangle ang) { return -(ang.bcos() * 3) >> 5; }
int chaseCamY(binangle ang) { return -(ang.bsin() * 3) >> 5; }
int chaseCamZ(fixedhoriz horiz) { return (horiz.asq16() * 3) >> 10; }
void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
int GetCurrentSkill() override;
::GameStats getStats() override;

View file

@ -478,7 +478,7 @@ int seq_GetSeqPicnum(int16_t nSeq, int16_t edx, int16_t ebx)
int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal)
{
tspritetype* pTSprite = &mytsprite[nSprite];
tspritetype* pTSprite = mytspriteArray->get(nSprite);
int nAngle = GetMyAngle(nCamerax - pTSprite->pos.X, nCameray - pTSprite->pos.Y);
int nSeqOffset = ((((pTSprite->ang + 512) - nAngle) + 128) & kAngleMask) >> 8;
@ -526,7 +526,7 @@ int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal)
int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
{
tspritetype* pTSprite = &mytsprite[nSprite];
tspritetype* pTSprite = mytspriteArray->get(nSprite);
int nAngle = GetMyAngle(nCamerax - pTSprite->pos.X, nCameray - pTSprite->pos.Y);
int val;
@ -579,7 +579,7 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
break;
}
tspritetype* tsp = &mytsprite[(*myspritesortcnt)++];
tspritetype* tsp = mytspriteArray->newTSprite();
tsp->pos.X = pTSprite->pos.X;
tsp->pos.Y = pTSprite->pos.Y;
tsp->pos.Z = pTSprite->pos.Z;

View file

@ -59,20 +59,16 @@ int viewz;
// We cannot drag these through the entire event system... :(
tspritetype* mytsprite;
int* myspritesortcnt;
tspriteArray* mytspriteArray;
// NOTE - not to be confused with Ken's analyzesprites()
static void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int x, int y, int z, double const smoothratio)
static void analyzesprites(tspriteArray& tsprites, int x, int y, int z, double const smoothratio)
{
tspritetype *pTSprite;
mytspriteArray = &tsprites;
mytsprite = tsprite;
myspritesortcnt = &spritesortcnt;
for (int i = 0; i < spritesortcnt; i++) {
validateTSpriteSize(tsprite, spritesortcnt);
pTSprite = &tsprite[i];
for (unsigned i = 0; i < tsprites.Size(); i++)
{
auto pTSprite = tsprites.get(i);
if (pTSprite->ownerActor)
{
@ -94,12 +90,9 @@ static void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int x, int
int nAngle = (2048 - pPlayerActor->spr.ang) & kAngleMask;
int nTSprite;
// int var_20 = var_24;
for (nTSprite = spritesortcnt-1, pTSprite = &tsprite[nTSprite]; nTSprite >= 0; nTSprite--, pTSprite--)
for (int nTSprite = int(tsprites.Size()-1); nTSprite >= 0; nTSprite--)
{
auto pTSprite = tsprites.get(nTSprite);
auto pActor = static_cast<DExhumedActor*>(pTSprite->ownerActor);
if (pTSprite->sectp != nullptr)
@ -176,8 +169,7 @@ static void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int x, int
}
}
mytsprite = nullptr;
myspritesortcnt = nullptr;
mytspriteArray = nullptr;
}
@ -450,9 +442,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
analyzesprites(tsprite, spritesortcnt, viewx, viewy, viewz, smoothRatio);
analyzesprites(tsprites, viewx, viewy, viewz, smoothRatio);
}

View file

@ -40,8 +40,7 @@ extern bool bTouchFloor;
extern int nChunkTotal;
extern int gFov;
extern tspritetype* mytsprite;
extern int* myspritesortcnt;
extern tspriteArray* mytspriteArray;
END_PS_NS

View file

@ -88,13 +88,13 @@ void ShadeSprite(tspritetype* tsp)
#endif
int GetRotation(tspritetype* tsprite, int& spritesortcnt, int tSpriteNum, int viewx, int viewy)
int GetRotation(tspriteArray& tsprites, int tSpriteNum, int viewx, int viewy)
{
static const uint8_t RotTable8[] = {0, 7, 6, 5, 4, 3, 2, 1};
static const uint8_t RotTable5[] = {0, 1, 2, 3, 4, 3, 2, 1};
int rotation;
tspritetype* tsp = &tsprite[tSpriteNum];
tspritetype* tsp = tsprites.get(tSpriteNum);
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
int angle2;
@ -159,9 +159,9 @@ directions was not standardized.
*/
int SetActorRotation(tspritetype* tsprite, int& spritesortcnt, int tSpriteNum, int viewx, int viewy)
int SetActorRotation(tspriteArray& tsprites, int tSpriteNum, int viewx, int viewy)
{
tspritetype* tsp = &tsprite[tSpriteNum];
tspritetype* tsp = tsprites.get(tSpriteNum);
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
int StateOffset, Rotation;
@ -177,7 +177,7 @@ int SetActorRotation(tspritetype* tsprite, int& spritesortcnt, int tSpriteNum, i
StateOffset = int(State - StateStart);
// Get the rotation angle
Rotation = GetRotation(tsprite, spritesortcnt, tSpriteNum, viewx, viewy);
Rotation = GetRotation(tsprites, tSpriteNum, viewx, viewy);
ASSERT(Rotation < 5);
@ -248,9 +248,9 @@ int DoShadowFindGroundPoint(tspritetype* tspr)
return loz;
}
void DoShadows(tspritetype* tsprite, int& spritesortcnt, tspritetype* tsp, int viewz, int camang)
void DoShadows(tspriteArray& tsprites, tspritetype* tsp, int viewz, int camang)
{
tspritetype* tSpr = &tsprite[spritesortcnt];
tspritetype* tSpr = tsprites.newTSprite();
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
int ground_dist = 0;
int view_dist = 0;
@ -342,11 +342,9 @@ void DoShadows(tspritetype* tsprite, int& spritesortcnt, tspritetype* tsp, int v
// Check for voxel items and use a round generic pic if so
//DoVoxelShadow(New);
spritesortcnt++;
}
void DoMotionBlur(tspritetype* tsprite, int& spritesortcnt, tspritetype const * const tsp)
void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp)
{
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
int nx,ny,nz = 0,dx,dy,dz;
@ -404,7 +402,7 @@ void DoMotionBlur(tspritetype* tsprite, int& spritesortcnt, tspritetype const *
for (i = 0; i < ownerActor->user.motion_blur_num; i++)
{
tspritetype* tSpr = &tsprite[spritesortcnt];
tspritetype* tSpr = tsprites.newTSprite();
*tSpr = *tsp;
tSpr->cstat |= CSTAT_SPRITE_TRANSLUCENT|CSTAT_SPRITE_TRANS_FLIP;
@ -421,13 +419,11 @@ void DoMotionBlur(tspritetype* tsprite, int& spritesortcnt, tspritetype const *
xrepeat -= repeat_adj;
yrepeat -= repeat_adj;
spritesortcnt++;
}
}
void WarpCopySprite(tspritetype* tsprite, int& spritesortcnt)
void WarpCopySprite(tspriteArray& tsprites)
{
int spnum;
int xoff,yoff,zoff;
@ -457,7 +453,7 @@ void WarpCopySprite(tspritetype* tsprite, int& spritesortcnt)
if (itActor2->spr.picnum == ST1)
continue;
tspritetype* newTSpr = renderAddTsprite(tsprite, spritesortcnt, itActor2);
tspritetype* newTSpr = renderAddTsprite(tsprites, itActor2);
newTSpr->statnum = 0;
xoff = itActor->spr.pos.X - newTSpr->pos.X;
@ -479,7 +475,7 @@ void WarpCopySprite(tspritetype* tsprite, int& spritesortcnt)
if (itActor2->spr.picnum == ST1)
continue;
tspritetype* newTSpr = renderAddTsprite(tsprite, spritesortcnt, itActor2);
tspritetype* newTSpr = renderAddTsprite(tsprites, itActor2);
newTSpr->statnum = 0;
auto off = itActor1->spr.pos - newTSpr->pos;
@ -576,7 +572,7 @@ DSWActor* ConnectCopySprite(spritetypebase const* tsp)
}
void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang)
void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int camang)
{
int tSpriteNum;
int smr4, smr2;
@ -592,10 +588,9 @@ void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int vie
smr4 = int(smoothratio) + IntToFixed(MoveSkip4);
smr2 = int(smoothratio) + IntToFixed(MoveSkip2);
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
for (tSpriteNum = (int)tsprites.Size() - 1; tSpriteNum >= 0; tSpriteNum--)
{
validateTSpriteSize(tsprite, spritesortcnt);
tspritetype* tsp = &tsprite[tSpriteNum];
tspritetype* tsp = tsprites.get(tSpriteNum);
auto tActor = static_cast<DSWActor*>(tsp->ownerActor);
auto tsectp = tsp->sectp;
@ -651,7 +646,7 @@ void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int vie
if (r_shadows && (tActor->user.Flags & SPR_SHADOW))
{
DoShadows(tsprite, spritesortcnt, tsp, viewz, camang);
DoShadows(tsprites, tsp, viewz, camang);
}
//#define UK_VERSION 1
@ -682,11 +677,11 @@ void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int vie
// rotation
if (tActor->user.RotNum > 0)
SetActorRotation(tsprite, spritesortcnt, tSpriteNum, viewx, viewy);
SetActorRotation(tsprites, tSpriteNum, viewx, viewy);
if (tActor->user.motion_blur_num)
{
DoMotionBlur(tsprite, spritesortcnt, tsp);
DoMotionBlur(tsprites, tsp);
}
// set palette lookup correctly
@ -870,40 +865,40 @@ void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int vie
}
}
WarpCopySprite(tsprite, spritesortcnt);
WarpCopySprite(tsprites);
}
#if 1
tspritetype* get_tsprite(tspritetype* tsprite, int& spritesortcnt, DSWActor* actor)
tspritetype* get_tsprite(tspriteArray& tsprites, DSWActor* actor)
{
int tSpriteNum;
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
for (tSpriteNum = (int)tsprites.Size() - 1; tSpriteNum >= 0; tSpriteNum--)
{
if (tsprite[tSpriteNum].ownerActor == actor)
return &tsprite[tSpriteNum];
if (tsprites.get(tSpriteNum)->ownerActor == actor)
return tsprites.get(tSpriteNum);
}
return nullptr;
}
void post_analyzesprites(tspritetype* tsprite, int& spritesortcnt)
void post_analyzesprites(tspriteArray& tsprites)
{
int tSpriteNum;
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
for (tSpriteNum = (int)tsprites.Size() - 1; tSpriteNum >= 0; tSpriteNum--)
{
auto actor = static_cast<DSWActor*>(tsprite[tSpriteNum].ownerActor);
auto actor = static_cast<DSWActor*>(tsprites.get(tSpriteNum)->ownerActor);
if (!actor) continue; // JBF: verify this is safe
tspritetype* tsp = &tsprite[tSpriteNum];
tspritetype* tsp = tsprites.get(tSpriteNum);
if (actor->hasU())
{
if (actor->user.ID == FIREBALL_FLAMES && actor->user.attachActor != nullptr)
{
tspritetype* const atsp = get_tsprite(tsprite, spritesortcnt, actor->user.attachActor);
tspritetype* const atsp = get_tsprite(tsprites, actor->user.attachActor);
if (!atsp)
{
@ -1784,10 +1779,10 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int
return true;
}
void GameInterface::processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio)
{
analyzesprites(tsprite, spritesortcnt, viewx, viewy, viewz, viewang.asbuild());
post_analyzesprites(tsprite, spritesortcnt);
analyzesprites(tsprites, viewx, viewy, viewz, viewang.asbuild());
post_analyzesprites(tsprites);
}

View file

@ -1666,7 +1666,7 @@ void SetOwner(int a, int b); // we still need this...
void ClearOwner(DSWActor* ownr);
DSWActor* GetOwner(DSWActor* child);
void SetAttach(DSWActor*, DSWActor*);
void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang);
void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int camang);
void CollectPortals();
int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, int hit_y, int hit_z);
@ -1922,7 +1922,7 @@ struct GameInterface : public ::GameInterface
int chaseCamX(binangle ang) override { return -ang.bcos(-3); }
int chaseCamY(binangle ang) override { return -ang.bsin(-3); }
int chaseCamZ(fixedhoriz horiz) override { return horiz.asq16() >> 8; }
void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override;