Move fadingdata (fade_t thinker) to line_t

This commit is contained in:
mazmazz 2018-08-17 00:32:20 -04:00
parent cf853e3982
commit 2e252cb905
4 changed files with 97 additions and 53 deletions

View File

@ -2578,8 +2578,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker)
ht->doghostfade = READUINT8(save_p);
line_t *ffloorline = LoadLine(ht->affectee);
if (ffloorline && ffloorline->frontsector)
ffloorline->frontsector->fadingdata = ht;
if (ffloorline)
ffloorline->fadingdata = ht;
P_AddThinker(&ht->thinker);
}
@ -2770,7 +2770,13 @@ static void P_NetUnArchiveThinkers(void)
// clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity
for (i = 0; i < numsectors; i++)
{
sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadingdata = NULL;
sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL;
}
// same for line thinker pointers
for (i = 0; i < numlines; i++)
{
lines[i].fadingdata = NULL;
}
// read in saved thinkers

View File

@ -693,7 +693,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i)
ss->floordata = NULL;
ss->ceilingdata = NULL;
ss->lightingdata = NULL;
ss->fadingdata = NULL;
ss->linecount = 0;
ss->lines = NULL;
@ -1311,6 +1310,8 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i)
#ifdef POLYOBJECTS
ld->polyobj = NULL;
#endif
ld->fadingdata = NULL;
}
}

View File

@ -3103,43 +3103,91 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 452: // Fade FOF
{
INT32 s, j;
for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;)
for (j = 0; (unsigned)j < sectors[s].linecount; j++)
if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300)
{
if (sides[line->sidenum[0]].rowoffset>>FRACBITS > 0)
P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS,
sides[line->sidenum[0]].rowoffset>>FRACBITS,
(line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS
!(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT
(line->flags & ML_BOUNCY), // handle FF_SOLID
(line->flags & ML_EFFECT1), // handle spawnflags
(line->flags & ML_EFFECT2), // enable flags on fade-in finish only
(INT32)(sectors[s].lines[j]-lines));
else
{
P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]);
P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS,
0, // set alpha immediately
(line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS
!(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT
(line->flags & ML_BOUNCY), // handle FF_SOLID
(line->flags & ML_EFFECT1), // handle spawnflags
(line->flags & ML_EFFECT2), // enable flags on fade-in finish only
(INT32)(sectors[s].lines[j]-lines));
}
}
INT16 destvalue = (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS);
INT16 speed = (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS);
INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS);
INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS);
sector_t *sec; // Sector that the FOF is visible in
ffloor_t *rover; // FOF that we are going to crumble
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
{
sec = sectors + secnum;
if (!sec->ffloors)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum);
return;
}
for (rover = sec->ffloors; rover; rover = rover->next)
{
if (rover->master->frontsector->tag == foftag)
break;
}
if (!rover)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag);
return;
}
if (speed > 0)
P_AddMasterFader(destvalue, speed,
(line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS
!(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT
(line->flags & ML_BOUNCY), // handle FF_SOLID
(line->flags & ML_EFFECT1), // handle spawnflags
(line->flags & ML_EFFECT2), // enable flags on fade-in finish only
(INT32)(rover->master-lines));
else
{
P_RemoveFading(&lines[(INT32)(rover->master-lines)]);
P_FindFakeFloorsDoAlpha(destvalue, 0, // set alpha immediately
(line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS
!(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT
(line->flags & ML_BOUNCY), // handle FF_SOLID
(line->flags & ML_EFFECT1), // handle spawnflags
(line->flags & ML_EFFECT2), // enable flags on fade-in finish only
(INT32)(rover->master-lines));
}
break;
}
break;
}
case 453: // Stop fading FOF
{
INT32 s, j;
for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;)
for (j = 0; (unsigned)j < sectors[s].linecount; j++)
if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300)
P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]);
INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS);
INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS);
sector_t *sec; // Sector that the FOF is visible in
ffloor_t *rover; // FOF that we are going to crumble
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
{
sec = sectors + secnum;
if (!sec->ffloors)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum);
return;
}
for (rover = sec->ffloors; rover; rover = rover->next)
{
if (rover->master->frontsector->tag == foftag)
break;
}
if (!rover)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag);
return;
}
P_RemoveFading(&lines[(INT32)(rover->master-lines)]);
break;
}
break;
}
@ -7151,25 +7199,13 @@ void T_Disappear(disappear_t *d)
*/
static void P_ResetFading(line_t *line, fade_t *data)
{
ffloor_t *rover;
register INT32 s;
// find any existing thinkers and remove them, then replace with new data
for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;)
if(((fade_t *)line->fadingdata) != data)
{
for (rover = sectors[s].ffloors; rover; rover = rover->next)
{
if (rover->master != line)
continue;
if(&((fade_t *)line->fadingdata)->thinker)
P_RemoveThinker(&((fade_t *)line->fadingdata)->thinker);
if(((fade_t *)rover->master->frontsector->fadingdata) != data)
{
if(&((fade_t *)rover->master->frontsector->fadingdata)->thinker)
P_RemoveThinker(&((fade_t *)rover->master->frontsector->fadingdata)->thinker);
rover->master->frontsector->fadingdata = data;
}
}
line->fadingdata = data;
}
}

View File

@ -308,7 +308,6 @@ typedef struct sector_s
void *floordata; // floor move thinker
void *ceilingdata; // ceiling move thinker
void *lightingdata; // lighting change thinker
void *fadingdata; // fading FOF thinker
// floor and ceiling texture offsets
fixed_t floor_xoffs, floor_yoffs;
@ -444,6 +443,8 @@ typedef struct line_s
char *text; // a concatination of all front and back texture names, for linedef specials that require a string.
INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0
void *fadingdata; // fading FOF thinker
} line_t;
//