mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'fix-writetextmap' into 'master'
Fix -writetextmap See merge request KartKrew/Kart!1041
This commit is contained in:
commit
aa1e31e51f
1 changed files with 43 additions and 16 deletions
|
|
@ -122,6 +122,7 @@ unsigned char mapmd5[16];
|
||||||
|
|
||||||
boolean udmf;
|
boolean udmf;
|
||||||
size_t numvertexes, numsegs, numsectors, numsubsectors, numnodes, numlines, numsides, nummapthings;
|
size_t numvertexes, numsegs, numsectors, numsubsectors, numnodes, numlines, numsides, nummapthings;
|
||||||
|
size_t num_orig_vertexes;
|
||||||
vertex_t *vertexes;
|
vertex_t *vertexes;
|
||||||
seg_t *segs;
|
seg_t *segs;
|
||||||
sector_t *sectors;
|
sector_t *sectors;
|
||||||
|
|
@ -1921,6 +1922,7 @@ static void P_WriteTextmap(void)
|
||||||
side_t *wsides;
|
side_t *wsides;
|
||||||
mtag_t freetag;
|
mtag_t freetag;
|
||||||
sectorspecialthings_t *specialthings;
|
sectorspecialthings_t *specialthings;
|
||||||
|
boolean *wusedvertexes;
|
||||||
|
|
||||||
f = fopen(filepath, "w");
|
f = fopen(filepath, "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
|
|
@ -1930,14 +1932,15 @@ static void P_WriteTextmap(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
wmapthings = Z_Calloc(nummapthings * sizeof(*mapthings), PU_LEVEL, NULL);
|
wmapthings = Z_Calloc(nummapthings * sizeof(*mapthings), PU_LEVEL, NULL);
|
||||||
wvertexes = Z_Calloc(numvertexes * sizeof(*vertexes), PU_LEVEL, NULL);
|
wvertexes = Z_Calloc(num_orig_vertexes * sizeof(*vertexes), PU_LEVEL, NULL);
|
||||||
wsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
wsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
||||||
wlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
|
wlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
|
||||||
wsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
|
wsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
|
||||||
specialthings = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
specialthings = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
||||||
|
wusedvertexes = Z_Calloc(num_orig_vertexes * sizeof(boolean), PU_LEVEL, NULL);
|
||||||
|
|
||||||
memcpy(wmapthings, mapthings, nummapthings * sizeof(*mapthings));
|
memcpy(wmapthings, mapthings, nummapthings * sizeof(*mapthings));
|
||||||
memcpy(wvertexes, vertexes, numvertexes * sizeof(*vertexes));
|
memcpy(wvertexes, vertexes, num_orig_vertexes * sizeof(*vertexes));
|
||||||
memcpy(wsectors, sectors, numsectors * sizeof(*sectors));
|
memcpy(wsectors, sectors, numsectors * sizeof(*sectors));
|
||||||
memcpy(wlines, lines, numlines * sizeof(*lines));
|
memcpy(wlines, lines, numlines * sizeof(*lines));
|
||||||
memcpy(wsides, sides, numsides * sizeof(*sides));
|
memcpy(wsides, sides, numsides * sizeof(*sides));
|
||||||
|
|
@ -1951,9 +1954,19 @@ static void P_WriteTextmap(void)
|
||||||
wsectors[i].tags.tags = memcpy(Z_Malloc(sectors[i].tags.count*sizeof(mtag_t), PU_LEVEL, NULL), sectors[i].tags.tags, sectors[i].tags.count*sizeof(mtag_t));
|
wsectors[i].tags.tags = memcpy(Z_Malloc(sectors[i].tags.count*sizeof(mtag_t), PU_LEVEL, NULL), sectors[i].tags.tags, sectors[i].tags.count*sizeof(mtag_t));
|
||||||
|
|
||||||
for (i = 0; i < numlines; i++)
|
for (i = 0; i < numlines; i++)
|
||||||
|
{
|
||||||
|
size_t v;
|
||||||
|
|
||||||
if (lines[i].tags.count)
|
if (lines[i].tags.count)
|
||||||
wlines[i].tags.tags = memcpy(Z_Malloc(lines[i].tags.count * sizeof(mtag_t), PU_LEVEL, NULL), lines[i].tags.tags, lines[i].tags.count * sizeof(mtag_t));
|
wlines[i].tags.tags = memcpy(Z_Malloc(lines[i].tags.count * sizeof(mtag_t), PU_LEVEL, NULL), lines[i].tags.tags, lines[i].tags.count * sizeof(mtag_t));
|
||||||
|
|
||||||
|
v = lines[i].v1 - vertexes;
|
||||||
|
wusedvertexes[v] = true;
|
||||||
|
|
||||||
|
v = lines[i].v2 - vertexes;
|
||||||
|
wusedvertexes[v] = true;
|
||||||
|
}
|
||||||
|
|
||||||
freetag = Tag_NextUnused(0);
|
freetag = Tag_NextUnused(0);
|
||||||
|
|
||||||
for (i = 0; i < nummapthings; i++)
|
for (i = 0; i < nummapthings; i++)
|
||||||
|
|
@ -1961,6 +1974,13 @@ static void P_WriteTextmap(void)
|
||||||
subsector_t *ss;
|
subsector_t *ss;
|
||||||
INT32 s;
|
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)
|
if (wmapthings[i].type != 751 && wmapthings[i].type != 752 && wmapthings[i].type != 758)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -2232,18 +2252,26 @@ static void P_WriteTextmap(void)
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < numvertexes; i++)
|
j = 0;
|
||||||
|
for (i = 0; i < num_orig_vertexes; i++)
|
||||||
{
|
{
|
||||||
fprintf(f, "vertex // %s\n", sizeu1(i));
|
if (wusedvertexes[i] == false)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(f, "vertex // %s\n", sizeu1(j));
|
||||||
fprintf(f, "{\n");
|
fprintf(f, "{\n");
|
||||||
fprintf(f, "x = %f;\n", FIXED_TO_FLOAT(wvertexes[i].x));
|
fprintf(f, "x = %f;\n", FIXED_TO_FLOAT(wvertexes[j].x));
|
||||||
fprintf(f, "y = %f;\n", FIXED_TO_FLOAT(wvertexes[i].y));
|
fprintf(f, "y = %f;\n", FIXED_TO_FLOAT(wvertexes[j].y));
|
||||||
if (wvertexes[i].floorzset)
|
if (wvertexes[j].floorzset)
|
||||||
fprintf(f, "zfloor = %f;\n", FIXED_TO_FLOAT(wvertexes[i].floorz));
|
fprintf(f, "zfloor = %f;\n", FIXED_TO_FLOAT(wvertexes[j].floorz));
|
||||||
if (wvertexes[i].ceilingzset)
|
if (wvertexes[j].ceilingzset)
|
||||||
fprintf(f, "zceiling = %f;\n", FIXED_TO_FLOAT(wvertexes[i].ceilingz));
|
fprintf(f, "zceiling = %f;\n", FIXED_TO_FLOAT(wvertexes[j].ceilingz));
|
||||||
fprintf(f, "}\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < numlines; i++)
|
for (i = 0; i < numlines; i++)
|
||||||
|
|
@ -2563,6 +2591,7 @@ static void P_WriteTextmap(void)
|
||||||
Z_Free(wlines);
|
Z_Free(wlines);
|
||||||
Z_Free(wsides);
|
Z_Free(wsides);
|
||||||
Z_Free(specialthings);
|
Z_Free(specialthings);
|
||||||
|
Z_Free(wusedvertexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Loads the textmap data, after obtaining the elements count and allocating their respective space.
|
/** Loads the textmap data, after obtaining the elements count and allocating their respective space.
|
||||||
|
|
@ -2939,6 +2968,10 @@ static boolean P_LoadMapData(const virtres_t *virt)
|
||||||
if (numlines <= 0)
|
if (numlines <= 0)
|
||||||
I_Error("Level has no linedefs");
|
I_Error("Level has no linedefs");
|
||||||
|
|
||||||
|
// Copy original vertex count before BSP modifications,
|
||||||
|
// as it can alter how -writetextmap works.
|
||||||
|
num_orig_vertexes = numvertexes;
|
||||||
|
|
||||||
vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL);
|
vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL);
|
||||||
sectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL);
|
sectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL);
|
||||||
sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
|
sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
|
||||||
|
|
@ -6880,10 +6913,8 @@ static void P_ConvertBinaryMap(void)
|
||||||
P_ConvertBinaryThingTypes();
|
P_ConvertBinaryThingTypes();
|
||||||
P_ConvertBinaryLinedefFlags();
|
P_ConvertBinaryLinedefFlags();
|
||||||
|
|
||||||
#if 0 // Don't do this yet...
|
|
||||||
if (M_CheckParm("-writetextmap"))
|
if (M_CheckParm("-writetextmap"))
|
||||||
P_WriteTextmap();
|
P_WriteTextmap();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compute MD5 message digest for bytes read from memory source
|
/** Compute MD5 message digest for bytes read from memory source
|
||||||
|
|
@ -7886,10 +7917,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||||
{
|
{
|
||||||
// Backwards compatibility for non-UDMF maps
|
// Backwards compatibility for non-UDMF maps
|
||||||
K_AdjustWaypointsParameters();
|
K_AdjustWaypointsParameters();
|
||||||
|
|
||||||
// Moved over here...
|
|
||||||
if (M_CheckParm("-writetextmap"))
|
|
||||||
P_WriteTextmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)
|
if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue