From 388d56a5f8a5eb9983700a3b9820aa3a015d2e94 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 01:56:03 -0700 Subject: [PATCH] Search FOF target sectors for slope anchors Requires spawning fake floors before slopes, and therefore before things, basically before everything. Hopefully nothing breaks! --- src/p_setup.c | 9 +++++--- src/p_spec.c | 36 +++++++++++++++++--------------- src/p_spec.h | 1 + src/slope_anchors.c | 50 ++++++++++++++++++++++++++++++++++++++------- 4 files changed, 70 insertions(+), 26 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index c2af9b3b2..51bdbce89 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3206,19 +3206,22 @@ boolean P_SetupLevel(boolean skipprecip) // anything that P_ResetDynamicSlopes/P_LoadThings needs to know P_InitSpecials(); + // set up world state + // jart: needs to be done here so anchored slopes know the attached list + P_SpawnSpecials(fromnetsave); + P_ResetDynamicSlopes(); P_LoadThings(); + P_RaiseThings(); + P_SpawnSecretItems(loademblems); for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) if (!playerstarts[numcoopstarts]) break; - // set up world state - P_SpawnSpecials(fromnetsave); - K_AdjustWaypointsParameters(); if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) diff --git a/src/p_spec.c b/src/p_spec.c index 4c86714eb..47e476478 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5358,6 +5358,26 @@ P_RaiseTaggedThingsToFakeFloor ( } } +void +P_RaiseThings (void) +{ + size_t i; + + for (i = 0; i < numlines; ++i) + { + switch (lines[i].special) + { + case 80: // Raise tagged things by type to this FOF + P_RaiseTaggedThingsToFakeFloor( + ( sides[lines[i].sidenum[0]].textureoffset >> FRACBITS ), + lines[i].tag, + lines[i].frontsector + ); + break; + } + } +} + // // SPECIAL SPAWNING // @@ -6822,22 +6842,6 @@ void P_SpawnSpecials(INT32 fromnetsave) } } - /* some things have to be done after FOF spawn */ - - for (i = 0; i < numlines; ++i) - { - switch (lines[i].special) - { - case 80: // Raise tagged things by type to this FOF - P_RaiseTaggedThingsToFakeFloor( - ( sides[lines[i].sidenum[0]].textureoffset >> FRACBITS ), - lines[i].tag, - lines[i].frontsector - ); - break; - } - } - // Allocate each list for (i = 0; i < numsectors; i++) if(secthinkers[i].thinkers) diff --git a/src/p_spec.h b/src/p_spec.h index 6c85c6d1a..ea497fb19 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -38,6 +38,7 @@ void P_SetupLevelFlatAnims(void); // at map load void P_InitSpecials(void); void P_SpawnSpecials(INT32 fromnetsave); +void P_RaiseThings(void); // every tic void P_UpdateSpecials(void); diff --git a/src/slope_anchors.c b/src/slope_anchors.c index 0102b68bf..ff1504a37 100644 --- a/src/slope_anchors.c +++ b/src/slope_anchors.c @@ -266,6 +266,8 @@ find_closest_anchors int last = 0; + size_t i; + if (list->count < 3) { I_Error("At least three slope anchors are required to make a slope."); @@ -273,7 +275,18 @@ find_closest_anchors anchors = Z_Malloc(3 * sizeof *anchors, PU_LEVEL, NULL); - get_sector_anchors(anchors, distances, list, sector); + if (sector->numattached > 0) + { + for (i = 0; i < sector->numattached; ++i) + { + get_sector_anchors + (anchors, distances, list, §ors[sector->attached[i]]); + } + } + else + { + get_sector_anchors(anchors, distances, list, sector); + } if (distances[2] < INT32_MAX) { @@ -287,13 +300,36 @@ find_closest_anchors else last = 0; - I_Error( - "(Sector #%s)" - " Slope requires anchors near 3 of its vertices (%d found)", + if (sector->numattached > 0) + { + CONS_Printf("\nSearched for anchors in sectors...\n\n"); - sizeu1 (sector - sectors), - last - ); + for (i = 0; i < sector->numattached; ++i) + { + CONS_Printf("#%s\n", sizeu1 (sector->attached[i])); + } + + I_Error( + "(Control Sector #%s)" + " Slope requires anchors near 3 of its target sectors' vertices" + " (%d found)" + + "\n\nCheck the log to see which sectors were searched.", + + sizeu1 (sector - sectors), + last + ); + } + else + { + I_Error( + "(Sector #%s)" + " Slope requires anchors near 3 of its vertices (%d found)", + + sizeu1 (sector - sectors), + last + ); + } } static pslope_t *