src/primitives.cpp

changeset 941
f895379d7fab
parent 931
85080f7a1c20
--- a/src/primitives.cpp	Sun Apr 12 23:02:26 2015 +0300
+++ b/src/primitives.cpp	Tue Jul 07 21:35:20 2015 +0300
@@ -28,8 +28,8 @@
 
 QList<PrimitiveCategory*> g_PrimitiveCategories;
 QList<Primitive> g_primitives;
-static PrimitiveScanner* g_activeScanner = null;
-PrimitiveCategory* g_unmatched = null;
+static PrimitiveScanner* g_activeScanner = nullptr;
+PrimitiveCategory* g_unmatched = nullptr;
 
 EXTERN_CFGENTRY (String, DefaultName)
 EXTERN_CFGENTRY (String, DefaultUser)
@@ -113,7 +113,6 @@
 {
 	g_activeScanner = this;
 	QDir dir (LDPaths::prims());
-	assert (dir.exists());
 	m_baselen = dir.absolutePath().length();
 	GetRecursiveFilenames (dir, m_files);
 	emit starting (m_files.size());
@@ -124,14 +123,14 @@
 //
 PrimitiveScanner::~PrimitiveScanner()
 {
-	g_activeScanner = null;
+	g_activeScanner = nullptr;
 }
 
 // =============================================================================
 //
 void PrimitiveScanner::work()
 {
-	int j = Min (m_i + 100, m_files.size());
+	int j = min (m_i + 100, m_files.size());
 
 	for (; m_i < j; ++m_i)
 	{
@@ -144,7 +143,7 @@
 		Primitive info;
 		info.name = fname.mid (m_baselen + 1);  // make full path relative
 		info.name.replace ('/', '\\');  // use DOS backslashes, they're expected
-		info.category = null;
+		info.category = nullptr;
 		QByteArray titledata = f.readLine();
 
 		if (titledata != QByteArray())
@@ -181,7 +180,7 @@
 		g_primitives = m_prims;
 		PrimitiveCategory::populateCategories();
 		print ("%1 primitives scanned", g_primitives.size());
-		g_activeScanner = null;
+		g_activeScanner = nullptr;
 		emit workDone();
 		deleteLater();
 	}
@@ -223,7 +222,7 @@
 	for (Primitive& prim : g_primitives)
 	{
 		bool matched = false;
-		prim.category = null;
+		prim.category = nullptr;
 
 		// Go over the categories and their regexes, if and when there's a match,
 		// the primitive's category is set to the category the regex beloings to.
@@ -254,13 +253,13 @@
 			}
 
 			// Drop out if a category was decided on.
-			if (prim.category != null)
+			if (prim.category != nullptr)
 				break;
 		}
 
 		// If there was a match, add the primitive to the category.
 		// Otherwise, add it to the list of unmatched primitives.
-		if (prim.category != null)
+		if (prim.category != nullptr)
 			prim.category->prims << prim;
 		else
 			g_unmatched->prims << prim;
@@ -296,7 +295,7 @@
 		return;
 	}
 
-	PrimitiveCategory* cat = null;
+	PrimitiveCategory* cat = nullptr;
 
 	while (not f.atEnd())
 	{
@@ -316,14 +315,14 @@
 
 			cat = new PrimitiveCategory (line);
 		}
-		elif (cat != null)
+		else if (cat != nullptr)
 		{
 			QString cmd = line.left (colon);
 			RegexType type = EFilenameRegex;
 
 			if (cmd == "f")
 				type = EFilenameRegex;
-			elif (cmd == "t")
+			else if (cmd == "t")
 				type = ETitleRegex;
 			else
 			{
@@ -368,7 +367,7 @@
 //
 bool IsPrimitiveLoaderBusy()
 {
-	return g_activeScanner != null;
+	return g_activeScanner != nullptr;
 }
 
 // =============================================================================
@@ -524,7 +523,7 @@
 		{
 			v1 = Vertex (v0[X], 1.0f, v0[Z]);
 		}
-		elif (type == Cone)
+		else if (type == Cone)
 		{
 			v1 = Vertex (v0[X] * (num + 1), 0.0f, v0[Z] * (num + 1));
 			v0.setX (v0.x() * num);
@@ -582,7 +581,7 @@
 	// Truncate the root if necessary (7-16rin4.dat for instance).
 	// However, always keep the root at least 2 characters.
 	int extra = (frac.length() + numstr.length() + root.length()) - 8;
-	root.chop (Clamp (extra, 0, 2));
+	root.chop (clamp (extra, 0, 2));
 
 	// Stick them all together and return the result.
 	return prefix + frac + root + numstr + ".dat";
@@ -655,7 +654,7 @@
 	QString name = MakeRadialFileName (type, segs, divs, num);
 	LDDocumentPtr f = GetDocument (name);
 
-	if (f != null)
+	if (f != nullptr)
 		return f;
 
 	return GeneratePrimitive (type, segs, divs, num);

mercurial