From 321ab2f6867e8a977c130f94cb13721d299f8e36 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 30 Oct 2009 03:29:15 +0000 Subject: [PATCH] - Make TranslateToStartSpot() set the new sector references for a polyobj's walls so that P_CheckSwitchRange() will work with them. SVN r1951 (trunk) --- docs/rh-log.txt | 4 ++++ src/p_spec.cpp | 6 ++++-- src/p_switch.cpp | 12 ++++++++---- src/po_man.cpp | 15 ++++++++++++--- src/r_defs.h | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b76087dfab..39b44e19ed 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ October 29, 2009 +- Make TranslateToStartSpot() set the new sector references for a polyobj's + walls so that P_CheckSwitchRange() will work with them. +- Fixed: If P_ActivateLine() failed in P_UseTraverse() it would not play + the *usefail sound. - Fixed: An unspecified save_dir will now save to the program directory on Windows. (Other operating systems already use the user's home directory instead.) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 82d91489d1..56ecd5179a 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -293,7 +293,10 @@ bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType) } if (activationType == SPAC_Use) { - if (!P_CheckSwitchRange(mo, line, side)) return false; + if (!P_CheckSwitchRange(mo, line, side)) + { + return false; + } } if ((lineActivation & activationType) == 0) @@ -392,7 +395,6 @@ bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType) // void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { - if (sector == NULL) { // Falling, not all the way down yet? diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 4e312a1660..25a8788849 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -466,7 +466,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) { // Activated from an empty side -> always succeed side_t *side = line->sidedef[sideno]; - if (side == NULL) return true; + if (side == NULL) + return true; fixed_t checktop; fixed_t checkbot; @@ -474,7 +475,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) FLineOpening open; // 3DMIDTEX forces CHECKSWITCHRANGE because otherwise it might cause problems. - if (!(line->flags & (ML_3DMIDTEX|ML_CHECKSWITCHRANGE))) return true; + if (!(line->flags & (ML_3DMIDTEX|ML_CHECKSWITCHRANGE))) + return true; // calculate the point where the user would touch the wall. divline_t dll, dlu; @@ -502,7 +504,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) // Now get the information from the line. P_LineOpening(open, NULL, line, checkx, checky, user->x, user->y); - if (open.range <= 0) goto onesided; + if (open.range <= 0) + goto onesided; if ((TryFindSwitch (side, side_t::top)) != -1) { @@ -516,7 +519,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) { // 3DMIDTEX lines will force a mid texture check if no switch is found on this line // to keep compatibility with Eternity's implementation. - if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) return false; + if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) + return false; return user->z < checktop || user->z + user->height > checkbot; } else diff --git a/src/po_man.cpp b/src/po_man.cpp index ebafff46fd..828ea951a2 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1565,21 +1565,30 @@ static void TranslateToStartSpot (int tag, int originX, int originY) (*tempSeg)->v1->x -= deltaX; (*tempSeg)->v1->y -= deltaY; } - avg.x += (*tempSeg)->v1->x>>FRACBITS; - avg.y += (*tempSeg)->v1->y>>FRACBITS; + avg.x += (*tempSeg)->v1->x >> FRACBITS; + avg.y += (*tempSeg)->v1->y >> FRACBITS; // the original Pts are based off the startSpot Pt, and are // unique to each seg, not each linedef tempPt->x = (*tempSeg)->v1->x-po->startSpot[0]; tempPt->y = (*tempSeg)->v1->y-po->startSpot[1]; } + // Put polyobj in its subsector. avg.x /= po->numsegs; avg.y /= po->numsegs; - sub = R_PointInSubsector (avg.x<poly != NULL) { I_Error ("PO_TranslateToStartSpot: Multiple polyobjs in a single subsector.\n"); } sub->poly = po; + // Reassign the sides of the polyobj to its new sector. + sector_t *sec = P_PointInSector (avg.x << FRACBITS, avg.y << FRACBITS); + for (i = 0; i < po->numsegs; ++i) + { + po->segs[i]->linedef->frontsector = sec; + po->segs[i]->linedef->sidedef[0]->sector = sec; + po->segs[i]->frontsector = sec; + } } //========================================================================== diff --git a/src/r_defs.h b/src/r_defs.h index 623e475c40..7d02fb4eb5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -871,7 +871,7 @@ struct line_t DWORD flags; DWORD activation; // activation type int special; - fixed_t Alpha; // <--- translucency (0-255/255=opaque) + fixed_t Alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque) int id; // <--- same as tag or set with Line_SetIdentification int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) int firstid, nextid;