Skip to content

Commit f0fca30

Browse files
committed
Implement ID24 flat rotation/offsets
Adapted from Odamex.
1 parent c2a4705 commit f0fca30

File tree

9 files changed

+179
-36
lines changed

9 files changed

+179
-36
lines changed

releasenotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* A bug is fixed whereby things spawned using the [*MBF21*](https://doomwiki.org/wiki/MBF21)-compatible `A_SpawnObject` codepointer couldn’t be made translucent.
1919
* `Retro bits = MOREBLOOD` can now be used to spawn blood splats around a thing with a custom sprite at the start of a map when the `r_corpses_moreblood` CVAR is `on`.
2020
* These changes have been made to [*ID24*](https://doomwiki.org/wiki/ID24) compatibility:
21+
* Flats can now be offset and rotated using line specials 2,048 to 2,056.
2122
* Colormaps can now be applied to individual sectors using line specials 2,075 to 2,081.
2223
* These changes have been made to the support for the [`SKYDEFS`](https://doomwiki.org/wiki/SKYDEFS) lump:
2324
* Skies can now be scaled using `scalex`.

src/p_saveg.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@ void P_ArchiveWorld(void)
11571157
saveg_write32(sector->ceilingxoffset);
11581158
saveg_write32(sector->ceilingyoffset);
11591159
saveg_write32(sector->colormap);
1160+
saveg_write32(sector->floorrotation);
1161+
saveg_write32(sector->ceilingrotation);
11601162
}
11611163

11621164
// do lines
@@ -1165,6 +1167,7 @@ void P_ArchiveWorld(void)
11651167
saveg_write16(line->flags);
11661168
saveg_write16(line->special);
11671169
saveg_write16(line->tag);
1170+
saveg_write32(line->angle);
11681171

11691172
for (int j = 0; j < 2; j++)
11701173
{
@@ -1224,7 +1227,11 @@ void P_UnarchiveWorld(void)
12241227
sector->baseceilingyoffset = sector->oldceilingyoffset = sector->ceilingyoffset;
12251228

12261229
if (!M_StringCompare(savegameversion, DOOMRETRO_SAVEGAMEVERSION_3_6))
1230+
{
12271231
sector->colormap = saveg_read32();
1232+
sector->floorrotation = saveg_read32();
1233+
sector->ceilingrotation = saveg_read32();
1234+
}
12281235
}
12291236

12301237
// do lines
@@ -1239,6 +1246,9 @@ void P_UnarchiveWorld(void)
12391246
line->special = saveg_read16();
12401247
line->tag = saveg_read16();
12411248

1249+
if (!M_StringCompare(savegameversion, DOOMRETRO_SAVEGAMEVERSION_3_6))
1250+
line->angle = saveg_read32();
1251+
12421252
for (int j = 0; j < 2; j++)
12431253
{
12441254
side_t *side;

src/p_setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,8 @@ static void P_LoadLineDefs(int lump)
20872087

20882088
ld->slopetype = (!ld->dx ? ST_VERTICAL : (!ld->dy ? ST_HORIZONTAL : (FixedDiv(ld->dy, ld->dx) > 0 ? ST_POSITIVE : ST_NEGATIVE)));
20892089

2090+
ld->angle = R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y);
2091+
20902092
if (v1->x < v2->x)
20912093
{
20922094
ld->bbox[BOXLEFT] = v1->x;

src/p_spec.c

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,20 +2745,6 @@ void P_SpawnSpecials(void)
27452745
break;
27462746
}
27472747

2748-
// [KLN] 04/13/25: Support for the ID24 line special 2075: Set the target sector's colormap
2749-
// (Always) uses a new SHORT in side_t, which is loaded via P_LoadSideDefs2
2750-
// Uses the front color map index set by the toptexture since this line cannot be activated
2751-
// by the back (or any other way but automatically)
2752-
case SetTheTargetSectorsColormap:
2753-
{
2754-
const short index = sides[*line->sidenum].frontcolormap;
2755-
2756-
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2757-
sectors[s].colormap = index;
2758-
2759-
break;
2760-
}
2761-
27622748
// killough 03/16/98: Add support for setting floor lighting independently (e.g. lava)
27632749
case Floor_ChangeBrightnessToThisBrightness:
27642750
{
@@ -2794,6 +2780,103 @@ void P_SpawnSpecials(void)
27942780
sectors[s].floorsky = sectors[s].ceilingsky = (i | PL_SKYFLAT);
27952781

27962782
break;
2783+
2784+
case OffsetTargetFloorTextureByLineDirection:
2785+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2786+
{
2787+
sectors[s].floorxoffset -= line->dx;
2788+
sectors[s].flooryoffset += line->dy;
2789+
}
2790+
2791+
break;
2792+
2793+
case OffsetTargetCeilingTextureByLineDirection:
2794+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2795+
{
2796+
sectors[s].ceilingxoffset -= line->dx;
2797+
sectors[s].ceilingyoffset += line->dy;
2798+
}
2799+
2800+
break;
2801+
2802+
case OffsetTargetFloorAndCeilingTextureByLineDirection:
2803+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2804+
{
2805+
sectors[s].floorxoffset -= line->dx;
2806+
sectors[s].flooryoffset += line->dy;
2807+
sectors[s].ceilingxoffset -= line->dx;
2808+
sectors[s].ceilingyoffset += line->dy;
2809+
}
2810+
2811+
break;
2812+
2813+
case RotateTargetFloorTextureByLineAngle:
2814+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2815+
sectors[s].floorrotation -= line->angle;
2816+
2817+
break;
2818+
2819+
case RotateTargetCeilingTextureByLineAngle:
2820+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2821+
sectors[s].ceilingrotation -= line->angle;
2822+
2823+
break;
2824+
2825+
case RotateTargetFloorAndCeilingTextureByLineAngle:
2826+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2827+
{
2828+
sectors[s].floorrotation -= line->angle;
2829+
sectors[s].ceilingrotation -= line->angle;
2830+
}
2831+
2832+
break;
2833+
2834+
case OffsetThenRotateTargetFloorTextureByLineDirectionAndAngle:
2835+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2836+
{
2837+
sectors[s].floorxoffset -= line->dx;
2838+
sectors[s].flooryoffset += line->dy;
2839+
sectors[s].floorrotation -= line->angle;
2840+
}
2841+
2842+
break;
2843+
2844+
case OffsetThenRotateTargetCeilingTextureByLineDirectionAndAngle:
2845+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2846+
{
2847+
sectors[s].ceilingxoffset -= line->dx;
2848+
sectors[s].ceilingyoffset += line->dy;
2849+
sectors[s].ceilingrotation -= line->angle;
2850+
}
2851+
2852+
break;
2853+
2854+
case OffsetThenRotateTargetFloorAndCeiilngTextureByLineDirectionAndAngle:
2855+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2856+
{
2857+
sectors[s].floorxoffset -= line->dx;
2858+
sectors[s].flooryoffset += line->dy;
2859+
sectors[s].ceilingxoffset -= line->dx;
2860+
sectors[s].ceilingyoffset += line->dy;
2861+
sectors[s].floorrotation -= line->angle;
2862+
sectors[s].ceilingrotation -= line->angle;
2863+
}
2864+
2865+
break;
2866+
2867+
// [KLN] 04/13/25: Support for the ID24 line special 2075: Set the target sector's colormap
2868+
// (Always) uses a new SHORT in side_t, which is loaded via P_LoadSideDefs2
2869+
// Uses the front color map index set by the toptexture since this line cannot be activated
2870+
// by the back (or any other way but automatically)
2871+
case SetTheTargetSectorsColormap:
2872+
{
2873+
const short index = sides[*line->sidenum].frontcolormap;
2874+
2875+
for (int s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0; )
2876+
sectors[s].colormap = index;
2877+
2878+
break;
2879+
}
27972880
}
27982881
}
27992882

src/r_bsp.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ static void R_RecalcLineFlags(line_t *line)
143143
|| backsector->floorpic != frontsector->floorpic
144144
|| backsector->ceilingpic != frontsector->ceilingpic
145145
|| backsector->lightlevel != frontsector->lightlevel
146-
|| backsector->colormap != frontsector->colormap)
146+
|| backsector->colormap != frontsector->colormap
147+
|| backsector->floorrotation != frontsector->floorrotation
148+
|| backsector->ceilingrotation != frontsector->ceilingrotation)
147149
{
148150
line->r_flags = RF_NONE;
149151
return;
@@ -300,19 +302,22 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
300302
tempsec->floorpic = s->floorpic;
301303
tempsec->floorxoffset = s->floorxoffset;
302304
tempsec->flooryoffset = s->flooryoffset;
305+
tempsec->floorrotation = s->floorrotation;
303306

304307
if (s->ceilingpic == skyflatnum)
305308
{
306309
tempsec->interpfloorheight = tempsec->interpceilingheight + 1;
307310
tempsec->ceilingpic = tempsec->floorpic;
308311
tempsec->ceilingxoffset = tempsec->floorxoffset;
309312
tempsec->ceilingyoffset = tempsec->flooryoffset;
313+
tempsec->ceilingrotation = s->floorrotation;
310314
}
311315
else
312316
{
313317
tempsec->ceilingpic = s->ceilingpic;
314318
tempsec->ceilingxoffset = s->ceilingxoffset;
315319
tempsec->ceilingyoffset = s->ceilingyoffset;
320+
tempsec->ceilingrotation = s->ceilingrotation;
316321
}
317322

318323
tempsec->lightlevel = s->lightlevel;
@@ -334,13 +339,15 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
334339
tempsec->floorpic = tempsec->ceilingpic = s->ceilingpic;
335340
tempsec->floorxoffset = tempsec->ceilingxoffset = s->ceilingxoffset;
336341
tempsec->flooryoffset = tempsec->ceilingyoffset = s->ceilingyoffset;
342+
tempsec->floorrotation = s->ceilingrotation;
337343

338344
if (s->floorpic != skyflatnum)
339345
{
340346
tempsec->interpceilingheight = sec->interpceilingheight;
341347
tempsec->floorpic = s->floorpic;
342348
tempsec->floorxoffset = s->floorxoffset;
343349
tempsec->flooryoffset = s->flooryoffset;
350+
tempsec->floorrotation = s->floorrotation;
344351
}
345352

346353
tempsec->lightlevel = s->lightlevel;
@@ -558,7 +565,8 @@ static void R_Subsector(int num)
558565
frontsector->floorxoffset, // killough 03/07/98
559566
frontsector->flooryoffset,
560567
(floorlightsec ? floorlightsec->colormap :
561-
(heightsec ? heightsec->colormap : frontsector->colormap))) : NULL);
568+
(heightsec ? heightsec->colormap : frontsector->colormap)),
569+
(heightsec ? heightsec->floorrotation : frontsector->floorrotation)) : NULL);
562570

