return 1;
}
-float MapInfo_FilterGametypeAndString(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate, string sf)
+float MapInfo_FilterString(string sf)
{
+ // this function further filters _MapInfo_filtered, which is prepared by MapInfo_FilterGametype by string
float i, j;
string title;
- if (!_MapInfo_filtered_allocated)
- {
- _MapInfo_filtered_allocated = 1;
- _MapInfo_filtered = buf_create();
- }
- MapInfo_count = 0;
- for(i = 0, j = -1; i < _MapInfo_globcount; ++i)
+
+ for(i = 0, j = -1; i < MapInfo_count; ++i)
{
- if(MapInfo_Get_ByName(_MapInfo_GlobItem(i), 1, 0) == 2) // if we generated one... BAIL OUT and let the caller continue in the next frame.
- if(pAbortOnGenerate)
- {
- dprint("Autogenerated a .mapinfo, doing the rest later.\n");
- MapInfo_progress = i / _MapInfo_globcount;
- return 0;
- }
- // prepare for keyword filter
- if (MapInfo_Map_title && strstrofs(MapInfo_Map_title, "<TITLE>", 0) == -1)
- title = MapInfo_Map_title;
- else
- title = MapInfo_Map_bspname;
- // keyword filter
- if((strstrofs(strtolower(title), strtolower(sf), 0)) >= 0)
- if((MapInfo_Map_supportedGametypes & pGametype) != 0)
- if((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures)
- if((MapInfo_Map_flags & pFlagsForbidden) == 0)
- if((MapInfo_Map_flags & pFlagsRequired) == pFlagsRequired)
- bufstr_set(_MapInfo_filtered, ++j, ftos(i));
+ if (MapInfo_Get_ByID(i))
+ {
+ // prepare for keyword filter
+ if (MapInfo_Map_title && strstrofs(MapInfo_Map_title, "<TITLE>", 0) == -1)
+ title = MapInfo_Map_title;
+ else
+ title = MapInfo_Map_bspname;
+ // keyword filter
+ if((strstrofs(strtolower(title), strtolower(sf), 0)) >= 0)
+ bufstr_set(_MapInfo_filtered, ++j, bufstr_get(_MapInfo_filtered, i));
+ }
}
MapInfo_count = j + 1;
MapInfo_ClearTemps();
// filter the info by game type mask (updates MapInfo_count)
float MapInfo_progress;
float MapInfo_FilterGametype(float gametype, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
+float MapInfo_FilterString(string sf); // this one runs after MapInfo_FilterGametype to futhur filter the list by a string
float MapInfo_FilterGametypeAndString(float gametype, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate, string filterString); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
int MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
int MapInfo_CurrentGametype(); // retrieves current gametype from cvars
float gt, f;
gt = MapInfo_CurrentGametype();
f = MapInfo_CurrentFeatures();
- // TODO consider consolidating the two functions
+ MapInfo_FilterGametype(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
if (me.stringFilter)
- MapInfo_FilterGametypeAndString(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0, me.stringFilter);
- else
- MapInfo_FilterGametype(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
+ MapInfo_FilterString(me.stringFilter);
me.nItems = MapInfo_count;
for(i = 0; i < MapInfo_count; ++i)
{
float i;
string s;
+ MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all
if (me.stringFilter)
- MapInfo_FilterGametypeAndString(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0, me.stringFilter);
- else
- MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all
+ MapInfo_FilterString(me.stringFilter);
s = "";
for(i = 0; i < MapInfo_count; ++i)
s = strcat(s, " ", MapInfo_BSPName_ByID(i));