P_WriteTextmap: Convert colormaps

This commit is contained in:
MascaraSnake 2022-01-09 10:22:25 +01:00
parent a46619684f
commit c1f03e7720

View file

@ -2006,6 +2006,11 @@ static void P_WriteTextmap(void)
FILE *f; FILE *f;
char *filepath = va(pandf, srb2home, "TEXTMAP"); char *filepath = va(pandf, srb2home, "TEXTMAP");
mtag_t firsttag; mtag_t firsttag;
mapthing_t *wmapthings;
vertex_t *wvertexes;
sector_t *wsectors;
line_t *wlines;
side_t *wsides;
f = fopen(filepath, "w"); f = fopen(filepath, "w");
if (!f) if (!f)
@ -2014,6 +2019,34 @@ static void P_WriteTextmap(void)
return; return;
} }
wmapthings = Z_Calloc(nummapthings * sizeof(*mapthings), PU_LEVEL, NULL);
wvertexes = Z_Calloc(numvertexes * sizeof(*vertexes), PU_LEVEL, NULL);
wsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
wlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
wsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
memcpy(wmapthings, mapthings, nummapthings * sizeof(*mapthings));
memcpy(wvertexes, vertexes, numvertexes * sizeof(*vertexes));
memcpy(wsectors, sectors, numsectors * sizeof(*sectors));
memcpy(wlines, lines, numlines * sizeof(*lines));
memcpy(wsides, sides, numsides * sizeof(*sides));
for (i = 0; i < numlines; i++)
{
INT32 s;
if (wlines[i].special != 606)
continue;
TAG_ITER_SECTORS(wlines[i].args[0], s)
{
if (wsectors[s].colormap_protected)
continue;
wsectors[s].extra_colormap = wsides[wlines[i].sidenum[0]].colormap_data;
}
}
fprintf(f, "namespace = \"srb2\";\n"); fprintf(f, "namespace = \"srb2\";\n");
for (i = 0; i < nummapthings; i++) for (i = 0; i < nummapthings; i++)
{ {
@ -2033,24 +2066,24 @@ static void P_WriteTextmap(void)
} }
fprintf(f, "\";\n"); fprintf(f, "\";\n");
} }
fprintf(f, "x = %d;\n", mapthings[i].x); fprintf(f, "x = %d;\n", wmapthings[i].x);
fprintf(f, "y = %d;\n", mapthings[i].y); fprintf(f, "y = %d;\n", wmapthings[i].y);
if (mapthings[i].z != 0) if (wmapthings[i].z != 0)
fprintf(f, "height = %d;\n", mapthings[i].z); fprintf(f, "height = %d;\n", wmapthings[i].z);
fprintf(f, "angle = %d;\n", mapthings[i].angle); fprintf(f, "angle = %d;\n", wmapthings[i].angle);
if (mapthings[i].pitch != 0) if (wmapthings[i].pitch != 0)
fprintf(f, "pitch = %d;\n", mapthings[i].pitch); fprintf(f, "pitch = %d;\n", wmapthings[i].pitch);
if (mapthings[i].roll != 0) if (wmapthings[i].roll != 0)
fprintf(f, "roll = %d;\n", mapthings[i].roll); fprintf(f, "roll = %d;\n", wmapthings[i].roll);
if (mapthings[i].type != 0) if (wmapthings[i].type != 0)
fprintf(f, "type = %d;\n", mapthings[i].type); fprintf(f, "type = %d;\n", wmapthings[i].type);
if (mapthings[i].scale != FRACUNIT) if (wmapthings[i].scale != FRACUNIT)
fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(mapthings[i].scale)); fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
if (mapthings[i].options & MTF_OBJECTFLIP) if (wmapthings[i].options & MTF_OBJECTFLIP)
fprintf(f, "flip = true;\n"); fprintf(f, "flip = true;\n");
for (j = 0; j < NUMMAPTHINGARGS; j++) for (j = 0; j < NUMMAPTHINGARGS; j++)
if (mapthings[i].args[j] != 0) if (wmapthings[i].args[j] != 0)
fprintf(f, "arg%d = %d;\n", j, mapthings[i].args[j]); fprintf(f, "arg%d = %d;\n", j, wmapthings[i].args[j]);
for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++) for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++)
if (mapthings[i].stringargs[j]) if (mapthings[i].stringargs[j])
fprintf(f, "stringarg%d = \"%s\";\n", j, mapthings[i].stringargs[j]); fprintf(f, "stringarg%d = \"%s\";\n", j, mapthings[i].stringargs[j]);
@ -2062,12 +2095,12 @@ static void P_WriteTextmap(void)
{ {
fprintf(f, "vertex // %d\n", i); fprintf(f, "vertex // %d\n", i);
fprintf(f, "{\n"); fprintf(f, "{\n");
fprintf(f, "x = %f;\n", FIXED_TO_FLOAT(vertexes[i].x)); fprintf(f, "x = %f;\n", FIXED_TO_FLOAT(wvertexes[i].x));
fprintf(f, "y = %f;\n", FIXED_TO_FLOAT(vertexes[i].y)); fprintf(f, "y = %f;\n", FIXED_TO_FLOAT(wvertexes[i].y));
if (vertexes[i].floorzset) if (wvertexes[i].floorzset)
fprintf(f, "zfloor = %f;\n", FIXED_TO_FLOAT(vertexes[i].floorz)); fprintf(f, "zfloor = %f;\n", FIXED_TO_FLOAT(wvertexes[i].floorz));
if (vertexes[i].ceilingzset) if (wvertexes[i].ceilingzset)
fprintf(f, "zceiling = %f;\n", FIXED_TO_FLOAT(vertexes[i].ceilingz)); fprintf(f, "zceiling = %f;\n", FIXED_TO_FLOAT(wvertexes[i].ceilingz));
fprintf(f, "}\n"); fprintf(f, "}\n");
fprintf(f, "\n"); fprintf(f, "\n");
} }
@ -2076,11 +2109,11 @@ static void P_WriteTextmap(void)
{ {
fprintf(f, "linedef // %d\n", i); fprintf(f, "linedef // %d\n", i);
fprintf(f, "{\n"); fprintf(f, "{\n");
fprintf(f, "v1 = %d;\n", lines[i].v1 - vertexes); fprintf(f, "v1 = %d;\n", wlines[i].v1 - vertexes);
fprintf(f, "v2 = %d;\n", lines[i].v2 - vertexes); fprintf(f, "v2 = %d;\n", wlines[i].v2 - vertexes);
fprintf(f, "sidefront = %d;\n", lines[i].sidenum[0]); fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]);
if (lines[i].sidenum[1] != 0xffff) if (wlines[i].sidenum[1] != 0xffff)
fprintf(f, "sideback = %d;\n", lines[i].sidenum[1]); fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]);
firsttag = Tag_FGet(&lines[i].tags); firsttag = Tag_FGet(&lines[i].tags);
if (firsttag != 0) if (firsttag != 0)
fprintf(f, "id = %d;\n", firsttag); fprintf(f, "id = %d;\n", firsttag);
@ -2095,19 +2128,19 @@ static void P_WriteTextmap(void)
} }
fprintf(f, "\";\n"); fprintf(f, "\";\n");
} }
if (lines[i].special != 0) if (wlines[i].special != 0)
fprintf(f, "special = %d;\n", lines[i].special); fprintf(f, "special = %d;\n", wlines[i].special);
for (j = 0; j < NUMLINEARGS; j++) for (j = 0; j < NUMLINEARGS; j++)
if (lines[i].args[j] != 0) if (wlines[i].args[j] != 0)
fprintf(f, "arg%d = %d;\n", j, lines[i].args[j]); fprintf(f, "arg%d = %d;\n", j, wlines[i].args[j]);
for (j = 0; j < NUMLINESTRINGARGS; j++) for (j = 0; j < NUMLINESTRINGARGS; j++)
if (lines[i].stringargs[j]) if (lines[i].stringargs[j])
fprintf(f, "stringarg%d = \"%s\";\n", j, lines[i].stringargs[j]); fprintf(f, "stringarg%d = \"%s\";\n", j, lines[i].stringargs[j]);
if (lines[i].alpha != FRACUNIT) if (wlines[i].alpha != FRACUNIT)
fprintf(f, "alpha = %f;\n", FIXED_TO_FLOAT(lines[i].alpha)); fprintf(f, "alpha = %f;\n", FIXED_TO_FLOAT(wlines[i].alpha));
if (lines[i].blendmode != AST_COPY) if (wlines[i].blendmode != AST_COPY)
{ {
switch (lines[i].blendmode) switch (wlines[i].blendmode)
{ {
case AST_ADD: case AST_ADD:
fprintf(f, "renderstyle = \"add\";\n"); fprintf(f, "renderstyle = \"add\";\n");
@ -2128,37 +2161,37 @@ static void P_WriteTextmap(void)
break; break;
} }
} }
if (lines[i].executordelay != 0) if (wlines[i].executordelay != 0)
fprintf(f, "executordelay = %d;\n", lines[i].executordelay); fprintf(f, "executordelay = %d;\n", wlines[i].executordelay);
if (lines[i].flags & ML_IMPASSIBLE) if (wlines[i].flags & ML_IMPASSIBLE)
fprintf(f, "blocking = true;\n"); fprintf(f, "blocking = true;\n");
if (lines[i].flags & ML_BLOCKMONSTERS) if (wlines[i].flags & ML_BLOCKMONSTERS)
fprintf(f, "blockmonsters = true;\n"); fprintf(f, "blockmonsters = true;\n");
if (lines[i].flags & ML_TWOSIDED) if (wlines[i].flags & ML_TWOSIDED)
fprintf(f, "twosided = true;\n"); fprintf(f, "twosided = true;\n");
if (lines[i].flags & ML_DONTPEGTOP) if (wlines[i].flags & ML_DONTPEGTOP)
fprintf(f, "dontpegtop = true;\n"); fprintf(f, "dontpegtop = true;\n");
if (lines[i].flags & ML_DONTPEGBOTTOM) if (wlines[i].flags & ML_DONTPEGBOTTOM)
fprintf(f, "dontpegbottom = true;\n"); fprintf(f, "dontpegbottom = true;\n");
if (lines[i].flags & ML_SKEWTD) if (wlines[i].flags & ML_SKEWTD)
fprintf(f, "skewtd = true;\n"); fprintf(f, "skewtd = true;\n");
if (lines[i].flags & ML_NOCLIMB) if (wlines[i].flags & ML_NOCLIMB)
fprintf(f, "noclimb = true;\n"); fprintf(f, "noclimb = true;\n");
if (lines[i].flags & ML_NOSKEW) if (wlines[i].flags & ML_NOSKEW)
fprintf(f, "noskew = true;\n"); fprintf(f, "noskew = true;\n");
if (lines[i].flags & ML_MIDPEG) if (wlines[i].flags & ML_MIDPEG)
fprintf(f, "midpeg = true;\n"); fprintf(f, "midpeg = true;\n");
if (lines[i].flags & ML_MIDSOLID) if (wlines[i].flags & ML_MIDSOLID)
fprintf(f, "midsolid = true;\n"); fprintf(f, "midsolid = true;\n");
if (lines[i].flags & ML_WRAPMIDTEX) if (wlines[i].flags & ML_WRAPMIDTEX)
fprintf(f, "wrapmidtex = true;\n"); fprintf(f, "wrapmidtex = true;\n");
if (lines[i].flags & ML_NONET) if (wlines[i].flags & ML_NONET)
fprintf(f, "nonet = true;\n"); fprintf(f, "nonet = true;\n");
if (lines[i].flags & ML_NETONLY) if (wlines[i].flags & ML_NETONLY)
fprintf(f, "netonly = true;\n"); fprintf(f, "netonly = true;\n");
if (lines[i].flags & ML_BOUNCY) if (wlines[i].flags & ML_BOUNCY)
fprintf(f, "bouncy = true;\n"); fprintf(f, "bouncy = true;\n");
if (lines[i].flags & ML_TFERLINE) if (wlines[i].flags & ML_TFERLINE)
fprintf(f, "transfer = true;\n"); fprintf(f, "transfer = true;\n");
fprintf(f, "}\n"); fprintf(f, "}\n");
fprintf(f, "\n"); fprintf(f, "\n");
@ -2168,19 +2201,19 @@ static void P_WriteTextmap(void)
{ {
fprintf(f, "sidedef // %d\n", i); fprintf(f, "sidedef // %d\n", i);
fprintf(f, "{\n"); fprintf(f, "{\n");
fprintf(f, "sector = %d;\n", sides[i].sector - sectors); fprintf(f, "sector = %d;\n", wsides[i].sector - sectors);
if (sides[i].textureoffset != 0) if (wsides[i].textureoffset != 0)
fprintf(f, "offsetx = %d;\n", sides[i].textureoffset >> FRACBITS); fprintf(f, "offsetx = %d;\n", wsides[i].textureoffset >> FRACBITS);
if (sides[i].rowoffset != 0) if (wsides[i].rowoffset != 0)
fprintf(f, "offsety = %d;\n", sides[i].rowoffset >> FRACBITS); fprintf(f, "offsety = %d;\n", wsides[i].rowoffset >> FRACBITS);
if (sides[i].toptexture > 0 && sides[i].toptexture < numtextures) if (wsides[i].toptexture > 0 && wsides[i].toptexture < numtextures)
fprintf(f, "texturetop = \"%.*s\";\n", 8, textures[sides[i].toptexture]->name); fprintf(f, "texturetop = \"%.*s\";\n", 8, textures[wsides[i].toptexture]->name);
if (sides[i].bottomtexture > 0 && sides[i].bottomtexture < numtextures) if (wsides[i].bottomtexture > 0 && wsides[i].bottomtexture < numtextures)
fprintf(f, "texturebottom = \"%.*s\";\n", 8, textures[sides[i].bottomtexture]->name); fprintf(f, "texturebottom = \"%.*s\";\n", 8, textures[wsides[i].bottomtexture]->name);
if (sides[i].midtexture > 0 && sides[i].midtexture < numtextures) if (wsides[i].midtexture > 0 && wsides[i].midtexture < numtextures)
fprintf(f, "texturemiddle = \"%.*s\";\n", 8, textures[sides[i].midtexture]->name); fprintf(f, "texturemiddle = \"%.*s\";\n", 8, textures[wsides[i].midtexture]->name);
if (sides[i].repeatcnt != 0) if (wsides[i].repeatcnt != 0)
fprintf(f, "repeatcnt = %d;\n", sides[i].repeatcnt); fprintf(f, "repeatcnt = %d;\n", wsides[i].repeatcnt);
fprintf(f, "}\n"); fprintf(f, "}\n");
fprintf(f, "\n"); fprintf(f, "\n");
} }
@ -2189,20 +2222,20 @@ static void P_WriteTextmap(void)
{ {
fprintf(f, "sector // %d\n", i); fprintf(f, "sector // %d\n", i);
fprintf(f, "{\n"); fprintf(f, "{\n");
fprintf(f, "heightfloor = %d;\n", sectors[i].floorheight >> FRACBITS); fprintf(f, "heightfloor = %d;\n", wsectors[i].floorheight >> FRACBITS);
fprintf(f, "heightceiling = %d;\n", sectors[i].ceilingheight >> FRACBITS); fprintf(f, "heightceiling = %d;\n", wsectors[i].ceilingheight >> FRACBITS);
if (sectors[i].floorpic != -1) if (wsectors[i].floorpic != -1)
fprintf(f, "texturefloor = \"%s\";\n", levelflats[sectors[i].floorpic].name); fprintf(f, "texturefloor = \"%s\";\n", levelflats[wsectors[i].floorpic].name);
if (sectors[i].ceilingpic != -1) if (wsectors[i].ceilingpic != -1)
fprintf(f, "textureceiling = \"%s\";\n", levelflats[sectors[i].ceilingpic].name); fprintf(f, "textureceiling = \"%s\";\n", levelflats[wsectors[i].ceilingpic].name);
fprintf(f, "lightlevel = %d;\n", sectors[i].lightlevel); fprintf(f, "lightlevel = %d;\n", wsectors[i].lightlevel);
if (sectors[i].floorlightlevel != 0) if (wsectors[i].floorlightlevel != 0)
fprintf(f, "lightfloor = %d;\n", sectors[i].floorlightlevel); fprintf(f, "lightfloor = %d;\n", wsectors[i].floorlightlevel);
if (sectors[i].floorlightabsolute) if (wsectors[i].floorlightabsolute)
fprintf(f, "lightfloorabsolute = true;\n"); fprintf(f, "lightfloorabsolute = true;\n");
if (sectors[i].ceilinglightlevel != 0) if (wsectors[i].ceilinglightlevel != 0)
fprintf(f, "lightceiling = %d;\n", sectors[i].ceilinglightlevel); fprintf(f, "lightceiling = %d;\n", wsectors[i].ceilinglightlevel);
if (sectors[i].ceilinglightabsolute) if (wsectors[i].ceilinglightabsolute)
fprintf(f, "lightceilingabsolute = true;\n"); fprintf(f, "lightceilingabsolute = true;\n");
firsttag = Tag_FGet(&sectors[i].tags); firsttag = Tag_FGet(&sectors[i].tags);
if (firsttag != 0) if (firsttag != 0)
@ -2218,7 +2251,7 @@ static void P_WriteTextmap(void)
} }
fprintf(f, "\";\n"); fprintf(f, "\";\n");
} }
sector_t tempsec = sectors[i]; sector_t tempsec = wsectors[i];
TextmapUnfixFlatOffsets(&tempsec); TextmapUnfixFlatOffsets(&tempsec);
if (tempsec.floor_xoffs != 0) if (tempsec.floor_xoffs != 0)
fprintf(f, "xpanningfloor = %f;\n", FIXED_TO_FLOAT(tempsec.floor_xoffs)); fprintf(f, "xpanningfloor = %f;\n", FIXED_TO_FLOAT(tempsec.floor_xoffs));
@ -2228,39 +2261,39 @@ static void P_WriteTextmap(void)
fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceiling_xoffs)); fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceiling_xoffs));
if (tempsec.ceiling_yoffs != 0) if (tempsec.ceiling_yoffs != 0)
fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceiling_yoffs)); fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceiling_yoffs));
if (sectors[i].floorpic_angle != 0) if (wsectors[i].floorpic_angle != 0)
fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(sectors[i].floorpic_angle))); fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].floorpic_angle)));
if (sectors[i].ceilingpic_angle != 0) if (wsectors[i].ceilingpic_angle != 0)
fprintf(f, "rotationceiling = %f;\n", FIXED_TO_FLOAT(AngleFixed(sectors[i].ceilingpic_angle))); fprintf(f, "rotationceiling = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].ceilingpic_angle)));
//TODO: Only if slope was defined via equations //TODO: Only if slope was defined via equations
/*if (sectors[i].f_slope) /*if (wsectors[i].f_slope)
{ {
fixed_t a = sectors[i].f_slope->normal.x; fixed_t a = wsectors[i].f_slope->normal.x;
fixed_t b = sectors[i].f_slope->normal.y; fixed_t b = wsectors[i].f_slope->normal.y;
fixed_t c = sectors[i].f_slope->normal.z; fixed_t c = wsectors[i].f_slope->normal.z;
fixed_t d = -FV3_Dot(&sectors[i].f_slope->normal, &sectors[i].f_slope->o); fixed_t d = -FV3_Dot(&wsectors[i].f_slope->normal, &wsectors[i].f_slope->o);
fprintf(f, "floorplane_a = %f;\n", FIXED_TO_FLOAT(a)); fprintf(f, "floorplane_a = %f;\n", FIXED_TO_FLOAT(a));
fprintf(f, "floorplane_b = %f;\n", FIXED_TO_FLOAT(b)); fprintf(f, "floorplane_b = %f;\n", FIXED_TO_FLOAT(b));
fprintf(f, "floorplane_c = %f;\n", FIXED_TO_FLOAT(c)); fprintf(f, "floorplane_c = %f;\n", FIXED_TO_FLOAT(c));
fprintf(f, "floorplane_d = %f;\n", FIXED_TO_FLOAT(d)); fprintf(f, "floorplane_d = %f;\n", FIXED_TO_FLOAT(d));
} }
if (sectors[i].c_slope) if (wsectors[i].c_slope)
{ {
fixed_t a = sectors[i].c_slope->normal.x; fixed_t a = wsectors[i].c_slope->normal.x;
fixed_t b = sectors[i].c_slope->normal.y; fixed_t b = wsectors[i].c_slope->normal.y;
fixed_t c = sectors[i].c_slope->normal.z; fixed_t c = wsectors[i].c_slope->normal.z;
fixed_t d = -FV3_Dot(&sectors[i].c_slope->normal, &sectors[i].c_slope->o); fixed_t d = -FV3_Dot(&wsectors[i].c_slope->normal, &wsectors[i].c_slope->o);
fprintf(f, "ceilingplane_a = %f;\n", FIXED_TO_FLOAT(a)); fprintf(f, "ceilingplane_a = %f;\n", FIXED_TO_FLOAT(a));
fprintf(f, "ceilingplane_b = %f;\n", FIXED_TO_FLOAT(b)); fprintf(f, "ceilingplane_b = %f;\n", FIXED_TO_FLOAT(b));
fprintf(f, "ceilingplane_c = %f;\n", FIXED_TO_FLOAT(c)); fprintf(f, "ceilingplane_c = %f;\n", FIXED_TO_FLOAT(c));
fprintf(f, "ceilingplane_d = %f;\n", FIXED_TO_FLOAT(d)); fprintf(f, "ceilingplane_d = %f;\n", FIXED_TO_FLOAT(d));
}*/ }*/
if (sectors[i].extra_colormap) if (wsectors[i].extra_colormap)
{ {
INT32 lightcolor = P_RGBAToColor(sectors[i].extra_colormap->rgba); INT32 lightcolor = P_RGBAToColor(wsectors[i].extra_colormap->rgba);
UINT8 lightalpha = R_GetRgbaA(sectors[i].extra_colormap->rgba); UINT8 lightalpha = R_GetRgbaA(wsectors[i].extra_colormap->rgba);
INT32 fadecolor = P_RGBAToColor(sectors[i].extra_colormap->fadergba); INT32 fadecolor = P_RGBAToColor(wsectors[i].extra_colormap->fadergba);
UINT8 fadealpha = R_GetRgbaA(sectors[i].extra_colormap->fadergba); UINT8 fadealpha = R_GetRgbaA(wsectors[i].extra_colormap->fadergba);
if (lightcolor != 0) if (lightcolor != 0)
fprintf(f, "lightcolor = %d;\n", lightcolor); fprintf(f, "lightcolor = %d;\n", lightcolor);
@ -2270,78 +2303,78 @@ static void P_WriteTextmap(void)
fprintf(f, "fadecolor = %d;\n", fadecolor); fprintf(f, "fadecolor = %d;\n", fadecolor);
if (fadealpha != 25) if (fadealpha != 25)
fprintf(f, "fadealpha = %d;\n", fadealpha); fprintf(f, "fadealpha = %d;\n", fadealpha);
if (sectors[i].extra_colormap->fadestart != 0) if (wsectors[i].extra_colormap->fadestart != 0)
fprintf(f, "fadestart = %d;\n", sectors[i].extra_colormap->fadestart); fprintf(f, "fadestart = %d;\n", wsectors[i].extra_colormap->fadestart);
if (sectors[i].extra_colormap->fadeend != 31) if (wsectors[i].extra_colormap->fadeend != 31)
fprintf(f, "fadeend = %d;\n", sectors[i].extra_colormap->fadeend); fprintf(f, "fadeend = %d;\n", wsectors[i].extra_colormap->fadeend);
if (sectors[i].extra_colormap->flags & CMF_FOG) if (wsectors[i].extra_colormap->flags & CMF_FOG)
fprintf(f, "colormapfog = true;\n"); fprintf(f, "colormapfog = true;\n");
if (sectors[i].extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES) if (wsectors[i].extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES)
fprintf(f, "colormapfadesprites = true;\n"); fprintf(f, "colormapfadesprites = true;\n");
} }
if (sectors[i].colormap_protected) if (wsectors[i].colormap_protected)
fprintf(f, "colormapprotected = true;\n"); fprintf(f, "colormapprotected = true;\n");
if (!(sectors[i].flags & MSF_FLIPSPECIAL_FLOOR)) if (!(wsectors[i].flags & MSF_FLIPSPECIAL_FLOOR))
fprintf(f, "flipspecial_nofloor = true;\n"); fprintf(f, "flipspecial_nofloor = true;\n");
if (sectors[i].flags & MSF_FLIPSPECIAL_CEILING) if (wsectors[i].flags & MSF_FLIPSPECIAL_CEILING)
fprintf(f, "flipspecial_ceiling = true;\n"); fprintf(f, "flipspecial_ceiling = true;\n");
if (sectors[i].flags & MSF_TRIGGERSPECIAL_TOUCH) if (wsectors[i].flags & MSF_TRIGGERSPECIAL_TOUCH)
fprintf(f, "triggerspecial_touch = true;\n"); fprintf(f, "triggerspecial_touch = true;\n");
if (sectors[i].flags & MSF_TRIGGERSPECIAL_HEADBUMP) if (wsectors[i].flags & MSF_TRIGGERSPECIAL_HEADBUMP)
fprintf(f, "triggerspecial_headbump = true;\n"); fprintf(f, "triggerspecial_headbump = true;\n");
if (sectors[i].flags & MSF_TRIGGERLINE_PLANE) if (wsectors[i].flags & MSF_TRIGGERLINE_PLANE)
fprintf(f, "triggerline_plane = true;\n"); fprintf(f, "triggerline_plane = true;\n");
if (sectors[i].flags & MSF_TRIGGERLINE_MOBJ) if (wsectors[i].flags & MSF_TRIGGERLINE_MOBJ)
fprintf(f, "triggerline_mobj = true;\n"); fprintf(f, "triggerline_mobj = true;\n");
if (sectors[i].flags & MSF_INVERTPRECIP) if (wsectors[i].flags & MSF_INVERTPRECIP)
fprintf(f, "invertprecip = true;\n"); fprintf(f, "invertprecip = true;\n");
if (sectors[i].flags & MSF_GRAVITYFLIP) if (wsectors[i].flags & MSF_GRAVITYFLIP)
fprintf(f, "gravityflip = true;\n"); fprintf(f, "gravityflip = true;\n");
if (sectors[i].flags & MSF_HEATWAVE) if (wsectors[i].flags & MSF_HEATWAVE)
fprintf(f, "heatwave = true;\n"); fprintf(f, "heatwave = true;\n");
if (sectors[i].flags & MSF_NOCLIPCAMERA) if (wsectors[i].flags & MSF_NOCLIPCAMERA)
fprintf(f, "noclipcamera = true;\n"); fprintf(f, "noclipcamera = true;\n");
if (sectors[i].specialflags & SSF_OUTERSPACE) if (wsectors[i].specialflags & SSF_OUTERSPACE)
fprintf(f, "outerspace = true;\n"); fprintf(f, "outerspace = true;\n");
if (sectors[i].specialflags & SSF_DOUBLESTEPUP) if (wsectors[i].specialflags & SSF_DOUBLESTEPUP)
fprintf(f, "doublestepup = true;\n"); fprintf(f, "doublestepup = true;\n");
if (sectors[i].specialflags & SSF_NOSTEPDOWN) if (wsectors[i].specialflags & SSF_NOSTEPDOWN)
fprintf(f, "nostepdown = true;\n"); fprintf(f, "nostepdown = true;\n");
if (sectors[i].specialflags & SSF_SPEEDPAD) if (wsectors[i].specialflags & SSF_SPEEDPAD)
fprintf(f, "speedpad = true;\n"); fprintf(f, "speedpad = true;\n");
if (sectors[i].specialflags & SSF_STARPOSTACTIVATOR) if (wsectors[i].specialflags & SSF_STARPOSTACTIVATOR)
fprintf(f, "starpostactivator = true;\n"); fprintf(f, "starpostactivator = true;\n");
if (sectors[i].specialflags & SSF_EXIT) if (wsectors[i].specialflags & SSF_EXIT)
fprintf(f, "exit = true;\n"); fprintf(f, "exit = true;\n");
if (sectors[i].specialflags & SSF_SPECIALSTAGEPIT) if (wsectors[i].specialflags & SSF_SPECIALSTAGEPIT)
fprintf(f, "specialstagepit = true;\n"); fprintf(f, "specialstagepit = true;\n");
if (sectors[i].specialflags & SSF_RETURNFLAG) if (wsectors[i].specialflags & SSF_RETURNFLAG)
fprintf(f, "returnflag = true;\n"); fprintf(f, "returnflag = true;\n");
if (sectors[i].specialflags & SSF_REDTEAMBASE) if (wsectors[i].specialflags & SSF_REDTEAMBASE)
fprintf(f, "redteambase = true;\n"); fprintf(f, "redteambase = true;\n");
if (sectors[i].specialflags & SSF_BLUETEAMBASE) if (wsectors[i].specialflags & SSF_BLUETEAMBASE)
fprintf(f, "blueteambase = true;\n"); fprintf(f, "blueteambase = true;\n");
if (sectors[i].specialflags & SSF_FAN) if (wsectors[i].specialflags & SSF_FAN)
fprintf(f, "fan = true;\n"); fprintf(f, "fan = true;\n");
if (sectors[i].specialflags & SSF_SUPERTRANSFORM) if (wsectors[i].specialflags & SSF_SUPERTRANSFORM)
fprintf(f, "supertransform = true;\n"); fprintf(f, "supertransform = true;\n");
if (sectors[i].specialflags & SSF_FORCESPIN) if (wsectors[i].specialflags & SSF_FORCESPIN)
fprintf(f, "forcespin = true;\n"); fprintf(f, "forcespin = true;\n");
if (sectors[i].specialflags & SSF_ZOOMTUBESTART) if (wsectors[i].specialflags & SSF_ZOOMTUBESTART)
fprintf(f, "zoomtubestart = true;\n"); fprintf(f, "zoomtubestart = true;\n");
if (sectors[i].specialflags & SSF_ZOOMTUBEEND) if (wsectors[i].specialflags & SSF_ZOOMTUBEEND)
fprintf(f, "zoomtubeend = true;\n"); fprintf(f, "zoomtubeend = true;\n");
if (sectors[i].specialflags & SSF_FINISHLINE) if (wsectors[i].specialflags & SSF_FINISHLINE)
fprintf(f, "finishline = true;\n"); fprintf(f, "finishline = true;\n");
if (sectors[i].specialflags & SSF_ROPEHANG) if (wsectors[i].specialflags & SSF_ROPEHANG)
fprintf(f, "ropehang = true;\n"); fprintf(f, "ropehang = true;\n");
if (sectors[i].friction != ORIG_FRICTION) if (wsectors[i].friction != ORIG_FRICTION)
fprintf(f, "friction = %f;\n", FIXED_TO_FLOAT(sectors[i].friction)); fprintf(f, "friction = %f;\n", FIXED_TO_FLOAT(wsectors[i].friction));
if (sectors[i].gravity != FRACUNIT) if (wsectors[i].gravity != FRACUNIT)
fprintf(f, "gravity = %f;\n", FIXED_TO_FLOAT(sectors[i].gravity)); fprintf(f, "gravity = %f;\n", FIXED_TO_FLOAT(wsectors[i].gravity));
if (sectors[i].damagetype != SD_NONE) if (wsectors[i].damagetype != SD_NONE)
{ {
switch (sectors[i].damagetype) switch (wsectors[i].damagetype)
{ {
case SD_GENERIC: case SD_GENERIC:
fprintf(f, "damagetype = \"Generic\";\n"); fprintf(f, "damagetype = \"Generic\";\n");
@ -2377,15 +2410,21 @@ static void P_WriteTextmap(void)
break; break;
} }
} }
if (sectors[i].triggertag != 0) if (wsectors[i].triggertag != 0)
fprintf(f, "triggertag = %d;\n", sectors[i].triggertag); fprintf(f, "triggertag = %d;\n", wsectors[i].triggertag);
if (sectors[i].triggerer != 0) if (wsectors[i].triggerer != 0)
fprintf(f, "triggerer = %d;\n", sectors[i].triggerer); fprintf(f, "triggerer = %d;\n", wsectors[i].triggerer);
fprintf(f, "}\n"); fprintf(f, "}\n");
fprintf(f, "\n"); fprintf(f, "\n");
} }
fclose(f); fclose(f);
Z_Free(wmapthings);
Z_Free(wvertexes);
Z_Free(wsectors);
Z_Free(wlines);
Z_Free(wsides);
} }
/** 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.