- did some more simple replacements of level

This commit is contained in:
Christoph Oelckers 2019-01-07 17:31:06 +01:00
parent e9e303405f
commit 15f933f20a
11 changed files with 50 additions and 59 deletions

View file

@ -1067,7 +1067,7 @@ void FParser::SF_Teleport(void)
} }
if(mo) if(mo)
EV_Teleport(0, tag, NULL, 0, mo, TELF_DESTFOG | TELF_SOURCEFOG); EV_Teleport(Level, 0, tag, NULL, 0, mo, TELF_DESTFOG | TELF_SOURCEFOG);
} }
} }
@ -1096,7 +1096,7 @@ void FParser::SF_SilentTeleport(void)
} }
if(mo) if(mo)
EV_Teleport(0, tag, NULL, 0, mo, TELF_KEEPORIENTATION); EV_Teleport(Level, 0, tag, NULL, 0, mo, TELF_KEEPORIENTATION);
} }
} }

View file

@ -1947,20 +1947,6 @@ void P_ReadACSDefereds (FSerializer &arc)
} }
//==========================================================================
//
//
//==========================================================================
void FLevelLocals::Tick ()
{
// Reset carry sectors
if (Scrolls.Size() > 0)
{
memset (&Scrolls[0], 0, sizeof(Scrolls[0])*Scrolls.Size());
}
}
//========================================================================== //==========================================================================
// //
// //

View file

@ -1103,7 +1103,7 @@ FUNC(LS_Teleport)
{ {
flags |= TELF_SOURCEFOG; flags |= TELF_SOURCEFOG;
} }
return EV_Teleport (arg0, arg1, ln, backSide, it, flags); return EV_Teleport (Level, arg0, arg1, ln, backSide, it, flags);
} }
FUNC( LS_Teleport_NoStop ) FUNC( LS_Teleport_NoStop )
@ -1114,7 +1114,7 @@ FUNC( LS_Teleport_NoStop )
{ {
flags |= TELF_SOURCEFOG; flags |= TELF_SOURCEFOG;
} }
return EV_Teleport( arg0, arg1, ln, backSide, it, flags); return EV_Teleport(Level, arg0, arg1, ln, backSide, it, flags);
} }
FUNC(LS_Teleport_NoFog) FUNC(LS_Teleport_NoFog)
@ -1144,7 +1144,7 @@ FUNC(LS_Teleport_NoFog)
{ {
flags |= TELF_KEEPHEIGHT; flags |= TELF_KEEPHEIGHT;
} }
return EV_Teleport (arg0, arg2, ln, backSide, it, flags); return EV_Teleport (Level, arg0, arg2, ln, backSide, it, flags);
} }
FUNC(LS_Teleport_ZombieChanger) FUNC(LS_Teleport_ZombieChanger)
@ -1153,7 +1153,7 @@ FUNC(LS_Teleport_ZombieChanger)
// This is practically useless outside of Strife, but oh well. // This is practically useless outside of Strife, but oh well.
if (it != NULL) if (it != NULL)
{ {
EV_Teleport (arg0, arg1, ln, backSide, it, 0); EV_Teleport (Level, arg0, arg1, ln, backSide, it, 0);
if (it->health >= 0) it->SetState (it->FindState(NAME_Pain)); if (it->health >= 0) it->SetState (it->FindState(NAME_Pain));
return true; return true;
} }
@ -1163,19 +1163,19 @@ FUNC(LS_Teleport_ZombieChanger)
FUNC(LS_TeleportOther) FUNC(LS_TeleportOther)
// TeleportOther (other_tid, dest_tid, fog?) // TeleportOther (other_tid, dest_tid, fog?)
{ {
return EV_TeleportOther (arg0, arg1, arg2?true:false); return EV_TeleportOther (Level, arg0, arg1, arg2?true:false);
} }
FUNC(LS_TeleportGroup) FUNC(LS_TeleportGroup)
// TeleportGroup (group_tid, source_tid, dest_tid, move_source?, fog?) // TeleportGroup (group_tid, source_tid, dest_tid, move_source?, fog?)
{ {
return EV_TeleportGroup (arg0, it, arg1, arg2, arg3?true:false, arg4?true:false); return EV_TeleportGroup (Level, arg0, it, arg1, arg2, arg3?true:false, arg4?true:false);
} }
FUNC(LS_TeleportInSector) FUNC(LS_TeleportInSector)
// TeleportInSector (tag, source_tid, dest_tid, bFog, group_tid) // TeleportInSector (tag, source_tid, dest_tid, bFog, group_tid)
{ {
return EV_TeleportSector (arg0, arg1, arg2, arg3?true:false, arg4); return EV_TeleportSector (Level, arg0, arg1, arg2, arg3?true:false, arg4);
} }
FUNC(LS_Teleport_EndGame) FUNC(LS_Teleport_EndGame)

