- added Line_SetPortalTarget action special so that portals can be assigned new targets. Setting the target to 0 disables the portal.cpp. Static linked portals can not be reassigned.
Please note that these still require the portal to be set up in the map with Line_SetPortal. It will not create a new portal if none exists on any line with the given ID.
This commit is contained in:
parent
0ab3051f75
commit
77b9f41dff
4 changed files with 67 additions and 16 deletions
|
|
@ -29,6 +29,24 @@ FArchive &operator<< (FArchive &arc, FLinePortal &port)
|
|||
}
|
||||
|
||||
|
||||
static line_t *FindDestination(line_t *src, int tag)
|
||||
{
|
||||
if (tag)
|
||||
{
|
||||
int lineno = -1;
|
||||
FLineIdIterator it(tag);
|
||||
|
||||
while ((lineno = it.Next()) >= 0)
|
||||
{
|
||||
if (&lines[lineno] != src)
|
||||
{
|
||||
return &lines[lineno];
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void P_SpawnLinePortal(line_t* line)
|
||||
{
|
||||
// portal destination is special argument #0
|
||||
|
|
@ -36,21 +54,7 @@ void P_SpawnLinePortal(line_t* line)
|
|||
|
||||
if (line->args[2] >= PORTT_VISUAL && line->args[2] <= PORTT_LINKED)
|
||||
{
|
||||
if (line->args[0] > 0)
|
||||
{
|
||||
int linenum = -1;
|
||||
|
||||
for (int i = 0; i < numlines; i++)
|
||||
{
|
||||
if (&lines[i] == line)
|
||||
continue;
|
||||
if (tagManager.LineHasID(&lines[i], line->args[0]))
|
||||
{
|
||||
dst = &lines[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dst = FindDestination(line, line->args[0]);
|
||||
|
||||
line->portalindex = linePortals.Reserve(1);
|
||||
FLinePortal *port = &linePortals.Last();
|
||||
|
|
@ -156,6 +160,45 @@ void P_FinalizePortals()
|
|||
}
|
||||
}
|
||||
|
||||
static bool ChangePortalLine(line_t *line, int destid)
|
||||
{
|
||||
if (line->portalindex >= linePortals.Size()) return false;
|
||||
FLinePortal *port = &linePortals[line->portalindex];
|
||||
if (port->mType == PORTT_LINKED) return false; // linked portals cannot be changed.
|
||||
port->mDestination = FindDestination(line, destid);
|
||||
if (port->mType == PORTT_INTERACTIVE)
|
||||
{
|
||||
FLinePortal *portd = &linePortals[port->mDestination->portalindex];
|
||||
if (portd != NULL && portd->mType == PORTT_INTERACTIVE && portd->mDestination == line)
|
||||
{
|
||||
// this is a 2-way interactive portal
|
||||
port->mFlags = port->mDefFlags | PORTF_INTERACTIVE;
|
||||
portd->mFlags = portd->mDefFlags | PORTF_INTERACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
port->mFlags = port->mDefFlags;
|
||||
portd->mFlags = portd->mDefFlags;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool P_ChangePortal(line_t *ln, int thisid, int destid)
|
||||
{
|
||||
int lineno;
|
||||
|
||||
if (thisid == 0) return ChangePortalLine(ln, destid);
|
||||
FLineIdIterator it(thisid);
|
||||
bool res = false;
|
||||
while ((lineno = it.Next()) >= 0)
|
||||
{
|
||||
res |= ChangePortalLine(&lines[lineno], destid);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// [ZZ] lots of floats here to avoid overflowing a lot
|
||||
bool P_IntersectLines(fixed_t o1x, fixed_t o1y, fixed_t p1x, fixed_t p1y,
|
||||
fixed_t o2x, fixed_t o2y, fixed_t p2x, fixed_t p2y,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue