2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
2021-03-20 22:01:16 +00:00
|
|
|
#include "automap.h"
|
|
|
|
#include "savegamehelp.h"
|
|
|
|
|
|
|
|
#include "blood.h"
|
2021-03-21 13:48:35 +00:00
|
|
|
#include "render.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
int mirrorcnt, mirrorsector, mirrorwall[4];
|
|
|
|
|
|
|
|
MIRROR mirror[16];
|
|
|
|
|
|
|
|
void InitMirrors(void)
|
|
|
|
{
|
|
|
|
r_rortexture = 4080;
|
|
|
|
r_rortexturerange = 16;
|
|
|
|
|
|
|
|
mirrorcnt = 0;
|
|
|
|
tileDelete(504);
|
2021-03-21 13:48:35 +00:00
|
|
|
portalClear();
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-10-11 19:04:31 +00:00
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
tileDelete(4080 + i);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = numwalls - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (mirrorcnt == 16)
|
|
|
|
break;
|
|
|
|
int nTile = 4080+mirrorcnt;
|
|
|
|
if (wall[i].overpicnum == 504)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (wall[i].extra > 0 && GetWallType(i) == kWallStack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
wall[i].overpicnum = nTile;
|
2021-03-21 13:48:35 +00:00
|
|
|
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].wallnum = i;
|
|
|
|
mirror[mirrorcnt].type = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
wall[i].cstat |= 32;
|
|
|
|
int tmp = xwall[wall[i].extra].data;
|
|
|
|
int j;
|
|
|
|
for (j = numwalls - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
if (j == i)
|
|
|
|
continue;
|
2019-10-11 21:59:39 +00:00
|
|
|
if (wall[j].extra > 0 && GetWallType(i) == kWallStack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (tmp != xwall[wall[j].extra].data)
|
|
|
|
continue;
|
|
|
|
wall[i].hitag = j;
|
|
|
|
wall[j].hitag = i;
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].link = j;
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j < 0)
|
2021-03-21 13:48:35 +00:00
|
|
|
{
|
|
|
|
Printf(PRINT_HIGH, "wall[%d] has no matching wall link! (data=%d)\n", i, tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mirrorcnt++;
|
|
|
|
wall[i].portalflags = PORTAL_WALL_VIEW;
|
2021-03-21 16:04:06 +00:00
|
|
|
wall[i].portalnum = j;
|
2021-03-21 13:48:35 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (wall[i].picnum == 504)
|
|
|
|
{
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].link = i;
|
|
|
|
mirror[mirrorcnt].wallnum = i;
|
2019-09-19 22:42:45 +00:00
|
|
|
wall[i].picnum = nTile;
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].type = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
wall[i].cstat |= 32;
|
2021-03-20 22:01:16 +00:00
|
|
|
wall[i].portalflags = PORTAL_WALL_MIRROR;
|
2019-09-19 22:42:45 +00:00
|
|
|
mirrorcnt++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = numsectors - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (mirrorcnt >= 15)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (sector[i].floorpicnum == 504)
|
|
|
|
{
|
2021-09-04 18:49:00 +00:00
|
|
|
auto link = getUpperLink(i);
|
|
|
|
if (link == nullptr)
|
2019-09-19 22:42:45 +00:00
|
|
|
continue;
|
2021-09-04 18:49:00 +00:00
|
|
|
auto link2 = link->GetOwner();
|
|
|
|
if (link2 == nullptr)
|
|
|
|
continue;
|
|
|
|
int j = link2->s().sectnum;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (sector[j].ceilingpicnum != 504)
|
2020-10-11 10:22:36 +00:00
|
|
|
I_Error("Lower link sector %d doesn't have mirror picnum\n", j);
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].type = 2;
|
2021-09-04 18:49:00 +00:00
|
|
|
mirror[mirrorcnt].dx = link2->s().x - link->s().x;
|
|
|
|
mirror[mirrorcnt].dy = link2->s().y - link->s().y;
|
|
|
|
mirror[mirrorcnt].dz = link2->s().z - link->s().z;
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].wallnum = i;
|
|
|
|
mirror[mirrorcnt].link = j;
|
2021-09-04 18:49:00 +00:00
|
|
|
sector[i].floorpicnum = 4080 + mirrorcnt;
|
2021-03-20 22:01:16 +00:00
|
|
|
sector[i].portalflags = PORTAL_SECTOR_FLOOR;
|
2021-03-21 13:48:35 +00:00
|
|
|
sector[i].portalnum = portalAdd(PORTAL_SECTOR_FLOOR, j, mirror[mirrorcnt].dx, mirror[mirrorcnt].dy, mirror[mirrorcnt].dz);
|
2019-09-19 22:42:45 +00:00
|
|
|
mirrorcnt++;
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].type = 1;
|
2021-09-04 18:49:00 +00:00
|
|
|
mirror[mirrorcnt].dx = link->s().x - link2->s().x;
|
|
|
|
mirror[mirrorcnt].dy = link->s().y - link2->s().y;
|
|
|
|
mirror[mirrorcnt].dz = link->s().z - link2->s().z;
|
2020-11-21 22:40:08 +00:00
|
|
|
mirror[mirrorcnt].wallnum = j;
|
|
|
|
mirror[mirrorcnt].link = i;
|
2021-09-04 18:49:00 +00:00
|
|
|
sector[j].ceilingpicnum = 4080 + mirrorcnt;
|
2021-03-20 22:01:16 +00:00
|
|
|
sector[j].portalflags = PORTAL_SECTOR_CEILING;
|
2021-03-24 22:11:06 +00:00
|
|
|
sector[j].portalnum = portalAdd(PORTAL_SECTOR_CEILING, i, mirror[mirrorcnt].dx, mirror[mirrorcnt].dy, mirror[mirrorcnt].dz);
|
2019-09-19 22:42:45 +00:00
|
|
|
mirrorcnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mirrorsector = numsectors;
|
2021-03-21 13:48:35 +00:00
|
|
|
mergePortals();
|
2021-03-20 22:01:16 +00:00
|
|
|
#if 1 // The new backend won't need this shit anymore.
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
mirrorwall[i] = numwalls+i;
|
|
|
|
wall[mirrorwall[i]].picnum = 504;
|
|
|
|
wall[mirrorwall[i]].overpicnum = 504;
|
|
|
|
wall[mirrorwall[i]].cstat = 0;
|
|
|
|
wall[mirrorwall[i]].nextsector = -1;
|
|
|
|
wall[mirrorwall[i]].nextwall = -1;
|
2019-06-24 08:09:29 +00:00
|
|
|
wall[mirrorwall[i]].point2 = numwalls+i+1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
wall[mirrorwall[3]].point2 = mirrorwall[0];
|
|
|
|
sector[mirrorsector].ceilingpicnum = 504;
|
|
|
|
sector[mirrorsector].floorpicnum = 504;
|
|
|
|
sector[mirrorsector].wallptr = mirrorwall[0];
|
|
|
|
sector[mirrorsector].wallnum = 4;
|
2021-03-20 22:01:16 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TranslateMirrorColors(int nShade, int nPalette)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-22 12:14:43 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-22 12:14:43 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRROR& w, MIRROR* def)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-22 12:14:43 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
2019-10-11 19:04:31 +00:00
|
|
|
{
|
2020-11-22 12:14:43 +00:00
|
|
|
arc ("type", w.type)
|
|
|
|
("link", w.link)
|
|
|
|
("dx", w.dx)
|
|
|
|
("dy", w.dy)
|
|
|
|
("dz", w.dz)
|
|
|
|
("wallnum", w.wallnum)
|
|
|
|
.EndObject();
|
2019-10-11 19:04:31 +00:00
|
|
|
}
|
2020-11-22 12:14:43 +00:00
|
|
|
return arc;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 12:14:43 +00:00
|
|
|
void SerializeMirrors(FSerializer& arc)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-22 12:14:43 +00:00
|
|
|
if (arc.BeginObject("mirror"))
|
|
|
|
{
|
|
|
|
arc("mirrorcnt", mirrorcnt)
|
|
|
|
("mirrorsector", mirrorsector)
|
|
|
|
.Array("mirror", mirror, countof(mirror))
|
|
|
|
.Array("mirrorwall", mirrorwall, countof(mirrorwall))
|
|
|
|
.EndObject();
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-22 12:14:43 +00:00
|
|
|
if (arc.isReading())
|
|
|
|
{
|
|
|
|
|
|
|
|
tileDelete(504);
|
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
r_rortexture = 4080;
|
|
|
|
r_rortexturerange = 16;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
tileDelete(4080 + i);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
wall[mirrorwall[i]].picnum = 504;
|
|
|
|
wall[mirrorwall[i]].overpicnum = 504;
|
|
|
|
wall[mirrorwall[i]].cstat = 0;
|
|
|
|
wall[mirrorwall[i]].nextsector = -1;
|
|
|
|
wall[mirrorwall[i]].nextwall = -1;
|
|
|
|
wall[mirrorwall[i]].point2 = numwalls + i + 1;
|
|
|
|
}
|
|
|
|
wall[mirrorwall[3]].point2 = mirrorwall[0];
|
|
|
|
sector[mirrorsector].ceilingpicnum = 504;
|
|
|
|
sector[mirrorsector].floorpicnum = 504;
|
|
|
|
sector[mirrorsector].wallptr = mirrorwall[0];
|
|
|
|
sector[mirrorsector].wallnum = 4;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|