View file

@ -966,7 +966,7 @@ DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimfla
pitch = P_AimLineAttack (mo, an, 16.*64, pLineTarget, 0., aimflags); pitch = P_AimLineAttack (mo, an, 16.*64, pLineTarget, 0., aimflags);
if (mo->player != NULL && if (mo->player != NULL &&
level.IsFreelookAllowed() && mo->__GetLevel()->IsFreelookAllowed() &&
mo->player->userinfo.GetAimDist() <= 0.5) mo->player->userinfo.GetAimDist() <= 0.5)
{ {
break; break;

View file

@ -331,9 +331,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t
// //
//========================================================================== //==========================================================================
void RecalculateDrawnSubsectors() void RecalculateDrawnSubsectors(FLevelLocals *Level)
{ {
for (auto &sub : level.subsectors) for (auto &sub : Level->subsectors)
{ {
for (unsigned int j = 0; j<sub.numlines; j++) for (unsigned int j = 0; j<sub.numlines; j++)
{ {
@ -352,12 +352,12 @@ void RecalculateDrawnSubsectors()
// //
//========================================================================== //==========================================================================
FSerializer &SerializeSubsectors(FSerializer &arc, const char *key) FSerializer &SerializeSubsectors(FSerializer &arc, FLevelLocals *Level, const char *key)
{ {
uint8_t by; uint8_t by;
const char *str; const char *str;
auto numsubsectors = level.subsectors.Size(); auto numsubsectors = Level->subsectors.Size();
if (arc.isWriting()) if (arc.isWriting())
{ {
TArray<char> encoded(1 + (numsubsectors + 5) / 6); TArray<char> encoded(1 + (numsubsectors + 5) / 6);
@ -367,7 +367,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
by = 0; by = 0;
for (unsigned j = 0; j < 6; j++) for (unsigned j = 0; j < 6; j++)
{ {
if (i + j < numsubsectors && (level.subsectors[i + j].flags & SSECMF_DRAWN)) if (i + j < numsubsectors && (Level->subsectors[i + j].flags & SSECMF_DRAWN))
{ {
by |= (1 << j); by |= (1 << j);
} }
@ -383,7 +383,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
str = &encoded[0]; str = &encoded[0];
if (arc.BeginArray(key)) if (arc.BeginArray(key))
{ {
auto numvertexes = level.vertexes.Size(); auto numvertexes = Level->vertexes.Size();
arc(nullptr, numvertexes) arc(nullptr, numvertexes)
(nullptr, numsubsectors) (nullptr, numsubsectors)
.StringPtr(nullptr, str) .StringPtr(nullptr, str)
@ -401,7 +401,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
.StringPtr(nullptr, str) .StringPtr(nullptr, str)
.EndArray(); .EndArray();
if (num_verts == (int)level.vertexes.Size() && num_subs == (int)numsubsectors) if (num_verts == (int)Level->vertexes.Size() && num_subs == (int)numsubsectors)
{ {
success = true; success = true;
int sub = 0; int sub = 0;
@ -422,7 +422,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
{ {
if (sub + s < (int)numsubsectors && (by & (1 << s))) if (sub + s < (int)numsubsectors && (by & (1 << s)))
{ {
level.subsectors[sub + s].flags |= SSECMF_DRAWN; Level->subsectors[sub + s].flags |= SSECMF_DRAWN;
} }
} }
sub += 6; sub += 6;
@ -430,7 +430,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
} }
if (!success) if (!success)
{ {
RecalculateDrawnSubsectors(); RecalculateDrawnSubsectors(Level);
} }
} }
@ -1012,7 +1012,7 @@ void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload)
E_SerializeEvents(arc); E_SerializeEvents(arc);
DThinker::SerializeThinkers(arc, hubload); DThinker::SerializeThinkers(arc, hubload);
arc("polyobjs", Level->Polyobjects); arc("polyobjs", Level->Polyobjects);
SerializeSubsectors(arc, "subsectors"); SerializeSubsectors(arc, Level, "subsectors");
StatusBar->SerializeMessages(arc); StatusBar->SerializeMessages(arc);
AM_SerializeMarkers(arc); AM_SerializeMarkers(arc);
FRemapTable::StaticSerializeTranslations(arc); FRemapTable::StaticSerializeTranslations(arc);

View file

@ -468,7 +468,7 @@ FBlockNode *FBlockNode::Create(AActor *who, int x, int y, int group)
{ {
block = (FBlockNode *)secnodearena.Alloc(sizeof(FBlockNode)); block = (FBlockNode *)secnodearena.Alloc(sizeof(FBlockNode));
} }
block->BlockIndex = x + y * level.blockmap.bmapwidth; block->BlockIndex = x + y * who->__GetLevel()->blockmap.bmapwidth;
block->Me = who; block->Me = who;
block->NextActor = nullptr; block->NextActor = nullptr;
block->PrevActor = nullptr; block->PrevActor = nullptr;

View file

@ -1530,7 +1530,7 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
} }
auto Level = sector->Level; auto Level = sector->Level;
if (!foggy || level.flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors if (!foggy || Level->flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors
{ {
if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0) if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0)
{ {

View file

@ -1489,7 +1489,7 @@ void P_SpawnSpecials (MapLoader *ml)
} }
} }
// [RH] Start running any open scripts on this map // [RH] Start running any open scripts on this map
level.Behaviors.StartTypedScripts (SCRIPT_Open, NULL, false); Level->Behaviors.StartTypedScripts (SCRIPT_Open, NULL, false);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////

View file

@ -688,11 +688,11 @@ enum
void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false); void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false);
bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags); bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags);
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags); bool EV_Teleport (FLevelLocals *Level, int tid, int tag, line_t *line, int side, AActor *thing, int flags);
bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse);
bool EV_TeleportOther (int other_tid, int dest_tid, bool fog); bool EV_TeleportOther (FLevelLocals *Level, int other_tid, int dest_tid, bool fog);
bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog); bool EV_TeleportGroup (FLevelLocals *Level, int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog);
bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int group_tid); bool EV_TeleportSector (FLevelLocals *Level, int tag, int source_tid, int dest_tid, bool fog, int group_tid);
// //

View file

@ -236,7 +236,7 @@ DEFINE_ACTION_FUNCTION(AActor, Teleport)
ACTION_RETURN_BOOL(P_Teleport(self, DVector3(x, y, z), an, flags)); ACTION_RETURN_BOOL(P_Teleport(self, DVector3(x, y, z), an, flags));
} }
static AActor *SelectTeleDest (int tid, int tag, bool norandom) static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool norandom)
{ {
AActor *searcher; AActor *searcher;
@ -320,7 +320,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
TThinkerIterator<AActor> it2(NAME_TeleportDest); TThinkerIterator<AActor> it2(NAME_TeleportDest);
while ((searcher = it2.Next()) != NULL) while ((searcher = it2.Next()) != NULL)
{ {
if (searcher->Sector == &level.sectors[secnum]) if (searcher->Sector == &Level->sectors[secnum])
{ {
return searcher; return searcher;
} }
@ -331,7 +331,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
return NULL; return NULL;
} }
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags) bool EV_Teleport (FLevelLocals *Level, int tid, int tag, line_t *line, int side, AActor *thing, int flags)
{ {
AActor *searcher; AActor *searcher;
double z; double z;
@ -353,7 +353,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f
{ // Don't teleport if hit back of line, so you can get out of teleporter. { // Don't teleport if hit back of line, so you can get out of teleporter.
return 0; return 0;
} }
searcher = SelectTeleDest(tid, tag, predicting); searcher = SelectTeleDest(Level, tid, tag, predicting);
if (searcher == NULL) if (searcher == NULL)
{ {
return false; return false;
@ -427,6 +427,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
{ {
int i; int i;
line_t *l; line_t *l;
auto Level = thing->__GetLevel();
if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL) if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL)
return false; return false;
@ -437,7 +438,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
if (line->Index() == i) if (line->Index() == i)
continue; continue;
if ((l=&level.lines[i]) != line && l->backsector) if ((l=&Level->lines[i]) != line && l->backsector)
{ {
// Get the thing's position along the source linedef // Get the thing's position along the source linedef
double pos; double pos;
@ -601,7 +602,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
} }
// [RH] Teleport anything matching other_tid to dest_tid // [RH] Teleport anything matching other_tid to dest_tid
bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) bool EV_TeleportOther (FLevelLocals *Level, int other_tid, int dest_tid, bool fog)
{ {
bool didSomething = false; bool didSomething = false;
@ -612,7 +613,7 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog)
while ( (victim = iterator.Next ()) ) while ( (victim = iterator.Next ()) )
{ {
didSomething |= EV_Teleport (dest_tid, 0, NULL, 0, victim, didSomething |= EV_Teleport (Level, dest_tid, 0, NULL, 0, victim,
fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION);
} }
} }
@ -639,7 +640,7 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl
// [RH] Teleport a group of actors centered around source_tid so // [RH] Teleport a group of actors centered around source_tid so
// that they become centered around dest_tid instead. // that they become centered around dest_tid instead.
bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog) bool EV_TeleportGroup (FLevelLocals *Level, int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog)
{ {
AActor *sourceOrigin, *destOrigin; AActor *sourceOrigin, *destOrigin;
{ {
@ -648,7 +649,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
} }
if (sourceOrigin == NULL) if (sourceOrigin == NULL)
{ // If there is no source origin, behave like TeleportOther { // If there is no source origin, behave like TeleportOther
return EV_TeleportOther (group_tid, dest_tid, fog); return EV_TeleportOther (Level, group_tid, dest_tid, fog);
} }
{ {
@ -694,7 +695,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
// [RH] Teleport a group of actors in a sector. Source_tid is used as a // [RH] Teleport a group of actors in a sector. Source_tid is used as a
// reference point so that they end up in the same position relative to // reference point so that they end up in the same position relative to
// dest_tid. Group_tid can be used to not teleport all actors in the sector. // dest_tid. Group_tid can be used to not teleport all actors in the sector.
bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int group_tid) bool EV_TeleportSector (FLevelLocals *Level, int tag, int source_tid, int dest_tid, bool fog, int group_tid)
{ {
AActor *sourceOrigin, *destOrigin; AActor *sourceOrigin, *destOrigin;
{ {
@ -723,7 +724,7 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
msecnode_t *node; msecnode_t *node;
const sector_t * const sec = &level.sectors[secnum]; const sector_t * const sec = &Level->sectors[secnum];
for (node = sec->touching_thinglist; node; ) for (node = sec->touching_thinglist; node; )
{ {

View file

@ -55,6 +55,7 @@ static FRandom pr_leadtarget ("LeadTarget");
bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid) bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid)
{ {
int rtn = 0; int rtn = 0;
auto Level = source->__GetLevel();
PClassActor *kind; PClassActor *kind;
AActor *spot, *mobj; AActor *spot, *mobj;
FActorIterator iterator (tid); FActorIterator iterator (tid);
@ -68,7 +69,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i
kind = kind->GetReplacement(); kind = kind->GetReplacement();
if ((GetDefaultByType(kind)->flags3 & MF3_ISMONSTER) && if ((GetDefaultByType(kind)->flags3 & MF3_ISMONSTER) &&
((dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS))) ((dmflags & DF_NO_MONSTERS) || (Level->flags2 & LEVEL2_NOMONSTERS)))
return false; return false;
if (tid == 0) if (tid == 0)
@ -261,6 +262,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
bool leadTarget) bool leadTarget)
{ {
int rtn = 0; int rtn = 0;
auto Level = source->__GetLevel();
PClassActor *kind; PClassActor *kind;
AActor *spot, *mobj, *targ = forcedest; AActor *spot, *mobj, *targ = forcedest;
FActorIterator iterator (tid); FActorIterator iterator (tid);
@ -284,7 +286,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
defflags3 = GetDefaultByType(kind)->flags3; defflags3 = GetDefaultByType(kind)->flags3;
if ((defflags3 & MF3_ISMONSTER) && if ((defflags3 & MF3_ISMONSTER) &&
((dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS))) ((dmflags & DF_NO_MONSTERS) || (Level->flags2 & LEVEL2_NOMONSTERS)))
return false; return false;
if (tid == 0) if (tid == 0)
@ -316,7 +318,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
{ {
z -= spot->Floorclip; z -= spot->Floorclip;
} }
mobj = Spawn (spot->__GetLevel(), kind, spot->PosAtZ(z), ALLOW_REPLACE); mobj = Spawn (Level, kind, spot->PosAtZ(z), ALLOW_REPLACE);
if (mobj) if (mobj)
{ {
@ -953,19 +955,21 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do
caller->Vel.Zero(); caller->Vel.Zero();
} }
auto &Displacements = caller->__GetLevel()->Displacements;
// this is no fun with line portals // this is no fun with line portals
if (flags & WARPF_WARPINTERPOLATION) if (flags & WARPF_WARPINTERPOLATION)
{ {
// This just translates the movement but doesn't change the vector // This just translates the movement but doesn't change the vector
DVector3 displacedold = old + level.Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); DVector3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup);
caller->Prev += caller->Pos() - displacedold; caller->Prev += caller->Pos() - displacedold;
caller->PrevPortalGroup = caller->Sector->PortalGroup; caller->PrevPortalGroup = caller->Sector->PortalGroup;
} }
else if (flags & WARPF_COPYINTERPOLATION) else if (flags & WARPF_COPYINTERPOLATION)
{ {
// Map both positions of the reference actor to the current portal group // Map both positions of the reference actor to the current portal group
DVector3 displacedold = old + level.Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); DVector3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup);
DVector3 displacedref = old + level.Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); DVector3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup);
caller->Prev = caller->Pos() + displacedold - displacedref; caller->Prev = caller->Pos() + displacedold - displacedref;
caller->PrevPortalGroup = caller->Sector->PortalGroup; caller->PrevPortalGroup = caller->Sector->PortalGroup;
} }