This commit is contained in:
Christoph Oelckers 2016-03-04 14:10:28 +01:00
commit e9e30a6431
12 changed files with 158 additions and 49 deletions

View file

@ -121,7 +121,7 @@ if( MSVC )
set( ALL_C_FLAGS "/GF /Gy /GR-" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4")
# SSE2 option (mostly to switch it off in VC2012 and later where it's the default
# SSE2 option (to allow x87 in 32 bit and disallow extended feature sets which have not yet been checked for precision)
option (ZDOOM_USE_SSE2 "Use SSE2 instruction set")
if (ZDOOM_USE_SSE2)
set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2")
@ -131,6 +131,8 @@ if( MSVC )
set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:IA32")
endif ()
endif ()
else()
set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2")
endif()
# Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations.

View file

@ -224,6 +224,23 @@ static line_t *FindDestination(line_t *src, int tag)
return NULL;
}
//============================================================================
//
//
//
//============================================================================
static void SetRotation(FLinePortal *port)
{
line_t *dst = port->mDestination;
line_t *line = port->mOrigin;
double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI;
port->mSinRot = FLOAT2FIXED(sin(angle));
port->mCosRot = FLOAT2FIXED(cos(angle));
port->mAngleDiff = RAD2ANGLE(angle);
}
//============================================================================
//
// Spawns a single line portal
@ -270,12 +287,7 @@ void P_SpawnLinePortal(line_t* line)
// Get the angle between the two linedefs, for rotating
// orientation and velocity. Rotate 180 degrees, and flip
// the position across the exit linedef, if reversed.
double angle = atan2(dst->dy, dst->dx) - atan2(line->dy, line->dx) + M_PI;
port->mSinRot = FLOAT2FIXED(sin(angle));
port->mCosRot = FLOAT2FIXED(cos(angle));
port->mAngleDiff = RAD2ANGLE(angle);
SetRotation(port);
}
else if (line->args[2] == PORTT_LINKEDEE && line->args[0] == 0)
{
@ -296,6 +308,7 @@ void P_SpawnLinePortal(line_t* line)
port->mType = PORTT_LINKED;
port->mAlign = PORG_ABSOLUTE;
port->mDefFlags = PORTF_TYPEINTERACTIVE;
SetRotation(port);
// we need to create the backlink here, too.
lines[i].portalindex = linePortals.Reserve(1);
@ -308,6 +321,7 @@ void P_SpawnLinePortal(line_t* line)
port->mAlign = PORG_ABSOLUTE;
port->mDefFlags = PORTF_TYPEINTERACTIVE;
SetRotation(port);
}
}
}
@ -427,9 +441,10 @@ static bool ChangePortalLine(line_t *line, int destid)
else
{
port->mFlags = port->mDefFlags;
portd->mFlags = portd->mDefFlags;
}
SetRotation(portd);
}
SetRotation(port);
return true;
}

View file

@ -39,6 +39,7 @@
#include "v_text.h"
#include "w_wad.h"
#include "gi.h"
#include "i_system.h"
// Console Doom LZSS wrapper.
class FileReaderLZSS : public FileReaderBase
@ -343,6 +344,12 @@ bool FWadFile::Open(bool quiet)
NumLumps = BigLong(header.NumLumps);
InfoTableOfs = BigLong(header.InfoTableOfs);
isBigEndian = true;
// Check again to detect broken wads
if (InfoTableOfs + NumLumps*sizeof(wadlump_t) > (unsigned)wadSize)
{
I_Error("Cannot load broken WAD file %s\n", Filename);
}
}
wadlump_t *fileinfo = new wadlump_t[NumLumps];

View file

