Skip to content

Commit

Permalink
Fixed BUG #1656495: I think I've found and fixed the cause of the "th…
Browse files Browse the repository at this point in the history
…ing archive exhausted" issues. Basically, what was happening is that when moving platforms/ceilings were being put into stasis, the thinker's function ptr was set to -1 to indicate it was not a runable function. However, this happens to be the same value as Doomsday uses to indicate a thinker should be removed (NOPFUNC). When determining the number of things thinker_t->func was compared to P_MobjThinker() but when writing the thinkers in P_ArchiveThinkers() thinker_t->func was being compared to NOPFUNC.

Fixed BUG #1651484: Due to active plats/ceilings using the NOPFUNC value, they were not restarting properly because Doomsday had already removed their thinkers.
  • Loading branch information
danij committed Mar 18, 2007
1 parent 590c26c commit 80bd76d
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 68 deletions.
21 changes: 11 additions & 10 deletions doomsday/plugins/common/src/p_ceilings.c
Expand Up @@ -307,6 +307,7 @@ static int EV_DoCeiling2(int tag, float basespeed, ceiling_e type)
ceiling->thinker.function = T_MoveCeiling;
ceiling->sector = sec;
ceiling->crush = false;
ceiling->speed = basespeed;

switch(type)
{
Expand All @@ -321,16 +322,16 @@ static int EV_DoCeiling2(int tag, float basespeed, ceiling_e type)
ceiling->speed *= 2;
break;
#endif
#if __JDOOM__ || __WOLFTC__ || __DOOM64TC__
case silentCrushAndRaise:
#endif
#if __JHEXEN__
case crushRaiseAndStay:
ceiling->crush = arg[2]; // arg[2] = crushing value
ceiling->topheight = P_GetFloatp(sec, DMU_CEILING_HEIGHT);
ceiling->bottomheight = P_GetFloatp(sec, DMU_FLOOR_HEIGHT) + 8;
ceiling->direction = -1;
break;
#endif
#if __JDOOM__ || __WOLFTC__ || __DOOM64TC__
case silentCrushAndRaise:
#endif
case crushAndRaise:
#if !__JHEXEN__
Expand Down Expand Up @@ -459,6 +460,7 @@ int EV_DoCeiling(line_t *line, ceiling_e type)
FIX2FLT((fixed_t) arg[1] * (FRACUNIT / 8)),
type);
#else
int rtn = 0;
// Reactivate in-stasis ceilings...for certain types.
switch(type)
{
Expand All @@ -467,16 +469,16 @@ int EV_DoCeiling(line_t *line, ceiling_e type)
case silentCrushAndRaise:
# endif
case crushAndRaise:
P_ActivateInStasisCeiling(line);
rtn = P_ActivateInStasisCeiling(line);
break;

default:
break;
}
# if __DOOM64TC__
return EV_DoCeiling2(line, P_XLine(line)->tag, CEILSPEED, type);
return EV_DoCeiling2(line, P_XLine(line)->tag, CEILSPEED, type) || rtn;
# else
return EV_DoCeiling2(P_XLine(line)->tag, CEILSPEED, type);
return EV_DoCeiling2(P_XLine(line)->tag, CEILSPEED, type) || rtn;
# endif
#endif
}
Expand Down Expand Up @@ -575,13 +577,14 @@ void P_RemoveAllActiveCeilings(void)
int P_ActivateInStasisCeiling(line_t *line)
{
int rtn = 0;
xline_t *xline = P_XLine(line);
ceilinglist_t *cl;

for(cl = activeceilings; cl; cl = cl->next)
{
ceiling_t *ceiling = cl->ceiling;

if(ceiling->direction == 0 && ceiling->tag == P_XLine(line)->tag)
if(ceiling->direction == 0 && ceiling->tag == xline->tag)
{
ceiling->direction = ceiling->olddirection;
# if __JHERETIC__
Expand Down Expand Up @@ -630,9 +633,7 @@ static int EV_CeilingCrushStop2(int tag)
{
ceiling->olddirection = ceiling->direction;
ceiling->direction = 0;
ceiling->thinker.function = NOPFUNC;

// return true
ceiling->thinker.function = INSTASIS;
rtn = 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_plats.c
Expand Up @@ -547,7 +547,7 @@ static boolean EV_StopPlat2(int tag)
// Put it in stasis
plat->oldstatus = plat->status;
plat->status = in_stasis;
plat->thinker.function = NOPFUNC;
plat->thinker.function = INSTASIS;
}
}
return true;
Expand Down
12 changes: 6 additions & 6 deletions doomsday/plugins/common/src/p_saveg.c
Expand Up @@ -625,7 +625,7 @@ static void SetMobjPtr(int *archiveNum)

#else

/*
/**
* Must be called before saving or loading any data.
*/
static void SV_InitThingArchive(boolean load)
Expand All @@ -643,7 +643,7 @@ static void SV_InitThingArchive(boolean load)
{
thinker_t *th;

// Count the number of mobjs we'll be writting.
// Count the number of mobjs we'll be writing.
th = thinkercap.next;
while(th != &thinkercap)
{
Expand All @@ -660,7 +660,7 @@ static void SV_InitThingArchive(boolean load)
thing_archiveSize = count;
}

/*
/**
* Free the thing archive. Called when load is complete.
*/
static void SV_FreeThingArchive(void)
Expand All @@ -670,7 +670,7 @@ static void SV_FreeThingArchive(void)
thing_archiveSize = 0;
}

/*
/**
* Called by the write code to get archive numbers.
* If the mobj is already archived, the existing number is returned.
* Number zero is not used.
Expand All @@ -681,7 +681,7 @@ unsigned short SV_ThingArchiveNum(mobj_t *mo)
int first_empty = -1;

// We only archive valid mobj thinkers.
if(mo == NULL || ((thinker_t *) mo)->function == NOPFUNC)
if(mo == NULL || ((thinker_t *) mo)->function != P_MobjThinker)
return 0;

for(i = 0; i < thing_archiveSize; i++)
Expand Down Expand Up @@ -4054,7 +4054,7 @@ static void P_ArchiveThinkers(void)
for(th = thinkercap.next; th != &thinkercap && th; th = th->next)
{
#if !__JHEXEN__
if(th->function == NOPFUNC) // Special case for thinkers in stasis.
if(th->function == INSTASIS) // Special case for thinkers in stasis.
{
platlist_t *pl;
ceilinglist_t *cl; //jff 2/22/98 need this for ceilings too now
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom64tc/include/d_think.h
Expand Up @@ -19,7 +19,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

Expand All @@ -46,6 +46,7 @@ typedef void (*actionf_v) ();
typedef void (*actionf_p1) (void *);
typedef void (*actionf_p2) (void *, void *);

#define INSTASIS ((actionf_v) (-2))
#define NOPFUNC ((actionf_v) (-1))

typedef union {
Expand Down
16 changes: 4 additions & 12 deletions doomsday/plugins/doom64tc/src/p_floor.c
Expand Up @@ -89,8 +89,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);

flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -104,13 +102,12 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
else
{
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos - speed);
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, floorheight - speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);
return crushed;
}
Expand All @@ -124,7 +121,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -139,7 +135,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
{
// COULD GET CRUSHED
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos + speed);
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, floorheight + speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -148,7 +144,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,

P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);
return crushed;
}
Expand All @@ -168,7 +163,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -182,7 +176,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
{
// COULD GET CRUSHED
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos - speed);
P_SetFloatp(sector, DMU_CEILING_HEIGHT, ceilingheight - speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -191,7 +185,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,

P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);

return crushed;
Expand All @@ -206,7 +199,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -219,7 +211,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
else
{
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos + speed);
P_SetFloatp(sector, DMU_CEILING_HEIGHT, ceilingheight + speed);
flag = P_ChangeSector(sector, crush);
}
break;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_think.h
Expand Up @@ -46,6 +46,7 @@ typedef void (*actionf_v) ();
typedef void (*actionf_p1) (void *);
typedef void (*actionf_p2) (void *, void *);

#define INSTASIS ((actionf_v) (-2))
#define NOPFUNC ((actionf_v) (-1))

typedef union {
Expand Down
16 changes: 4 additions & 12 deletions doomsday/plugins/jdoom/src/p_floor.c
Expand Up @@ -88,8 +88,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);

flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -103,13 +101,12 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
else
{
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos - speed);
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, floorheight - speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);
return crushed;
}
Expand All @@ -123,7 +120,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -138,7 +134,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
{
// COULD GET CRUSHED
lastpos = floorheight;
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos + speed);
P_SetFloatp(sector, DMU_FLOOR_HEIGHT, floorheight + speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -147,7 +143,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,

P_SetFloatp(sector, DMU_FLOOR_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);
return crushed;
}
Expand All @@ -167,7 +162,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -181,7 +175,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
{
// COULD GET CRUSHED
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos - speed);
P_SetFloatp(sector, DMU_CEILING_HEIGHT, ceilingheight - speed);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -190,7 +184,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,

P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos);
P_SetFloatp(sector, ptarget, lastpos);
//P_SetFloatp(sector, pspeed, 0);
P_ChangeSector(sector, crush);

return crushed;
Expand All @@ -205,7 +198,6 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
// The move is complete.
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, dest);
//P_SetFloatp(sector, pspeed, 0);
flag = P_ChangeSector(sector, crush);
if(flag == true)
{
Expand All @@ -218,7 +210,7 @@ result_e T_MovePlane(sector_t *sector, float speed, float dest,
else
{
lastpos = ceilingheight;
P_SetFloatp(sector, DMU_CEILING_HEIGHT, lastpos + speed);
P_SetFloatp(sector, DMU_CEILING_HEIGHT, ceilingheight + speed);
flag = P_ChangeSector(sector, crush);
}
break;
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jheretic/include/h_think.h
Expand Up @@ -19,7 +19,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

Expand All @@ -46,6 +46,7 @@ typedef void (*actionf_v) ();
typedef void (*actionf_p1) (void *);
typedef void (*actionf_p2) (void *, void *);

#define INSTASIS ((actionf_v) (-2))
#define NOPFUNC ((actionf_v) (-1))

typedef union {
Expand Down

0 comments on commit 80bd76d

Please sign in to comment.