From 078d37e073bd0359ed752644ed3b938da7a595ec Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 3 Mar 2016 13:41:34 -0600 Subject: [PATCH 1/7] Pretty sure this was a typo --- src/zscript/zcc_parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 0f4b0573c7..26428ef104 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -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; From 964ff4606344d8a07e85064becf65d93545ca68d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 3 Mar 2016 15:34:42 -0600 Subject: [PATCH 2/7] Add new state options to parser and actually enable them - Added new state options that DECORATE got to the lemon parser. - Enable token generation for state options. They were previously not generated, so the grammar treated them as function calls instead. --- src/sc_man.cpp | 12 ++++++-- src/sc_man.h | 2 ++ src/sc_man_scanner.re | 19 ++++++++---- src/sc_man_tokens.h | 8 +++++ src/zscript/ast.cpp | 9 +++--- src/zscript/zcc-parse.lemon | 25 ++++++++++++++-- src/zscript/zcc_parser.cpp | 59 ++++++++++++++++++++++--------------- src/zscript/zcc_parser.h | 6 +++- 8 files changed, 101 insertions(+), 39 deletions(-) diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 9c65ddc669..50ec1214e8 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -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; } //========================================================================== diff --git a/src/sc_man.h b/src/sc_man.h index 04de9539ff..b1231e547b 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -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; }; diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index ae322488ee..7e82f19c1b 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -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(':'); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index 49444c7fa1..7fda91330c 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -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 diff --git a/src/zscript/ast.cpp b/src/zscript/ast.cpp index 94d8de5111..a59a656af0 100644 --- a/src/zscript/ast.cpp +++ b/src/zscript/ast.cpp @@ -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); diff --git a/src/zscript/zcc-parse.lemon b/src/zscript/zcc-parse.lemon index 2b0ca76331..1e574299fd 100644 --- a/src/zscript/zcc-parse.lemon +++ b/src/zscript/zcc-parse.lemon @@ -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. diff --git a/src/zscript/zcc_parser.cpp b/src/zscript/zcc_parser.cpp index b8e7f0ea0f..2b914d0335 100644 --- a/src/zscript/zcc_parser.cpp +++ b/src/zscript/zcc_parser.cpp @@ -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); diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 26428ef104..1621aaa099 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -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; From 5c1ec2c0bf233f40811580788863187cf0da94fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 01:39:55 +0100 Subject: [PATCH 3/7] - added some more British English text variants. --- wadsrc/static/language.eng | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/language.eng b/wadsrc/static/language.eng index 6f90950325..11c5b8f0a5 100644 --- a/wadsrc/static/language.eng +++ b/wadsrc/static/language.eng @@ -1,11 +1,51 @@ -/* British English */ +/* British, Canadian, Australian, New Zealand, Hiberno, South African, Jamaican, +Caribbean, Belizean, Trinidadian, and Zimbabwean English */ -[eng] +[eng enc ena enz eni ens enj enb enl ent enw] GOTARMOR = "Picked up the armour."; GOTMEGA = "Picked up the MegaArmour!"; GOTARMBONUS = "Picked up an armour bonus."; +C2TEXT = + "YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" + "HUMANKIND TO EVACUATE EARTH AND ESCAPE\n" + "THE NIGHTMARE. NOW YOU ARE THE ONLY\n" + "HUMAN LEFT ON THE FACE OF THE PLANET.\n" + "CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n" + "AND EVIL SPIRITS ARE YOUR ONLY NEIGHBOURS.\n" + "YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n" + "THAT YOU HAVE SAVED YOUR SPECIES.\n" + "\n" + "BUT THEN, EARTH CONTROL BEAMS DOWN A\n" + "MESSAGE FROM SPACE: \"SENSORS HAVE LOCATED\n" + "THE SOURCE OF THE ALIEN INVASION. IF YOU\n" + "GO THERE, YOU MAY BE ABLE TO BLOCK THEIR\n" + "ENTRY. THE ALIEN BASE IS IN THE HEART OF\n" + "YOUR OWN HOME CITY, NOT FAR FROM THE\n" + "STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n" + "UP AND RETURN TO THE FRAY."; +NERVETEXT = + "TROUBLE WAS BREWING AGAIN IN YOUR FAVOURITE\n" + "VACATION SPOT... HELL. SOME CYBERDEMON\n" + "PUNK THOUGHT HE COULD TURN HELL INTO A\n" + "PERSONAL AMUSEMENT PARK, AND MAKE EARTH\n" + "THE TICKET BOOTH.\n" + "\n" + "WELL THAT HALF-ROBOT FREAK SHOW DIDN'T\n" + "KNOW WHO WAS COMING TO THE FAIR. THERE'S\n" + "NOTHING LIKE A SHOOTING GALLERY FULL OF\n" + "HELLSPAWN TO GET THE BLOOD PUMPING...\n" + "\n" + "NOW THE WALLS OF THE DEMON'S LABYRINTH\n" + "ECHO WITH THE SOUND OF HIS METALLIC LIMBS\n" + "HITTING THE FLOOR. HIS DEATH MOAN GURGLES\n" + "OUT THROUGH THE MESS YOU LEFT OF HIS FACE.\n" + "\n" + "THIS RIDE IS CLOSED.\n"; + +OB_TURRET = "%o triggered the automatic defences."; + SCORE_COLOR = "COLOUR"; TAG_SHADOWARMOR = "Shadow Armour"; @@ -19,12 +59,14 @@ TXT_METALARMOR = "You picked up the Metal Armour."; TXT_LEATHERARMOR = "You picked up the Leather Armour."; TXT_SHADOWARMOR = "You picked up the Shadow armour."; +TXT_RANDOM_PGUARD_10 = "If there is any honour inside that pathetic shell of a body, you'll enter into the arms of the order."; GOTCHEXARMOR = "Picked up the Chex(R) Armour."; GOTSUPERCHEXARMOR = "Picked up the Super Chex(R) Armour!"; OB_BIPEDICUS2 = "%o was slimed by an armoured bipedicus."; MNU_COLORPICKER = "SELECT COLOUR"; +CNTRLMNU_CENTERVIEW = "Centre view"; PLYRMNU_PLAYERCOLOR = "Colour"; DSPLYMNU_DIMCOLOR = "Dim colour"; HUDMNU_CROSSHAIRCOLOR = "Crosshair colour"; @@ -45,10 +87,25 @@ AUTOMAPMNU_CUSTOMCOLORS = "Allow map defined colours"; AUTOMAPMNU_SETCUSTOMCOLORS = "Set custom colours"; MAPCOLORMNU_TITLE = "CUSTOMIZE MAP COLOURS"; MAPCOLORMNU_DEFAULTMAPCOLORS = "Restore default custom colours"; +MAPCOLORMNU_XHAIRCOLOR = "Centre point"; +MSGMNU_CENTERMESSAGES = "Centre messages"; MSGMNU_MESSAGECOLORS = "Message Colours"; +MSGMNU_CENTEREDMESSAGES = "Centred Messages"; SCRBRDMNU_HEADERCOLOR = "Header Colour"; SCRBRDMNU_YOURCOLOR = "Your Player Colour"; SCRBRDMNU_OTHERPLAYERCOLOR = "Other Players' Colour"; GMPLYMNU_ALLOWARMOR = "Allow armour"; GMPLYMNU_KEEPARMOR = "Keep armour"; +CMPTMNU_ACTORBEHAVIOR = "Actor Behaviour"; +CMPTMNU_DEHACKEDBEHAVIOR = "DehackEd Behaviour"; +CMPTMNU_MAPACTIONBEHAVIOR = "Map/Action Behaviour"; +CMPTMNU_LIGHT = "Find neighbouring light like Doom"; +CMPTMNU_FLOORMOVE = "Use Doom's floor motion behaviour"; +CMPTMNU_PHYSICSBEHAVIOR = "Physics Behaviour"; +CMPTMNU_RENDERINGBEHAVIOR = "Rendering Behaviour"; +CMPTMNU_SOUNDBEHAVIOR = "Sound Behaviour"; +CMPTMNU_SECTORSOUNDS = "Sector sounds use centre as source"; OPTVAL_MAPDEFINEDCOLORSONLY = "Map defined colours only"; +C_GRAY = "\ccgrey"; +C_DARKGRAY = "\cudark grey"; +MNU_COLORPICKER = "SELECT COLOUR"; From e4a74f4bbe2574b10edd482de3b7ba21c77a9105 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 3 Mar 2016 20:26:13 -0600 Subject: [PATCH 4/7] Fix memory leak from ZCC_OpInfo operator prototypes --- src/zscript/zcc_expr.cpp | 21 +++++++++++++++++++++ src/zscript/zcc_parser.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/zscript/zcc_expr.cpp b/src/zscript/zcc_expr.cpp index 69a25970b4..644a122a5a 100644 --- a/src/zscript/zcc_expr.cpp +++ b/src/zscript/zcc_expr.cpp @@ -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); diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 1621aaa099..cf51ff7651 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -489,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 From 93323b64f8bb43136f17d1362c31f07e94fbbd9a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 10:16:23 +0100 Subject: [PATCH 5/7] - explicitly force SSE2 for Visual Studio 64 bit projects so that the advanced instruction sets don't get activated by accident. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0da51d230..2e0bf8b770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. From 9b23b410219b035fcbe245647ccad70f841436cd Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 4 Mar 2016 11:20:19 +0200 Subject: [PATCH 6/7] Added detection for broken WAD files Do not try to allocate nonsensical amount of memory and bail out when broken WAD is detected See http://forum.drdteam.org/viewtopic.php?t=6844 --- src/resourcefiles/file_wad.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 0bdc0a7369..0732d4c115 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -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]; From b427f27e3b52d6469188af26580a344691df020d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Mar 2016 14:09:26 +0100 Subject: [PATCH 7/7] - fixed: line portal rotations were not set for all types. --- src/portal.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index 49a1592a3e..6f0baeaea0 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -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; }