From e48f154bfd0342c962e37241ba1b7496482ef9a0 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 27 Dec 2022 06:12:31 -0500 Subject: [PATCH] Update executors 402, 408, 439 These now use their first arg as a tag to copy properties from, with 0 falling back to old behavior, so that they can be more useful for ACS. --- src/p_setup.c | 21 +++++----- src/p_spec.c | 108 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 91 insertions(+), 38 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index bee4bacb1..0fd430fc5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4864,8 +4864,9 @@ static void P_ConvertBinaryLinedefTypes(void) lines[i].special = 400; break; case 402: //Copy light level - lines[i].args[0] = tag; - lines[i].args[1] = 0; + lines[i].args[0] = 0; + lines[i].args[1] = tag; + lines[i].args[2] = 0; break; case 403: //Move tagged sector's floor case 404: //Move tagged sector's ceiling @@ -4886,18 +4887,19 @@ static void P_ConvertBinaryLinedefTypes(void) lines[i].special = 405; break; case 408: //Set flats - lines[i].args[0] = tag; + lines[i].args[0] = 0; + lines[i].args[1] = tag; if ((lines[i].flags & (ML_NOCLIMB|ML_MIDSOLID)) == (ML_NOCLIMB|ML_MIDSOLID)) { CONS_Alert(CONS_WARNING, M_GetText("Set flats linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), tag); lines[i].special = 0; } else if (lines[i].flags & ML_NOCLIMB) - lines[i].args[1] = TMP_CEILING; + lines[i].args[2] = TMP_CEILING; else if (lines[i].flags & ML_MIDSOLID) - lines[i].args[1] = TMP_FLOOR; + lines[i].args[2] = TMP_FLOOR; else - lines[i].args[1] = TMP_BOTH; + lines[i].args[2] = TMP_BOTH; break; case 409: //Change tagged sector's tag lines[i].args[0] = tag; @@ -5168,9 +5170,10 @@ static void P_ConvertBinaryLinedefTypes(void) lines[i].args[0] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS; break; case 439: //Change tagged linedef's textures - lines[i].args[0] = tag; - lines[i].args[1] = TMSD_FRONTBACK; - lines[i].args[2] = !!(lines[i].flags & ML_NOCLIMB); + lines[i].args[0] = 0; + lines[i].args[1] = tag; + lines[i].args[2] = TMSD_FRONTBACK; + lines[i].args[3] = !!(lines[i].flags & ML_NOCLIMB); break; case 441: //Condition set trigger lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; diff --git a/src/p_spec.c b/src/p_spec.c index 30a8593ad..93308b757 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2232,26 +2232,43 @@ void P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char * break; case 402: // Copy light level to tagged sectors - if (line == NULL) { - break; // TODO - } + sector_t *copySector = NULL; - { INT16 newlightlevel; INT16 newfloorlightlevel, newceilinglightlevel; boolean newfloorlightabsolute, newceilinglightabsolute; INT32 newfloorlightsec, newceilinglightsec; - newlightlevel = line->frontsector->lightlevel; - newfloorlightlevel = line->frontsector->floorlightlevel; - newfloorlightabsolute = line->frontsector->floorlightabsolute; - newceilinglightlevel = line->frontsector->ceilinglightlevel; - newceilinglightabsolute = line->frontsector->ceilinglightabsolute; - newfloorlightsec = line->frontsector->floorlightsec; - newceilinglightsec = line->frontsector->ceilinglightsec; + if (args[0] == 0) + { + if (line == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 402 Executor: No frontsector to copy light level from!\n"); + return; + } + copySector = line->frontsector; + } + else + { + INT32 destsec = Tag_Iterate_Sectors(args[0], 0); + if (destsec == -1) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 402 Executor: No sector to copy light level from (tag %d)!\n", args[0]); + return; + } + copySector = §ors[destsec]; + } - TAG_ITER_SECTORS(args[0], secnum) + newlightlevel = copySector->lightlevel; + newfloorlightlevel = copySector->floorlightlevel; + newfloorlightabsolute = copySector->floorlightabsolute; + newceilinglightlevel = copySector->ceilinglightlevel; + newceilinglightabsolute = copySector->ceilinglightabsolute; + newfloorlightsec = copySector->floorlightsec; + newceilinglightsec = copySector->ceilinglightsec; + + TAG_ITER_SECTORS(args[1], secnum) { if (sectors[secnum].lightingdata) { @@ -2260,17 +2277,17 @@ void P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char * sectors[secnum].lightingdata = NULL; } - if (!(args[1] & TMLC_NOSECTOR)) + if (!(args[2] & TMLC_NOSECTOR)) sectors[secnum].lightlevel = newlightlevel; - if (!(args[1] & TMLC_NOFLOOR)) + if (!(args[2] & TMLC_NOFLOOR)) { sectors[secnum].floorlightlevel = newfloorlightlevel; sectors[secnum].floorlightabsolute = newfloorlightabsolute; sectors[secnum].floorlightsec = newfloorlightsec; } - if (!(args[1] & TMLC_NOCEILING)) + if (!(args[2] & TMLC_NOCEILING)) { sectors[secnum].ceilinglightlevel = newceilinglightlevel; sectors[secnum].ceilinglightabsolute = newceilinglightabsolute; @@ -2306,17 +2323,34 @@ void P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char * case 408: // Set flats { - if (line == NULL) + sector_t *copySector = NULL; + + if (args[0] == 0) { - break; // TODO + if (line == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 408 Executor: No frontsector to copy flats from!\n"); + return; + } + copySector = line->frontsector; + } + else + { + INT32 destsec = Tag_Iterate_Sectors(args[0], 0); + if (destsec == -1) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 408 Executor: No sector to copy flats from (tag %d)!\n", args[0]); + return; + } + copySector = §ors[destsec]; } - TAG_ITER_SECTORS(args[0], secnum) + TAG_ITER_SECTORS(args[1], secnum) { - if (args[1] != TMP_CEILING) - sectors[secnum].floorpic = line->frontsector->floorpic; - if (args[1] != TMP_FLOOR) - sectors[secnum].ceilingpic = line->frontsector->ceilingpic; + if (args[2] != TMP_CEILING) + sectors[secnum].floorpic = copySector->floorpic; + if (args[2] != TMP_FLOOR) + sectors[secnum].ceilingpic = copySector->ceilingpic; } break; } @@ -2804,28 +2838,44 @@ void P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char * case 439: // Set texture { + line_t *copyLine = NULL; size_t linenum; side_t *set, *this; boolean always; - if (line == NULL) + if (args[0] == 0) { - break; // TODO + if (line == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 439 Executor: No activating line to copy textures from!\n"); + return; + } + copyLine = line; + } + else + { + INT32 origline = Tag_Iterate_Lines(args[0], 0); + if (origline == -1) + { + CONS_Debug(DBG_GAMELOGIC, "Special type 439 Executor: No tagged line to copy textures from (tag %d)!\n", args[0]); + return; + } + copyLine = &lines[origline]; } - set = &sides[line->sidenum[0]]; - always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc. + set = &sides[copyLine->sidenum[0]]; + always = !(args[3]); // If args[3] is set: Only change mid texture if mid texture already exists on tagged lines, etc. for (linenum = 0; linenum < numlines; linenum++) { if (lines[linenum].special == 439) continue; // Don't override other set texture lines! - if (!Tag_Find(&lines[linenum].tags, line->args[0])) + if (!Tag_Find(&lines[linenum].tags, args[1])) continue; // Find tagged lines // Front side - if (line->args[1] != TMSD_BACK) + if (args[2] != TMSD_BACK) { this = &sides[lines[linenum].sidenum[0]]; if (always || this->toptexture) this->toptexture = set->toptexture; @@ -2834,7 +2884,7 @@ void P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char * } // Back side - if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != 0xffff) + if (args[2] != TMSD_FRONT && lines[linenum].sidenum[1] != 0xffff) { this = &sides[lines[linenum].sidenum[1]]; if (always || this->toptexture) this->toptexture = set->toptexture;