-Pass tag as argument to EV_ functions

-Get rid of junk linedefs for specialized EV_ calls
-Store tag in args[0]
This commit is contained in:
MascaraSnake 2021-06-25 10:12:16 +02:00
parent 4bedca6ba7
commit 7025f12d95
7 changed files with 80 additions and 83 deletions

View file

@ -383,18 +383,18 @@ void T_CrushCeiling(ceiling_t *ceiling)
/** Starts a ceiling mover. /** Starts a ceiling mover.
* *
* \param tag Tag.
* \param line The source line. * \param line The source line.
* \param type The type of ceiling movement. * \param type The type of ceiling movement.
* \return 1 if at least one ceiling mover was started, 0 otherwise. * \return 1 if at least one ceiling mover was started, 0 otherwise.
* \sa EV_DoCrush, EV_DoFloor, EV_DoElevator, T_MoveCeiling * \sa EV_DoCrush, EV_DoFloor, EV_DoElevator, T_MoveCeiling
*/ */
INT32 EV_DoCeiling(line_t *line, ceiling_e type) INT32 EV_DoCeiling(mtag_t tag, line_t *line, ceiling_e type)
{ {
INT32 rtn = 0, firstone = 1; INT32 rtn = 0, firstone = 1;
INT32 secnum = -1; INT32 secnum = -1;
sector_t *sec; sector_t *sec;
ceiling_t *ceiling; ceiling_t *ceiling;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_SECTORS(tag, secnum) TAG_ITER_SECTORS(tag, secnum)
{ {
@ -603,19 +603,19 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type)
/** Starts a ceiling crusher. /** Starts a ceiling crusher.
* *
* \param tag Tag.
* \param line The source line. * \param line The source line.
* \param type The type of ceiling, either ::crushAndRaise or * \param type The type of ceiling, either ::crushAndRaise or
* ::fastCrushAndRaise. * ::fastCrushAndRaise.
* \return 1 if at least one crusher was started, 0 otherwise. * \return 1 if at least one crusher was started, 0 otherwise.
* \sa EV_DoCeiling, EV_DoFloor, EV_DoElevator, T_CrushCeiling * \sa EV_DoCeiling, EV_DoFloor, EV_DoElevator, T_CrushCeiling
*/ */
INT32 EV_DoCrush(line_t *line, ceiling_e type) INT32 EV_DoCrush(mtag_t tag, line_t *line, ceiling_e type)
{ {
INT32 rtn = 0; INT32 rtn = 0;
INT32 secnum = -1; INT32 secnum = -1;
sector_t *sec; sector_t *sec;
ceiling_t *ceiling; ceiling_t *ceiling;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_SECTORS(tag, secnum) TAG_ITER_SECTORS(tag, secnum)
{ {

View file

@ -3873,7 +3873,6 @@ void A_BossDeath(mobj_t *mo)
{ {
thinker_t *th; thinker_t *th;
mobj_t *mo2; mobj_t *mo2;
line_t junk;
INT32 i; INT32 i;
if (LUA_CallAction(A_BOSSDEATH, mo)) if (LUA_CallAction(A_BOSSDEATH, mo))
@ -3925,18 +3924,11 @@ void A_BossDeath(mobj_t *mo)
} }
else else
{ {
// Initialize my junk
junk.tags.tags = NULL;
junk.tags.count = 0;
// Bring the egg trap up to the surface // Bring the egg trap up to the surface
// Incredibly shitty code ahead // Incredibly shitty code ahead
Tag_FSet(&junk.tags, LE_CAPSULE0); EV_DoElevator(LE_CAPSULE0, NULL, elevateHighest, false);
EV_DoElevator(&junk, elevateHighest, false); EV_DoElevator(LE_CAPSULE1, NULL, elevateUp, false);
Tag_FSet(&junk.tags, LE_CAPSULE1); EV_DoElevator(LE_CAPSULE2, NULL, elevateHighest, false);
EV_DoElevator(&junk, elevateUp, false);
Tag_FSet(&junk.tags, LE_CAPSULE2);
EV_DoElevator(&junk, elevateHighest, false);
if (mapheaderinfo[gamemap-1]->muspostbossname[0] && if (mapheaderinfo[gamemap-1]->muspostbossname[0] &&
S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname, !midi_disabled, !digital_disabled)) S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname, !midi_disabled, !digital_disabled))
@ -4058,12 +4050,7 @@ bossjustdie:
} }
case MT_KOOPA: case MT_KOOPA:
{ {
// Initialize my junk EV_DoCeiling(LE_KOOPA, NULL, raiseToHighest);
junk.tags.tags = NULL;
junk.tags.count = 0;
Tag_FSet(&junk.tags, LE_KOOPA);
EV_DoCeiling(&junk, raiseToHighest);
return; return;
} }
case MT_FANG: case MT_FANG:

View file

@ -1805,13 +1805,12 @@ void T_PlaneDisplace(planedisplace_t *pd)
// (egg capsule button), P_PlayerInSpecialSector (buttons), // (egg capsule button), P_PlayerInSpecialSector (buttons),
// and P_SpawnSpecials (continuous floor movers and instant lower). // and P_SpawnSpecials (continuous floor movers and instant lower).
// //
void EV_DoFloor(line_t *line, floor_e floortype) void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
{ {
INT32 firstone = 1; INT32 firstone = 1;
INT32 secnum = -1; INT32 secnum = -1;
sector_t *sec; sector_t *sec;
floormove_t *dofloor; floormove_t *dofloor;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_SECTORS(tag, secnum) TAG_ITER_SECTORS(tag, secnum)
{ {
@ -2022,12 +2021,11 @@ void EV_DoFloor(line_t *line, floor_e floortype)
// //
// jff 2/22/98 new type to move floor and ceiling in parallel // jff 2/22/98 new type to move floor and ceiling in parallel
// //
void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) void EV_DoElevator(mtag_t tag, line_t *line, elevator_e elevtype, boolean customspeed)
{ {
INT32 secnum = -1; INT32 secnum = -1;
sector_t *sec; sector_t *sec;
elevator_t *elevator; elevator_t *elevator;
mtag_t tag = Tag_FGet(&line->tags);
// act on all sectors with the same tag as the triggering linedef // act on all sectors with the same tag as the triggering linedef
TAG_ITER_SECTORS(tag, secnum) TAG_ITER_SECTORS(tag, secnum)

View file

@ -1381,19 +1381,13 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return; return;
case MT_AXE: case MT_AXE:
{ {
line_t junk;
thinker_t *th; thinker_t *th;
mobj_t *mo2; mobj_t *mo2;
if (player->bot) if (player->bot)
return; return;
// Initialize my junk EV_DoElevator(LE_AXE, NULL, bridgeFall, false);
junk.tags.tags = NULL;
junk.tags.count = 0;
Tag_FSet(&junk.tags, LE_AXE);
EV_DoElevator(&junk, bridgeFall, false);
// scan the remaining thinkers to find koopa // scan the remaining thinkers to find koopa
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)

View file

@ -3081,6 +3081,28 @@ static void P_ConvertBinaryMap(void)
break; break;
} }
case 50: //Instantly lower floor on level load
case 51: //Instantly raise ceiling on level load
lines[i].args[0] = tag;
break;
case 53: //Continuous floor/ceiling mover
case 54: //Continuous floor mover
case 55: //Continuous ceiling mover
lines[i].args[0] = tag;
break;
case 56: //Continuous two-speed floor/ceiling mover
case 57: //Continuous two-speed floor mover
case 58: //Continuous two-speed ceiling mover
lines[i].args[0] = tag;
break;
case 59: //Activate moving platform
case 60: //Activate moving platform (adjustable speed)
lines[i].args[0] = tag;
break;
case 61: //Crusher (Ceiling to floor)
case 62: //Crusher (Floor to ceiling)
lines[i].args[0] = tag;
break;
case 76: //Make FOF bouncy case 76: //Make FOF bouncy
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS; lines[i].args[1] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS;
@ -3482,6 +3504,26 @@ static void P_ConvertBinaryMap(void)
else else
lines[i].args[1] = 255; lines[i].args[1] = 255;
break; break;
case 400: //Set tagged sector's floor height/texture
case 401: //Set tagged sector's ceiling height/texture
lines[i].args[0] = tag;
break;
case 403: //Move tagged sector's floor
case 404: //Move tagged sector's ceiling
lines[i].args[0] = tag;
break;
case 405: //Move floor according to front texture offsets
case 407: //Move ceiling according to front texture offsets
lines[i].args[0] = tag;
break;
case 428: //Start platform movement
lines[i].args[0] = tag;
break;
case 429: //Crush ceiling once
case 430: //Crush floor once
case 431: //Crush floor and ceiling once
lines[i].args[0] = tag;
break;
case 443: //Call Lua function case 443: //Call Lua function
if (lines[i].text) if (lines[i].text)
{ {

View file

@ -2234,11 +2234,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
switch (line->special) switch (line->special)
{ {
case 400: // Set tagged sector's floor height/pic case 400: // Set tagged sector's floor height/pic
EV_DoFloor(line, instantMoveFloorByFrontSector); EV_DoFloor(line->args[0], line, instantMoveFloorByFrontSector);
break; break;
case 401: // Set tagged sector's ceiling height/pic case 401: // Set tagged sector's ceiling height/pic
EV_DoCeiling(line, instantMoveCeilingByFrontSector); EV_DoCeiling(line->args[0], line, instantMoveCeilingByFrontSector);
break; break;
case 402: // Set tagged sector's light level case 402: // Set tagged sector's light level
@ -2272,37 +2272,21 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
break; break;
case 403: // Move floor, linelen = speed, frontsector floor = dest height case 403: // Move floor, linelen = speed, frontsector floor = dest height
EV_DoFloor(line, moveFloorByFrontSector); EV_DoFloor(line->args[0], line, moveFloorByFrontSector);
break; break;
case 404: // Move ceiling, linelen = speed, frontsector ceiling = dest height case 404: // Move ceiling, linelen = speed, frontsector ceiling = dest height
EV_DoCeiling(line, moveCeilingByFrontSector); EV_DoCeiling(line->args[0], line, moveCeilingByFrontSector);
break; break;
case 405: // Move floor by front side texture offsets, offset x = speed, offset y = amount to raise/lower case 405: // Move floor by front side texture offsets, offset x = speed, offset y = amount to raise/lower
EV_DoFloor(line, moveFloorByFrontTexture); EV_DoFloor(line->args[0], line, moveFloorByFrontTexture);
break; break;
case 407: // Move ceiling by front side texture offsets, offset x = speed, offset y = amount to raise/lower case 407: // Move ceiling by front side texture offsets, offset x = speed, offset y = amount to raise/lower
EV_DoCeiling(line, moveCeilingByFrontTexture); EV_DoCeiling(line->args[0], line, moveCeilingByFrontTexture);
break; break;
/* case 405: // Lower floor by line, dx = speed, dy = amount to lower
EV_DoFloor(line, lowerFloorByLine);
break;
case 406: // Raise floor by line, dx = speed, dy = amount to raise
EV_DoFloor(line, raiseFloorByLine);
break;
case 407: // Lower ceiling by line, dx = speed, dy = amount to lower
EV_DoCeiling(line, lowerCeilingByLine);
break;
case 408: // Raise ceiling by line, dx = speed, dy = amount to raise
EV_DoCeiling(line, raiseCeilingByLine);
break;*/
case 409: // Change tagged sectors' tag case 409: // Change tagged sectors' tag
// (formerly "Change calling sectors' tag", but behavior was changed) // (formerly "Change calling sectors' tag", but behavior was changed)
{ {
@ -2886,19 +2870,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
break; break;
case 428: // Start floating platform movement case 428: // Start floating platform movement
EV_DoElevator(line, elevateContinuous, true); EV_DoElevator(line->args[0], line, elevateContinuous, true);
break; break;
case 429: // Crush Ceiling Down Once case 429: // Crush Ceiling Down Once
EV_DoCrush(line, crushCeilOnce); EV_DoCrush(line->args[0], line, crushCeilOnce);
break; break;
case 430: // Crush Floor Up Once case 430: // Crush Floor Up Once
EV_DoFloor(line, crushFloorOnce); EV_DoFloor(line->args[0], line, crushFloorOnce);
break; break;
case 431: // Crush Floor & Ceiling to middle Once case 431: // Crush Floor & Ceiling to middle Once
EV_DoCrush(line, crushBothOnce); EV_DoCrush(line->args[0], line, crushBothOnce);
break; break;
case 432: // Enable 2D Mode (Disable if noclimb) case 432: // Enable 2D Mode (Disable if noclimb)
@ -4414,7 +4398,6 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
{ {
thinker_t *th; thinker_t *th;
mobj_t *mo2; mobj_t *mo2;
line_t junk;
if (player->bot || sector->ceilingdata || sector->floordata) if (player->bot || sector->ceilingdata || sector->floordata)
return; return;
@ -4434,20 +4417,13 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
// clear the special so you can't push the button twice. // clear the special so you can't push the button twice.
sector->special = 0; sector->special = 0;
// Initialize my junk
junk.tags.tags = NULL;
junk.tags.count = 0;
// Move the button down // Move the button down
Tag_FSet(&junk.tags, LE_CAPSULE0); EV_DoElevator(LE_CAPSULE0, NULL, elevateDown, false);
EV_DoElevator(&junk, elevateDown, false);
// Open the top FOF // Open the top FOF
Tag_FSet(&junk.tags, LE_CAPSULE1); EV_DoFloor(LE_CAPSULE1, NULL, raiseFloorToNearestFast);
EV_DoFloor(&junk, raiseFloorToNearestFast);
// Open the bottom FOF // Open the bottom FOF
Tag_FSet(&junk.tags, LE_CAPSULE2); EV_DoCeiling(LE_CAPSULE2, NULL, lowerToLowestFast);
EV_DoCeiling(&junk, lowerToLowestFast);
// Mark all players with the time to exit thingy! // Mark all players with the time to exit thingy!
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -6342,11 +6318,11 @@ void P_SpawnSpecials(boolean fromnetsave)
break; break;
case 50: // Insta-Lower Sector case 50: // Insta-Lower Sector
EV_DoFloor(&lines[i], instantLower); EV_DoFloor(lines[i].args[0], &lines[i], instantLower);
break; break;
case 51: // Instant raise for ceilings case 51: // Instant raise for ceilings
EV_DoCeiling(&lines[i], instantRaise); EV_DoCeiling(lines[i].args[0], &lines[i], instantRaise);
break; break;
case 52: // Continuously Falling sector case 52: // Continuously Falling sector
@ -6356,20 +6332,20 @@ void P_SpawnSpecials(boolean fromnetsave)
case 53: // New super cool and awesome moving floor and ceiling type case 53: // New super cool and awesome moving floor and ceiling type
case 54: // New super cool and awesome moving floor type case 54: // New super cool and awesome moving floor type
if (lines[i].backsector) if (lines[i].backsector)
EV_DoFloor(&lines[i], bounceFloor); EV_DoFloor(lines[i].args[0], &lines[i], bounceFloor);
if (lines[i].special == 54) if (lines[i].special == 54)
break; break;
/* FALLTHRU */ /* FALLTHRU */
case 55: // New super cool and awesome moving ceiling type case 55: // New super cool and awesome moving ceiling type
if (lines[i].backsector) if (lines[i].backsector)
EV_DoCeiling(&lines[i], bounceCeiling); EV_DoCeiling(lines[i].args[0], &lines[i], bounceCeiling);
break; break;
case 56: // New super cool and awesome moving floor and ceiling crush type case 56: // New super cool and awesome moving floor and ceiling crush type
case 57: // New super cool and awesome moving floor crush type case 57: // New super cool and awesome moving floor crush type
if (lines[i].backsector) if (lines[i].backsector)
EV_DoFloor(&lines[i], bounceFloorCrush); EV_DoFloor(lines[i].args[0], &lines[i], bounceFloorCrush);
if (lines[i].special == 57) if (lines[i].special == 57)
break; //only move the floor break; //only move the floor
@ -6377,23 +6353,23 @@ void P_SpawnSpecials(boolean fromnetsave)
case 58: // New super cool and awesome moving ceiling crush type case 58: // New super cool and awesome moving ceiling crush type
if (lines[i].backsector) if (lines[i].backsector)
EV_DoCeiling(&lines[i], bounceCeilingCrush); EV_DoCeiling(lines[i].args[0], &lines[i], bounceCeilingCrush);
break; break;
case 59: // Activate floating platform case 59: // Activate floating platform
EV_DoElevator(&lines[i], elevateContinuous, false); EV_DoElevator(lines[i].args[0], &lines[i], elevateContinuous, false);
break; break;
case 60: // Floating platform with adjustable speed case 60: // Floating platform with adjustable speed
EV_DoElevator(&lines[i], elevateContinuous, true); EV_DoElevator(lines[i].args[0], &lines[i], elevateContinuous, true);
break; break;
case 61: // Crusher! case 61: // Crusher!
EV_DoCrush(&lines[i], crushAndRaise); EV_DoCrush(lines[i].args[0], &lines[i], crushAndRaise);
break; break;
case 62: // Crusher (up and then down)! case 62: // Crusher (up and then down)!
EV_DoCrush(&lines[i], fastCrushAndRaise); EV_DoCrush(lines[i].args[0], &lines[i], fastCrushAndRaise);
break; break;
case 63: // support for drawn heights coming from different sector case 63: // support for drawn heights coming from different sector

View file

@ -307,9 +307,9 @@ typedef struct
#define CEILSPEED (FRACUNIT) #define CEILSPEED (FRACUNIT)
INT32 EV_DoCeiling(line_t *line, ceiling_e type); INT32 EV_DoCeiling(mtag_t tag, line_t *line, ceiling_e type);
INT32 EV_DoCrush(line_t *line, ceiling_e type); INT32 EV_DoCrush(mtag_t tag, line_t *line, ceiling_e type);
void T_CrushCeiling(ceiling_t *ceiling); void T_CrushCeiling(ceiling_t *ceiling);
void T_MoveCeiling(ceiling_t *ceiling); void T_MoveCeiling(ceiling_t *ceiling);
@ -520,8 +520,8 @@ typedef enum
result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crush, result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crush,
boolean ceiling, INT32 direction); boolean ceiling, INT32 direction);
void EV_DoFloor(line_t *line, floor_e floortype); void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype);
void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed); void EV_DoElevator(mtag_t tag, line_t *line, elevator_e elevtype, boolean customspeed);
void EV_CrumbleChain(sector_t *sec, ffloor_t *rover); void EV_CrumbleChain(sector_t *sec, ffloor_t *rover);
void EV_BounceSector(sector_t *sector, fixed_t momz, line_t *sourceline); void EV_BounceSector(sector_t *sector, fixed_t momz, line_t *sourceline);