Merge pull request #18 from STJr/flats-png
Merge upstream's master into flats-png
This commit is contained in:
commit
3fb113e786
76
src/r_data.c
76
src/r_data.c
|
@ -530,48 +530,37 @@ void R_LoadTextures(void)
|
||||||
size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
||||||
patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
||||||
|
|
||||||
// Then, check the lump directly to see if it's a texture SOC,
|
//CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height);
|
||||||
// and if it is, load it using dehacked instead.
|
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
|
||||||
if (strstr((const char *)patchlump, "TEXTURE"))
|
|
||||||
|
// Set texture properties.
|
||||||
|
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
||||||
|
if (R_IsLumpPNG((UINT8 *)patchlump, lumplength))
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, "%s is a Texture SOC.\n", W_CheckNameForNumPwad((UINT16)w,texstart+j));
|
INT16 width, height;
|
||||||
Z_Unlock(patchlump);
|
R_PNGDimensions((UINT8 *)patchlump, &width, &height, lumplength);
|
||||||
DEH_LoadDehackedLumpPwad((UINT16)w, texstart + j);
|
texture->width = width;
|
||||||
|
texture->height = height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height);
|
texture->width = SHORT(patchlump->width);
|
||||||
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
|
texture->height = SHORT(patchlump->height);
|
||||||
|
|
||||||
// Set texture properties.
|
|
||||||
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
|
||||||
if (R_IsLumpPNG((UINT8 *)patchlump, lumplength))
|
|
||||||
{
|
|
||||||
INT16 width, height;
|
|
||||||
R_PNGDimensions((UINT8 *)patchlump, &width, &height, lumplength);
|
|
||||||
texture->width = width;
|
|
||||||
texture->height = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
texture->width = SHORT(patchlump->width);
|
|
||||||
texture->height = SHORT(patchlump->height);
|
|
||||||
}
|
|
||||||
texture->patchcount = 1;
|
|
||||||
texture->holes = false;
|
|
||||||
|
|
||||||
// Allocate information for the texture's patches.
|
|
||||||
patch = &texture->patches[0];
|
|
||||||
|
|
||||||
patch->originx = patch->originy = 0;
|
|
||||||
patch->wad = (UINT16)w;
|
|
||||||
patch->lump = texstart + j;
|
|
||||||
|
|
||||||
Z_Unlock(patchlump);
|
|
||||||
|
|
||||||
texturewidth[i] = texture->width;
|
|
||||||
textureheight[i] = texture->height << FRACBITS;
|
|
||||||
}
|
}
|
||||||
|
texture->patchcount = 1;
|
||||||
|
texture->holes = false;
|
||||||
|
|
||||||
|
// Allocate information for the texture's patches.
|
||||||
|
patch = &texture->patches[0];
|
||||||
|
|
||||||
|
patch->originx = patch->originy = 0;
|
||||||
|
patch->wad = (UINT16)w;
|
||||||
|
patch->lump = texstart + j;
|
||||||
|
|
||||||
|
Z_Unlock(patchlump);
|
||||||
|
|
||||||
|
texturewidth[i] = texture->width;
|
||||||
|
textureheight[i] = texture->height << FRACBITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,6 +1141,7 @@ void R_ReInitColormaps(UINT16 num)
|
||||||
{
|
{
|
||||||
char colormap[9] = "COLORMAP";
|
char colormap[9] = "COLORMAP";
|
||||||
lumpnum_t lump;
|
lumpnum_t lump;
|
||||||
|
const lumpnum_t basecolormaplump = W_GetNumForName(colormap);
|
||||||
|
|
||||||
if (num > 0 && num <= 10000)
|
if (num > 0 && num <= 10000)
|
||||||
snprintf(colormap, 8, "CLM%04u", num-1);
|
snprintf(colormap, 8, "CLM%04u", num-1);
|
||||||
|
@ -1159,8 +1149,16 @@ void R_ReInitColormaps(UINT16 num)
|
||||||
// Load in the light tables, now 64k aligned for smokie...
|
// Load in the light tables, now 64k aligned for smokie...
|
||||||
lump = W_GetNumForName(colormap);
|
lump = W_GetNumForName(colormap);
|
||||||
if (lump == LUMPERROR)
|
if (lump == LUMPERROR)
|
||||||
lump = W_GetNumForName("COLORMAP");
|
lump = basecolormaplump;
|
||||||
W_ReadLump(lump, colormaps);
|
else
|
||||||
|
{
|
||||||
|
if (W_LumpLength(lump) != W_LumpLength(basecolormaplump))
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_WARNING, "%s lump size does not match COLORMAP, results may be unexpected.\n", colormap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U);
|
||||||
|
|
||||||
// Init Boom colormaps.
|
// Init Boom colormaps.
|
||||||
R_ClearColormaps();
|
R_ClearColormaps();
|
||||||
|
|
|
@ -362,7 +362,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
||||||
gme_track_info(emu, &info, 0);
|
gme_track_info(emu, &info, 0);
|
||||||
|
|
||||||
len = (info->play_length * 441 / 10) << 2;
|
len = (info->play_length * 441 / 10) << 2;
|
||||||
mem = malloc(len);
|
mem = Z_Malloc(len, PU_SOUND, 0);
|
||||||
gme_play(emu, len >> 1, mem);
|
gme_play(emu, len >> 1, mem);
|
||||||
gme_free_info(info);
|
gme_free_info(info);
|
||||||
gme_delete(emu);
|
gme_delete(emu);
|
||||||
|
@ -435,7 +435,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
||||||
gme_track_info(emu, &info, 0);
|
gme_track_info(emu, &info, 0);
|
||||||
|
|
||||||
len = (info->play_length * 441 / 10) << 2;
|
len = (info->play_length * 441 / 10) << 2;
|
||||||
mem = malloc(len);
|
mem = Z_Malloc(len, PU_SOUND, 0);
|
||||||
gme_play(emu, len >> 1, mem);
|
gme_play(emu, len >> 1, mem);
|
||||||
gme_free_info(info);
|
gme_free_info(info);
|
||||||
gme_delete(emu);
|
gme_delete(emu);
|
||||||
|
|
12
src/w_wad.c
12
src/w_wad.c
|
@ -149,9 +149,15 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
|
||||||
{
|
{
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
|
|
||||||
strncpy(filenamebuf, *filename, MAX_WADPATH);
|
// Officially, strncpy should not have overlapping buffers, since W_VerifyNMUSlumps is called after this, and it
|
||||||
filenamebuf[MAX_WADPATH - 1] = '\0';
|
// changes filename to point at filenamebuf, it would technically be doing that. I doubt any issue will occur since
|
||||||
*filename = filenamebuf;
|
// they point to the same location, but it's better to be safe and this is a simple change.
|
||||||
|
if (filenamebuf != *filename)
|
||||||
|
{
|
||||||
|
strncpy(filenamebuf, *filename, MAX_WADPATH);
|
||||||
|
filenamebuf[MAX_WADPATH - 1] = '\0';
|
||||||
|
*filename = filenamebuf;
|
||||||
|
}
|
||||||
|
|
||||||
// open wad file
|
// open wad file
|
||||||
if ((handle = fopen(*filename, "rb")) == NULL)
|
if ((handle = fopen(*filename, "rb")) == NULL)
|
||||||
|
|
Loading…
Reference in New Issue