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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "r_data.h"
|
|
|
|
#include "p_setup.h"
|
|
|
|
#include "sc_man.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"
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Dm=1,
|
|
|
|
Ht=2,
|
|
|
|
Hx=4,
|
|
|
|
St=8,
|
|
|
|
Zd=16,
|
|
|
|
Zdt=32,
|
|
|
|
|
|
|
|
// will be extended later. Unknown namespaces will always be treated like the base
|
|
|
|
// namespace for each game
|
|
|
|
};
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, mapsidedef_t *msd, int special, int tag, short *alpha);
|
|
|
|
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;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
struct UDMFParser
|
|
|
|
{
|
|
|
|
FScanner sc;
|
|
|
|
FName namespc;
|
2008-05-22 19:35:38 +00:00
|
|
|
int namespace_bits;
|
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;
|
|
|
|
TArray<mapsidedef_t> ParsedSideTextures;
|
|
|
|
TArray<sector_t> ParsedSectors;
|
|
|
|
TArray<vertex_t> ParsedVertices;
|
|
|
|
|
|
|
|
FDynamicColormap *fogMap, *normMap;
|
|
|
|
|
|
|
|
UDMFParser()
|
|
|
|
{
|
|
|
|
linemap.Clear();
|
|
|
|
fogMap = normMap = NULL;
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parses a 'key = value' line of the map but doesn't read the semicolon
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
FName ParseKey()
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetString();
|
|
|
|
FName key = sc.String;
|
|
|
|
sc.MustGetToken('=');
|
|
|
|
|
|
|
|
sc.Number = 0;
|
|
|
|
sc.Float = 0;
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
|
|
|
|
if (sc.TokenType == '+' || sc.TokenType == '-')
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
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;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Syntax checks
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
int CheckInt(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_IntConst)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Integer value expected for key '%s'", key);
|
|
|
|
}
|
|
|
|
return sc.Number;
|
|
|
|
}
|
|
|
|
|
|
|
|
double CheckFloat(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_IntConst && sc.TokenType != TK_FloatConst)
|
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
sc.ScriptMessage("Floating point value expected for key '%s'", key);
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
|
|
|
return sc.Float;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t CheckFixed(const char *key)
|
|
|
|
{
|
|
|
|
return FLOAT2FIXED(CheckFloat(key));
|
|
|
|
}
|
|
|
|
|
2008-06-14 15:26:16 +00:00
|
|
|
angle_t CheckAngle(const char *key)
|
|
|
|
{
|
|
|
|
return angle_t(CheckFloat(key) * ANGLE_90 / 90.);
|
|
|
|
}
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
bool 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 *CheckString(const char *key)
|
|
|
|
{
|
|
|
|
if (sc.TokenType != TK_StringConst)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.ScriptMessage("String value expected for key '%s'", key);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
return sc.String;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag(DWORD &value, int mask, const char *key)
|
|
|
|
{
|
|
|
|
if (CheckBool(key)) value |= mask;
|
|
|
|
else value &= ~mask;
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parse a thing block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseThing(FMapThing *th)
|
|
|
|
{
|
|
|
|
memset(th, 0, sizeof(*th));
|
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:
|
2008-05-22 19:35:38 +00:00
|
|
|
th->type = (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_Special:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt)
|
|
|
|
th->special = 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_Arg0:
|
|
|
|
case NAME_Arg1:
|
|
|
|
case NAME_Arg2:
|
|
|
|
case NAME_Arg3:
|
|
|
|
case NAME_Arg4:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt)
|
|
|
|
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
|
|
|
|
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:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt)
|
|
|
|
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:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(Hx | Zd | Zdt)
|
|
|
|
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:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(th->flags, MTF_SHADOW, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Invisible:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(th->flags, MTF_ALTSHADOW, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Friend: // This maps to Strife's friendly flag
|
|
|
|
CHECK_N(Dm | Zd | Zdt)
|
|
|
|
Flag(th->flags, MTF_FRIENDLY, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Strifeally:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(th->flags, MTF_FRIENDLY, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Standing:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(th->flags, MTF_STANDSTILL, key);
|
|
|
|
break;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken(';');
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
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
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseLinedef(line_t *ld)
|
|
|
|
{
|
|
|
|
bool passuse = false;
|
2008-05-22 19:35:38 +00:00
|
|
|
bool strifetrans = false;
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
memset(ld, 0, sizeof(*ld));
|
|
|
|
ld->Alpha = FRACUNIT;
|
|
|
|
ld->id = -1;
|
|
|
|
ld->sidenum[0] = ld->sidenum[1] = NO_SIDE;
|
|
|
|
if (level.flags & LEVEL_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
|
|
|
|
if (level.flags & LEVEL_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
|
|
|
|
if (level.flags & LEVEL_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
|
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_V2:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->v2 = (vertex_t*)(intptr_t)CheckInt(key); // must be relocated later
|
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_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
|
|
|
|
}
|
|
|
|
|
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_Id:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->id = 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_Sidefront:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->sidenum[0] = 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_Sideback:
|
2008-05-22 19:35:38 +00:00
|
|
|
ld->sidenum[1] = 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_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);
|
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_Blocking:
|
2008-05-22 19:35:38 +00:00
|
|
|
Flag(ld->flags, ML_BLOCKING, key);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Blocksound:
|
|
|
|
Flag(ld->flags, ML_SOUNDBLOCK, key);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Jumpover:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(ld->flags, ML_RAILING, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Blockfloating:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
Flag(ld->flags, ML_BLOCK_FLOATERS, key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Transparent:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(St | Zd | Zdt)
|
|
|
|
strifetrans = CheckBool(key);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case NAME_Passuse:
|
2008-05-22 19:35:38 +00:00
|
|
|
CHECK_N(Dm | Zd | Zdt)
|
|
|
|
passuse = CheckBool(key);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Repeatspecial:
|
|
|
|
Flag(ld->flags, ML_REPEAT_SPECIAL, key);
|
|
|
|
break;
|
|
|
|
|
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
|
2008-05-22 19:35:38 +00:00
|
|
|
if (namespace_bits & (Zd|Zdt)) 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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Anycross:
|
|
|
|
Flag(ld->activation, SPAC_AnyCross, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Monsteractivate:
|
|
|
|
Flag(ld->flags, ML_MONSTERSCANACTIVATE, key);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken(';');
|
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;
|
|
|
|
mld.tag = ld->id;
|
|
|
|
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;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Parse a sidedef block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseSidedef(side_t *sd, mapsidedef_t *sdt)
|
|
|
|
{
|
|
|
|
fixed_t texofs[2]={0,0};
|
|
|
|
|
|
|
|
memset(sd, 0, sizeof(*sd));
|
|
|
|
strncpy(sdt->bottomtexture, "-", 8);
|
|
|
|
strncpy(sdt->toptexture, "-", 8);
|
|
|
|
strncpy(sdt->midtexture, "-", 8);
|
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;
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Offsety:
|
2008-05-22 19:35:38 +00:00
|
|
|
texofs[1] = CheckInt(key) << FRACBITS;
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Texturetop:
|
2008-05-22 19:35:38 +00:00
|
|
|
strncpy(sdt->toptexture, CheckString(key), 8);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Texturebottom:
|
2008-05-22 19:35:38 +00:00
|
|
|
strncpy(sdt->bottomtexture, CheckString(key), 8);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Texturemiddle:
|
2008-05-22 19:35:38 +00:00
|
|
|
strncpy(sdt->midtexture, CheckString(key), 8);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Sector:
|
2008-05-22 19:35:38 +00:00
|
|
|
sd->sector = (sector_t*)(intptr_t)CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
if (namespace_bits & (Zd|Zdt)) switch(key)
|
|
|
|
{
|
|
|
|
case NAME_offsetx_top:
|
|
|
|
sd->SetTextureXOffset(side_t::top, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_offsety_top:
|
|
|
|
sd->SetTextureYOffset(side_t::top, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_offsetx_mid:
|
|
|
|
sd->SetTextureXOffset(side_t::mid, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_offsety_mid:
|
|
|
|
sd->SetTextureYOffset(side_t::mid, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_offsetx_bottom:
|
|
|
|
sd->SetTextureXOffset(side_t::bottom, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_offsety_bottom:
|
|
|
|
sd->SetTextureYOffset(side_t::bottom, CheckFixed(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_light:
|
2008-06-14 15:26:16 +00:00
|
|
|
sd->SetLight(CheckInt(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_lightabsolute:
|
2008-08-21 08:04:21 +00:00
|
|
|
if (CheckBool(key)) sd->Flags |= WALLF_ABSLIGHTING;
|
|
|
|
else sd->Flags &= ~WALLF_ABSLIGHTING;
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_nofakecontrast:
|
2008-08-21 08:04:21 +00:00
|
|
|
if (CheckBool(key)) sd->Flags |= WALLF_NOFAKECONTRAST;
|
|
|
|
else sd->Flags &= WALLF_NOFAKECONTRAST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_smoothlighting:
|
|
|
|
if (CheckBool(key)) sd->Flags |= WALLF_SMOOTHLIGHTING;
|
|
|
|
else sd->Flags &= ~WALLF_SMOOTHLIGHTING;
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken(';');
|
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
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseSector(sector_t *sec)
|
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
int lightcolor = -1;
|
|
|
|
int fadecolor = -1;
|
|
|
|
int desaturation = -1;
|
|
|
|
|
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);
|
2008-05-11 21:16:32 +00:00
|
|
|
sec->oldspecial = !!(sec->special&SECRET_MASK);
|
|
|
|
sec->thinglist = NULL;
|
|
|
|
sec->touching_thinglist = NULL; // phares 3/14/98
|
|
|
|
sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL)? 0:-1;
|
|
|
|
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
|
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);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Heightceiling:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneTexZ(sector_t::ceiling, CheckInt(key) << FRACBITS);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Texturefloor:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetTexture(sector_t::floor, TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Textureceiling:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetTexture(sector_t::ceiling, TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightlevel:
|
2008-05-22 19:35:38 +00:00
|
|
|
sec->lightlevel = (BYTE)clamp<int>(CheckInt(key), 0, 255);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
case NAME_Id:
|
|
|
|
sec->tag = (short)CheckInt(key);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
|
|
|
|
if (namespace_bits & (Zd|Zdt)) switch(key)
|
|
|
|
{
|
|
|
|
case NAME_Xpanningfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXOffset(sector_t::floor, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Ypanningfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYOffset(sector_t::floor, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Xpanningceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXOffset(sector_t::ceiling, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Ypanningceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYOffset(sector_t::ceiling, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Xscalefloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXScale(sector_t::floor, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Yscalefloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYScale(sector_t::floor, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Xscaleceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetXScale(sector_t::ceiling, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Yscaleceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetYScale(sector_t::ceiling, CheckFixed(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Rotationfloor:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetAngle(sector_t::floor, CheckAngle(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Rotationceiling:
|
2008-06-14 15:26:16 +00:00
|
|
|
sec->SetAngle(sector_t::ceiling, CheckAngle(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightfloor:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneLight(sector_t::floor, CheckInt(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightceiling:
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->SetPlaneLight(sector_t::ceiling, CheckInt(key));
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightfloorabsolute:
|
2008-08-16 20:19:35 +00:00
|
|
|
if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING);
|
|
|
|
else sec->ChangeFlags(sector_t::floor, SECF_ABSLIGHTING, 0);
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightceilingabsolute:
|
2008-08-16 20:19:35 +00:00
|
|
|
if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING);
|
|
|
|
else sec->ChangeFlags(sector_t::ceiling, SECF_ABSLIGHTING, 0);
|
2008-05-30 06:56:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Gravity:
|
|
|
|
sec->gravity = float(CheckFloat(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Lightcolor:
|
|
|
|
lightcolor = CheckInt(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Fadecolor:
|
|
|
|
fadecolor = CheckInt(key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Desaturation:
|
|
|
|
desaturation = int(255*CheckFloat(key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Silent:
|
|
|
|
Flag(sec->Flags, SECF_SILENT, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Nofallingdamage:
|
|
|
|
Flag(sec->Flags, SECF_NOFALLINGDAMAGE, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME_Dropactors:
|
|
|
|
Flag(sec->Flags, SECF_FLOORDROP, key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
sc.MustGetToken(';');
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
|
2008-05-11 21:16:32 +00:00
|
|
|
sec->floorplane.c = FRACUNIT;
|
|
|
|
sec->floorplane.ic = FRACUNIT;
|
2008-08-16 20:19:35 +00:00
|
|
|
sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
|
2008-05-11 21:16:32 +00:00
|
|
|
sec->ceilingplane.c = -FRACUNIT;
|
|
|
|
sec->ceilingplane.ic = -FRACUNIT;
|
|
|
|
|
|
|
|
// [RH] Sectors default to white light with the default fade.
|
|
|
|
// If they are outside (have a sky ceiling), they use the outside fog.
|
2008-08-16 20:19:35 +00:00
|
|
|
if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside))
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
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-30 06:56:50 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// parse a vertex block
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void ParseVertex(vertex_t *vt)
|
|
|
|
{
|
|
|
|
vt->x = vt->y = 0;
|
|
|
|
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;
|
|
|
|
case NAME_Y:
|
|
|
|
vt->y = FLOAT2FIXED(strtod(value, NULL));
|
|
|
|
break;
|
|
|
|
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];
|
|
|
|
|
|
|
|
if (ParsedLines[i].sidenum[0] != NO_SIDE)
|
|
|
|
sidecount++;
|
|
|
|
if (ParsedLines[i].sidenum[1] != NO_SIDE)
|
|
|
|
sidecount++;
|
|
|
|
linemap.Push(i+skipped);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numlines = ParsedLines.Size();
|
|
|
|
numsides = sidecount;
|
|
|
|
lines = new line_t[numlines];
|
|
|
|
sides = new side_t[numsides];
|
|
|
|
|
|
|
|
for(int line = 0, side = 0; line < numlines; line++)
|
|
|
|
{
|
|
|
|
short tempalpha[2] = {-1,-1};
|
|
|
|
|
|
|
|
lines[line] = ParsedLines[line];
|
|
|
|
|
|
|
|
for(int sd = 0; sd < 2; sd++)
|
|
|
|
{
|
|
|
|
if (lines[line].sidenum[sd] != NO_SIDE)
|
|
|
|
{
|
|
|
|
int mapside = lines[line].sidenum[sd];
|
|
|
|
sides[side] = ParsedSides[mapside];
|
|
|
|
sides[side].linenum = line;
|
|
|
|
sides[side].sector = §ors[intptr_t(sides[side].sector)];
|
|
|
|
lines[line].sidenum[sd] = side;
|
|
|
|
|
|
|
|
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
|
|
|
|
lines[line].special, lines[line].args[0], &tempalpha[sd]);
|
|
|
|
|
|
|
|
side++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
P_AdjustLine(&lines[line]);
|
|
|
|
P_FinishLoadingLineDef(&lines[line], tempalpha[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
map->Read(ML_TEXTMAP, buffer);
|
|
|
|
sc.OpenMem(Wads.GetLumpFullName(map->lumpnum), buffer, map->Size(ML_TEXTMAP));
|
|
|
|
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:
|
|
|
|
namespace_bits = Zdt;
|
|
|
|
break;
|
|
|
|
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");
|
2008-05-22 19:35:38 +00:00
|
|
|
level.flags |= LEVEL_DUMMYSWITCHES;
|
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
case NAME_Heretic:
|
|
|
|
namespace_bits = Ht;
|
2008-05-12 17:14:38 +00:00
|
|
|
P_LoadTranslator("xlat/heretic_base.txt");
|
2008-05-22 19:35:38 +00:00
|
|
|
level.flags |= LEVEL_DUMMYSWITCHES;
|
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
case NAME_Strife:
|
|
|
|
namespace_bits = St;
|
2008-05-12 17:14:38 +00:00
|
|
|
P_LoadTranslator("xlat/strife_base.txt");
|
2008-05-22 19:35:38 +00:00
|
|
|
level.flags |= LEVEL_DUMMYSWITCHES|LEVEL_RAILINGHACK;
|
|
|
|
floordrop = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameNames[gameinfo.gametype]);
|
|
|
|
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:
|
|
|
|
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;
|
|
|
|
ParseThing(&th);
|
|
|
|
MapThingsConverted.Push(th);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("linedef"))
|
|
|
|
{
|
|
|
|
line_t li;
|
|
|
|
ParseLinedef(&li);
|
|
|
|
ParsedLines.Push(li);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("sidedef"))
|
|
|
|
{
|
|
|
|
side_t si;
|
|
|
|
mapsidedef_t st;
|
|
|
|
ParseSidedef(&si, &st);
|
|
|
|
ParsedSides.Push(si);
|
|
|
|
ParsedSideTextures.Push(st);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("sector"))
|
|
|
|
{
|
|
|
|
sector_t sec;
|
|
|
|
ParseSector(&sec);
|
|
|
|
ParsedSectors.Push(sec);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("vertex"))
|
|
|
|
{
|
|
|
|
vertex_t vt;
|
|
|
|
ParseVertex(&vt);
|
|
|
|
ParsedVertices.Push(vt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the real vertices
|
|
|
|
numvertexes = ParsedVertices.Size();
|
|
|
|
vertexes = new vertex_t[numvertexes];
|
|
|
|
memcpy(vertexes, &ParsedVertices[0], numvertexes * sizeof(*vertexes));
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void P_ParseTextMap(MapData *map)
|
|
|
|
{
|
|
|
|
UDMFParser parse;
|
|
|
|
|
|
|
|
parse.ParseTextMap(map);
|
|
|
|
}
|