mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- rest of draw.cpp.
This file is very messy...
This commit is contained in:
parent
919a08448e
commit
e192f4d40f
2 changed files with 61 additions and 66 deletions
|
@ -71,7 +71,7 @@ extern short f_c;
|
||||||
|
|
||||||
extern ParentalStruct aVoxelArray[MAXTILES];
|
extern ParentalStruct aVoxelArray[MAXTILES];
|
||||||
|
|
||||||
int ConnectCopySprite(spritetype const * tsp);
|
DSWActor* ConnectCopySprite(spritetype const * tsp);
|
||||||
void PreDrawStackedWater(void);
|
void PreDrawStackedWater(void);
|
||||||
|
|
||||||
void SW_InitMultiPsky(void)
|
void SW_InitMultiPsky(void)
|
||||||
|
@ -1236,13 +1236,12 @@ PostDraw(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CopySprite(spritetype const * tsp, short newsector)
|
DSWActor* CopySprite(spritetype const * tsp, short newsector)
|
||||||
{
|
{
|
||||||
short New;
|
|
||||||
SPRITEp sp;
|
SPRITEp sp;
|
||||||
|
|
||||||
New = COVERinsertsprite(newsector, STAT_FAF_COPY);
|
auto actorNew = InsertActor(newsector, STAT_FAF_COPY);
|
||||||
sp = &sprite[New];
|
sp = &actorNew->s();
|
||||||
|
|
||||||
sp->x = tsp->x;
|
sp->x = tsp->x;
|
||||||
sp->y = tsp->y;
|
sp->y = tsp->y;
|
||||||
|
@ -1262,10 +1261,10 @@ int CopySprite(spritetype const * tsp, short newsector)
|
||||||
|
|
||||||
RESET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||||
|
|
||||||
return New;
|
return actorNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConnectCopySprite(spritetype const * tsp)
|
DSWActor* ConnectCopySprite(spritetype const * tsp)
|
||||||
{
|
{
|
||||||
int newsector;
|
int newsector;
|
||||||
int testz;
|
int testz;
|
||||||
|
@ -1298,45 +1297,37 @@ int ConnectCopySprite(spritetype const * tsp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreDrawStackedWater(void)
|
void PreDrawStackedWater(void)
|
||||||
{
|
{
|
||||||
int i, si;
|
SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
||||||
SPRITEp sp;
|
while (auto itActor = it.Next())
|
||||||
USERp u,nu;
|
|
||||||
short New;
|
|
||||||
|
|
||||||
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
|
||||||
while ((si = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
SectIterator it(sprite[si].sectnum);
|
SWSectIterator it2(itActor->s().sectnum);
|
||||||
while ((i = it.NextIndex()) >= 0)
|
while (auto itActor2 = it2.Next())
|
||||||
{
|
{
|
||||||
if (User[i].Data())
|
if (itActor2->hasU())
|
||||||
{
|
{
|
||||||
if (sprite[i].statnum == STAT_ITEM)
|
auto sp = &itActor2->s();
|
||||||
|
auto u = itActor2->u();
|
||||||
|
if (sp->statnum == STAT_ITEM)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sprite[i].statnum <= STAT_DEFAULT || sprite[i].statnum > STAT_PLAYER0 + MAX_SW_PLAYERS)
|
if (sp->statnum <= STAT_DEFAULT || sp->statnum > STAT_PLAYER0 + MAX_SW_PLAYERS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// code so that a copied sprite will not make another copy
|
// code so that a copied sprite will not make another copy
|
||||||
if (User[i]->xchange == -989898)
|
if (u->xchange == -989898)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sp = &sprite[i];
|
auto actorNew = ConnectCopySprite((spritetype const *)sp);
|
||||||
u = User[i].Data();
|
if (actorNew != nullptr)
|
||||||
|
|
||||||
New = ConnectCopySprite((spritetype const *)sp);
|
|
||||||
if (New >= 0)
|
|
||||||
{
|
{
|
||||||
// spawn a user
|
// spawn a user
|
||||||
User[New].Alloc();
|
auto nu = actorNew->allocUser();
|
||||||
nu = User[New].Data();
|
|
||||||
ASSERT(nu != nullptr);
|
|
||||||
|
|
||||||
nu->xchange = -989898;
|
nu->xchange = -989898;
|
||||||
|
|
||||||
|
@ -1351,10 +1342,6 @@ void PreDrawStackedWater(void)
|
||||||
nu->RotNum = u->RotNum;
|
nu->RotNum = u->RotNum;
|
||||||
nu->ID = u->ID;
|
nu->ID = u->ID;
|
||||||
|
|
||||||
// set these to other sprite for players draw
|
|
||||||
nu->SpriteNum = i;
|
|
||||||
nu->SpriteP = sp;
|
|
||||||
|
|
||||||
nu->PlayerP = u->PlayerP;
|
nu->PlayerP = u->PlayerP;
|
||||||
nu->spal = u->spal;
|
nu->spal = u->spal;
|
||||||
}
|
}
|
||||||
|
@ -1399,11 +1386,10 @@ void UpdateWallPortalState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
||||||
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
while (auto actor = it.Next())
|
||||||
while ((i = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
auto sp = &sprite[i];
|
auto sp = &actor->s();
|
||||||
if (SP_TAG3(sp) == 0)
|
if (SP_TAG3(sp) == 0)
|
||||||
{
|
{
|
||||||
// back up ceilingpicnum and ceilingstat
|
// back up ceilingpicnum and ceilingstat
|
||||||
|
@ -1429,11 +1415,10 @@ void UpdateWallPortalState()
|
||||||
|
|
||||||
void RestorePortalState()
|
void RestorePortalState()
|
||||||
{
|
{
|
||||||
int i;
|
SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
||||||
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
while (auto actor = it.Next())
|
||||||
while ((i = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
auto sp = &sprite[i];
|
auto sp = &actor->s();
|
||||||
if (SP_TAG3(sp) == 0)
|
if (SP_TAG3(sp) == 0)
|
||||||
{
|
{
|
||||||
// restore ceilingpicnum and ceilingstat
|
// restore ceilingpicnum and ceilingstat
|
||||||
|
@ -1564,10 +1549,10 @@ drawscreen(PLAYERp pp, double smoothratio)
|
||||||
{
|
{
|
||||||
tz -= 8448;
|
tz -= 8448;
|
||||||
|
|
||||||
if (!calcChaseCamPos(&tx, &ty, &tz, &sprite[pp->PlayerSprite], &tsectnum, tang, thoriz, smoothratio))
|
if (!calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsectnum, tang, thoriz, smoothratio))
|
||||||
{
|
{
|
||||||
tz += 8448;
|
tz += 8448;
|
||||||
calcChaseCamPos(&tx, &ty, &tz, &sprite[pp->PlayerSprite], &tsectnum, tang, thoriz, smoothratio);
|
calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsectnum, tang, thoriz, smoothratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1626,32 +1611,35 @@ drawscreen(PLAYERp pp, double smoothratio)
|
||||||
|
|
||||||
if ((automapMode != am_off) && pp == Player+myconnectindex)
|
if ((automapMode != am_off) && pp == Player+myconnectindex)
|
||||||
{
|
{
|
||||||
for (j = 0; j < MAXSPRITES; j++)
|
SWSpriteIterator it;
|
||||||
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
|
auto sp = &actor->s();
|
||||||
// Don't show sprites tagged with 257
|
// Don't show sprites tagged with 257
|
||||||
if (sprite[j].lotag == 257)
|
if (sp->lotag == 257)
|
||||||
{
|
{
|
||||||
if (TEST(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
if (TEST(sp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
||||||
{
|
{
|
||||||
RESET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
RESET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
||||||
sprite[j].owner = -2;
|
sp->owner = -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawOverheadMap(tx, ty, tang.asbuild(), smoothratio);
|
DrawOverheadMap(tx, ty, tang.asbuild(), smoothratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < MAXSPRITES; j++)
|
SWSpriteIterator it;
|
||||||
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
|
auto sp = &actor->s();
|
||||||
// Don't show sprites tagged with 257
|
// Don't show sprites tagged with 257
|
||||||
if (sprite[j].lotag == 257 && sprite[j].owner == -2)
|
if (sp->lotag == 257 && sp->owner == -2)
|
||||||
SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
{
|
||||||
|
SET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
||||||
|
sp->owner = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//PrintLocationInfo(pp);
|
|
||||||
//PrintSpriteInfo(pp);
|
|
||||||
|
|
||||||
#if SYNC_TEST
|
#if SYNC_TEST
|
||||||
SyncStatMessage();
|
SyncStatMessage();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1704,7 +1692,7 @@ bool GameInterface::GenerateSavePic()
|
||||||
|
|
||||||
bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio)
|
bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio)
|
||||||
{
|
{
|
||||||
int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
|
int i, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
|
||||||
int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
|
int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
|
||||||
int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
|
int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
|
||||||
int xvect, yvect;
|
int xvect, yvect;
|
||||||
|
@ -1720,32 +1708,32 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
|
||||||
|
|
||||||
|
|
||||||
// Draw sprites
|
// Draw sprites
|
||||||
k = Player[screenpeek].PlayerSprite;
|
auto peekActor = Player[screenpeek].Actor();
|
||||||
for (i = 0; i < numsectors; i++)
|
for (i = 0; i < numsectors; i++)
|
||||||
{
|
{
|
||||||
SectIterator it(i);
|
SWSectIterator it(i);
|
||||||
while ((j = it.NextIndex()) >= 0)
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
|
spr = &actor->s();
|
||||||
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
||||||
{
|
{
|
||||||
if (Player[p].PlayerSprite == j)
|
if (Player[p].Actor() == actor)
|
||||||
{
|
{
|
||||||
if (sprite[Player[p].PlayerSprite].xvel > 16)
|
if (spr->xvel > 16)
|
||||||
pspr_ndx[myconnectindex] = ((PlayClock >> 4) & 3);
|
pspr_ndx[myconnectindex] = ((PlayClock >> 4) & 3);
|
||||||
sprisplayer = true;
|
sprisplayer = true;
|
||||||
|
|
||||||
goto SHOWSPRITE;
|
goto SHOWSPRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gFullMap || (sprite[j].cstat2 & CSTAT2_SPRITE_MAPPED))
|
if (gFullMap || (spr->cstat2 & CSTAT2_SPRITE_MAPPED))
|
||||||
{
|
{
|
||||||
SHOWSPRITE:
|
SHOWSPRITE:
|
||||||
spr = &sprite[j];
|
|
||||||
|
|
||||||
PalEntry col = GPalette.BaseColors[56]; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple
|
PalEntry col = GPalette.BaseColors[56]; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple
|
||||||
if ((spr->cstat & 1) > 0)
|
if ((spr->cstat & 1) > 0)
|
||||||
col = GPalette.BaseColors[248];
|
col = GPalette.BaseColors[248];
|
||||||
if (j == k)
|
if (actor == peekActor)
|
||||||
col = GPalette.BaseColors[31];
|
col = GPalette.BaseColors[31];
|
||||||
|
|
||||||
sprx = spr->x;
|
sprx = spr->x;
|
||||||
|
@ -1761,7 +1749,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
|
||||||
switch (spr->cstat & 48)
|
switch (spr->cstat & 48)
|
||||||
{
|
{
|
||||||
case 0: // Regular sprite
|
case 0: // Regular sprite
|
||||||
if (Player[p].PlayerSprite == j)
|
if (Player[p].Actor() == actor)
|
||||||
{
|
{
|
||||||
x1 = sprx - cposx;
|
x1 = sprx - cposx;
|
||||||
y1 = spry - cposy;
|
y1 = spry - cposy;
|
||||||
|
@ -1776,7 +1764,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
|
||||||
int spnum = -1;
|
int spnum = -1;
|
||||||
if (sprisplayer)
|
if (sprisplayer)
|
||||||
{
|
{
|
||||||
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite)
|
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || actor == Player[screenpeek].Actor())
|
||||||
spnum = 1196 + pspr_ndx[myconnectindex];
|
spnum = 1196 + pspr_ndx[myconnectindex];
|
||||||
}
|
}
|
||||||
else spnum = spr->picnum;
|
else spnum = spr->picnum;
|
||||||
|
|
|
@ -29,6 +29,13 @@ public:
|
||||||
*/
|
*/
|
||||||
spritetype& s() { return sprite[index]; }
|
spritetype& s() { return sprite[index]; }
|
||||||
USER* u() { return User[index].Data(); }
|
USER* u() { return User[index].Data(); }
|
||||||
|
USER* allocUser()
|
||||||
|
{
|
||||||
|
User[index].Alloc();
|
||||||
|
User[index]->SpriteNum = GetSpriteIndex();
|
||||||
|
User[index]->SpriteP = &sprite[index];
|
||||||
|
return User[index].Data();
|
||||||
|
}
|
||||||
|
|
||||||
int GetSpriteIndex() const
|
int GetSpriteIndex() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue