- pointers in mirror struct.

This commit is contained in:
Christoph Oelckers 2021-11-24 18:18:23 +01:00
parent 4d8434ffd2
commit 3ccf3ab52d
6 changed files with 45 additions and 55 deletions

View file

@ -213,8 +213,8 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
if (bIsWallMirror)
{
j = abs(wall[mirror[cnt].mirrorwall].x - tx);
j += abs(wall[mirror[cnt].mirrorwall].y - ty);
j = abs(mirror[cnt].mirrorWall->x - tx);
j += abs(mirror[cnt].mirrorWall->y - ty);
if (j < dist)
dist = j;
}
@ -243,11 +243,11 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
sp = &mirror[cnt].cameraActor->s();
// Calculate the angle of the mirror wall
w = mirror[cnt].mirrorwall;
auto wal = mirror[cnt].mirrorWall;
// Get wall midpoint for offset in mirror view
midx = (wall[w].x + wall[w].point2Wall()->x) / 2;
midy = (wall[w].y + wall[w].point2Wall()->y) / 2;
midx = (wal->x + wal->point2Wall()->x) / 2;
midy = (wal->y + wal->point2Wall()->y) / 2;
// Finish finding offsets
tdx = abs(midx - tx);
@ -302,9 +302,9 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
// completemirror after drawrooms
display_mirror = true;
renderPrepareMirror(tx, ty, tz, tpq16ang, tpq16horiz,
mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang);
wallnum(mirror[cnt].mirrorWall), /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang);
renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, mirror[cnt].mirrorsector, true);
renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, sectnum(mirror[cnt].mirrorSector), true);
analyzesprites(pm_tsprite, pm_spritesortcnt, tposx, tposy, tz, tang >> 16);
renderDrawMasks();
@ -313,14 +313,9 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
display_mirror = false;
}
// g_visibility = tvisibility;
// g_visibility = NormalVisibility;
// renderDrawRoomsQ16(tx, ty, tz, tpq16ang, tpq16horiz, pp->cursectnum);
// Clean up anything that the camera view might have done
tileDelete(MIRROR);
wall[mirror[cnt].mirrorwall].overpicnum = MIRRORLABEL + cnt;
mirror[cnt].mirrorWall->overpicnum = MIRRORLABEL + cnt;
}
else
mirrorinview = false;

View file

@ -1349,10 +1349,10 @@ void UpdateWallPortalState()
// This is too obtuse to be maintained statically, but with 8 mirrors at most easy to be kept up to date.
for (int i = 0; i < mirrorcnt; i++)
{
if (mirror[i].mirrorwall < 0) {
if (mirror[i].mirrorWall == nullptr) {
continue;
}
walltype* wal = &wall[mirror[i].mirrorwall];
walltype* wal = mirror[i].mirrorWall;
if (wal->picnum != MIRRORLABEL + i)
{
wal->portalflags = 0;

View file

@ -298,30 +298,30 @@ void JS_InitMirrors(void)
mirror[i].ismagic = false;
}
for (i = 0; i < numwalls; i++)
for(auto& wal : walls())
{
s = wall[i].nextsector;
if ((s >= 0) && (wall[i].overpicnum == MIRROR) && (wall[i].cstat & 32))
if (wal.twoSided() && (wal.overpicnum == MIRROR) && (wal.cstat & 32))
{
if ((sector[s].floorstat & 1) == 0)
auto sec = wal.nextSector();
if ((sec->floorstat & 1) == 0)
{
if (mirrorcnt >= MAXMIRRORS)
{
Printf("MAXMIRRORS reached! Skipping mirror wall[%d]\n", i);
wall[i].overpicnum = sector[s].ceilingpicnum;
wal.overpicnum = sec->ceilingpicnum;
continue;
}
wall[i].overpicnum = MIRRORLABEL + mirrorcnt;
wall[i].picnum = MIRRORLABEL + mirrorcnt;
sector[s].ceilingpicnum = MIRRORLABEL + mirrorcnt;
sector[s].floorpicnum = MIRRORLABEL + mirrorcnt;
sector[s].floorstat |= 1;
mirror[mirrorcnt].mirrorwall = i;
mirror[mirrorcnt].mirrorsector = s;
wal.overpicnum = MIRRORLABEL + mirrorcnt;
wal.picnum = MIRRORLABEL + mirrorcnt;
sec->ceilingpicnum = MIRRORLABEL + mirrorcnt;
sec->floorpicnum = MIRRORLABEL + mirrorcnt;
sec->floorstat |= 1;
mirror[mirrorcnt].mirrorWall = &wal;
mirror[mirrorcnt].mirrorSector = sec;
mirror[mirrorcnt].numspawnspots = 0;
mirror[mirrorcnt].ismagic = false;
do if (wall[i].lotag == TAG_WALL_MAGIC_MIRROR)
do if (wal.lotag == TAG_WALL_MAGIC_MIRROR)
{
int ii;
SPRITEp sp;
@ -333,7 +333,7 @@ void JS_InitMirrors(void)
{
sp = &itActor->s();
// if correct type and matches
if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag)
if (sp->hitag == MIRROR_CAM && sp->lotag == wal.hitag)
{
mirror[mirrorcnt].cameraActor = itActor;
// Set up camera variables
@ -349,7 +349,7 @@ void JS_InitMirrors(void)
sp = &itActor->s();
// if correct type and matches
if (sp->hitag == MIRROR_CAM && sp->lotag == wall[i].hitag)
if (sp->hitag == MIRROR_CAM && sp->lotag == wal.hitag)
{
mirror[mirrorcnt].cameraActor = itActor;
// Set up camera variables
@ -361,8 +361,8 @@ void JS_InitMirrors(void)
if (!Found_Cam)
{
Printf("Cound not find the camera view sprite for match %d\n", wall[i].hitag);
Printf("Map Coordinates: x = %d, y = %d\n", wall[i].x, wall[i].y);
Printf("Cound not find the camera view sprite for match %d\n", wal.hitag);
Printf("Map Coordinates: x = %d, y = %d\n", wal.x, wal.y);
break;
}
@ -376,7 +376,7 @@ void JS_InitMirrors(void)
{
sp = &itActor->s();
if (sp->picnum >= CAMSPRITE && sp->picnum < CAMSPRITE + 8 &&
sp->hitag == wall[i].hitag)
sp->hitag == wal.hitag)
{
mirror[mirrorcnt].campic = sp->picnum;
mirror[mirrorcnt].camspriteActor = itActor;
@ -391,8 +391,8 @@ void JS_InitMirrors(void)
if (!Found_Cam)
{
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);
Printf("wall[%d].hitag == %d\n", i, wal.hitag);
Printf("Map Coordinates: x = %d, y = %d\n", wal.x, wal.y);
RESET_BOOL1(&mirror[mirrorcnt].cameraActor->s());
}
}
@ -414,19 +414,17 @@ void JS_InitMirrors(void)
mirrorcnt++;
}
else
wall[i].overpicnum = sector[s].ceilingpicnum;
wal.overpicnum = sec->ceilingpicnum;
}
}
// Invalidate textures in sector behind mirror
for (i = 0; i < mirrorcnt; i++)
{
startwall = sector[mirror[i].mirrorsector].wallptr;
endwall = startwall + sector[mirror[i].mirrorsector].wallnum;
for (j = startwall; j < endwall; j++)
for (auto& wal : wallsofsector(mirror[i].mirrorSector))
{
wall[j].picnum = MIRROR;
wall[j].overpicnum = MIRROR;
wal.picnum = MIRROR;
wal.overpicnum = MIRROR;
}
}
@ -546,8 +544,8 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
if (bIsWallMirror)
{
j = abs(wall[mirror[cnt].mirrorwall].x - tx);
j += abs(wall[mirror[cnt].mirrorwall].y - ty);
j = abs(mirror[cnt].mirrorWall->x - tx);
j += abs(mirror[cnt].mirrorWall->y - ty);
if (j < dist)
dist = j;
}
@ -570,17 +568,14 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
ASSERT(mirror[cnt].cameraActor != nullptr);
sp = &mirror[cnt].cameraActor->s();
ASSERT(sp);
// Calculate the angle of the mirror wall
w = mirror[cnt].mirrorwall;
auto wal = mirror[cnt].mirrorWall;
// Get wall midpoint for offset in mirror view
midx = (wall[w].x + wall[w].point2Wall()->x) / 2;
midy = (wall[w].y + wall[w].point2Wall()->y) / 2;
midx = (wal->x + wal->point2Wall()->x) / 2;
midy = (wal->y + wal->point2Wall()->y) / 2;
// Finish finding offsets
tdx = abs(midx - tx);

View file

@ -42,8 +42,8 @@ typedef struct
{
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
walltype* mirrorWall; // Wall number containing the mirror tile
sectortype* 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.

View file

@ -87,8 +87,8 @@ static int osdcmd_mirror(CCmdFuncPtr parm)
Printf("camspic is the tile number of the drawtotile in editart");
Printf("iscamera is whether or not this mirror is a camera type");
Printf(" ");
Printf("mirror[%d].mirrorwall = %d", op1, mirror[op1].mirrorwall);
Printf("mirror[%d].mirrorsector = %d", op1, mirror[op1].mirrorsector);
Printf("mirror[%d].mirrorwall = %d", op1, wallnum(mirror[op1].mirrorWall));
Printf("mirror[%d].mirrorsector = %d", op1, sectnum(mirror[op1].mirrorSector));
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);

View file

@ -969,8 +969,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRRORTYPE& w, MIR
}
if (arc.BeginObject(keyname))
{
arc("mirrorwall", w.mirrorwall, def->mirrorwall)
("mirrorsector", w.mirrorsector, def->mirrorsector)
arc("mirrorwall", w.mirrorWall, def->mirrorWall)
("mirrorsector", w.mirrorSector, def->mirrorSector)
("camera", w.cameraActor, def->cameraActor)
("camsprite", w.camspriteActor, def->camspriteActor)
("campic", w.campic, def->campic)