563571
ceilingplane = (frontsector->interpceilingheight > viewz
564572
|| frontsector->ceilingpic == skyflatnum
@@ -570,7 +578,8 @@ static void R_Subsector(int num)
570578
frontsector->ceilingxoffset, // killough 03/07/98
571579
frontsector->ceilingyoffset,
572580
(ceilinglightsec ? ceilinglightsec->colormap :
573-
(heightsec ? heightsec->colormap : frontsector->colormap))) : NULL);
581+
(heightsec ? heightsec->colormap : frontsector->colormap)),
582+
(heightsec ? heightsec->ceilingrotation : frontsector->ceilingrotation)) : NULL);
574583

575584
// killough 09/18/98: Fix underwater slowdown, by passing real sector
576585
// instead of fake one. Improve sprite lighting by basing sprite

src/r_defs.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ typedef struct sector_s
192192
int midmap;
193193
int topmap;
194194

195-
// [KLN] 04/06/25: colormap for ID24 spec
196-
int colormap;
197-
198195
// killough 08/28/98: friction is a sector property, not an mobj property.
199196
// these fields used to be in mobj_t, but presented performance problems
200197
// when processed as mobj properties. Fix is to make them sector properties.
@@ -210,6 +207,12 @@ typedef struct sector_s
210207
int floorsky;
211208
int ceilingsky;
212209

210+
// [KLN] 04/06/25: colormap for ID24 spec
211+
int colormap;
212+
213+
int floorrotation;
214+
int ceilingrotation;
215+
213216
terraintype_t terraintype;
214217

215218
bool islift;
@@ -295,6 +298,8 @@ typedef struct line_s
295298
// To aid move clipping.
296299
slopetype_t slopetype;
297300

301+
angle_t angle;
302+
298303
// Front and back sector.
299304
// Note: redundant? Can be retrieved from SideDefs.
300305
sector_t *frontsector;
@@ -1170,6 +1175,7 @@ typedef struct visplane_s
11701175

11711176
bool modified;
11721177
int colormap;
1178+
angle_t angle;
11731179
} visplane_t;
11741180

11751181
#endif

0 commit comments

Comments
 (0)