mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
created P_GetFFloorID to get an "ID" of an FOF in its target sector (an opposite to P_GetFFloorByID you could say!), rewrote floor/ceiling rover archiving code to use both P_GetFFloorID and P_GetFFloorByID
This commit is contained in:
parent
e406a7bef5
commit
7dda5f6b94
3 changed files with 41 additions and 57 deletions
|
@ -1518,42 +1518,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|
|||
|
||||
if (diff2 & MD2_FLOORROVER)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
size_t i = 0;
|
||||
UINT32 roverindex = 0;
|
||||
|
||||
for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (rover == mobj->floorrover)
|
||||
{
|
||||
roverindex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors));
|
||||
WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref
|
||||
WRITEUINT32(save_p, SaveSector(mobj->floorrover->target));
|
||||
WRITEUINT16(save_p, P_GetFFloorID(mobj->floorrover));
|
||||
}
|
||||
|
||||
if (diff2 & MD2_CEILINGROVER)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
size_t i = 0;
|
||||
UINT32 roverindex = 0;
|
||||
|
||||
for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (rover == mobj->ceilingrover)
|
||||
{
|
||||
roverindex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
WRITEUINT32(save_p, (UINT32)(mobj->ceilingrover->target - sectors));
|
||||
WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref
|
||||
WRITEUINT32(save_p, SaveSector(mobj->ceilingrover->target));
|
||||
WRITEUINT16(save_p, P_GetFFloorID(mobj->ceilingrover));
|
||||
}
|
||||
|
||||
if (diff & MD_SPAWNPOINT)
|
||||
|
@ -2634,34 +2606,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
|
||||
if (diff2 & MD2_FLOORROVER)
|
||||
{
|
||||
size_t floor_sectornum = (size_t)READUINT32(save_p);
|
||||
size_t floor_rovernum = (size_t)READUINT32(save_p);
|
||||
ffloor_t *rover = NULL;
|
||||
size_t rovernum = 0;
|
||||
|
||||
for (rover = sectors[floor_sectornum].ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (rovernum == floor_rovernum)
|
||||
break;
|
||||
rovernum++;
|
||||
}
|
||||
floorrover = rover;
|
||||
sector_t *sec = LoadSector(READUINT32(save_p));
|
||||
UINT16 id = READUINT16(save_p);
|
||||
floorrover = P_GetFFloorByID(sec, id);
|
||||
}
|
||||
|
||||
if (diff2 & MD2_CEILINGROVER)
|
||||
{
|
||||
size_t ceiling_sectornum = (size_t)READUINT32(save_p);
|
||||
size_t ceiling_rovernum = (size_t)READUINT32(save_p);
|
||||
ffloor_t *rover = NULL;
|
||||
size_t rovernum = 0;
|
||||
|
||||
for (rover = sectors[ceiling_sectornum].ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (rovernum == ceiling_rovernum)
|
||||
break;
|
||||
rovernum++;
|
||||
}
|
||||
ceilingrover = rover;
|
||||
sector_t *sec = LoadSector(READUINT32(save_p));
|
||||
UINT16 id = READUINT16(save_p);
|
||||
ceilingrover = P_GetFFloorByID(sec, id);
|
||||
}
|
||||
|
||||
if (diff & MD_SPAWNPOINT)
|
||||
|
|
31
src/p_spec.c
31
src/p_spec.c
|
@ -5678,6 +5678,35 @@ void P_UpdateSpecials(void)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Floor over floors (FOFs), 3Dfloors, 3Dblocks, fake floors (ffloors), rovers, or whatever you want to call them
|
||||
//
|
||||
|
||||
/** Gets the ID number for a 3Dfloor in its target sector.
|
||||
*
|
||||
* \param fflr The 3Dfloor we want an ID for.
|
||||
* \return ID of 3Dfloor in target sector. Note that the first FOF's ID is 0. UINT16_MAX is given if invalid.
|
||||
* \sa P_GetFFloorByID
|
||||
*/
|
||||
UINT16 P_GetFFloorID(ffloor_t *fflr)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
sector_t *sec;
|
||||
UINT16 i = 0;
|
||||
|
||||
if (!rover)
|
||||
return UINT16_MAX;
|
||||
|
||||
sec = rover->target;
|
||||
|
||||
if (!sec->ffloors)
|
||||
return UINT16_MAX;
|
||||
for (rover = sec->ffloors; rover; rover = rover->next, i++)
|
||||
if (rover == fflr)
|
||||
return i;
|
||||
return UINT16_MAX;
|
||||
}
|
||||
|
||||
/** Gets a 3Dfloor by control sector.
|
||||
*
|
||||
* \param sec Target sector.
|
||||
|
@ -5702,7 +5731,7 @@ static inline ffloor_t *P_GetFFloorBySec(sector_t *sec, sector_t *sec2)
|
|||
* \param sec Target sector.
|
||||
* \param id ID of 3Dfloor in target sector. Note that the first FOF's ID is 0.
|
||||
* \return Pointer to found 3Dfloor, or NULL.
|
||||
* \sa P_GetFFloorBySec
|
||||
* \sa P_GetFFloorBySec, P_GetFFloorID
|
||||
*/
|
||||
ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ void P_RunDeNightserizeExecutors(mobj_t *actor);
|
|||
void P_RunNightsLapExecutors(mobj_t *actor);
|
||||
void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean enoughspheres);
|
||||
|
||||
UINT16 P_GetFFloorID(ffloor_t *fflr);
|
||||
ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id);
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue