// only one of filename / pack will be used
char filename[MAX_OSPATH];
pack_t *pack;
+ const char *vpack; // points into filename where the pack short name starts
struct searchpath_s *next;
} searchpath_t;
{
if (s->pack)
Con_Printf("%s (%i files)\n", s->pack->filename, s->pack->numfiles);
+ else if (s->vpack)
+ Con_Printf("%s (virtual pack)\n", s->filename);
else
Con_Printf("%s\n", s->filename);
}
{
searchpath_t *search;
pack_t *pak = NULL;
+ qboolean fakepack = true;
const char *ext = FS_FileExtension(pakfile);
for(search = fs_searchpaths; search; search = search->next)
{
- if(search->pack && !strcasecmp(search->pack->filename, pakfile))
+ if(search->pack ? !strcasecmp(search->pack->filename, pakfile) : (search->vpack && !strcasecmp(search->filename, pakfile)))
{
if(already_loaded)
*already_loaded = true;
if(already_loaded)
*already_loaded = false;
- if(!strcasecmp(ext, "pak"))
+ if(FS_SysFileType(pakfile) == FS_FILETYPE_DIRECTORY)
+ {
+ fakepack = true;
+ Con_DPrintf("Added packfile %s (virtual pack)\n", pakfile);
+ }
+ else if(!strcasecmp(ext, "pak"))
pak = FS_LoadPackPAK (pakfile);
else if(!strcasecmp(ext, "pk3"))
pak = FS_LoadPackPK3 (pakfile);
{
if(!insertion_point->next)
break;
- if(insertion_point->next->pack)
+ if(insertion_point->next->vpack)
break;
insertion_point = insertion_point->next;
}
if(!insertion_point)
{
search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
- search->pack = pak;
search->next = fs_searchpaths;
fs_searchpaths = search;
}
// otherwise we want to append directly after insertion_point.
{
search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
- search->pack = pak;
search->next = insertion_point->next;
insertion_point->next = search;
}
else
{
search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
- search->pack = pak;
search->next = fs_searchpaths;
fs_searchpaths = search;
}
+ search->pack = pak;
+ if(!pak)
+ search->filename = fn;
+ if(strlen(filename) >= strlen(shortname))
+ search->vpack = search->filename + strlen(search->filename) - strlen(shortname);
+ else
+ search->vpack = search->filename;
return true;
}
else
// then find the real name...
search = FS_FindFile(pakfile, &index, true);
- if(!search || search->pack)
+ if(!search || search->vpack)
{
Con_Printf("could not find pak \"%s\"\n", pakfile);
return false;
// Found in the filesystem?
if (pack_ind < 0)
{
+ // this works with vpacks, so we are fine
char path [MAX_OSPATH];
dpsnprintf (path, sizeof (path), "%s%s", search->filename, filename);
return FS_SysOpen (path, "rb", nonblocking);
return NULL;
}
- dpsnprintf (real_path, sizeof (real_path), "%s/%s", fs_gamedir, filepath);
+ dpsnprintf (real_path, sizeof (real_path), "%s/%s", fs_gamedir, filepath); // this is never a vpack
// If the file is opened in "write", "append", or "read/write" mode,
// create directories up to the file.
}
if (sp->pack)
Con_Printf("%s is in package %s\n", filename, sp->pack->shortname);
+ else if (sp->vpack)
+ Con_Printf("%s is in virtual package %s\n", filename, sp->vpack);
else
Con_Printf("%s is file %s%s\n", filename, sp->filename, filename);
}
searchpath_t *sp = FS_FindFile(filename, &index, true);
if(sp && sp->pack)
return sp->pack->shortname;
+ else if(sp && sp->vpack)
+ return sp->vpack;
else
return 0;
}
// we found the requested pack but it is not registered quake
return false;
}
+ // TODO do we want to support vpacks in here too?
}
return false;