- AutoBreakWall and SpawnShrap cleanup.

This commit is contained in:
Christoph Oelckers 2021-10-31 16:55:24 +01:00
parent d63ac59fa0
commit 13f0b08aeb
6 changed files with 31 additions and 40 deletions

View file

@ -39,8 +39,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
BREAK_INFOp GlobBreakInfo;
static int SectorOfWall(short theline);
static void DoWallBreakSpriteMatch(short match);
@ -556,9 +554,7 @@ DSWActor* FindBreakSpriteMatch(short match)
int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, short ang, short type)
{
BREAK_INFOp break_info;
short BreakSprite;
WALLp nwp;
SPRITEp bsp;
wallp->lotag = 0;
if (wallp->nextwall >= 0)
@ -593,23 +589,16 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, short ang, short
{
vec3_t hit_pos = { hit_x, hit_y, hit_z };
// need correct location for spawning shrap
BreakSprite = COVERinsertsprite(0, STAT_DEFAULT);
ASSERT(BreakSprite >= 0);
auto breakActor = &swActors[BreakSprite];
bsp = &sprite[BreakSprite];
auto breakActor = InsertActor(0, STAT_DEFAULT);
auto bsp = &breakActor->s();
bsp->cstat = 0;
bsp->extra = 0;
bsp->ang = ang;
bsp->picnum = ST1;
bsp->xrepeat = bsp->yrepeat = 64;
setspritez(BreakSprite, &hit_pos);
// pass Break Info Globally
GlobBreakInfo = break_info;
SpawnShrap(breakActor, nullptr);
GlobBreakInfo = nullptr;
KillSprite(BreakSprite);
SetActorZ(breakActor, &hit_pos);
SpawnShrap(breakActor, nullptr, -1, break_info);
KillActor(breakActor);
}
// change the wall
@ -649,14 +638,11 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, short ang, short
DoWallBreakSpriteMatch(wallp->hitag);
}
}
return true;
}
bool UserBreakWall(WALLp wp, short)
{
SPRITEp sp;
short match = wp->hitag;
int block_flags = CSTAT_WALL_BLOCK|CSTAT_WALL_BLOCK_HITSCAN;
int type_flags = CSTAT_WALL_TRANSLUCENT|CSTAT_WALL_MASKED|CSTAT_WALL_1WAY;
@ -680,7 +666,7 @@ bool UserBreakWall(WALLp wp, short)
return true;
}
sp = &actor->s();
auto sp = &actor->s();
if (wp->picnum == SP_TAG5(sp))
return true;
@ -972,9 +958,7 @@ int AutoBreakSprite(short BreakSprite, short type)
bp->picnum = break_info->breaknum;
// pass Break Info Globally
GlobBreakInfo = break_info;
SpawnShrap(breakActor, nullptr);
GlobBreakInfo = nullptr;
SpawnShrap(breakActor, nullptr, -1, break_info);
if (bp->picnum == 3683)
RESET(bp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
}
@ -986,9 +970,7 @@ int AutoBreakSprite(short BreakSprite, short type)
RESET(bp->cstat, CSTAT_SPRITE_BREAKABLE);
// pass Break Info Globally
GlobBreakInfo = break_info;
SpawnShrap(breakActor, nullptr);
GlobBreakInfo = nullptr;
SpawnShrap(breakActor, nullptr, -1, break_info);
// kill it or change the pic
if (TEST(break_info->flags, BF_KILL) || break_info->breaknum == -1)

View file

@ -39,18 +39,17 @@ enum
BF_LEAVE_BREAK = BIT(5),
};
typedef struct
typedef struct BREAK_INFO
{
short picnum, breaknum, shrap_type;
short flags, shrap_amt;
} BREAK_INFO, *BREAK_INFOp;
} *BREAK_INFOp;
BREAK_INFOp FindWallBreakInfo(short picnum);
BREAK_INFOp FindSpriteBreakInfo(short picnum);
void SortBreakInfo(void);
BREAK_INFOp SetupWallForBreak(WALLp wallp);
BREAK_INFOp SetupSpriteForBreak(DSWActor* actor);
DSWActor* FindBreakSpriteMatch(short match);
bool HitBreakWall(WALLp wp, int, int, int, short ang, short type);
int HitBreakSprite(short BreakSprite, short type);
bool CheckBreakToughness(BREAK_INFOp break_info, short ID);

