raze/source/games/duke/src/premap_r.cpp

263 lines
6.3 KiB
C++
Raw Normal View History

//-------------------------------------------------------------------------
/*
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
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"
#include "dukeactor.h"
#include "precache.h"
BEGIN_DUKE_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void prelevel_r(int g, TArray<DDukeActor*>& actors)
{
DDukePlayer* p;
int j;
int lotaglist;
TArray<short> lotags;
int speed = 0;
2020-07-20 21:21:27 +00:00
int dist;
int sound;
2020-07-20 21:21:27 +00:00
sound = 0;
prelevel_common(g);
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)
getPlayer(myconnectindex)->steroids_amount = 0;
2020-07-20 21:21:27 +00:00
if (isRRRA())
{
for(auto actor : actors)
2020-07-20 21:21:27 +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)
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
}
}
}
for (auto&sect: sector)
2020-07-20 21:21:27 +00:00
{
auto sectp = &sect;
2020-07-20 21:21:27 +00:00
switch (sectp->lotag)
2020-07-20 21:21:27 +00:00
{
case ST_41_JAILDOOR:
{
DukeSectIterator it(sectp);
dist = 0;
2020-10-28 05:37:17 +00:00
while (auto act = it.Next())
2020-07-20 21:21:27 +00:00
{
if (act->GetClass() == RedneckJaildoorDefClass)
2020-07-20 21:21:27 +00:00
{
dist = act->spr.lotag;
2021-12-21 20:14:27 +00:00
speed = act->spr.hitag;
act->Destroy();
2020-07-20 21:21:27 +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;
act->Destroy();
2020-07-20 21:21:27 +00:00
}
}
if (dist == 0)
{
// Oh no, we got an incomplete definition.
if (sectindex(sectp) == 534 && currentLevel->levelNumber == 2007) // fix for bug in RR E2L7 Beaudry Mansion.
{
dist = 48;
speed = 32;
}
}
for(auto& osect: sector)
2020-07-20 21:21:27 +00:00
{
if (sectp->hitag == osect.hitag && &osect != sectp)
2020-07-20 21:21:27 +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.
addjaildoor(dist, speed, sectp->hitag, osect.lotag & 32767, sound, &osect);
2020-07-20 21:21:27 +00:00
}
}
break;
}
case ST_42_MINECART:
2020-07-20 21:21:27 +00:00
{
sectortype* childsectnum = nullptr;
dist = 0;
speed = 0;
DukeSectIterator it(sectp);
2020-10-28 05:37:17 +00:00
while (auto act = it.Next())
2020-07-20 21:21:27 +00:00
{
if (act->GetClass() == RedneckMinecartDefClass)
2020-07-20 21:21:27 +00:00
{
dist = act->spr.lotag;
2021-12-21 20:14:27 +00:00
speed = act->spr.hitag;
DukeSpriteIterator itt;
while(auto act1 = itt.Next())
2020-07-20 21:21:27 +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
{
childsectnum = act1->sector();
act1->Destroy();
2020-07-20 21:21:27 +00:00
}
}
act->Destroy();
2020-07-20 21:21:27 +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;
act->Destroy();
2020-07-20 21:21:27 +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
{
getPlayer(0)->Exit = ac->spr.pos.XY();
2020-07-20 21:21:27 +00:00
}
else
2020-07-20 21:21:27 +00:00
{
premapcontroller(ac);
2020-07-20 21:21:27 +00:00
}
}
for (auto actor : actors)
2020-07-20 21:21:27 +00:00
{
if (!actor->exists()) continue;
if (actor->GetClass() == RedneckGeometryEffectClass)
2020-07-20 21:21:27 +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
{
geosector[geocnt] = actor->sector();
for (auto actor2 : actors)
2020-07-20 21:21:27 +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
{
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
{
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++;
}
}
}
for (auto actor : actors)
2020-07-20 21:21:27 +00:00
{
if (actor->exists())
2020-07-20 21:21:27 +00:00
{
if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR)
2020-07-20 21:21:27 +00:00
continue;
spriteinit(actor, actors);
2020-07-20 21:21:27 +00:00
}
}
for (auto actor : actors)
2020-07-20 21:21:27 +00:00
{
if (actor->exists())
2020-07-20 21:21:27 +00:00
{
if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR)
spriteinit(actor, actors);
if (actor->GetClass() == RedneckGeometryEffectClass)
actor->Destroy();
if (actor->GetClass() == RedneckKeyinfoSetterClass)
{
actor->sector()->lockinfo = uint8_t(actor->spr.lotag);
actor->Destroy();
}
2020-07-20 21:21:27 +00:00
}
}
lotaglist = 0;
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
{
auto ext = GetExtInfo(ac->spr.spritetexture());
if (ext.switchphase == 1 && switches[ext.switchindex].type == SwitchDef::Regular)
2020-07-20 21:21:27 +00:00
{
j = lotags.Find(ac->spr.lotag);
if (j == lotags.Size())
2020-07-20 21:21:27 +00:00
{
lotags.Push(ac->spr.lotag);
2020-11-02 22:53:55 +00:00
DukeStatIterator it1(STAT_EFFECTOR);
while (auto actj = it1.Next())
2020-07-20 21:21:27 +00:00
{
if (actj->spr.lotag == SE_12_LIGHT_SWITCH && actj->spr.hitag == ac->spr.lotag)
actj->counter = 1;
2020-07-20 21:21:27 +00:00
}
}
}
}
2020-05-21 09:41:48 +00:00
}
2020-05-21 09:41:48 +00:00
END_DUKE_NS