From 72672d68cff914c6fc0d5eca180099c15684eeda Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 27 Sep 2020 03:58:41 -0400 Subject: [PATCH] UDMF support for waypoints Changes: - "waypoint ID" is now tag (previously angle) - "next waypoint ID" is now angle (previously Z height) - Z height is Z height - Radius is controlled by args[0] - "is finish line" is controlled by args[1] - Waypoint parameters linedef, riser things, and anchor things will not do anything in UDMF mode - Non-UDMF maps are unaffected --- src/p_mobj.c | 30 +++++++++--------------------- src/p_setup.c | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 70984c546..9a1b3915b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11324,33 +11324,21 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean const fixed_t mobjscale = mapheaderinfo[gamemap-1]->default_waypoint_radius; - // Just like MT_SPINMACEPOINT, this now works here too! - INT32 line = P_FindSpecialLineFromTag(2000, mthing->angle, -1); - - if (mobjscale == 0) - mobj->radius = DEFAULT_WAYPOINT_RADIUS * mapobjectscale; - else + if (mthing->args[0] > 0) + mobj->radius = (mthing->args[0]) * FRACUNIT; + else if (mobjscale > 0) mobj->radius = mobjscale; + else + mobj->radius = DEFAULT_WAYPOINT_RADIUS * mapobjectscale; - // Set the radius, mobj z, and mthing z to match what the parameters want - if (line != -1) - { - fixed_t lineradius = sides[lines[line].sidenum[0]].textureoffset; - fixed_t linez = sides[lines[line].sidenum[0]].rowoffset; - - if (lineradius > 0) - mobj->radius = lineradius; - mobj->z += linez; - mthing->z += linez >> FRACBITS; - } // Use threshold to store the next waypoint ID // movecount is being used for the current waypoint ID // reactiontime lets us know if we can respawn at it // lastlook is used for indicating the waypoint is a shortcut // extravalue1 is used for indicating the waypoint is disabled // extravalue2 is used for indicating the waypoint is the finishline - mobj->threshold = ((mthing->options >> ZSHIFT)); - mobj->movecount = mthing->angle; + mobj->threshold = mthing->angle; + mobj->movecount = mthing->tag; if (mthing->options & MTF_EXTRA) { mobj->extravalue1 = 0; // The waypoint is disabled if extra is on @@ -11375,9 +11363,9 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean { mobj->reactiontime = 1; } - if (mthing->extrainfo == 1) + if (mthing->args[1] == 1) { - mobj->extravalue2 = 1; // extrainfo of 1 means the waypoint is at the finish line + mobj->extravalue2 = 1; // args[1] of 1 means the waypoint is at the finish line } else { diff --git a/src/p_setup.c b/src/p_setup.c index 886a402b0..b3fe54d05 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1357,9 +1357,7 @@ static void P_LoadThings(UINT8 *data) mt->type &= 4095; - if (mt->type == mobjinfo[MT_WAYPOINT].doomednum) - mt->z = 0; // Waypoints set Z pos in other methods - else if (mt->type == 1705 || (mt->type == 750 && mt->extrainfo)) + if (mt->type == 1705 || (mt->type == 750 && mt->extrainfo)) mt->z = mt->options; // NiGHTS Hoops use the full flags bits to set the height. else mt->z = mt->options >> ZSHIFT; @@ -3159,6 +3157,27 @@ static void P_ConvertBinaryMap(void) case 780: mapthings[i].tag = mapthings[i].extrainfo; break; + case 2001: // MT_WAYPOINT + { + INT32 firstline = P_FindSpecialLineFromTag(2000, mapthings[i].angle, -1); + + mapthings[i].tag = mapthings[i].angle; + mapthings[i].angle = mapthings[i].z; + mapthings[i].args[1] = mapthings[i].extrainfo; + mapthings[i].z = 0; + + if (firstline != -1) + { + fixed_t lineradius = sides[lines[firstline].sidenum[0]].textureoffset; + fixed_t linez = sides[lines[firstline].sidenum[0]].rowoffset; + + if (lineradius > 0) + mapthings[i].args[0] = lineradius / FRACUNIT; + + mapthings[i].z = linez / FRACUNIT; + } + break; + } default: break; } @@ -3991,9 +4010,6 @@ boolean P_LoadLevel(boolean fromnetsave) P_SpawnSpecialsAfterSlopes(); P_SpawnMapThings(!fromnetsave); - - P_SpawnSpecialsThatRequireObjects(); - skyboxmo[0] = skyboxviewpnts[0]; skyboxmo[1] = skyboxcenterpnts[0]; @@ -4001,7 +4017,13 @@ boolean P_LoadLevel(boolean fromnetsave) if (!playerstarts[numcoopstarts]) break; - K_AdjustWaypointsParameters(); + P_SpawnSpecialsThatRequireObjects(); + + if (!udmf) + { + // Backwards compatibility for non-UDMF maps + K_AdjustWaypointsParameters(); + } if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) P_SpawnPrecipitation(); @@ -4009,7 +4031,7 @@ boolean P_LoadLevel(boolean fromnetsave) // The waypoint data that's in PU_LEVEL needs to be reset back to 0/NULL now since PU_LEVEL was cleared K_ClearWaypoints(); // Load the waypoints please! - if ((gametyperules & GTR_CIRCUIT)) + if (gametyperules & GTR_CIRCUIT) { if (K_SetupWaypointList() == false) {