mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-06 03:55:32 +03:00
Added auto precaching detail textures if present
Moved auto WAD precaching to TEX_InitFromWad
This commit is contained in:
parent
7b3636c110
commit
4cd651d865
@ -5086,34 +5086,40 @@ void PrecacheMapSpecifiedResources()
|
|||||||
if (FS_FileExists(va("maps/%s.txt", g_psv.name)))
|
if (FS_FileExists(va("maps/%s.txt", g_psv.name)))
|
||||||
PF_precache_generic_I(va("maps/%s.txt", g_psv.name));
|
PF_precache_generic_I(va("maps/%s.txt", g_psv.name));
|
||||||
|
|
||||||
// TODO: or this is not-engine and this better do by gamedll or .res?
|
char *detailTextureInfoFileName = va("maps/%s_detail.txt", g_psv.name);
|
||||||
if (FS_FileExists(va("maps/%s_detail.txt", g_psv.name)))
|
if (FS_FileExists(detailTextureInfoFileName))
|
||||||
PF_precache_generic_I(va("maps/%s_detail.txt", g_psv.name));
|
|
||||||
|
|
||||||
if (wadpath != nullptr)
|
|
||||||
{
|
{
|
||||||
char tempPath[1024];
|
PF_precache_generic_I(detailTextureInfoFileName);
|
||||||
Q_strncpy(tempPath, wadpath, sizeof(tempPath) - 2);
|
|
||||||
tempPath[sizeof(tempPath) - 2] = 0;
|
|
||||||
if (!Q_strchr(tempPath, ';'))
|
|
||||||
Q_strcat(tempPath, ";");
|
|
||||||
|
|
||||||
for (char *token = strtok(tempPath, ";"); token != nullptr; token = strtok(nullptr, ";"))
|
char *buffer = (char *)COM_LoadFileForMe(detailTextureInfoFileName, nullptr);
|
||||||
|
char *pos = buffer;
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
char wadName[MAX_QPATH];
|
// Get texture name
|
||||||
COM_FileBase(token, wadName);
|
pos = COM_Parse(pos);
|
||||||
COM_DefaultExtension(wadName, ".wad");
|
|
||||||
|
|
||||||
if (!FS_FileExists(wadName)
|
if (com_token[0] == '\0')
|
||||||
|| !Q_stricmp(wadName, "pldecal.wad")
|
break;
|
||||||
|| !Q_stricmp(wadName, "tempdecal.wad")
|
|
||||||
|| !Q_stricmp(wadName, "halflife.wad")
|
|
||||||
|| !Q_stricmp(wadName, "xeno.wad")
|
|
||||||
|| !Q_stricmp(wadName, "decals.wad"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
PF_precache_generic_I(wadName);
|
// Skip '{' in texture name (COM_Parse read one symbol '{' as full token)
|
||||||
|
if (com_token[0] == '{')
|
||||||
|
pos = COM_Parse(pos);
|
||||||
|
|
||||||
|
// Get detail texture filename
|
||||||
|
pos = COM_Parse(pos);
|
||||||
|
|
||||||
|
char *detailTextureFileName = va("gfx/%s.tga", com_token);
|
||||||
|
if (FS_FileExists(detailTextureFileName))
|
||||||
|
PF_precache_generic_I(detailTextureFileName);
|
||||||
|
else
|
||||||
|
Con_Printf("WARNING: detail texture '%s' for map '%s' not found!\n", detailTextureFileName, g_psv.name);
|
||||||
|
|
||||||
|
// Skip hscale and vscale
|
||||||
|
pos = COM_Parse(pos);
|
||||||
|
pos = COM_Parse(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
COM_FreeFile(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // REHLDS_FIXES
|
#endif // REHLDS_FIXES
|
||||||
|
@ -118,6 +118,14 @@ qboolean TEX_InitFromWad(char *path)
|
|||||||
if (Q_strstr(wadName, "pldecal") || Q_strstr(wadName, "tempdecal"))
|
if (Q_strstr(wadName, "pldecal") || Q_strstr(wadName, "tempdecal"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
if (g_psv.active
|
||||||
|
&& Q_stricmp(wadPath, "halflife.wad")
|
||||||
|
&& Q_stricmp(wadPath, "xeno.wad")
|
||||||
|
&& Q_stricmp(wadPath, "decals.wad"))
|
||||||
|
PF_precache_generic_I(wadPath);
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
|
|
||||||
texfile = FS_Open(wadPath, "rb");
|
texfile = FS_Open(wadPath, "rb");
|
||||||
texfiles[nTexFiles++] = texfile;
|
texfiles[nTexFiles++] = texfile;
|
||||||
if (!texfile)
|
if (!texfile)
|
||||||
|
Loading…
Reference in New Issue
Block a user