@ -120,6 +120,7 @@ FScanner &FScanner::operator=(const FScanner &other)
CMode = other.CMode;
Escape = other.Escape;
StateMode = other.StateMode;
StateOptions = other.StateOptions;
// Copy public members
if (other.String == other.StringBuffer)
@ -277,6 +278,7 @@ void FScanner::PrepareScript ()
CMode = false;
Escape = true;
StateMode = 0;
StateOptions = false;
StringBuffer[0] = '\0';
BigStringBuffer = "";
}
@ -409,15 +411,19 @@ void FScanner::SetEscape (bool esc)
// * ;
// * } - Automatically exits state mode after it's seen.
//
// Quoted strings are returned as TOK_NonWhitespace, minus the quotes. In
// addition, any two consecutive sequences of TOK_NonWhitespace also exit
// state mode.
// Quoted strings are returned as TOK_NonWhitespace, minus the quotes. Once
// two consecutive sequences of TOK_NonWhitespace have been encountered
// (which would be the state's sprite and frame specifiers), nearly normal
// processing resumes, with the exception that various identifiers
// used for state options will be returned as tokens and not identifiers.
// This ends once a ';' or '{' character is encountered.
//
//==========================================================================
void FScanner::SetStateMode(bool stately)
{
StateMode = stately ? 2 : 0;
StateOptions = stately;
}
//==========================================================================

View file

@ -28,6 +28,7 @@ public:
void SetCMode(bool cmode);
void SetEscape(bool esc);
void SetStateMode(bool stately);
void DisableStateOptions();
const SavedPos SavePos();
void RestorePos(const SavedPos &pos);
@ -99,6 +100,7 @@ protected:
int LastGotLine;
bool CMode;
BYTE StateMode;
bool StateOptions;
bool Escape;
};

View file

@ -49,7 +49,7 @@ std2:
TOK2 = (NWS\STOP1);
TOKC2 = (NWS\STOPC);
*/
#define RET(x) TokenType = x; goto normal_token;
#define RET(x) TokenType = (x); goto normal_token;
if (tokens && StateMode != 0)
{
/*!re2c
@ -63,10 +63,10 @@ std2:
'wait' { RET(TK_Wait); }
'fail' { RET(TK_Fail); }
'loop' { RET(TK_Loop); }
'goto' { StateMode = 0; RET(TK_Goto); }
'goto' { StateMode = 0; StateOptions = false; RET(TK_Goto); }
":" { RET(':'); }
";" { RET(';'); }
"}" { StateMode = 0; RET('}'); }
"}" { StateMode = 0; StateOptions = false; RET('}'); }
WSP+ { goto std1; }
"\n" { goto newline; }
@ -181,6 +181,15 @@ std2:
'action' { RET(TK_Action); }
'readonly' { RET(TK_ReadOnly); }
/* Actor state options */
'bright' { RET(StateOptions ? TK_Bright : TK_Identifier); }
'fast' { RET(StateOptions ? TK_Fast : TK_Identifier); }
'slow' { RET(StateOptions ? TK_Slow : TK_Identifier); }
'nodelay' { RET(StateOptions ? TK_NoDelay : TK_Identifier); }
'canraise' { RET(StateOptions ? TK_CanRaise : TK_Identifier); }
'offset' { RET(StateOptions ? TK_Offset : TK_Identifier); }
'light' { RET(StateOptions ? TK_Light : TK_Identifier); }
/* other DECORATE top level keywords */
'#include' { RET(TK_Include); }
'fixed_t' { RET(TK_Fixed_t); }
@ -228,8 +237,8 @@ std2:
"<>=" { RET(TK_LtGtEq); }
"**" { RET(TK_MulMul); }
"::" { RET(TK_ColonColon); }
";" { RET(';'); }
"{" { RET('{'); }
";" { StateOptions = false; RET(';'); }
"{" { StateOptions = false; RET('{'); }
"}" { RET('}'); }
"," { RET(','); }
":" { RET(':'); }

View file

@ -129,4 +129,12 @@ xx(TK_Wait, "'wait'")
xx(TK_Meta, "'meta'")
xx(TK_Deprecated, "'deprecated'")
xx(TK_ReadOnly, "'readonly'")
xx(TK_CanRaise, "'canraise'")
xx(TK_Fast, "'fast'")
xx(TK_Light, "'light'")
xx(TK_NoDelay, "'nodelay'")
xx(TK_Offset, "'offset'")
xx(TK_Slow, "'slow'")
xx(TK_Bright, "'bright'")
#undef xx

View file

@ -377,10 +377,11 @@ static void PrintStateLine(FLispString &out, ZCC_TreeNode *node)
ZCC_StateLine *snode = (ZCC_StateLine *)node;
out.Open("state-line");
out.Add(snode->Sprite, 4);
if (snode->bBright)
{
out.Add("bright", 6);
}
if (snode->bNoDelay) out.Add("nodelay", 7);
if (snode->bBright) out.Add("bright", 6);
if (snode->bFast) out.Add("fast", 4);
if (snode->bSlow) out.Add("slow", 4);
if (snode->bCanRaise) out.Add("canraise", 8);
out.Add(*(snode->Frames));
PrintNodes(out, snode->Offset);
PrintNodes(out, snode->Action, false);

View file

@ -41,6 +41,19 @@ static void SetNodeLine(ZCC_TreeNode *name, int line)
struct StateOpts {
ZCC_Expression *Offset;
bool Bright;
bool Fast;
bool Slow;
bool NoDelay;
bool CanRaise;
void Zero() {
Offset = NULL;
Bright = false;
Fast = false;
Slow = false;
NoDelay = false;
CanRaise = false;
}
};
struct VarOrFun
@ -433,15 +446,23 @@ state_line(X) ::= NWS(A) NWS(B) expr state_opts(C) state_action(D).
}
line->Frames = stat->Strings.Alloc(FName(B.Name()).GetChars());
line->bBright = C.Bright;
line->bFast = C.Fast;
line->bSlow = C.Slow;
line->bNoDelay = C.NoDelay;
line->bCanRaise = C.CanRaise;
line->Offset = C.Offset;
line->Action = D;
X = line;
}
state_opts(X) ::= . { StateOpts opts; opts.Offset = NULL; opts.Bright = false; X = opts; }
state_opts(X) ::= . { StateOpts opts; opts.Zero(); X = opts; }
state_opts(X) ::= state_opts(A) BRIGHT. { A.Bright = true; X = A; }
state_opts(X) ::= state_opts(A) FAST. { A.Fast = true; X = A; }
state_opts(X) ::= state_opts(A) SLOW. { A.Slow = true; X = A; }
state_opts(X) ::= state_opts(A) NODELAY. { A.NoDelay = true; X = A; }
state_opts(X) ::= state_opts(A) CANRAISE. { A.CanRaise = true; X = A; }
state_opts(X) ::= state_opts(A) OFFSET LPAREN expr(B) COMMA expr(C) RPAREN. { A.Offset = B; B->AppendSibling(C); X = A; }
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; }
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; } ///FIXME: GZDoom would want to know this
light_list ::= STRCONST.
light_list ::= light_list COMMA STRCONST.

View file

