- made camsprite an actor variable.

This commit is contained in:
Christoph Oelckers 2020-11-04 19:25:49 +01:00
parent 25c93e65fc
commit 083454986b
7 changed files with 17 additions and 20 deletions

View file

@ -1301,12 +1301,12 @@ static void moveviewscreen(DDukeActor* actor)
{ {
#if 0 #if 0
if (actor->s.yvel == 1) if (actor->s.yvel == 1)
camsprite = i; camsprite = actor;
#endif #endif
} }
else if (camsprite != -1 && actor->temp_data[0] == 1) else if (camsprite != nullptr && actor->temp_data[0] == 1)
{ {
camsprite = -1; camsprite = nullptr;
actor->s.yvel = 0; actor->s.yvel = 0;
actor->temp_data[0] = 0; actor->temp_data[0] = 0;
} }

View file

@ -259,14 +259,14 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
continue; continue;
case VIEWSCREEN: case VIEWSCREEN:
case VIEWSCREEN2: case VIEWSCREEN2:
if (camsprite >= 0 && h->GetOwner()->temp_data[0] == 1) if (camsprite != nullptr && h->GetOwner()->temp_data[0] == 1)
{ {
t->picnum = STATIC; t->picnum = STATIC;
t->cstat |= (rand() & 12); t->cstat |= (rand() & 12);
t->xrepeat += 8; t->xrepeat += 8;
t->yrepeat += 8; t->yrepeat += 8;
} }
else if (camsprite >= 0) else if (camsprite != nullptr)
{ {
t->picnum = TILE_VIEWSCR; t->picnum = TILE_VIEWSCR;
} }

View file

@ -84,7 +84,7 @@ animwalltype animwall[MAXANIMWALLS];
int numanimwalls; int numanimwalls;
int animatecnt; int animatecnt;
int numclouds; int numclouds;
int camsprite; DDukeActor* camsprite;
int numcyclers; int numcyclers;
int earthquaketime; int earthquaketime;
int freezerhurtowner; int freezerhurtowner;

View file

@ -70,7 +70,7 @@ extern animwalltype animwall[MAXANIMWALLS];
extern int numanimwalls; extern int numanimwalls;
extern int animatecnt; extern int animatecnt;
extern int numclouds; extern int numclouds;
extern int camsprite; extern DDukeActor* camsprite;
extern int numcyclers; extern int numcyclers;
extern int earthquaketime; extern int earthquaketime;
extern int freezerhurtowner; extern int freezerhurtowner;

View file

@ -418,7 +418,7 @@ void resetprestat(int snum,int g)
paused = 0; paused = 0;
ud.cameraactor =nullptr; ud.cameraactor =nullptr;
tempwallptr = 0; tempwallptr = 0;
camsprite =-1; camsprite =nullptr;
earthquaketime = 0; earthquaketime = 0;
WindTime = 0; WindTime = 0;
@ -742,8 +742,8 @@ void resettimevars(void)
{ {
cloudclock = 0; cloudclock = 0;
ud.levelclock = 0; ud.levelclock = 0;
if (camsprite >= 0) if (camsprite != nullptr)
hittype[camsprite].temp_data[0] = 0; camsprite->temp_data[0] = 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -273,18 +273,15 @@ void animatecamsprite(double smoothratio)
{ {
const int VIEWSCREEN_ACTIVE_DISTANCE = 8192; const int VIEWSCREEN_ACTIVE_DISTANCE = 8192;
if (camsprite < 0) if (camsprite == nullptr)
return; return;
int spriteNum = camsprite;
auto p = &ps[screenpeek]; auto p = &ps[screenpeek];
auto act = &hittype[spriteNum]; auto sp = &camsprite->s;
auto sp = &act->s;
if (p->newOwner != nullptr) act->SetOwner(p->newOwner); if (p->newOwner != nullptr) camsprite->SetOwner(p->newOwner);
if (act->GetOwner() && dist(p->GetActor(), act) < VIEWSCREEN_ACTIVE_DISTANCE) if (camsprite->GetOwner() && dist(p->GetActor(), camsprite) < VIEWSCREEN_ACTIVE_DISTANCE)
{ {
auto tex = tileGetTexture(sp->picnum); auto tex = tileGetTexture(sp->picnum);
TileFiles.MakeCanvas(TILE_VIEWSCR, tex->GetDisplayWidth(), tex->GetDisplayHeight()); TileFiles.MakeCanvas(TILE_VIEWSCR, tex->GetDisplayWidth(), tex->GetDisplayHeight());
@ -294,8 +291,8 @@ void animatecamsprite(double smoothratio)
screen->RenderTextureView(canvas, [=](IntRect& rect) screen->RenderTextureView(canvas, [=](IntRect& rect)
{ {
auto camera = &act->GetOwner()->s; auto camera = &camsprite->GetOwner()->s;
auto ang = getcamspriteang(act->GetOwner(), smoothratio); auto ang = getcamspriteang(camsprite->GetOwner(), smoothratio);
// Note: no ROR or camera here for now - the current setup has no means to detect these things before rendering the scene itself. // Note: no ROR or camera here for now - the current setup has no means to detect these things before rendering the scene itself.
drawrooms(camera->x, camera->y, camera->z, ang, 100 + camera->shade, camera->sectnum); // why 'shade'...? drawrooms(camera->x, camera->y, camera->z, ang, 100 + camera->shade, camera->sectnum); // why 'shade'...?
display_mirror = 1; // should really be 'display external view'. display_mirror = 1; // should really be 'display external view'.

View file

@ -1710,7 +1710,7 @@ void checksectors_d(int snum)
neartagsprite->SetOwner(acti); neartagsprite->SetOwner(acti);
neartagsprite->s.yvel = 1; neartagsprite->s.yvel = 1;
camsprite = neartagsprite->GetIndex(); camsprite = neartagsprite;
j = p->cursectnum; j = p->cursectnum;