r3300 - in trunk/data/qcsrc: common menu/nexuiz
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Jan 29 05:31:11 EST 2008
Author: div0
Date: 2008-01-29 05:30:56 -0500 (Tue, 29 Jan 2008)
New Revision: 3300
Modified:
trunk/data/qcsrc/common/mapinfo.qc
trunk/data/qcsrc/common/mapinfo.qh
trunk/data/qcsrc/menu/nexuiz/util.qc
Log:
replace the HugeSetOfIntegers by another string buffer... and add a progress indicator for mapinfo autogeneration
Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc 2008-01-29 09:43:55 UTC (rev 3299)
+++ trunk/data/qcsrc/common/mapinfo.qc 2008-01-29 10:30:56 UTC (rev 3300)
@@ -27,6 +27,7 @@
cvar_set("settemp_list", "0");
}
+#ifdef HSOI
// HUGE SET - stored in a string
string HugeSetOfIntegers_empty()
{
@@ -51,6 +52,7 @@
s = strcat(" ", ftos(n));
return strcat(a1, substring(s, strlen(s) - 4, 4), a2);
}
+#endif
// generic string stuff
float startsWith(string haystack, string needle)
@@ -187,7 +189,14 @@
}
// filter the info by game type mask (updates MapInfo_count)
+//
+#ifdef HSOI
string _MapInfo_filtered;
+float MapInfo_FilterList_Lookup(float i)
+{
+ return MapInfo_FilterList_Lookup(i);
+}
+
string MapInfo_FilterGametype_Recursive(float pGametype, float pFeatures, float pBegin, float pEnd, float pAbortOnGenerate)
{
float m, valid;
@@ -203,7 +212,10 @@
return string_null; // BAIL OUT
if(MapInfo_Get_ByName(_MapInfo_GlobItem(m), 1, 0) == 2) // if we generated one... BAIL OUT and let the caller continue in the next frame.
if(pAbortOnGenerate)
+ {
+ MapInfo_progress = m / _MapInfo_globcount;
return string_null; // BAIL OUT
+ }
valid = (((MapInfo_Map_supportedGametypes & pGametype) != 0) && ((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures));
r = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, m + 1, pEnd, pAbortOnGenerate);
if not(r)
@@ -214,6 +226,7 @@
else
return HugeSetOfIntegers_concat(l, r);
}
+
float MapInfo_FilterGametype(float pGametype, float pFeatures, float pAbortOnGenerate)
{
if(_MapInfo_filtered)
@@ -229,11 +242,44 @@
MapInfo_ClearTemps();
return 1;
}
+#else
+float _MapInfo_filtered;
+float _MapInfo_filtered_allocated;
+float MapInfo_FilterList_Lookup(float i)
+{
+ return stof(bufstr_get(_MapInfo_filtered, i));
+}
+float MapInfo_FilterGametype(float pGametype, float pFeatures, float pAbortOnGenerate)
+{
+ float i, j;
+ if not(_MapInfo_filtered_allocated)
+ {
+ _MapInfo_filtered_allocated = 1;
+ _MapInfo_filtered = buf_create();
+ }
+ MapInfo_count = 0;
+ for(i = 0, j = 0; i < _MapInfo_globcount; ++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;
+ }
+ if(((MapInfo_Map_supportedGametypes & pGametype) != 0) && ((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures))
+ bufstr_set(_MapInfo_filtered, j++, ftos(i));
+ }
+ MapInfo_count = j;
+ return 1;
+}
+#endif
+
// load info about the i-th map into the MapInfo_Map_* globals
string MapInfo_BSPName_ByID(float i)
{
- return _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, i));
+ return _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i));
}
string unquote(string s)
@@ -598,7 +644,7 @@
while(l != r)
{
m = floor((l + r) / 2);
- MapInfo_FindName_match = _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, m));
+ MapInfo_FindName_match = _MapInfo_GlobItem(MapInfo_FilterList_Lookup(m));
cmp = strcasecmp(MapInfo_FindName_match, s);
if(cmp == 0)
return m; // found and good
@@ -607,7 +653,7 @@
else
r = m; // behind s
}
- MapInfo_FindName_match = _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, l));
+ MapInfo_FindName_match = _MapInfo_GlobItem(MapInfo_FilterList_Lookup(l));
MapInfo_FindName_firstResult = l;
// r == l, so: l is behind s, l-1 is before
// SO: if there is any, l is the one with the right prefix
@@ -626,7 +672,7 @@
}
if(l == MapInfo_count - 1)
return l; // last one, nothing can follow => unique
- if(startsWithNocase(_MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, l + 1)), s))
+ if(startsWithNocase(_MapInfo_GlobItem(MapInfo_FilterList_Lookup(l + 1)), s))
{
MapInfo_FindName_match = string_null;
return -1; // ambigous MapInfo_FindName_match
@@ -729,7 +775,7 @@
out = "";
for(i = 0; i < MapInfo_count; ++i)
- out = strcat(out, " ", _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, i)));
+ out = strcat(out, " ", _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i)));
return substring(out, 1, strlen(out) - 1);
}
Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh 2008-01-29 09:43:55 UTC (rev 3299)
+++ trunk/data/qcsrc/common/mapinfo.qh 2008-01-29 10:30:56 UTC (rev 3300)
@@ -29,7 +29,8 @@
void MapInfo_Enumerate();
// filter the info by game type mask (updates MapInfo_count)
-float MapInfo_FilterGametype(float gametype, float features, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then)
+float MapInfo_progress;
+float MapInfo_FilterGametype(float gametype, float features, float pAbortOnGenerate); // 1 on success, 0 on temporary failure (call it again next frame then; use MapInfo_progress as progress indicator)
float MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
float MapInfo_CurrentGametype(); // retrieves current gametype from cvars
Modified: trunk/data/qcsrc/menu/nexuiz/util.qc
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/util.qc 2008-01-29 09:43:55 UTC (rev 3299)
+++ trunk/data/qcsrc/menu/nexuiz/util.qc 2008-01-29 10:30:56 UTC (rev 3300)
@@ -154,26 +154,31 @@
// END OF EXTRESPONSE SYSTEM /////////////////////////////////////////////////
-float nMenuInitDots;
float preMenuInit()
{
- string s;
- float i, w, sz;
+ vector sz;
+ vector boxA, boxB;
MapInfo_Cache_Create();
MapInfo_Enumerate();
if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 1))
{
- nMenuInitDots = nMenuInitDots + 1;
- s = "Generating mapinfo..";
- for(i = 0; i < nMenuInitDots; ++i)
- s = strcat(s, ".");
draw_reset();
- w = draw_TextWidth(s, 0);
- sz = min(0.025, 1 / w);
- draw_CenterText(eX * 0.5 + eY * 0.5, s, eX * sz + eY * sz * (draw_scale_x / draw_scale_y), '1 1 1', 1, 0);
+ sz = eX * 0.025 + eY * 0.025 * (draw_scale_x / draw_scale_y);
+ draw_CenterText('0.5 0.5 0' - 1.25 * sz_y * eY, "Autogenerating mapinfo for newly added maps...", sz, '1 1 1', 1, 0);
+ boxA = '0.05 0.5 0' + 0.25 * sz_y * eY;
+ boxB = '0.95 0.5 0' + 1.25 * sz_y * eY;
+ draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
+
+ boxA += sz * 0.1;
+ boxB -= sz * 0.1;
+ draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
+
+ boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
+ draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
+
return FALSE;
}
return TRUE;
More information about the nexuiz-commits
mailing list