2008-05-11 21:16:32 +00:00
|
|
|
/*
|
|
|
|
** p_udmf.cpp
|
|
|
|
**
|
|
|
|
** UDMF text map parser
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2008 Christoph Oelckers
|
|
|
|
** 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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2011-07-06 14:20:54 +00:00
|
|
|
#include "doomstat.h"
|
2008-05-11 21:16:32 +00:00
|
|
|
#include "p_setup.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
2008-05-22 19:35:38 +00:00
|
|
|
#include "gi.h"
|
2008-06-15 18:36:26 +00:00
|
|
|
#include "r_sky.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_palette.h"
|
2010-08-20 12:20:51 +00:00
|
|
|
#include "p_udmf.h"
|
2011-07-05 10:02:38 +00:00
|
|
|
#include "r_state.h"
|
2011-07-06 07:35:36 +00:00
|
|
|
#include "r_data/colormaps.h"
|
2012-10-22 01:28:11 +00:00
|
|
|
#include "w_wad.h"
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Maps for Hexen namespace need to filter out all extended line and sector
|
|
|
|
// specials to comply with the spec.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
static char HexenLineSpecialOk[]={
|
|
|
|
1,1,1,1,1,1,1,1,1,0, // 0-9
|
|
|
|
1,1,1,1,0,0,0,0,0,0, // 10-19
|
|
|
|
1,1,1,1,1,1,1,1,1,1, // 20-29
|
|
|
|
1,1,1,0,0,1,1,0,0,0, // 30-39
|
|
|
|
1,1,1,1,1,1,1,0,0,0, // 40-49
|
|
|
|
0,0,0,0,0,0,0,0,0,0, // 50-59
|
|
|
|
1,1,1,1,1,1,1,1,1,1, // 60-69
|
|
|
|
1,1,1,1,1,1,0,0,0,0, // 70-79
|
|
|
|
1,1,1,1,0,0,0,0,0,0, // 80-89
|
|
|
|
1,1,1,1,1,1,1,0,0,0, // 90-99
|
|
|
|
1,1,1,1,0,0,0,0,0,1, // 100-109
|
|
|
|
1,1,1,1,1,1,1,0,0,0, // 110-119
|
|
|
|
1,0,0,0,0,0,0,0,0,1, // 120-129
|
|
|
|
1,1,1,1,1,1,1,1,1,0, // 130-139
|
|
|
|
1
|
|
|
|
// 140 is the highest valid special in Hexen.
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static char HexenSectorSpecialOk[256]={
|
|
|
|
1,1,1,1,1,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,1,1,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
|
|
1,1,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
|
|
1,1,1,1,1,
|
|
|
|
};
|
|
|
|
|
2012-11-09 23:25:56 +00:00
|
|
|
static inline bool P_IsThingSpecial(int specnum)
|
|
|
|
{
|
|
|
|
return (specnum >= Thing_Projectile && specnum <= Thing_SpawnNoFog) ||
|
|
|
|
specnum == Thing_SpawnFacing || Thing_ProjectileIntercept || Thing_ProjectileAimed;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Dm=1,
|
|
|
|
Ht=2,
|
|
|
|
Hx=4,
|
|
|
|
St=8,
|
|
|
|
Zd=16,
|
|
|
|
Zdt=32,
|
2009-03-11 19:28:10 +00:00
|
|
|
Va=64,
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
// will be extended later. Unknown namespaces will always be treated like the base
|
|
|
|
// namespace for each game
|
|
|
|
};
|
|
|
|
|
2014-05-16 20:48:37 +00:00
|
|
|
void SetTexture (sector_t *sector, int index, int position, const char *name, FMissingTextureTracker &, bool truncate);
|
|
|
|
void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmapsidedef_t *msd, int special, int tag, short *alpha, FMissingTextureTracker &);
|
2008-05-11 21:16:32 +00:00
|
|
|
void P_AdjustLine (line_t *ld);
|
|
|
|
void P_FinishLoadingLineDef(line_t *ld, int alpha);
|
|
|
|
void SpawnMapThing(int index, FMapThing *mt, int position);
|
|
|
|
extern bool ForceNodeBuild;
|
|
|
|
extern TArray<FMapThing> MapThingsConverted;
|
|
|
|
extern TArray<int> linemap;
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
#define CHECK_N(f) if (!(namespace_bits&(f))) break;
|
|
|
|
|
2009-05-11 21:05:40 +00:00
|
|
|
|
2010-08-20 12:20:51 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Common parsing routines
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Skip a key or block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void UDMFParserBase::Skip()
|
|
|
|
{
|
|
|
|
if (developer) sc.ScriptMessage("Ignoring unknown key \"%s\".", sc.String);
|
|
|
|
if(sc.CheckToken('{'))
|
|
|
|
{
|
|
|
|
int level = 1;
|
|
|
|
while(sc.GetToken())
|
|
|
|
{
|
|
|
|
if (sc.TokenType == '}')
|
|
|
|
{
|
|
|
|
level--;
|
|
|
|
if(level == 0)
|
|
|
|
{
|
|
|
|
sc.UnGet();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sc.TokenType == '{')
|
|
|
|
{
|
|
|
|
level++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sc.MustGetToken('=');
|
|
|
|
do
|
|
|
|
{
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
}
|
|
|
|
while(sc.TokenType != ';');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parses a 'key = value' line of the map
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
FName UDMFParserBase::ParseKey(bool checkblock, bool *isblock)
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
FName key = sc.String;
|
|
|
|
if (checkblock)
|
|
|
|
{
|
|
|
|
if (sc.CheckToken('{'))
|
|
|
|
{
|
|
|
|
if (isblock) *isblock = true;
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
else if (isblock) *isblock = false;
|
|
|
|
}
|
|
|
|
sc.MustGetToken('=');
|
|
|
|
|
|
|
|
sc.Number = 0;
|
|
|
|
sc.Float = 0;
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
|
|
|
|
if (sc.TokenType == '+' || sc.TokenType == '-')
|
|
|
|
{
|
|
|
|
bool neg = (sc.TokenType == '-');
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst && sc.TokenType != TK_FloatConst)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Numeric constant expected");
|
|
|
|
}
|
|
|
|
if (neg)
|
|
|
|
{
|
|
|
|
sc.Number = -sc.Number;
|
|
|
|
sc.Float = -sc.Float;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sc.TokenType == TK_StringConst)
|
|
|
|
{
|
|
|
|
parsedString = sc.String;
|
|
|
|
}
|
|
|
|
int savedtoken = sc.TokenType;
|
|
|
|
sc.MustGetToken(';');
|
|
|
|
sc.TokenType = savedtoken;
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Syntax checks
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
int UDMFParserBase::CheckInt(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_IntConst)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Integer value expected for key '%s'", key);
|
|
|
|
}
|
|
|
|
return sc.Number;
|
|
|
|
}
|
|
|
|
|
|
|
|
double UDMFParserBase::CheckFloat(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_IntConst && sc.TokenType != TK_FloatConst)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Floating point value expected for key '%s'", key);
|
|
|
|
}
|
|
|
|
return sc.Float;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t UDMFParserBase::CheckFixed(const char *key)
|
|
|
|
{
|
|
|
|
return FLOAT2FIXED(CheckFloat(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
angle_t UDMFParserBase::CheckAngle(const char *key)
|
|
|
|
{
|
|
|
|
return angle_t(CheckFloat(key) * ANGLE_90 / 90.);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UDMFParserBase::CheckBool(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType == TK_True) return true;
|
|
|
|
if (sc.TokenType == TK_False) return false;
|
|
|
|
sc.ScriptMessage("Boolean value expected for key '%s'", key);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *UDMFParserBase::CheckString(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_StringConst)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("String value expected for key '%s'", key);
|
|
|
|
}
|
|
|
|
return parsedString;
|
|
|
|
}
|
|
|
|
|
2009-05-11 21:05:40 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Storage of UDMF user properties
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
typedef TMap<int, FUDMFKeys> FUDMFKeyMap;
|
|
|
|
|
|
|
|
|
|
|
|
static FUDMFKeyMap UDMFKeys[4];
|
|
|
|
// Things must be handled differently
|
|
|
|
|
|
|
|
void P_ClearUDMFKeys()
|
|
|
|
{
|
|
|
|
for(int i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
UDMFKeys[i].Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int STACK_ARGS udmfcmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
FUDMFKey *A = (FUDMFKey*)a;
|
|
|
|
FUDMFKey *B = (FUDMFKey*)b;
|
|
|
|
|
|
|
|
return int(A->Key) - int(B->Key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FUDMFKeys::Sort()
|
|
|
|
{
|
|
|
|
qsort(&(*this)[0], Size(), sizeof(FUDMFKey), udmfcmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
FUDMFKey *FUDMFKeys::Find(FName key)
|
|
|
|
{
|
|
|
|
int min = 0, max = Size()-1;
|
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
int mid = (min + max) / 2;
|
|
|
|
if ((*this)[mid].Key == key)
|
|
|
|
{
|
|
|
|
return &(*this)[mid];
|
|
|
|
}
|
|
|
|
else if ((*this)[mid].Key <= key)
|
|
|
|
{
|
|
|
|
min = mid + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max = mid - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Retrieves UDMF user properties
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
int GetUDMFInt(int type, int index, const char *key)
|
|
|
|
{
|
|
|
|
assert(type >=0 && type <=3);
|
|
|
|
|
2015-02-21 02:42:30 +00:00
|
|
|
FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index);
|
2009-05-11 21:05:40 +00:00
|
|
|
|
2015-02-21 02:42:30 +00:00
|
|
|
if (pKeys != NULL)
|
|
|
|
{
|
|
|
|
FUDMFKey *pKey = pKeys->Find(key);
|
|
|
|
if (pKey != NULL)
|
2009-05-11 21:05:40 +00:00
|
|
|
{
|
2015-02-21 02:42:30 +00:00
|
|
|
return pKey->IntVal;
|
2009-05-11 21:05:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t GetUDMFFixed(int type, int index, const char *key)
|
|
|
|
{
|
|
|
|
assert(type >=0 && type <=3);
|
|
|
|
|
2015-02-21 02:42:30 +00:00
|
|
|
FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index);
|
2009-05-11 21:05:40 +00:00
|
|
|
|
2015-02-21 02:42:30 +00:00
|
|
|
if (pKeys != NULL)
|
|
|
|
{
|
|
|
|
FUDMFKey *pKey = pKeys->Find(key);
|
|
|
|
if (pKey != NULL)
|
2009-05-11 21:05:40 +00:00
|
|
|
{
|
2015-02-21 02:42:30 +00:00
|
|
|
return FLOAT2FIXED(pKey->FloatVal);
|
2009-05-11 21:05:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// UDMF parser
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2010-08-20 12:20:51 +00:00
|
|
|
class UDMFParser : public UDMFParserBase
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
bool isTranslated;
|
|
|
|
bool isExtended;
|
2008-05-22 19:35:38 +00:00
|
|
|
bool floordrop;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
TArray<line_t> ParsedLines;
|
|
|
|
TArray<side_t> ParsedSides;
|
2014-05-16 20:48:37 +00:00
|
|
|
TArray<intmapsidedef_t> ParsedSideTextures;
|
2008-05-11 21:16:32 +00:00
|
|
|
TArray<sector_t> ParsedSectors;
|
|
|
|
TArray<vertex_t> ParsedVertices;
|
2010-12-14 00:56:44 +00:00
|
|
|
TArray<vertexdata_t> ParsedVertexDatas;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
FDynamicColormap *fogMap, *normMap;
|
2011-05-08 00:30:32 +00:00
|
|
|
FMissingTextureTracker &missingTex;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2010-08-20 12:20:51 +00:00
|
|
|
public:
|
2011-05-08 00:30:32 +00:00
|
|
|
UDMFParser(FMissingTextureTracker &missing)
|
|
|
|
: missingTex(missing)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
linemap.Clear();
|
|
|
|
fogMap = normMap = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-11 21:05:40 +00:00
|
|
|
void AddUserKey(FName key, int kind, int index)
|
|
|
|
{
|
|
|
|
FUDMFKeys &keyarray = UDMFKeys[kind][index];
|
|
|
|
|
|
|
|
for(unsigned i=0; i < keyarray.Size(); i++)
|
|
|
|
{
|
|
|
|
if (keyarray[i].Key == key)
|
|
|
|
{
|
|
|
|
switch (sc.TokenType)
|
|
|
|
{
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_IntConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
keyarray[i] = sc.Number;
|
|
|
|
break;
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_FloatConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
keyarray[i] = sc.Float;
|
|
|
|
break;
|
|
|
|
default:
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_StringConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
keyarray[i] = parsedString;
|
|
|
|
break;
|
|
|
|
case TK_True:
|
|
|
|
keyarray[i] = 1;
|
|
|
|
break;
|
|
|
|
case TK_False:
|
|
|
|
keyarray[i] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FUDMFKey ukey;
|
|
|
|
ukey.Key = key;
|
|
|
|
switch (sc.TokenType)
|
|
|
|
{
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_IntConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
ukey = sc.Number;
|
|
|
|
break;
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_FloatConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
ukey = sc.Float;
|
|
|
|
break;
|
|
|
|
default:
|
2012-02-21 22:11:52 +00:00
|
|
|
case TK_StringConst:
|
2009-05-11 21:05:40 +00:00
|
|
|
ukey = parsedString;
|
|
|
|
break;
|
|
|
|
case TK_True:
|
|
|
|
ukey = 1;
|
|
|
|
break;
|
|
|
|
case TK_False:
|
|
|
|
ukey = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
keyarray.Push(ukey);
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parse a thing block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseThing(FMapThing *th)
|
|
|
|
{
|
2012-11-09 23:25:56 +00:00
|
|
|
FString arg0str, arg1str;
|
2012-02-26 02:32:45 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
memset(th, 0, sizeof(*th));
|
2013-08-09 14:25:16 +00:00
|
|
|
th->gravity = FRACUNIT;
|
2014-04-10 22:58:59 +00:00
|
|
|
th->RenderStyle = STYLE_Count;
|
|
|
|
th->alpha = -1;
|
|
|
|
th->health = 1;
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken('{');
|
|
|
|
while (!sc.CheckToken('}'))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
FName key = ParseKey();
|
2008-05-11 21:16:32 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Id:
|
|
|
|
th->thingid = CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_X:
|
2008-05-22 19:35:38 +00:00
|
|
|
th->x = CheckFixed(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Y:
|
2008-05-22 19:35:38 +00:00
|
|
|
th->y = CheckFixed(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Height:
|
2008-05-22 19:35:38 +00:00
|
|
|
th->z = CheckFixed(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Angle:
|
2008-05-22 19:35:38 +00:00
|
|
|
th->angle = (short)CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Type:
|
2015-04-04 08:25:01 +00:00
|
|
|
th->EdNum = (short)CheckInt(key);
|
|
|
|
th->info = DoomEdMap.CheckKey(th->EdNum);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2010-08-22 17:18:46 +00:00
|
|
|
case NAME_Conversation:
|
|
|
|
CHECK_N(Zd | Zdt)
|
|
|
|
th->Conversation = CheckInt(key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Special:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
th->special = CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2013-08-09 14:25:16 +00:00
|
|
|
case NAME_Gravity:
|
|
|
|
CHECK_N(Zd | Zdt)
|
|
|
|
th->gravity = CheckFixed(key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Arg0:
|
|
|
|
case NAME_Arg1:
|
|
|
|
case NAME_Arg2:
|
|
|
|
case NAME_Arg3:
|
|
|
|
case NAME_Arg4:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
th->args[int(key)-int(NAME_Arg0)] = CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2012-02-26 02:32:45 +00:00
|
|
|
case NAME_Arg0Str:
|
|
|
|
CHECK_N(Zd);
|
|
|
|
arg0str = CheckString(key);
|
|
|
|
break;
|
|
|
|
|
2012-11-09 23:25:56 +00:00
|
|
|
case NAME_Arg1Str:
|
|
|
|
CHECK_N(Zd);
|
|
|
|
arg1str = CheckString(key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Skill1:
|
|
|
|
case NAME_Skill2:
|
|
|
|
case NAME_Skill3:
|
|
|
|
case NAME_Skill4:
|
|
|
|
case NAME_Skill5:
|
|
|
|
case NAME_Skill6:
|
|
|
|
case NAME_Skill7:
|
|
|
|
case NAME_Skill8:
|
|
|
|
case NAME_Skill9:
|
|
|
|
case NAME_Skill10:
|
|
|
|
case NAME_Skill11:
|
|
|
|
case NAME_Skill12:
|
|
|
|
case NAME_Skill13:
|
|
|
|
case NAME_Skill14:
|
|
|
|
case NAME_Skill15:
|
|
|
|
case NAME_Skill16:
|
2008-05-22 19:35:38 +00:00
|
|
|
if (CheckBool(key)) th->SkillFilter |= (1<<(int(key)-NAME_Skill1));
|
2008-05-11 21:16:32 +00:00
|
|
|
else th->SkillFilter &= ~(1<<(int(key)-NAME_Skill1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Class1:
|
|
|
|
case NAME_Class2:
|
|
|
|
case NAME_Class3:
|
|
|
|
case NAME_Class4:
|
|
|
|
case NAME_Class5:
|
|
|
|
case NAME_Class6:
|
|
|
|
case NAME_Class7:
|
|
|
|
case NAME_Class8:
|
|
|
|
case NAME_Class9:
|
|
|
|
case NAME_Class10:
|
|
|
|
case NAME_Class11:
|
|
|
|
case NAME_Class12:
|
|
|
|
case NAME_Class13:
|
|
|
|
case NAME_Class14:
|
|
|
|
case NAME_Class15:
|
|
|
|
case NAME_Class16:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
if (CheckBool(key)) th->ClassFilter |= (1<<(int(key)-NAME_Class1));
|
2008-08-21 07:08:55 +00:00
|
|
|
else th->ClassFilter &= ~(1<<(int(key)-NAME_Class1));
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Ambush:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_AMBUSH, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Dormant:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_DORMANT, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Single:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_SINGLE, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Coop:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_COOPERATIVE, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Dm:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_DEATHMATCH, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Translucent:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_SHADOW, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Invisible:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_ALTSHADOW, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Friend: // This maps to Strife's friendly flag
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Dm | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_FRIENDLY, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Strifeally:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_FRIENDLY, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Standing:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(th->flags, MTF_STANDSTILL, key);
|
|
|
|
break;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2010-09-19 00:06:45 +00:00
|
|
|
case NAME_Countsecret:
|
|
|
|
CHECK_N(Zd | Zdt | Va)
|
|
|
|
Flag(th->flags, MTF_SECRET, key);
|
|
|
|
break;
|
|
|
|
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_Renderstyle:
|
|
|
|
{
|
|
|
|
FName style = CheckString(key);
|
|
|
|
switch (style)
|
|
|
|
{
|
|
|
|
case NAME_None:
|
|
|
|
th->RenderStyle = STYLE_None;
|
|
|
|
break;
|
|
|
|
case NAME_Normal:
|
|
|
|
th->RenderStyle = STYLE_Normal;
|
|
|
|
break;
|
|
|
|
case NAME_Fuzzy:
|
|
|
|
th->RenderStyle = STYLE_Fuzzy;
|
|
|
|
break;
|
|
|
|
case NAME_SoulTrans:
|
|
|
|
th->RenderStyle = STYLE_SoulTrans;
|
|
|
|
break;
|
|
|
|
case NAME_OptFuzzy:
|
|
|
|
th->RenderStyle = STYLE_OptFuzzy;
|
|
|
|
break;
|
|
|
|
case NAME_Stencil:
|
|
|
|
th->RenderStyle = STYLE_Stencil;
|
|
|
|
break;
|
2014-05-13 19:16:06 +00:00
|
|
|
case NAME_AddStencil:
|
|
|
|
th->RenderStyle = STYLE_AddStencil;
|
|
|
|
break;
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_Translucent:
|
|
|
|
th->RenderStyle = STYLE_Translucent;
|
|
|
|
break;
|
|
|
|
case NAME_Add:
|
|
|
|
case NAME_Additive:
|
|
|
|
th->RenderStyle = STYLE_Add;
|
|
|
|
break;
|
|
|
|
case NAME_Shaded:
|
|
|
|
th->RenderStyle = STYLE_Shaded;
|
|
|
|
break;
|
2014-05-13 19:16:06 +00:00
|
|
|
case NAME_AddShaded:
|
|
|
|
th->RenderStyle = STYLE_AddShaded;
|
|
|
|
break;
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_TranslucentStencil:
|
|
|
|
th->RenderStyle = STYLE_TranslucentStencil;
|
|
|
|
break;
|
|
|
|
case NAME_Shadow:
|
|
|
|
th->RenderStyle = STYLE_Shadow;
|
|
|
|
break;
|
|
|
|
case NAME_Subtract:
|
|
|
|
case NAME_Subtractive:
|
|
|
|
th->RenderStyle = STYLE_Subtract;
|
|
|
|
break;
|
2014-04-12 08:55:10 +00:00
|
|
|
default:
|
|
|
|
break;
|
2014-04-10 22:58:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-10 10:32:23 +00:00
|
|
|
break;
|
|
|
|
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_Alpha:
|
|
|
|
th->alpha = CheckFixed(key);
|
2014-04-10 10:32:23 +00:00
|
|
|
break;
|
|
|
|
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_FillColor:
|
|
|
|
th->fillcolor = CheckInt(key);
|
2014-10-28 20:19:01 +00:00
|
|
|
break;
|
2014-04-10 22:58:59 +00:00
|
|
|
|
|
|
|
case NAME_Health:
|
|
|
|
th->health = CheckInt(key);
|
2014-04-10 10:32:23 +00:00
|
|
|
break;
|
|
|
|
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_Score:
|
|
|
|
th->score = CheckInt(key);
|
2014-04-10 10:32:23 +00:00
|
|
|
break;
|
|
|
|
|
2014-04-10 22:58:59 +00:00
|
|
|
case NAME_Pitch:
|
|
|
|
th->pitch = (short)CheckInt(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Roll:
|
|
|
|
th->roll = (short)CheckInt(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ScaleX:
|
|
|
|
th->scaleX = CheckFixed(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ScaleY:
|
|
|
|
th->scaleY = CheckFixed(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Scale:
|
|
|
|
th->scaleX = th->scaleY = CheckFixed(key);
|
2014-04-10 10:32:23 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
default:
|
2015-04-15 07:43:43 +00:00
|
|
|
CHECK_N(Zd | Zdt)
|
2013-02-17 00:23:58 +00:00
|
|
|
if (0 == strnicmp("user_", key.GetChars(), 5))
|
|
|
|
{ // Custom user key - Sets an actor's user variable directly
|
|
|
|
FMapThingUserData ud;
|
|
|
|
ud.Property = key;
|
|
|
|
ud.Value = CheckInt(key);
|
|
|
|
MapThingsUserData.Push(ud);
|
2009-05-11 21:05:40 +00:00
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-09 23:25:56 +00:00
|
|
|
if (arg0str.IsNotEmpty() && (P_IsACSSpecial(th->special) || th->special == 0))
|
2012-02-26 02:32:45 +00:00
|
|
|
{
|
|
|
|
th->args[0] = -FName(arg0str);
|
|
|
|
}
|
2012-11-09 23:25:56 +00:00
|
|
|
if (arg1str.IsNotEmpty() && (P_IsThingSpecial(th->special) || th->special == 0))
|
|
|
|
{
|
|
|
|
th->args[1] = -FName(arg1str);
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
// Thing specials are only valid in namespaces with Hexen-type specials
|
|
|
|
// and in ZDoomTranslated - which will use the translator on them.
|
|
|
|
if (namespc == NAME_ZDoomTranslated)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
maplinedef_t mld;
|
|
|
|
line_t ld;
|
2008-05-12 17:14:38 +00:00
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
if (th->special != 0) // if special is 0, keep the args (e.g. for bridge things)
|
|
|
|
{
|
|
|
|
// The trigger type is ignored here.
|
2008-05-12 17:14:38 +00:00
|
|
|
mld.flags = 0;
|
|
|
|
mld.special = th->special;
|
|
|
|
mld.tag = th->args[0];
|
|
|
|
P_TranslateLineDef(&ld, &mld);
|
|
|
|
th->special = ld.special;
|
|
|
|
memcpy(th->args, ld.args, sizeof (ld.args));
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
|
|
|
else if (isTranslated)
|
|
|
|
{
|
|
|
|
th->special = 0;
|
|
|
|
memset(th->args, 0, sizeof (th->args));
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parse a linedef block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2009-05-11 21:05:40 +00:00
|
|
|
void ParseLinedef(line_t *ld, int index)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
bool passuse = false;
|
2008-05-22 19:35:38 +00:00
|
|
|
bool strifetrans = false;
|
2014-04-10 10:32:23 +00:00
|
|
|
bool strifetrans2 = false;
|
2012-11-09 23:25:56 +00:00
|
|
|
FString arg0str, arg1str;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
memset(ld, 0, sizeof(*ld));
|
|
|
|
ld->Alpha = FRACUNIT;
|
2015-04-15 07:37:06 +00:00
|
|
|
ld->ClearIds();
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->sidedef[0] = ld->sidedef[1] = NULL;
|
2009-02-03 19:11:43 +00:00
|
|
|
if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
sc.MustGetToken('{');
|
|
|
|
while (!sc.CheckToken('}'))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
FName key = ParseKey();
|
2008-05-12 17:14:38 +00:00
|
|
|
|
|
|
|
// This switch contains all keys of the UDMF base spec
|
2008-05-11 21:16:32 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case NAME_V1:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->v1 = (vertex_t*)(intptr_t)CheckInt(key); // must be relocated later
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_V2:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->v2 = (vertex_t*)(intptr_t)CheckInt(key); // must be relocated later
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Special:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->special = CheckInt(key);
|
|
|
|
if (namespc == NAME_Hexen)
|
|
|
|
{
|
|
|
|
if (ld->special < 0 || ld->special > 140 || !HexenLineSpecialOk[ld->special])
|
|
|
|
ld->special = 0; // NULL all specials which don't exist in Hexen
|
|
|
|
}
|
|
|
|
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Id:
|
2015-04-15 07:37:06 +00:00
|
|
|
ld->SetMainId(CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Sidefront:
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->sidedef[0] = (side_t*)(intptr_t)(1 + CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Sideback:
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->sidedef[1] = (side_t*)(intptr_t)(1 + CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Arg0:
|
|
|
|
case NAME_Arg1:
|
|
|
|
case NAME_Arg2:
|
|
|
|
case NAME_Arg3:
|
|
|
|
case NAME_Arg4:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->args[int(key)-int(NAME_Arg0)] = CheckInt(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2012-02-18 02:39:01 +00:00
|
|
|
case NAME_Arg0Str:
|
|
|
|
CHECK_N(Zd);
|
|
|
|
arg0str = CheckString(key);
|
|
|
|
continue;
|
|
|
|
|
2012-11-09 23:25:56 +00:00
|
|
|
case NAME_Arg1Str:
|
|
|
|
CHECK_N(Zd);
|
|
|
|
arg1str = CheckString(key);
|
|
|
|
continue;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Blocking:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCKING, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Blockmonsters:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCKMONSTERS, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Twosided:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_TWOSIDED, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Dontpegtop:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_DONTPEGTOP, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Dontpegbottom:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_DONTPEGBOTTOM, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Secret:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_SECRET, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
case NAME_Blocksound:
|
|
|
|
Flag(ld->flags, ML_SOUNDBLOCK, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Dontdraw:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_DONTDRAW, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Mapped:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_MAPPED, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Jumpover:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_RAILING, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2009-12-24 23:31:06 +00:00
|
|
|
case NAME_Blockfloaters:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCK_FLOATERS, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2011-10-03 00:36:37 +00:00
|
|
|
case NAME_Translucent:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
strifetrans = CheckBool(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2014-04-10 10:32:23 +00:00
|
|
|
case NAME_Transparent:
|
|
|
|
CHECK_N(St | Zd | Zdt | Va)
|
|
|
|
strifetrans2 = CheckBool(key);
|
|
|
|
continue;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Passuse:
|
2009-03-11 19:28:10 +00:00
|
|
|
CHECK_N(Dm | Zd | Zdt | Va)
|
2008-05-22 19:35:38 +00:00
|
|
|
passuse = CheckBool(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This switch contains all keys of the UDMF base spec which only apply to Hexen format specials
|
|
|
|
if (!isTranslated) switch (key)
|
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Playercross:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_Cross, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Playeruse:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_Use, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2010-04-25 07:21:35 +00:00
|
|
|
case NAME_Playeruseback:
|
|
|
|
Flag(ld->activation, SPAC_UseBack, key);
|
|
|
|
continue;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Monstercross:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_MCross, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Impact:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_Impact, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Playerpush:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_Push, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Missilecross:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_PCross, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Monsteruse:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_MUse, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Monsterpush:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->activation, SPAC_MPush, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
case NAME_Repeatspecial:
|
|
|
|
Flag(ld->flags, ML_REPEAT_SPECIAL, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
// This switch contains all keys which are ZDoom specific
|
2009-03-11 19:28:10 +00:00
|
|
|
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
|
2008-05-12 17:14:38 +00:00
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
case NAME_Alpha:
|
|
|
|
ld->Alpha = CheckFixed(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Renderstyle:
|
|
|
|
{
|
|
|
|
const char *str = CheckString(key);
|
|
|
|
if (!stricmp(str, "translucent")) ld->flags &= ~ML_ADDTRANS;
|
|
|
|
else if (!stricmp(str, "add")) ld->flags |= ML_ADDTRANS;
|
|
|
|
else sc.ScriptMessage("Unknown value \"%s\" for 'renderstyle'\n", str);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
}
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Anycross:
|
|
|
|
Flag(ld->activation, SPAC_AnyCross, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
case NAME_Monsteractivate:
|
|
|
|
Flag(ld->flags, ML_MONSTERSCANACTIVATE, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Blockplayers:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCK_PLAYERS, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Blockeverything:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCKEVERYTHING, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Zoneboundary:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_ZONEBOUNDARY, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Clipmidtex:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_CLIP_MIDTEX, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Wrapmidtex:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_WRAP_MIDTEX, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Midtex3d:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_3DMIDTEX, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Checkswitchrange:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_CHECKSWITCHRANGE, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-12 17:14:38 +00:00
|
|
|
case NAME_Firstsideonly:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_FIRSTSIDEONLY, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2009-02-22 15:39:42 +00:00
|
|
|
case NAME_blockprojectiles:
|
|
|
|
Flag(ld->flags, ML_BLOCKPROJECTILE, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2009-02-22 15:39:42 +00:00
|
|
|
|
2009-04-28 20:53:07 +00:00
|
|
|
case NAME_blockuse:
|
|
|
|
Flag(ld->flags, ML_BLOCKUSE, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2009-04-28 20:53:07 +00:00
|
|
|
|
2012-02-18 02:39:01 +00:00
|
|
|
case NAME_blocksight:
|
|
|
|
Flag(ld->flags, ML_BLOCKSIGHT, key);
|
|
|
|
continue;
|
|
|
|
|
2013-08-09 18:35:10 +00:00
|
|
|
case NAME_blockhitscan:
|
|
|
|
Flag(ld->flags, ML_BLOCKHITSCAN, key);
|
|
|
|
continue;
|
|
|
|
|
2014-09-28 14:17:19 +00:00
|
|
|
// [TP] Locks the special with a key
|
2012-02-18 02:39:01 +00:00
|
|
|
case NAME_Locknumber:
|
|
|
|
ld->locknumber = CheckInt(key);
|
|
|
|
continue;
|
|
|
|
|
2014-09-28 14:17:19 +00:00
|
|
|
// [TP] Causes a 3d midtex to behave like an impassible line
|
|
|
|
case NAME_Midtex3dimpassible:
|
|
|
|
Flag(ld->flags, ML_3DMIDTEX_IMPASS, key);
|
|
|
|
continue;
|
|
|
|
|
2012-02-18 02:39:01 +00:00
|
|
|
default:
|
|
|
|
break;
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2009-05-11 21:05:40 +00:00
|
|
|
|
2015-04-15 07:37:06 +00:00
|
|
|
#if 0 // for later
|
2015-04-15 07:43:43 +00:00
|
|
|
if (namespace_bits & (Zd)) && !strnicmp(key.GetChars(), "Id", 2))
|
2015-04-15 07:37:06 +00:00
|
|
|
{
|
|
|
|
char *endp;
|
|
|
|
int num = strtol(key.GetChars(), &endp, 10);
|
|
|
|
if (num > 0 && *endp == NULL)
|
|
|
|
{
|
|
|
|
// only allow ID## with ## as a proper number
|
|
|
|
ld->SetId((short)CheckInt(key), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-15 07:43:43 +00:00
|
|
|
if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
|
2009-05-11 21:05:40 +00:00
|
|
|
{
|
|
|
|
AddUserKey(key, UDMF_Line, index);
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
if (isTranslated)
|
|
|
|
{
|
|
|
|
int saved = ld->flags;
|
|
|
|
|
|
|
|
maplinedef_t mld;
|
|
|
|
memset(&mld, 0, sizeof(mld));
|
|
|
|
mld.special = ld->special;
|
2015-04-15 07:37:06 +00:00
|
|
|
mld.tag = ld->GetMainId();
|
2008-05-11 21:16:32 +00:00
|
|
|
P_TranslateLineDef(ld, &mld);
|
|
|
|
ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY));
|
|
|
|
}
|
|
|
|
if (passuse && (ld->activation & SPAC_Use))
|
|
|
|
{
|
|
|
|
ld->activation = (ld->activation & ~SPAC_Use) | SPAC_UseThrough;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
if (strifetrans && ld->Alpha == FRACUNIT)
|
|
|
|
{
|
|
|
|
ld->Alpha = FRACUNIT * 3/4;
|
|
|
|
}
|
2014-04-10 10:32:23 +00:00
|
|
|
if (strifetrans2 && ld->Alpha == FRACUNIT)
|
|
|
|
{
|
|
|
|
ld->Alpha = FRACUNIT * 1/4;
|
|
|
|
}
|
2010-05-29 09:11:12 +00:00
|
|
|
if (ld->sidedef[0] == NULL)
|
|
|
|
{
|
|
|
|
ld->sidedef[0] = (side_t*)(intptr_t)(1);
|
|
|
|
Printf("Line %d has no first side.\n", index);
|
|
|
|
}
|
2012-11-09 23:25:56 +00:00
|
|
|
if (arg0str.IsNotEmpty() && (P_IsACSSpecial(ld->special) || ld->special == 0))
|
2012-02-18 02:39:01 +00:00
|
|
|
{
|
|
|
|
ld->args[0] = -FName(arg0str);
|
|
|
|
}
|
2012-11-09 23:25:56 +00:00
|
|
|
if (arg1str.IsNotEmpty() && (P_IsThingSpecial(ld->special) || ld->special == 0))
|
|
|
|
{
|
|
|
|
ld->args[1] = -FName(arg1str);
|
|
|
|
}
|
2014-09-28 14:17:19 +00:00
|
|
|
if ((ld->flags & ML_3DMIDTEX_IMPASS) && !(ld->flags & ML_3DMIDTEX)) // [TP]
|
|
|
|
{
|
|
|
|
Printf ("Line %d has midtex3dimpassible without midtex3d.\n", index);
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parse a sidedef block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2014-05-16 20:48:37 +00:00
|
|
|
void ParseSidedef(side_t *sd, intmapsidedef_t *sdt, int index)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
fixed_t texofs[2]={0,0};
|
|
|
|
|
|
|
|
memset(sd, 0, sizeof(*sd));
|
2014-05-16 20:48:37 +00:00
|
|
|
sdt->bottomtexture = "-";
|
|
|
|
sdt->toptexture = "-";
|
|
|
|
sdt->midtexture = "-";
|
2009-06-07 01:14:14 +00:00
|
|
|
sd->SetTextureXScale(FRACUNIT);
|
|
|
|
sd->SetTextureYScale(FRACUNIT);
|
2015-02-21 03:51:14 +00:00
|
|
|
sd->Index = index;
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
sc.MustGetToken('{');
|
|
|
|
while (!sc.CheckToken('}'))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
FName key = ParseKey();
|
2008-05-11 21:16:32 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case NAME_Offsetx:
|
2008-05-22 19:35:38 +00:00
|
|
|
texofs[0] = CheckInt(key) << FRACBITS;
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Offsety:
|
2008-05-22 19:35:38 +00:00
|
|
|
texofs[1] = CheckInt(key) << FRACBITS;
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Texturetop:
|
2014-05-16 20:48:37 +00:00
|
|
|
sdt->toptexture = CheckString(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Texturebottom:
|
2014-05-16 20:48:37 +00:00
|
|
|
sdt->bottomtexture = CheckString(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Texturemiddle:
|
2014-05-16 20:48:37 +00:00
|
|
|
sdt->midtexture = CheckString(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Sector:
|
2008-05-22 19:35:38 +00:00
|
|
|
sd->sector = (sector_t*)(intptr_t)CheckInt(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2009-03-11 19:28:10 +00:00
|
|
|
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
|
2008-05-30 06:56:50 +00:00
|
|
|
{
|
|
|
|
case NAME_offsetx_top:
|
|
|
|
sd->SetTextureXOffset(side_t::top, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_offsety_top:
|
|
|
|
sd->SetTextureYOffset(side_t::top, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_offsetx_mid:
|
|
|
|
sd->SetTextureXOffset(side_t::mid, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_offsety_mid:
|
|
|
|
sd->SetTextureYOffset(side_t::mid, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_offsetx_bottom:
|
|
|
|
sd->SetTextureXOffset(side_t::bottom, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_offsety_bottom:
|
|
|
|
sd->SetTextureYOffset(side_t::bottom, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2009-06-07 01:14:14 +00:00
|
|
|
case NAME_scalex_top:
|
|
|
|
sd->SetTextureXScale(side_t::top, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_scaley_top:
|
|
|
|
sd->SetTextureYScale(side_t::top, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_scalex_mid:
|
|
|
|
sd->SetTextureXScale(side_t::mid, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_scaley_mid:
|
|
|
|
sd->SetTextureYScale(side_t::mid, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_scalex_bottom:
|
|
|
|
sd->SetTextureXScale(side_t::bottom, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_scaley_bottom:
|
|
|
|
sd->SetTextureYScale(side_t::bottom, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
case NAME_light:
|
2008-06-14 15:26:16 +00:00
|
|
|
sd->SetLight(CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_lightabsolute:
|
2009-06-07 01:14:14 +00:00
|
|
|
Flag(sd->Flags, WALLF_ABSLIGHTING, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2012-11-03 02:02:42 +00:00
|
|
|
case NAME_lightfog:
|
|
|
|
Flag(sd->Flags, WALLF_LIGHT_FOG, key);
|
|
|
|
continue;
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
case NAME_nofakecontrast:
|
2009-06-07 01:14:14 +00:00
|
|
|
Flag(sd->Flags, WALLF_NOFAKECONTRAST, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-08-21 08:04:21 +00:00
|
|
|
|
|
|
|
case NAME_smoothlighting:
|
2009-06-07 01:14:14 +00:00
|
|
|
Flag(sd->Flags, WALLF_SMOOTHLIGHTING, key);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_Wrapmidtex:
|
|
|
|
Flag(sd->Flags, WALLF_WRAP_MIDTEX, key);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_Clipmidtex:
|
|
|
|
Flag(sd->Flags, WALLF_CLIP_MIDTEX, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2009-07-13 22:07:18 +00:00
|
|
|
case NAME_Nodecals:
|
|
|
|
Flag(sd->Flags, WALLF_NOAUTODECALS, key);
|
|
|
|
continue;
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2015-04-15 07:43:43 +00:00
|
|
|
if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
|
2009-05-11 21:05:40 +00:00
|
|
|
{
|
|
|
|
AddUserKey(key, UDMF_Side, index);
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
// initialization of these is delayed to allow separate offsets and add them with the global ones.
|
|
|
|
sd->AddTextureXOffset(side_t::top, texofs[0]);
|
|
|
|
sd->AddTextureXOffset(side_t::mid, texofs[0]);
|
|
|
|
sd->AddTextureXOffset(side_t::bottom, texofs[0]);
|
|
|
|
sd->AddTextureYOffset(side_t::top, texofs[1]);
|
|
|
|
sd->AddTextureYOffset(side_t::mid, texofs[1]);
|
|
|
|
sd->AddTextureYOffset(side_t::bottom, texofs[1]);
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// parse a sector block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2009-05-02 09:14:01 +00:00
|
|
|
void ParseSector(sector_t *sec, int index)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
int lightcolor = -1;
|
|
|
|
int fadecolor = -1;
|
|
|
|
int desaturation = -1;
|
2014-05-14 10:16:33 +00:00
|
|
|
int fplaneflags = 0, cplaneflags = 0;
|
2014-06-02 08:51:17 +00:00
|
|
|
double fp[4] = { 0 }, cp[4] = { 0 };
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
memset(sec, 0, sizeof(*sec));
|
2008-05-22 19:35:38 +00:00
|
|
|
sec->lightlevel = 160;
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling
|
|
|
|
sec->SetYScale(sector_t::floor, FRACUNIT);
|
|
|
|
sec->SetXScale(sector_t::ceiling, FRACUNIT);
|
|
|
|
sec->SetYScale(sector_t::ceiling, FRACUNIT);
|
2010-11-07 22:12:38 +00:00
|
|
|
sec->SetAlpha(sector_t::floor, FRACUNIT);
|
|
|
|
sec->SetAlpha(sector_t::ceiling, FRACUNIT);
|
2008-05-11 21:16:32 +00:00
|
|
|
sec->thinglist = NULL;
|
|
|
|
sec->touching_thinglist = NULL; // phares 3/14/98
|
2010-08-07 04:32:18 +00:00
|
|
|
sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1;
|
2008-05-11 21:16:32 +00:00
|
|
|
sec->nextsec = -1; //jff 2/26/98 add fields to support locking out
|
|
|
|
sec->prevsec = -1; // stair retriggering until build completes
|
|
|
|
sec->heightsec = NULL; // sector used to get floor and ceiling height
|
2009-08-11 00:22:43 +00:00
|
|
|
sec->sectornum = index;
|
2008-05-22 19:35:38 +00:00
|
|
|
if (floordrop) sec->Flags = SECF_FLOORDROP;
|
2008-05-11 21:16:32 +00:00
|
|
|
// killough 3/7/98: end changes
|
|
|
|
|
|
|
|
sec->gravity = 1.f; // [RH] Default sector gravity of 1.0
|
|
|
|
sec->ZoneNumber = 0xFFFF;
|
|
|
|
|
|
|
|
// killough 8/28/98: initialize all sectors to normal friction
|
|
|
|
sec->friction = ORIG_FRICTION;
|
|
|
|
sec->movefactor = ORIG_FRICTION_FACTOR;
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken('{');
|
|
|
|
while (!sc.CheckToken('}'))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
FName key = ParseKey();
|
2008-05-11 21:16:32 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case NAME_Heightfloor:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneTexZ(sector_t::floor, CheckInt(key) << FRACBITS);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Heightceiling:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneTexZ(sector_t::ceiling, CheckInt(key) << FRACBITS);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Texturefloor:
|
2014-05-16 20:48:37 +00:00
|
|
|
SetTexture(sec, index, sector_t::floor, CheckString(key), missingTex, false);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Textureceiling:
|
2014-05-16 20:48:37 +00:00
|
|
|
SetTexture(sec, index, sector_t::ceiling, CheckString(key), missingTex, false);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Lightlevel:
|
2011-06-11 23:58:33 +00:00
|
|
|
sec->lightlevel = sector_t::ClampLight(CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
case NAME_Special:
|
2008-05-22 19:35:38 +00:00
|
|
|
sec->special = (short)CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
if (isTranslated) sec->special = P_TranslateSectorSpecial(sec->special);
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (namespc == NAME_Hexen)
|
|
|
|
{
|
|
|
|
if (sec->special < 0 || sec->special > 255 || !HexenSectorSpecialOk[sec->special])
|
|
|
|
sec->special = 0; // NULL all unknown specials
|
|
|
|
}
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Id:
|
2015-04-14 16:48:19 +00:00
|
|
|
sec->SetMainTag((short)CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2009-03-11 19:28:10 +00:00
|
|
|
if (namespace_bits & (Zd|Zdt|Va)) switch(key)
|
2008-05-30 06:56:50 +00:00
|
|
|
{
|
|
|
|
case NAME_Xpanningfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXOffset(sector_t::floor, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Ypanningfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYOffset(sector_t::floor, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Xpanningceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXOffset(sector_t::ceiling, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Ypanningceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYOffset(sector_t::ceiling, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Xscalefloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXScale(sector_t::floor, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Yscalefloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYScale(sector_t::floor, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Xscaleceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXScale(sector_t::ceiling, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Yscaleceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYScale(sector_t::ceiling, CheckFixed(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Rotationfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetAngle(sector_t::floor, CheckAngle(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Rotationceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetAngle(sector_t::ceiling, CheckAngle(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Lightfloor:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneLight(sector_t::floor, CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Lightceiling:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneLight(sector_t::ceiling, CheckInt(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2010-11-07 22:12:38 +00:00
|
|
|
case NAME_Alphafloor:
|
|
|
|
sec->SetAlpha(sector_t::floor, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NAME_Alphaceiling:
|
|
|
|
sec->SetAlpha(sector_t::ceiling, CheckFixed(key));
|
|
|
|
continue;
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
case NAME_Renderstylefloor:
|
|
|
|
{
|
|
|
|
const char *str = CheckString(key);
|
|
|
|
if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::floor, PLANEF_ADDITIVE, 0);
|
|
|
|
else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ADDITIVE);
|
|
|
|
else sc.ScriptMessage("Unknown value \"%s\" for 'renderstylefloor'\n", str);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NAME_Renderstyleceiling:
|
|
|
|
{
|
|
|
|
const char *str = CheckString(key);
|
|
|
|
if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::ceiling, PLANEF_ADDITIVE, 0);
|
|
|
|
else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ADDITIVE);
|
|
|
|
else sc.ScriptMessage("Unknown value \"%s\" for 'renderstyleceiling'\n", str);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
case NAME_Lightfloorabsolute:
|
2009-09-17 10:40:38 +00:00
|
|
|
if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
|
|
|
|
else sec->ChangeFlags(sector_t::floor, PLANEF_ABSLIGHTING, 0);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Lightceilingabsolute:
|
2009-09-17 10:40:38 +00:00
|
|
|
if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
|
|
|
|
else sec->ChangeFlags(sector_t::ceiling, PLANEF_ABSLIGHTING, 0);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Gravity:
|
|
|
|
sec->gravity = float(CheckFloat(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Lightcolor:
|
|
|
|
lightcolor = CheckInt(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Fadecolor:
|
|
|
|
fadecolor = CheckInt(key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Desaturation:
|
|
|
|
desaturation = int(255*CheckFloat(key));
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Silent:
|
|
|
|
Flag(sec->Flags, SECF_SILENT, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2008-12-14 19:12:41 +00:00
|
|
|
case NAME_NoRespawn:
|
|
|
|
Flag(sec->Flags, SECF_NORESPAWN, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-12-14 19:12:41 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
case NAME_Nofallingdamage:
|
|
|
|
Flag(sec->Flags, SECF_NOFALLINGDAMAGE, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
case NAME_Dropactors:
|
|
|
|
Flag(sec->Flags, SECF_FLOORDROP, key);
|
2009-05-11 21:05:40 +00:00
|
|
|
continue;
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2010-08-07 04:32:18 +00:00
|
|
|
case NAME_SoundSequence:
|
|
|
|
sec->SeqName = CheckString(key);
|
|
|
|
sec->seqType = -1;
|
|
|
|
continue;
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
case NAME_hidden:
|
2013-08-09 09:47:25 +00:00
|
|
|
Flag(sec->MoreFlags, SECF_HIDDEN, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Waterzone:
|
|
|
|
Flag(sec->MoreFlags, SECF_UNDERWATER, key);
|
2010-08-27 15:20:05 +00:00
|
|
|
break;
|
|
|
|
|
2014-05-14 10:16:33 +00:00
|
|
|
case NAME_floorplane_a:
|
|
|
|
fplaneflags |= 1;
|
2014-06-02 08:51:17 +00:00
|
|
|
fp[0] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_floorplane_b:
|
|
|
|
fplaneflags |= 2;
|
2014-06-02 08:51:17 +00:00
|
|
|
fp[1] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_floorplane_c:
|
|
|
|
fplaneflags |= 4;
|
2014-06-02 08:51:17 +00:00
|
|
|
fp[2] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_floorplane_d:
|
|
|
|
fplaneflags |= 8;
|
2014-06-02 08:51:17 +00:00
|
|
|
fp[3] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ceilingplane_a:
|
|
|
|
cplaneflags |= 1;
|
2014-06-02 08:51:17 +00:00
|
|
|
cp[0] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ceilingplane_b:
|
|
|
|
cplaneflags |= 2;
|
2014-06-02 08:51:17 +00:00
|
|
|
cp[1] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ceilingplane_c:
|
|
|
|
cplaneflags |= 4;
|
2014-06-02 08:51:17 +00:00
|
|
|
cp[2] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ceilingplane_d:
|
|
|
|
cplaneflags |= 8;
|
2014-06-02 08:51:17 +00:00
|
|
|
cp[3] = CheckFloat(key);
|
2014-05-14 10:16:33 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-04-15 07:37:06 +00:00
|
|
|
#if 0 // for later
|
|
|
|
if (namespace_bits & (Zd)) && !strnicmp(key.GetChars(), "Id", 2))
|
|
|
|
{
|
|
|
|
char *endp;
|
|
|
|
int num = strtol(key.GetChars(), &endp, 10);
|
|
|
|
if (num > 0 && *endp == NULL)
|
|
|
|
{
|
|
|
|
// only allow ID## with ## as a proper number
|
|
|
|
sec->SetTag((short)CheckInt(key), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-05-30 06:56:50 +00:00
|
|
|
|
2015-04-15 07:43:43 +00:00
|
|
|
if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
|
2009-05-11 21:05:40 +00:00
|
|
|
{
|
|
|
|
AddUserKey(key, UDMF_Sector, index);
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 10:43:51 +00:00
|
|
|
sec->secretsector = !!(sec->special&SECRET_MASK);
|
2014-05-14 10:16:33 +00:00
|
|
|
|
|
|
|
// Reset the planes to their defaults if not all of the plane equation's parameters were found.
|
|
|
|
if (fplaneflags != 15)
|
|
|
|
{
|
|
|
|
sec->floorplane.a = sec->floorplane.b = 0;
|
|
|
|
sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
|
|
|
|
sec->floorplane.c = FRACUNIT;
|
|
|
|
sec->floorplane.ic = FRACUNIT;
|
|
|
|
}
|
2014-06-02 08:51:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
double ulen = TVector3<double>(fp[0], fp[1], fp[2]).Length();
|
|
|
|
|
|
|
|
// normalize the vector, it must have a length of 1
|
|
|
|
sec->floorplane.a = FLOAT2FIXED(fp[0] / ulen);
|
|
|
|
sec->floorplane.b = FLOAT2FIXED(fp[1] / ulen);
|
|
|
|
sec->floorplane.c = FLOAT2FIXED(fp[2] / ulen);
|
|
|
|
sec->floorplane.d = FLOAT2FIXED(fp[3] / ulen);
|
|
|
|
sec->floorplane.ic = FLOAT2FIXED(ulen / fp[2]);
|
|
|
|
}
|
2014-05-14 10:16:33 +00:00
|
|
|
if (cplaneflags != 15)
|
|
|
|
{
|
|
|
|
sec->ceilingplane.a = sec->ceilingplane.b = 0;
|
|
|
|
sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
|
|
|
|
sec->ceilingplane.c = -FRACUNIT;
|
|
|
|
sec->ceilingplane.ic = -FRACUNIT;
|
|
|
|
}
|
2014-06-02 08:51:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
double ulen = TVector3<double>(cp[0], cp[1], cp[2]).Length();
|
|
|
|
|
|
|
|
// normalize the vector, it must have a length of 1
|
2014-10-31 07:57:43 +00:00
|
|
|
sec->ceilingplane.a = FLOAT2FIXED(cp[0] / ulen);
|
|
|
|
sec->ceilingplane.b = FLOAT2FIXED(cp[1] / ulen);
|
|
|
|
sec->ceilingplane.c = FLOAT2FIXED(cp[2] / ulen);
|
|
|
|
sec->ceilingplane.d = FLOAT2FIXED(cp[3] / ulen);
|
|
|
|
sec->ceilingplane.ic = FLOAT2FIXED(ulen / cp[2]);
|
2014-06-02 08:51:17 +00:00
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2009-01-10 09:40:47 +00:00
|
|
|
if (lightcolor == -1 && fadecolor == -1 && desaturation == -1)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2009-01-10 09:40:47 +00:00
|
|
|
// [RH] Sectors default to white light with the default fade.
|
|
|
|
// If they are outside (have a sky ceiling), they use the outside fog.
|
|
|
|
if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside))
|
|
|
|
{
|
|
|
|
if (fogMap == NULL)
|
|
|
|
fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0);
|
|
|
|
sec->ColorMap = fogMap;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (normMap == NULL)
|
|
|
|
normMap = GetSpecialLights (PalEntry (255,255,255), level.fadeto, NormalLight.Desaturate);
|
|
|
|
sec->ColorMap = normMap;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-10 09:40:47 +00:00
|
|
|
if (lightcolor == -1) lightcolor = PalEntry(255,255,255);
|
|
|
|
if (fadecolor == -1)
|
|
|
|
{
|
|
|
|
if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside))
|
|
|
|
fadecolor = level.outsidefog;
|
|
|
|
else
|
|
|
|
fadecolor = level.fadeto;
|
|
|
|
}
|
|
|
|
if (desaturation == -1) desaturation = NormalLight.Desaturate;
|
|
|
|
|
|
|
|
sec->ColorMap = GetSpecialLights (lightcolor, fadecolor, desaturation);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// parse a vertex block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2010-12-14 00:56:44 +00:00
|
|
|
void ParseVertex(vertex_t *vt, vertexdata_t *vd)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
vt->x = vt->y = 0;
|
2010-12-14 00:56:44 +00:00
|
|
|
vd->zCeiling = vd->zFloor = vd->flags = 0;
|
2008-05-11 21:16:32 +00:00
|
|
|
sc.MustGetStringName("{");
|
|
|
|
while (!sc.CheckString("}"))
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
FName key = sc.String;
|
|
|
|
sc.MustGetStringName("=");
|
|
|
|
sc.MustGetString();
|
|
|
|
FString value = sc.String;
|
|
|
|
sc.MustGetStringName(";");
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case NAME_X:
|
|
|
|
vt->x = FLOAT2FIXED(strtod(value, NULL));
|
|
|
|
break;
|
2010-12-14 00:56:44 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Y:
|
|
|
|
vt->y = FLOAT2FIXED(strtod(value, NULL));
|
|
|
|
break;
|
2010-12-14 00:56:44 +00:00
|
|
|
|
|
|
|
case NAME_ZCeiling:
|
|
|
|
vd->zCeiling = FLOAT2FIXED(strtod(value, NULL));
|
|
|
|
vd->flags |= VERTEXFLAG_ZCeilingEnabled;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_ZFloor:
|
|
|
|
vd->zFloor = FLOAT2FIXED(strtod(value, NULL));
|
|
|
|
vd->flags |= VERTEXFLAG_ZFloorEnabled;
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Processes the linedefs after the map has been loaded
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ProcessLineDefs()
|
|
|
|
{
|
|
|
|
int sidecount = 0;
|
|
|
|
for(unsigned i = 0, skipped = 0; i < ParsedLines.Size();)
|
|
|
|
{
|
|
|
|
// Relocate the vertices
|
|
|
|
intptr_t v1i = intptr_t(ParsedLines[i].v1);
|
|
|
|
intptr_t v2i = intptr_t(ParsedLines[i].v2);
|
|
|
|
|
|
|
|
if (v1i >= numvertexes || v2i >= numvertexes || v1i < 0 || v2i < 0)
|
|
|
|
{
|
2008-05-14 03:39:30 +00:00
|
|
|
I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else if (v1i == v2i ||
|
|
|
|
(vertexes[v1i].x == vertexes[v2i].x && vertexes[v1i].y == vertexes[v2i].y))
|
|
|
|
{
|
|
|
|
Printf ("Removing 0-length line %d\n", i+skipped);
|
|
|
|
ParsedLines.Delete(i);
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
skipped++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ParsedLines[i].v1 = &vertexes[v1i];
|
|
|
|
ParsedLines[i].v2 = &vertexes[v2i];
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ParsedLines[i].sidedef[0] != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
sidecount++;
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ParsedLines[i].sidedef[1] != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
sidecount++;
|
|
|
|
linemap.Push(i+skipped);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numlines = ParsedLines.Size();
|
|
|
|
numsides = sidecount;
|
|
|
|
lines = new line_t[numlines];
|
|
|
|
sides = new side_t[numsides];
|
2012-04-19 02:14:34 +00:00
|
|
|
int line, side;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2012-04-19 02:14:34 +00:00
|
|
|
for(line = 0, side = 0; line < numlines; line++)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2009-08-29 03:33:36 +00:00
|
|
|
short tempalpha[2] = { SHRT_MIN, SHRT_MIN };
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
lines[line] = ParsedLines[line];
|
|
|
|
|
|
|
|
for(int sd = 0; sd < 2; sd++)
|
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
if (lines[line].sidedef[sd] != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
int mapside = int(intptr_t(lines[line].sidedef[sd]))-1;
|
2012-04-19 02:14:34 +00:00
|
|
|
if (mapside < sidecount)
|
|
|
|
{
|
|
|
|
sides[side] = ParsedSides[mapside];
|
|
|
|
sides[side].linedef = &lines[line];
|
|
|
|
sides[side].sector = §ors[intptr_t(sides[side].sector)];
|
|
|
|
lines[line].sidedef[sd] = &sides[side];
|
|
|
|
|
|
|
|
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
|
|
|
|
lines[line].special, lines[line].args[0], &tempalpha[sd], missingTex);
|
|
|
|
|
|
|
|
side++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lines[line].sidedef[sd] = NULL;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
P_AdjustLine(&lines[line]);
|
|
|
|
P_FinishLoadingLineDef(&lines[line], tempalpha[0]);
|
|
|
|
}
|
2012-04-19 02:14:34 +00:00
|
|
|
assert(side <= numsides);
|
|
|
|
if (side < numsides)
|
|
|
|
{
|
|
|
|
Printf("Map had %d invalid side references\n", numsides - side);
|
|
|
|
numsides = side;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Main parsing function
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseTextMap(MapData *map)
|
|
|
|
{
|
|
|
|
char *buffer = new char[map->Size(ML_TEXTMAP)];
|
|
|
|
|
|
|
|
isTranslated = true;
|
2011-12-06 08:36:28 +00:00
|
|
|
isExtended = false;
|
|
|
|
floordrop = false;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
map->Read(ML_TEXTMAP, buffer);
|
|
|
|
sc.OpenMem(Wads.GetLumpFullName(map->lumpnum), buffer, map->Size(ML_TEXTMAP));
|
2009-04-06 17:18:29 +00:00
|
|
|
delete [] buffer;
|
2008-05-11 21:16:32 +00:00
|
|
|
sc.SetCMode(true);
|
2008-05-12 17:14:38 +00:00
|
|
|
if (sc.CheckString("namespace"))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-12 17:14:38 +00:00
|
|
|
sc.MustGetStringName("=");
|
|
|
|
sc.MustGetString();
|
|
|
|
namespc = sc.String;
|
2008-05-22 19:35:38 +00:00
|
|
|
switch(namespc)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_ZDoom:
|
|
|
|
namespace_bits = Zd;
|
2008-05-12 17:14:38 +00:00
|
|
|
isTranslated = false;
|
2008-05-22 19:35:38 +00:00
|
|
|
break;
|
|
|
|
case NAME_ZDoomTranslated:
|
2013-06-03 07:14:42 +00:00
|
|
|
level.flags2 |= LEVEL2_DUMMYSWITCHES;
|
2008-05-22 19:35:38 +00:00
|
|
|
namespace_bits = Zdt;
|
|
|
|
break;
|
2009-03-11 19:28:10 +00:00
|
|
|
case NAME_Vavoom:
|
|
|
|
namespace_bits = Va;
|
|
|
|
isTranslated = false;
|
|
|
|
break;
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Hexen:
|
|
|
|
namespace_bits = Hx;
|
2008-05-12 17:14:38 +00:00
|
|
|
isTranslated = false;
|
2008-05-22 19:35:38 +00:00
|
|
|
break;
|
|
|
|
case NAME_Doom:
|
|
|
|
namespace_bits = Dm;
|
2008-05-12 17:14:38 +00:00
|
|
|
P_LoadTranslator("xlat/doom_base.txt");
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_DUMMYSWITCHES;
|
2008-05-22 19:35:38 +00:00
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
case NAME_Heretic:
|
|
|
|
namespace_bits = Ht;
|
2008-05-12 17:14:38 +00:00
|
|
|
P_LoadTranslator("xlat/heretic_base.txt");
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_DUMMYSWITCHES;
|
2008-05-22 19:35:38 +00:00
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
case NAME_Strife:
|
|
|
|
namespace_bits = St;
|
2008-05-12 17:14:38 +00:00
|
|
|
P_LoadTranslator("xlat/strife_base.txt");
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_DUMMYSWITCHES|LEVEL2_RAILINGHACK;
|
2008-05-22 19:35:38 +00:00
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
default:
|
2010-10-15 15:13:53 +00:00
|
|
|
Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameTypeName());
|
2008-05-22 19:35:38 +00:00
|
|
|
switch (gameinfo.gametype)
|
|
|
|
{
|
2008-05-29 23:33:07 +00:00
|
|
|
default: // Shh, GCC
|
2008-05-22 19:35:38 +00:00
|
|
|
case GAME_Doom:
|
2008-09-21 18:02:38 +00:00
|
|
|
case GAME_Chex:
|
2008-05-22 19:35:38 +00:00
|
|
|
namespace_bits = Dm;
|
|
|
|
P_LoadTranslator("xlat/doom_base.txt");
|
|
|
|
break;
|
|
|
|
case GAME_Heretic:
|
|
|
|
namespace_bits = Ht;
|
|
|
|
P_LoadTranslator("xlat/heretic_base.txt");
|
|
|
|
break;
|
|
|
|
case GAME_Strife:
|
|
|
|
namespace_bits = St;
|
|
|
|
P_LoadTranslator("xlat/strife_base.txt");
|
|
|
|
break;
|
|
|
|
case GAME_Hexen:
|
|
|
|
namespace_bits = Hx;
|
|
|
|
isTranslated = false;
|
|
|
|
break;
|
|
|
|
}
|
2008-05-12 17:14:38 +00:00
|
|
|
}
|
|
|
|
sc.MustGetStringName(";");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf("Map does not define a namespace.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
while (sc.GetString())
|
|
|
|
{
|
|
|
|
if (sc.Compare("thing"))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
FMapThing th;
|
2013-02-17 00:23:58 +00:00
|
|
|
unsigned userdatastart = MapThingsUserData.Size();
|
2008-05-11 21:16:32 +00:00
|
|
|
ParseThing(&th);
|
|
|
|
MapThingsConverted.Push(th);
|
2013-02-17 00:23:58 +00:00
|
|
|
if (userdatastart < MapThingsUserData.Size())
|
|
|
|
{ // User data added
|
|
|
|
MapThingsUserDataIndex[MapThingsConverted.Size()-1] = userdatastart;
|
|
|
|
// Mark end of the user data for this map thing
|
|
|
|
FMapThingUserData ud;
|
|
|
|
ud.Property = NAME_None;
|
|
|
|
ud.Value = 0;
|
|
|
|
MapThingsUserData.Push(ud);
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else if (sc.Compare("linedef"))
|
|
|
|
{
|
|
|
|
line_t li;
|
2009-05-11 21:05:40 +00:00
|
|
|
ParseLinedef(&li, ParsedLines.Size());
|
2008-05-11 21:16:32 +00:00
|
|
|
ParsedLines.Push(li);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("sidedef"))
|
|
|
|
{
|
|
|
|
side_t si;
|
2014-05-16 20:48:37 +00:00
|
|
|
intmapsidedef_t st;
|
2009-05-11 21:05:40 +00:00
|
|
|
ParseSidedef(&si, &st, ParsedSides.Size());
|
2008-05-11 21:16:32 +00:00
|
|
|
ParsedSides.Push(si);
|
|
|
|
ParsedSideTextures.Push(st);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("sector"))
|
|
|
|
{
|
|
|
|
sector_t sec;
|
2009-05-02 09:14:01 +00:00
|
|
|
ParseSector(&sec, ParsedSectors.Size());
|
2008-05-11 21:16:32 +00:00
|
|
|
ParsedSectors.Push(sec);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("vertex"))
|
|
|
|
{
|
|
|
|
vertex_t vt;
|
2010-12-14 00:56:44 +00:00
|
|
|
vertexdata_t vd;
|
|
|
|
ParseVertex(&vt, &vd);
|
2008-05-11 21:16:32 +00:00
|
|
|
ParsedVertices.Push(vt);
|
2010-12-14 00:56:44 +00:00
|
|
|
ParsedVertexDatas.Push(vd);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2010-08-20 12:20:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Skip();
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 08:36:28 +00:00
|
|
|
// Catch bogus maps here rather than during nodebuilding
|
|
|
|
if (ParsedVertices.Size() == 0) I_Error("Map has no vertices.\n");
|
|
|
|
if (ParsedSectors.Size() == 0) I_Error("Map has no sectors. \n");
|
|
|
|
if (ParsedLines.Size() == 0) I_Error("Map has no linedefs.\n");
|
|
|
|
if (ParsedSides.Size() == 0) I_Error("Map has no sidedefs.\n");
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
// Create the real vertices
|
|
|
|
numvertexes = ParsedVertices.Size();
|
|
|
|
vertexes = new vertex_t[numvertexes];
|
|
|
|
memcpy(vertexes, &ParsedVertices[0], numvertexes * sizeof(*vertexes));
|
|
|
|
|
2010-12-14 00:56:44 +00:00
|
|
|
// Create the real vertex datas
|
|
|
|
numvertexdatas = ParsedVertexDatas.Size();
|
|
|
|
vertexdatas = new vertexdata_t[numvertexdatas];
|
|
|
|
memcpy(vertexdatas, &ParsedVertexDatas[0], numvertexdatas * sizeof(*vertexdatas));
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
// Create the real sectors
|
|
|
|
numsectors = ParsedSectors.Size();
|
|
|
|
sectors = new sector_t[numsectors];
|
|
|
|
memcpy(sectors, &ParsedSectors[0], numsectors * sizeof(*sectors));
|
2008-05-22 19:35:38 +00:00
|
|
|
sectors[0].e = new extsector_t[numsectors];
|
2008-05-11 21:16:32 +00:00
|
|
|
for(int i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
sectors[i].e = §ors[0].e[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the real linedefs and decompress the sidedefs
|
|
|
|
ProcessLineDefs();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void P_ParseTextMap(MapData *map, FMissingTextureTracker &missingtex)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
UDMFParser parse(missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
parse.ParseTextMap(map);
|
|
|
|
}
|