2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** p_xlat.cpp
|
|
|
|
** Translate old Doom format maps to the Hexen format
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2007-01-28 04:59:04 +00:00
|
|
|
** Copyright 1998-2007 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "doomdata.h"
|
|
|
|
#include "r_data.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "p_spec.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "w_wad.h"
|
2006-10-25 16:21:08 +00:00
|
|
|
#include "sc_man.h"
|
|
|
|
#include "cmdlib.h"
|
2008-03-19 21:09:53 +00:00
|
|
|
#include "xlat/xlat.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// define names for the TriggerType field of the general linedefs
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
WalkOnce,
|
|
|
|
WalkMany,
|
|
|
|
SwitchOnce,
|
|
|
|
SwitchMany,
|
|
|
|
GunOnce,
|
|
|
|
GunMany,
|
|
|
|
PushOnce,
|
|
|
|
PushMany,
|
|
|
|
} triggertype_e;
|
|
|
|
|
|
|
|
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
|
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
unsigned short special = (unsigned short) LittleShort(mld->special);
|
2006-02-24 04:48:15 +00:00
|
|
|
short tag = LittleShort(mld->tag);
|
|
|
|
DWORD flags = LittleShort(mld->flags);
|
2006-09-14 00:02:31 +00:00
|
|
|
INTBOOL passthrough;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (flags & ML_TRANSLUCENT_STRIFE)
|
|
|
|
{
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->Alpha = FRACUNIT*3/4;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (gameinfo.gametype == GAME_Strife)
|
|
|
|
{
|
|
|
|
if (flags & ML_RAILING_STRIFE)
|
|
|
|
{
|
|
|
|
flags |= ML_RAILING;
|
|
|
|
}
|
|
|
|
if (flags & ML_BLOCK_FLOATERS_STRIFE)
|
|
|
|
{
|
|
|
|
flags |= ML_BLOCK_FLOATERS;
|
|
|
|
}
|
|
|
|
passthrough = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-30 19:44:19 +00:00
|
|
|
if (gameinfo.gametype & GAME_DoomChex)
|
2006-05-17 02:19:20 +00:00
|
|
|
{
|
|
|
|
if (flags & ML_RESERVED_ETERNITY)
|
|
|
|
{
|
|
|
|
flags &= 0x1FF;
|
|
|
|
}
|
|
|
|
}
|
2008-03-18 18:18:18 +00:00
|
|
|
if (flags & ML_3DMIDTEX_ETERNITY)
|
|
|
|
{
|
|
|
|
flags |= ML_3DMIDTEX;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
passthrough = (flags & ML_PASSUSE_BOOM);
|
|
|
|
}
|
|
|
|
flags = flags & 0xFFFF01FF; // Ignore flags unknown to DOOM
|
|
|
|
|
|
|
|
// For purposes of maintaining BOOM compatibility, each
|
|
|
|
// line also needs to have its ID set to the same as its tag.
|
|
|
|
// An external conversion program would need to do this more
|
|
|
|
// intelligently.
|
|
|
|
ld->id = tag;
|
|
|
|
|
|
|
|
// 0 specials are never translated.
|
|
|
|
if (special == 0)
|
|
|
|
{
|
|
|
|
ld->special = 0;
|
|
|
|
ld->flags = flags;
|
|
|
|
ld->args[0] = mld->tag;
|
|
|
|
memset (ld->args+1, 0, sizeof(ld->args)-sizeof(ld->args[0]));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
FLineTrans *linetrans = NULL;
|
|
|
|
if (special < SimpleLineTranslations.Size()) linetrans = &SimpleLineTranslations[special];
|
|
|
|
if (linetrans != NULL && linetrans->special != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
ld->special = linetrans->special;
|
|
|
|
ld->args[0] = linetrans->args[0];
|
|
|
|
ld->args[1] = linetrans->args[1];
|
|
|
|
ld->args[2] = linetrans->args[2];
|
|
|
|
ld->args[3] = linetrans->args[3];
|
|
|
|
ld->args[4] = linetrans->args[4];
|
|
|
|
|
|
|
|
ld->flags = flags | ((linetrans->flags & 0x1f) << 9);
|
2008-05-02 10:55:48 +00:00
|
|
|
if (linetrans->flags & 0x20) ld->flags |= ML_FIRSTSIDEONLY;
|
|
|
|
ld->activation = 1 << GET_SPAC(ld->flags);
|
|
|
|
if (ld->activation == SPAC_AnyCross) ld->activation = SPAC_Impact|SPAC_PCross; // this is really PTouch
|
|
|
|
ld->flags &= ~ML_SPAC_MASK;
|
2008-03-19 21:09:53 +00:00
|
|
|
|
2008-05-02 10:55:48 +00:00
|
|
|
if (passthrough && ld->activation == SPAC_Use)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->activation = SPAC_UseThrough;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-02 10:55:48 +00:00
|
|
|
switch (linetrans->flags & LINETRANS_TAGMASK)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
case LINETRANS_HAS2TAGS: // First two arguments are tags
|
|
|
|
ld->args[1] = tag;
|
|
|
|
case LINETRANS_HASTAGAT1: // First argument is a tag
|
|
|
|
ld->args[0] = tag;
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
case LINETRANS_HASTAGAT2: // Second argument is a tag
|
|
|
|
ld->args[1] = tag;
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
case LINETRANS_HASTAGAT3: // Third argument is a tag
|
|
|
|
ld->args[2] = tag;
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
case LINETRANS_HASTAGAT4: // Fourth argument is a tag
|
|
|
|
ld->args[3] = tag;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LINETRANS_HASTAGAT5: // Fifth argument is a tag
|
|
|
|
ld->args[4] = tag;
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-02 10:55:48 +00:00
|
|
|
if ((ld->flags & ML_SECRET) && ld->activation & (SPAC_Use|SPAC_UseThrough))
|
2008-03-19 21:09:53 +00:00
|
|
|
{
|
|
|
|
ld->flags &= ~ML_MONSTERSCANACTIVATE;
|
|
|
|
}
|
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
for(int i=0;i<NumBoomish;i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
FBoomTranslator *b = &Boomish[i];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
if (special >= b->FirstLinetype && special <= b->LastLinetype)
|
|
|
|
{
|
|
|
|
ld->special = b->NewSpecial;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
switch (special & 0x0007)
|
|
|
|
{
|
|
|
|
case WalkMany:
|
|
|
|
flags |= ML_REPEAT_SPECIAL;
|
|
|
|
case WalkOnce:
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->activation = SPAC_Cross;
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SwitchMany:
|
|
|
|
case PushMany:
|
|
|
|
flags |= ML_REPEAT_SPECIAL;
|
|
|
|
case SwitchOnce:
|
|
|
|
case PushOnce:
|
|
|
|
if (passthrough)
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->activation = SPAC_UseThrough;
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->activation = SPAC_Use;
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GunMany:
|
|
|
|
flags |= ML_REPEAT_SPECIAL;
|
|
|
|
case GunOnce:
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->activation = SPAC_Impact;
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ld->args[0] = tag;
|
|
|
|
ld->args[1] = ld->args[2] = ld->args[3] = ld->args[4] = 0;
|
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
for(unsigned j=0; j < b->Args.Size(); j++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
FBoomArg *arg = &b->Args[j];
|
2006-04-16 13:29:50 +00:00
|
|
|
int *destp;
|
|
|
|
int flagtemp;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE val = 0; // quiet, GCC
|
|
|
|
bool found;
|
|
|
|
|
2008-03-19 21:09:53 +00:00
|
|
|
if (arg->ArgNum < 4)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
destp = &ld->args[arg->ArgNum+1];
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
flagtemp = ((flags >> 9) & 0x3f);
|
2006-02-24 04:48:15 +00:00
|
|
|
destp = &flagtemp;
|
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
if (arg->ListSize == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
val = arg->ConstantValue;
|
2006-02-24 04:48:15 +00:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
found = false;
|
2008-03-19 21:09:53 +00:00
|
|
|
for (int k = 0; k < arg->ListSize; k++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
if ((special & arg->AndValue) == arg->ResultFilter[k])
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
val = arg->ResultValue[k];
|
2006-02-24 04:48:15 +00:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
if (arg->bOrExisting)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
*destp |= val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*destp = val;
|
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
if (arg->ArgNum == 4)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
flags = (flags & ~0x7e00) | (flagtemp << 9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
// We treat push triggers like switch triggers with zero tags.
|
|
|
|
if ((special & 7) == PushMany || (special & 7) == PushOnce)
|
|
|
|
{
|
|
|
|
if (ld->special == Generic_Door)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-19 21:09:53 +00:00
|
|
|
ld->args[2] |= 128;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ld->args[0] = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
ld->flags = flags;
|
2008-05-02 10:55:48 +00:00
|
|
|
if (flags & ML_MONSTERSCANACTIVATE && ld->activation == SPAC_Cross)
|
|
|
|
{
|
|
|
|
// In Boom anything can activate such a line so set the proper type here.
|
|
|
|
ld->activation = SPAC_AnyCross;
|
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
return;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Don't know what to do, so 0 it
|
|
|
|
ld->special = 0;
|
|
|
|
ld->flags = flags;
|
|
|
|
memset (ld->args, 0, sizeof(ld->args));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that ZDoom again gives the option of using Doom's original teleport
|
|
|
|
// behavior, only teleport dests in a sector with a 0 tag need to be
|
|
|
|
// given a TID. And since Doom format maps don't have TIDs, we can safely
|
|
|
|
// give them TID 1.
|
|
|
|
|
|
|
|
void P_TranslateTeleportThings ()
|
|
|
|
{
|
2008-08-08 19:47:18 +00:00
|
|
|
AActor *dest;
|
|
|
|
TThinkerIterator<AActor> iterator(NAME_TeleportDest);
|
2006-02-24 04:48:15 +00:00
|
|
|
bool foundSomething = false;
|
|
|
|
|
|
|
|
while ( (dest = iterator.Next()) )
|
|
|
|
{
|
|
|
|
if (dest->Sector->tag == 0)
|
|
|
|
{
|
|
|
|
dest->tid = 1;
|
|
|
|
dest->AddToHash ();
|
|
|
|
foundSomething = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (foundSomething)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < numlines; ++i)
|
|
|
|
{
|
|
|
|
if (lines[i].special == Teleport)
|
|
|
|
{
|
|
|
|
if (lines[i].args[1] == 0)
|
|
|
|
{
|
|
|
|
lines[i].args[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lines[i].special == Teleport_NoFog)
|
|
|
|
{
|
|
|
|
if (lines[i].args[2] == 0)
|
|
|
|
{
|
|
|
|
lines[i].args[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
2006-04-11 08:36:23 +00:00
|
|
|
else if (lines[i].special == Teleport_ZombieChanger)
|
|
|
|
{
|
2006-06-21 11:47:27 +00:00
|
|
|
if (lines[i].args[1] == 0)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
|
|
|
lines[i].args[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-25 16:21:08 +00:00
|
|
|
int P_TranslateSectorSpecial (int special)
|
|
|
|
{
|
2008-03-23 00:23:47 +00:00
|
|
|
int mask = 0;
|
2006-10-25 16:21:08 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
for(int i = SectorMasks.Size()-1; i>=0; i--)
|
2006-10-25 16:21:08 +00:00
|
|
|
{
|
2008-03-23 00:23:47 +00:00
|
|
|
int newmask = special & SectorMasks[i].mask;
|
|
|
|
if (newmask)
|
|
|
|
{
|
|
|
|
special &= ~newmask;
|
|
|
|
if (SectorMasks[i].op == 1) newmask <<= SectorMasks[i].shift;
|
|
|
|
else if (SectorMasks[i].op == -1) newmask >>= SectorMasks[i].shift;
|
2008-03-23 20:52:34 +00:00
|
|
|
else if (SectorMasks[i].op == 0 && SectorMasks[i].shift ==1) newmask = 0;
|
2008-03-23 00:23:47 +00:00
|
|
|
mask |= newmask;
|
|
|
|
}
|
2006-10-25 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
2008-03-27 04:25:52 +00:00
|
|
|
if ((unsigned)special < SectorTranslations.Size())
|
2008-03-23 00:23:47 +00:00
|
|
|
{
|
|
|
|
if (SectorTranslations[special].bitmask_allowed && mask) special = 0;
|
|
|
|
else special = SectorTranslations[special].newtype;
|
|
|
|
}
|
|
|
|
return special | mask;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-03-19 21:09:53 +00:00
|
|
|
|