@ -33,6 +33,27 @@ struct OpProto2
EvalConst2op EvalConst;
};
static struct FreeOpInfoProtos
{
~FreeOpInfoProtos()
{
for (size_t i = 0; i < countof(ZCC_OpInfo); ++i)
{
ZCC_OpInfo[i].FreeAllProtos();
}
}
} ProtoFreeer;
void ZCC_OpInfoType::FreeAllProtos()
{
for (ZCC_OpProto *proto = Protos, *next = NULL; proto != NULL; proto = next)
{
next = proto->Next;
delete proto;
}
Protos = NULL;
}
void ZCC_OpInfoType::AddProto(PType *res, PType *optype, EvalConst1op evalconst)
{
ZCC_OpProto *proto = new ZCC_OpProto(res, optype, NULL);

View file

@ -147,6 +147,14 @@ static void InitTokenMap()
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
TOKENDEF (TK_NonWhitespace, ZCC_NWS);
TOKENDEF (TK_Bright, ZCC_BRIGHT);
TOKENDEF (TK_Slow, ZCC_SLOW);
TOKENDEF (TK_Fast, ZCC_FAST);
TOKENDEF (TK_NoDelay, ZCC_NODELAY);
TOKENDEF (TK_Offset, ZCC_OFFSET);
TOKENDEF (TK_CanRaise, ZCC_CANRAISE);
TOKENDEF (TK_Light, ZCC_CANRAISE);
ZCC_InitOperators();
ZCC_InitConversions();
}
@ -194,43 +202,44 @@ static void DoParse(const char *filename)
while (sc.GetToken())
{
value.SourceLoc = sc.GetMessageLine();
if (sc.TokenType == TK_StringConst)
switch (sc.TokenType)
{
case TK_StringConst:
value.String = state.Strings.Alloc(sc.String, sc.StringLen);
tokentype = ZCC_STRCONST;
}
else if (sc.TokenType == TK_NameConst)
{
break;
case TK_NameConst:
value.Int = sc.Name;
tokentype = ZCC_NAMECONST;
}
else if (sc.TokenType == TK_IntConst)
{
break;
case TK_IntConst:
value.Int = sc.Number;
tokentype = ZCC_INTCONST;
}
else if (sc.TokenType == TK_UIntConst)
{
break;
case TK_UIntConst:
value.Int = sc.Number;
tokentype = ZCC_UINTCONST;
}
else if (sc.TokenType == TK_FloatConst)
{
break;
case TK_FloatConst:
value.Float = sc.Float;
tokentype = ZCC_FLOATCONST;
}
else if (sc.TokenType == TK_Identifier)
{
break;
case TK_Identifier:
value.Int = FName(sc.String);
tokentype = ZCC_IDENTIFIER;
}
else if (sc.TokenType == TK_NonWhitespace)
{
break;
case TK_NonWhitespace:
value.Int = FName(sc.String);
tokentype = ZCC_NWS;
}
else
{
break;
default:
TokenMapEntry *zcctoken = TokenMap.CheckKey(sc.TokenType);
if (zcctoken != NULL)
{
@ -240,16 +249,18 @@ static void DoParse(const char *filename)
else
{
sc.ScriptMessage("Unexpected token %s.\n", sc.TokenName(sc.TokenType).GetChars());
break;
goto parse_end;
}
break;
}
ZCCParse(parser, tokentype, value, &state);
if (failed)
{
sc.ScriptMessage("Parse failed\n");
break;
goto parse_end;
}
}
parse_end:
value.Int = -1;
ZCCParse(parser, ZCC_EOF, value, &state);
ZCCParse(parser, 0, value, &state);

View file

@ -158,8 +158,8 @@ struct ZCC_TreeNode
assert(SiblingNext->SiblingPrev == this);
// Check integrity of new sibling list.
assert(sibling->SiblingPrev->SiblingNext = sibling);
assert(sibling->SiblingNext->SiblingPrev = sibling);
assert(sibling->SiblingPrev->SiblingNext == sibling);
assert(sibling->SiblingNext->SiblingPrev == sibling);
ZCC_TreeNode *siblingend = sibling->SiblingPrev;
SiblingPrev->SiblingNext = sibling;
@ -253,7 +253,11 @@ struct ZCC_StateGoto : ZCC_StatePart
struct ZCC_StateLine : ZCC_StatePart
{
char Sprite[4];
BITFIELD bBright:1;
BITFIELD bBright : 1;
BITFIELD bFast : 1;
BITFIELD bSlow : 1;
BITFIELD bNoDelay : 1;
BITFIELD bCanRaise : 1;
FString *Frames;
ZCC_Expression *Offset;
ZCC_TreeNode *Action;
@ -485,6 +489,8 @@ struct ZCC_OpInfoType
ZCC_OpProto *FindBestProto(PType *optype, const PType::Conversion **route, int &numslots);
ZCC_OpProto *FindBestProto(PType *left, const PType::Conversion **route1, int &numslots,
PType *right, const PType::Conversion **route2, int &numslots2);
void FreeAllProtos();
};
#define CONVERSION_ROUTE_SIZE 8