- handle all occurences of tileWidth and tileHeight using spritetypebase::picnum.

This commit is contained in:
Christoph Oelckers 2022-12-06 21:49:04 +01:00
parent 1258ddc551
commit e26d9106aa
19 changed files with 77 additions and 37 deletions

View file

@ -147,7 +147,8 @@ void processTileImport(const char* cmd, FScriptPosition& pos, TileImport& imp)
if (imp.crc32 != INT64_MAX && int(imp.crc32) != tileGetCRC32(imp.tile))
return;
if (imp.sizex != INT_MAX && tileWidth(imp.tile) != imp.sizex && tileHeight(imp.tile) != imp.sizey)
auto tex = tileGetTexture(imp.tile);
if (imp.sizex != INT_MAX && tex->GetTexelWidth() != imp.sizex && tex->GetTexelHeight() != imp.sizey)
return;
imp.alphacut = clamp(imp.alphacut, 0, 255);
@ -160,7 +161,7 @@ void processTileImport(const char* cmd, FScriptPosition& pos, TileImport& imp)
// This is not quite the same as originally, for two reasons:
// 1: Since these are texture properties now, there's no need to clear them.
// 2: The original code assumed that an imported texture cannot have an offset. But this can import Doom patches and PNGs with grAb, so the situation is very different.
auto tex = tileGetTexture(imp.tile);
tex = tileGetTexture(imp.tile); // this is not the same texture as above anymore!
if (imp.xoffset == INT_MAX) imp.xoffset = tex->GetTexelLeftOffset();
else imp.xoffset = clamp(imp.xoffset, -128, 127);

View file

@ -532,7 +532,8 @@ double intersectSprite(DCoreActor* actor, const DVector3& start, const DVector3&
if (factor < 0 || factor > maxfactor) return -1;
auto sprwidth = tileWidth(actor->spr.picnum) * actor->spr.scale.X * 0.5;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
auto sprwidth = tex->GetDisplayWidth() * actor->spr.scale.X * 0.5;
auto point = start + direction * factor;
// Using proper distance here, Build originally used the sum of x- and y-distance

View file

@ -98,7 +98,7 @@ SkyDefinition getSky(int tilenum)
result = {};
result.scale = 1.f;
}
int w = tileWidth(tilenum);
int w = tileWidth(tilenum);
if (result.lognumtiles == 0 || w >= 256)
{
if (w < 512) result.lognumtiles = 2;

View file

@ -2573,7 +2573,8 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector
if (mass > 0)
{
double size = (tileWidth(actor->spr.picnum) * actor->spr.scale.X * tileHeight(actor->spr.picnum) * actor->spr.scale.Y) / 0x20000;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double size = (tex->GetDisplayWidth() * actor->spr.scale.X * tex->GetDisplayHeight() * actor->spr.scale.Y) / 0x20000;
actor->vel += vect * Scale(damage, size, mass);
}
}

View file

