mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 21:50:48 +00:00
Make T_EachTimeThinker use its own struct
This commit is contained in:
parent
3e0a9c8718
commit
89539512f6
4 changed files with 64 additions and 44 deletions
|
@ -1581,7 +1581,7 @@ static INT32 P_HavePlayersEnteredArea(boolean *curPlayers, boolean *oldPlayers,
|
||||||
//
|
//
|
||||||
// \sa P_AddEachTimeThinker
|
// \sa P_AddEachTimeThinker
|
||||||
//
|
//
|
||||||
void T_EachTimeThinker(levelspecthink_t *eachtime)
|
void T_EachTimeThinker(eachtime_t *eachtime)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
sector_t *sec = NULL;
|
sector_t *sec = NULL;
|
||||||
|
@ -1604,19 +1604,10 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (i & 1)
|
oldPlayersInArea[i] = eachtime->playersInArea[i];
|
||||||
{
|
oldPlayersOnArea[i] = eachtime->playersOnArea[i];
|
||||||
oldPlayersInArea[i] = eachtime->vars[i/2] & 65535;
|
eachtime->playersInArea[i] = false;
|
||||||
oldPlayersOnArea[i] = eachtime->var2s[i/2] & 65535;
|
eachtime->playersOnArea[i] = false;
|
||||||
eachtime->vars[i/2] = 0;
|
|
||||||
eachtime->var2s[i/2] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
oldPlayersInArea[i] = eachtime->vars[i/2] >> 16;
|
|
||||||
oldPlayersOnArea[i] = eachtime->var2s[i/2] >> 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
playersInArea[i] = false;
|
playersInArea[i] = false;
|
||||||
playersOnArea[i] = false;
|
playersOnArea[i] = false;
|
||||||
}
|
}
|
||||||
|
@ -1705,20 +1696,12 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
|
||||||
|
|
||||||
if (floortouch == true && P_IsObjectOnGroundIn(players[j].mo, targetsec))
|
if (floortouch == true && P_IsObjectOnGroundIn(players[j].mo, targetsec))
|
||||||
{
|
{
|
||||||
if (j & 1)
|
eachtime->playersOnArea[j] = true;
|
||||||
eachtime->var2s[j/2] |= 1;
|
|
||||||
else
|
|
||||||
eachtime->var2s[j/2] |= 1 << 16;
|
|
||||||
|
|
||||||
playersOnArea[j] = true;
|
playersOnArea[j] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (j & 1)
|
eachtime->playersInArea[j] = true;
|
||||||
eachtime->vars[j/2] |= 1;
|
|
||||||
else
|
|
||||||
eachtime->vars[j/2] |= 1 << 16;
|
|
||||||
|
|
||||||
playersInArea[j] = true;
|
playersInArea[j] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1766,27 +1749,19 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
|
||||||
|
|
||||||
if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec))
|
if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec))
|
||||||
{
|
{
|
||||||
if (i & 1)
|
eachtime->playersOnArea[i] = true;
|
||||||
eachtime->var2s[i/2] |= 1;
|
|
||||||
else
|
|
||||||
eachtime->var2s[i/2] |= 1 << 16;
|
|
||||||
|
|
||||||
playersOnArea[i] = true;
|
playersOnArea[i] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i & 1)
|
eachtime->playersInArea[i] = true;
|
||||||
eachtime->vars[i/2] |= 1;
|
|
||||||
else
|
|
||||||
eachtime->vars[i/2] |= 1 << 16;
|
|
||||||
|
|
||||||
playersInArea[i] = true;
|
playersInArea[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((eachtime->sourceline->flags & ML_BOUNCY) == ML_BOUNCY)
|
if (eachtime->triggerOnExit)
|
||||||
inAndOut = true;
|
inAndOut = true;
|
||||||
|
|
||||||
// Check if a new player entered.
|
// Check if a new player entered.
|
||||||
|
|
|
@ -1659,6 +1659,24 @@ static void SaveSpecialLevelThinker(const thinker_t *th, const UINT8 type)
|
||||||
WRITEUINT32(save_p, SaveSector(ht->sector));
|
WRITEUINT32(save_p, SaveSector(ht->sector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveEachTimeThinker
|
||||||
|
//
|
||||||
|
// Loads a eachtime_t from a save game
|
||||||
|
//
|
||||||
|
static void SaveEachTimeThinker(const thinker_t *th, const UINT8 type)
|
||||||
|
{
|
||||||
|
const eachtime_t *ht = (const void *)th;
|
||||||
|
size_t i;
|
||||||
|
WRITEUINT8(save_p, type);
|
||||||
|
WRITEUINT32(save_p, SaveLine(ht->sourceline));
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
WRITECHAR(save_p, ht->playersInArea[i]);
|
||||||
|
WRITECHAR(save_p, ht->playersOnArea[i]);
|
||||||
|
}
|
||||||
|
WRITECHAR(save_p, ht->triggerOnExit);
|
||||||
|
}
|
||||||
|
|
||||||
// SaveRaiseThinker
|
// SaveRaiseThinker
|
||||||
//
|
//
|
||||||
// Saves a raise_t thinker
|
// Saves a raise_t thinker
|
||||||
|
@ -2250,7 +2268,7 @@ static void P_NetArchiveThinkers(void)
|
||||||
}
|
}
|
||||||
else if (th->function.acp1 == (actionf_p1)T_EachTimeThinker)
|
else if (th->function.acp1 == (actionf_p1)T_EachTimeThinker)
|
||||||
{
|
{
|
||||||
SaveSpecialLevelThinker(th, tc_eachtime);
|
SaveEachTimeThinker(th, tc_eachtime);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (th->function.acp1 == (actionf_p1)T_RaiseSector)
|
else if (th->function.acp1 == (actionf_p1)T_RaiseSector)
|
||||||
|
@ -2788,6 +2806,25 @@ static thinker_t* LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeili
|
||||||
return &ht->thinker;
|
return &ht->thinker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadEachTimeThinker
|
||||||
|
//
|
||||||
|
// Loads a eachtime_t from a save game
|
||||||
|
//
|
||||||
|
static thinker_t* LoadEachTimeThinker(actionf_p1 thinker)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
eachtime_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||||
|
ht->thinker.function.acp1 = thinker;
|
||||||
|
ht->sourceline = LoadLine(READUINT32(save_p));
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
ht->playersInArea[i] = READCHAR(save_p);
|
||||||
|
ht->playersOnArea[i] = READCHAR(save_p);
|
||||||
|
}
|
||||||
|
ht->triggerOnExit = READCHAR(save_p);
|
||||||
|
return &ht->thinker;
|
||||||
|
}
|
||||||
|
|
||||||
// LoadRaiseThinker
|
// LoadRaiseThinker
|
||||||
//
|
//
|
||||||
// Loads a raise_t from a save game
|
// Loads a raise_t from a save game
|
||||||
|
@ -3481,7 +3518,7 @@ static void P_NetUnArchiveThinkers(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tc_eachtime:
|
case tc_eachtime:
|
||||||
th = LoadSpecialLevelThinker((actionf_p1)T_EachTimeThinker, 0);
|
th = LoadEachTimeThinker((actionf_p1)T_EachTimeThinker);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tc_raisesector:
|
case tc_raisesector:
|
||||||
|
|
11
src/p_spec.c
11
src/p_spec.c
|
@ -6160,14 +6160,13 @@ static inline void P_AddNoEnemiesThinker(sector_t *sec, line_t *sourceline)
|
||||||
/** Adds a thinker for Each-Time linedef executors. A linedef executor is run
|
/** Adds a thinker for Each-Time linedef executors. A linedef executor is run
|
||||||
* only when a player enters the area and doesn't run again until they re-enter.
|
* only when a player enters the area and doesn't run again until they re-enter.
|
||||||
*
|
*
|
||||||
* \param sec Control sector that contains the lines of executors we will want to run.
|
|
||||||
* \param sourceline Control linedef.
|
* \param sourceline Control linedef.
|
||||||
* \sa P_SpawnSpecials, T_EachTimeThinker
|
* \sa P_SpawnSpecials, T_EachTimeThinker
|
||||||
* \author SSNTails <http://www.ssntails.org>
|
* \author SSNTails <http://www.ssntails.org>
|
||||||
*/
|
*/
|
||||||
static void P_AddEachTimeThinker(sector_t *sec, line_t *sourceline)
|
static void P_AddEachTimeThinker(line_t *sourceline)
|
||||||
{
|
{
|
||||||
levelspecthink_t *eachtime;
|
eachtime_t *eachtime;
|
||||||
|
|
||||||
// create and initialize new thinker
|
// create and initialize new thinker
|
||||||
eachtime = Z_Calloc(sizeof (*eachtime), PU_LEVSPEC, NULL);
|
eachtime = Z_Calloc(sizeof (*eachtime), PU_LEVSPEC, NULL);
|
||||||
|
@ -6175,8 +6174,8 @@ static void P_AddEachTimeThinker(sector_t *sec, line_t *sourceline)
|
||||||
|
|
||||||
eachtime->thinker.function.acp1 = (actionf_p1)T_EachTimeThinker;
|
eachtime->thinker.function.acp1 = (actionf_p1)T_EachTimeThinker;
|
||||||
|
|
||||||
eachtime->sector = sec;
|
|
||||||
eachtime->sourceline = sourceline;
|
eachtime->sourceline = sourceline;
|
||||||
|
eachtime->triggerOnExit = !!(sourceline->flags & ML_BOUNCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a camera scanner.
|
/** Adds a camera scanner.
|
||||||
|
@ -7160,7 +7159,7 @@ void P_SpawnSpecials(boolean fromnetsave)
|
||||||
case 332:
|
case 332:
|
||||||
case 335:
|
case 335:
|
||||||
sec = sides[*lines[i].sidenum].sector - sectors;
|
sec = sides[*lines[i].sidenum].sector - sectors;
|
||||||
P_AddEachTimeThinker(§ors[sec], &lines[i]);
|
P_AddEachTimeThinker(&lines[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// No More Enemies Linedef Exec
|
// No More Enemies Linedef Exec
|
||||||
|
@ -7192,7 +7191,7 @@ void P_SpawnSpecials(boolean fromnetsave)
|
||||||
if (lines[i].special == 322) // Each time
|
if (lines[i].special == 322) // Each time
|
||||||
{
|
{
|
||||||
sec = sides[*lines[i].sidenum].sector - sectors;
|
sec = sides[*lines[i].sidenum].sector - sectors;
|
||||||
P_AddEachTimeThinker(§ors[sec], &lines[i]);
|
P_AddEachTimeThinker(&lines[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
11
src/p_spec.h
11
src/p_spec.h
|
@ -320,6 +320,15 @@ typedef struct
|
||||||
sector_t *sector; // Sector the thinker is from
|
sector_t *sector; // Sector the thinker is from
|
||||||
} levelspecthink_t;
|
} levelspecthink_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
thinker_t thinker;
|
||||||
|
line_t *sourceline; // Source line of the thinker
|
||||||
|
boolean playersInArea[MAXPLAYERS];
|
||||||
|
boolean playersOnArea[MAXPLAYERS];
|
||||||
|
boolean triggerOnExit;
|
||||||
|
} eachtime_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
RF_REVERSE = 1, //Lower when stood on
|
RF_REVERSE = 1, //Lower when stood on
|
||||||
|
@ -377,7 +386,7 @@ void T_FloatSector(levelspecthink_t *floater);
|
||||||
void T_MarioBlockChecker(levelspecthink_t *block);
|
void T_MarioBlockChecker(levelspecthink_t *block);
|
||||||
void T_ThwompSector(levelspecthink_t *thwomp);
|
void T_ThwompSector(levelspecthink_t *thwomp);
|
||||||
void T_NoEnemiesSector(levelspecthink_t *nobaddies);
|
void T_NoEnemiesSector(levelspecthink_t *nobaddies);
|
||||||
void T_EachTimeThinker(levelspecthink_t *eachtime);
|
void T_EachTimeThinker(eachtime_t *eachtime);
|
||||||
void T_CameraScanner(elevator_t *elevator);
|
void T_CameraScanner(elevator_t *elevator);
|
||||||
void T_RaiseSector(raise_t *raise);
|
void T_RaiseSector(raise_t *raise);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue