mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Patch from Striker to allow selective tile redefinition in .def files based on the crc of the original tile
This only works for "tilefromtexture" for now. git-svn-id: https://svn.eduke32.com/eduke32@7370 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f31f31a17e
commit
e84d62416d
3 changed files with 38 additions and 0 deletions
|
@ -1068,6 +1068,7 @@ void artClearMapArt(void);
|
|||
void artSetupMapArt(const char *filename);
|
||||
bool tileLoad(int16_t tilenume);
|
||||
void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer);
|
||||
int32_t tileCRC(int16_t tileNum);
|
||||
void artConvertRGB(palette_t *pic, uint8_t const *buf, int32_t bufsizx, int32_t sizx, int32_t sizy);
|
||||
|
||||
int32_t qloadkvx(int32_t voxindex, const char *filename);
|
||||
|
|
|
@ -121,6 +121,7 @@ enum scripttoken_t
|
|||
T_DST_COLOR, T_ONE_MINUS_DST_COLOR,
|
||||
T_SHADERED, T_SHADEGREEN, T_SHADEBLUE,
|
||||
T_SHADEFACTOR,
|
||||
T_IFCRC,
|
||||
};
|
||||
|
||||
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
|
||||
|
@ -792,6 +793,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
int32_t havexoffset = 0, haveyoffset = 0;
|
||||
int32_t xoffset = 0, yoffset = 0;
|
||||
int32_t istexture = 0;
|
||||
int32_t tilecrc = 0, origcrc = 0;
|
||||
|
||||
static const tokenlist tilefromtexturetokens[] =
|
||||
{
|
||||
|
@ -805,6 +807,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{ "texhitscan", T_TEXHITSCAN },
|
||||
{ "nofullbright", T_NOFULLBRIGHT },
|
||||
{ "texture", T_TEXTURE },
|
||||
{ "ifcrc", T_IFCRC },
|
||||
};
|
||||
|
||||
if (scriptfile_getsymbol(script,&tile)) break;
|
||||
|
@ -831,6 +834,9 @@ static int32_t defsparser(scriptfile *script)
|
|||
scriptfile_getsymbol(script,&yoffset);
|
||||
yoffset = clamp(yoffset, -128, 127);
|
||||
break;
|
||||
case T_IFCRC:
|
||||
scriptfile_getsymbol(script, &tilecrc);
|
||||
break;
|
||||
case T_TEXHITSCAN:
|
||||
flags |= PICANM_TEXHITSCAN_BIT;
|
||||
break;
|
||||
|
@ -852,6 +858,16 @@ static int32_t defsparser(scriptfile *script)
|
|||
break;
|
||||
}
|
||||
|
||||
if (tilecrc)
|
||||
{
|
||||
origcrc = tileCRC(tile);
|
||||
if (origcrc != tilecrc)
|
||||
{
|
||||
//initprintf("CRC of tile %d doesn't match! CRC: %d, Expected: %d\n", tile, origcrc, tilecrc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fn)
|
||||
{
|
||||
// tilefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "engine_priv.h"
|
||||
#include "cache1d.h"
|
||||
#include "lz4.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
@ -740,6 +741,26 @@ static void tilePostLoad(int16_t tilenume)
|
|||
#endif
|
||||
}
|
||||
|
||||
int32_t tileCRC(int16_t tileNum)
|
||||
{
|
||||
char *data;
|
||||
|
||||
if ((unsigned)tileNum >= (unsigned)MAXTILES)
|
||||
return 0;
|
||||
int const dasiz = tilesiz[tileNum].x * tilesiz[tileNum].y;
|
||||
if (dasiz <= 0)
|
||||
return 0;
|
||||
|
||||
data = (char *)Bmalloc(dasiz);
|
||||
tileLoadData(tileNum, dasiz, data);
|
||||
|
||||
int32_t crc = Bcrc32((unsigned char *)data, (unsigned int)dasiz, 0);
|
||||
|
||||
Bfree(data);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
// Assumes pic has been initialized to zero.
|
||||
void artConvertRGB(palette_t * const pic, uint8_t const * const buf, int32_t const bufsizx, int32_t const sizx, int32_t const sizy)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue