return;
}
- s = FS_Search(Cmd_Argv(cmd, 1), true, true);
+ s = FS_Search(Cmd_Argv(cmd, 1), true, true, NULL);
if(!s || !s->numfilenames)
{
Con_Printf("couldn't exec %s\n",Cmd_Argv(cmd, 1));
unsigned char buf[1024];
dpsnprintf(message, sizeof(message), "maps/%s*.bsp", s);
- t = FS_Search(message, 1, true);
+ t = FS_Search(message, 1, true, NULL);
if(!t)
return false;
if (t->numfilenames > 1)
fssearch_t *search;
if(strchr(com_token, '/'))
{
- search = FS_Search(com_token, true, true);
+ search = FS_Search(com_token, true, true, NULL);
}
else
{
{
strlcpy(t, s, min(sizeof(t), (unsigned int)(slash - s + 2))); // + 2, because I want to include the slash
strlcat(t, com_token, sizeof(t));
- search = FS_Search(t, true, true);
+ search = FS_Search(t, true, true, NULL);
}
else
- search = FS_Search(com_token, true, true);
+ search = FS_Search(com_token, true, true, NULL);
}
if(search)
{
{
strlcpy(t, s, min(sizeof(t), (unsigned int)(slash - s + 2))); // + 2, because I want to include the slash
strlcat(t, "*", sizeof(t));
- search = FS_Search(t, true, true);
+ search = FS_Search(t, true, true, NULL);
}
else
- search = FS_Search("*", true, true);
+ search = FS_Search("*", true, true, NULL);
if(search)
{
for(i = 0; i < search->numfilenames; ++i)
//function definitions:
void coverage() = #642; // Reports a coverage event. The engine counts for each of the calls to this builtin whether it has been called.
+//DP_QC_FS_SEARCH_PACKFILE
+//idea: Mario
+//darkplaces implementation: Mario
+//builtin definitions:
+float(string pattern, float caseinsensitive, float quiet, string packfile) search_packfile_begin = #444;
+//description:
+//extension to search_begin (DP_QC_FS_SEARCH), performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
+//only searches for files within the specified packfile, which is expected to match the results of whichpack().
+
// assorted builtins
const float STAT_MOVEVARS_TICRATE = 240;
const float STAT_MOVEVARS_TIMESCALE = 241;
string __fullspawndata;
//description:
// http://icculus.org/finger/marco?date=2019-01-25&time=05-38-02
+
+//DP_QC_FS_SEARCH_PACKFILE
+//idea: Mario
+//darkplaces implementation: Mario
+//builtin definitions:
+float(string pattern, float caseinsensitive, float quiet, string packfile) search_packfile_begin = #444;
+//description:
+//extension to search_begin (DP_QC_FS_SEARCH), performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
+//only searches for files within the specified packfile, which is expected to match the results of whichpack().
//function definitions:
void coverage() = #642; // Reports a coverage event. The engine counts for each of the calls to this builtin whether it has been called.
+//DP_QC_FS_SEARCH_PACKFILE
+//idea: Mario
+//darkplaces implementation: Mario
+//builtin definitions:
+float(string pattern, float caseinsensitive, float quiet, string packfile) search_packfile_begin = #444;
+//description:
+//extension to search_begin (DP_QC_FS_SEARCH), performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
+//only searches for files within the specified packfile, which is expected to match the results of whichpack().
+
// assorted undocumented extensions
string(string, float) netaddress_resolve = #625;
string(string search, string replace, string subject) strreplace = #484;
Allocate and fill a search structure with information on matching filenames.
===========
*/
-fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet)
+fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet, const char *packfile)
{
fssearch_t *search;
searchpath_t *searchpath;
{
// look through all the pak file elements
pak = searchpath->pack;
+ if(packfile)
+ {
+ if(strcmp(packfile, pak->shortname))
+ continue;
+ }
for (i = 0;i < pak->numfiles;i++)
{
char temp[MAX_OSPATH];
}
else
{
+ if(packfile)
+ continue;
stringlist_t matchedSet, foundSet;
const char *start = pattern;
const char *name;
char linebuf[MAX_INPUTLINE];
fssearch_t *search;
- search = FS_Search(pattern, true, true);
+ search = FS_Search(pattern, true, true, NULL);
if (!search)
return 0;
numfiles = search->numfilenames;
}
fssearch_t;
-fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet);
+fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet, const char *packfile);
void FS_FreeSearch(fssearch_t *search);
unsigned char *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet, fs_offset_t *filesizepointer);
return;
}
filename_pattern = Cmd_Argv(cmd, 1);
- search = FS_Search(filename_pattern, true, true);
+ search = FS_Search(filename_pattern, true, true, NULL);
if(!search)
return;
for(i = 0; i < search->numfilenames; ++i)
}
// parse shaders
- search = FS_Search("scripts/*.shader", true, false);
+ search = FS_Search("scripts/*.shader", true, false, NULL);
if (!search)
return;
for (fileindex = 0;fileindex < search->numfilenames;fileindex++)
=========
VM_search_begin
-float search_begin(string pattern, float caseinsensitive, float quiet)
+float search_begin(string pattern, float caseinsensitive, float quiet[, string packfile])
=========
*/
void VM_search_begin(prvm_prog_t *prog)
{
int handle;
- const char *pattern;
+ const char *packfile = NULL, *pattern;
int caseinsens, quiet;
- VM_SAFEPARMCOUNT(3, VM_search_begin);
+ VM_SAFEPARMCOUNTRANGE(3, 4, VM_search_begin);
pattern = PRVM_G_STRING(OFS_PARM0);
caseinsens = (int)PRVM_G_FLOAT(OFS_PARM1);
quiet = (int)PRVM_G_FLOAT(OFS_PARM2);
+ // optional packfile parameter (DP_QC_FS_SEARCH_PACKFILE)
+ if(prog->argc >= 4)
+ packfile = PRVM_G_STRING(OFS_PARM3);
+
for(handle = 0; handle < PRVM_MAX_OPENSEARCHES; handle++)
if(!prog->opensearches[handle])
break;
return;
}
- if(!(prog->opensearches[handle] = FS_Search(pattern,caseinsens, quiet)))
+ if(!(prog->opensearches[handle] = FS_Search(pattern,caseinsens, quiet, packfile)))
PRVM_G_FLOAT(OFS_RETURN) = -1;
else
{
"TW_SV_STEPCONTROL",
"ZQ_PAUSE",
"DP_RM_CLIPGROUP",
+"DP_QC_FS_SEARCH_PACKFILE",
NULL
//"EXT_CSQC" // not ready yet
};