View file

@ -1950,7 +1950,8 @@ bool SoundValidAndActive(SPRITEp spr, int channel);
ANIMATOR DoActorBeginJump,DoActorJump,DoActorBeginFall,DoActorFall,DoActorDeathMove;
int SpawnShrap(DSWActor*, DSWActor*, int = -1);
struct BREAK_INFO;
int SpawnShrap(DSWActor*, DSWActor*, int = -1, BREAK_INFO* breakinfo = nullptr);
void PlayerUpdateHealth(PLAYERp pp, short value);
void PlayerUpdateAmmo(PLAYERp pp, short WeaponNum, short value);
@ -2187,6 +2188,7 @@ void SetSpikeActive(short SpriteNum); // spike.c
#define NTAG_SEARCH_LO_HI 3
int COVERinsertsprite(short sectnum, short statnum); //returns (short)spritenum;
DSWActor* InsertActor(int sectnum, int statnum);
void AudioUpdate(void); // stupid

View file

@ -54,6 +54,11 @@ SAVE save;
bool FAF_DebugView = false;
DSWActor* InsertActor(int sectnum, int stat)
{
return &swActors[COVERinsertsprite(sectnum, stat)];
}
int COVERinsertsprite(short sectnum, short stat)
{
short spnum;
@ -62,17 +67,17 @@ int COVERinsertsprite(short sectnum, short stat)
PRODUCTION_ASSERT(spnum >= 0);
pSprite->x = sprite[spnum].y = sprite[spnum].z = 0;
pSprite->x = pSprite->y = pSprite->z = 0;
pSprite->cstat = 0;
pSprite->picnum = 0;
pSprite->shade = 0;
pSprite->pal = 0;
pSprite->clipdist = 0;
pSprite->xrepeat = sprite[spnum].yrepeat = 0;
pSprite->xoffset = sprite[spnum].yoffset = 0;
pSprite->xrepeat = pSprite->yrepeat = 0;
pSprite->xoffset = pSprite->yoffset = 0;
pSprite->ang = 0;
pSprite->owner = -1;
pSprite->xvel = sprite[spnum].yvel = sprite[spnum].zvel = 0;
pSprite->xvel = pSprite->yvel = pSprite->zvel = 0;
pSprite->lotag = 0;
pSprite->hitag = 0;
pSprite->extra = 0;

View file

@ -191,4 +191,9 @@ inline void ChangeActorSect(DSWActor* actor, int sect)
changespritesect(actor->GetSpriteIndex(), sect);
}
inline int SetActorZ(DSWActor* actor, const vec3_t* newpos)
{
return setspritez(actor->GetSpriteIndex(), newpos);
}
END_SW_NS

View file

@ -2863,7 +2863,7 @@ STATEp UserStateSetup(short base_tile, short num_tiles)
#endif
int
SpawnShrap(DSWActor* parentActor, DSWActor* secondaryActor, int means)
SpawnShrap(DSWActor* parentActor, DSWActor* secondaryActor, int means, BREAK_INFOp breakinfo)
{
int Secondary = secondaryActor ? secondaryActor->GetSpriteIndex() : means;
int ParentNum = parentActor->GetSpriteIndex();
@ -3207,7 +3207,6 @@ SpawnShrap(DSWActor* parentActor, DSWActor* secondaryActor, int means)
short shrap_ang = parent->ang;
short shrap_delta_size = 0;
short shrap_amt = 0;
extern BREAK_INFOp GlobBreakInfo;
if (Prediction)
return 0;
@ -3220,11 +3219,10 @@ SpawnShrap(DSWActor* parentActor, DSWActor* secondaryActor, int means)
return 0;
}
if (GlobBreakInfo)
if (breakinfo)
{
shrap_type = GlobBreakInfo->shrap_type;
shrap_amt = GlobBreakInfo->shrap_amt;
GlobBreakInfo = nullptr;
shrap_type = breakinfo->shrap_type;
shrap_amt = breakinfo->shrap_amt;
goto AutoShrap;
}
else if (TEST(parent->extra, SPRX_BREAKABLE))