diff --git a/src/k_waypoint.cpp b/src/k_waypoint.cpp index 377593798..cab010095 100644 --- a/src/k_waypoint.cpp +++ b/src/k_waypoint.cpp @@ -2315,7 +2315,6 @@ static boolean K_RaiseWaypoint( fixed_t sort; fixed_t z; - fixed_t delta; if ( !( riser->spawnpoint->options & MTF_OBJECTSPECIAL ) || @@ -2360,16 +2359,14 @@ static boolean K_RaiseWaypoint( } } - // Keep changes for -writetextmap - if (descending) - delta = sort - waypointmobj->z; - else - delta = waypointmobj->z - sort; - waypointmobj->spawnpoint->z += delta; - waypointmobj->z = sort; } + // Keep changes for -writetextmap + waypointmobj->spawnpoint->z = ((waypointmobj->spawnpoint->options & MTF_OBJECTFLIP) + ? waypointmobj->ceilingz - waypointmobj->z + : waypointmobj->z - waypointmobj->floorz) / FRACUNIT; + return true; } else @@ -2402,7 +2399,7 @@ static boolean K_AnchorWaypointRadius( anchor->x, anchor->y); // Keep changes for -writetextmap - waypointmobj->spawnpoint->args[0] = waypointmobj->radius >> FRACBITS; + waypointmobj->spawnpoint->args[1] = waypointmobj->radius >> FRACBITS; return true; } else diff --git a/src/p_setup.c b/src/p_setup.c index edb13775c..c1b7ae6f2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2189,13 +2189,6 @@ static void P_WriteTextmap(void) subsector_t *ss; INT32 s; - if (wmapthings[i].type == mobjinfo[MT_WAYPOINT].doomednum - || wmapthings[i].type == mobjinfo[MT_WAYPOINT_ANCHOR].doomednum - || wmapthings[i].type == mobjinfo[MT_WAYPOINT_RISER].doomednum) - { - CONS_Alert(CONS_WARNING, M_GetText("Thing %s is a waypoint or waypoint parameter, which cannot be converted fully.\n"), sizeu1(i)); - } - if (wmapthings[i].type != 751 && wmapthings[i].type != 752 && wmapthings[i].type != 758) continue; @@ -2424,6 +2417,14 @@ static void P_WriteTextmap(void) fprintf(f, "namespace = \"srb2\";\n"); for (i = k = 0; i < nummapthings; i++) { + if (wmapthings[i].type == mobjinfo[MT_WAYPOINT].doomednum + || wmapthings[i].type == mobjinfo[MT_WAYPOINT_ANCHOR].doomednum + || wmapthings[i].type == mobjinfo[MT_WAYPOINT_RISER].doomednum) + { + // Skip waypoints. Because the multi-thing setup was merged into a + // single thing type in UDMF, these must be converted later. + continue; + } P_WriteTextmapThing(f, wmapthings, i, k); @@ -2867,6 +2868,29 @@ static void P_WriteTextmap(void) Z_Free(wusedvertexes); } +static void P_WriteTextmapWaypoints(void) +{ + FILE *f; + mobj_t *waypointmobj; + + // Append to output from P_WriteTextmap prior + f = P_OpenTextmap("a", "Couldn't save map file (waypoints)"); + if (!f) + { + return; + } + + for ( + waypointmobj = waypointcap; + waypointmobj; + waypointmobj = waypointmobj->tracer + ){ + P_WriteTextmapThing(f, waypointmobj->spawnpoint, 0, waypointmobj->spawnpoint - mapthings); + } + + fclose(f); +} + /** Loads the textmap data, after obtaining the elements count and allocating their respective space. */ static void P_LoadTextmap(void) @@ -8255,6 +8279,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) { // Backwards compatibility for non-UDMF maps K_AdjustWaypointsParameters(); + + if (M_CheckParm("-writetextmap")) + P_WriteTextmapWaypoints(); } if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)