- cleanup in Blood plus repeats in aiunicult.cpp

* removed the picWidth/Height functions because their one use can be easily inlined
* deleted the unused initvals in GENDUDEEXTRA
This commit is contained in:
Christoph Oelckers 2022-10-06 18:28:42 +02:00
parent 1085752e01
commit 1d48b0776e
7 changed files with 18 additions and 37 deletions

View file

@ -2947,8 +2947,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
{
pEffect->spr.cstat = CSTAT_SPRITE_ALIGNMENT_FACING;
pEffect->spr.pal = 6;
pEffect->spr.xrepeat = actor->spr.xrepeat;
pEffect->spr.yrepeat = actor->spr.yrepeat;
pEffect->spr.CopyScale(&actor->spr);
}
GIBTYPE nGibType;
@ -6250,8 +6249,8 @@ DBloodActor* actSpawnThing(sectortype* pSector, const DVector3& pos, int nThingT
actor->spr.picnum = pThingInfo->picnum;
actor->spr.shade = pThingInfo->shade;
actor->spr.pal = pThingInfo->pal;
if (pThingInfo->_xrepeat) actor->spr.xrepeat = pThingInfo->_xrepeat;
if (pThingInfo->_yrepeat) actor->spr.yrepeat = pThingInfo->_yrepeat;
if (pThingInfo->_xrepeat) actor->spr.SetScaleX(pThingInfo->_xrepeat * REPEAT_SCALE);
if (pThingInfo->_yrepeat) actor->spr.SetScaleY(pThingInfo->_yrepeat * REPEAT_SCALE);
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
switch (nThingType)
{

View file

@ -342,8 +342,10 @@ static void ThrowThing(DBloodActor* actor, bool impact)
impact = true;
break;
case kModernThingThrowableRock:
{
double s = 0.375 + Random(42) * REPEAT_SCALE;
spawned->spr.picnum = gCustomDudeDebrisPics[Random(5)];
spawned->spr.xrepeat = spawned->spr.yrepeat = 24 + Random(42);
spawned->spr.SetScale(s, s);
spawned->spr.cstat |= CSTAT_SPRITE_BLOCK;
spawned->spr.pal = 5;
@ -355,6 +357,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
else if (spawned->spr.ScaleX() > 0.46875) spawned->xspr.data1 = 23;
else spawned->xspr.data1 = 12;
return;
}
case kThingTNTBarrel:
case kThingArmedProxBomb:
case kThingArmedSpray:
@ -879,9 +882,9 @@ static void unicultThinkChase(DBloodActor* actor)
}
int wd1 = picWidth(hitactor->spr.picnum, hitactor->spr.xrepeat);
int wd2 = picWidth(actor->spr.picnum, actor->spr.xrepeat);
if (wd1 < (wd2 << 3))
double wd1 = tileWidth(hitactor->spr.picnum) * hitactor->spr.ScaleX();
double wd2 = tileWidth(actor->spr.picnum) * actor->spr.ScaleX();
if (wd1 < (wd2 * 8))
{
//viewSetSystemMessage("OBJ SIZE: %d DUDE SIZE: %d", wd1, wd2);
if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeDodgeShorterW);
@ -1934,8 +1937,7 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, double nDist)
// inherit sprite size (useful for seqs with zero repeats)
if (source->spr.flags & kModernTypeFlag2)
{
spawned->spr.xrepeat = source->spr.xrepeat;
spawned->spr.yrepeat = source->spr.yrepeat;
spawned->spr.CopyScale(&source->spr);
}
gKillMgr.AddKill(spawned);
@ -1979,8 +1981,7 @@ void genDudeTransform(DBloodActor* actor)
actor->spr.pal = actIncarnation->spr.pal;
actor->spr.shade = actIncarnation->spr.shade;
actor->copy_clipdist(actIncarnation);
actor->spr.xrepeat = actIncarnation->spr.xrepeat;
actor->spr.yrepeat = actIncarnation->spr.yrepeat;
actor->spr.CopyScale(&actIncarnation->spr);
actor->xspr.txID = actIncarnation->xspr.txID;
actor->xspr.command = actIncarnation->xspr.command;
@ -2258,9 +2259,7 @@ bool genDudePrepare(DBloodActor* actor, int propId)
case kGenDudePropertyAll:
case kGenDudePropertyInitVals:
pExtra->moveSpeed = getGenDudeMoveSpeed(actor, 0, true, false);
pExtra->initVals[0] = actor->spr.xrepeat;
pExtra->initVals[1] = actor->spr.yrepeat;
pExtra->initVals[2] = actor->spr.clipdist;
pExtra->clipdist = actor->spr.clipdist;
if (propId) break;
[[fallthrough]];
@ -2477,7 +2476,7 @@ bool genDudePrepare(DBloodActor* actor, int propId)
if (!(actor->sector()->floorstat & CSTAT_SECTOR_SKY))
actor->spr.pos.Z += min(actor->sector()->floorz - zBot, 0.);
actor->clipdist = clamp((actor->spr.xrepeat + actor->spr.yrepeat) * 0.125, 1., 30.);
actor->clipdist = clamp((actor->spr.ScaleX() + actor->spr.ScaleY()) * 8, 1., 30.);
if (propId) break;
}
}

View file

@ -159,7 +159,7 @@ extern const GENDUDESND gCustomDudeSnd[];
// temporary, until normal DUDEEXTRA gets refactored
struct GENDUDEEXTRA
{
uint16_t initVals[3]; // xrepeat, yrepeat, clipdist
double clipdist;
uint16_t availDeaths[kDamageMax]; // list of seqs with deaths for each damage type
uint32_t moveSpeed;
double fireDist; // counts from sprite size

View file

@ -587,20 +587,5 @@ BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int n
return sectorMap;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int picWidth(int nPic, int repeat) {
return ClipLow((tileWidth(nPic) * repeat) << 2, 0);
}
int picHeight(int nPic, int repeat) {
return ClipLow((tileHeight(nPic) * repeat) << 2, 0);
}
END_BLD_NS

View file

@ -41,7 +41,5 @@ void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Col
void ClipMove(DVector3& pos, sectortype** pSector, const DVector2& vect, double wd, double cd, double fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3);
BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int nDist, TArray<walltype*>* pWalls, bool newSectCheckMethod = false);
int picWidth(int nPic, int repeat);
int picHeight(int nPic, int repeat);
END_BLD_NS

View file

@ -1419,7 +1419,7 @@ int getSpriteMassBySize(DBloodActor* actor)
case kDudeModernCustom:
case kDudeModernCustomBurning:
seqId = actor->xspr.data2;
clipDist = actor->genDudeExtra.initVals[2];
clipDist = actor->genDudeExtra.clipdist;
break;
default:
seqId = getDudeInfo(actor->spr.type)->seqStartID;
@ -9322,7 +9322,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, GENDUDEEXTRA& w, G
{
if (arc.BeginObject(keyname))
{
arc.Array("initvals", w.initVals, 3)
arc ("clipdist", w.clipdist)
.Array("availdeaths", w.availDeaths, kDamageMax)
("movespeed", w.moveSpeed)
("firedist", w.fireDist)

View file

@ -2305,7 +2305,7 @@ bool bloodpool(DDukeActor* actor, bool puke)
}
}
if (xx < 844 / 16. && actor->spr.ScaleX() > 0.09375 && actor->spr.yrepeat > 6)
if (xx < 844 / 16. && actor->spr.ScaleX() > 0.09375 && actor->spr.ScaleY() > 0.09375)
{
if (actor->spr.pal == 0 && (krand() & 255) < 16 && !puke)
{