@ -881,9 +881,11 @@ static void unicultThinkChase(DBloodActor* actor)
return;
}
auto tex1 = TexMan.GetGameTexture(hitactor->spr.spritetexture());
auto tex2 = TexMan.GetGameTexture(actor->spr.spritetexture());
double wd1 = tileWidth(hitactor->spr.picnum) * hitactor->spr.scale.X;
double wd2 = tileWidth(actor->spr.picnum) * actor->spr.scale.X;
double wd1 = tex1->GetDisplayWidth() * hitactor->spr.scale.X;
double wd2 = tex2->GetDisplayWidth() * actor->spr.scale.X;
if (wd1 < (wd2 * 8))
{
//viewSetSystemMessage("OBJ SIZE: %d DUDE SIZE: %d", wd1, wd2);

View file

@ -41,9 +41,10 @@ void fxFlameLick(DBloodActor* actor, sectortype*) // 0
if (!actor) return;
double top, bottom;
GetActorExtents(actor, &top, &bottom);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double nDist = (actor->spr.scale.X * tex->GetDisplayWidth()) * (1. / 4);
for (int i = 0; i < 3; i++)
{
double nDist = (actor->spr.scale.X * tileWidth(actor->spr.picnum)) * (1. / 4);
DAngle nAngle = RandomAngle();
DVector2 dv = nAngle.ToVector() * nDist;
DVector2 pos = actor->spr.pos.XY() + dv;
@ -223,7 +224,8 @@ void fxDynPuff(DBloodActor* actor, sectortype*) // 8
if (!actor) return;
if (actor->vel.Z)
{
double nDist = (actor->spr.scale.X * tileWidth(actor->spr.picnum)) * (1. / 2);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double nDist = (actor->spr.scale.X * tex->GetDisplayWidth()) * (1. / 2);
DVector3 pos = actor->spr.pos + (actor->spr.Angles.Yaw - DAngle90).ToVector() * nDist;
auto pFX = gFX.fxSpawnActor(FX_7, actor->sector(), pos);
if (pFX)
@ -340,9 +342,12 @@ void PlayerBubble(DBloodActor* actor, sectortype*) // 10
return;
double top, bottom;
GetActorExtents(actor, &top, &bottom);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double nDist = (actor->spr.scale.X * tex->GetDisplayWidth()) * (1. / 2);
for (int i = 0; i < (pPlayer->bubbleTime >> 6); i++)
{
double nDist = (actor->spr.scale.X * tileWidth(actor->spr.picnum)) * (1. / 2);
DVector2 pos = actor->spr.pos.XY() + actor->spr.Angles.Yaw.ToVector() * nDist;
double z = bottom - RandomD(bottom - top, 8);
auto pFX = gFX.fxSpawnActor((FX_ID)(FX_23 + Random(3)), actor->sector(), DVector3(pos, z));
@ -368,10 +373,11 @@ void EnemyBubble(DBloodActor* actor, sectortype*) // 11
if (!actor) return;
double top, bottom;
GetActorExtents(actor, &top, &bottom);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double nDist = (actor->spr.scale.X * tex->GetDisplayWidth()) * (1. / 2);
for (int i = 0; i < int(abs(actor->vel.Z) * 0.25); i++)
{
auto nAngle = RandomAngle();
double nDist = (actor->spr.scale.X * tileWidth(actor->spr.picnum)) * (1. / 2);
DVector2 pos = actor->spr.pos.XY() + nAngle.ToVector() * nDist;
double z = bottom - RandomD(bottom - top, 8);

View file

@ -1557,7 +1557,8 @@ void debrisConcuss(DBloodActor* owneractor, int listIndex, const DVector3& pos,
dmg = int(dmg * (0x4000 / (0x4000 + dv.LengthSquared())));
bool thing = (actor->spr.type >= kThingBase && actor->spr.type < kThingMax);
double size = (tileWidth(actor->spr.picnum) * actor->spr.scale.X * tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 2048;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double size = (tex->GetDisplayWidth() * actor->spr.scale.X * tex->GetDisplayHeight() * actor->spr.scale.Y) * 2048;
if (actor->xspr.physAttr & kPhysDebrisExplode)
{
if (actor->spriteMass.mass > 0)
@ -1588,9 +1589,11 @@ void debrisBubble(DBloodActor* actor)
{
double top, bottom;
GetActorExtents(actor, &top, &bottom);
for (unsigned int i = 0; i < 1 + Random(5); i++) {
double nDist = actor->spr.scale.X * tileWidth(actor->spr.picnum) * 0.5; // original code ended with * 8 which is 1/2 map unit.
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double nDist = (actor->spr.scale.X * tex->GetDisplayWidth()) * (1. / 2);
for (unsigned int i = 0; i < 1 + Random(5); i++)
{
DAngle nAngle = RandomAngle();
DVector3 pos;
pos.XY() = actor->spr.pos.XY() + nAngle.ToVector() * nDist;

View file

@ -39,6 +39,7 @@ This file contains parts of DukeGDX by Alexander Makarov-[M210] (m210-2007@mail.
#include "names_d.h"
#include "serializer.h"
#include "dukeactor.h"
#include "texturemanager.h"
BEGIN_DUKE_NS
@ -406,7 +407,9 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip
auto dasectp = actor->sector();
auto ppos = actor->spr.pos;
ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 0.5;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
ppos.Z -= tex->GetDisplayHeight() * actor->spr.scale.Y * 0.5;
if (bg)
{

View file

@ -326,7 +326,8 @@ int movesprite_ex_r(DDukeActor* actor, const DVector3& change, unsigned int clip
auto dasectp = actor->sector();
auto ppos = actor->spr.pos;
ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 0.5;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
ppos.Z -= tex->GetDisplayHeight() * actor->spr.scale.Y * 0.5;
if (bg)
{
@ -996,7 +997,8 @@ static void rrra_specialstats()
else if (enemysizecheat == 2)
{
act->spr.scale *= 0.5;
act->clipdist = act->spr.scale.X, tileHeight(act->spr.picnum) * 0.125;
auto tex = TexMan.GetGameTexture(act->spr.spritetexture());
act->clipdist = act->spr.scale.X, tex->GetDisplayHeight() * 0.125;
}
break;
}

View file

@ -1748,7 +1748,8 @@ int ParseState::parse(void)
insptr++;
auto scale = g_ac->spr.scale.Y;
if ((g_ac->isPlayer() && scale < 0.5626) || *insptr * REPEAT_SCALE < scale || (scale * (tileHeight(g_ac->spr.picnum) + 8)) < g_ac->floorz - g_ac->ceilingz)
auto tex = TexMan.GetGameTexture(g_ac->spr.spritetexture());
if ((g_ac->isPlayer() && scale < 0.5626) || *insptr * REPEAT_SCALE < scale || (scale * (tex->GetDisplayHeight() + 8)) < g_ac->floorz - g_ac->ceilingz)
{
siz = ((*insptr) * REPEAT_SCALE - g_ac->spr.scale.Y);
g_ac->spr.scale.Y = (clamp(g_ac->spr.scale.Y + Sgn(siz) * REPEAT_SCALE, 0., 4.));

View file

@ -331,7 +331,8 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) + 5;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) + 5;
switch (aimed->spr.picnum)
{
case DTILE_GREENSLIME:
@ -584,7 +585,8 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) - 12;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) - 12;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist;
@ -671,7 +673,8 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
aimed = aim(actor, AUTO_AIM_ANGLE);
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) + 8;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) + 8;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist;
if (!actorflag(aimed, SFLAG2_SPECIALAUTOAIM))
@ -896,7 +899,8 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang)
auto aimed = aim(actor, AUTO_AIM_ANGLE);
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) + 5;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) + 5;
switch (aimed->spr.picnum)
{
case DTILE_GREENSLIME:
@ -999,7 +1003,8 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle
auto aimed = isNamWW2GI() ? nullptr : aim(actor, AUTO_AIM_ANGLE);
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5);
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5);
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal - 4) * 48) / dist;
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
@ -1051,7 +1056,8 @@ void shoot_d(DDukeActor* actor, int atwith, PClass *cls)
else
{
p = -1;
spos = actor->spr.pos.plusZ(-(actor->spr.scale.Y * tileHeight(actor->spr.picnum) * 0.5) + 4);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
spos = actor->spr.pos.plusZ(-(actor->spr.scale.Y * tex->GetDisplayHeight() * 0.5) + 4);
if (actor->spr.picnum != DTILE_ROTATEGUN)
{

View file

@ -213,7 +213,8 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int
auto aimed = aim(actor, AUTO_AIM_ANGLE);
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) + 5;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) + 5;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * 16) / dist;
ang = (aimed->spr.pos - pos).Angle();
@ -495,7 +496,8 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) - 12;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) - 12;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist;
@ -581,7 +583,8 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
else
act90 = aimed;
}
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) + 8;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) + 8;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist;
if (!actorflag(aimed, SFLAG2_SPECIALAUTOAIM))
@ -703,7 +706,8 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at
if (aimed)
{
double dal = ((aimed->spr.scale.X * tileHeight(aimed->spr.picnum)) * 0.5) -12;
auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture());
double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5) - 12;
double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length();
zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist;
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
@ -792,7 +796,8 @@ void shoot_r(DDukeActor* actor, int atwith, PClass* cls)
else
{
p = -1;
spos = actor->spr.pos.plusZ(-(actor->spr.scale.Y * tileHeight(actor->spr.picnum) * 0.5) - 3);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
spos = actor->spr.pos.plusZ(-(actor->spr.scale.Y * tex->GetDisplayHeight() * 0.5) - 3);
if (badguy(actor))
{

View file

@ -4,6 +4,7 @@
#include "packet.h"
#include "d_net.h"
#include "gameinput.h"
#include "texturemanager.h"
BEGIN_DUKE_NS
@ -125,7 +126,8 @@ public:
void setClipDistFromTile()
{
clipdist = spr.scale.X * tileWidth(spr.picnum) * 0.125;
auto tex = TexMan.GetGameTexture(spr.spritetexture());
clipdist = spr.scale.X * tex->GetDisplayWidth() * 0.125;
}
};

View file

@ -628,7 +628,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, checkhitsprite, DukeActor_checkhitspri
int duke_spw(DDukeActor* act)
{
return tileWidth(act->spr.picnum);
auto tex = TexMan.GetGameTexture(act->spr.spritetexture());
return (int)tex->GetDisplayWidth();
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spritewidth, duke_spw)

View file

@ -183,7 +183,8 @@ void IgniteSprite(DExhumedActor* pActor)
{
pAnimActor->pTarget = pActor;
ChangeActorStat(pAnimActor, kStatIgnited);
pAnimActor->spr.scale.Y = (max(1, (tileHeight(pAnimActor->spr.picnum) * 32) / nFlameHeight) * REPEAT_SCALE);
auto tex = TexMan.GetGameTexture(pAnimActor->spr.spritetexture());
pAnimActor->spr.scale.Y = (max(1.f, (tex->GetDisplayHeight() * 32) / nFlameHeight) * REPEAT_SCALE);
}
}

