2020-05-20 20:18:03 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2017-2019 Nuke.YKT
|
2020-06-28 07:03:31 +00:00
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
2020-05-20 20:18:03 +00:00
|
|
|
|
|
|
|
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-07-07 15:56:20 +00:00
|
|
|
#include "mapinfo.h"
|
2020-10-21 17:14:41 +00:00
|
|
|
#include "dukeactor.h"
|
2021-04-11 07:59:55 +00:00
|
|
|
#include "precache.h"
|
2020-05-20 20:18:03 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-04 12:02:38 +00:00
|
|
|
void prelevel_r(int g, TArray<DDukeActor*>& actors)
|
2020-05-20 20:18:03 +00:00
|
|
|
{
|
2023-10-02 19:03:59 +00:00
|
|
|
DDukePlayer* p;
|
2021-11-07 15:46:23 +00:00
|
|
|
int j;
|
|
|
|
int lotaglist;
|
2022-12-03 19:30:49 +00:00
|
|
|
TArray<short> lotags;
|
2021-11-14 14:03:50 +00:00
|
|
|
int speed = 0;
|
2020-07-20 21:21:27 +00:00
|
|
|
int dist;
|
2021-11-07 15:46:23 +00:00
|
|
|
int sound;
|
2020-07-20 21:21:27 +00:00
|
|
|
sound = 0;
|
|
|
|
|
|
|
|
prelevel_common(g);
|
2023-10-02 02:51:13 +00:00
|
|
|
p = getPlayer(screenpeek);
|
2020-07-20 21:21:27 +00:00
|
|
|
|
2021-05-02 12:01:10 +00:00
|
|
|
if (currentLevel->gameflags & LEVEL_RR_CLEARMOONSHINE)
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(myconnectindex)->steroids_amount = 0;
|
2020-07-20 21:21:27 +00:00
|
|
|
|
|
|
|
if (isRRRA())
|
|
|
|
{
|
2021-12-04 12:02:38 +00:00
|
|
|
for(auto actor : actors)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-04 12:02:38 +00:00
|
|
|
if (!actor->exists()) continue;
|
2021-12-21 20:14:27 +00:00
|
|
|
if (actor->spr.pal == 100)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
|
|
|
if (numplayers > 1)
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
else
|
2021-12-21 20:14:27 +00:00
|
|
|
actor->spr.pal = 0;
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
2021-12-21 20:14:27 +00:00
|
|
|
else if (actor->spr.pal == 101)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-21 20:14:27 +00:00
|
|
|
actor->spr.extra = 0;
|
|
|
|
actor->spr.hitag = 1;
|
|
|
|
actor->spr.pal = 0;
|
2022-12-02 16:34:44 +00:00
|
|
|
ChangeActorStat(actor, STAT_BOBBING);
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 08:23:39 +00:00
|
|
|
for (auto§: sector)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-11-18 18:44:26 +00:00
|
|
|
auto sectp = §
|
2020-07-20 21:21:27 +00:00
|
|
|
|
2021-11-06 23:15:26 +00:00
|
|
|
switch (sectp->lotag)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-01-28 18:02:36 +00:00
|
|
|
case ST_41_JAILDOOR:
|
2020-10-14 19:16:54 +00:00
|
|
|
{
|
2021-11-18 18:44:26 +00:00
|
|
|
DukeSectIterator it(sectp);
|
2021-11-14 14:03:50 +00:00
|
|
|
dist = 0;
|
2020-10-28 05:37:17 +00:00
|
|
|
while (auto act = it.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
if (act->GetClass() == RedneckJaildoorDefClass)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-01-28 18:02:36 +00:00
|
|
|
dist = act->spr.lotag;
|
2021-12-21 20:14:27 +00:00
|
|
|
speed = act->spr.hitag;
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
2022-12-29 08:56:14 +00:00
|
|
|
if (act->GetClass() == RedneckJaildoorSoundClass)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-21 20:14:27 +00:00
|
|
|
sound = act->spr.lotag;
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-24 20:26:06 +00:00
|
|
|
if (dist == 0)
|
|
|
|
{
|
|
|
|
// Oh no, we got an incomplete definition.
|
2022-11-15 11:03:44 +00:00
|
|
|
if (sectindex(sectp) == 534 && currentLevel->levelNumber == 2007) // fix for bug in RR E2L7 Beaudry Mansion.
|
2022-08-24 20:26:06 +00:00
|
|
|
{
|
|
|
|
dist = 48;
|
|
|
|
speed = 32;
|
|
|
|
}
|
|
|
|
}
|
2021-12-21 08:23:39 +00:00
|
|
|
for(auto& osect: sector)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-11-18 18:44:26 +00:00
|
|
|
if (sectp->hitag == osect.hitag && &osect != sectp)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2020-10-18 10:10:46 +00:00
|
|
|
// & 32767 to avoid some ordering issues here.
|
|
|
|
// Other code assumes that the lotag is always a sector effector type and can mask the high bit in.
|
2021-11-18 18:44:26 +00:00
|
|
|
addjaildoor(dist, speed, sectp->hitag, osect.lotag & 32767, sound, &osect);
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2020-10-14 19:16:54 +00:00
|
|
|
}
|
2022-01-28 18:02:36 +00:00
|
|
|
case ST_42_MINECART:
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-11-18 18:44:26 +00:00
|
|
|
sectortype* childsectnum = nullptr;
|
2021-11-14 12:33:35 +00:00
|
|
|
dist = 0;
|
2021-11-14 14:03:50 +00:00
|
|
|
speed = 0;
|
2021-11-18 18:44:26 +00:00
|
|
|
DukeSectIterator it(sectp);
|
2020-10-28 05:37:17 +00:00
|
|
|
while (auto act = it.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
if (act->GetClass() == RedneckMinecartDefClass)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-01-28 17:47:53 +00:00
|
|
|
dist = act->spr.lotag;
|
2021-12-21 20:14:27 +00:00
|
|
|
speed = act->spr.hitag;
|
2021-11-21 08:08:05 +00:00
|
|
|
DukeSpriteIterator itt;
|
2021-12-24 09:53:27 +00:00
|
|
|
while(auto act1 = itt.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
if (act1->GetClass() == RedneckMinecartInnerClass)
|
2021-12-30 15:39:43 +00:00
|
|
|
if (act1->spr.lotag == act->sectno()) // bad map format design... Should have used a tag instead...
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
childsectnum = act1->sector();
|
2022-11-20 18:25:23 +00:00
|
|
|
act1->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
2022-12-29 08:56:14 +00:00
|
|
|
if (act->GetClass() == RedneckMinecartSoundClass)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-21 20:14:27 +00:00
|
|
|
sound = act->spr.lotag;
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-18 18:44:26 +00:00
|
|
|
addminecart(dist, speed, sectp, sectp->hitag, sound, childsectnum);
|
2020-07-20 21:21:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-02 18:13:58 +00:00
|
|
|
DukeStatIterator it(STAT_DEFAULT);
|
|
|
|
while (auto ac = it.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2020-10-23 18:27:05 +00:00
|
|
|
LoadActor(ac, -1, -1);
|
2020-07-20 21:21:27 +00:00
|
|
|
|
2021-12-21 20:14:27 +00:00
|
|
|
if (ac->spr.lotag == -1 && (ac->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(0)->Exit = ac->spr.pos.XY();
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
2022-11-20 12:57:51 +00:00
|
|
|
else
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-07-25 22:12:57 +00:00
|
|
|
premapcontroller(ac);
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 12:02:38 +00:00
|
|
|
for (auto actor : actors)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-04 12:02:38 +00:00
|
|
|
if (!actor->exists()) continue;
|
2022-12-29 08:56:14 +00:00
|
|
|
if (actor->GetClass() == RedneckGeometryEffectClass)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2023-04-02 12:10:57 +00:00
|
|
|
if (geocnt >= MAXGEOSECTORS)
|
2020-07-20 21:21:27 +00:00
|
|
|
I_Error("Too many geometry effects");
|
2021-12-21 20:14:27 +00:00
|
|
|
if (actor->spr.hitag == 0)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
geosector[geocnt] = actor->sector();
|
2021-12-04 12:02:38 +00:00
|
|
|
for (auto actor2 : actors)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-03 19:20:22 +00:00
|
|
|
if (actor && actor->spr.lotag == actor2->spr.lotag && actor2 != actor && actor2->GetClass() == actor->GetClass())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-21 20:14:27 +00:00
|
|
|
if (actor2->spr.hitag == 1)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
geosectorwarp[geocnt] = actor2->sector();
|
2022-02-07 07:49:03 +00:00
|
|
|
geox[geocnt] = actor->spr.pos.X - actor2->spr.pos.X;
|
|
|
|
geoy[geocnt] = actor->spr.pos.Y - actor2->spr.pos.Y;
|
2021-12-21 20:14:27 +00:00
|
|
|
//geoz[geocnt] = actor->spr.z - actor2->spr.z;
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
2021-12-21 20:14:27 +00:00
|
|
|
if (actor2->spr.hitag == 2)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
geosectorwarp2[geocnt] = actor2->sector();
|
2022-02-07 07:49:03 +00:00
|
|
|
geox2[geocnt] = actor->spr.pos.X - actor2->spr.pos.X;
|
|
|
|
geoy2[geocnt] = actor->spr.pos.Y - actor2->spr.pos.Y;
|
2021-12-21 20:14:27 +00:00
|
|
|
//geoz2[geocnt] = actor->spr.z - actor2->spr.z;
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
geocnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 12:02:38 +00:00
|
|
|
for (auto actor : actors)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-04 12:02:38 +00:00
|
|
|
if (actor->exists())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-01 19:54:41 +00:00
|
|
|
if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR)
|
2020-07-20 21:21:27 +00:00
|
|
|
continue;
|
2022-12-15 09:46:41 +00:00
|
|
|
spriteinit(actor, actors);
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 12:02:38 +00:00
|
|
|
for (auto actor : actors)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2021-12-04 12:02:38 +00:00
|
|
|
if (actor->exists())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-01 19:54:41 +00:00
|
|
|
if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR)
|
2022-12-15 09:46:41 +00:00
|
|
|
spriteinit(actor, actors);
|
2022-12-29 08:56:14 +00:00
|
|
|
if (actor->GetClass() == RedneckGeometryEffectClass)
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2022-12-29 08:56:14 +00:00
|
|
|
if (actor->GetClass() == RedneckKeyinfoSetterClass)
|
2021-12-04 12:02:38 +00:00
|
|
|
{
|
2022-12-31 16:58:14 +00:00
|
|
|
actor->sector()->lockinfo = uint8_t(actor->spr.lotag);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2021-12-04 12:02:38 +00:00
|
|
|
}
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lotaglist = 0;
|
|
|
|
|
2020-10-14 20:18:10 +00:00
|
|
|
it.Reset(STAT_DEFAULT);
|
2020-11-02 18:13:58 +00:00
|
|
|
while (auto ac = it.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-10 23:23:38 +00:00
|
|
|
auto ext = GetExtInfo(ac->spr.spritetexture());
|
|
|
|
if (ext.switchphase == 1 && switches[ext.switchindex].type == SwitchDef::Regular)
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-03 19:30:49 +00:00
|
|
|
j = lotags.Find(ac->spr.lotag);
|
|
|
|
if (j == lotags.Size())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-03 19:30:49 +00:00
|
|
|
lotags.Push(ac->spr.lotag);
|
2020-11-02 22:53:55 +00:00
|
|
|
DukeStatIterator it1(STAT_EFFECTOR);
|
2021-12-24 09:53:27 +00:00
|
|
|
while (auto actj = it1.Next())
|
2020-07-20 21:21:27 +00:00
|
|
|
{
|
2022-12-03 19:20:22 +00:00
|
|
|
if (actj->spr.lotag == SE_12_LIGHT_SWITCH && actj->spr.hitag == ac->spr.lotag)
|
2022-12-22 08:49:42 +00:00
|
|
|
actj->counter = 1;
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 09:41:48 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 20:18:03 +00:00
|
|
|
|
2020-05-21 09:41:48 +00:00
|
|
|
END_DUKE_NS
|