From 3f059898fde0fe53b77e85e247f086fa0f66f525 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Dec 2009 15:50:35 +0000 Subject: [PATCH] - added a linedef based method to define portals. Portals defined this way still have the same limitations as those defines with the portal things. SVN r2052 (trunk) --- docs/rh-log.txt | 4 +++ src/actionspecials.h | 1 + src/g_shared/a_sharedglobal.h | 10 +++++- src/g_shared/a_skies.cpp | 11 ++----- src/p_spec.cpp | 57 +++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 9 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 733aef90d9..0c96f07a56 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +December 27, 2009 (Changes by Graf Zahl) +- added a linedef based method to define portals. Portals defined this way + still have the same limitations as those defines with the portal things. + December 25, 2009 (Changes by Graf Zahl) - Fixed: Decals could spread to walls which had a decal-less texture or were flagged not to have decals. diff --git a/src/actionspecials.h b/src/actionspecials.h index 98c899f5bb..417c823b16 100644 --- a/src/actionspecials.h +++ b/src/actionspecials.h @@ -55,6 +55,7 @@ DEFINE_SPECIAL(Line_SetTextureOffset, 53, 5, 5, 5) DEFINE_SPECIAL(Sector_ChangeFlags, 54, 3, 3, 3) DEFINE_SPECIAL(Line_SetBlocking, 55, 3, 3, 3) DEFINE_SPECIAL(Line_SetTextureScale, 56, 5, 5, 5) +DEFINE_SPECIAL(Sector_SetPortal, 57, -1, -1, 5) DEFINE_SPECIAL(Plat_PerpetualRaise, 60, 3, 3, 3) DEFINE_SPECIAL(Plat_Stop, 61, 1, 1, 1) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 798f314e31..c152bf44d1 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -89,16 +89,24 @@ public: class ASkyViewpoint : public AActor { DECLARE_CLASS (ASkyViewpoint, AActor) + HAS_OBJECT_POINTERS public: void Serialize (FArchive &arc); void BeginPlay (); void Destroy (); bool bInSkybox; bool bAlways; - ASkyViewpoint *Mate; + TObjPtr Mate; fixed_t PlaneAlpha; }; +class AStackPoint : public ASkyViewpoint +{ + DECLARE_CLASS (AStackPoint, ASkyViewpoint) +public: + void BeginPlay (); +}; + class DFlashFader : public DThinker { DECLARE_CLASS (DFlashFader, DThinker) diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index 77704dd500..cfe024b48e 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -38,7 +38,9 @@ // arg0 = Visibility*4 for this skybox -IMPLEMENT_CLASS (ASkyViewpoint) +IMPLEMENT_POINTY_CLASS (ASkyViewpoint) + DECLARE_POINTER(Mate) +END_POINTERS // If this actor has no TID, make it the default sky box void ASkyViewpoint::BeginPlay () @@ -144,13 +146,6 @@ void ASkyPicker::PostBeginPlay () // arg0 = opacity of plane; 0 = invisible, 255 = fully opaque -class AStackPoint : public ASkyViewpoint -{ - DECLARE_CLASS (AStackPoint, ASkyViewpoint) -public: - void BeginPlay (); -}; - IMPLEMENT_CLASS (AStackPoint) void AStackPoint::BeginPlay () diff --git a/src/p_spec.cpp b/src/p_spec.cpp index bce0bcb30b..1571ef31ba 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -59,6 +59,7 @@ #include "statnums.h" #include "g_level.h" #include "v_font.h" +#include "a_sharedglobal.h" // State. #include "r_state.h" @@ -827,6 +828,50 @@ void DWallLightTransfer::DoTransfer (BYTE lightlevel, int target, BYTE flags) } } +void P_SpawnPortal(line_t *line, int sectortag, INTBOOL ceiling, int alpha) +{ + for (int i=0;iv1->x + line->v2->x) >> 1; + fixed_t y1 = (line->v1->y + line->v2->y) >> 1; + fixed_t x2 = (lines[i].v1->x + lines[i].v2->x) >> 1; + fixed_t y2 = (lines[i].v1->y + lines[i].v2->y) >> 1; + + AStackPoint *anchor = Spawn(x1, y1, 0, NO_REPLACE); + AStackPoint *reference = Spawn(x2, y2, 0, NO_REPLACE); + + reference->Mate = anchor; + anchor->Mate = reference; + + // This is so that the renderer can distinguish these portals from + // the ones spawned with the '*StackLookOnly' things. + reference->flags |= MF_JUSTATTACKED; + anchor->flags |= MF_JUSTATTACKED; + + for (int s=-1; (s = P_FindSectorFromTag(sectortag,s)) >= 0;) + { + if (ceiling) + { + if (sectors[s].CeilingSkyBox == NULL) sectors[s].CeilingSkyBox = reference; + } + else + { + if (sectors[s].FloorSkyBox == NULL) sectors[s].FloorSkyBox = reference; + } + } + return; + } + } +} + // // P_SpawnSpecials @@ -1049,6 +1094,18 @@ void P_SpawnSpecials (void) } break; + case Sector_SetPortal: + // arg 0 = sector tag + // arg 1 = type (must be 0, other values reserved for later use) + // arg 2 = 0:floor, 1:ceiling + // arg 3 = 0: anchor, 1: reference line + // arg 4 = for the anchor only: alpha + if (lines[i].args[1] == 0 && lines[i].args[3] == 0) + { + P_SpawnPortal(&lines[i], lines[i].args[0], lines[i].args[2], lines[i].args[4]); + } + break; + // [RH] ZDoom Static_Init settings case Static_Init: switch (lines[i].args[1])