2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "blood.h"
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
int nTileFiles = 0;
|
|
|
|
|
|
|
|
int tileStart[256];
|
|
|
|
int tileEnd[256];
|
|
|
|
int hTileFile[256];
|
|
|
|
|
2021-11-16 17:36:34 +00:00
|
|
|
uint8_t surfType[kMaxTiles];
|
2021-04-17 08:14:03 +00:00
|
|
|
int8_t tileShade[kMaxTiles];
|
2019-09-19 22:42:45 +00:00
|
|
|
short voxelIndex[kMaxTiles];
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-07-13 10:11:17 +00:00
|
|
|
void GameInterface::LoadGameTextures()
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-04-11 21:54:33 +00:00
|
|
|
auto hFile = fileSystem.OpenFileReader("SURFACE.DAT");
|
2019-10-20 22:13:17 +00:00
|
|
|
if (hFile.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-20 22:13:17 +00:00
|
|
|
hFile.Read(surfType, sizeof(surfType));
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-04-11 21:54:33 +00:00
|
|
|
hFile = fileSystem.OpenFileReader("VOXEL.DAT");
|
2019-10-20 22:13:17 +00:00
|
|
|
if (hFile.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-20 22:13:17 +00:00
|
|
|
hFile.Read(voxelIndex, sizeof(voxelIndex));
|
2021-12-14 11:08:48 +00:00
|
|
|
#if WORDS_BIGENDIAN
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < kMaxTiles; i++)
|
2020-08-03 17:09:57 +00:00
|
|
|
voxelIndex[i] = LittleShort(voxelIndex[i]);
|
2019-09-19 22:42:45 +00:00
|
|
|
#endif
|
|
|
|
}
|
2020-04-11 21:54:33 +00:00
|
|
|
hFile = fileSystem.OpenFileReader("SHADE.DAT");
|
2019-10-20 22:13:17 +00:00
|
|
|
if (hFile.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-20 22:13:17 +00:00
|
|
|
hFile.Read(tileShade, sizeof(tileShade));
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < kMaxTiles; i++)
|
|
|
|
{
|
|
|
|
if (voxelIndex[i] >= 0 && voxelIndex[i] < kMaxVoxels)
|
2021-04-11 16:37:11 +00:00
|
|
|
voxreserve.Set(voxelIndex[i]);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-08-27 19:49:18 +00:00
|
|
|
int tileGetSurfType(int hit)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-08-27 19:49:18 +00:00
|
|
|
return surfType[hit];
|
|
|
|
}
|
|
|
|
|
2021-12-05 19:55:19 +00:00
|
|
|
int tileGetSurfType(CollisionBase& hit)
|
2021-08-27 19:49:18 +00:00
|
|
|
{
|
|
|
|
switch (hit.type)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-08-27 19:49:18 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
case kHitSector:
|
2021-11-26 13:03:21 +00:00
|
|
|
return surfType[hit.hitSector->floorpicnum];
|
2021-08-27 19:49:18 +00:00
|
|
|
case kHitWall:
|
2021-11-26 13:03:21 +00:00
|
|
|
return surfType[hit.hitWall->picnum];
|
2021-08-27 19:49:18 +00:00
|
|
|
case kHitSprite:
|
2021-12-21 22:18:23 +00:00
|
|
|
return surfType[hit.hitActor->spr.picnum];
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-09-14 23:27:24 +00:00
|
|
|
void GameInterface::SetTileProps(int tile, int surf, int vox, int shade)
|
|
|
|
{
|
|
|
|
if (surf != INT_MAX) surfType[tile] = surf;
|
|
|
|
if (vox != INT_MAX) voxelIndex[tile] = vox;
|
|
|
|
if (shade != INT_MAX) tileShade[tile] = shade;
|
|
|
|
}
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|