View file

@ -402,7 +402,8 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli
double GetActorHeight(DExhumedActor* actor)
{
return tileHeight(actor->spr.picnum) * actor->spr.scale.Y;
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
return tex->GetDisplayHeight() * actor->spr.scale.Y;
}
DExhumedActor* insertActor(sectortype* s, int st)

View file

@ -711,7 +711,8 @@ int DoActorJump(DSWActor* actor)
actor->spr.pos.Z += actor->user.jump_speed * ACTORMOVETICS * JUMP_FACTOR;
// if player gets to close the ceiling while jumping
double minh = actor->user.hiz + tileHeight(actor->spr.picnum);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double minh = actor->user.hiz + tex->GetDisplayHeight();
if (actor->spr.pos.Z < minh)
{
// put player at the ceiling
@ -905,7 +906,8 @@ int DoJump(DSWActor* actor)
actor->spr.pos.Z += actor->user.jump_speed * ACTORMOVETICS * JUMP_FACTOR;
// if player gets to close the ceiling while jumping
double minh = actor->user.hiz + tileHeight(actor->spr.picnum);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
double minh = actor->user.hiz + tex->GetDisplayHeight();
if (actor->spr.pos.Z < minh)
{
// put player at the ceiling

View file

@ -302,7 +302,8 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
if (tsp->scale.Y > 0.25)
{
double sizey = tileHeight(tsp->picnum) * tsp->scale.Y;
auto tex = TexMan.GetGameTexture(tsp->spritetexture());
double sizey = tex->GetDisplayHeight() * tsp->scale.Y;
scale.Y = (tsp->scale.Y * 0.25) - (sizey / 2048.);
scale.X = tsp->scale.X;
}

View file

@ -2045,7 +2045,8 @@ inline DVector3 ActorVectOfMiddle(DSWActor* actor)
inline double ActorSizeZ(DSWActor* actor)
{
return (tileHeight(actor->spr.picnum) * actor->spr.scale.Y);
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
return (tex->GetDisplayHeight() * actor->spr.scale.Y);
}
inline double ActorUpperZ(DSWActor* actor)