- no more picnum in spawn CCMD

This commit is contained in:
Christoph Oelckers 2022-12-30 19:12:20 +01:00
parent 745275dc24
commit b56aa1e1a3
4 changed files with 28 additions and 22 deletions

View file

@ -45,7 +45,7 @@ public:
bool operator > (FTextureID other) const { return texnum > other.texnum; }
protected:
FTextureID(int num) { texnum = num; }
constexpr FTextureID(int num) : texnum(num) { }
private:
int texnum;
};
@ -53,13 +53,13 @@ private:
class FNullTextureID : public FTextureID
{
public:
FNullTextureID() : FTextureID(0) {}
constexpr FNullTextureID() : FTextureID(0) {}
};
// This is for the script interface which needs to do casts from int to texture.
class FSetTextureID : public FTextureID
{
public:
FSetTextureID(int v) : FTextureID(v) {}
constexpr FSetTextureID(int v) : FTextureID(v) {}
};

View file

@ -180,10 +180,13 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (!h->GetOwner())
{
applyRotation1(h, t, viewang);
FTextureID base = FNullTextureID();
if (t->sectp->lotag == ST_2_UNDERWATER) base = TexMan.CheckForTexture("APLAYERSWIMMING", ETextureType::Any);
else if ((h->floorz - h->spr.pos.Z) > 64) base = TexMan.CheckForTexture("APLAYERJUMP", ETextureType::Any);
if (!base.isValid()) base = h->spr.spritetexture();
applyRotation1(h, t, viewang, base);
if (t->sectp->lotag == ST_2_UNDERWATER) t->picnum += DTILE_APLAYERSWIMMING - DTILE_APLAYER;
else if ((h->floorz - h->spr.pos.Z) > 64) t->picnum += DTILE_APLAYERJUMP - DTILE_APLAYER;
t->pal = ps[p].palookup;
continue;

View file

@ -44,7 +44,7 @@ static int ccmd_spawn(CCmdFuncPtr parm)
{
int x = 0, y = 0, z = 0;
ESpriteFlags cstat = 0;
int picnum = 0;
PClassActor* cls = nullptr;
unsigned int pal = 0;
DAngle ang = nullAngle;
int set = 0;
@ -74,24 +74,25 @@ static int ccmd_spawn(CCmdFuncPtr parm)
[[fallthrough]];
case 1: // tile number
if (isdigit((uint8_t)parm->parms[0][0])) {
picnum = (unsigned short)atol(parm->parms[0]);
cls = GetSpawnType((unsigned short)atol(parm->parms[0]));
}
else
{
picnum = tileForName(parm->parms[0]);
if (picnum < 0)
cls = PClass::FindActor(parm->parms[0]);
if (!cls)
{
picnum = getlabelvalue(parm->parms[0]);
if (picnum < 0)
int picno = tileForName(parm->parms[0]);
if (picno < 0)
{
Printf("spawn: Invalid tile label given\n");
return CCMD_OK;
picno = getlabelvalue(parm->parms[0]);
}
cls = GetSpawnType(picno);
}
}
if (picnum >= MAXTILES) {
Printf("spawn: Invalid tile number\n");
if (cls == nullptr)
{
Printf("spawn: Invalid actor type '%s'\n", parm->parms[0]);
return CCMD_OK;
}
break;
@ -99,7 +100,7 @@ static int ccmd_spawn(CCmdFuncPtr parm)
return CCMD_SHOWHELP;
}
auto spawned = spawn(ps[myconnectindex].GetActor(), picnum);
auto spawned = spawn(ps[myconnectindex].GetActor(), cls);
if (spawned)
{
if (set & 1) spawned->spr.pal = (uint8_t)pal;
@ -160,7 +161,7 @@ bool GameInterface::WantEscape()
int registerosdcommands(void)
{
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
C_RegisterFunction("spawn","spawn <typename> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
return 0;
}

View file

@ -231,7 +231,7 @@ inline int angletorotation2(DAngle sprang, DAngle viewang)
}
// 4 (8) frame rotation.
inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang)
inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang, FTextureID base = FNullTextureID())
{
if (tilehasmodelorvoxel(h->spr.spritetexture(), h->spr.pal))
{
@ -246,11 +246,12 @@ inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang)
t->cstat |= CSTAT_SPRITE_XFLIP;
}
else t->cstat &= ~CSTAT_SPRITE_XFLIP;
t->picnum = h->spr.picnum + k;
if (base.isNull()) base = h->spr.spritetexture();
t->setspritetexture(base + k);
}
// 6 (12) frame rotation.
inline void applyRotation2(DDukeActor* h, tspritetype* t, DAngle viewang)
inline void applyRotation2(DDukeActor* h, tspritetype* t, DAngle viewang, FTextureID base = FNullTextureID())
{
if (tilehasmodelorvoxel(h->spr.spritetexture(), h->spr.pal))
{
@ -265,7 +266,8 @@ inline void applyRotation2(DDukeActor* h, tspritetype* t, DAngle viewang)
t->cstat |= CSTAT_SPRITE_XFLIP;
}
else t->cstat &= ~CSTAT_SPRITE_XFLIP;
t->picnum = h->spr.picnum + k;
if (base.isNull()) base = h->spr.spritetexture();
t->setspritetexture(base + k);
}
inline int monsterCheatCheck(DDukeActor* self)