From: Rudolf Polzer <divverent@xonotic.org>
Date: Thu, 27 Dec 2012 16:27:24 +0000 (+0100)
Subject: mapinfo: don't spam errors when there is no maps
X-Git-Tag: xonotic-v0.7.0~159
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=605ba4c6e90d84d0b84f7314fda01779391c25bf;p=xonotic%2Fxonotic-data.pk3dir.git

mapinfo: don't spam errors when there is no maps
---

diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc
index 05c93865d..d29cc5d08 100644
--- a/qcsrc/common/mapinfo.qc
+++ b/qcsrc/common/mapinfo.qc
@@ -89,6 +89,8 @@ float _MapInfo_globhandle;
 string _MapInfo_GlobItem(float i)
 {
 	string s;
+	if(!_MapInfo_globopen)
+		return string_null;
 	s = search_getfilename(_MapInfo_globhandle, i);
 	return substring(s, 5, strlen(s) - 9); // without maps/ and .bsp
 }
@@ -96,11 +98,19 @@ string _MapInfo_GlobItem(float i)
 void MapInfo_Enumerate()
 {
 	if(_MapInfo_globopen)
+	{
 		search_end(_MapInfo_globhandle);
+		_MapInfo_globopen = 0;
+	}
 	MapInfo_Cache_Invalidate();
 	_MapInfo_globhandle = search_begin("maps/*.bsp", TRUE, TRUE);
-	_MapInfo_globcount = search_getsize(_MapInfo_globhandle);
-	_MapInfo_globopen = 1;
+	if(_MapInfo_globhandle >= 0)
+	{
+		_MapInfo_globcount = search_getsize(_MapInfo_globhandle);
+		_MapInfo_globopen = 1;
+	}
+	else
+		_MapInfo_globcount = 0;
 }
 
 // filter the info by game type mask (updates MapInfo_count)