PK3 support

This commit is contained in:
Jaime Passos 2019-03-19 18:25:55 -03:00
parent f714cba310
commit da001a5b54
3 changed files with 24 additions and 8 deletions

View File

@ -5956,7 +5956,7 @@ static inline UINT16 HWR_CheckShader(UINT16 wadnum)
return INT16_MAX;
}
void HWR_LoadShaders(UINT16 wadnum)
void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
{
UINT16 lump;
char *shaderdef, *line;
@ -6037,17 +6037,29 @@ skip_lump:
{
size_t shader_size;
char *shader_source;
char shader_lumpname[9];
char *shader_lumpname;
UINT16 shader_lumpnum;
strcpy(shader_lumpname, "SH_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
if (PK3)
{
shader_lumpname = Z_Malloc(strlen(value) + 12, PU_STATIC, NULL);
strcpy(shader_lumpname, "Shaders/sh_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0);
}
else
{
shader_lumpname = Z_Malloc(strlen(value) + 4, PU_STATIC, NULL);
strcpy(shader_lumpname, "SH_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
}
if (shader_lumpnum == INT16_MAX)
{
CONS_Alert(CONS_ERROR, "HWR_LoadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
break;
Z_Free(shader_lumpname);
continue;
}
shader_size = W_LumpLengthPwad(wadnum, shader_lumpnum);
@ -6057,6 +6069,7 @@ skip_lump:
HWD.pfnLoadCustomShader(shaderxlat[i].id, shader_source, shader_size, (shadertype == 2));
Z_Free(shader_source);
Z_Free(shader_lumpname);
}
}

View File

@ -65,7 +65,7 @@ void HWR_DrawIntermissionBG(void);
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(int width, int height);
void HWR_LoadShaders(UINT16 wadnum);
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
// This stuff is put here so MD2's can use them
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, UINT32 mixcolor, UINT32 fadecolor);

View File

@ -783,7 +783,7 @@ UINT16 W_InitFile(const char *filename)
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_LoadShaders(numwadfiles - 1);
HWR_LoadShaders(numwadfiles - 1, (wadfile->type == RET_PK3));
#endif
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
@ -1699,7 +1699,10 @@ int W_VerifyNMUSlumps(const char *filename)
{"PAL", 3},
{"CLM", 3},
{"TRANS", 5},
#ifdef HWRENDER
{"SHADERS", 7},
{"SH_", 3},
#endif
{NULL, 0},
};
return W_VerifyFile(filename, NMUSlist, false);