From 931774ab382a34761adac2705b6a5d8ab28bcf46 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Apr 2016 12:14:56 +0200 Subject: [PATCH] - fixed some issues with the PathTraverse and sight checking code: * typo in calculating end position from a trace vector * must use floor to convert from floating point block coordinate to block index to account for running off the negative side of the blockmap. (Int cast always rounds toward zero which is wrong here.) * bad calculation of sight checking slopes - they has the actor's z coordinate duplicated. - fixed scaling of automap markers. --- src/am_map.cpp | 2 +- src/p_maputl.cpp | 12 ++++++------ src/p_sight.cpp | 13 +++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 172f31bdee..e8203c0fc3 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -3011,7 +3011,7 @@ void AM_drawAuthorMarkers () marked->subsector->flags & SSECF_DRAWN : marked->Sector->MoreFlags & SECF_DRAWN))) { - DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation, + DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X*16, mark->Scale.Y*16, mark->Translation, mark->Alpha, mark->fillcolor, mark->RenderStyle); } marked = mark->args[0] != 0 ? it.Next() : NULL; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 8c03674afa..6279a054f3 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1456,7 +1456,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, if (flags & PT_DELTA) { x2 += x1; - y2 += y2; + y2 += y1; } x1 -= bmaporgx; @@ -1469,10 +1469,10 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, xt2 = x2 / MAPBLOCKUNITS; yt2 = y2 / MAPBLOCKUNITS; - mapx = int(xt1); - mapy = int(yt1); - int mapex = int(xt2); - int mapey = int(yt2); + mapx = xs_FloorToInt(xt1); + mapy = xs_FloorToInt(yt1); + int mapex = xs_FloorToInt(xt2); + int mapey = xs_FloorToInt(yt2); if (mapex > mapx) @@ -1563,7 +1563,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, } // [RH] Handle corner cases properly instead of pretending they don't exist. - switch (((int(yintercept) == mapy) << 1) | (int(xintercept) == mapx)) + switch (((xs_FloorToInt(yintercept) == mapy) << 1) | (xs_FloorToInt(xintercept) == mapx)) { case 0: // neither xintercept nor yintercept match! count = 100; // Stop traversing, because somebody screwed up. diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 2e6531d898..b69daa0cf6 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -642,10 +642,11 @@ bool SightCheck::P_SightPathTraverse () xt2 = x2 / MAPBLOCKUNITS; yt2 = y2 / MAPBLOCKUNITS; - mapx = int(xt1); - mapy = int(yt1); - int mapex = int(xt2); - int mapey = int(yt2); + mapx = xs_FloorToInt(xt1); + mapy = xs_FloorToInt(yt1); + int mapex = xs_FloorToInt(xt2); + int mapey = xs_FloorToInt(yt2); + if (mapex > mapx) { @@ -731,7 +732,7 @@ bool SightCheck::P_SightPathTraverse () if (res == -1 || (mapxstep | mapystep) == 0) break; - switch (((int(yintercept) == mapy) << 1) | (int(xintercept) == mapx)) + switch (((xs_FloorToInt(yintercept) == mapy) << 1) | (xs_FloorToInt(xintercept) == mapx)) { case 0: // neither xintercept nor yintercept match! sightcounts[5]++; @@ -872,7 +873,7 @@ sightcounts[0]++; double lookheight = t1->Center(); t1->GetPortalTransition(lookheight, &sec); - double bottomslope = t2->Z() - (t1->Z() + lookheight); + double bottomslope = t2->Z() - lookheight; double topslope = bottomslope + t2->Height; SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup };