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"
2022-12-07 16:10:27 +00:00
# include "hw_voxels.h"
# include "tilesetbuilder.h"
2019-09-19 22:42:45 +00:00
2019-09-22 06:39:22 +00:00
BEGIN_BLD_NS
2019-09-19 22:42:45 +00:00
int nTileFiles = 0 ;
2022-11-25 15:52:08 +00:00
# define x(a, b) registerName(#a, b);
2022-12-07 16:10:27 +00:00
static void SetTileNames ( TilesetBuildInfo & info )
2022-11-25 15:52:08 +00:00
{
2022-12-07 16:10:27 +00:00
auto registerName = [ & ] ( const char * name , int index )
2022-11-25 15:52:08 +00:00
{
2022-12-07 16:10:27 +00:00
info . addName ( name , index ) ;
2022-11-25 15:52:08 +00:00
} ;
# include "namelist.h"
2022-12-07 16:10:27 +00:00
// Oh Joy! Plasma Pak changes the tile number of the title screen, but we preferably want mods that use the original one to display it, e.g. Cryptic Passage
2022-11-25 15:52:08 +00:00
// So let's make this remapping depend on the CRC.
2022-12-07 16:10:27 +00:00
const int OTITLE = 2046 , PTITLE = 2518 ;
auto & orgtitle = info . tile [ OTITLE ] ;
auto & pptile = info . tile [ PTITLE ] ;
if ( tileGetCRC32 ( pptile . tileimage ) = = 1170870757 & & ( tileGetCRC32 ( orgtitle . tileimage ) ! = 290208654 | | pptile . tileimage - > GetWidth ( ) = = 0 ) ) registerName ( " titlescreen " , 2046 ) ;
2022-11-25 15:52:08 +00:00
else registerName ( " titlescreen " , 2518 ) ;
}
# undef x
2021-12-29 21:56:21 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2022-12-07 16:10:27 +00:00
void GameInterface : : LoadTextureInfo ( TilesetBuildInfo & info )
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
{
2022-12-08 18:15:55 +00:00
int count = ( int ) hFile . GetLength ( ) ;
for ( int i = 0 ; i < count ; i + + )
{
info . tile [ i ] . extinfo . surftype = hFile . ReadInt8 ( ) ;
}
2019-09-19 22:42:45 +00:00
}
2022-12-08 18:15:55 +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
{
2022-12-08 17:26:09 +00:00
int count = ( int ) hFile . GetLength ( ) / 2 ;
for ( int i = 0 ; i < count ; i + + )
{
int voxindex = hFile . ReadInt16 ( ) ;
// only insert into the table if they are flagged to be processed in viewProcessSprites, i.e. the type value is 6 or 7,
if ( voxindex > - 1 & & ( info . tile [ i ] . extinfo . picanm . extra & 7 ) > = 6 )
{
info . tile [ i ] . extinfo . tiletovox = voxindex ;
}
}
2019-09-19 22:42:45 +00:00
}
2022-12-08 18:15:55 +00:00
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
{
2022-12-08 18:15:55 +00:00
int count = ( int ) hFile . GetLength ( ) ;
for ( int i = 0 ; i < count ; i + + )
{
info . tile [ i ] . extinfo . tileshade = hFile . ReadInt8 ( ) ;
}
2019-09-19 22:42:45 +00:00
}
}
2022-12-07 16:10:27 +00:00
void GameInterface : : SetupSpecialTextures ( TilesetBuildInfo & info )
2022-12-05 16:14:01 +00:00
{
2022-12-07 16:10:27 +00:00
SetTileNames ( info ) ;
2022-12-05 16:14:01 +00:00
// set up all special tiles here, before we fully hook up with the texture manager.
2022-12-07 16:10:27 +00:00
info . Delete ( 504 ) ;
info . MakeWritable ( 2342 ) ;
}
2021-12-29 21:56:21 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
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 :
2022-12-09 09:48:47 +00:00
return GetExtInfo ( hit . hitSector - > floortexture ) . surftype ;
2021-08-27 19:49:18 +00:00
case kHitWall :
2022-12-10 18:03:17 +00:00
return GetExtInfo ( hit . hitWall - > walltexture ) . surftype ;
2021-08-27 19:49:18 +00:00
case kHitSprite :
2022-12-08 18:15:55 +00:00
return GetExtInfo ( hit . hitActor - > spr . spritetexture ( ) ) . surftype ;
2019-09-19 22:42:45 +00:00
}
}
2019-09-22 06:39:22 +00:00
END_BLD_NS