From 0a92138edf0e1f7c7366cdf0cf74f51ca9d8706f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Mar 2016 17:43:36 +0100 Subject: [PATCH 1/5] - fixed: The portal link table was not created when there were no sector portals. - fixed: P_TryMove could loop endlessly over a list of static portals when there was an error during portal creation. # Conflicts: # src/gl/models/gl_models.cpp # src/gl/scene/gl_sprite.cpp --- src/p_map.cpp | 12 ++++++++++-- src/portal.cpp | 42 +++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 9dc666468..ca8b7b751 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2287,9 +2287,12 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { fixed_t bestfrac = FIXED_MAX; spechit_t besthit; + int besthitnum; // find the portal nearest to the crossing actor - for (auto &spec : portalhit) + for (unsigned i = 0; i < portalhit.Size();i++) { + auto &spec = portalhit[i]; + line_t *ld = spec.line; if (ld->frontsector->PortalGroup != thing->Sector->PortalGroup) continue; // must be in the same group to be considered valid. @@ -2305,12 +2308,14 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { besthit = spec; bestfrac = frac; + besthitnum = i; } } } if (bestfrac < FIXED_MAX) { + portalhit.Delete(besthitnum); line_t *ld = besthit.line; FLinePortal *port = ld->getPortal(); if (port->mType == PORTT_LINKED) @@ -2370,7 +2375,10 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } R_AddInterpolationPoint(hit); } - if (port->mType == PORTT_LINKED) continue; + if (port->mType == PORTT_LINKED) + { + continue; + } } break; } diff --git a/src/portal.cpp b/src/portal.cpp index 63dfeafe6..013403ba5 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -933,7 +933,7 @@ void P_CreateLinkedPortals() TThinkerIterator it; AStackPoint *mo; TArray orgs; - int id = 0; + int id = 1; bool bogus = false; while ((mo = it.Next())) @@ -952,36 +952,32 @@ void P_CreateLinkedPortals() } } } - if (orgs.Size() == 0) + if (orgs.Size() != 0) { - // Create the 0->0 translation which is always needed. - Displacements.Create(1); - return; - } - for (int i = 0; i < numsectors; i++) - { - for (int j = 0; j < 2; j++) + for (int i = 0; i < numsectors; i++) { - AActor *box = sectors[i].SkyBoxes[j]; - if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL) + for (int j = 0; j < 2; j++) { - secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane; - if (plane.a || plane.b) + AActor *box = sectors[i].SkyBoxes[j]; + if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL) { - // The engine cannot deal with portals on a sloped plane. - sectors[i].SkyBoxes[j] = NULL; - Printf("Portal on %s of sector %d is sloped and will be disabled\n", j==0? "floor":"ceiling", i); + secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane; + if (plane.a || plane.b) + { + // The engine cannot deal with portals on a sloped plane. + sectors[i].SkyBoxes[j] = NULL; + Printf("Portal on %s of sector %d is sloped and will be disabled\n", j == 0 ? "floor" : "ceiling", i); + } } } } - } - // Group all sectors, starting at each portal origin. - id = 1; - for (unsigned i = 0; i < orgs.Size(); i++) - { - if (CollectSectors(id, orgs[i]->Sector)) id++; - if (CollectSectors(id, orgs[i]->Mate->Sector)) id++; + // Group all sectors, starting at each portal origin. + for (unsigned i = 0; i < orgs.Size(); i++) + { + if (CollectSectors(id, orgs[i]->Sector)) id++; + if (CollectSectors(id, orgs[i]->Mate->Sector)) id++; + } } for (unsigned i = 0; i < linePortals.Size(); i++) { From 8c027aef8b51903860c8fd44f8776c23447b6576 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Mar 2016 22:37:43 +0100 Subject: [PATCH 2/5] - added NULL pointer check to portal rotation calculation function. --- src/portal.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index 013403ba5..a9dd40487 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -245,12 +245,15 @@ static line_t *FindDestination(line_t *src, int tag) 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); + if (port != NULL && port->mDestination != NULL) + { + 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); + } } //============================================================================ From 4a295dfa3ddcc1464cc83d34c34f0495e41fcdb3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 11 Mar 2016 20:41:45 -0600 Subject: [PATCH 3/5] Accept constant definitions in structs. - We already need to handle them for enums, so there's really nothing to be gained by not accepting constant definitions directly. --- src/zscript/zcc-parse.lemon | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zscript/zcc-parse.lemon b/src/zscript/zcc-parse.lemon index 3d0e40121..c42e0818b 100644 --- a/src/zscript/zcc-parse.lemon +++ b/src/zscript/zcc-parse.lemon @@ -262,6 +262,7 @@ struct_body(X) ::= struct_member(A) struct_body(B). { X = A; A->AppendSibling(B struct_member(X) ::= declarator_no_fun(A). { X = A; } struct_member(X) ::= enum_def(A). { X = A; } +struct_member(X) ::= const_def(A). { X = A; } /*----- Constant Definition ------*/ /* Like UnrealScript, a constant's type is implied by its value's type. */ From 8a03b99b9ccbbb14d4b2cac7353797a8ad6901ae Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 12 Mar 2016 19:23:49 -0600 Subject: [PATCH 4/5] Use ScriptMessage to warn about missing patches in a TEXTURES texture --- src/textures/multipatchtexture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 0f015fbf1..358fde9ea 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1023,7 +1023,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i } if (part.Texture == NULL) { - if (!silent) Printf(TEXTCOLOR_RED "Unknown patch '%s' in texture '%s'\n", sc.String, Name.GetChars()); + if (!silent) sc.ScriptMessage(TEXTCOLOR_RED "Unknown patch '%s' in texture '%s'\n", sc.String, Name.GetChars()); } sc.MustGetStringName(","); sc.MustGetNumber(); From b73d6e42af5a56e8283579e3a2d8dbcc5c4ecd89 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Mar 2016 02:28:13 +0100 Subject: [PATCH 5/5] - fixed: FMultiBlockLinesIterator must reset the current sector when doing the final up and downwards check from the start position. --- src/p_maputl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 526626b22..b55989c97 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -833,6 +833,7 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item) } if (onlast) { + cursector = startsector; // We reached the end of the list. Check if we still need to check up- and downwards. if (GoUp(checkpoint.x, checkpoint.y) || GoDown(checkpoint.x, checkpoint.y))