From 4168bb37155db4970ffa47e7d8e0867d4b2864ee Mon Sep 17 00:00:00 2001 From: div0 Date: Thu, 15 Nov 2007 22:09:25 +0000 Subject: [PATCH] some fixes against extreme CPU load and not loading the maplist git-svn-id: svn://svn.icculus.org/nexuiz/trunk@2963 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/common/mapinfo.qc | 13 +++++++------ data/qcsrc/server/g_world.qc | 14 +++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/data/qcsrc/common/mapinfo.qc b/data/qcsrc/common/mapinfo.qc index c190944d3..f071f8627 100644 --- a/data/qcsrc/common/mapinfo.qc +++ b/data/qcsrc/common/mapinfo.qc @@ -100,8 +100,6 @@ string MapInfo_FilterGametype_Recursive(float pGametype, float pFeatures, float } float MapInfo_FilterGametype(float pGametype, float pFeatures) { - MapInfo_Enumerate(); - if(_MapInfo_filtered) strunzone(_MapInfo_filtered); _MapInfo_filtered = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, 0, _MapInfo_globcount); @@ -374,7 +372,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype if(!(MapInfo_Map_supportedGametypes & pGametypeToSet)) error("Can't select the requested game type. Bailing out."); if(MapInfo_Map_supportedGametypes != 0) - return 1; + return r; dprint("Map ", pFilename, " supports no game types, ignored\n"); return 0; } @@ -386,8 +384,6 @@ string MapInfo_FixName(string s) // note that DP sorts glob results... so I can use a binary search string match; float l, r, m, cmp; - MapInfo_Enumerate(); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures()); l = 0; r = MapInfo_count; // invariants: r is behind s, l-1 is equal or before @@ -484,8 +480,13 @@ string MapInfo_ListAllowedMaps() { string out; float i; + + // to make absolutely sure: MapInfo_Enumerate(); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures()); + for(;;) + if(MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures())) + break; + out = ""; for(i = 0; i < MapInfo_count; ++i) out = strcat(out, " ", _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, i))); diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 1a64736cd..944c64cd1 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -349,6 +349,11 @@ void worldspawn (void) readlevelcvars(); Ban_LoadBans(); + +#ifdef MAPINFO + MapInfo_Enumerate(); + MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures()); +#endif } void light (void) @@ -2069,7 +2074,14 @@ void MapVote_Tick() } void MapVote_Start() { - mapvote_run = TRUE; + if(mapvote_run) + return; + +#ifdef MAPINFO + MapInfo_Enumerate(); + if(MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures())) +#endif + mapvote_run = TRUE; } void MapVote_Think() { -- 2.39.2