- sprite indices in mirrors converted to actor pointers

This commit is contained in:
Christoph Oelckers 2021-11-02 18:40:03 +01:00
parent 1152ec0b54
commit 5078750569
6 changed files with 23 additions and 33 deletions

View file

@ -231,7 +231,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
{ {
SPRITEp tp; SPRITEp tp;
tp = &sprite[mirror[cnt].camsprite]; tp = &mirror[cnt].camspriteActor->s();
j = abs(tp->x - tx); j = abs(tp->x - tx);
j += abs(tp->y - ty); j += abs(tp->y - ty);
@ -247,9 +247,9 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
int dx, dy, dz, tdx, tdy, tdz, midx, midy; int dx, dy, dz, tdx, tdy, tdz, midx, midy;
ASSERT(mirror[cnt].camera != -1); ASSERT(mirror[cnt].cameraActor != nullptr);
sp = &sprite[mirror[cnt].camera]; sp = &mirror[cnt].cameraActor->s();
// Calculate the angle of the mirror wall // Calculate the angle of the mirror wall
w = mirror[cnt].mirrorwall; w = mirror[cnt].mirrorwall;

View file

@ -1380,11 +1380,11 @@ void UpdateWallPortalState()
} }
else else
{ {
auto sp = &sprite[mirror[i].camera]; auto sp = &mirror[i].cameraActor->s();
if (!TEST_BOOL1(sp)) if (!TEST_BOOL1(sp))
{ {
wal->portalflags = PORTAL_WALL_TO_SPRITE; wal->portalflags = PORTAL_WALL_TO_SPRITE;
wal->portalnum = mirror[i].camera; wal->portalnum = mirror[i].cameraActor->GetSpriteIndex();
} }
} }
} }

View file

