mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-21 11:11:16 +00:00
- moved the other tile info tables of Blood to the texExtInfo array as well.
The two fields are easily reusable for the other games so it's a welcome simplification.
This commit is contained in:
parent
c34756e5f2
commit
e23a5095cb
12 changed files with 39 additions and 92 deletions
|
@ -228,8 +228,8 @@ void processTileImport(FScanner& sc, const char* cmd, FScriptPosition& pos, Tile
|
|||
if (imp.fn.IsNotEmpty() && tileImportFromTexture(sc, imp.fn, imp.tile, imp.alphacut, imp.istexture) < 0) return;
|
||||
|
||||
tbuild->tile[imp.tile].extinfo.picanm.sf |= imp.flags;
|
||||
|
||||
gi->SetTileProps(imp.tile, imp.surface, imp.shade);
|
||||
tbuild->tile[imp.tile].extinfo.surftype = imp.surface;
|
||||
tbuild->tile[imp.tile].extinfo.tileshade = imp.shade;
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -110,7 +110,6 @@ struct GameInterface
|
|||
virtual void NewGame(MapRecord* map, int skill, bool special = false) {}
|
||||
virtual void LevelCompleted(MapRecord* map, int skill) {}
|
||||
virtual bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) { return false; }
|
||||
virtual void SetTileProps(int tile, int surf, int shade) {}
|
||||
virtual DAngle playerPitchMin() { return DAngle::fromDeg(57.375); }
|
||||
virtual DAngle playerPitchMax() { return DAngle::fromDeg(-57.375); }
|
||||
virtual void WarpToCoords(double x, double y, double z, DAngle a) {}
|
||||
|
|
|
@ -58,8 +58,8 @@ struct TileOffs
|
|||
struct TexExtInfo
|
||||
{
|
||||
// TexAnim *texanim // todo: extended texture animation like ZDoom's ANIMDEFS.
|
||||
uint8_t terrain; // Contents depend on the game, e.g. this holds Blood's surfType.
|
||||
uint8_t shadeinfo; // Blood's shade.dat
|
||||
uint8_t surftype; // Contents depend on the game, e.g. this holds Blood's surfType. Other games have hard coded handling for similar effects.
|
||||
uint8_t tileshade; // Blood's shade.dat
|
||||
int16_t tiletovox; // engine-side voxel index
|
||||
picanm_t picanm; // tile-based animation data.
|
||||
uint32_t flags; // contents are game dependent.
|
||||
|
|
|
@ -3943,7 +3943,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode)
|
|||
actDamageSprite(missileOwner, actorHit, kDamageBullet, nDamage);
|
||||
}
|
||||
|
||||
if (tprops[actorHit->spr.spritetexture()].surfType == kSurfFlesh)
|
||||
if (GetExtInfo(actorHit->spr.spritetexture()).surftype == kSurfFlesh)
|
||||
{
|
||||
missileActor->spr.picnum = 2123;
|
||||
missileActor->SetTarget(actorHit);
|
||||
|
@ -4109,7 +4109,7 @@ static void actTouchFloor(DBloodActor* actor, sectortype* pSector)
|
|||
|
||||
actDamageSprite(actor, actor, nDamageType, Scale(4, nDamage, 120) << 4);
|
||||
}
|
||||
if (tprops[pSector->floortexture()].surfType == kSurfLava)
|
||||
if (GetExtInfo(pSector->floortexture()).surftype == kSurfLava)
|
||||
{
|
||||
actDamageSprite(actor, actor, kDamageBurn, 16);
|
||||
sfxPlay3DSound(actor, 352, 5, 2);
|
||||
|
@ -6631,7 +6631,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3
|
|||
if (pSector->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
nSurf = kSurfNone;
|
||||
else
|
||||
nSurf = tprops[pSector->ceilingtexture()].surfType;
|
||||
nSurf = GetExtInfo(pSector->ceilingtexture()).surftype;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
|
@ -6639,17 +6639,17 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3
|
|||
if (pSector->floorstat & CSTAT_SECTOR_SKY)
|
||||
nSurf = kSurfNone;
|
||||
else
|
||||
nSurf = tprops[pSector->floortexture()].surfType;
|
||||
nSurf = GetExtInfo(pSector->floortexture()).surftype;
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
auto pWall = gHitInfo.hitWall;
|
||||
nSurf = tprops[pWall->walltexture()].surfType;
|
||||
nSurf = GetExtInfo(pWall->walltexture()).surftype;
|
||||
if (actCanSplatWall(pWall))
|
||||
{
|
||||
auto ppos = gHitInfo.hitpos - dv;
|
||||
int nnSurf = tprops[pWall->walltexture()].surfType;
|
||||
int nnSurf = GetExtInfo(pWall->walltexture()).surftype;
|
||||
assert(nnSurf < kSurfMax);
|
||||
if (pVectorData->surfHit[nnSurf].fx1 >= 0)
|
||||
{
|
||||
|
@ -6667,7 +6667,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3
|
|||
case 4:
|
||||
{
|
||||
auto pWall = gHitInfo.hitWall;
|
||||
nSurf = tprops[pWall->overtexture()].surfType;
|
||||
nSurf = GetExtInfo(pWall->overtexture()).surftype;
|
||||
if (pWall->hasX())
|
||||
{
|
||||
if (pWall->xw().triggerVector)
|
||||
|
@ -6678,7 +6678,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3
|
|||
case 3:
|
||||
{
|
||||
auto actor = gHitInfo.actor();
|
||||
nSurf = tprops[actor->spr.spritetexture()].surfType;
|
||||
nSurf = GetExtInfo(actor->spr.spritetexture()).surftype;
|
||||
pos -= 7 * dv;
|
||||
int shift = 4;
|
||||
if (vectorType == kVectorTine && !actor->IsPlayerActor()) shift = 3;
|
||||
|
@ -6742,7 +6742,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3
|
|||
if (actCanSplatWall(pWall))
|
||||
{
|
||||
auto ppos = gHitInfo.hitpos - dv;
|
||||
int nnSurf = tprops[pWall->walltexture()].surfType;
|
||||
int nnSurf = GetExtInfo(pWall->walltexture()).surftype;
|
||||
const VECTORDATA* pVectorData1 = &gVectorData[19];
|
||||
FX_ID t2 = pVectorData1->surfHit[nnSurf].fx2;
|
||||
FX_ID t3 = pVectorData1->surfHit[nnSurf].fx3;
|
||||
|
|
|
@ -1576,7 +1576,7 @@ static void scaleDamage(DBloodActor* actor)
|
|||
}
|
||||
|
||||
// take surface type into account
|
||||
int surfType = tprops[actor->spr.spritetexture()].surfType;
|
||||
int surfType = GetExtInfo(actor->spr.spritetexture()).surftype;
|
||||
switch (surfType)
|
||||
{
|
||||
case 1: // stone
|
||||
|
|
|
@ -663,13 +663,13 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
|
||||
if ((pSector->ceilingstat & CSTAT_SECTOR_SKY) && (pSector->floorstat & CSTAT_SECTOR_NO_CEILINGSHADE) == 0)
|
||||
{
|
||||
nShade += tprops[pSector->ceilingtexture()].tileShade + pSector->ceilingshade;
|
||||
nShade += GetExtInfo(pSector->ceilingtexture()).tileshade + pSector->ceilingshade;
|
||||
}
|
||||
else
|
||||
{
|
||||
nShade += tprops[pSector->floortexture()].tileShade + pSector->floorshade;
|
||||
nShade += GetExtInfo(pSector->floortexture()).tileshade + pSector->floorshade;
|
||||
}
|
||||
nShade += tprops[pTSprite->spritetexture()].tileShade;
|
||||
nShade += GetExtInfo(pTSprite->spritetexture()).tileshade;
|
||||
pTSprite->shade = ClipRange(nShade, -128, 127);
|
||||
if ((pTSprite->flags & kHitagRespawn) && pTSprite->ownerActor->spr.intowner == 3 && owneractor->hasX()) // Where does this 3 come from? Nothing sets it.
|
||||
{
|
||||
|
|
|
@ -75,7 +75,6 @@ IMPLEMENT_POINTERS_END
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void MarkSprInSect();
|
||||
void tileInitProps();
|
||||
|
||||
size_t DBloodActor::PropagateMark()
|
||||
{
|
||||
|
@ -588,7 +587,6 @@ void GameInterface::loadPalette(void)
|
|||
void GameInterface::app_init()
|
||||
{
|
||||
mirrortile = tileGetTextureID(504);
|
||||
tileInitProps();
|
||||
|
||||
GC::AddMarkerFunc(markgcroots);
|
||||
|
||||
|
|
|
@ -132,7 +132,6 @@ struct GameInterface : public ::GameInterface
|
|||
void NextLevel(MapRecord* map, int skill) override;
|
||||
void LevelCompleted(MapRecord* map, int skill) override;
|
||||
bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override;
|
||||
void SetTileProps(int til, int surf, int shade) override;
|
||||
DAngle playerPitchMin() override { return DAngle::fromDeg(54.575); }
|
||||
DAngle playerPitchMax() override { return DAngle::fromDeg(-43.15); }
|
||||
void WarpToCoords(double x, double y, double z, DAngle a) override;
|
||||
|
|
|
@ -100,33 +100,4 @@ void tilePrecacheTile(int nTile, int nType, int palette);
|
|||
|
||||
int tileGetSurfType(CollisionBase& hit);
|
||||
|
||||
struct TextureAttr
|
||||
{
|
||||
uint8_t surfType = kSurfNone;
|
||||
int8_t tileShade = 0;
|
||||
};
|
||||
|
||||
class FTextureAttrArray
|
||||
{
|
||||
TextureAttr defaultattr;
|
||||
public:
|
||||
TArray<TextureAttr> Types;
|
||||
|
||||
TextureAttr operator [](FTextureID tex) const
|
||||
{
|
||||
if ((unsigned)tex.GetIndex() >= Types.Size()) return defaultattr;
|
||||
return Types[tex.GetIndex()];
|
||||
}
|
||||
void Set(int index, const TextureAttr& value)
|
||||
{
|
||||
if ((unsigned)index >= Types.Size())
|
||||
{
|
||||
Types.Resize(index + 1);
|
||||
}
|
||||
Types[index] = value;
|
||||
}
|
||||
};
|
||||
|
||||
inline FTextureAttrArray tprops;
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -1446,7 +1446,7 @@ int getSpriteMassBySize(DBloodActor* actor)
|
|||
int yscale = int(actor->spr.scale.Y * 64);
|
||||
|
||||
// take surface type into account
|
||||
switch (tprops[actor->spr.spritetexture()].surfType)
|
||||
switch (GetExtInfo(actor->spr.spritetexture()).surftype)
|
||||
{
|
||||
case 1: massDiv = 16; break; // stone
|
||||
case 2: massDiv = 18; break; // metal
|
||||
|
@ -3956,7 +3956,7 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
|
|||
walltype* pObj = eob.wall();
|
||||
switch (cond)
|
||||
{
|
||||
case 24: return condCmp(tprops[pObj->walltexture()].surfType, arg1, arg2, cmpOp);
|
||||
case 24: return condCmp(GetExtInfo(pObj->walltexture()).surftype, arg1, arg2, cmpOp);
|
||||
case 25: return condCmp(legacyTileNum(pObj->walltexture()), arg1, arg2, cmpOp);
|
||||
case 26: return condCmp(pObj->pal, arg1, arg2, cmpOp);
|
||||
case 27: return condCmp(pObj->shade, arg1, arg2, cmpOp);
|
||||
|
@ -3974,7 +3974,7 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
|
|||
if (!actor) break;
|
||||
switch (cond)
|
||||
{
|
||||
case 24: return condCmp(tprops[actor->spr.spritetexture()].surfType, arg1, arg2, cmpOp);
|
||||
case 24: return condCmp(GetExtInfo(actor->spr.spritetexture()).surftype, arg1, arg2, cmpOp);
|
||||
case 25: return condCmp(actor->spr.picnum, arg1, arg2, cmpOp);
|
||||
case 26: return condCmp(actor->spr.pal, arg1, arg2, cmpOp);
|
||||
case 27: return condCmp(actor->spr.shade, arg1, arg2, cmpOp);
|
||||
|
@ -3994,9 +3994,9 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
|
|||
case 24:
|
||||
switch (arg3)
|
||||
{
|
||||
default: return (condCmp(tprops[pObj->floortexture()].surfType, arg1, arg2, cmpOp) || condCmp(tprops[pObj->ceilingtexture()].surfType, arg1, arg2, cmpOp));
|
||||
case 1: return condCmp(tprops[pObj->floortexture()].surfType, arg1, arg2, cmpOp);
|
||||
case 2: return condCmp(tprops[pObj->ceilingtexture()].surfType, arg1, arg2, cmpOp);
|
||||
default: return (condCmp(GetExtInfo(pObj->floortexture()).surftype, arg1, arg2, cmpOp) || condCmp(GetExtInfo(pObj->ceilingtexture()).surftype, arg1, arg2, cmpOp));
|
||||
case 1: return condCmp(GetExtInfo(pObj->floortexture()).surftype, arg1, arg2, cmpOp);
|
||||
case 2: return condCmp(GetExtInfo(pObj->ceilingtexture()).surftype, arg1, arg2, cmpOp);
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
|
|
|
@ -360,7 +360,7 @@ void SEQINST::Update()
|
|||
if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && actor->vel.Z == 0 && actor->vel.X != 0) {
|
||||
|
||||
if (actor->sector()->upperLink) break; // don't play surface sound for stacked sectors
|
||||
int surf = tprops[actor->sector()->floortexture()].surfType;
|
||||
int surf = GetExtInfo(actor->sector()->floortexture()).surftype;
|
||||
if (!surf) break;
|
||||
static int surfSfxMove[15][4] = {
|
||||
/* {snd1, snd2, gameVolume, myVolume} */
|
||||
|
|
|
@ -36,9 +36,6 @@ BEGIN_BLD_NS
|
|||
|
||||
int nTileFiles = 0;
|
||||
|
||||
// these arrays get partially filled by .def, so they need to remain global.
|
||||
static uint8_t surfType[kMaxTiles];
|
||||
static int8_t tileShade[kMaxTiles];
|
||||
|
||||
#define x(a, b) registerName(#a, b);
|
||||
static void SetTileNames(TilesetBuildInfo& info)
|
||||
|
@ -70,8 +67,13 @@ void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
|
|||
auto hFile = fileSystem.OpenFileReader("SURFACE.DAT");
|
||||
if (hFile.isOpen())
|
||||
{
|
||||
hFile.Read(surfType, sizeof(surfType));
|
||||
int count = (int)hFile.GetLength();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
info.tile[i].extinfo.surftype = hFile.ReadInt8();
|
||||
}
|
||||
}
|
||||
|
||||
hFile = fileSystem.OpenFileReader("VOXEL.DAT");
|
||||
if (hFile.isOpen())
|
||||
{
|
||||
|
@ -88,10 +90,15 @@ void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
hFile = fileSystem.OpenFileReader("SHADE.DAT");
|
||||
if (hFile.isOpen())
|
||||
{
|
||||
hFile.Read(tileShade, sizeof(tileShade));
|
||||
int count = (int)hFile.GetLength();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
info.tile[i].extinfo.tileshade = hFile.ReadInt8();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,18 +111,6 @@ void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info)
|
|||
|
||||
}
|
||||
|
||||
void tileInitProps()
|
||||
{
|
||||
for (int i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
auto tex = tileGetTexture(i);
|
||||
if (tex)
|
||||
{
|
||||
TextureAttr a = { surfType[i], tileShade[i] };
|
||||
tprops.Set(tex->GetID().GetIndex(), a);
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -129,27 +124,12 @@ int tileGetSurfType(CollisionBase& hit)
|
|||
default:
|
||||
return 0;
|
||||
case kHitSector:
|
||||
return tprops[hit.hitSector->floortexture()].surfType;
|
||||
return GetExtInfo(hit.hitSector->floortexture()).surftype;
|
||||
case kHitWall:
|
||||
return tprops[hit.hitWall->walltexture()].surfType;
|
||||
return GetExtInfo(hit.hitWall->walltexture()).surftype;
|
||||
case kHitSprite:
|
||||
return tprops[hit.hitActor->spr.spritetexture()].surfType;
|
||||
return GetExtInfo(hit.hitActor->spr.spritetexture()).surftype;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::SetTileProps(int tile, int surf, int shade)
|
||||
{
|
||||
if (surf != INT_MAX) surfType[tile] = surf;
|
||||
if (shade != INT_MAX) tileShade[tile] = shade;
|
||||
|
||||
mirrortile = tileGetTextureID(504);
|
||||
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
Loading…
Reference in a new issue