From 50787505699e7eac2bc88239c3cd506923bc1a1f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Nov 2021 18:40:03 +0100 Subject: [PATCH] - sprite indices in mirrors converted to actor pointers --- source/games/sw/src/_polymost.cpp | 6 +++--- source/games/sw/src/draw.cpp | 4 ++-- source/games/sw/src/jsector.cpp | 30 ++++++++++-------------------- source/games/sw/src/jsector.h | 8 ++++---- source/games/sw/src/osdcmds.cpp | 4 ++-- source/games/sw/src/save.cpp | 4 ++-- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index 235847702..03b6b7f92 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -231,7 +231,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed { SPRITEp tp; - tp = &sprite[mirror[cnt].camsprite]; + tp = &mirror[cnt].camspriteActor->s(); j = abs(tp->x - tx); 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; - 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 w = mirror[cnt].mirrorwall; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 029dadfec..76f21d2af 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1380,11 +1380,11 @@ void UpdateWallPortalState() } else { - auto sp = &sprite[mirror[i].camera]; + auto sp = &mirror[i].cameraActor->s(); if (!TEST_BOOL1(sp)) { wal->portalflags = PORTAL_WALL_TO_SPRITE; - wal->portalnum = mirror[i].camera; + wal->portalnum = mirror[i].cameraActor->GetSpriteIndex(); } } } diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 1d186d301..1b344f11f 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -294,8 +294,8 @@ void JS_InitMirrors(void) { tileDelete(i + MIRRORLABEL); mirror[i].campic = -1; - mirror[i].camsprite = -1; - mirror[i].camera = -1; + mirror[i].camspriteActor = nullptr; + mirror[i].cameraActor = nullptr; mirror[i].ismagic = false; } @@ -336,7 +336,7 @@ void JS_InitMirrors(void) // if correct type and matches if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag) { - mirror[mirrorcnt].camera = itActor->GetSpriteIndex(); + mirror[mirrorcnt].cameraActor = itActor; // Set up camera variables SP_TAG5(sp) = sp->ang; // Set current angle to // sprite angle @@ -352,7 +352,7 @@ void JS_InitMirrors(void) // if correct type and matches if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag) { - mirror[mirrorcnt].camera = itActor->GetSpriteIndex(); + mirror[mirrorcnt].cameraActor = itActor; // Set up camera variables SP_TAG5(sp) = sp->ang; // Set current angle to // sprite angle @@ -370,7 +370,7 @@ void JS_InitMirrors(void) mirror[mirrorcnt].ismagic = true; Found_Cam = false; - if (TEST_BOOL1(&sprite[mirror[mirrorcnt].camera])) + if (TEST_BOOL1(&mirror[mirrorcnt].cameraActor->s())) { SWStatIterator it(STAT_DEFAULT); while (auto itActor = it.Next()) @@ -380,7 +380,7 @@ void JS_InitMirrors(void) sp->hitag == wall[i].hitag) { 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 tileDelete(mirror[mirrorcnt].campic); @@ -394,7 +394,7 @@ void JS_InitMirrors(void) Printf("Did not find drawtotile for camera number %d\n", mirrorcnt); Printf("wall[%d].hitag == %d\n", i, wall[i].hitag); 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 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++; } else @@ -568,7 +558,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio) { SPRITEp tp; - tp = &sprite[mirror[cnt].camsprite]; + tp = &mirror[cnt].camspriteActor->s(); j = abs(tp->x - tx); 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; - ASSERT(mirror[cnt].camera != -1); + ASSERT(mirror[cnt].cameraActor != nullptr); - sp = &sprite[mirror[cnt].camera]; + sp = &mirror[cnt].cameraActor->s(); ASSERT(sp); diff --git a/source/games/sw/src/jsector.h b/source/games/sw/src/jsector.h index ed2eef270..2d4bb2563 100644 --- a/source/games/sw/src/jsector.h +++ b/source/games/sw/src/jsector.h @@ -40,10 +40,10 @@ typedef enum typedef struct { - short mirrorwall; // Wall number containing the mirror tile - short mirrorsector; // nextsector used internally to draw mirror rooms - short camera; // Contains number of ST1 sprite used as a camera - short camsprite; // sprite pointing to campic + DSWActor* cameraActor; // Contains number of ST1 sprite used as a camera + DSWActor* camspriteActor; // sprite pointing to campic + int mirrorwall; // Wall number containing the mirror tile + int mirrorsector; // nextsector used internally to draw mirror rooms short campic; // Editart tile number to draw a screen to 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. diff --git a/source/games/sw/src/osdcmds.cpp b/source/games/sw/src/osdcmds.cpp index 0dbdc4617..d9a54d563 100644 --- a/source/games/sw/src/osdcmds.cpp +++ b/source/games/sw/src/osdcmds.cpp @@ -89,8 +89,8 @@ static int osdcmd_mirror(CCmdFuncPtr parm) Printf(" "); Printf("mirror[%d].mirrorwall = %d", op1, mirror[op1].mirrorwall); Printf("mirror[%d].mirrorsector = %d", op1, mirror[op1].mirrorsector); - Printf("mirror[%d].camera = %d", op1, mirror[op1].camera); - Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camsprite); + Printf("mirror[%d].camera = %d", op1, mirror[op1].cameraActor->GetIndex()); + Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camspriteActor->GetIndex()); Printf("mirror[%d].campic = %d", op1, mirror[op1].campic); Printf("mirror[%d].iscamera = %d", op1, mirror[op1].ismagic); return CCMD_OK; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index f7a4937fd..fb14ef9c7 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -1073,8 +1073,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRRORTYPE& w, MIR { arc("mirrorwall", w.mirrorwall, def->mirrorwall) ("mirrorsector", w.mirrorsector, def->mirrorsector) - ("camera", w.camera, def->camera) - ("camsprite", w.camsprite, def->camsprite) + ("camera", w.cameraActor, def->cameraActor) + ("camsprite", w.camspriteActor, def->camspriteActor) ("campic", w.campic, def->campic) ("numspawnspots", w.numspawnspots, def->numspawnspots) .Array("spawnspots", w.spawnspots, def->spawnspots, w.numspawnspots)