@ -294,8 +294,8 @@ void JS_InitMirrors(void)
{ {
tileDelete(i + MIRRORLABEL); tileDelete(i + MIRRORLABEL);
mirror[i].campic = -1; mirror[i].campic = -1;
mirror[i].camsprite = -1; mirror[i].camspriteActor = nullptr;
mirror[i].camera = -1; mirror[i].cameraActor = nullptr;
mirror[i].ismagic = false; mirror[i].ismagic = false;
} }
@ -336,7 +336,7 @@ void JS_InitMirrors(void)
// if correct type and matches // if correct type and matches
if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag) if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag)
{ {
mirror[mirrorcnt].camera = itActor->GetSpriteIndex(); mirror[mirrorcnt].cameraActor = itActor;
// Set up camera variables // Set up camera variables
SP_TAG5(sp) = sp->ang; // Set current angle to SP_TAG5(sp) = sp->ang; // Set current angle to
// sprite angle // sprite angle
@ -352,7 +352,7 @@ void JS_InitMirrors(void)
// if correct type and matches // if correct type and matches
if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag) if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag)
{ {
mirror[mirrorcnt].camera = itActor->GetSpriteIndex(); mirror[mirrorcnt].cameraActor = itActor;
// Set up camera variables // Set up camera variables
SP_TAG5(sp) = sp->ang; // Set current angle to SP_TAG5(sp) = sp->ang; // Set current angle to
// sprite angle // sprite angle
@ -370,7 +370,7 @@ void JS_InitMirrors(void)
mirror[mirrorcnt].ismagic = true; mirror[mirrorcnt].ismagic = true;
Found_Cam = false; Found_Cam = false;
if (TEST_BOOL1(&sprite[mirror[mirrorcnt].camera])) if (TEST_BOOL1(&mirror[mirrorcnt].cameraActor->s()))
{ {
SWStatIterator it(STAT_DEFAULT); SWStatIterator it(STAT_DEFAULT);
while (auto itActor = it.Next()) while (auto itActor = it.Next())
@ -380,7 +380,7 @@ void JS_InitMirrors(void)
sp->hitag == wall[i].hitag) sp->hitag == wall[i].hitag)
{ {
mirror[mirrorcnt].campic = sp->picnum; mirror[mirrorcnt].campic = sp->picnum;
mirror[mirrorcnt].camsprite = itActor->GetSpriteIndex(); mirror[mirrorcnt].camspriteActor = itActor;
// JBF: commenting out this line results in the screen in $BULLET being visible // JBF: commenting out this line results in the screen in $BULLET being visible
tileDelete(mirror[mirrorcnt].campic); tileDelete(mirror[mirrorcnt].campic);
@ -394,7 +394,7 @@ void JS_InitMirrors(void)
Printf("Did not find drawtotile for camera number %d\n", mirrorcnt); Printf("Did not find drawtotile for camera number %d\n", mirrorcnt);
Printf("wall[%d].hitag == %d\n", i, wall[i].hitag); Printf("wall[%d].hitag == %d\n", i, wall[i].hitag);
Printf("Map Coordinates: x = %d, y = %d\n", wall[i].x, wall[i].y); Printf("Map Coordinates: x = %d, y = %d\n", wall[i].x, wall[i].y);
RESET_BOOL1(&sprite[mirror[mirrorcnt].camera]); RESET_BOOL1(&mirror[mirrorcnt].cameraActor->s());
} }
} }
@ -412,16 +412,6 @@ void JS_InitMirrors(void)
// Set tics used to none // Set tics used to none
mirror[mirrorcnt].tics = 0; mirror[mirrorcnt].tics = 0;
if (mirror[mirrorcnt].ismagic)
{
//DSPRINTF(ds, "mirror.mirrorwall %d", mirror[mirrorcnt].mirrorwall);
MONO_PRINT(ds);
//DSPRINTF(ds, "mirror.mirrorsector %d", mirror[mirrorcnt].mirrorsector);
MONO_PRINT(ds);
//DSPRINTF(ds, "mirror.camera %d", mirror[mirrorcnt].camera);
MONO_PRINT(ds);
}
mirrorcnt++; mirrorcnt++;
} }
else else
@ -568,7 +558,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
{ {
SPRITEp tp; SPRITEp tp;
tp = &sprite[mirror[cnt].camsprite]; tp = &mirror[cnt].camspriteActor->s();
j = abs(tp->x - tx); j = abs(tp->x - tx);
j += abs(tp->y - ty); j += abs(tp->y - ty);
@ -582,9 +572,9 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
int dx, dy, dz, tdx, tdy, tdz, midx, midy; int dx, dy, dz, tdx, tdy, tdz, midx, midy;
ASSERT(mirror[cnt].camera != -1); ASSERT(mirror[cnt].cameraActor != nullptr);
sp = &sprite[mirror[cnt].camera]; sp = &mirror[cnt].cameraActor->s();
ASSERT(sp); ASSERT(sp);

View file

@ -40,10 +40,10 @@ typedef enum
typedef struct typedef struct
{ {
short mirrorwall; // Wall number containing the mirror tile DSWActor* cameraActor; // Contains number of ST1 sprite used as a camera
short mirrorsector; // nextsector used internally to draw mirror rooms DSWActor* camspriteActor; // sprite pointing to campic
short camera; // Contains number of ST1 sprite used as a camera int mirrorwall; // Wall number containing the mirror tile
short camsprite; // sprite pointing to campic int mirrorsector; // nextsector used internally to draw mirror rooms
short campic; // Editart tile number to draw a screen to short campic; // Editart tile number to draw a screen to
short numspawnspots; // Number of spawnspots used short numspawnspots; // Number of spawnspots used
short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill level for a max of up to 4 coolie ghosts to spawn. short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill level for a max of up to 4 coolie ghosts to spawn.

View file

@ -89,8 +89,8 @@ static int osdcmd_mirror(CCmdFuncPtr parm)
Printf(" "); Printf(" ");
Printf("mirror[%d].mirrorwall = %d", op1, mirror[op1].mirrorwall); Printf("mirror[%d].mirrorwall = %d", op1, mirror[op1].mirrorwall);
Printf("mirror[%d].mirrorsector = %d", op1, mirror[op1].mirrorsector); Printf("mirror[%d].mirrorsector = %d", op1, mirror[op1].mirrorsector);
Printf("mirror[%d].camera = %d", op1, mirror[op1].camera); Printf("mirror[%d].camera = %d", op1, mirror[op1].cameraActor->GetIndex());
Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camsprite); Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camspriteActor->GetIndex());
Printf("mirror[%d].campic = %d", op1, mirror[op1].campic); Printf("mirror[%d].campic = %d", op1, mirror[op1].campic);
Printf("mirror[%d].iscamera = %d", op1, mirror[op1].ismagic); Printf("mirror[%d].iscamera = %d", op1, mirror[op1].ismagic);
return CCMD_OK; return CCMD_OK;

View file

@ -1073,8 +1073,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRRORTYPE& w, MIR
{ {
arc("mirrorwall", w.mirrorwall, def->mirrorwall) arc("mirrorwall", w.mirrorwall, def->mirrorwall)
("mirrorsector", w.mirrorsector, def->mirrorsector) ("mirrorsector", w.mirrorsector, def->mirrorsector)
("camera", w.camera, def->camera) ("camera", w.cameraActor, def->cameraActor)
("camsprite", w.camsprite, def->camsprite) ("camsprite", w.camspriteActor, def->camspriteActor)
("campic", w.campic, def->campic) ("campic", w.campic, def->campic)
("numspawnspots", w.numspawnspots, def->numspawnspots) ("numspawnspots", w.numspawnspots, def->numspawnspots)
.Array("spawnspots", w.spawnspots, def->spawnspots, w.numspawnspots) .Array("spawnspots", w.spawnspots, def->spawnspots, w.numspawnspots)