Search FOF target sectors for slope anchors

Requires spawning fake floors before slopes, and therefore before things,
basically before everything. Hopefully nothing breaks!
This commit is contained in:
James R 2020-09-24 01:56:03 -07:00
parent b35e2ac9b3
commit 388d56a5f8
4 changed files with 70 additions and 26 deletions

View file

@ -3206,19 +3206,22 @@ boolean P_SetupLevel(boolean skipprecip)
// anything that P_ResetDynamicSlopes/P_LoadThings needs to know // anything that P_ResetDynamicSlopes/P_LoadThings needs to know
P_InitSpecials(); 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_ResetDynamicSlopes();
P_LoadThings(); P_LoadThings();
P_RaiseThings();
P_SpawnSecretItems(loademblems); P_SpawnSecretItems(loademblems);
for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++)
if (!playerstarts[numcoopstarts]) if (!playerstarts[numcoopstarts])
break; break;
// set up world state
P_SpawnSpecials(fromnetsave);
K_AdjustWaypointsParameters(); K_AdjustWaypointsParameters();
if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)

View file

@ -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 // 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 // Allocate each list
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)
if(secthinkers[i].thinkers) if(secthinkers[i].thinkers)

View file

@ -38,6 +38,7 @@ void P_SetupLevelFlatAnims(void);
// at map load // at map load
void P_InitSpecials(void); void P_InitSpecials(void);
void P_SpawnSpecials(INT32 fromnetsave); void P_SpawnSpecials(INT32 fromnetsave);
void P_RaiseThings(void);
// every tic // every tic
void P_UpdateSpecials(void); void P_UpdateSpecials(void);

View file

@ -266,6 +266,8 @@ find_closest_anchors
int last = 0; int last = 0;
size_t i;
if (list->count < 3) if (list->count < 3)
{ {
I_Error("At least three slope anchors are required to make a slope."); 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); anchors = Z_Malloc(3 * sizeof *anchors, PU_LEVEL, NULL);
if (sector->numattached > 0)
{
for (i = 0; i < sector->numattached; ++i)
{
get_sector_anchors
(anchors, distances, list, &sectors[sector->attached[i]]);
}
}
else
{
get_sector_anchors(anchors, distances, list, sector); get_sector_anchors(anchors, distances, list, sector);
}
if (distances[2] < INT32_MAX) if (distances[2] < INT32_MAX)
{ {
@ -287,6 +300,28 @@ find_closest_anchors
else else
last = 0; last = 0;
if (sector->numattached > 0)
{
CONS_Printf("\nSearched for anchors in sectors...\n\n");
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( I_Error(
"(Sector #%s)" "(Sector #%s)"
" Slope requires anchors near 3 of its vertices (%d found)", " Slope requires anchors near 3 of its vertices (%d found)",
@ -294,6 +329,7 @@ find_closest_anchors
sizeu1 (sector - sectors), sizeu1 (sector - sectors),
last last
); );
}
} }
static pslope_t * static pslope_t *