Commit 8ed89a1e authored by Jordon Moss's avatar Jordon Moss Committed by Richard Gobeille
Browse files

When loading new art files, blanks no longer erase existing tiles, allowing...

When loading new art files, blanks no longer erase existing tiles, allowing "inserting" new tiles, or essentially stacking them.
parent 5c200636
......@@ -1203,6 +1203,7 @@ typedef struct {
typedef struct artheader_t {
int32_t tilestart, tileend, numtiles;
uint8_t* tileread;
} artheader_t;
#define ARTv1_UNITOFFSET ((signed)(4*sizeof(int32_t) + 2*sizeof(int16_t) + sizeof(picanm_t)))
......@@ -1229,8 +1230,8 @@ int32_t artReadHeader(buildvfs_kfd fil, char const *fn, artheader_t *local);
int32_t artReadHeaderFromBuffer(uint8_t const *buf, artheader_t *local);
int32_t artCheckUnitFileHeader(uint8_t const *buf, int32_t length);
void tileConvertAnimFormat(int32_t picnum, uint32_t const picanmdisk);
void artReadManifest(buildvfs_kfd fil, artheader_t const *local);
void artPreloadFile(buildvfs_kfd fil, artheader_t const *local);
void artReadManifest(buildvfs_kfd fil, artheader_t * const local);
void artPreloadFile(buildvfs_kfd fil, artheader_t * const local);
int32_t artLoadFiles(const char *filename, int32_t askedsize);
void artClearMapArt(void);
void artSetupMapArt(const char *filename);
......
......@@ -394,20 +394,33 @@ void tileConvertAnimFormat(int32_t const picnum, uint32_t const picanmdisk)
thispicanm->sf = ((picanmdisk>>24)&15) | (picanmdisk&192);
}
void artReadManifest(buildvfs_kfd const fil, artheader_t const * const local)
void artReadManifest(buildvfs_kfd const fil, artheader_t * const local)
{
int16_t *tilesizx = (int16_t *) Xmalloc(local->numtiles * sizeof(int16_t));
int16_t *tilesizy = (int16_t *) Xmalloc(local->numtiles * sizeof(int16_t));
kread(fil, tilesizx, local->numtiles*sizeof(int16_t));
kread(fil, tilesizy, local->numtiles*sizeof(int16_t));
local->tileread = (uint8_t*)Xcalloc(1, (local->numtiles + 7) >> 3);
for (bssize_t i=local->tilestart; i<=local->tileend; i++)
{
tilesiz[i].x = B_LITTLE16(tilesizx[i-local->tilestart]);
tilesiz[i].y = B_LITTLE16(tilesizy[i-local->tilestart]);
int32_t const localIndex = i - local->tilestart;
int16_t const tilex = B_LITTLE16(tilesizx[localIndex]);
int16_t const tiley = B_LITTLE16(tilesizy[localIndex]);
int32_t const dasiz = tilex * tiley;
uint32_t picanmdisk;
kread(fil, &picanmdisk, sizeof(uint32_t));
if (dasiz == 0)
continue;
tilesiz[i].x = tilex;
tilesiz[i].y = tiley;
bitmap_set(local->tileread, localIndex);
picanmdisk = B_LITTLE32(picanmdisk);
tileConvertAnimFormat(i, picanmdisk);
}
......@@ -416,15 +429,18 @@ void artReadManifest(buildvfs_kfd const fil, artheader_t const * const local)
DO_FREE_AND_NULL(tilesizy);
}
void artPreloadFile(buildvfs_kfd const fil, artheader_t const * const local)
void artPreloadFile(buildvfs_kfd const fil, artheader_t * const local)
{
char *buffer = NULL;
int32_t buffersize = 0;
for (bssize_t i=local->tilestart; i<=local->tileend; i++)
{
int const dasiz = tilesiz[i].x * tilesiz[i].y;
int32_t const localIndex = i - local->tilestart;
if (!bitmap_test(local->tileread, localIndex))
continue;
int const dasiz = tilesiz[i].x * tilesiz[i].y;
if (dasiz == 0)
{
tileDelete(i);
......@@ -437,17 +453,21 @@ void artPreloadFile(buildvfs_kfd const fil, artheader_t const * const local)
}
DO_FREE_AND_NULL(buffer);
DO_FREE_AND_NULL(local->tileread);
}
static void artPreloadFileSafe(buildvfs_kfd const fil, artheader_t const * const local)
static void artPreloadFileSafe(buildvfs_kfd const fil, artheader_t * const local)
{
char *buffer = NULL;
int32_t buffersize = 0;
for (bssize_t i=local->tilestart; i<=local->tileend; i++)
{
int const dasiz = tilesiz[i].x * tilesiz[i].y;
int32_t const localIndex = i - local->tilestart;
if (!bitmap_test(local->tileread, localIndex))
continue;
int const dasiz = tilesiz[i].x * tilesiz[i].y;
if (dasiz == 0)
{
tileSoftDelete(i);
......@@ -460,6 +480,7 @@ static void artPreloadFileSafe(buildvfs_kfd const fil, artheader_t const * const
}
DO_FREE_AND_NULL(buffer);
DO_FREE_AND_NULL(local->tileread);
}
static const char *artGetIndexedFileName(int32_t tilefilei)
......@@ -545,6 +566,10 @@ static int32_t artReadIndexedFile(int32_t tilefilei)
for (bssize_t i=local.tilestart; i<=local.tileend; ++i)
{
int32_t const localIndex = i - local.tilestart;
if (!bitmap_test(local.tileread, localIndex))
continue;
int const dasiz = tilesiz[i].x * tilesiz[i].y;
tilefilenum[i] = tilefilei;
......@@ -553,6 +578,8 @@ static int32_t artReadIndexedFile(int32_t tilefilei)
offscount += dasiz;
// artsize += ((dasiz+15)&0xfffffff0);
}
DO_FREE_AND_NULL(local.tileread);
}
if (permap)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment