mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 20:11:47 +00:00
Make T_MarioBlock use its own thinker data structure
This commit is contained in:
parent
e6193297d8
commit
a90735fdf0
3 changed files with 67 additions and 41 deletions
|
|
@ -941,17 +941,10 @@ void T_StartCrumble(elevator_t *elevator)
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// Mario hits a block!
|
// Mario hits a block!
|
||||||
//
|
//
|
||||||
void T_MarioBlock(levelspecthink_t *block)
|
void T_MarioBlock(mariothink_t *block)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
#define speed vars[1]
|
|
||||||
#define direction vars[2]
|
|
||||||
#define floorwasheight vars[3]
|
|
||||||
#define ceilingwasheight vars[4]
|
|
||||||
#define distance vars[5]
|
|
||||||
#define low vars[6]
|
|
||||||
|
|
||||||
T_MovePlane
|
T_MovePlane
|
||||||
(
|
(
|
||||||
block->sector,
|
block->sector,
|
||||||
|
|
@ -972,12 +965,12 @@ void T_MarioBlock(levelspecthink_t *block)
|
||||||
block->direction
|
block->direction
|
||||||
);
|
);
|
||||||
|
|
||||||
if (block->sector->ceilingheight >= block->ceilingwasheight + 32*FRACUNIT) // Go back down now..
|
if (block->sector->ceilingheight >= block->ceilingstartheight + 32*FRACUNIT) // Go back down now..
|
||||||
block->direction = -block->direction;
|
block->direction *= -1;
|
||||||
else if (block->sector->ceilingheight <= block->ceilingwasheight)
|
else if (block->sector->ceilingheight <= block->ceilingstartheight)
|
||||||
{
|
{
|
||||||
block->sector->ceilingheight = block->ceilingwasheight;
|
block->sector->ceilingheight = block->ceilingstartheight;
|
||||||
block->sector->floorheight = block->floorwasheight;
|
block->sector->floorheight = block->floorstartheight;
|
||||||
P_RemoveThinker(&block->thinker);
|
P_RemoveThinker(&block->thinker);
|
||||||
block->sector->floordata = NULL;
|
block->sector->floordata = NULL;
|
||||||
block->sector->ceilingdata = NULL;
|
block->sector->ceilingdata = NULL;
|
||||||
|
|
@ -986,15 +979,8 @@ void T_MarioBlock(levelspecthink_t *block)
|
||||||
block->direction = 0;
|
block->direction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;)
|
for (i = -1; (i = P_FindSectorFromTag(block->tag, i)) >= 0 ;)
|
||||||
P_RecalcPrecipInSector(§ors[i]);
|
P_RecalcPrecipInSector(§ors[i]);
|
||||||
|
|
||||||
#undef speed
|
|
||||||
#undef direction
|
|
||||||
#undef floorwasheight
|
|
||||||
#undef ceilingwasheight
|
|
||||||
#undef distance
|
|
||||||
#undef low
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_FloatSector(floatthink_t *floater)
|
void T_FloatSector(floatthink_t *floater)
|
||||||
|
|
@ -2460,11 +2446,11 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
void EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
||||||
{
|
{
|
||||||
sector_t *roversec = rover->master->frontsector;
|
sector_t *roversec = rover->master->frontsector;
|
||||||
fixed_t topheight = *rover->topheight;
|
fixed_t topheight = *rover->topheight;
|
||||||
levelspecthink_t *block;
|
mariothink_t *block;
|
||||||
mobj_t *thing;
|
mobj_t *thing;
|
||||||
fixed_t oldx = 0, oldy = 0, oldz = 0;
|
fixed_t oldx = 0, oldy = 0, oldz = 0;
|
||||||
|
|
||||||
|
|
@ -2472,7 +2458,7 @@ INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
||||||
I_Assert(puncher->player != NULL);
|
I_Assert(puncher->player != NULL);
|
||||||
|
|
||||||
if (roversec->floordata || roversec->ceilingdata)
|
if (roversec->floordata || roversec->ceilingdata)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
if (!(rover->flags & FF_SOLID))
|
if (!(rover->flags & FF_SOLID))
|
||||||
rover->flags |= (FF_SOLID|FF_RENDERALL|FF_CUTLEVEL);
|
rover->flags |= (FF_SOLID|FF_RENDERALL|FF_CUTLEVEL);
|
||||||
|
|
@ -2480,8 +2466,9 @@ INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
||||||
// Find an item to pop out!
|
// Find an item to pop out!
|
||||||
thing = SearchMarioNode(roversec->touching_thinglist);
|
thing = SearchMarioNode(roversec->touching_thinglist);
|
||||||
|
|
||||||
// Found something!
|
if (!thing)
|
||||||
if (thing)
|
S_StartSound(puncher, sfx_mario1); // "Thunk!" sound - puncher is "close enough".
|
||||||
|
else // Found something!
|
||||||
{
|
{
|
||||||
const boolean itsamonitor = (thing->flags & MF_MONITOR) == MF_MONITOR;
|
const boolean itsamonitor = (thing->flags & MF_MONITOR) == MF_MONITOR;
|
||||||
// create and initialize new elevator thinker
|
// create and initialize new elevator thinker
|
||||||
|
|
@ -2494,13 +2481,11 @@ INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
||||||
|
|
||||||
// Set up the fields
|
// Set up the fields
|
||||||
block->sector = roversec;
|
block->sector = roversec;
|
||||||
block->vars[0] = sector->tag; // actionsector
|
block->speed = 4*FRACUNIT;
|
||||||
block->vars[1] = 4*FRACUNIT; // speed
|
block->direction = 1;
|
||||||
block->vars[2] = 1; // Up // direction
|
block->floorstartheight = block->sector->floorheight;
|
||||||
block->vars[3] = block->sector->floorheight; // floorwasheight
|
block->ceilingstartheight = block->sector->ceilingheight;
|
||||||
block->vars[4] = block->sector->ceilingheight; // ceilingwasheight
|
block->tag = (INT16)sector->tag;
|
||||||
block->vars[5] = FRACUNIT; // distance
|
|
||||||
block->vars[6] = 1; // low
|
|
||||||
|
|
||||||
if (itsamonitor)
|
if (itsamonitor)
|
||||||
{
|
{
|
||||||
|
|
@ -2541,8 +2526,4 @@ INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
||||||
P_SetThingPosition(thing);
|
P_SetThingPosition(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
S_StartSound(puncher, sfx_mario1); // "Thunk!" sound - puncher is "close enough".
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1675,6 +1675,23 @@ static void SaveContinuousFallThinker(const thinker_t *th, const UINT8 type)
|
||||||
WRITEFIXED(save_p, ht->destheight);
|
WRITEFIXED(save_p, ht->destheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SaveMarioBlockThinker
|
||||||
|
//
|
||||||
|
// Saves a mariothink_t thinker
|
||||||
|
//
|
||||||
|
static void SaveMarioBlockThinker(const thinker_t *th, const UINT8 type)
|
||||||
|
{
|
||||||
|
const mariothink_t *ht = (const void *)th;
|
||||||
|
WRITEUINT8(save_p, type);
|
||||||
|
WRITEUINT32(save_p, SaveSector(ht->sector));
|
||||||
|
WRITEFIXED(save_p, ht->speed);
|
||||||
|
WRITEINT32(save_p, ht->direction);
|
||||||
|
WRITEFIXED(save_p, ht->floorstartheight);
|
||||||
|
WRITEFIXED(save_p, ht->ceilingstartheight);
|
||||||
|
WRITEINT16(save_p, ht->tag);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// SaveFloatThinker
|
// SaveFloatThinker
|
||||||
//
|
//
|
||||||
|
|
@ -2338,7 +2355,7 @@ static void P_NetArchiveThinkers(void)
|
||||||
}
|
}
|
||||||
else if (th->function.acp1 == (actionf_p1)T_MarioBlock)
|
else if (th->function.acp1 == (actionf_p1)T_MarioBlock)
|
||||||
{
|
{
|
||||||
SaveSpecialLevelThinker(th, tc_marioblock);
|
SaveMarioBlockThinker(th, tc_marioblock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker)
|
else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker)
|
||||||
|
|
@ -2848,6 +2865,23 @@ static thinker_t* LoadContinuousFallThinker(actionf_p1 thinker)
|
||||||
return &ht->thinker;
|
return &ht->thinker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadMarioBlockThinker
|
||||||
|
//
|
||||||
|
// Loads a mariothink_t from a save game
|
||||||
|
//
|
||||||
|
static thinker_t* LoadMarioBlockThinker(actionf_p1 thinker)
|
||||||
|
{
|
||||||
|
mariothink_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||||
|
ht->thinker.function.acp1 = thinker;
|
||||||
|
ht->sector = LoadSector(READUINT32(save_p));
|
||||||
|
ht->speed = READFIXED(save_p);
|
||||||
|
ht->direction = READINT32(save_p);
|
||||||
|
ht->floorstartheight = READFIXED(save_p);
|
||||||
|
ht->ceilingstartheight = READFIXED(save_p);
|
||||||
|
ht->tag = READINT16(save_p);
|
||||||
|
return &ht->thinker;
|
||||||
|
}
|
||||||
|
|
||||||
// LoadFloatThinker
|
// LoadFloatThinker
|
||||||
//
|
//
|
||||||
// Loads a floatthink_t from a save game
|
// Loads a floatthink_t from a save game
|
||||||
|
|
@ -3596,7 +3630,7 @@ static void P_NetUnArchiveThinkers(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tc_marioblock:
|
case tc_marioblock:
|
||||||
th = LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3);
|
th = LoadMarioBlockThinker((actionf_p1)T_MarioBlock);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tc_marioblockchecker:
|
case tc_marioblockchecker:
|
||||||
|
|
|
||||||
15
src/p_spec.h
15
src/p_spec.h
|
|
@ -331,6 +331,17 @@ typedef struct
|
||||||
fixed_t destheight;
|
fixed_t destheight;
|
||||||
} continuousfall_t;
|
} continuousfall_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
thinker_t thinker;
|
||||||
|
sector_t *sector;
|
||||||
|
fixed_t speed;
|
||||||
|
INT32 direction;
|
||||||
|
fixed_t floorstartheight;
|
||||||
|
fixed_t ceilingstartheight;
|
||||||
|
INT16 tag;
|
||||||
|
} mariothink_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
thinker_t thinker;
|
thinker_t thinker;
|
||||||
|
|
@ -391,7 +402,7 @@ INT32 EV_StartCrumble(sector_t *sector, ffloor_t *rover,
|
||||||
|
|
||||||
void EV_DoContinuousFall(sector_t *sec, sector_t *backsector, fixed_t spd, boolean backwards);
|
void EV_DoContinuousFall(sector_t *sec, sector_t *backsector, fixed_t spd, boolean backwards);
|
||||||
|
|
||||||
INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher);
|
void EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher);
|
||||||
|
|
||||||
void T_MoveFloor(floormove_t *movefloor);
|
void T_MoveFloor(floormove_t *movefloor);
|
||||||
|
|
||||||
|
|
@ -399,7 +410,7 @@ void T_MoveElevator(elevator_t *elevator);
|
||||||
void T_ContinuousFalling(continuousfall_t *faller);
|
void T_ContinuousFalling(continuousfall_t *faller);
|
||||||
void T_BounceCheese(levelspecthink_t *bouncer);
|
void T_BounceCheese(levelspecthink_t *bouncer);
|
||||||
void T_StartCrumble(elevator_t *elevator);
|
void T_StartCrumble(elevator_t *elevator);
|
||||||
void T_MarioBlock(levelspecthink_t *block);
|
void T_MarioBlock(mariothink_t *block);
|
||||||
void T_FloatSector(floatthink_t *floater);
|
void T_FloatSector(floatthink_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);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue